Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b72406b8
Commit
b72406b8
authored
Mar 18, 2013
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor to fix refleaks
parent
6fba3dbc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
27 deletions
+49
-27
Parser/asdl_c.py
Parser/asdl_c.py
+15
-5
Python/Python-ast.c
Python/Python-ast.c
+34
-22
No files found.
Parser/asdl_c.py
View file @
b72406b8
...
@@ -499,12 +499,10 @@ class Obj2ModVisitor(PickleVisitor):
...
@@ -499,12 +499,10 @@ class Obj2ModVisitor(PickleVisitor):
def
visitField
(
self
,
field
,
name
,
sum
=
None
,
prod
=
None
,
depth
=
0
):
def
visitField
(
self
,
field
,
name
,
sum
=
None
,
prod
=
None
,
depth
=
0
):
ctype
=
get_c_type
(
field
.
type
)
ctype
=
get_c_type
(
field
.
type
)
if
field
.
opt
:
if
field
.
opt
:
add_check
=
" && _PyObject_GetAttrId(obj, &PyId_%s) != Py_None"
\
check
=
"exists_not_none(obj, &PyId_%s)"
%
(
field
.
name
,)
%
(
field
.
name
)
else
:
else
:
add_check
=
str
()
check
=
"_PyObject_HasAttrId(obj, &PyId_%s)"
%
(
field
.
name
,)
self
.
emit
(
"if (_PyObject_HasAttrId(obj, &PyId_%s)%s) {"
self
.
emit
(
"if (%s) {"
%
(
check
,),
depth
,
reflow
=
False
)
%
(
field
.
name
,
add_check
),
depth
,
reflow
=
False
)
self
.
emit
(
"int res;"
,
depth
+
1
)
self
.
emit
(
"int res;"
,
depth
+
1
)
if
field
.
seq
:
if
field
.
seq
:
self
.
emit
(
"Py_ssize_t len;"
,
depth
+
1
)
self
.
emit
(
"Py_ssize_t len;"
,
depth
+
1
)
...
@@ -931,6 +929,18 @@ static int add_ast_fields(void)
...
@@ -931,6 +929,18 @@ static int add_ast_fields(void)
return 0;
return 0;
}
}
static int exists_not_none(PyObject *obj, _Py_Identifier *id)
{
PyObject *attr = _PyObject_GetAttrId(obj, id);
if (!attr) {
PyErr_Clear();
return 0;
}
int isnone = attr == Py_None;
Py_DECREF(attr);
return !isnone;
}
"""
,
0
,
reflow
=
False
)
"""
,
0
,
reflow
=
False
)
self
.
emit
(
"static int init_types(void)"
,
0
)
self
.
emit
(
"static int init_types(void)"
,
0
)
...
...
Python/Python-ast.c
View file @
b72406b8
...
@@ -770,6 +770,18 @@ static int add_ast_fields(void)
...
@@ -770,6 +770,18 @@ static int add_ast_fields(void)
return
0
;
return
0
;
}
}
static
int
exists_not_none
(
PyObject
*
obj
,
_Py_Identifier
*
id
)
{
PyObject
*
attr
=
_PyObject_GetAttrId
(
obj
,
id
);
if
(
!
attr
)
{
PyErr_Clear
();
return
0
;
}
int
isnone
=
attr
==
Py_None
;
Py_DECREF
(
attr
);
return
!
isnone
;
}
static
int
init_types
(
void
)
static
int
init_types
(
void
)
{
{
...
@@ -3846,7 +3858,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
...
@@ -3846,7 +3858,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
decorator_list
\"
missing from FunctionDef"
);
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
decorator_list
\"
missing from FunctionDef"
);
return
1
;
return
1
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_returns
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_returns
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_returns
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_returns
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_returns
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -3937,7 +3949,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
...
@@ -3937,7 +3949,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
keywords
\"
missing from ClassDef"
);
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
keywords
\"
missing from ClassDef"
);
return
1
;
return
1
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_starargs
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_starargs
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_starargs
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_starargs
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_starargs
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -3948,7 +3960,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
...
@@ -3948,7 +3960,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
}
else
{
}
else
{
starargs
=
NULL
;
starargs
=
NULL
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_kwargs
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_kwargs
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_kwargs
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_kwargs
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_kwargs
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -4021,7 +4033,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
...
@@ -4021,7 +4033,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if
(
isinstance
)
{
if
(
isinstance
)
{
expr_ty
value
;
expr_ty
value
;
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_value
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_value
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_value
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_value
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_value
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -4479,7 +4491,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
...
@@ -4479,7 +4491,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
expr_ty
exc
;
expr_ty
exc
;
expr_ty
cause
;
expr_ty
cause
;
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_exc
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_exc
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_exc
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_exc
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_exc
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -4490,7 +4502,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
...
@@ -4490,7 +4502,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
}
else
{
}
else
{
exc
=
NULL
;
exc
=
NULL
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_cause
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_cause
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_cause
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_cause
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_cause
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -4640,7 +4652,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
...
@@ -4640,7 +4652,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
test
\"
missing from Assert"
);
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
test
\"
missing from Assert"
);
return
1
;
return
1
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_msg
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_msg
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_msg
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_msg
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_msg
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -4700,7 +4712,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
...
@@ -4700,7 +4712,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
asdl_seq
*
names
;
asdl_seq
*
names
;
int
level
;
int
level
;
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_module
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_module
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_module
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_module
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_module
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -4736,7 +4748,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
...
@@ -4736,7 +4748,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
names
\"
missing from ImportFrom"
);
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
names
\"
missing from ImportFrom"
);
return
1
;
return
1
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_level
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_level
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_level
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_level
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_level
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -5455,7 +5467,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
...
@@ -5455,7 +5467,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if
(
isinstance
)
{
if
(
isinstance
)
{
expr_ty
value
;
expr_ty
value
;
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_value
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_value
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_value
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_value
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_value
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -5642,7 +5654,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
...
@@ -5642,7 +5654,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
keywords
\"
missing from Call"
);
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
keywords
\"
missing from Call"
);
return
1
;
return
1
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_starargs
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_starargs
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_starargs
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_starargs
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_starargs
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -5653,7 +5665,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
...
@@ -5653,7 +5665,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
}
else
{
}
else
{
starargs
=
NULL
;
starargs
=
NULL
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_kwargs
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_kwargs
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_kwargs
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_kwargs
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_kwargs
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -6124,7 +6136,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
...
@@ -6124,7 +6136,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
expr_ty
upper
;
expr_ty
upper
;
expr_ty
step
;
expr_ty
step
;
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_lower
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_lower
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_lower
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_lower
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_lower
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -6135,7 +6147,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
...
@@ -6135,7 +6147,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
}
else
{
}
else
{
lower
=
NULL
;
lower
=
NULL
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_upper
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_upper
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_upper
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_upper
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_upper
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -6146,7 +6158,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
...
@@ -6146,7 +6158,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
}
else
{
}
else
{
upper
=
NULL
;
upper
=
NULL
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_step
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_step
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_step
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_step
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_step
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -6601,7 +6613,7 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
...
@@ -6601,7 +6613,7 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
identifier
name
;
identifier
name
;
asdl_seq
*
body
;
asdl_seq
*
body
;
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_type
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_type
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_type
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_type
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_type
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -6612,7 +6624,7 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
...
@@ -6612,7 +6624,7 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
}
else
{
}
else
{
type
=
NULL
;
type
=
NULL
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_name
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_name
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_name
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_name
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_name
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -6696,7 +6708,7 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
...
@@ -6696,7 +6708,7 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
args
\"
missing from arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
args
\"
missing from arguments"
);
return
1
;
return
1
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_vararg
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_vararg
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_vararg
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_vararg
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_vararg
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -6757,7 +6769,7 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
...
@@ -6757,7 +6769,7 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
kw_defaults
\"
missing from arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
kw_defaults
\"
missing from arguments"
);
return
1
;
return
1
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_kwarg
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_kwarg
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_kwarg
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_kwarg
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_kwarg
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -6820,7 +6832,7 @@ obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena)
...
@@ -6820,7 +6832,7 @@ obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena)
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
arg
\"
missing from arg"
);
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
arg
\"
missing from arg"
);
return
1
;
return
1
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_annotation
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_annotation
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_annotation
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_annotation
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_annotation
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -6895,7 +6907,7 @@ obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena)
...
@@ -6895,7 +6907,7 @@ obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena)
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
name
\"
missing from alias"
);
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
name
\"
missing from alias"
);
return
1
;
return
1
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_asname
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_asname
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_asname
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_asname
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_asname
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
@@ -6932,7 +6944,7 @@ obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena)
...
@@ -6932,7 +6944,7 @@ obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena)
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
context_expr
\"
missing from withitem"
);
PyErr_SetString
(
PyExc_TypeError
,
"required field
\"
context_expr
\"
missing from withitem"
);
return
1
;
return
1
;
}
}
if
(
_PyObject_HasAttrId
(
obj
,
&
PyId_optional_vars
)
&&
_PyObject_GetAttrId
(
obj
,
&
PyId_optional_vars
)
!=
Py_None
)
{
if
(
exists_not_none
(
obj
,
&
PyId_optional_vars
)
)
{
int
res
;
int
res
;
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_optional_vars
);
tmp
=
_PyObject_GetAttrId
(
obj
,
&
PyId_optional_vars
);
if
(
tmp
==
NULL
)
goto
failed
;
if
(
tmp
==
NULL
)
goto
failed
;
...
...
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