@@ -237,9 +237,9 @@ BaseException_repr(PyObject *op)
237237
238238/* Pickling support */
239239
240- /* Returns dict on success, after having added a __timestamp_ns__ key; NULL
241- otherwise . dict does not have to be self->dict as the getstate use case
242- often uses a copy. No key is added if its value would be 0. */
240+ /* Returns dict on success, after having maybe added a __timestamp_ns__ key;
241+ NULL on error . dict does not have to be self->dict as the getstate use
242+ case often uses a copy. No key is added if its value would be 0. */
243243static PyObject * BaseException_add_timestamp_to_dict (PyBaseExceptionObject * self , PyObject * dict )
244244{
245245 assert (dict != NULL );
@@ -249,7 +249,7 @@ static PyObject* BaseException_add_timestamp_to_dict(PyBaseExceptionObject *self
249249 PyObject * ts = PyLong_FromLongLong (self -> timestamp_ns );
250250 if (!ts )
251251 return NULL ;
252- if (PyDict_SetItemString (dict , " __timestamp_ns__" , ts ) == -1 ) {
252+ if (PyDict_SetItemString (dict , & _Py_ID ( __timestamp_ns__ ) , ts ) == -1 ) {
253253 Py_DECREF (ts );
254254 return NULL ;
255255 }
@@ -1879,21 +1879,6 @@ ImportError_getstate(PyObject *op)
18791879 if (dict == NULL ) {
18801880 return NULL ;
18811881 }
1882- if (self -> name || self -> path || self -> name_from ) {
1883- if (self -> name && PyDict_SetItem (dict , & _Py_ID (name ), self -> name ) < 0 ) {
1884- Py_DECREF (dict );
1885- return NULL ;
1886- }
1887- if (self -> path && PyDict_SetItem (dict , & _Py_ID (path ), self -> path ) < 0 ) {
1888- Py_DECREF (dict );
1889- return NULL ;
1890- }
1891- if (self -> name_from && PyDict_SetItem (dict , & _Py_ID (name_from ), self -> name_from ) < 0 ) {
1892- Py_DECREF (dict );
1893- return NULL ;
1894- }
1895- return dict ;
1896- }
18971882 if (!BaseException_add_timestamp_to_dict ((PyBaseExceptionObject * )self , dict )) {
18981883 Py_DECREF (dict );
18991884 return NULL ;
0 commit comments