summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2022-03-01 23:09:28 (GMT)
committerGitHub <noreply@github.com>2022-03-01 23:09:28 (GMT)
commit9833bb91e4d5c2606421d9ec2085f5c2dfb6f72c (patch)
treecae368d226475abbeae93afd07081e78a7539cd9 /Tools
parent21099fc064c61d59c936a2f6a0db3e07cd5c8de5 (diff)
downloadcpython-9833bb91e4d5c2606421d9ec2085f5c2dfb6f72c.zip
cpython-9833bb91e4d5c2606421d9ec2085f5c2dfb6f72c.tar.gz
cpython-9833bb91e4d5c2606421d9ec2085f5c2dfb6f72c.tar.bz2
bpo-46845: Reduce dict size when all keys are Unicode (GH-31564)
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/gdb/libpython.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index e3d73bc..8b227e6 100755
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -787,12 +787,6 @@ class PyDictObjectPtr(PyObjectPtr):
def _get_entries(keys):
dk_nentries = int(keys['dk_nentries'])
dk_size = 1<<int(keys['dk_log2_size'])
- try:
- # <= Python 3.5
- return keys['dk_entries'], dk_size
- except RuntimeError:
- # >= Python 3.6
- pass
if dk_size <= 0xFF:
offset = dk_size
@@ -805,7 +799,10 @@ class PyDictObjectPtr(PyObjectPtr):
ent_addr = keys['dk_indices'].address
ent_addr = ent_addr.cast(_type_unsigned_char_ptr()) + offset
- ent_ptr_t = gdb.lookup_type('PyDictKeyEntry').pointer()
+ if int(keys['dk_kind']) == 0: # DICT_KEYS_GENERAL
+ ent_ptr_t = gdb.lookup_type('PyDictKeyEntry').pointer()
+ else:
+ ent_ptr_t = gdb.lookup_type('PyDictUnicodeEntry').pointer()
ent_addr = ent_addr.cast(ent_ptr_t)
return ent_addr, dk_nentries