Skip to content

Commit 0c4fbff

Browse files
author
Victor Stinner
committed
libpython.py: defer call to gdb.lookup_type('PyUnicodeObject')
The lookup fails at startup if Python is linked to a shared library.
1 parent 1659b83 commit 0c4fbff

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Tools/gdb/libpython.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
_type_unsigned_short_ptr = gdb.lookup_type('unsigned short').pointer()
5454
_type_unsigned_int_ptr = gdb.lookup_type('unsigned int').pointer()
5555

56-
_is_pep393 = 'data' in [f.name for f in gdb.lookup_type('PyUnicodeObject').target().fields()]
56+
# value computed later, see PyUnicodeObjectPtr.proxy()
57+
_is_pep393 = None
5758

5859
SIZEOF_VOID_P = _type_void_ptr.sizeof
5960

@@ -1123,6 +1124,10 @@ def char_width(self):
11231124
return _type_Py_UNICODE.sizeof
11241125

11251126
def proxyval(self, visited):
1127+
global _is_pep393
1128+
if _is_pep393 is None:
1129+
fields = gdb.lookup_type('PyUnicodeObject').target().fields()
1130+
_is_pep393 = 'data' in [f.name for f in fields]
11261131
if _is_pep393:
11271132
# Python 3.3 and newer
11281133
may_have_surrogates = False

0 commit comments

Comments
 (0)