diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-12-07 23:08:22 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-12-07 23:08:22 (GMT) |
commit | 0c4fbff6a72164ed18146fbc05d4601eb8881dc5 (patch) | |
tree | 09832e253d569ce5384f627bab97d4f62a8b9ff7 | |
parent | 1659b83b1d976aa0b938e347e5bf9273ebd0c7a4 (diff) | |
download | cpython-0c4fbff6a72164ed18146fbc05d4601eb8881dc5.zip cpython-0c4fbff6a72164ed18146fbc05d4601eb8881dc5.tar.gz cpython-0c4fbff6a72164ed18146fbc05d4601eb8881dc5.tar.bz2 |
libpython.py: defer call to gdb.lookup_type('PyUnicodeObject')
The lookup fails at startup if Python is linked to a shared library.
-rw-r--r-- | Tools/gdb/libpython.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py index 1e38c26..6972b9b 100644 --- a/Tools/gdb/libpython.py +++ b/Tools/gdb/libpython.py @@ -53,7 +53,8 @@ _type_size_t = gdb.lookup_type('size_t') _type_unsigned_short_ptr = gdb.lookup_type('unsigned short').pointer() _type_unsigned_int_ptr = gdb.lookup_type('unsigned int').pointer() -_is_pep393 = 'data' in [f.name for f in gdb.lookup_type('PyUnicodeObject').target().fields()] +# value computed later, see PyUnicodeObjectPtr.proxy() +_is_pep393 = None SIZEOF_VOID_P = _type_void_ptr.sizeof @@ -1123,6 +1124,10 @@ class PyUnicodeObjectPtr(PyObjectPtr): return _type_Py_UNICODE.sizeof def proxyval(self, visited): + global _is_pep393 + if _is_pep393 is None: + fields = gdb.lookup_type('PyUnicodeObject').target().fields() + _is_pep393 = 'data' in [f.name for f in fields] if _is_pep393: # Python 3.3 and newer may_have_surrogates = False |