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
bd7cf3ad
Kaydet (Commit)
bd7cf3ad
authored
Şub 24, 2014
tarafından
Terry Jan Reedy
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #9974: When untokenizing, use row info to insert backslash+newline.
Original patches by A. Kuchling and G. Rees (#12691).
üst
e0a03d6e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
test_tokenize.py
Lib/test/test_tokenize.py
+15
-1
tokenize.py
Lib/tokenize.py
+6
-0
No files found.
Lib/test/test_tokenize.py
Dosyayı görüntüle @
bd7cf3ad
...
...
@@ -4,7 +4,7 @@ Tests for the tokenize module.
>>> import glob, random, sys
The tests can be really simple. Given a small fragment of source
code, print out a table with tokens. The ENDMARK is omitted for
code, print out a table with tokens. The ENDMARK
ER
is omitted for
brevity.
>>> dump_tokens("1 + 1")
...
...
@@ -618,6 +618,7 @@ def decistmt(s):
class
UntokenizeTest
(
TestCase
):
def
test_bad_input_order
(
self
):
# raise if previous row
u
=
Untokenizer
()
u
.
prev_row
=
2
u
.
prev_col
=
2
...
...
@@ -625,8 +626,21 @@ class UntokenizeTest(TestCase):
u
.
add_whitespace
((
1
,
3
))
self
.
assertEqual
(
cm
.
exception
.
args
[
0
],
'start (1,3) precedes previous end (2,2)'
)
# raise if previous column in row
self
.
assertRaises
(
ValueError
,
u
.
add_whitespace
,
(
2
,
1
))
def
test_backslash_continuation
(
self
):
# The problem is that <whitespace>\<newline> leaves no token
u
=
Untokenizer
()
u
.
prev_row
=
1
u
.
prev_col
=
1
u
.
tokens
=
[]
u
.
add_whitespace
((
2
,
0
))
self
.
assertEqual
(
u
.
tokens
,
[
'
\\\n
'
])
u
.
prev_row
=
2
u
.
add_whitespace
((
4
,
4
))
self
.
assertEqual
(
u
.
tokens
,
[
'
\\\n
'
,
'
\\\n\\\n
'
,
' '
])
def
test_iter_compat
(
self
):
u
=
Untokenizer
()
token
=
(
NAME
,
'Hello'
)
...
...
Lib/tokenize.py
Dosyayı görüntüle @
bd7cf3ad
...
...
@@ -188,6 +188,10 @@ class Untokenizer:
if
row
<
self
.
prev_row
or
row
==
self
.
prev_row
and
col
<
self
.
prev_col
:
raise
ValueError
(
"start ({},{}) precedes previous end ({},{})"
.
format
(
row
,
col
,
self
.
prev_row
,
self
.
prev_col
))
row_offset
=
row
-
self
.
prev_row
if
row_offset
:
self
.
tokens
.
append
(
"
\\\n
"
*
row_offset
)
self
.
prev_col
=
0
col_offset
=
col
-
self
.
prev_col
if
col_offset
:
self
.
tokens
.
append
(
" "
*
col_offset
)
...
...
@@ -199,6 +203,8 @@ class Untokenizer:
self
.
compat
(
t
,
it
)
break
tok_type
,
token
,
start
,
end
,
line
=
t
if
tok_type
==
ENDMARKER
:
break
self
.
add_whitespace
(
start
)
self
.
tokens
.
append
(
token
)
self
.
prev_row
,
self
.
prev_col
=
end
...
...
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