Merge pull request #2728 from komoto48g/fix-introspect
Some checks failed
ci-build / build-source-dist (push) Has been cancelled
ci-build / Build wxPython documentation (push) Has been cancelled
ci-build / build-wheels (arm64, macos-14, 3.10) (push) Has been cancelled
ci-build / build-wheels (arm64, macos-14, 3.11) (push) Has been cancelled
ci-build / build-wheels (arm64, macos-14, 3.12) (push) Has been cancelled
ci-build / build-wheels (arm64, macos-14, 3.13) (push) Has been cancelled
ci-build / build-wheels (arm64, macos-14, 3.9) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.10) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.11) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.12) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.13) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.9) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.10) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.11) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.12) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.13) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.9) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.10) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.11) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.12) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.13) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.9) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.10) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.11) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.12) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.13) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.9) (push) Has been cancelled
ci-build / Publish Python distribution to PyPI (push) Has been cancelled
ci-build / Create GitHub Release and upload source (push) Has been cancelled
ci-build / Upload wheels to snapshot-builds on wxpython.org (push) Has been cancelled

Fix introspect
This commit is contained in:
Scott Talbert
2025-03-31 09:35:31 -04:00
committed by GitHub
2 changed files with 17 additions and 15 deletions

View File

@@ -39,8 +39,11 @@ def getAttributeNames(obj, includeMagic=1, includeSingle=1,
if not hasattrAlwaysReturnsTrue(obj): if not hasattrAlwaysReturnsTrue(obj):
# Add some attributes that don't always get picked up. # Add some attributes that don't always get picked up.
special_attrs = ['__bases__', '__class__', '__dict__', '__name__', special_attrs = ['__bases__', '__class__', '__dict__', '__name__',
'func_closure', 'func_code', 'func_defaults', '__closure__', '__code__', '__defaults__',
'func_dict', 'func_doc', 'func_globals', 'func_name'] '__kwdefaults__', '__globals__', '__qualname__',
'__builtins__', # Added to method attributes in 3.10
'__get__', # Not found in `dir(method)` in 3.11
]
attributes += [attr for attr in special_attrs \ attributes += [attr for attr in special_attrs \
if hasattr(obj, attr)] if hasattr(obj, attr)]
if includeMagic: if includeMagic:
@@ -243,10 +246,12 @@ def getRoot(command, terminator=None):
if tokens and tokens[-1][0] is tokenize.NEWLINE: if tokens and tokens[-1][0] is tokenize.NEWLINE:
# Remove newline. # Remove newline.
del tokens[-1] del tokens[-1]
if tokens and tokens[-1][0] is tokenize.NL:
# Remove non-logical newline.
del tokens[-1]
if not tokens: if not tokens:
return '' return ''
if terminator == '.' and \ if tokens[-1][1] != '.' or tokens[-1][0] is not tokenize.OP:
(tokens[-1][1] != '.' or tokens[-1][0] is not tokenize.OP):
# Trap decimals in numbers, versus the dot operator. # Trap decimals in numbers, versus the dot operator.
return '' return ''
@@ -268,7 +273,7 @@ def getRoot(command, terminator=None):
tokentype = token[0] tokentype = token[0]
tokenstring = token[1] tokenstring = token[1]
line = token[4] line = token[4]
if tokentype in (tokenize.ENDMARKER, tokenize.NEWLINE): if tokentype in (tokenize.ENDMARKER, tokenize.NEWLINE, tokenize.NL):
continue continue
if tokentype is tokenize.ENCODING: if tokentype is tokenize.ENCODING:
line = lastline line = lastline

View File

@@ -411,9 +411,12 @@ class GetAttributeTestCase(unittest.TestCase):
'__builtins__', '__builtins__',
'__call__', '__call__',
'__class__', '__class__',
'__closure__',
'__cmp__', '__cmp__',
'__code__',
'__coerce__', '__coerce__',
'__contains__', '__contains__',
'__defaults__',
'__del__', '__del__',
'__delattr__', '__delattr__',
'__delitem__', '__delitem__',
@@ -428,12 +431,14 @@ class GetAttributeTestCase(unittest.TestCase):
'__flags__', '__flags__',
'__float__', '__float__',
'__floordiv__', '__floordiv__',
'__func__',
'__ge__', '__ge__',
'__get__', '__get__',
'__getattr__', '__getattr__',
'__getattribute__', '__getattribute__',
'__getitem__', '__getitem__',
'__getslice__', '__getslice__',
'__globals__',
'__gt__', '__gt__',
'__hash__', '__hash__',
'__hex__', '__hex__',
@@ -444,6 +449,7 @@ class GetAttributeTestCase(unittest.TestCase):
'__invert__', '__invert__',
'__itemsize__', '__itemsize__',
'__iter__', '__iter__',
'__kwdefaults__',
'__le__', '__le__',
'__len__', '__len__',
'__long__', '__long__',
@@ -463,6 +469,7 @@ class GetAttributeTestCase(unittest.TestCase):
'__path__', '__path__',
'__pos__', '__pos__',
'__pow__', '__pow__',
'__qualname__',
'__radd__', '__radd__',
'__rand__', '__rand__',
'__rdiv__', '__rdiv__',
@@ -522,18 +529,8 @@ class GetAttributeTestCase(unittest.TestCase):
'fileno', 'fileno',
'find', 'find',
'flush', 'flush',
'func_closure',
'func_code',
'func_defaults',
'func_dict',
'func_doc',
'func_globals',
'func_name',
'get', 'get',
'has_key', 'has_key',
'im_class',
'im_func',
'im_self',
'imag', 'imag',
'index', 'index',
'insert', 'insert',