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,12 +160,12 @@ def cmod(a, b): ...@@ -160,12 +160,12 @@ def cmod(a, b):
# Emulated language constructs # Emulated language constructs
def cast(type, *args, **kwargs): def cast(type_, *args, **kwargs):
kwargs.pop('typecheck', None) kwargs.pop('typecheck', None)
assert not kwargs assert not kwargs
if callable(type) and not (args and isinstance(args[0], type)): if callable(type_):
return type(*args) if not isinstance(type_, type) or not (args and isinstance(args[0], type_)):
else: return type_(*args)
return args[0] return args[0]
def sizeof(arg): def sizeof(arg):
......
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