Skip to content

Commit d0058a3

Browse files
authored
Merge pull request #2728 from komoto48g/fix-introspect
Fix introspect
2 parents 4247674 + 636dab5 commit d0058a3

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

wx/py/introspect.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ def getAttributeNames(obj, includeMagic=1, includeSingle=1,
3939
if not hasattrAlwaysReturnsTrue(obj):
4040
# Add some attributes that don't always get picked up.
4141
special_attrs = ['__bases__', '__class__', '__dict__', '__name__',
42-
'func_closure', 'func_code', 'func_defaults',
43-
'func_dict', 'func_doc', 'func_globals', 'func_name']
42+
'__closure__', '__code__', '__defaults__',
43+
'__kwdefaults__', '__globals__', '__qualname__',
44+
'__builtins__', # Added to method attributes in 3.10
45+
'__get__', # Not found in `dir(method)` in 3.11
46+
]
4447
attributes += [attr for attr in special_attrs \
4548
if hasattr(obj, attr)]
4649
if includeMagic:
@@ -243,10 +246,12 @@ def getRoot(command, terminator=None):
243246
if tokens and tokens[-1][0] is tokenize.NEWLINE:
244247
# Remove newline.
245248
del tokens[-1]
249+
if tokens and tokens[-1][0] is tokenize.NL:
250+
# Remove non-logical newline.
251+
del tokens[-1]
246252
if not tokens:
247253
return ''
248-
if terminator == '.' and \
249-
(tokens[-1][1] != '.' or tokens[-1][0] is not tokenize.OP):
254+
if tokens[-1][1] != '.' or tokens[-1][0] is not tokenize.OP:
250255
# Trap decimals in numbers, versus the dot operator.
251256
return ''
252257

@@ -268,7 +273,7 @@ def getRoot(command, terminator=None):
268273
tokentype = token[0]
269274
tokenstring = token[1]
270275
line = token[4]
271-
if tokentype in (tokenize.ENDMARKER, tokenize.NEWLINE):
276+
if tokentype in (tokenize.ENDMARKER, tokenize.NEWLINE, tokenize.NL):
272277
continue
273278
if tokentype is tokenize.ENCODING:
274279
line = lastline

wx/py/tests/test_introspect.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,12 @@ def setUp(self):
411411
'__builtins__',
412412
'__call__',
413413
'__class__',
414+
'__closure__',
414415
'__cmp__',
416+
'__code__',
415417
'__coerce__',
416418
'__contains__',
419+
'__defaults__',
417420
'__del__',
418421
'__delattr__',
419422
'__delitem__',
@@ -428,12 +431,14 @@ def setUp(self):
428431
'__flags__',
429432
'__float__',
430433
'__floordiv__',
434+
'__func__',
431435
'__ge__',
432436
'__get__',
433437
'__getattr__',
434438
'__getattribute__',
435439
'__getitem__',
436440
'__getslice__',
441+
'__globals__',
437442
'__gt__',
438443
'__hash__',
439444
'__hex__',
@@ -444,6 +449,7 @@ def setUp(self):
444449
'__invert__',
445450
'__itemsize__',
446451
'__iter__',
452+
'__kwdefaults__',
447453
'__le__',
448454
'__len__',
449455
'__long__',
@@ -463,6 +469,7 @@ def setUp(self):
463469
'__path__',
464470
'__pos__',
465471
'__pow__',
472+
'__qualname__',
466473
'__radd__',
467474
'__rand__',
468475
'__rdiv__',
@@ -522,18 +529,8 @@ def setUp(self):
522529
'fileno',
523530
'find',
524531
'flush',
525-
'func_closure',
526-
'func_code',
527-
'func_defaults',
528-
'func_dict',
529-
'func_doc',
530-
'func_globals',
531-
'func_name',
532532
'get',
533533
'has_key',
534-
'im_class',
535-
'im_func',
536-
'im_self',
537534
'imag',
538535
'index',
539536
'insert',

0 commit comments

Comments
 (0)