Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
fe19e932
Commit
fe19e932
authored
Oct 15, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Format the status code as a str on Python 3. Fixes #664.
parent
38e85ece
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
2 deletions
+21
-2
changelog.rst
changelog.rst
+2
-0
gevent/pywsgi.py
gevent/pywsgi.py
+5
-1
greentest/test__pywsgi.py
greentest/test__pywsgi.py
+14
-1
No files found.
changelog.rst
View file @
fe19e932
...
...
@@ -25,6 +25,8 @@
when logging) are much lighter weight. For example, they no longer
allocate and then delete a :class:`~gevent.lock.Semaphore`, which is
especially important for PyPy.
- Request logging by :mod:`gevent.pywsgi` formats the status code
correctly on Python 3. Reported in :issue:`664` by Kevin Chen.
.. _details: https://mail.python.org/pipermail/cython-devel/2015-October/004571.html
...
...
gevent/pywsgi.py
View file @
fe19e932
...
...
@@ -738,6 +738,7 @@ class WSGIHandler(object):
code
=
int
(
status
.
split
(
' '
,
1
)[
0
])
self
.
status
=
status
if
not
PY3
else
status
.
encode
(
"latin-1"
)
self
.
_orig_status
=
status
# Preserve the native string for logging
self
.
response_headers
=
response_headers
self
.
code
=
code
...
...
@@ -784,7 +785,10 @@ class WSGIHandler(object):
client_address
or
'-'
,
now
,
getattr
(
self
,
'requestline'
,
''
),
(
getattr
(
self
,
'status'
,
None
)
or
'000'
).
split
()[
0
],
# Use the native string version of the status, saved so we don't have to
# decode. But fallback to the encoded 'status' in case of subclasses
# (Is that really necessary? At least there's no overhead.)
(
getattr
(
self
,
'_orig_status'
,
None
)
or
getattr
(
self
,
'status'
,
None
)
or
'000'
).
split
()[
0
],
length
,
delta
)
...
...
greentest/test__pywsgi.py
View file @
fe19e932
...
...
@@ -1444,7 +1444,7 @@ class Test414(TestCase):
read_http
(
fd
,
code
=
414
)
class
Test
663
(
TestCase
):
class
Test
Logging
(
TestCase
):
# Something that gets wrapped in a LoggingLogAdapter
class
Logger
(
object
):
...
...
@@ -1464,6 +1464,13 @@ class Test663(TestCase):
def
init_logger
(
self
):
return
self
.
Logger
()
@
staticmethod
def
application
(
env
,
start_response
):
start_response
(
'200 OK'
,
[(
'Content-Type'
,
'text/plain'
)])
return
[
b'hello'
]
# Tests for issue #663
def
test_proxy_methods_on_log
(
self
):
# An object that looks like a logger gets wrapped
# with a proxy that
...
...
@@ -1481,6 +1488,12 @@ class Test663(TestCase):
del
self
.
server
.
log
.
thing
self
.
assertEqual
(
self
.
server
.
log
.
get_thing
(),
None
)
def
test_status_log
(
self
):
# Issue 664: Make sure we format the status line as a string
self
.
urlopen
()
self
.
assertTrue
(
'"GET / HTTP/1.1" 200 '
in
self
.
server
.
log
.
logged
[
1
],
self
.
server
.
log
.
logged
[
1
])
del
CommonTests
if
__name__
==
'__main__'
:
...
...
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