From: Stefan Behnel Date: Mon, 27 Dec 2010 09:21:58 +0000 (+0100) Subject: nogil fix: disallow ExprStatNode to clean up Python expression results without holdin... X-Git-Tag: 0.14.1rc0~13^2~4 X-Git-Url: http://git.tremily.us/?p=cython.git;a=commitdiff_plain;h=bc3b45b6b3469274a09e687e659f187da8856b5a nogil fix: disallow ExprStatNode to clean up Python expression results without holding the GIL --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 41b55d6c..e9d889e5 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -3346,6 +3346,12 @@ class ExprStatNode(StatNode): def analyse_expressions(self, env): self.expr.analyse_expressions(env) + def nogil_check(self, env): + if self.expr.type.is_pyobject: + self.gil_error() + + gil_message = "Discarding owned Python object" + def generate_execution_code(self, code): self.expr.generate_evaluation_code(code) if not self.expr.is_temp and self.expr.result(): diff --git a/tests/errors/nogil.pyx b/tests/errors/nogil.pyx index e8285664..387818ca 100644 --- a/tests/errors/nogil.pyx +++ b/tests/errors/nogil.pyx @@ -89,13 +89,17 @@ _ERRORS = u""" 1:5: Function with Python return type cannot be declared nogil 4:5: Function declared nogil has Python locals or temporaries 6:6: Assignment of Python object not allowed without gil +9:5: Discarding owned Python object not allowed without gil 11:5: Function with Python return type cannot be declared nogil 15:5: Calling gil-requiring function not allowed without gil 24:9: Calling gil-requiring function not allowed without gil 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 31:15: Assignment of Python object not allowed without gil 31:15: Operation not allowed without gil @@ -105,20 +109,30 @@ _ERRORS = u""" 32:25: Constructing Python list not allowed without gil 32:25: Operation not allowed without gil 33:17: Iterating over Python object not allowed without gil +35:11: Discarding owned Python object not allowed without gil 35:11: Indexing Python object not allowed without gil +36:11: Discarding owned Python object not allowed without gil 36:11: Slicing Python object not allowed without gil 37:11: Constructing Python slice object not allowed without gil +37:11: Discarding owned Python object not allowed without gil 37:11: Indexing Python object not allowed without gil 37:13: Converting to Python object not allowed without gil 37:15: Converting to Python object not allowed without gil 37:17: Converting to Python object not allowed without gil 38:11: Accessing Python attribute not allowed without gil -39: 9: Constructing Python tuple not allowed without gil -40: 8: Constructing Python list not allowed without gil -41: 8: Constructing Python dict not allowed without gil +38:11: Discarding owned Python object not allowed without gil +39:9: Constructing Python tuple not allowed without gil +39:9: Discarding owned Python object not allowed without gil +40:8: Constructing Python list not allowed without gil +40:8: Discarding owned Python object not allowed without gil +41:8: Constructing Python dict not allowed without gil +41:8: Discarding owned Python object not allowed without gil +42:12: Discarding owned Python object not allowed without gil 42:12: Truth-testing Python object not allowed without gil 43:13: Python type test not allowed without gil +45:10: Discarding owned Python object not allowed without gil 45:10: Operation not allowed without gil +46:8: Discarding owned Python object not allowed without gil 46:8: Operation not allowed without gil 47:10: Assignment of Python object not allowed without gil 47:14: Assignment of Python object not allowed without gil