File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -1869,6 +1869,9 @@ ImportError_repr(PyObject *self)
18691869{
18701870 int hasargs = PyTuple_GET_SIZE (((PyBaseExceptionObject * )self )-> args ) != 0 ;
18711871 PyImportErrorObject * exc = PyImportErrorObject_CAST (self );
1872+ if (exc -> name == NULL && exc -> path == NULL ) {
1873+ return BaseException_repr (self );
1874+ }
18721875 PyUnicodeWriter * writer = PyUnicodeWriter_Create (0 );
18731876 if (writer == NULL ) {
18741877 goto error ;
@@ -1880,10 +1883,10 @@ ImportError_repr(PyObject *self)
18801883 if (PyUnicodeWriter_WriteSubstring (
18811884 writer , r , 0 , PyUnicode_GET_LENGTH (r ) - 1 ) < 0 )
18821885 {
1883- Py_XDECREF (r );
1886+ Py_DECREF (r );
18841887 goto error ;
18851888 }
1886- Py_XDECREF (r );
1889+ Py_DECREF (r );
18871890 if (exc -> name ) {
18881891 if (hasargs ) {
18891892 if (PyUnicodeWriter_WriteASCII (writer , ", " , 2 ) < 0 ) {
You can’t perform that action at this time.
0 commit comments