From d6b6c3c0fde15692183ba2be2435ab2534321c07 Mon Sep 17 00:00:00 2001 From: Kazuya O'moto Date: Sat, 29 Mar 2025 20:10:35 +0900 Subject: [PATCH 1/3] Add NL token type check to getRoot little tweaks to if statements. --- wx/py/introspect.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wx/py/introspect.py b/wx/py/introspect.py index 66efba42..11d36ce5 100644 --- a/wx/py/introspect.py +++ b/wx/py/introspect.py @@ -243,10 +243,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 +270,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 From fbd25d56fc1fa579d5dfda00dd4e5d8ea21d05ac Mon Sep 17 00:00:00 2001 From: Kazuya O'moto Date: Sun, 30 Mar 2025 01:24:07 +0900 Subject: [PATCH 2/3] Change special_attrs from PY2 to PY3 Change deprecated variables in PY2 to new ones in PY3 --- wx/py/introspect.py | 7 +++++-- wx/py/tests/test_introspect.py | 25 +++++++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/wx/py/introspect.py b/wx/py/introspect.py index 11d36ce5..b7c119cf 100644 --- a/wx/py/introspect.py +++ b/wx/py/introspect.py @@ -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__', + '__globals__', + '__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: diff --git a/wx/py/tests/test_introspect.py b/wx/py/tests/test_introspect.py index a33ef3e9..9aedfb79 100644 --- a/wx/py/tests/test_introspect.py +++ b/wx/py/tests/test_introspect.py @@ -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__', @@ -522,18 +527,18 @@ class GetAttributeTestCase(unittest.TestCase): 'fileno', 'find', 'flush', - 'func_closure', - 'func_code', - 'func_defaults', - 'func_dict', - 'func_doc', - 'func_globals', - 'func_name', + # 'func_closure', + # 'func_code', + # 'func_defaults', + # 'func_dict', + # 'func_doc', + # 'func_globals', + # 'func_name', 'get', 'has_key', - 'im_class', - 'im_func', - 'im_self', + # 'im_class', + # 'im_func', + # 'im_self', 'imag', 'index', 'insert', From 636dab57b88c407ee28b3a9ece007f39ddc5ea73 Mon Sep 17 00:00:00 2001 From: Kazuya O'moto Date: Sun, 30 Mar 2025 02:33:51 +0900 Subject: [PATCH 3/3] Add a few more dunders Clean up comments --- wx/py/introspect.py | 2 +- wx/py/tests/test_introspect.py | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/wx/py/introspect.py b/wx/py/introspect.py index b7c119cf..052f895a 100644 --- a/wx/py/introspect.py +++ b/wx/py/introspect.py @@ -40,7 +40,7 @@ def getAttributeNames(obj, includeMagic=1, includeSingle=1, # Add some attributes that don't always get picked up. special_attrs = ['__bases__', '__class__', '__dict__', '__name__', '__closure__', '__code__', '__defaults__', - '__globals__', + '__kwdefaults__', '__globals__', '__qualname__', '__builtins__', # Added to method attributes in 3.10 '__get__', # Not found in `dir(method)` in 3.11 ] diff --git a/wx/py/tests/test_introspect.py b/wx/py/tests/test_introspect.py index 9aedfb79..98852353 100644 --- a/wx/py/tests/test_introspect.py +++ b/wx/py/tests/test_introspect.py @@ -449,6 +449,7 @@ class GetAttributeTestCase(unittest.TestCase): '__invert__', '__itemsize__', '__iter__', + '__kwdefaults__', '__le__', '__len__', '__long__', @@ -468,6 +469,7 @@ class GetAttributeTestCase(unittest.TestCase): '__path__', '__pos__', '__pow__', + '__qualname__', '__radd__', '__rand__', '__rdiv__', @@ -527,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',