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
6543912c
Unverified
Kaydet (Commit)
6543912c
authored
Eki 19, 2018
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
Eki 19, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-32912: Replace a DeprecationWarning with a SyntaxWarning (GH-9652)
for invalid escape sequences in string and bytes literals.
üst
20914483
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
12 deletions
+23
-12
lexical_analysis.rst
Doc/reference/lexical_analysis.rst
+5
-2
3.8.rst
Doc/whatsnew/3.8.rst
+6
-0
test_fstring.py
Lib/test/test_fstring.py
+1
-1
test_string_literals.py
Lib/test/test_string_literals.py
+6
-6
2018-10-01-10-41-53.bpo-32912.JeIOdM.rst
...ore and Builtins/2018-10-01-10-41-53.bpo-32912.JeIOdM.rst
+2
-0
ast.c
Python/ast.c
+3
-3
No files found.
Doc/reference/lexical_analysis.rst
Dosyayı görüntüle @
6543912c
...
...
@@ -559,8 +559,11 @@ escape sequences only recognized in string literals fall into the category of
unrecognized escapes for bytes literals.
.. versionchanged:: 3.6
Unrecognized escape sequences produce a DeprecationWarning. In
some future version of Python they will be a SyntaxError.
Unrecognized escape sequences produce a :exc:`DeprecationWarning`.
.. versionchanged:: 3.8
Unrecognized escape sequences produce a :exc:`SyntaxWarning`. In
some future version of Python they will be a :exc:`SyntaxError`.
Even in a raw literal, quotes can be escaped with a backslash, but the
backslash remains in the result; for example, ``r"\""`` is a valid string
...
...
Doc/whatsnew/3.8.rst
Dosyayı görüntüle @
6543912c
...
...
@@ -107,6 +107,12 @@ Other Language Changes
and :keyword:`return` statements.
(Contributed by David Cuthbert and Jordan Chapman in :issue:`32117`.)
* A backslash-character pair that is not a valid escape sequence generates
a :exc:`DeprecationWarning` since Python 3.6. In Python 3.8 it generates
a :exc:`SyntaxWarning` instead.
(Contributed by Serhiy Storchaka in :issue:`32912`.)
New Modules
===========
...
...
Lib/test/test_fstring.py
Dosyayı görüntüle @
6543912c
...
...
@@ -626,7 +626,7 @@ non-important content
self
.
assertEqual
(
f
'2
\x20
3'
,
'2 3'
)
self
.
assertEqual
(
f
'
\x20
3'
,
' 3'
)
with
self
.
assertWarns
(
Deprecation
Warning
):
# invalid escape sequence
with
self
.
assertWarns
(
Syntax
Warning
):
# invalid escape sequence
value
=
eval
(
r"f'\{6*7}'"
)
self
.
assertEqual
(
value
,
'
\\
42'
)
self
.
assertEqual
(
f
'
\\
{6*7}'
,
'
\\
42'
)
...
...
Lib/test/test_string_literals.py
Dosyayı görüntüle @
6543912c
...
...
@@ -109,18 +109,18 @@ class TestLiterals(unittest.TestCase):
for
b
in
range
(
1
,
128
):
if
b
in
b
"""
\n\r
"'01234567NU
\\
abfnrtuvx"""
:
continue
with
self
.
assertWarns
(
Deprecation
Warning
):
with
self
.
assertWarns
(
Syntax
Warning
):
self
.
assertEqual
(
eval
(
r"'\%c'"
%
b
),
'
\\
'
+
chr
(
b
))
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
'always'
,
category
=
Deprecation
Warning
)
warnings
.
simplefilter
(
'always'
,
category
=
Syntax
Warning
)
eval
(
"'''
\n\\
z'''"
)
self
.
assertEqual
(
len
(
w
),
1
)
self
.
assertEqual
(
w
[
0
]
.
filename
,
'<string>'
)
self
.
assertEqual
(
w
[
0
]
.
lineno
,
2
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
'error'
,
category
=
Deprecation
Warning
)
warnings
.
simplefilter
(
'error'
,
category
=
Syntax
Warning
)
with
self
.
assertRaises
(
SyntaxError
)
as
cm
:
eval
(
"'''
\n\\
z'''"
)
exc
=
cm
.
exception
...
...
@@ -158,18 +158,18 @@ class TestLiterals(unittest.TestCase):
for
b
in
range
(
1
,
128
):
if
b
in
b
"""
\n\r
"'01234567
\\
abfnrtvx"""
:
continue
with
self
.
assertWarns
(
Deprecation
Warning
):
with
self
.
assertWarns
(
Syntax
Warning
):
self
.
assertEqual
(
eval
(
r"b'\%c'"
%
b
),
b
'
\\
'
+
bytes
([
b
]))
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
'always'
,
category
=
Deprecation
Warning
)
warnings
.
simplefilter
(
'always'
,
category
=
Syntax
Warning
)
eval
(
"b'''
\n\\
z'''"
)
self
.
assertEqual
(
len
(
w
),
1
)
self
.
assertEqual
(
w
[
0
]
.
filename
,
'<string>'
)
self
.
assertEqual
(
w
[
0
]
.
lineno
,
2
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
'error'
,
category
=
Deprecation
Warning
)
warnings
.
simplefilter
(
'error'
,
category
=
Syntax
Warning
)
with
self
.
assertRaises
(
SyntaxError
)
as
cm
:
eval
(
"b'''
\n\\
z'''"
)
exc
=
cm
.
exception
...
...
Misc/NEWS.d/next/Core and Builtins/2018-10-01-10-41-53.bpo-32912.JeIOdM.rst
0 → 100644
Dosyayı görüntüle @
6543912c
A :exc:`SyntaxWarning` is now emitted instead of a :exc:`DeprecationWarning`
for invalid escape sequences in string and bytes literals.
Python/ast.c
Dosyayı görüntüle @
6543912c
...
...
@@ -4128,14 +4128,14 @@ warn_invalid_escape_sequence(struct compiling *c, const node *n,
if
(
msg
==
NULL
)
{
return
-
1
;
}
if
(
PyErr_WarnExplicitObject
(
PyExc_
Deprecation
Warning
,
msg
,
if
(
PyErr_WarnExplicitObject
(
PyExc_
Syntax
Warning
,
msg
,
c
->
c_filename
,
LINENO
(
n
),
NULL
,
NULL
)
<
0
)
{
if
(
PyErr_ExceptionMatches
(
PyExc_
Deprecation
Warning
))
{
if
(
PyErr_ExceptionMatches
(
PyExc_
Syntax
Warning
))
{
const
char
*
s
;
/* Replace the
Deprecation
Warning exception with a SyntaxError
/* Replace the
Syntax
Warning exception with a SyntaxError
to get a more accurate error report */
PyErr_Clear
();
...
...
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