mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-41094: Fix decoding errors with audit when open files. (GH-21095)
This commit is contained in:
parent
bf2e515fa4
commit
6c6810d989
5 changed files with 35 additions and 14 deletions
|
@ -1415,15 +1415,12 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args)
|
|||
if (name != Py_None) {
|
||||
if (PyUnicode_FSConverter(name, &name2) == 0)
|
||||
return NULL;
|
||||
if (PyBytes_Check(name2))
|
||||
name_str = PyBytes_AS_STRING(name2);
|
||||
else
|
||||
name_str = PyByteArray_AS_STRING(name2);
|
||||
name_str = PyBytes_AS_STRING(name2);
|
||||
} else {
|
||||
name_str = NULL;
|
||||
name2 = NULL;
|
||||
}
|
||||
if (PySys_Audit("ctypes.dlopen", "s", name_str) < 0) {
|
||||
if (PySys_Audit("ctypes.dlopen", "O", name) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
handle = ctypes_dlopen(name_str, mode);
|
||||
|
|
|
@ -379,13 +379,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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue