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
5f429e02
Kaydet (Commit)
5f429e02
authored
Ara 13, 2009
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
account for PyObject_IsInstance's new ability to fail
üst
c169c781
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
4 deletions
+24
-4
asdl_c.py
Parser/asdl_c.py
+19
-3
Python-ast.c
Python/Python-ast.c
+0
-0
bltinmodule.c
Python/bltinmodule.c
+5
-1
No files found.
Parser/asdl_c.py
Dosyayı görüntüle @
5f429e02
...
...
@@ -367,6 +367,7 @@ class Obj2ModVisitor(PickleVisitor):
self
.
emit
(
"obj2ast_
%
s(PyObject* obj,
%
s* out, PyArena* arena)"
%
(
name
,
ctype
),
0
)
self
.
emit
(
"{"
,
0
)
self
.
emit
(
"PyObject* tmp = NULL;"
,
1
)
self
.
emit
(
"int isinstance;"
,
1
)
self
.
emit
(
""
,
0
)
def
sumTrailer
(
self
,
name
):
...
...
@@ -386,7 +387,13 @@ class Obj2ModVisitor(PickleVisitor):
def
simpleSum
(
self
,
sum
,
name
):
self
.
funcHeader
(
name
)
for
t
in
sum
.
types
:
self
.
emit
(
"if (PyObject_IsInstance(obj, (PyObject*)
%
s_type)) {"
%
t
.
name
,
1
)
line
=
(
"isinstance = PyObject_IsInstance(obj, "
"(PyObject *)
%
s_type);"
)
self
.
emit
(
line
%
(
t
.
name
,),
1
)
self
.
emit
(
"if (isinstance == -1) {"
,
1
)
self
.
emit
(
"return 1;"
,
2
)
self
.
emit
(
"}"
,
1
)
self
.
emit
(
"if (isinstance) {"
,
1
)
self
.
emit
(
"*out =
%
s;"
%
t
.
name
,
2
)
self
.
emit
(
"return 0;"
,
2
)
self
.
emit
(
"}"
,
1
)
...
...
@@ -408,7 +415,12 @@ class Obj2ModVisitor(PickleVisitor):
for
a
in
sum
.
attributes
:
self
.
visitField
(
a
,
name
,
sum
=
sum
,
depth
=
1
)
for
t
in
sum
.
types
:
self
.
emit
(
"if (PyObject_IsInstance(obj, (PyObject*)
%
s_type)) {"
%
t
.
name
,
1
)
line
=
"isinstance = PyObject_IsInstance(obj, (PyObject*)
%
s_type);"
self
.
emit
(
line
%
(
t
.
name
,),
1
)
self
.
emit
(
"if (isinstance == -1) {"
,
1
)
self
.
emit
(
"return 1;"
,
2
)
self
.
emit
(
"}"
,
1
)
self
.
emit
(
"if (isinstance) {"
,
1
)
for
f
in
t
.
fields
:
self
.
visitFieldDeclaration
(
f
,
t
.
name
,
sum
=
sum
,
depth
=
2
)
self
.
emit
(
""
,
0
)
...
...
@@ -1093,11 +1105,15 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type,
(PyObject*)Interactive_type};
char *req_name[] = {"Module", "Expression", "Interactive"};
int isinstance;
assert(0 <= mode && mode <= 2);
init_types();
if (!PyObject_IsInstance(ast, req_type[mode])) {
isinstance = PyObject_IsInstance(ast, req_type[mode]);
if (isinstance == -1)
return NULL;
if (!isinstance) {
PyErr_Format(PyExc_TypeError, "expected
%
s node, got
%.400
s",
req_name[mode], Py_TYPE(ast)->tp_name);
return NULL;
...
...
Python/Python-ast.c
Dosyayı görüntüle @
5f429e02
This diff is collapsed.
Click to expand it.
Python/bltinmodule.c
Dosyayı görüntüle @
5f429e02
...
...
@@ -466,6 +466,7 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds)
int
mode
=
-
1
;
int
dont_inherit
=
0
;
int
supplied_flags
=
0
;
int
is_ast
;
PyCompilerFlags
cf
;
PyObject
*
result
=
NULL
,
*
cmd
,
*
tmp
=
NULL
;
Py_ssize_t
length
;
...
...
@@ -505,7 +506,10 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds)
return
NULL
;
}
if
(
PyAST_Check
(
cmd
))
{
is_ast
=
PyAST_Check
(
cmd
);
if
(
is_ast
==
-
1
)
return
NULL
;
if
(
is_ast
)
{
if
(
supplied_flags
&
PyCF_ONLY_AST
)
{
Py_INCREF
(
cmd
);
result
=
cmd
;
...
...
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