diff --git a/wx/py/introspect.py b/wx/py/introspect.py index 66efba42..052f895a 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__', + '__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 diff --git a/wx/py/tests/test_introspect.py b/wx/py/tests/test_introspect.py index a33ef3e9..98852353 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__', @@ -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',