Commit 22516cc1 authored by Stefan Behnel's avatar Stefan Behnel

re-allow Python values in ExprStatNode and NameNode in nogil sections if they...

re-allow Python values in ExprStatNode and NameNode in nogil sections if they do not need cleanup (e.g. cached builtin names or constants)
parent bc3b45b6
......@@ -1431,8 +1431,8 @@ class NameNode(AtomicExprNode):
if self.is_used_as_rvalue:
entry = self.entry
if entry.is_builtin:
# if not Options.cache_builtins: # cached builtins are ok
self.gil_error()
if not Options.cache_builtins: # cached builtins are ok
self.gil_error()
elif entry.is_pyglobal:
self.gil_error()
......
......@@ -3347,7 +3347,7 @@ class ExprStatNode(StatNode):
self.expr.analyse_expressions(env)
def nogil_check(self, env):
if self.expr.type.is_pyobject:
if self.expr.type.is_pyobject and self.expr.is_temp:
self.gil_error()
gil_message = "Discarding owned Python object"
......
......@@ -82,8 +82,12 @@ def ticket_338():
for obj from 0 <= obj < 4:
pass
def bare_pyvar_name(object x):
with nogil:
x
# For m(), the important thing is that there are errors on all lines in the range 23-69
# except these: 34, 44, 56, 58, 60, 62-64
# except these: 29, 34, 44, 56, 58, 60, 62-64
_ERRORS = u"""
1:5: Function with Python return type cannot be declared nogil
......@@ -96,8 +100,6 @@ _ERRORS = u"""
26:12: Assignment of Python object not allowed without gil
28:8: Discarding owned Python object not allowed without gil
28:16: Constructing complex number not allowed without gil
29:12: Accessing Python global or builtin not allowed without gil
29:12: Discarding owned Python object not allowed without gil
30:8: Backquote expression not allowed without gil
30:8: Discarding owned Python object not allowed without gil
30:9: Operation not allowed without gil
......
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