bpo-32962: python-gdb catchs UnicodeDecodeError (GH-7693) · python/cpython@d22fc0b (original) (raw)
`@@ -270,12 +270,13 @@ def is_optimized_out(self):
`
270
270
``
271
271
`def safe_tp_name(self):
`
272
272
`try:
`
273
``
`-
return self.type().field('tp_name').string()
`
274
``
`-
except NullPyObjectPtr:
`
275
``
`-
NULL tp_name?
`
276
``
`-
return 'unknown'
`
277
``
`-
except RuntimeError:
`
278
``
`-
Can't even read the object at all?
`
``
273
`+
ob_type = self.type()
`
``
274
`+
tp_name = ob_type.field('tp_name')
`
``
275
`+
return tp_name.string()
`
``
276
`+
NullPyObjectPtr: NULL tp_name?
`
``
277
`+
RuntimeError: Can't even read the object at all?
`
``
278
`+
UnicodeDecodeError: Failed to decode tp_name bytestring
`
``
279
`+
except (NullPyObjectPtr, RuntimeError, UnicodeDecodeError):
`
279
280
`return 'unknown'
`
280
281
``
281
282
`def proxyval(self, visited):
`
`@@ -349,7 +350,9 @@ def subclass_from_type(cls, t):
`
349
350
`try:
`
350
351
`tp_name = t.field('tp_name').string()
`
351
352
`tp_flags = int(t.field('tp_flags'))
`
352
``
`-
except RuntimeError:
`
``
353
`+
RuntimeError: NULL pointers
`
``
354
`+
UnicodeDecodeError: string() fails to decode the bytestring
`
``
355
`+
except (RuntimeError, UnicodeDecodeError):
`
353
356
`# Handle any kind of error e.g. NULL ptrs by simply using the base
`
354
357
`# class
`
355
358
`return cls
`
`@@ -617,7 +620,10 @@ class PyCFunctionObjectPtr(PyObjectPtr):
`
617
620
``
618
621
`def proxyval(self, visited):
`
619
622
`m_ml = self.field('m_ml') # m_ml is a (PyMethodDef*)
`
620
``
`-
ml_name = m_ml['ml_name'].string()
`
``
623
`+
try:
`
``
624
`+
ml_name = m_ml['ml_name'].string()
`
``
625
`+
except UnicodeDecodeError:
`
``
626
`+
ml_name = '<ml_name:UnicodeDecodeError>'
`
621
627
``
622
628
`pyop_m_self = self.pyop_field('m_self')
`
623
629
`if pyop_m_self.is_null():
`
`@@ -1340,13 +1346,13 @@ def safe_name(self):
`
1340
1346
`try:
`
1341
1347
`name = self.field('descr')['d_base']['name'].string()
`
1342
1348
`return repr(name)
`
1343
``
`-
except (NullPyObjectPtr, RuntimeError):
`
``
1349
`+
except (NullPyObjectPtr, RuntimeError, UnicodeDecodeError):
`
1344
1350
`return ''
`
1345
1351
``
1346
1352
`def safe_tp_name(self):
`
1347
1353
`try:
`
1348
1354
`return self.field('self')['ob_type']['tp_name'].string()
`
1349
``
`-
except (NullPyObjectPtr, RuntimeError):
`
``
1355
`+
except (NullPyObjectPtr, RuntimeError, UnicodeDecodeError):
`
1350
1356
`return ''
`
1351
1357
``
1352
1358
`def safe_self_addresss(self):
`