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
79fa98af
Kaydet (Commit)
79fa98af
authored
Haz 01, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19656: Running Python with the -3 option now also warns about
non-ascii bytes literals.
üst
e75a5550
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
test_py3kwarn.py
Lib/test/test_py3kwarn.py
+5
-0
NEWS
Misc/NEWS
+3
-0
ast.c
Python/ast.c
+17
-5
No files found.
Lib/test/test_py3kwarn.py
Dosyayı görüntüle @
79fa98af
...
@@ -307,6 +307,11 @@ class TestPy3KWarnings(unittest.TestCase):
...
@@ -307,6 +307,11 @@ class TestPy3KWarnings(unittest.TestCase):
w
.
reset
()
w
.
reset
()
self
.
assertWarning
(
sequenceIncludes
(
range
(
3
),
2
),
w
,
seq_warn
)
self
.
assertWarning
(
sequenceIncludes
(
range
(
3
),
2
),
w
,
seq_warn
)
def
test_nonascii_bytes_literals
(
self
):
expected
=
"non-ascii bytes literals not supported in 3.x"
with
check_py3k_warnings
((
expected
,
SyntaxWarning
)):
exec
"b'
\xbd
'"
class
TestStdlibRemovals
(
unittest
.
TestCase
):
class
TestStdlibRemovals
(
unittest
.
TestCase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
79fa98af
...
@@ -10,6 +10,9 @@ What's New in Python 2.7.8?
...
@@ -10,6 +10,9 @@ What's New in Python 2.7.8?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #19656: Running Python with the -3 option now also warns about
non-ascii bytes literals.
- Issue #21523: Fix over-pessimistic computation of the stack effect of
- Issue #21523: Fix over-pessimistic computation of the stack effect of
some opcodes in the compiler. This also fixes a quadratic compilation
some opcodes in the compiler. This also fixes a quadratic compilation
time issue noticeable when compiling code with a large number of "and"
time issue noticeable when compiling code with a large number of "and"
...
...
Python/ast.c
Dosyayı görüntüle @
79fa98af
...
@@ -37,7 +37,7 @@ static expr_ty ast_for_testlist_comp(struct compiling *, const node *);
...
@@ -37,7 +37,7 @@ static expr_ty ast_for_testlist_comp(struct compiling *, const node *);
static
expr_ty
ast_for_call
(
struct
compiling
*
,
const
node
*
,
expr_ty
);
static
expr_ty
ast_for_call
(
struct
compiling
*
,
const
node
*
,
expr_ty
);
static
PyObject
*
parsenumber
(
struct
compiling
*
,
const
char
*
);
static
PyObject
*
parsenumber
(
struct
compiling
*
,
const
char
*
);
static
PyObject
*
parsestr
(
struct
compiling
*
,
const
char
*
);
static
PyObject
*
parsestr
(
struct
compiling
*
,
const
node
*
n
,
const
char
*
);
static
PyObject
*
parsestrplus
(
struct
compiling
*
,
const
node
*
n
);
static
PyObject
*
parsestrplus
(
struct
compiling
*
,
const
node
*
n
);
#ifndef LINENO
#ifndef LINENO
...
@@ -3444,13 +3444,14 @@ decode_unicode(struct compiling *c, const char *s, size_t len, int rawmode, cons
...
@@ -3444,13 +3444,14 @@ decode_unicode(struct compiling *c, const char *s, size_t len, int rawmode, cons
* parsestr parses it, and returns the decoded Python string object.
* parsestr parses it, and returns the decoded Python string object.
*/
*/
static
PyObject
*
static
PyObject
*
parsestr
(
struct
compiling
*
c
,
const
char
*
s
)
parsestr
(
struct
compiling
*
c
,
const
node
*
n
,
const
char
*
s
)
{
{
size_t
len
;
size_t
len
,
i
;
int
quote
=
Py_CHARMASK
(
*
s
);
int
quote
=
Py_CHARMASK
(
*
s
);
int
rawmode
=
0
;
int
rawmode
=
0
;
int
need_encoding
;
int
need_encoding
;
int
unicode
=
c
->
c_future_unicode
;
int
unicode
=
c
->
c_future_unicode
;
int
bytes
=
0
;
if
(
isalpha
(
quote
)
||
quote
==
'_'
)
{
if
(
isalpha
(
quote
)
||
quote
==
'_'
)
{
if
(
quote
==
'u'
||
quote
==
'U'
)
{
if
(
quote
==
'u'
||
quote
==
'U'
)
{
...
@@ -3460,6 +3461,7 @@ parsestr(struct compiling *c, const char *s)
...
@@ -3460,6 +3461,7 @@ parsestr(struct compiling *c, const char *s)
if
(
quote
==
'b'
||
quote
==
'B'
)
{
if
(
quote
==
'b'
||
quote
==
'B'
)
{
quote
=
*++
s
;
quote
=
*++
s
;
unicode
=
0
;
unicode
=
0
;
bytes
=
1
;
}
}
if
(
quote
==
'r'
||
quote
==
'R'
)
{
if
(
quote
==
'r'
||
quote
==
'R'
)
{
quote
=
*++
s
;
quote
=
*++
s
;
...
@@ -3489,6 +3491,16 @@ parsestr(struct compiling *c, const char *s)
...
@@ -3489,6 +3491,16 @@ parsestr(struct compiling *c, const char *s)
return
NULL
;
return
NULL
;
}
}
}
}
if
(
Py_Py3kWarningFlag
&&
bytes
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
((
unsigned
char
)
s
[
i
]
>
127
)
{
if
(
!
ast_warn
(
c
,
n
,
"non-ascii bytes literals not supported in 3.x"
))
return
NULL
;
break
;
}
}
}
#ifdef Py_USING_UNICODE
#ifdef Py_USING_UNICODE
if
(
unicode
||
Py_UnicodeFlag
)
{
if
(
unicode
||
Py_UnicodeFlag
)
{
return
decode_unicode
(
c
,
s
,
len
,
rawmode
,
c
->
c_encoding
);
return
decode_unicode
(
c
,
s
,
len
,
rawmode
,
c
->
c_encoding
);
...
@@ -3531,11 +3543,11 @@ parsestrplus(struct compiling *c, const node *n)
...
@@ -3531,11 +3543,11 @@ parsestrplus(struct compiling *c, const node *n)
PyObject
*
v
;
PyObject
*
v
;
int
i
;
int
i
;
REQ
(
CHILD
(
n
,
0
),
STRING
);
REQ
(
CHILD
(
n
,
0
),
STRING
);
if
((
v
=
parsestr
(
c
,
STR
(
CHILD
(
n
,
0
))))
!=
NULL
)
{
if
((
v
=
parsestr
(
c
,
n
,
STR
(
CHILD
(
n
,
0
))))
!=
NULL
)
{
/* String literal concatenation */
/* String literal concatenation */
for
(
i
=
1
;
i
<
NCH
(
n
);
i
++
)
{
for
(
i
=
1
;
i
<
NCH
(
n
);
i
++
)
{
PyObject
*
s
;
PyObject
*
s
;
s
=
parsestr
(
c
,
STR
(
CHILD
(
n
,
i
)));
s
=
parsestr
(
c
,
n
,
STR
(
CHILD
(
n
,
i
)));
if
(
s
==
NULL
)
if
(
s
==
NULL
)
goto
onError
;
goto
onError
;
if
(
PyString_Check
(
v
)
&&
PyString_Check
(
s
))
{
if
(
PyString_Check
(
v
)
&&
PyString_Check
(
s
))
{
...
...
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