@@ -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 *
@@ -1481,21 +1483,25 @@ list_builtin_module_names(void)
14811483static PyObject *
14821484get_warnoptions (void )
14831485{
1484- PyObject * warnoptions = PyThreadState_GET () -> interp -> warnoptions ;
1486+ PyObject * warnoptions = _PySys_GetObjectId ( & PyId_warnoptions ) ;
14851487 if (warnoptions == NULL || !PyList_Check (warnoptions )) {
14861488 Py_XDECREF (warnoptions );
14871489 warnoptions = PyList_New (0 );
14881490 if (warnoptions == NULL )
14891491 return NULL ;
1490- PyThreadState_GET ()-> interp -> warnoptions = warnoptions ;
1492+ if (_PySys_SetObjectId (& PyId_warnoptions , warnoptions )) {
1493+ Py_DECREF (warnoptions );
1494+ return NULL ;
1495+ }
1496+ Py_DECREF (warnoptions );
14911497 }
14921498 return warnoptions ;
14931499}
14941500
14951501void
14961502PySys_ResetWarnOptions (void )
14971503{
1498- PyObject * warnoptions = PyThreadState_GET () -> interp -> warnoptions ;
1504+ PyObject * warnoptions = _PySys_GetObjectId ( & PyId_warnoptions ) ;
14991505 if (warnoptions == NULL || !PyList_Check (warnoptions ))
15001506 return ;
15011507 PyList_SetSlice (warnoptions , 0 , PyList_GET_SIZE (warnoptions ), NULL );
@@ -1524,20 +1530,24 @@ PySys_AddWarnOption(const wchar_t *s)
15241530int
15251531PySys_HasWarnOptions (void )
15261532{
1527- PyObject * warnoptions = PyThreadState_GET () -> interp -> warnoptions ;
1533+ PyObject * warnoptions = _PySys_GetObjectId ( & PyId_warnoptions ) ;
15281534 return (warnoptions != NULL && (PyList_Size (warnoptions ) > 0 )) ? 1 : 0 ;
15291535}
15301536
15311537static PyObject *
15321538get_xoptions (void )
15331539{
1534- PyObject * xoptions = PyThreadState_GET () -> interp -> xoptions ;
1540+ PyObject * xoptions = _PySys_GetObjectId ( & PyId__xoptions ) ;
15351541 if (xoptions == NULL || !PyDict_Check (xoptions )) {
15361542 Py_XDECREF (xoptions );
15371543 xoptions = PyDict_New ();
15381544 if (xoptions == NULL )
15391545 return NULL ;
1540- PyThreadState_GET ()-> interp -> xoptions = xoptions ;
1546+ if (_PySys_SetObjectId (& PyId__xoptions , xoptions )) {
1547+ Py_DECREF (xoptions );
1548+ return NULL ;
1549+ }
1550+ Py_DECREF (xoptions );
15411551 }
15421552 return xoptions ;
15431553}
@@ -2086,16 +2096,6 @@ _PySys_BeginInit(void)
20862096#undef SET_SYS_FROM_STRING_BORROW
20872097
20882098/* Updating the sys namespace, returning integer error codes */
2089- #define SET_SYS_FROM_STRING_BORROW_INT_RESULT (key , value ) \
2090- do { \
2091- PyObject *v = (value); \
2092- if (v == NULL) \
2093- return -1; \
2094- res = PyDict_SetItemString(sysdict, key, v); \
2095- if (res < 0) { \
2096- return res; \
2097- } \
2098- } while (0)
20992099#define SET_SYS_FROM_STRING_INT_RESULT (key , value ) \
21002100 do { \
21012101 PyObject *v = (value); \
@@ -2140,23 +2140,18 @@ _PySys_EndInit(PyObject *sysdict)
21402140 SET_SYS_FROM_STRING_INT_RESULT ("base_exec_prefix" ,
21412141 PyUnicode_FromWideChar (Py_GetExecPrefix (), -1 ));
21422142
2143- PyObject * warnoptions = get_warnoptions ();
2144- if (warnoptions == NULL )
2143+ if (get_warnoptions () == NULL )
21452144 return -1 ;
2146- SET_SYS_FROM_STRING_BORROW_INT_RESULT ("warnoptions" , warnoptions );
21472145
2148- PyObject * xoptions = get_xoptions ();
2149- if (xoptions == NULL )
2146+ if (get_xoptions () == NULL )
21502147 return -1 ;
2151- SET_SYS_FROM_STRING_BORROW_INT_RESULT ("_xoptions" , xoptions );
21522148
21532149 if (PyErr_Occurred ())
21542150 return -1 ;
21552151 return 0 ;
21562152}
21572153
21582154#undef SET_SYS_FROM_STRING_INT_RESULT
2159- #undef SET_SYS_FROM_STRING_BORROW_INT_RESULT
21602155
21612156static PyObject *
21622157makepathobject (const wchar_t * path , wchar_t delim )
0 commit comments