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
11a70c79
Kaydet (Commit)
11a70c79
authored
Tem 17, 2004
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Upgrade None assignment SyntaxWarning to a SyntaxError.
üst
910d8f1e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
7 deletions
+21
-7
test_compile.py
Lib/test/test_compile.py
+15
-0
compile.c
Python/compile.c
+6
-7
No files found.
Lib/test/test_compile.py
Dosyayı görüntüle @
11a70c79
...
@@ -138,6 +138,21 @@ if 1:
...
@@ -138,6 +138,21 @@ if 1:
self
.
assertEqual
(
i
,
1
)
self
.
assertEqual
(
i
,
1
)
self
.
assertEqual
(
j
,
-
1
)
self
.
assertEqual
(
j
,
-
1
)
def
test_none_assignment
(
self
):
stmts
=
[
'None = 0'
,
'None += 0'
,
'__builtins__.None = 0'
,
'def None(): pass'
,
'class None: pass'
,
'(a, None) = 0, 0'
,
'for None in range(10): pass'
,
'def f(None): pass'
,
]
for
stmt
in
stmts
:
stmt
+=
"
\n
"
self
.
assertRaises
(
SyntaxError
,
compile
,
stmt
,
'tmp'
,
'single'
)
self
.
assertRaises
(
SyntaxError
,
compile
,
stmt
,
'tmp'
,
'exec'
)
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
TestSpecifics
)
test_support
.
run_unittest
(
TestSpecifics
)
...
...
Python/compile.c
Dosyayı görüntüle @
11a70c79
...
@@ -1227,10 +1227,8 @@ none_assignment_check(struct compiling *c, char *name, int assigning)
...
@@ -1227,10 +1227,8 @@ none_assignment_check(struct compiling *c, char *name, int assigning)
msg
=
"assignment to None"
;
msg
=
"assignment to None"
;
else
else
msg
=
"deleting None"
;
msg
=
"deleting None"
;
if
(
issue_warning
(
msg
,
c
->
c_filename
,
c
->
c_lineno
)
<
0
)
{
com_error
(
c
,
PyExc_SyntaxError
,
msg
);
c
->
c_errors
++
;
return
-
1
;
return
-
1
;
}
}
}
return
0
;
return
0
;
}
}
...
@@ -1247,7 +1245,6 @@ com_addop_varname(struct compiling *c, int kind, char *name)
...
@@ -1247,7 +1245,6 @@ com_addop_varname(struct compiling *c, int kind, char *name)
if
(
kind
!=
VAR_LOAD
&&
if
(
kind
!=
VAR_LOAD
&&
none_assignment_check
(
c
,
name
,
kind
==
VAR_STORE
))
none_assignment_check
(
c
,
name
,
kind
==
VAR_STORE
))
{
{
c
->
c_errors
++
;
i
=
255
;
i
=
255
;
goto
done
;
goto
done
;
}
}
...
@@ -5483,8 +5480,10 @@ symtable_add_def(struct symtable *st, char *name, int flag)
...
@@ -5483,8 +5480,10 @@ symtable_add_def(struct symtable *st, char *name, int flag)
if
((
flag
&
DEF_PARAM
)
&&
!
(
flag
&
DEF_INTUPLE
)
&&
if
((
flag
&
DEF_PARAM
)
&&
!
(
flag
&
DEF_INTUPLE
)
&&
*
name
==
'N'
&&
strcmp
(
name
,
"None"
)
==
0
)
*
name
==
'N'
&&
strcmp
(
name
,
"None"
)
==
0
)
{
{
if
(
symtable_warn
(
st
,
"argument named None"
))
PyErr_SetString
(
PyExc_SyntaxError
,
return
-
1
;
"Invalid syntax. Assignment to None."
);
symtable_error
(
st
,
0
);
return
-
1
;
}
}
if
(
_Py_Mangle
(
st
->
st_private
,
name
,
buffer
,
sizeof
(
buffer
)))
if
(
_Py_Mangle
(
st
->
st_private
,
name
,
buffer
,
sizeof
(
buffer
)))
name
=
buffer
;
name
=
buffer
;
...
...
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