@@ -1622,14 +1622,14 @@ PyObject *
16221622_PySys_Init (void )
16231623{
16241624 PyObject * m , * sysdict , * version_info ;
1625+ int res ;
16251626
16261627 m = PyModule_Create (& sysmodule );
16271628 if (m == NULL )
16281629 return NULL ;
16291630 sysdict = PyModule_GetDict (m );
16301631#define SET_SYS_FROM_STRING_BORROW (key , value ) \
16311632 do { \
1632- int res; \
16331633 PyObject *v = (value); \
16341634 if (v == NULL) \
16351635 return NULL; \
@@ -1640,7 +1640,6 @@ _PySys_Init(void)
16401640 } while (0)
16411641#define SET_SYS_FROM_STRING (key , value ) \
16421642 do { \
1643- int res; \
16441643 PyObject *v = (value); \
16451644 if (v == NULL) \
16461645 return NULL; \
@@ -1759,6 +1758,9 @@ _PySys_Init(void)
17591758 /* prevent user from creating new instances */
17601759 VersionInfoType .tp_init = NULL ;
17611760 VersionInfoType .tp_new = NULL ;
1761+ res = PyDict_DelItemString (VersionInfoType .tp_dict , "__new__" );
1762+ if (res < 0 && PyErr_ExceptionMatches (PyExc_KeyError ))
1763+ PyErr_Clear ();
17621764
17631765 /* implementation */
17641766 SET_SYS_FROM_STRING ("implementation" , make_impl_info (version_info ));
@@ -1772,7 +1774,9 @@ _PySys_Init(void)
17721774 /* prevent user from creating new instances */
17731775 FlagsType .tp_init = NULL ;
17741776 FlagsType .tp_new = NULL ;
1775-
1777+ res = PyDict_DelItemString (FlagsType .tp_dict , "__new__" );
1778+ if (res < 0 && PyErr_ExceptionMatches (PyExc_KeyError ))
1779+ PyErr_Clear ();
17761780
17771781#if defined(MS_WINDOWS )
17781782 /* getwindowsversion */
@@ -1783,6 +1787,9 @@ _PySys_Init(void)
17831787 /* prevent user from creating new instances */
17841788 WindowsVersionType .tp_init = NULL ;
17851789 WindowsVersionType .tp_new = NULL ;
1790+ res = PyDict_DelItemString (WindowsVersionType .tp_dict , "__new__" );
1791+ if (res < 0 && PyErr_ExceptionMatches (PyExc_KeyError ))
1792+ PyErr_Clear ();
17861793#endif
17871794
17881795 /* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */
0 commit comments