Ticket #28 (closed enhancement: invalid)

Opened 2 years ago

Last modified 2 years ago

Fix assertion in write() of BaseFCGIServer

Reported by: trac Assigned to: asaddi
Priority: critical Milestone: flup.server-1.0.1
Component: flup.server Version: 1.0
Keywords: Cc:

Description

Inside the write() method of the BaseFCGIServer class there is an assertion on the first line:

assert type(data) is str, 'write() argument must be string'

In order to support subclasses of str, the assertion should be modified like this:

assert isinstance(data, str)

This modification is already tested using Django and flup.

Change History

11/30/07 12:56:16 changed by asaddi

From the following: http://www.python.org/dev/peps/pep-0333/#unicode-issues

Specifically,

Again, all strings referred to in this specification must be of type str or StringType, and must not be of type unicode or UnicodeType.

My interpretation of this is "type(data) is str". Additionally, from wsgiref, I see:

    def write(self, data):
        """'write()' callable as specified by PEP 333"""

        assert type(data) is StringType,"write() argument must be string"

        ...

I don't believe Django's usage of a string subclass is spec-compliant. Although I don't see why it should be this strict, I defer to the spec and the behavior of wsgiref's simple_server. If you disagree, please bring it up with web-sig and/or Philip J. Eby.

12/03/07 11:57:16 changed by asaddi

12/15/07 08:05:29 changed by asaddi

  • status changed from new to closed.
  • resolution set to invalid.

Closing with resolution of Django ticket.