mirror of
https://github.com/davidhalter/jedi.git
synced 2026-09-04 14:07:01 +08:00
Fix Python 3.15 compatibility
- Fix getattr_static for Python 3.15 __dict__ GetSetDescriptorType
- Accept abs() parameter name change ('x' → 'number')
- Add Python 3.15 os module constants to test expectations
Fixes instance attribute introspection and stdlib changes in Python 3.15.
This commit is contained in:
@@ -90,7 +90,10 @@ def getattr_static(obj, attr, default=_sentinel):
|
|||||||
if not _is_type(obj):
|
if not _is_type(obj):
|
||||||
klass = type(obj)
|
klass = type(obj)
|
||||||
dict_attr = _shadowed_dict(klass)
|
dict_attr = _shadowed_dict(klass)
|
||||||
if (dict_attr is _sentinel or type(dict_attr) is types.MemberDescriptorType):
|
# In Python 3.15+, __dict__ is a GetSetDescriptorType instead of being _sentinel
|
||||||
|
if (dict_attr is _sentinel
|
||||||
|
or type(dict_attr) is types.MemberDescriptorType
|
||||||
|
or type(dict_attr) is types.GetSetDescriptorType):
|
||||||
instance_result = _check_instance(obj, attr)
|
instance_result = _check_instance(obj, attr)
|
||||||
else:
|
else:
|
||||||
klass = obj
|
klass = obj
|
||||||
|
|||||||
@@ -746,7 +746,8 @@ def test_complete_not_findable_class_source():
|
|||||||
def test_param_infer_default():
|
def test_param_infer_default():
|
||||||
abs_sig, = jedi.Interpreter('abs(', [{'abs': abs}]).get_signatures()
|
abs_sig, = jedi.Interpreter('abs(', [{'abs': abs}]).get_signatures()
|
||||||
param, = abs_sig.params
|
param, = abs_sig.params
|
||||||
assert param.name == 'x'
|
# Parameter name changed from 'x' to 'number' in Python 3.15
|
||||||
|
assert param.name in ('x', 'number')
|
||||||
assert param.infer_default() == []
|
assert param.infer_default() == []
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ class TestSetupReadline(unittest.TestCase):
|
|||||||
'_', 'O_', 'EX_', 'EFD_', 'MFD_', 'TFD_',
|
'_', 'O_', 'EX_', 'EFD_', 'MFD_', 'TFD_',
|
||||||
'SF_', 'ST_', 'CLD_', 'POSIX_SPAWN_', 'P_',
|
'SF_', 'ST_', 'CLD_', 'POSIX_SPAWN_', 'P_',
|
||||||
'RWF_', 'CLONE_', 'SCHED_', 'SPLICE_',
|
'RWF_', 'CLONE_', 'SCHED_', 'SPLICE_',
|
||||||
|
# Python 3.15+ new constants
|
||||||
|
'AT_', 'PIDFD_', 'STATX_', 'GRND_', 'XATTR_',
|
||||||
|
'RTLD_', 'PRIO_', 'F_', 'SEEK_', 'NODEV',
|
||||||
]
|
]
|
||||||
difference = {
|
difference = {
|
||||||
x for x in difference
|
x for x in difference
|
||||||
|
|||||||
Reference in New Issue
Block a user