[Web-SIG] WSGI for Python 3

Robert Brewer fumanchu at aminus.org
Fri Aug 27 22:04:06 CEST 2010


Paul Davis wrote:
> > Since the major stumbling block, irrespective of other changes,
> > to any sort of agreement is still bytes vs unicode
>
> I ran into this while I was attempting to put together enough code to
> play with a wsgiref2 that ran on both 2.x and 3.x. As Graham has
> deftly pointed out, its a pretty big pain in the rear.
> 
> Specifically, if we specify that all keys in the environ dictionary
> are byte strings, then there's a noticeable amount of pain in trying
> to write code that runs on both platforms. I object to 2to3.py on
> religious grounds, so when I was implementing this I was doing so with
> code that would run unmodified on both 2 and 3.

Religion is what gets us into this mess. Pragmatism will get us out. We
have two options:

 1. Continue to try to write code that runs unmodified on Python 2 and
3, or that runs when 2to3 is applied. There is a morass of corner cases
and state machines that behave differently depending on when you look at
them lurking here. You can all see where that is getting us: nowhere. By
the time you all discover how to write a spec that deals with all the
pain points which 2to3 introduces, Python 2 will be dead and you will
have wasted your time.
 2. Write a Python 3 version of your code. Yes, it's more drudge work.
Suck it up. To ameliorate that, make the Python 3 version the default as
soon as possible. Deprecate the Python 2 branch. Backport features as
necessary to the Python 2 branch (just as Python itself has been doing,
if you notice). If you do that, we can write a WSGI for Python 3 now
that doesn't suffer from any of the complexities of 2to3.


Robert Brewer
fumanchu at aminus.org


More information about the Web-SIG mailing list