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
56e2c80a
Commit
56e2c80a
authored
Jan 20, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'upstream/master'
parents
30872e93
30482ee8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
125 additions
and
85 deletions
+125
-85
COPYING.txt
COPYING.txt
+2
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+16
-1
Cython/Debugger/libcython.py
Cython/Debugger/libcython.py
+12
-13
Cython/Debugger/libpython.py
Cython/Debugger/libpython.py
+2
-2
Cython/Tests/xmlrunner.py
Cython/Tests/xmlrunner.py
+69
-66
tests/run/raise_memory_error_T650.pyx
tests/run/raise_memory_error_T650.pyx
+24
-0
No files found.
COPYING.txt
View file @
56e2c80a
...
...
@@ -4,10 +4,9 @@ redistribute, modify and distribute modified versions."
------------------
Cython, which derives from Pyrex, is licensed under the
Python
Software
Foundation License. More precisely, all modifications
Cython, which derives from Pyrex, is licensed under the
Apache 2.0
Software
License. More precisely, all modifications and new code
made to go from Pyrex to Cython are so licensed.
See LICENSE.txt for more details.
Cython/Compiler/Nodes.py
View file @
56e2c80a
...
...
@@ -4113,12 +4113,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
()
...
...
@@ -4134,6 +4148,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
,
...
...
Cython/Debugger/libcython.py
View file @
56e2c80a
...
...
@@ -389,20 +389,19 @@ class CythonBase(object):
value
)
def
is_initialized
(
self
,
cython_func
,
local_name
):
islocal
=
local_name
in
cython_func
.
locals
if
islocal
:
cyvar
=
cython_func
.
locals
[
local_name
]
if
'->'
in
cyvar
.
cname
:
# Closed over free variable
if
self
.
get_cython_lineno
()
>=
cython_func
.
lineno
+
1
:
if
cyvar
.
type
==
PythonObject
:
return
long
(
gdb
.
parse_and_eval
(
cyvar
.
cname
))
return
True
return
False
cyvar
=
cython_func
.
locals
[
local_name
]
cur_lineno
=
self
.
get_cython_lineno
()
return
(
local_name
in
cython_func
.
arguments
or
(
islocal
and
cur_lineno
>
cyvar
.
lineno
))
if
'->'
in
cyvar
.
cname
:
# Closed over free variable
if
cur_lineno
>
cython_func
.
lineno
:
if
cyvar
.
type
==
PythonObject
:
return
long
(
gdb
.
parse_and_eval
(
cyvar
.
cname
))
return
True
return
False
return
cur_lineno
>
cyvar
.
lineno
class
SourceFileDescriptor
(
object
):
def
__init__
(
self
,
filename
,
lexer
,
formatter
=
None
):
...
...
Cython/Debugger/libpython.py
View file @
56e2c80a
...
...
@@ -2074,8 +2074,8 @@ class ExecutionControlCommandBase(gdb.Command):
self.finish_executing(result)
def run(self,
*args
):
self.finish_executing(gdb.execute('run
'
, to_string=True))
def run(self,
args, from_tty
):
self.finish_executing(gdb.execute('run
' + args
, to_string=True))
def cont(self, *args):
self.finish_executing(gdb.execute('cont', to_string=True))
...
...
Cython/Tests/xmlrunner.py
View file @
56e2c80a
...
...
@@ -59,6 +59,8 @@ class _TestInfo(object):
self
.
test_method
=
test_method
self
.
outcome
=
outcome
self
.
err
=
err
self
.
stdout
=
test_result
.
stdout
and
test_result
.
stdout
.
getvalue
().
strip
()
or
''
self
.
stderr
=
test_result
.
stdout
and
test_result
.
stderr
.
getvalue
().
strip
()
or
''
def
get_elapsed_time
(
self
):
"""Return the time that shows how long the test method took to
...
...
@@ -118,8 +120,21 @@ class _XMLTestResult(_TextTestResult):
self
.
stream
.
write
(
short_str
)
self
.
callback
=
callback
def
_patch_standard_output
(
self
):
"""Replace the stdout and stderr streams with string-based streams
in order to capture the tests' output.
"""
(
self
.
old_stdout
,
self
.
old_stderr
)
=
(
sys
.
stdout
,
sys
.
stderr
)
(
sys
.
stdout
,
sys
.
stderr
)
=
(
self
.
stdout
,
self
.
stderr
)
=
\
(
StringIO
(),
StringIO
())
def
_restore_standard_output
(
self
):
"Restore the stdout and stderr streams."
(
sys
.
stdout
,
sys
.
stderr
)
=
(
self
.
old_stdout
,
self
.
old_stderr
)
def
startTest
(
self
,
test
):
"Called before execute each test method."
self
.
_patch_standard_output
()
self
.
start_time
=
time
.
time
()
TestResult
.
startTest
(
self
,
test
)
...
...
@@ -129,6 +144,7 @@ class _XMLTestResult(_TextTestResult):
def
stopTest
(
self
,
test
):
"Called after execute each test method."
self
.
_restore_standard_output
()
_TextTestResult
.
stopTest
(
self
,
test
)
self
.
stop_time
=
time
.
time
()
...
...
@@ -138,18 +154,18 @@ class _XMLTestResult(_TextTestResult):
def
addSuccess
(
self
,
test
):
"Called when a test executes successfully."
self
.
_prepare_callback
(
_TestInfo
(
self
,
test
),
\
self
.
successes
,
'OK'
,
'.'
)
self
.
_prepare_callback
(
_TestInfo
(
self
,
test
),
self
.
successes
,
'OK'
,
'.'
)
def
addFailure
(
self
,
test
,
err
):
"Called when a test method fails."
self
.
_prepare_callback
(
_TestInfo
(
self
,
test
,
_TestInfo
.
FAILURE
,
err
),
\
self
.
failures
,
'FAIL'
,
'F'
)
self
.
_prepare_callback
(
_TestInfo
(
self
,
test
,
_TestInfo
.
FAILURE
,
err
),
self
.
failures
,
'FAIL'
,
'F'
)
def
addError
(
self
,
test
,
err
):
"Called when a test method raises an error."
self
.
_prepare_callback
(
_TestInfo
(
self
,
test
,
_TestInfo
.
ERROR
,
err
),
\
self
.
errors
,
'ERROR'
,
'E'
)
self
.
_prepare_callback
(
_TestInfo
(
self
,
test
,
_TestInfo
.
ERROR
,
err
),
self
.
errors
,
'ERROR'
,
'E'
)
def
printErrorList
(
self
,
flavour
,
errors
):
"Write some information about the FAIL or ERROR to the stream."
...
...
@@ -230,19 +246,17 @@ class _XMLTestResult(_TextTestResult):
_report_testcase
=
staticmethod
(
_report_testcase
)
def
_report_output
(
test_runner
,
xml_testsuite
,
xml_document
):
def
_report_output
(
test_runner
,
xml_testsuite
,
xml_document
,
stdout
,
stderr
):
"Appends the system-out and system-err sections to the XML document."
systemout
=
xml_document
.
createElement
(
'system-out'
)
xml_testsuite
.
appendChild
(
systemout
)
stdout
=
test_runner
.
stdout
.
getvalue
()
systemout_text
=
xml_document
.
createCDATASection
(
stdout
)
systemout
.
appendChild
(
systemout_text
)
systemerr
=
xml_document
.
createElement
(
'system-err'
)
xml_testsuite
.
appendChild
(
systemerr
)
stderr
=
test_runner
.
stderr
.
getvalue
()
systemerr_text
=
xml_document
.
createCDATASection
(
stderr
)
systemerr
.
appendChild
(
systemerr_text
)
...
...
@@ -262,9 +276,15 @@ class _XMLTestResult(_TextTestResult):
# Build the XML file
testsuite
=
_XMLTestResult
.
_report_testsuite
(
suite
,
tests
,
doc
)
stdout
,
stderr
=
[],
[]
for
test
in
tests
:
_XMLTestResult
.
_report_testcase
(
suite
,
test
,
testsuite
,
doc
)
_XMLTestResult
.
_report_output
(
test_runner
,
testsuite
,
doc
)
if
test
.
stdout
:
stdout
.
extend
([
'*****************'
,
test
.
get_description
(),
test
.
stdout
])
if
test
.
stderr
:
stderr
.
extend
([
'*****************'
,
test
.
get_description
(),
test
.
stderr
])
_XMLTestResult
.
_report_output
(
test_runner
,
testsuite
,
doc
,
'
\
n
'
.
join
(
stdout
),
'
\
n
'
.
join
(
stderr
))
xml_content
=
doc
.
toprettyxml
(
indent
=
'
\
t
'
)
if
type
(
test_runner
.
output
)
is
str
:
...
...
@@ -297,64 +317,47 @@ class XMLTestRunner(TextTestRunner):
return
_XMLTestResult
(
self
.
stream
,
self
.
descriptions
,
\
self
.
verbosity
,
self
.
elapsed_times
)
def
_patch_standard_output
(
self
):
"""Replace the stdout and stderr streams with string-based streams
in order to capture the tests' output.
"""
(
self
.
old_stdout
,
self
.
old_stderr
)
=
(
sys
.
stdout
,
sys
.
stderr
)
(
sys
.
stdout
,
sys
.
stderr
)
=
(
self
.
stdout
,
self
.
stderr
)
=
\
(
StringIO
(),
StringIO
())
def
_restore_standard_output
(
self
):
"Restore the stdout and stderr streams."
(
sys
.
stdout
,
sys
.
stderr
)
=
(
self
.
old_stdout
,
self
.
old_stderr
)
def
run
(
self
,
test
):
"Run the given test case or test suite."
try
:
# Prepare the test execution
self
.
_patch_standard_output
()
result
=
self
.
_make_result
()
# Print a nice header
self
.
stream
.
writeln
()
self
.
stream
.
writeln
(
'Running tests...'
)
self
.
stream
.
writeln
(
result
.
separator2
)
# Execute tests
start_time
=
time
.
time
()
test
(
result
)
stop_time
=
time
.
time
()
time_taken
=
stop_time
-
start_time
# Print results
result
.
printErrors
()
self
.
stream
.
writeln
(
result
.
separator2
)
run
=
result
.
testsRun
self
.
stream
.
writeln
(
"Ran %d test%s in %.3fs"
%
(
run
,
run
!=
1
and
"s"
or
""
,
time_taken
))
self
.
stream
.
writeln
()
# Error traces
if
not
result
.
wasSuccessful
()
:
self
.
stream
.
write
(
"
FAILED ("
)
failed
,
errored
=
(
len
(
result
.
failures
),
len
(
result
.
errors
))
# Prepare the test execution
result
=
self
.
_make_result
()
# Print a nice header
self
.
stream
.
writeln
()
self
.
stream
.
writeln
(
'Running tests...'
)
self
.
stream
.
writeln
(
result
.
separator2
)
# Execute tests
start_time
=
time
.
time
(
)
test
(
result
)
stop_time
=
time
.
time
()
time_taken
=
stop_time
-
start_time
# Print results
result
.
printErrors
()
self
.
stream
.
writeln
(
result
.
separator2
)
run
=
result
.
testsRun
self
.
stream
.
writeln
(
"Ran %d test%s in %.3fs"
%
(
run
,
run
!=
1
and
"s"
or
""
,
time_taken
)
)
self
.
stream
.
writeln
()
# Error traces
if
not
result
.
wasSuccessful
():
self
.
stream
.
write
(
"FAILED ("
)
failed
,
errored
=
(
len
(
result
.
failures
),
len
(
result
.
errors
))
if
failed
:
self
.
stream
.
write
(
"
failures=%d"
%
failed
)
if
errored
:
if
failed
:
self
.
stream
.
write
(
"failures=%d"
%
failed
)
if
errored
:
if
failed
:
self
.
stream
.
write
(
", "
)
self
.
stream
.
write
(
"errors=%d"
%
errored
)
self
.
stream
.
writeln
(
")"
)
else
:
self
.
stream
.
writeln
(
"OK"
)
# Generate reports
self
.
stream
.
writeln
()
self
.
stream
.
writeln
(
'Generating XML reports...'
)
result
.
generate_reports
(
self
)
finally
:
self
.
_restore_standard_output
()
self
.
stream
.
write
(
", "
)
self
.
stream
.
write
(
"errors=%d"
%
errored
)
self
.
stream
.
writeln
(
")"
)
else
:
self
.
stream
.
writeln
(
"OK"
)
# Generate reports
self
.
stream
.
writeln
()
self
.
stream
.
writeln
(
'Generating XML reports...'
)
result
.
generate_reports
(
self
)
return
result
tests/run/raise_memory_error_T650.pyx
0 → 100644
View file @
56e2c80a
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