Skip to content

Commit 1b41c7b

Browse files
authored
gh-152132: Enhance Py_RunMain() and fix bugs (#153461)
* Check for signals more often. Previously, a pending exception could be removed by PyErr_Clear(). * Only call _PyInterpreterState_SetNotRunningMain() if _PyInterpreterState_SetRunningMain() has been called. * Add pymain_error() and pyrun_error(): write the error message to sys.stderr instead of the C stream stderr. * Convert _PyPathConfig_UpdateGlobal() PyStatus error to an exception. * Simplify pymain_run_startup(): avoid strerror() which is decoded from the wrong encoding. Instead display the exception, Py_fopen() raises an OSError with the path object (and can raise other exceptions). * Add pymain_set_path0() function. * Add _PySys_FormatV() function.
1 parent 87e5aac commit 1b41c7b

5 files changed

Lines changed: 231 additions & 136 deletions

File tree

Include/internal/pycore_sysmodule.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ extern int _PySys_SetIntMaxStrDigits(int maxdigits);
2121

2222
extern int _PySysRemoteDebug_SendExec(int pid, int tid, const char *debugger_script_path);
2323

24+
extern void _PySys_FormatV(
25+
PyObject *key,
26+
FILE *fp,
27+
const char *format,
28+
va_list va);
29+
2430
#ifdef __cplusplus
2531
}
2632
#endif

Lib/test/test_cmd_line.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def test_undecodable_code(self):
314314
# decodable from ASCII) and run_command() failed on
315315
# PyUnicode_AsUTF8String(). This is the expected behaviour on
316316
# Linux.
317-
pattern = b"Unable to decode the command from the command line:"
317+
pattern = b"python: Unable to decode the command from the command line:"
318318
elif p.returncode == 0:
319319
# _Py_char2wchar() decoded b'\xff' as '\xff' even if the locale is
320320
# C and the locale encoding is ASCII. It occurs on FreeBSD, Solaris

0 commit comments

Comments
 (0)