Commit 011acaaf authored by Stefan Behnel's avatar Stefan Behnel

Only isinstance-test the type for actual types.

Fixes "Make it a bit less likely that the Python version of cython.cast() does something unexpected/wrong."
parent 3149eb83
......@@ -160,13 +160,13 @@ def cmod(a, b):
# Emulated language constructs
def cast(type, *args, **kwargs):
def cast(type_, *args, **kwargs):
kwargs.pop('typecheck', None)
assert not kwargs
if callable(type) and not (args and isinstance(args[0], type)):
return type(*args)
else:
return args[0]
if callable(type_):
if not isinstance(type_, type) or not (args and isinstance(args[0], type_)):
return type_(*args)
return args[0]
def sizeof(arg):
return 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment