diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-06-24 16:45:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-24 16:45:38 (GMT) |
commit | 1813d318fd4e517042415fa4f59fe8668c17a235 (patch) | |
tree | 0641b3dab4350db252cc85bfc5177e494a66e87a /Modules/main.c | |
parent | fb4a6241054ad6b7f24d1b32af6827e02936d568 (diff) | |
download | cpython-1813d318fd4e517042415fa4f59fe8668c17a235.zip cpython-1813d318fd4e517042415fa4f59fe8668c17a235.tar.gz cpython-1813d318fd4e517042415fa4f59fe8668c17a235.tar.bz2 |
bpo-41094: Fix decoding errors with audit when open files. (GH-21095)
(cherry picked from commit 6c6810d98979add7a89391c3c38990d0859f7a29)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Modules/main.c b/Modules/main.c index 2a360b5..788bc11 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -391,13 +391,20 @@ pymain_run_startup(PyConfig *config, PyCompilerFlags *cf, int *exitcode) if (startup == NULL) { return 0; } - if (PySys_Audit("cpython.run_startup", "s", startup) < 0) { + PyObject *startup_obj = PyUnicode_DecodeFSDefault(startup); + if (startup_obj == NULL) { return pymain_err_print(exitcode); } + if (PySys_Audit("cpython.run_startup", "O", startup_obj) < 0) { + Py_DECREF(startup_obj); + return pymain_err_print(exitcode); + } + Py_DECREF(startup_obj); FILE *fp = _Py_fopen(startup, "r"); if (fp == NULL) { int save_errno = errno; + PyErr_Clear(); PySys_WriteStderr("Could not open PYTHONSTARTUP\n"); errno = save_errno; |