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):
# Add some attributes that don't always get picked up.
special_attrs = ['__bases__', '__class__', '__dict__', '__name__',
'func_closure', 'func_code', 'func_defaults',
'func_dict', 'func_doc', 'func_globals', 'func_name']
'__closure__', '__code__', '__defaults__',
'__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 \
if hasattr(obj, attr)]
if includeMagic:
@@ -243,10 +246,12 @@ def getRoot(command, terminator=None):
if tokens and tokens[-1][0] is tokenize.NEWLINE:
# Remove newline.
del tokens[-1]
if tokens and tokens[-1][0] is tokenize.NL:
# Remove non-logical newline.
del tokens[-1]
if not tokens:
return ''
if terminator == '.' and \
(tokens[-1][1] != '.' or tokens[-1][0] is not tokenize.OP):
if tokens[-1][1] != '.' or tokens[-1][0] is not tokenize.OP:
# Trap decimals in numbers, versus the dot operator.
return ''
@@ -268,7 +273,7 @@ def getRoot(command, terminator=None):
tokentype = token[0]
tokenstring = token[1]
line = token[4]
if tokentype in (tokenize.ENDMARKER, tokenize.NEWLINE):
if tokentype in (tokenize.ENDMARKER, tokenize.NEWLINE, tokenize.NL):
continue
if tokentype is tokenize.ENCODING:
line = lastline

View File

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