@@ -36,12 +36,14 @@ extern const char *PyWin_DLLVersionString;
3636
3737_Py_IDENTIFIER (_ );
3838_Py_IDENTIFIER (__sizeof__ );
39+ _Py_IDENTIFIER (_xoptions );
3940_Py_IDENTIFIER (buffer );
4041_Py_IDENTIFIER (builtins );
4142_Py_IDENTIFIER (encoding );
4243_Py_IDENTIFIER (path );
4344_Py_IDENTIFIER (stdout );
4445_Py_IDENTIFIER (stderr );
46+ _Py_IDENTIFIER (warnoptions );
4547_Py_IDENTIFIER (write );
4648
4749PyObject *
@@ -1479,21 +1481,25 @@ list_builtin_module_names(void)
14791481static PyObject *
14801482get_warnoptions (void )
14811483{
1482- PyObject * warnoptions = PyThreadState_GET () -> interp -> warnoptions ;
1484+ PyObject * warnoptions = _PySys_GetObjectId ( & PyId_warnoptions ) ;
14831485 if (warnoptions == NULL || !PyList_Check (warnoptions )) {
14841486 Py_XDECREF (warnoptions );
14851487 warnoptions = PyList_New (0 );
14861488 if (warnoptions == NULL )
14871489 return NULL ;
1488- PyThreadState_GET ()-> interp -> warnoptions = warnoptions ;
1490+ if (_PySys_SetObjectId (& PyId_warnoptions , warnoptions )) {
1491+ Py_DECREF (warnoptions );
1492+ return NULL ;
1493+ }
1494+ Py_DECREF (warnoptions );
14891495 }
14901496 return warnoptions ;
14911497}
14921498
14931499void
14941500PySys_ResetWarnOptions (void )
14951501{
1496- PyObject * warnoptions = PyThreadState_GET () -> interp -> warnoptions ;
1502+ PyObject * warnoptions = _PySys_GetObjectId ( & PyId_warnoptions ) ;
14971503 if (warnoptions == NULL || !PyList_Check (warnoptions ))
14981504 return ;
14991505 PyList_SetSlice (warnoptions , 0 , PyList_GET_SIZE (warnoptions ), NULL );
@@ -1522,20 +1528,24 @@ PySys_AddWarnOption(const wchar_t *s)
15221528int
15231529PySys_HasWarnOptions (void )
15241530{
1525- PyObject * warnoptions = PyThreadState_GET () -> interp -> warnoptions ;
1531+ PyObject * warnoptions = _PySys_GetObjectId ( & PyId_warnoptions ) ;
15261532 return (warnoptions != NULL && (PyList_Size (warnoptions ) > 0 )) ? 1 : 0 ;
15271533}
15281534
15291535static PyObject *
15301536get_xoptions (void )
15311537{
1532- PyObject * xoptions = PyThreadState_GET () -> interp -> xoptions ;
1538+ PyObject * xoptions = _PySys_GetObjectId ( & PyId__xoptions ) ;
15331539 if (xoptions == NULL || !PyDict_Check (xoptions )) {
15341540 Py_XDECREF (xoptions );
15351541 xoptions = PyDict_New ();
15361542 if (xoptions == NULL )
15371543 return NULL ;
1538- PyThreadState_GET ()-> interp -> xoptions = xoptions ;
1544+ if (_PySys_SetObjectId (& PyId__xoptions , xoptions )) {
1545+ Py_DECREF (xoptions );
1546+ return NULL ;
1547+ }
1548+ Py_DECREF (xoptions );
15391549 }
15401550 return xoptions ;
15411551}
@@ -2084,16 +2094,6 @@ _PySys_BeginInit(void)
20842094#undef SET_SYS_FROM_STRING_BORROW
20852095
20862096/* Updating the sys namespace, returning integer error codes */
2087- #define SET_SYS_FROM_STRING_BORROW_INT_RESULT (key , value ) \
2088- do { \
2089- PyObject *v = (value); \
2090- if (v == NULL) \
2091- return -1; \
2092- res = PyDict_SetItemString(sysdict, key, v); \
2093- if (res < 0) { \
2094- return res; \
2095- } \
2096- } while (0)
20972097#define SET_SYS_FROM_STRING_INT_RESULT (key , value ) \
20982098 do { \
20992099 PyObject *v = (value); \
@@ -2138,23 +2138,18 @@ _PySys_EndInit(PyObject *sysdict)
21382138 SET_SYS_FROM_STRING_INT_RESULT ("base_exec_prefix" ,
21392139 PyUnicode_FromWideChar (Py_GetExecPrefix (), -1 ));
21402140
2141- PyObject * warnoptions = get_warnoptions ();
2142- if (warnoptions == NULL )
2141+ if (get_warnoptions () == NULL )
21432142 return -1 ;
2144- SET_SYS_FROM_STRING_BORROW_INT_RESULT ("warnoptions" , warnoptions );
21452143
2146- PyObject * xoptions = get_xoptions ();
2147- if (xoptions == NULL )
2144+ if (get_xoptions () == NULL )
21482145 return -1 ;
2149- SET_SYS_FROM_STRING_BORROW_INT_RESULT ("_xoptions" , xoptions );
21502146
21512147 if (PyErr_Occurred ())
21522148 return -1 ;
21532149 return 0 ;
21542150}
21552151
21562152#undef SET_SYS_FROM_STRING_INT_RESULT
2157- #undef SET_SYS_FROM_STRING_BORROW_INT_RESULT
21582153
21592154static PyObject *
21602155makepathobject (const wchar_t * path , wchar_t delim )
0 commit comments