Repository navigation
wsgiref package totally broken #48968
Copy link
Copy link
Closed
Labels
release-blockerstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
| BPO | 4718 |
|---|---|
| Nosy | @pjeby, @pitrou, @benjaminp |
| Files |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = <Date 2009-01-31.23:30:45.350>
created_at = <Date 2008-12-22.11:30:56.870>
labels = ['library', 'type-crash', 'release-blocker']
title = 'wsgiref package totally broken'
updated_at = <Date 2009-01-31.23:30:45.332>
user = 'https://bugs.python.org/hdima'bugs.python.org fields:
activity = <Date 2009-01-31.23:30:45.332>
actor = 'benjamin.peterson'
assignee = 'none'
closed = True
closed_date = <Date 2009-01-31.23:30:45.350>
closer = 'benjamin.peterson'
components = ['Library (Lib)']
creation = <Date 2008-12-22.11:30:56.870>
creator = 'hdima'
dependencies = []
files = ['12447', '12454', '12573', '12577']
hgrepos = []
issue_num = 4718
keywords = ['patch']
message_count = 45.0
messages = ['78171', '78172', '78188', '78192', '78193', '78194', '78196', '78207', '78214', '78215', '78229', '78232', '78235', '78236', '78237', '78241', '78251', '78261', '78269', '78279', '78280', '78292', '78294', '78298', '78304', '78348', '78349', '78351', '78352', '78353', '78354', '78612', '78738', '78787', '78990', '78996', '78997', '78999', '79000', '79002', '79003', '79005', '79013', '79020', '80889']
nosy_count = 5.0
nosy_names = ['pje', 'hdima', 'pitrou', 'benjamin.peterson', 'grahamd']
pr_nums = []
priority = 'release blocker'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue4718'
versions = ['Python 3.0']Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
release-blockerstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Activity
hdima commentedon Dec 22, 2008
It seems the wsgiref package was copied from Python 2.* without any
modifications. There are already 3 issues about that but they only
describe a part of the problem so I decided to start a new one. The
issues was:
http://bugs.python.org/issue3348
http://bugs.python.org/issue3795
http://bugs.python.org/issue4522
The attached patch fix the problem with the following changes:
Fixed headers handling in wsgiref/simple_server.py;
Fixed encoding problems. Now WSGI applications must return iterable
with bytes but start_response() allow status and headers as bytes and as
strings. "wsgi.input" file-like now use BytesIO instead of StringIO;
Fixed tests;
Updated documentation examples;
pitrou commentedon Dec 22, 2008
Phillip, do you have time to take a look at it? We really *must* fix
wsgiref in py3k...
pitrou commentedon Dec 22, 2008
FYI, instead of trying to do exhaustive type checking in _check_type(),
you can just rely on duck typing and catch the TypeError:
pjeby commentedon Dec 22, 2008
If you want to change to using bytes, you're going to have to take it to
the Web-SIG and hash out a revision to PEP-333, which at the moment
requires the use of strings, period.
This has nothing to do with the desirability of bytes vs. strings; I am
sure that if Python had bytes from day 1, bytes would've been the way to
go with it. But simply changing the reference library is not the way to
change the spec.
In the meantime, as far as I'm aware, there are two other patches
pending to address these issues, but I'm not in a position to assess
their readiness/correctness since I have yet to even download Py3K. In
principle, I approve their approaches, so if someone else can handle the
code review, those fixes could in principle be put in without changing
the PEP. But to put *this* patch in, the PEP would have to be changed.
pitrou commentedon Dec 22, 2008
What was called str in 2.x has become the bytes object in py3k.
What was called unicode in 2.x has become str in py3k.
(roughly)
Given the meaning of the term "string" and its possible acceptions have
dramatically changed between 2.x and py3k, how does this patch violate
the PEP more than any other?
Actually, the PEP says:
So, not accepting bytes in py3k is clearly a violation of the PEP!
hdima commentedon Dec 22, 2008
Antoine Pitrou wrote:
Good point! I'll update the patch soon.
hdima commentedon Dec 22, 2008
Antoine Pitrou wrote:
Agreed, moreover it's time for Python 3.0.1 and we need to decide -
apply a patch or just remove wsgiref completely for now. Keep wsgiref
just as nonworking piece of code is the worse solution which can made
questionable all WSGI effort.
Given that old str has been replaced by bytes in Python 3 I think the
patch is a correct implementation of the PEP from the Python 3's point
of view. To avoid confusion note about the meaning of the term *string*
can be added to the PEP later.
hdima commentedon Dec 22, 2008
New version of the patch:
allowing bytes leads to big changes in wsgiref.validate and
wsgiref.handlers;
pjeby commentedon Dec 22, 2008
At 03:37 PM 12/22/2008 +0000, Antoine Pitrou wrote:
On the contrary. Please read the two paragraphs *after* the one you quoted.
pjeby commentedon Dec 22, 2008
To be quite clear: this change requires discussion on the Web-SIG and an
appropriate revision of the PEP. Ideally, the patch should include the
necessary PEP revision.
The Web-SIG discussion regarding a switch to bytes should also take into
consideration the effects of running 2to3 on existing WSGI applications
and/or servers. Will their code be converted to use bytes, or Unicode?
The previous choice to use Unicode was based on source compatibility
across Python implementations, so this shouldn't be thrown out on the
basis of simple expediency.
hdima commentedon Dec 23, 2008
OK, I've attached PEP-333 compatible fixes for wsgiref. I think there is
only one problem remains:
http.server module. I didn't find any restrictions on data returned by
read() method of the "wsgi.input" stream in the PEP. Maybe I've missed
some details?
pitrou commentedon Dec 23, 2008
I don't see anything forbidding bytes objects in those two paragraphs.
22 remaining items
pitrou commentedon Jan 3, 2009
It is committed now in py3k and the 3.0 maintenance branch. Thanks all
for your participation!
pitrou commentedon Jan 3, 2009
Reopening, the patch actually produces failures when run with "python
-bb", that is there are comparisons between str and bytes.
See the errors at the end of
http://www.python.org/dev/buildbot/3.x.stable/ppc%20Debian%20unstable%203.0/builds/26/step-test/0
pitrou commentedon Jan 3, 2009
People, does this patch look ok to you?
hdima commentedon Jan 3, 2009
Antoine Pitrou wrote:
Oh, didn't know about -bb.
The patch looks OK for me.
pitrou commentedon Jan 3, 2009
Le samedi 03 janvier 2009 à 20:24 +0000, Dmitry Vasiliev a écrit :
Well, it's meant to catch potential bugs. str and bytes always compare
unequal in py3k (i.e. "a" != b"a"), so it's good to use -bb when porting
some stuff from 2.x.
There's another problem in that buildbot failure with the environment
variable "NO_PROXY". We'll see if it's still there after the patch.
hdima commentedon Jan 3, 2009
Antoine Pitrou wrote:
Strange error and it seems there is only part of the traceback. I've
already seen such "partially displayed" Python 3 traceback and error
actually can be in very different place.
pitrou commentedon Jan 3, 2009
If you can reproduce such a problem, please open a bug.
hdima commentedon Jan 3, 2009
Antoine Pitrou wrote:
OK, I'll try to reproduce.
hdima commentedon Jan 3, 2009
Attached patch for test_urllib, possible source of the "NO_PROXY" problem.
pitrou commentedon Jan 3, 2009
Nice catch! I've committed the two patches and we'll see whether it
makes the buildbots feel better.
benjaminp commentedon Jan 31, 2009
I assume the buildbots were placated?