Commit 81c3fbd3 authored by Mark Florisson's avatar Mark Florisson

Fail gracefully on import instead of cimport from cython.view

parent 1fc34d3b
...@@ -12,6 +12,7 @@ STOP_ERR = "Axis specification only allowed in the 'step' slot." ...@@ -12,6 +12,7 @@ STOP_ERR = "Axis specification only allowed in the 'step' slot."
STEP_ERR = "Step must be omitted, 1, or a valid specifier." STEP_ERR = "Step must be omitted, 1, or a valid specifier."
BOTH_CF_ERR = "Cannot specify an array that is both C and Fortran contiguous." BOTH_CF_ERR = "Cannot specify an array that is both C and Fortran contiguous."
INVALID_ERR = "Invalid axis specification." INVALID_ERR = "Invalid axis specification."
NOT_CIMPORTED_ERR = "Variable was not cimported from cython.view"
EXPR_ERR = "no expressions allowed in axis spec, only names and literals." EXPR_ERR = "no expressions allowed in axis spec, only names and literals."
CF_ERR = "Invalid axis specification for a C/Fortran contiguous array." CF_ERR = "Invalid axis specification for a C/Fortran contiguous array."
ERR_UNINITIALIZED = ("Cannot check if memoryview %s is initialized without the " ERR_UNINITIALIZED = ("Cannot check if memoryview %s is initialized without the "
...@@ -897,8 +898,13 @@ def _resolve_NameNode(env, node): ...@@ -897,8 +898,13 @@ def _resolve_NameNode(env, node):
resolved_name = env.lookup(node.name).name resolved_name = env.lookup(node.name).name
except AttributeError: except AttributeError:
raise CompileError(node.pos, INVALID_ERR) raise CompileError(node.pos, INVALID_ERR)
viewscope = env.global_scope().context.cython_scope.viewscope viewscope = env.global_scope().context.cython_scope.viewscope
return viewscope.lookup(resolved_name) entry = viewscope.lookup(resolved_name)
if entry is None:
raise CompileError(node.pos, NOT_CIMPORTED_ERR)
return entry
def _resolve_AttributeNode(env, node): def _resolve_AttributeNode(env, node):
path = [] path = []
......
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