Skip to content

Commit 878c1f7

Browse files
committed
adapt for Cython 3 module names in inspection
1 parent bfd17cc commit 878c1f7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/sage/misc/sageinspect.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@ def isclassinstance(obj):
224224
return (not inspect.isclass(obj) and
225225
hasattr(obj, '__class__') and
226226
hasattr(obj.__class__, '__module__') and
227-
obj.__class__.__module__ not in builtin_mods)
227+
obj.__class__.__module__ not in builtin_mods and
228+
# Starting with Cython 3, Cython's builtin types have __module__ set
229+
# to the shared module names like _cython_3_0_0.
230+
not (isinstance(obj.__class__.__module__, str) and
231+
obj.__class__.__module__.startswith('_cython_')))
228232

229233

230234
# Parse strings of form "File: sage/rings/rational.pyx (starting at line 1080)"

0 commit comments

Comments
 (0)