Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6cff7dff
Commit
6cff7dff
authored
Mar 31, 2006
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
traceback now shows error position for all SyntaxError subclasses,
e.g. IndentationError. (bug #1447885)
parent
99ace1da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
Lib/test/test_traceback.py
Lib/test/test_traceback.py
+10
-0
Lib/traceback.py
Lib/traceback.py
+1
-1
No files found.
Lib/test/test_traceback.py
View file @
6cff7dff
...
...
@@ -23,6 +23,9 @@ class TracebackCases(unittest.TestCase):
def
syntax_error_without_caret
(
self
):
# XXX why doesn't compile raise the same traceback?
import
test.badsyntax_nocaret
def
syntax_error_bad_indentation
(
self
):
compile
(
"def spam():
\
n
print 1
\
n
print 2"
,
"?"
,
"exec"
)
def
test_caret
(
self
):
err
=
self
.
get_exception_format
(
self
.
syntax_error_with_caret
,
...
...
@@ -40,6 +43,13 @@ class TracebackCases(unittest.TestCase):
self
.
assert_
(
len
(
err
)
==
3
)
self
.
assert_
(
err
[
1
].
strip
()
==
"[x for x in x] = x"
)
def
test_bad_indentation
(
self
):
err
=
self
.
get_exception_format
(
self
.
syntax_error_bad_indentation
,
IndentationError
)
self
.
assert_
(
len
(
err
)
==
4
)
self
.
assert_
(
"^"
in
err
[
2
])
self
.
assert_
(
err
[
1
].
strip
()
==
"print 2"
)
def
test_bug737473
(
self
):
import
sys
,
os
,
tempfile
,
time
...
...
Lib/traceback.py
View file @
6cff7dff
...
...
@@ -165,7 +165,7 @@ def format_exception_only(etype, value):
if
value
is
None
:
list
.
append
(
str
(
stype
)
+
'
\
n
'
)
else
:
if
etype
is
SyntaxError
:
if
issubclass
(
etype
,
SyntaxError
)
:
try
:
msg
,
(
filename
,
lineno
,
offset
,
line
)
=
value
except
:
...
...
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