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
2c98faad
Kaydet (Commit)
2c98faad
authored
Kas 08, 2008
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
check for assignment to __debug__ during AST generation
Also, give assignment to None a better error message
üst
942e4779
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
17 deletions
+11
-17
test_syntax.py
Lib/test/test_syntax.py
+8
-10
ast.c
Python/ast.c
+3
-1
compile.c
Python/compile.c
+0
-6
No files found.
Lib/test/test_syntax.py
Dosyayı görüntüle @
2c98faad
...
@@ -27,15 +27,13 @@ In ast.c, syntax errors are raised by calling ast_error().
...
@@ -27,15 +27,13 @@ In ast.c, syntax errors are raised by calling ast_error().
Errors from set_context():
Errors from set_context():
TODO(jhylton): "assignment to None" is inconsistent with other messages
>>> obj.None = 1
>>> obj.None = 1
Traceback (most recent call last):
Traceback (most recent call last):
SyntaxError:
assignment
to None (<doctest test.test_syntax[1]>, line 1)
SyntaxError:
cannot assign
to None (<doctest test.test_syntax[1]>, line 1)
>>> None = 1
>>> None = 1
Traceback (most recent call last):
Traceback (most recent call last):
SyntaxError:
assignment
to None (<doctest test.test_syntax[2]>, line 1)
SyntaxError:
cannot assign
to None (<doctest test.test_syntax[2]>, line 1)
It's a syntax error to assign to the empty tuple. Why isn't it an
It's a syntax error to assign to the empty tuple. Why isn't it an
error to assign to the empty list? It will always raise some error at
error to assign to the empty list? It will always raise some error at
...
@@ -95,7 +93,7 @@ From compiler_complex_args():
...
@@ -95,7 +93,7 @@ From compiler_complex_args():
>>> def f(None=1):
>>> def f(None=1):
... pass
... pass
Traceback (most recent call last):
Traceback (most recent call last):
SyntaxError:
assignment
to None (<doctest test.test_syntax[14]>, line 1)
SyntaxError:
cannot assign
to None (<doctest test.test_syntax[14]>, line 1)
From ast_for_arguments():
From ast_for_arguments():
...
@@ -108,17 +106,17 @@ SyntaxError: non-default argument follows default argument (<doctest test.test_s
...
@@ -108,17 +106,17 @@ SyntaxError: non-default argument follows default argument (<doctest test.test_s
>>> def f(x, None):
>>> def f(x, None):
... pass
... pass
Traceback (most recent call last):
Traceback (most recent call last):
SyntaxError:
assignment
to None (<doctest test.test_syntax[16]>, line 1)
SyntaxError:
cannot assign
to None (<doctest test.test_syntax[16]>, line 1)
>>> def f(*None):
>>> def f(*None):
... pass
... pass
Traceback (most recent call last):
Traceback (most recent call last):
SyntaxError:
assignment
to None (<doctest test.test_syntax[17]>, line 1)
SyntaxError:
cannot assign
to None (<doctest test.test_syntax[17]>, line 1)
>>> def f(**None):
>>> def f(**None):
... pass
... pass
Traceback (most recent call last):
Traceback (most recent call last):
SyntaxError:
assignment
to None (<doctest test.test_syntax[18]>, line 1)
SyntaxError:
cannot assign
to None (<doctest test.test_syntax[18]>, line 1)
From ast_for_funcdef():
From ast_for_funcdef():
...
@@ -126,7 +124,7 @@ From ast_for_funcdef():
...
@@ -126,7 +124,7 @@ From ast_for_funcdef():
>>> def None(x):
>>> def None(x):
... pass
... pass
Traceback (most recent call last):
Traceback (most recent call last):
SyntaxError:
assignment
to None (<doctest test.test_syntax[19]>, line 1)
SyntaxError:
cannot assign
to None (<doctest test.test_syntax[19]>, line 1)
From ast_for_call():
From ast_for_call():
...
@@ -231,7 +229,7 @@ Traceback (most recent call last):
...
@@ -231,7 +229,7 @@ Traceback (most recent call last):
SyntaxError: augmented assignment to generator expression not possible (<doctest test.test_syntax[31]>, line 1)
SyntaxError: augmented assignment to generator expression not possible (<doctest test.test_syntax[31]>, line 1)
>>> None += 1
>>> None += 1
Traceback (most recent call last):
Traceback (most recent call last):
SyntaxError:
assignment
to None (<doctest test.test_syntax[32]>, line 1)
SyntaxError:
cannot assign
to None (<doctest test.test_syntax[32]>, line 1)
>>> f() += 1
>>> f() += 1
Traceback (most recent call last):
Traceback (most recent call last):
SyntaxError: illegal expression for augmented assignment (<doctest test.test_syntax[33]>, line 1)
SyntaxError: illegal expression for augmented assignment (<doctest test.test_syntax[33]>, line 1)
...
...
Python/ast.c
Dosyayı görüntüle @
2c98faad
...
@@ -130,7 +130,9 @@ static int
...
@@ -130,7 +130,9 @@ static int
forbidden_check
(
struct
compiling
*
c
,
const
node
*
n
,
const
char
*
x
)
forbidden_check
(
struct
compiling
*
c
,
const
node
*
n
,
const
char
*
x
)
{
{
if
(
!
strcmp
(
x
,
"None"
))
if
(
!
strcmp
(
x
,
"None"
))
return
ast_error
(
n
,
"assignment to None"
);
return
ast_error
(
n
,
"cannot assign to None"
);
if
(
!
strcmp
(
x
,
"__debug__"
))
return
ast_error
(
n
,
"cannot assign to __debug__"
);
if
(
Py_Py3kWarningFlag
)
{
if
(
Py_Py3kWarningFlag
)
{
if
(
!
(
strcmp
(
x
,
"True"
)
&&
strcmp
(
x
,
"False"
))
&&
if
(
!
(
strcmp
(
x
,
"True"
)
&&
strcmp
(
x
,
"False"
))
&&
!
ast_warn
(
c
,
n
,
"assignment to True or False is forbidden in 3.x"
))
!
ast_warn
(
c
,
n
,
"assignment to True or False is forbidden in 3.x"
))
...
...
Python/compile.c
Dosyayı görüntüle @
2c98faad
...
@@ -2344,12 +2344,6 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
...
@@ -2344,12 +2344,6 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
PyObject
*
mangled
;
PyObject
*
mangled
;
/* XXX AugStore isn't used anywhere! */
/* XXX AugStore isn't used anywhere! */
/* First check for assignment to __debug__. Param? */
if
((
ctx
==
Store
||
ctx
==
AugStore
||
ctx
==
Del
)
&&
!
strcmp
(
PyString_AS_STRING
(
name
),
"__debug__"
))
{
return
compiler_error
(
c
,
"can not assign to __debug__"
);
}
mangled
=
_Py_Mangle
(
c
->
u
->
u_private
,
name
);
mangled
=
_Py_Mangle
(
c
->
u
->
u_private
,
name
);
if
(
!
mangled
)
if
(
!
mangled
)
return
0
;
return
0
;
...
...
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