Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7c59362a
Unverified
Kaydet (Commit)
7c59362a
authored
May 19, 2019
tarafından
Berker Peksag
Kaydeden (comit)
GitHub
May 19, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-29183: Fix double exceptions in wsgiref.handlers.BaseHandler (GH-12914)
üst
f4e1babf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
1 deletion
+38
-1
test_wsgiref.py
Lib/test/test_wsgiref.py
+25
-0
handlers.py
Lib/wsgiref/handlers.py
+10
-1
2019-04-22-22-55-29.bpo-29183.MILvsk.rst
...S.d/next/Library/2019-04-22-22-55-29.bpo-29183.MILvsk.rst
+3
-0
No files found.
Lib/test/test_wsgiref.py
Dosyayı görüntüle @
7c59362a
...
@@ -806,6 +806,31 @@ class HandlerTests(TestCase):
...
@@ -806,6 +806,31 @@ class HandlerTests(TestCase):
self
.
assertFalse
(
stderr
.
getvalue
())
self
.
assertFalse
(
stderr
.
getvalue
())
def
testDontResetInternalStateOnException
(
self
):
class
CustomException
(
ValueError
):
pass
# We are raising CustomException here to trigger an exception
# during the execution of SimpleHandler.finish_response(), so
# we can easily test that the internal state of the handler is
# preserved in case of an exception.
class
AbortingWriter
:
def
write
(
self
,
b
):
raise
CustomException
stderr
=
StringIO
()
environ
=
{
"SERVER_PROTOCOL"
:
"HTTP/1.0"
}
h
=
SimpleHandler
(
BytesIO
(),
AbortingWriter
(),
stderr
,
environ
)
h
.
run
(
hello_app
)
self
.
assertIn
(
"CustomException"
,
stderr
.
getvalue
())
# Test that the internal state of the handler is preserved.
self
.
assertIsNotNone
(
h
.
result
)
self
.
assertIsNotNone
(
h
.
headers
)
self
.
assertIsNotNone
(
h
.
status
)
self
.
assertIsNotNone
(
h
.
environ
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
Lib/wsgiref/handlers.py
Dosyayı görüntüle @
7c59362a
...
@@ -183,7 +183,16 @@ class BaseHandler:
...
@@ -183,7 +183,16 @@ class BaseHandler:
for
data
in
self
.
result
:
for
data
in
self
.
result
:
self
.
write
(
data
)
self
.
write
(
data
)
self
.
finish_content
()
self
.
finish_content
()
finally
:
except
:
# Call close() on the iterable returned by the WSGI application
# in case of an exception.
if
hasattr
(
self
.
result
,
'close'
):
self
.
result
.
close
()
raise
else
:
# We only call close() when no exception is raised, because it
# will set status, result, headers, and environ fields to None.
# See bpo-29183 for more details.
self
.
close
()
self
.
close
()
...
...
Misc/NEWS.d/next/Library/2019-04-22-22-55-29.bpo-29183.MILvsk.rst
0 → 100644
Dosyayı görüntüle @
7c59362a
Fix double exceptions in :class:`wsgiref.handlers.BaseHandler` by calling
its :meth:`~wsgiref.handlers.BaseHandler.close` method only when no
exception is raised.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment