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
694de3bf
Kaydet (Commit)
694de3bf
authored
Haz 15, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #27301: Fixed incorrect return codes for errors in compile.c.
üst
33e7ca78
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
+20
-16
compile.c
Python/compile.c
+20
-16
No files found.
Python/compile.c
Dosyayı görüntüle @
694de3bf
...
...
@@ -1494,6 +1494,9 @@ static int
compiler_visit_kwonlydefaults
(
struct
compiler
*
c
,
asdl_seq
*
kwonlyargs
,
asdl_seq
*
kw_defaults
)
{
/* Return the number of defaults + 1.
Returns 0 on error.
*/
int
i
,
default_count
=
0
;
for
(
i
=
0
;
i
<
asdl_seq_LEN
(
kwonlyargs
);
i
++
)
{
arg_ty
arg
=
asdl_seq_GET
(
kwonlyargs
,
i
);
...
...
@@ -1501,16 +1504,16 @@ compiler_visit_kwonlydefaults(struct compiler *c, asdl_seq *kwonlyargs,
if
(
default_
)
{
PyObject
*
mangled
=
_Py_Mangle
(
c
->
u
->
u_private
,
arg
->
arg
);
if
(
!
mangled
)
return
-
1
;
return
0
;
ADDOP_O
(
c
,
LOAD_CONST
,
mangled
,
consts
);
Py_DECREF
(
mangled
);
if
(
!
compiler_visit_expr
(
c
,
default_
))
{
return
-
1
;
return
0
;
}
default_count
++
;
}
}
return
default_count
;
return
default_count
+
1
;
}
static
int
...
...
@@ -1554,17 +1557,17 @@ compiler_visit_annotations(struct compiler *c, arguments_ty args,
expr_ty
returns
)
{
/* Push arg annotations and a list of the argument names. Return the #
of items pushed. The expressions are evaluated out-of-order wrt the
of items pushed
+ 1
. The expressions are evaluated out-of-order wrt the
source code.
More than 2^16-1 annotations is a SyntaxError. Returns
-1
on error.
More than 2^16-1 annotations is a SyntaxError. Returns
0
on error.
*/
static
identifier
return_str
;
PyObject
*
names
;
Py_ssize_t
len
;
names
=
PyList_New
(
0
);
if
(
!
names
)
return
-
1
;
return
0
;
if
(
!
compiler_visit_argannotations
(
c
,
args
->
args
,
names
))
goto
error
;
...
...
@@ -1614,11 +1617,11 @@ compiler_visit_annotations(struct compiler *c, arguments_ty args,
Py_DECREF
(
names
);
/* We just checked that len <= 65535, see above */
return
Py_SAFE_DOWNCAST
(
len
,
Py_ssize_t
,
int
);
return
Py_SAFE_DOWNCAST
(
len
+
1
,
Py_ssize_t
,
int
);
error:
Py_DECREF
(
names
);
return
-
1
;
return
0
;
}
static
int
...
...
@@ -1667,13 +1670,14 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async)
if
(
args
->
kwonlyargs
)
{
int
res
=
compiler_visit_kwonlydefaults
(
c
,
args
->
kwonlyargs
,
args
->
kw_defaults
);
if
(
res
<
0
)
if
(
res
==
0
)
return
0
;
kw_default_count
=
res
;
kw_default_count
=
res
-
1
;
}
num_annotations
=
compiler_visit_annotations
(
c
,
args
,
returns
);
if
(
num_annotations
<
0
)
if
(
num_annotations
==
0
)
return
0
;
num_annotations
--
;
assert
((
num_annotations
&
0xFFFF
)
==
num_annotations
);
if
(
!
compiler_enter_scope
(
c
,
name
,
...
...
@@ -1889,8 +1893,8 @@ compiler_lambda(struct compiler *c, expr_ty e)
if
(
args
->
kwonlyargs
)
{
int
res
=
compiler_visit_kwonlydefaults
(
c
,
args
->
kwonlyargs
,
args
->
kw_defaults
);
if
(
res
<
0
)
return
0
;
kw_default_count
=
res
;
if
(
res
==
0
)
return
0
;
kw_default_count
=
res
-
1
;
}
if
(
!
compiler_enter_scope
(
c
,
name
,
COMPILER_SCOPE_LAMBDA
,
(
void
*
)
e
,
e
->
lineno
))
...
...
@@ -2403,7 +2407,7 @@ compiler_import_as(struct compiler *c, identifier name, identifier asname)
Py_ssize_t
dot
=
PyUnicode_FindChar
(
name
,
'.'
,
0
,
PyUnicode_GET_LENGTH
(
name
),
1
);
if
(
dot
==
-
2
)
return
-
1
;
return
0
;
if
(
dot
!=
-
1
)
{
/* Consume the base module name to get the first attribute */
Py_ssize_t
pos
=
dot
+
1
;
...
...
@@ -2412,12 +2416,12 @@ compiler_import_as(struct compiler *c, identifier name, identifier asname)
dot
=
PyUnicode_FindChar
(
name
,
'.'
,
pos
,
PyUnicode_GET_LENGTH
(
name
),
1
);
if
(
dot
==
-
2
)
return
-
1
;
return
0
;
attr
=
PyUnicode_Substring
(
name
,
pos
,
(
dot
!=
-
1
)
?
dot
:
PyUnicode_GET_LENGTH
(
name
));
if
(
!
attr
)
return
-
1
;
return
0
;
ADDOP_O
(
c
,
LOAD_ATTR
,
attr
,
names
);
Py_DECREF
(
attr
);
pos
=
dot
+
1
;
...
...
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