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
43f42fc3
Kaydet (Commit)
43f42fc3
authored
Haz 17, 2012
tarafından
Meador Inge
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #15054: Fix incorrect tokenization of 'b' and 'br' string literals.
Patch by Serhiy Storchaka.
üst
7cf66996
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
5 deletions
+34
-5
test_tokenize.py
Lib/test/test_tokenize.py
+25
-0
tokenize.py
Lib/tokenize.py
+5
-5
NEWS
Misc/NEWS
+4
-0
No files found.
Lib/test/test_tokenize.py
Dosyayı görüntüle @
43f42fc3
...
@@ -278,6 +278,31 @@ String literals
...
@@ -278,6 +278,31 @@ String literals
OP '+' (1, 32) (1, 33)
OP '+' (1, 32) (1, 33)
STRING 'UR"ABC"' (1, 34) (1, 41)
STRING 'UR"ABC"' (1, 34) (1, 41)
>>> dump_tokens("b'abc' + B'abc'")
STRING "b'abc'" (1, 0) (1, 6)
OP '+' (1, 7) (1, 8)
STRING "B'abc'" (1, 9) (1, 15)
>>> dump_tokens('b"abc" + B"abc"')
STRING 'b"abc"' (1, 0) (1, 6)
OP '+' (1, 7) (1, 8)
STRING 'B"abc"' (1, 9) (1, 15)
>>> dump_tokens("br'abc' + bR'abc' + Br'abc' + BR'abc'")
STRING "br'abc'" (1, 0) (1, 7)
OP '+' (1, 8) (1, 9)
STRING "bR'abc'" (1, 10) (1, 17)
OP '+' (1, 18) (1, 19)
STRING "Br'abc'" (1, 20) (1, 27)
OP '+' (1, 28) (1, 29)
STRING "BR'abc'" (1, 30) (1, 37)
>>> dump_tokens('br"abc" + bR"abc" + Br"abc" + BR"abc"')
STRING 'br"abc"' (1, 0) (1, 7)
OP '+' (1, 8) (1, 9)
STRING 'bR"abc"' (1, 10) (1, 17)
OP '+' (1, 18) (1, 19)
STRING 'Br"abc"' (1, 20) (1, 27)
OP '+' (1, 28) (1, 29)
STRING 'BR"abc"' (1, 30) (1, 37)
Operators
Operators
>>> dump_tokens("def d22(a, b, c=2, d=2, *k): pass")
>>> dump_tokens("def d22(a, b, c=2, d=2, *k): pass")
...
...
Lib/tokenize.py
Dosyayı görüntüle @
43f42fc3
...
@@ -70,10 +70,10 @@ Double = r'[^"\\]*(?:\\.[^"\\]*)*"'
...
@@ -70,10 +70,10 @@ Double = r'[^"\\]*(?:\\.[^"\\]*)*"'
Single3
=
r"[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*'''"
Single3
=
r"[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*'''"
# Tail end of """ string.
# Tail end of """ string.
Double3
=
r'[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""'
Double3
=
r'[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""'
Triple
=
group
(
"[uU
]?[rR]?'''"
,
'[uU
]?[rR]?"""'
)
Triple
=
group
(
"[uU
bB]?[rR]?'''"
,
'[uUbB
]?[rR]?"""'
)
# Single-line ' or " string.
# Single-line ' or " string.
String
=
group
(
r"[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'"
,
String
=
group
(
r"[uU
bB
]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'"
,
r'[uU]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"'
)
r'[uU
bB
]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"'
)
# Because of leftmost-then-longest match semantics, be sure to put the
# Because of leftmost-then-longest match semantics, be sure to put the
# longest operators first (e.g., if = came before ==, == would get
# longest operators first (e.g., if = came before ==, == would get
...
@@ -91,9 +91,9 @@ PlainToken = group(Number, Funny, String, Name)
...
@@ -91,9 +91,9 @@ PlainToken = group(Number, Funny, String, Name)
Token
=
Ignore
+
PlainToken
Token
=
Ignore
+
PlainToken
# First (or only) line of ' or " string.
# First (or only) line of ' or " string.
ContStr
=
group
(
r"[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*"
+
ContStr
=
group
(
r"[uU
bB
]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*"
+
group
(
"'"
,
r'\\\r?\n'
),
group
(
"'"
,
r'\\\r?\n'
),
r'[uU]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*'
+
r'[uU
bB
]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*'
+
group
(
'"'
,
r'\\\r?\n'
))
group
(
'"'
,
r'\\\r?\n'
))
PseudoExtras
=
group
(
r'\\\r?\n'
,
Comment
,
Triple
)
PseudoExtras
=
group
(
r'\\\r?\n'
,
Comment
,
Triple
)
PseudoToken
=
Whitespace
+
group
(
PseudoExtras
,
Number
,
Funny
,
ContStr
,
Name
)
PseudoToken
=
Whitespace
+
group
(
PseudoExtras
,
Number
,
Funny
,
ContStr
,
Name
)
...
...
Misc/NEWS
Dosyayı görüntüle @
43f42fc3
...
@@ -67,6 +67,10 @@ Core and Builtins
...
@@ -67,6 +67,10 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
15054
:
A
bug
in
tokenize
.
tokenize
that
caused
string
literals
with
'b'
and
'br'
prefixes
to
be
incorrectly
tokenized
has
been
fixed
.
Patch
by
Serhiy
Storchaka
.
-
Issue
#
15036
:
Allow
removing
or
changing
multiple
items
in
-
Issue
#
15036
:
Allow
removing
or
changing
multiple
items
in
single
-
file
mailboxes
(
mbox
,
MMDF
,
Babyl
)
flushing
the
mailbox
single
-
file
mailboxes
(
mbox
,
MMDF
,
Babyl
)
flushing
the
mailbox
between
the
changes
.
between
the
changes
.
...
...
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