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
120364fa
Commit
120364fa
authored
Mar 22, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended test cases to check for exception __context__ in Py3
parent
4b446b49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
2 deletions
+36
-2
tests/run/funcexceptchained.pyx
tests/run/funcexceptchained.pyx
+18
-2
tests/run/funcexceptreplace.pyx
tests/run/funcexceptreplace.pyx
+18
-0
No files found.
tests/run/funcexceptchained.pyx
View file @
120364fa
...
...
@@ -8,7 +8,13 @@ __doc__ = u"""
... except AttributeError:
... print(sys.exc_info()[0] is AttributeError or sys.exc_info()[0])
... try: raise KeyError
... except: print(sys.exc_info()[0] is KeyError or sys.exc_info()[0])
... except:
... print(sys.exc_info()[0] is KeyError or sys.exc_info()[0])
... if IS_PY3:
... print(isinstance(sys.exc_info()[1].__context__, AttributeError)
... or sys.exc_info()[1].__context__)
... else:
... print(True)
... print((IS_PY3 and sys.exc_info()[0] is AttributeError) or
... (not IS_PY3 and sys.exc_info()[0] is KeyError) or
... sys.exc_info()[0])
...
...
@@ -24,6 +30,7 @@ True
True
True
True
True
>>> print(sys.exc_info()[0]) # test_py()
None
...
...
@@ -32,6 +39,7 @@ True
True
True
True
True
>>> print(sys.exc_info()[0]) # test_c()
None
...
...
@@ -52,6 +60,7 @@ True
True
True
True
True
>>> print(sys.exc_info()[0]) # test_py2()
None
...
...
@@ -62,6 +71,7 @@ True
True
True
True
True
>>> print(sys.exc_info()[0]) # test_c2()
None
"""
...
...
@@ -76,7 +86,13 @@ def test_c(outer_exc):
except
AttributeError
:
print
(
sys
.
exc_info
()[
0
]
is
AttributeError
or
sys
.
exc_info
()[
0
])
try
:
raise
KeyError
except
:
print
(
sys
.
exc_info
()[
0
]
is
KeyError
or
sys
.
exc_info
()[
0
])
except
:
print
(
sys
.
exc_info
()[
0
]
is
KeyError
or
sys
.
exc_info
()[
0
])
if
IS_PY3
:
print
(
isinstance
(
sys
.
exc_info
()[
1
].
__context__
,
AttributeError
)
or
sys
.
exc_info
()[
1
].
__context__
)
else
:
print
(
True
)
print
(
sys
.
exc_info
()[
0
]
is
AttributeError
or
sys
.
exc_info
()[
0
])
print
(
sys
.
exc_info
()[
0
]
is
outer_exc
or
sys
.
exc_info
()[
0
])
...
...
tests/run/funcexceptreplace.pyx
0 → 100644
View file @
120364fa
__doc__
=
u"""
>>> try: exc()
... except IndexError:
... if IS_PY3:
... print(isinstance(sys.exc_info()[1].__context__, ValueError))
... else:
... print(True)
True
"""
import
sys
IS_PY3
=
sys
.
version_info
[
0
]
>=
3
def
exc
():
try
:
raise
ValueError
except
ValueError
:
raise
IndexError
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