Skip to content

HTTP request handler: check sys.stderr != None before logging #89057

Description

@xiaolingbao
BPO 44894

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 = None
created_at = <Date 2021-08-11.23:56:49.134>
labels = ['type-bug', 'library', '3.9']
title = 'HTTP request handler: check sys.stderr != None before logging'
updated_at = <Date 2021-08-13.23:02:22.093>
user = 'https://bugs.python.org/xiaolingbao'

bugs.python.org fields:

activity = <Date 2021-08-13.23:02:22.093>
actor = 'terry.reedy'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2021-08-11.23:56:49.134>
creator = 'xiaolingbao'
dependencies = []
files = []
hgrepos = []
issue_num = 44894
keywords = []
message_count = 2.0
messages = ['399423', '399470']
nosy_count = 1.0
nosy_names = ['xiaolingbao']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue44894'
versions = ['Python 3.9']

Linked PRs

Activity

  1. xiaolingbao commented on Aug 11, 2021

    xiaolingbaomannequin
    MannequinAuthor

    This is about HTTP server library (found on Windows with python 3.9, not sure other platforms).

    In file Lib\http\server.py, we define:
    class BaseHTTPRequestHandler(...):
    def log_message(self, format, *args):
    sys.stderr.write(...)

    In certain cases, sys.stderr could be None and thus this function call will throw exception. My use case: I created an XMLRPC server (SimpleXMLRPCRequestHandler derives from BaseHTTPRequestHandler) within a Windows service. I guess with that combination, sys.stderr will be None. When this issue happens, the client got empty response and not much error log for debugging.

    I can upload sample source code files if needed.

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Aug 11, 2021
  3. xiaolingbao commented on Aug 12, 2021

    xiaolingbaomannequin
    MannequinAuthor

    It looks https://bugs.python.org/issue43348 has the same root cause as this one. When running with pythonservice.exe or pythonw.exe, sys.stderr will be None and thus causing crash when logging messages (calling sys.stderr.write).

  4. changed the title [-]HTTP request handler should check sys.stderr for None before use for logging[/-] [+]HTTP request handler: check sys.stderr != None before logging[/+] on Aug 13, 2021
  5. changed the title [-]HTTP request handler should check sys.stderr for None before use for logging[/-] [+]HTTP request handler: check sys.stderr != None before logging[/+] on Aug 13, 2021
  6. transferred this issue fromon Apr 10, 2022
  7. moved this from Todo to In Progress in HTTP issueson Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions