[issue10935] wsgiref.handlers.BaseHandler and subclasses of str

Phillip J. Eby report at bugs.python.org
Wed Jan 19 17:43:31 CET 2011


Phillip J. Eby <pje at telecommunity.com> added the comment:

Doesn't matter how unpythonic it is: the spec calls for exact types and has done so for six years already, so it's a bit late to do anything about it.  (And any version of Python that allowed string subclasses was in violation of the spec and therefore buggy.)

In principle, this class could allow non-str objects if and ONLY if they were converted to actual str objects upon receipt -- but they would have to be the *exact* type after this conversion.

If somebody wants to implement that, I have no objection.  But it MUST reject non-basestring input values and values that don't convert to an exact type str.  (IOW, "type(str(x)) is str" must hold.)

To put it another way, the WSGI protocol requires output headers to be of type 'list' where all elements are type 'tuple' and containing two 'str' entries.  The Headers class cannot fulfill this contract if it allows non-conforming input.  So non-conforming input must either be rejected or made to conform.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10935>
_______________________________________


More information about the Python-bugs-list mailing list