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
8b2d711e
Commit
8b2d711e
authored
Aug 15, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
parents
1c1572b9
9ccef3d9
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
76 additions
and
74 deletions
+76
-74
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_csv.c
Modules/_csv.c
+6
-2
Modules/_io/textio.c
Modules/_io/textio.c
+4
-1
Modules/_posixsubprocess.c
Modules/_posixsubprocess.c
+3
-4
Modules/_ssl.c
Modules/_ssl.c
+3
-3
Modules/itertoolsmodule.c
Modules/itertoolsmodule.c
+12
-7
Modules/parsermodule.c
Modules/parsermodule.c
+16
-32
Modules/pyexpat.c
Modules/pyexpat.c
+19
-19
Objects/typeobject.c
Objects/typeobject.c
+7
-5
Python/bltinmodule.c
Python/bltinmodule.c
+3
-1
No files found.
Misc/NEWS
View file @
8b2d711e
...
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Release Candidate 1?
...
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Release Candidate 1?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #15604: Update uses of PyObject_IsTrue() to check for and handle
errors correctly. Patch by Serhiy Storchaka.
Library
Library
-------
-------
...
...
Modules/_csv.c
View file @
8b2d711e
...
@@ -196,8 +196,12 @@ _set_bool(const char *name, int *target, PyObject *src, int dflt)
...
@@ -196,8 +196,12 @@ _set_bool(const char *name, int *target, PyObject *src, int dflt)
{
{
if
(
src
==
NULL
)
if
(
src
==
NULL
)
*
target
=
dflt
;
*
target
=
dflt
;
else
else
{
*
target
=
PyObject_IsTrue
(
src
);
int
b
=
PyObject_IsTrue
(
src
);
if
(
b
<
0
)
return
-
1
;
*
target
=
b
;
}
return
0
;
return
0
;
}
}
...
...
Modules/_io/textio.c
View file @
8b2d711e
...
@@ -1056,8 +1056,11 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
...
@@ -1056,8 +1056,11 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
res
=
_PyObject_CallMethodId
(
buffer
,
&
PyId_seekable
,
NULL
);
res
=
_PyObject_CallMethodId
(
buffer
,
&
PyId_seekable
,
NULL
);
if
(
res
==
NULL
)
if
(
res
==
NULL
)
goto
error
;
goto
error
;
self
->
seekable
=
self
->
telling
=
PyObject_IsTrue
(
res
);
r
=
PyObject_IsTrue
(
res
);
Py_DECREF
(
res
);
Py_DECREF
(
res
);
if
(
r
<
0
)
goto
error
;
self
->
seekable
=
self
->
telling
=
r
;
self
->
has_read1
=
_PyObject_HasAttrId
(
buffer
,
&
PyId_read1
);
self
->
has_read1
=
_PyObject_HasAttrId
(
buffer
,
&
PyId_read1
);
...
...
Modules/_posixsubprocess.c
View file @
8b2d711e
...
@@ -503,7 +503,7 @@ static PyObject *
...
@@ -503,7 +503,7 @@ static PyObject *
subprocess_fork_exec
(
PyObject
*
self
,
PyObject
*
args
)
subprocess_fork_exec
(
PyObject
*
self
,
PyObject
*
args
)
{
{
PyObject
*
gc_module
=
NULL
;
PyObject
*
gc_module
=
NULL
;
PyObject
*
executable_list
,
*
py_
close_fds
,
*
py_
fds_to_keep
;
PyObject
*
executable_list
,
*
py_fds_to_keep
;
PyObject
*
env_list
,
*
preexec_fn
;
PyObject
*
env_list
,
*
preexec_fn
;
PyObject
*
process_args
,
*
converted_args
=
NULL
,
*
fast_args
=
NULL
;
PyObject
*
process_args
,
*
converted_args
=
NULL
,
*
fast_args
=
NULL
;
PyObject
*
preexec_fn_args_tuple
=
NULL
;
PyObject
*
preexec_fn_args_tuple
=
NULL
;
...
@@ -518,15 +518,14 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
...
@@ -518,15 +518,14 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
Py_ssize_t
arg_num
;
Py_ssize_t
arg_num
;
if
(
!
PyArg_ParseTuple
(
if
(
!
PyArg_ParseTuple
(
args
,
"OO
O
OOOiiiiiiiiiiO:fork_exec"
,
args
,
"OO
p
OOOiiiiiiiiiiO:fork_exec"
,
&
process_args
,
&
executable_list
,
&
py_
close_fds
,
&
py_fds_to_keep
,
&
process_args
,
&
executable_list
,
&
close_fds
,
&
py_fds_to_keep
,
&
cwd_obj
,
&
env_list
,
&
cwd_obj
,
&
env_list
,
&
p2cread
,
&
p2cwrite
,
&
c2pread
,
&
c2pwrite
,
&
p2cread
,
&
p2cwrite
,
&
c2pread
,
&
c2pwrite
,
&
errread
,
&
errwrite
,
&
errpipe_read
,
&
errpipe_write
,
&
errread
,
&
errwrite
,
&
errpipe_read
,
&
errpipe_write
,
&
restore_signals
,
&
call_setsid
,
&
preexec_fn
))
&
restore_signals
,
&
call_setsid
,
&
preexec_fn
))
return
NULL
;
return
NULL
;
close_fds
=
PyObject_IsTrue
(
py_close_fds
);
if
(
close_fds
&&
errpipe_write
<
3
)
{
/* precondition */
if
(
close_fds
&&
errpipe_write
<
3
)
{
/* precondition */
PyErr_SetString
(
PyExc_ValueError
,
"errpipe_write must be >= 3"
);
PyErr_SetString
(
PyExc_ValueError
,
"errpipe_write must be >= 3"
);
return
NULL
;
return
NULL
;
...
...
Modules/_ssl.c
View file @
8b2d711e
...
@@ -1037,15 +1037,15 @@ PySSL_peercert(PySSLSocket *self, PyObject *args)
...
@@ -1037,15 +1037,15 @@ PySSL_peercert(PySSLSocket *self, PyObject *args)
PyObject
*
retval
=
NULL
;
PyObject
*
retval
=
NULL
;
int
len
;
int
len
;
int
verification
;
int
verification
;
PyObject
*
binary_mode
=
Py_None
;
int
binary_mode
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"|
O
:peer_certificate"
,
&
binary_mode
))
if
(
!
PyArg_ParseTuple
(
args
,
"|
p
:peer_certificate"
,
&
binary_mode
))
return
NULL
;
return
NULL
;
if
(
!
self
->
peer_cert
)
if
(
!
self
->
peer_cert
)
Py_RETURN_NONE
;
Py_RETURN_NONE
;
if
(
PyObject_IsTrue
(
binary_mode
)
)
{
if
(
binary_mode
)
{
/* return cert in DER-encoded format */
/* return cert in DER-encoded format */
unsigned
char
*
bytes_buf
=
NULL
;
unsigned
char
*
bytes_buf
=
NULL
;
...
...
Modules/itertoolsmodule.c
View file @
8b2d711e
...
@@ -1105,11 +1105,13 @@ dropwhile_next(dropwhileobject *lz)
...
@@ -1105,11 +1105,13 @@ dropwhile_next(dropwhileobject *lz)
}
}
ok
=
PyObject_IsTrue
(
good
);
ok
=
PyObject_IsTrue
(
good
);
Py_DECREF
(
good
);
Py_DECREF
(
good
);
if
(
!
ok
)
{
if
(
ok
==
0
)
{
lz
->
start
=
1
;
lz
->
start
=
1
;
return
item
;
return
item
;
}
}
Py_DECREF
(
item
);
Py_DECREF
(
item
);
if
(
ok
<
0
)
return
NULL
;
}
}
}
}
...
@@ -1124,7 +1126,7 @@ static PyObject *
...
@@ -1124,7 +1126,7 @@ static PyObject *
dropwhile_setstate
(
dropwhileobject
*
lz
,
PyObject
*
state
)
dropwhile_setstate
(
dropwhileobject
*
lz
,
PyObject
*
state
)
{
{
int
start
=
PyObject_IsTrue
(
state
);
int
start
=
PyObject_IsTrue
(
state
);
if
(
start
==
-
1
)
if
(
start
<
0
)
return
NULL
;
return
NULL
;
lz
->
start
=
start
;
lz
->
start
=
start
;
Py_RETURN_NONE
;
Py_RETURN_NONE
;
...
@@ -1270,10 +1272,11 @@ takewhile_next(takewhileobject *lz)
...
@@ -1270,10 +1272,11 @@ takewhile_next(takewhileobject *lz)
}
}
ok
=
PyObject_IsTrue
(
good
);
ok
=
PyObject_IsTrue
(
good
);
Py_DECREF
(
good
);
Py_DECREF
(
good
);
if
(
ok
)
if
(
ok
==
1
)
return
item
;
return
item
;
Py_DECREF
(
item
);
Py_DECREF
(
item
);
lz
->
stop
=
1
;
if
(
ok
==
0
)
lz
->
stop
=
1
;
return
NULL
;
return
NULL
;
}
}
...
@@ -1288,7 +1291,7 @@ static PyObject *
...
@@ -1288,7 +1291,7 @@ static PyObject *
takewhile_reduce_setstate
(
takewhileobject
*
lz
,
PyObject
*
state
)
takewhile_reduce_setstate
(
takewhileobject
*
lz
,
PyObject
*
state
)
{
{
int
stop
=
PyObject_IsTrue
(
state
);
int
stop
=
PyObject_IsTrue
(
state
);
if
(
stop
==
-
1
)
if
(
stop
<
0
)
return
NULL
;
return
NULL
;
lz
->
stop
=
stop
;
lz
->
stop
=
stop
;
Py_RETURN_NONE
;
Py_RETURN_NONE
;
...
@@ -3536,7 +3539,7 @@ compress_next(compressobject *lz)
...
@@ -3536,7 +3539,7 @@ compress_next(compressobject *lz)
if
(
ok
==
1
)
if
(
ok
==
1
)
return
datum
;
return
datum
;
Py_DECREF
(
datum
);
Py_DECREF
(
datum
);
if
(
ok
==
-
1
)
if
(
ok
<
0
)
return
NULL
;
return
NULL
;
}
}
}
}
...
@@ -3692,9 +3695,11 @@ filterfalse_next(filterfalseobject *lz)
...
@@ -3692,9 +3695,11 @@ filterfalse_next(filterfalseobject *lz)
ok
=
PyObject_IsTrue
(
good
);
ok
=
PyObject_IsTrue
(
good
);
Py_DECREF
(
good
);
Py_DECREF
(
good
);
}
}
if
(
!
ok
)
if
(
ok
==
0
)
return
item
;
return
item
;
Py_DECREF
(
item
);
Py_DECREF
(
item
);
if
(
ok
<
0
)
return
NULL
;
}
}
}
}
...
...
Modules/parsermodule.c
View file @
8b2d711e
...
@@ -382,36 +382,28 @@ parser_sizeof(PyST_Object *st, void *unused)
...
@@ -382,36 +382,28 @@ parser_sizeof(PyST_Object *st, void *unused)
static
PyObject
*
static
PyObject
*
parser_st2tuple
(
PyST_Object
*
self
,
PyObject
*
args
,
PyObject
*
kw
)
parser_st2tuple
(
PyST_Object
*
self
,
PyObject
*
args
,
PyObject
*
kw
)
{
{
PyObject
*
line_option
=
0
;
int
line_info
=
0
;
PyObject
*
col_option
=
0
;
int
col_info
=
0
;
PyObject
*
res
=
0
;
PyObject
*
res
=
0
;
int
ok
;
int
ok
;
static
char
*
keywords
[]
=
{
"st"
,
"line_info"
,
"col_info"
,
NULL
};
static
char
*
keywords
[]
=
{
"st"
,
"line_info"
,
"col_info"
,
NULL
};
if
(
self
==
NULL
||
PyModule_Check
(
self
))
{
if
(
self
==
NULL
||
PyModule_Check
(
self
))
{
ok
=
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"O!|
OO
:st2tuple"
,
keywords
,
ok
=
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"O!|
pp
:st2tuple"
,
keywords
,
&
PyST_Type
,
&
self
,
&
line_
option
,
&
PyST_Type
,
&
self
,
&
line_
info
,
&
col_
option
);
&
col_
info
);
}
}
else
else
ok
=
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"|
OO
:totuple"
,
&
keywords
[
1
],
ok
=
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"|
pp
:totuple"
,
&
keywords
[
1
],
&
line_
option
,
&
col_option
);
&
line_
info
,
&
col_info
);
if
(
ok
!=
0
)
{
if
(
ok
!=
0
)
{
int
lineno
=
0
;
int
col_offset
=
0
;
if
(
line_option
!=
NULL
)
{
lineno
=
(
PyObject_IsTrue
(
line_option
)
!=
0
)
?
1
:
0
;
}
if
(
col_option
!=
NULL
)
{
col_offset
=
(
PyObject_IsTrue
(
col_option
)
!=
0
)
?
1
:
0
;
}
/*
/*
* Convert ST into a tuple representation. Use Guido's function,
* Convert ST into a tuple representation. Use Guido's function,
* since it's known to work already.
* since it's known to work already.
*/
*/
res
=
node2tuple
(((
PyST_Object
*
)
self
)
->
st_node
,
res
=
node2tuple
(((
PyST_Object
*
)
self
)
->
st_node
,
PyTuple_New
,
PyTuple_SetItem
,
line
no
,
col_offset
);
PyTuple_New
,
PyTuple_SetItem
,
line
_info
,
col_info
);
}
}
return
(
res
);
return
(
res
);
}
}
...
@@ -426,35 +418,27 @@ parser_st2tuple(PyST_Object *self, PyObject *args, PyObject *kw)
...
@@ -426,35 +418,27 @@ parser_st2tuple(PyST_Object *self, PyObject *args, PyObject *kw)
static
PyObject
*
static
PyObject
*
parser_st2list
(
PyST_Object
*
self
,
PyObject
*
args
,
PyObject
*
kw
)
parser_st2list
(
PyST_Object
*
self
,
PyObject
*
args
,
PyObject
*
kw
)
{
{
PyObject
*
line_option
=
0
;
int
line_info
=
0
;
PyObject
*
col_option
=
0
;
int
col_info
=
0
;
PyObject
*
res
=
0
;
PyObject
*
res
=
0
;
int
ok
;
int
ok
;
static
char
*
keywords
[]
=
{
"st"
,
"line_info"
,
"col_info"
,
NULL
};
static
char
*
keywords
[]
=
{
"st"
,
"line_info"
,
"col_info"
,
NULL
};
if
(
self
==
NULL
||
PyModule_Check
(
self
))
if
(
self
==
NULL
||
PyModule_Check
(
self
))
ok
=
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"O!|
OO
:st2list"
,
keywords
,
ok
=
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"O!|
pp
:st2list"
,
keywords
,
&
PyST_Type
,
&
self
,
&
line_
option
,
&
PyST_Type
,
&
self
,
&
line_
info
,
&
col_
option
);
&
col_
info
);
else
else
ok
=
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"|
OO
:tolist"
,
&
keywords
[
1
],
ok
=
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"|
pp
:tolist"
,
&
keywords
[
1
],
&
line_
option
,
&
col_option
);
&
line_
info
,
&
col_info
);
if
(
ok
)
{
if
(
ok
)
{
int
lineno
=
0
;
int
col_offset
=
0
;
if
(
line_option
!=
0
)
{
lineno
=
PyObject_IsTrue
(
line_option
)
?
1
:
0
;
}
if
(
col_option
!=
NULL
)
{
col_offset
=
(
PyObject_IsTrue
(
col_option
)
!=
0
)
?
1
:
0
;
}
/*
/*
* Convert ST into a tuple representation. Use Guido's function,
* Convert ST into a tuple representation. Use Guido's function,
* since it's known to work already.
* since it's known to work already.
*/
*/
res
=
node2tuple
(
self
->
st_node
,
res
=
node2tuple
(
self
->
st_node
,
PyList_New
,
PyList_SetItem
,
line
no
,
col_offset
);
PyList_New
,
PyList_SetItem
,
line
_info
,
col_info
);
}
}
return
(
res
);
return
(
res
);
}
}
...
...
Modules/pyexpat.c
View file @
8b2d711e
...
@@ -1033,14 +1033,11 @@ getting the advantage of providing document type information to the parser.\n\
...
@@ -1033,14 +1033,11 @@ getting the advantage of providing document type information to the parser.\n\
static
PyObject
*
static
PyObject
*
xmlparse_UseForeignDTD
(
xmlparseobject
*
self
,
PyObject
*
args
)
xmlparse_UseForeignDTD
(
xmlparseobject
*
self
,
PyObject
*
args
)
{
{
PyObject
*
flagobj
=
NULL
;
int
flag
=
1
;
XML_Bool
flag
=
XML_TRUE
;
enum
XML_Error
rc
;
enum
XML_Error
rc
;
if
(
!
PyArg_
UnpackTuple
(
args
,
"UseForeignDTD"
,
0
,
1
,
&
flagobj
))
if
(
!
PyArg_
ParseTuple
(
args
,
"p:UseForeignDTD"
,
&
flag
))
return
NULL
;
return
NULL
;
if
(
flagobj
!=
NULL
)
rc
=
XML_UseForeignDTD
(
self
->
itself
,
flag
?
XML_TRUE
:
XML_FALSE
);
flag
=
PyObject_IsTrue
(
flagobj
)
?
XML_TRUE
:
XML_FALSE
;
rc
=
XML_UseForeignDTD
(
self
->
itself
,
flag
);
if
(
rc
!=
XML_ERROR_NONE
)
{
if
(
rc
!=
XML_ERROR_NONE
)
{
return
set_error
(
self
,
rc
);
return
set_error
(
self
,
rc
);
}
}
...
@@ -1405,7 +1402,10 @@ xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
...
@@ -1405,7 +1402,10 @@ xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
}
}
assert
(
PyUnicode_Check
(
name
));
assert
(
PyUnicode_Check
(
name
));
if
(
PyUnicode_CompareWithASCIIString
(
name
,
"buffer_text"
)
==
0
)
{
if
(
PyUnicode_CompareWithASCIIString
(
name
,
"buffer_text"
)
==
0
)
{
if
(
PyObject_IsTrue
(
v
))
{
int
b
=
PyObject_IsTrue
(
v
);
if
(
b
<
0
)
return
-
1
;
if
(
b
)
{
if
(
self
->
buffer
==
NULL
)
{
if
(
self
->
buffer
==
NULL
)
{
self
->
buffer
=
malloc
(
self
->
buffer_size
);
self
->
buffer
=
malloc
(
self
->
buffer_size
);
if
(
self
->
buffer
==
NULL
)
{
if
(
self
->
buffer
==
NULL
)
{
...
@@ -1424,25 +1424,25 @@ xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
...
@@ -1424,25 +1424,25 @@ xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
return
0
;
return
0
;
}
}
if
(
PyUnicode_CompareWithASCIIString
(
name
,
"namespace_prefixes"
)
==
0
)
{
if
(
PyUnicode_CompareWithASCIIString
(
name
,
"namespace_prefixes"
)
==
0
)
{
i
f
(
PyObject_IsTrue
(
v
))
i
nt
b
=
PyObject_IsTrue
(
v
);
self
->
ns_prefixes
=
1
;
if
(
b
<
0
)
else
return
-
1
;
self
->
ns_prefixes
=
0
;
self
->
ns_prefixes
=
b
;
XML_SetReturnNSTriplet
(
self
->
itself
,
self
->
ns_prefixes
);
XML_SetReturnNSTriplet
(
self
->
itself
,
self
->
ns_prefixes
);
return
0
;
return
0
;
}
}
if
(
PyUnicode_CompareWithASCIIString
(
name
,
"ordered_attributes"
)
==
0
)
{
if
(
PyUnicode_CompareWithASCIIString
(
name
,
"ordered_attributes"
)
==
0
)
{
i
f
(
PyObject_IsTrue
(
v
))
i
nt
b
=
PyObject_IsTrue
(
v
);
self
->
ordered_attributes
=
1
;
if
(
b
<
0
)
else
return
-
1
;
self
->
ordered_attributes
=
0
;
self
->
ordered_attributes
=
b
;
return
0
;
return
0
;
}
}
if
(
PyUnicode_CompareWithASCIIString
(
name
,
"specified_attributes"
)
==
0
)
{
if
(
PyUnicode_CompareWithASCIIString
(
name
,
"specified_attributes"
)
==
0
)
{
i
f
(
PyObject_IsTrue
(
v
))
i
nt
b
=
PyObject_IsTrue
(
v
);
self
->
specified_attributes
=
1
;
if
(
b
<
0
)
else
return
-
1
;
self
->
specified_attributes
=
0
;
self
->
specified_attributes
=
b
;
return
0
;
return
0
;
}
}
...
...
Objects/typeobject.c
View file @
8b2d711e
...
@@ -383,11 +383,15 @@ type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context)
...
@@ -383,11 +383,15 @@ type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context)
abc.ABCMeta.__new__, so this function doesn't do anything
abc.ABCMeta.__new__, so this function doesn't do anything
special to update subclasses.
special to update subclasses.
*/
*/
int
res
;
int
abstract
,
res
;
if
(
value
!=
NULL
)
{
if
(
value
!=
NULL
)
{
abstract
=
PyObject_IsTrue
(
value
);
if
(
abstract
<
0
)
return
-
1
;
res
=
PyDict_SetItemString
(
type
->
tp_dict
,
"__abstractmethods__"
,
value
);
res
=
PyDict_SetItemString
(
type
->
tp_dict
,
"__abstractmethods__"
,
value
);
}
}
else
{
else
{
abstract
=
0
;
res
=
PyDict_DelItemString
(
type
->
tp_dict
,
"__abstractmethods__"
);
res
=
PyDict_DelItemString
(
type
->
tp_dict
,
"__abstractmethods__"
);
if
(
res
&&
PyErr_ExceptionMatches
(
PyExc_KeyError
))
{
if
(
res
&&
PyErr_ExceptionMatches
(
PyExc_KeyError
))
{
PyErr_SetString
(
PyExc_AttributeError
,
"__abstractmethods__"
);
PyErr_SetString
(
PyExc_AttributeError
,
"__abstractmethods__"
);
...
@@ -396,12 +400,10 @@ type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context)
...
@@ -396,12 +400,10 @@ type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context)
}
}
if
(
res
==
0
)
{
if
(
res
==
0
)
{
PyType_Modified
(
type
);
PyType_Modified
(
type
);
if
(
value
&&
PyObject_IsTrue
(
value
))
{
if
(
abstract
)
type
->
tp_flags
|=
Py_TPFLAGS_IS_ABSTRACT
;
type
->
tp_flags
|=
Py_TPFLAGS_IS_ABSTRACT
;
}
else
else
{
type
->
tp_flags
&=
~
Py_TPFLAGS_IS_ABSTRACT
;
type
->
tp_flags
&=
~
Py_TPFLAGS_IS_ABSTRACT
;
}
}
}
return
res
;
return
res
;
}
}
...
...
Python/bltinmodule.c
View file @
8b2d711e
...
@@ -429,9 +429,11 @@ filter_next(filterobject *lz)
...
@@ -429,9 +429,11 @@ filter_next(filterobject *lz)
ok
=
PyObject_IsTrue
(
good
);
ok
=
PyObject_IsTrue
(
good
);
Py_DECREF
(
good
);
Py_DECREF
(
good
);
}
}
if
(
ok
)
if
(
ok
>
0
)
return
item
;
return
item
;
Py_DECREF
(
item
);
Py_DECREF
(
item
);
if
(
ok
<
0
)
return
NULL
;
}
}
}
}
...
...
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