Skip to content

Commit bfdbb63

Browse files
author
Release Manager
committed
gh-36543: Cleanup conditional assert The code we remove here is a legacy assert which has no equivalent in python 3.12. The way it's implemented uses compile time `IF` which is deprecated in cython 3 so it's desirable to remove. See also: #36524 (comment) ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. URL: #36543 Reported by: Gonzalo Tornaría Reviewer(s): Matthias Köppe, Tobias Diez
2 parents ff67b44 + d4ba99c commit bfdbb63

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

src/sage/cpython/dict_del_by_value.pyx

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,6 @@ cdef extern from "dict_internal.h":
4646
PyObject * me_key
4747
PyObject * me_value
4848

49-
50-
# dk_lookup was removed in python 3.11
51-
DEF HAS_DK_LOOKUP = PY_VERSION_HEX < 0x30b0000
52-
53-
IF HAS_DK_LOOKUP:
54-
55-
cdef extern from *:
56-
"""
57-
#define DK_LOOKUP(dk) ((dk)->dk_lookup)
58-
"""
59-
ctypedef void * dict_lookup_func # Precise definition not needed
60-
dict_lookup_func DK_LOOKUP(PyDictKeysObject *mp)
61-
62-
cdef dict_lookup_func lookdict
63-
64-
def init_lookdict():
65-
global lookdict
66-
# A dict which a non-string key uses the generic "lookdict"
67-
# as lookup function
68-
cdef object D = {}
69-
D[0] = 0
70-
lookdict = DK_LOOKUP((<PyDictObject *>D).ma_keys)
71-
72-
init_lookdict()
73-
7449
cdef int del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_t hash) except -1:
7550
"""
7651
This is used in callbacks for the weak values of :class:`WeakValueDictionary`.
@@ -147,12 +122,6 @@ cdef int del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_
147122
return 0
148123
ep = &(entries[ix])
149124

150-
# We need the lookup function to be the generic lookdict, otherwise
151-
# deletions may not work correctly
152-
IF HAS_DK_LOOKUP:
153-
# Can this fail? In any case dk_lookup was removed in python 3.11
154-
assert DK_LOOKUP(keys) is lookdict
155-
156125
T = PyList_New(2)
157126
PyList_SetItem(T, 0, ep.me_key)
158127
PyList_SetItem(T, 1, ep.me_value)

0 commit comments

Comments
 (0)