Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ae247a5f
Commit
ae247a5f
authored
Oct 21, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #16220: wsgiref now always calls close() on an iterable response.
Patch by Brent Tubbs.
parent
2778d0d1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
36 deletions
+29
-36
Lib/test/test_wsgiref.py
Lib/test/test_wsgiref.py
+18
-31
Lib/wsgiref/handlers.py
Lib/wsgiref/handlers.py
+7
-5
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_wsgiref.py
View file @
ae247a5f
...
...
@@ -656,40 +656,27 @@ class HandlerTests(TestCase):
b"data"
,
h
.
stdout
.
getvalue
())
# This epilogue is needed for compatibility with the Python 2.5 regrtest module
def
testCloseOnError
(
self
):
side_effects
=
{
'close_called'
:
False
}
MSG
=
b"Some output has been sent"
def
error_app
(
e
,
s
):
s
(
"200 OK"
,[])(
MSG
)
class
CrashyIterable
(
object
):
def
__iter__
(
self
):
while
True
:
yield
b'blah'
raise
AssertionError
(
"This should be caught by handler"
)
def
close
(
self
):
side_effects
[
'close_called'
]
=
True
return
CrashyIterable
()
h
=
ErrorHandler
()
h
.
run
(
error_app
)
self
.
assertEqual
(
side_effects
[
'close_called'
],
True
)
def
test_main
():
support
.
run_unittest
(
__name__
)
if
__name__
==
"__main__"
:
test_main
()
# the above lines intentionally left blank
Lib/wsgiref/handlers.py
View file @
ae247a5f
...
...
@@ -174,11 +174,13 @@ class BaseHandler:
in the event loop to iterate over the data, and to call
'self.close()' once the response is finished.
"""
if
not
self
.
result_is_file
()
or
not
self
.
sendfile
():
for
data
in
self
.
result
:
self
.
write
(
data
)
self
.
finish_content
()
self
.
close
()
try
:
if
not
self
.
result_is_file
()
or
not
self
.
sendfile
():
for
data
in
self
.
result
:
self
.
write
(
data
)
self
.
finish_content
()
finally
:
self
.
close
()
def
get_scheme
(
self
):
...
...
Misc/ACKS
View file @
ae247a5f
...
...
@@ -1067,6 +1067,7 @@ Richard Townsend
Laurence Tratt
John Tromp
Jason Trowbridge
Brent Tubbs
Anthony Tuininga
Erno Tukia
David Turner
...
...
Misc/NEWS
View file @
ae247a5f
...
...
@@ -132,6 +132,9 @@ Core and Builtins
Library
-------
- Issue #16220: wsgiref now always calls close() on an iterable response.
Patch by Brent Tubbs.
- Issue #16270: urllib may hang when used for retrieving files via FTP by using
a context manager. Patch by Giampaolo Rodola'.
...
...
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