Commit 875584d1 authored by da-woods's avatar da-woods Committed by GitHub

Error message on cpdef variables (GH-3963)

Allowing these gives people the false impression that they do something meaningful.

Closes https://github.com/cython/cython/issues/887
Closes https://github.com/cython/cython/issues/3959
parent fd8e8cbe
......@@ -1430,8 +1430,7 @@ class CVarDefNode(StatNode):
self.entry.create_wrapper = True
else:
if self.overridable:
warning(self.pos, "cpdef variables will not be supported in Cython 3; "
"currently they are no different from cdef variables", 2)
error(self.pos, "Variables cannot be declared with 'cpdef'. Use 'cdef' instead.")
if self.directive_locals:
error(self.pos, "Decorators can only be followed by functions")
self.entry = dest_scope.declare_var(
......
# tag: warnings
# mode: error
cpdef str a = "123"
cpdef b = 2
......@@ -16,9 +16,9 @@ def func():
return d
_WARNINGS = """
3:6: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
4:6: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
7:10: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
15:10: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
_ERRORS = """
3:6: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
4:6: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
7:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
15:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
"""
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