You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HTTP request handler: check sys.stderr != None before logging #89057
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.
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).
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
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
Activity
xiaolingbao commentedon Aug 11, 2021
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.
xiaolingbao commentedon Aug 12, 2021
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).
[-]HTTP request handler should check sys.stderr for None before use for logging[/-][+]HTTP request handler: check sys.stderr != None before logging[/+][-]HTTP request handler should check sys.stderr for None before use for logging[/-][+]HTTP request handler: check sys.stderr != None before logging[/+]