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
subprocess: surrogates of the error message (Python implementation on non-Windows) #52713
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=Noneclosed_at=<Date2010-04-23.20:22:34.391>created_at=<Date2010-04-20.12:02:54.306>labels= ['library', 'expert-unicode']
title='subprocess: surrogates of the error message (Python implementation on non-Windows)'updated_at=<Date2010-04-23.20:22:34.390>user='https://github.com/vstinner'
On a non-Windows OS where _posixsubprocess is missing (subprocess uses the pure Python implementation), if the child fails with a Python exception and the exception message contains a surrogate character, message.encode() fails silently (exception while processing exceptions are just ignored).
Surrogates should be passed to the parent process: surrogatepass can be used for that. Attached patch implements this idea with an unit test.
--
_posixsubprocess is not concerned because it writes an empty message for OSError (the parent process calls os.strerror() to get the message) or "Exception occurred in preexec_fn." (pure ASCII string) for RuntimeError.
On Windows, _subprocess.CreateProcess() calls PyErr_SetFromWindowsErr() on failure without the filename. So there is no surrogates here.
Activity
vstinner commentedon Apr 20, 2010
On a non-Windows OS where _posixsubprocess is missing (subprocess uses the pure Python implementation), if the child fails with a Python exception and the exception message contains a surrogate character, message.encode() fails silently (exception while processing exceptions are just ignored).
Surrogates should be passed to the parent process: surrogatepass can be used for that. Attached patch implements this idea with an unit test.
--
_posixsubprocess is not concerned because it writes an empty message for OSError (the parent process calls os.strerror() to get the message) or "Exception occurred in preexec_fn." (pure ASCII string) for RuntimeError.
On Windows, _subprocess.CreateProcess() calls PyErr_SetFromWindowsErr() on failure without the filename. So there is no surrogates here.
vstinner commentedon Apr 23, 2010
Commited in py3k (r80413), blocked in 3.1 (r80414).
Python 3.1 uses pickle to encode the traceback and pickle supports surrogates (see bpo-8383).