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

CGIHTTPRequestHandler does not work on windows #47383

Closed
amauryfa opened this issue Jun 18, 2008 · 3 comments
Closed

CGIHTTPRequestHandler does not work on windows #47383

amauryfa opened this issue Jun 18, 2008 · 3 comments
Labels
OS-windows stdlib Python modules in the Lib dir

Comments

@amauryfa
Copy link
Member

BPO 3133
Nosy @amauryfa
Files
  • httpserver.patch
  • 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 2008-06-18.22:20:24.657>
    created_at = <Date 2008-06-18.09:28:31.013>
    labels = ['library', 'OS-windows']
    title = 'CGIHTTPRequestHandler does not work on windows'
    updated_at = <Date 2008-06-18.22:20:24.656>
    user = 'https://github.com/amauryfa'

    bugs.python.org fields:

    activity = <Date 2008-06-18.22:20:24.656>
    actor = 'amaury.forgeotdarc'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-06-18.22:20:24.657>
    closer = 'amaury.forgeotdarc'
    components = ['Library (Lib)', 'Windows']
    creation = <Date 2008-06-18.09:28:31.013>
    creator = 'amaury.forgeotdarc'
    dependencies = []
    files = ['10651']
    hgrepos = []
    issue_num = 3133
    keywords = ['patch']
    message_count = 3.0
    messages = ['68361', '68362', '68379']
    nosy_count = 1.0
    nosy_names = ['amaury.forgeotdarc']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue3133'
    versions = ['Python 3.0']

    @amauryfa
    Copy link
    Member Author

    On windows, test_httpservers fails with the error:

    File "C:\python\py3k\Lib\http\server.py", line 1104, in run_cgi
    exec(open(scriptfile).read(), {"__name__": "__main__"})
    File "<string>", line 3, in <module>
    File "C:\python\py3k\Lib\socket.py", line 222, in write
    return self._sock.send(b)
    TypeError: send() argument 1 must be bytes or read-only buffer, not str

    There are two problems there:

    • Lib/http/server.py still looks for os.popen2 or os.popen3 to start a
      subprocess; these functions have been removed, this code should be
      rewritten using the subprocess module.
    • the fallback method, which exec() the cgi script in the python
      interpreter, fails because sys.stdout should be set to a TextIOWrapper,
      not a binary socket file.

    Certainly the fallback method could be removed: every platform
    implements subprocess nowadays.

    @amauryfa amauryfa added stdlib Python modules in the Lib dir OS-windows labels Jun 18, 2008
    @amauryfa
    Copy link
    Member Author

    The attached patch uses subprocess when fork is not available.
    test_httpservers now passes on windows

    @amauryfa
    Copy link
    Member Author

    Committed change r64389.

    @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
    OS-windows stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant