Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
45e124e2
Kaydet (Commit)
45e124e2
authored
Ock 22, 2014
tarafından
Florent Xicluna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #17825: Cursor ^ is correctly positioned for SyntaxError and IndentationError.
üst
f1e4fdcf
758fa5ea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
test_traceback.py
Lib/test/test_traceback.py
+14
-4
traceback.py
Lib/traceback.py
+4
-3
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_traceback.py
Dosyayı görüntüle @
45e124e2
...
@@ -35,6 +35,9 @@ class SyntaxTracebackCases(unittest.TestCase):
...
@@ -35,6 +35,9 @@ class SyntaxTracebackCases(unittest.TestCase):
def
syntax_error_with_caret_non_ascii
(
self
):
def
syntax_error_with_caret_non_ascii
(
self
):
compile
(
'Python = "
\u1e54\xfd\u0163\u0125\xf2\xf1
" +'
,
"?"
,
"exec"
)
compile
(
'Python = "
\u1e54\xfd\u0163\u0125\xf2\xf1
" +'
,
"?"
,
"exec"
)
def
syntax_error_bad_indentation2
(
self
):
compile
(
" print(2)"
,
"?"
,
"exec"
)
def
test_caret
(
self
):
def
test_caret
(
self
):
err
=
self
.
get_exception_format
(
self
.
syntax_error_with_caret
,
err
=
self
.
get_exception_format
(
self
.
syntax_error_with_caret
,
SyntaxError
)
SyntaxError
)
...
@@ -46,14 +49,14 @@ class SyntaxTracebackCases(unittest.TestCase):
...
@@ -46,14 +49,14 @@ class SyntaxTracebackCases(unittest.TestCase):
err
=
self
.
get_exception_format
(
self
.
syntax_error_with_caret_2
,
err
=
self
.
get_exception_format
(
self
.
syntax_error_with_caret_2
,
SyntaxError
)
SyntaxError
)
self
.
assertIn
(
"^"
,
err
[
2
])
# third line has caret
self
.
assertIn
(
"^"
,
err
[
2
])
# third line has caret
self
.
assert
True
(
err
[
2
]
.
count
(
'
\n
'
)
==
1
)
# and no additional newline
self
.
assert
Equal
(
err
[
2
]
.
count
(
'
\n
'
),
1
)
# and no additional newline
self
.
assert
True
(
err
[
1
]
.
find
(
"+"
)
==
err
[
2
]
.
find
(
"^"
))
# in the right place
self
.
assert
Equal
(
err
[
1
]
.
find
(
"+"
),
err
[
2
]
.
find
(
"^"
))
# in the right place
err
=
self
.
get_exception_format
(
self
.
syntax_error_with_caret_non_ascii
,
err
=
self
.
get_exception_format
(
self
.
syntax_error_with_caret_non_ascii
,
SyntaxError
)
SyntaxError
)
self
.
assertIn
(
"^"
,
err
[
2
])
# third line has caret
self
.
assertIn
(
"^"
,
err
[
2
])
# third line has caret
self
.
assert
True
(
err
[
2
]
.
count
(
'
\n
'
)
==
1
)
# and no additional newline
self
.
assert
Equal
(
err
[
2
]
.
count
(
'
\n
'
),
1
)
# and no additional newline
self
.
assert
True
(
err
[
1
]
.
find
(
"+"
)
==
err
[
2
]
.
find
(
"^"
))
# in the right place
self
.
assert
Equal
(
err
[
1
]
.
find
(
"+"
),
err
[
2
]
.
find
(
"^"
))
# in the right place
def
test_nocaret
(
self
):
def
test_nocaret
(
self
):
exc
=
SyntaxError
(
"error"
,
(
"x.py"
,
23
,
None
,
"bad syntax"
))
exc
=
SyntaxError
(
"error"
,
(
"x.py"
,
23
,
None
,
"bad syntax"
))
...
@@ -69,6 +72,13 @@ class SyntaxTracebackCases(unittest.TestCase):
...
@@ -69,6 +72,13 @@ class SyntaxTracebackCases(unittest.TestCase):
self
.
assertIn
(
"^"
,
err
[
2
])
self
.
assertIn
(
"^"
,
err
[
2
])
self
.
assertEqual
(
err
[
1
]
.
find
(
")"
),
err
[
2
]
.
find
(
"^"
))
self
.
assertEqual
(
err
[
1
]
.
find
(
")"
),
err
[
2
]
.
find
(
"^"
))
err
=
self
.
get_exception_format
(
self
.
syntax_error_bad_indentation2
,
IndentationError
)
self
.
assertEqual
(
len
(
err
),
4
)
self
.
assertEqual
(
err
[
1
]
.
strip
(),
"print(2)"
)
self
.
assertIn
(
"^"
,
err
[
2
])
self
.
assertEqual
(
err
[
1
]
.
find
(
"p"
),
err
[
2
]
.
find
(
"^"
))
def
test_base_exception
(
self
):
def
test_base_exception
(
self
):
# Test that exceptions derived from BaseException are formatted right
# Test that exceptions derived from BaseException are formatted right
e
=
KeyboardInterrupt
()
e
=
KeyboardInterrupt
()
...
...
Lib/traceback.py
Dosyayı görüntüle @
45e124e2
...
@@ -224,11 +224,12 @@ def _format_exception_only_iter(etype, value):
...
@@ -224,11 +224,12 @@ def _format_exception_only_iter(etype, value):
if
badline
is
not
None
:
if
badline
is
not
None
:
yield
' {}
\n
'
.
format
(
badline
.
strip
())
yield
' {}
\n
'
.
format
(
badline
.
strip
())
if
offset
is
not
None
:
if
offset
is
not
None
:
caretspace
=
badline
.
rstrip
(
'
\n
'
)[:
offset
]
.
lstrip
()
caretspace
=
badline
.
rstrip
(
'
\n
'
)
offset
=
min
(
len
(
caretspace
),
offset
)
-
1
caretspace
=
caretspace
[:
offset
]
.
lstrip
()
# non-space whitespace (likes tabs) must be kept for alignment
# non-space whitespace (likes tabs) must be kept for alignment
caretspace
=
((
c
.
isspace
()
and
c
or
' '
)
for
c
in
caretspace
)
caretspace
=
((
c
.
isspace
()
and
c
or
' '
)
for
c
in
caretspace
)
# only three spaces to account for offset1 == pos 0
yield
' {}^
\n
'
.
format
(
''
.
join
(
caretspace
))
yield
' {}^
\n
'
.
format
(
''
.
join
(
caretspace
))
msg
=
value
.
msg
or
"<no detail available>"
msg
=
value
.
msg
or
"<no detail available>"
yield
"{}: {}
\n
"
.
format
(
stype
,
msg
)
yield
"{}: {}
\n
"
.
format
(
stype
,
msg
)
...
...
Misc/NEWS
Dosyayı görüntüle @
45e124e2
...
@@ -10,6 +10,9 @@ Release date: 2014-01-19
...
@@ -10,6 +10,9 @@ Release date: 2014-01-19
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #17825: Cursor "^" is correctly positioned for SyntaxError and
IndentationError.
- Issue #2382: SyntaxError cursor "^" is now written at correct position in most
- Issue #2382: SyntaxError cursor "^" is now written at correct position in most
cases when multibyte characters are in line (before "^"). This still not
cases when multibyte characters are in line (before "^"). This still not
works correctly with wide East Asian characters.
works correctly with wide East Asian characters.
...
...
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