mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-108512: Add and use new replacements for PySys_GetObject() (GH-111035)
Add functions PySys_GetAttr(), PySys_GetAttrString(), PySys_GetOptionalAttr() and PySys_GetOptionalAttrString().
This commit is contained in:
parent
b265a7ddeb
commit
bac3fcba5b
32 changed files with 287 additions and 93 deletions
|
@ -10,7 +10,6 @@
|
|||
#include "pycore_pystate.h" // _PyThreadState_GET()
|
||||
#include "pycore_runtime.h" // _Py_ID()
|
||||
#include "pycore_structseq.h" // _PyStructSequence_FiniBuiltin()
|
||||
#include "pycore_sysmodule.h" // _PySys_GetOptionalAttr()
|
||||
#include "pycore_traceback.h" // _PyTraceBack_FromFrame()
|
||||
#include "pycore_unicodeobject.h" // _PyUnicode_Equal()
|
||||
|
||||
|
@ -1570,7 +1569,7 @@ write_unraisable_exc(PyThreadState *tstate, PyObject *exc_type,
|
|||
PyObject *obj)
|
||||
{
|
||||
PyObject *file;
|
||||
if (_PySys_GetOptionalAttr(&_Py_ID(stderr), &file) < 0) {
|
||||
if (PySys_GetOptionalAttr(&_Py_ID(stderr), &file) < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (file == NULL || file == Py_None) {
|
||||
|
@ -1677,7 +1676,7 @@ format_unraisable_v(const char *format, va_list va, PyObject *obj)
|
|||
}
|
||||
|
||||
PyObject *hook;
|
||||
if (_PySys_GetOptionalAttr(&_Py_ID(unraisablehook), &hook) < 0) {
|
||||
if (PySys_GetOptionalAttr(&_Py_ID(unraisablehook), &hook) < 0) {
|
||||
Py_DECREF(hook_args);
|
||||
err_msg_str = NULL;
|
||||
obj = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue