Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError in wsgiref.handlers when using CGIHandler #53268

Closed
toxicdav3 mannequin opened this issue Jun 18, 2010 · 3 comments
Closed

TypeError in wsgiref.handlers when using CGIHandler #53268

toxicdav3 mannequin opened this issue Jun 18, 2010 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@toxicdav3
Copy link
Mannequin

toxicdav3 mannequin commented Jun 18, 2010

BPO 9022
Nosy @orsenthil, @bobince
Superseder
  • bpo-10155: Add fixups for encoding problems to wsgiref
  • Files
  • issue9022.patch: Make CGIHandler use byte streams for input/outpu
  • 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 2012-12-25.15:16:34.553>
    created_at = <Date 2010-06-18.00:25:45.756>
    labels = ['type-bug', 'library']
    title = 'TypeError in wsgiref.handlers when using CGIHandler'
    updated_at = <Date 2012-12-25.15:16:34.552>
    user = 'https://bugs.python.org/toxicdav3'

    bugs.python.org fields:

    activity = <Date 2012-12-25.15:16:34.552>
    actor = 'orsenthil'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-12-25.15:16:34.553>
    closer = 'orsenthil'
    components = ['Library (Lib)']
    creation = <Date 2010-06-18.00:25:45.756>
    creator = 'toxicdav3'
    dependencies = []
    files = ['19299']
    hgrepos = []
    issue_num = 9022
    keywords = ['patch']
    message_count = 3.0
    messages = ['108073', '119215', '177666']
    nosy_count = 3.0
    nosy_names = ['orsenthil', 'aclover', 'toxicdav3']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '10155'
    type = 'behavior'
    url = 'https://bugs.python.org/issue9022'
    versions = ['Python 3.2']

    @toxicdav3
    Copy link
    Mannequin Author

    toxicdav3 mannequin commented Jun 18, 2010

    The following code produces a type error, but from what I can tell it does comply with PEP-333. This issue appeared using Python 3.1.1 and 3.1.2 on both Windows and Ubuntu. I have only tried the 32 bit versions. Works fine in Python 2.6.5.12 but I guess thats irrelevant.

    -----

    def application(environ, start_response):
    	start_response('200 OK',[('Content-type','text/html')])
    	return ['<html><body>Hello World!</body></html>']
    	
    from wsgiref.handlers import CGIHandler
    CGIHandler().run(application)

    Traceback (most recent call last):
      File "C:\Python31\lib\wsgiref\handlers.py", line 75, in run
        self.finish_response()
      File "C:\Python31\lib\wsgiref\handlers.py", line 116, in finish_response
        self.write(data)
      File "C:\Python31\lib\wsgiref\handlers.py", line 210, in write
        self.send_headers()
      File "C:\Python31\lib\wsgiref\handlers.py", line 266, in send_headers
        self.send_preamble()
      File "C:\Python31\lib\wsgiref\handlers.py", line 196, in send_preamble
        self._write('Status: %s\r\n' % self.status)
      File "C:\Python31\lib\wsgiref\handlers.py", line 402, in _write
        self.stdout.write(data)
    TypeError: must be str, not bytes

    @toxicdav3 toxicdav3 mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 18, 2010
    @bobince
    Copy link
    Mannequin

    bobince mannequin commented Oct 20, 2010

    Yes, CGIHandler is broken in 3.0-3.1; wsgiref in general has been in limbo until the whole issue of py3k-WSGI is sorted. This seems to be happening now in PEP-3333.

    Attached patch to make CGIHandler use the byte interfaces for stdin/stdout, which allows the write calls to work and provides byte streams to the WSGI application as required by PEP-3333.

    @bobince
    Copy link
    Mannequin

    bobince mannequin commented Dec 17, 2012

    (This issue should be closed; it is superseded by the fix for 10155 in Python 3.2.)

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant