Change special_attrs from PY2 to PY3

Change deprecated variables in PY2 to new ones in PY3
This commit is contained in:
Kazuya O'moto
2025-03-30 01:24:07 +09:00
parent d6b6c3c0fd
commit fbd25d56fc
2 changed files with 20 additions and 12 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__',
'__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:

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__',
@@ -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',