Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
925eb5f8
Commit
925eb5f8
authored
Jan 19, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement ticket #650: substitute PyErr_NoMemory() for 'raise MemoryError()'
parent
ef709723
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+16
-1
tests/run/raise_memory_error_T650.pyx
tests/run/raise_memory_error_T650.pyx
+24
-0
No files found.
Cython/Compiler/Nodes.py
View file @
925eb5f8
...
...
@@ -3935,12 +3935,26 @@ class RaiseStatNode(StatNode):
if
self
.
exc_tb
:
self
.
exc_tb
.
analyse_types
(
env
)
self
.
exc_tb
=
self
.
exc_tb
.
coerce_to_pyobject
(
env
)
env
.
use_utility_code
(
raise_utility_code
)
# special cases for builtin exceptions
self
.
builtin_exc_name
=
None
if
self
.
exc_type
and
not
self
.
exc_value
and
not
self
.
exc_tb
:
exc
=
self
.
exc_type
import
ExprNodes
if
isinstance
(
exc
,
ExprNodes
.
SimpleCallNode
)
and
not
exc
.
args
:
exc
=
exc
.
function
# extract the exception type
if
exc
.
is_name
and
exc
.
entry
.
is_builtin
:
self
.
builtin_exc_name
=
exc
.
name
if
self
.
builtin_exc_name
==
'MemoryError'
:
self
.
exc_type
=
None
# has a separate implementation
nogil_check
=
Node
.
gil_error
gil_message
=
"Raising exception"
def
generate_execution_code
(
self
,
code
):
if
self
.
builtin_exc_name
==
'MemoryError'
:
code
.
putln
(
'PyErr_NoMemory(); %s'
%
code
.
error_goto
(
self
.
pos
))
return
if
self
.
exc_type
:
self
.
exc_type
.
generate_evaluation_code
(
code
)
type_code
=
self
.
exc_type
.
py_result
()
...
...
@@ -3956,6 +3970,7 @@ class RaiseStatNode(StatNode):
tb_code
=
self
.
exc_tb
.
py_result
()
else
:
tb_code
=
"0"
code
.
globalstate
.
use_utility_code
(
raise_utility_code
)
code
.
putln
(
"__Pyx_Raise(%s, %s, %s);"
%
(
type_code
,
...
...
tests/run/raise_memory_error_T650.pyx
0 → 100644
View file @
925eb5f8
cimport
cython
@
cython
.
test_assert_path_exists
(
'//RaiseStatNode'
,
'//RaiseStatNode[@builtin_exc_name = "MemoryError"]'
)
def
raise_me_type
():
"""
>>> try: raise_me_type()
... except MemoryError: pass
... else: print('NOT RAISED!')
"""
raise
MemoryError
@
cython
.
test_assert_path_exists
(
'//RaiseStatNode'
,
'//RaiseStatNode[@builtin_exc_name = "MemoryError"]'
)
def
raise_me_instance
():
"""
>>> try: raise_me_instance()
... except MemoryError: pass
... else: print('NOT RAISED!')
"""
raise
MemoryError
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment