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
5a3c6dbe
Commit
5a3c6dbe
authored
Apr 07, 2013
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Plain Diff
merge heads
parents
20efcfaf
8ab1e513
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
239 additions
and
443 deletions
+239
-443
Doc/library/argparse.rst
Doc/library/argparse.rst
+203
-202
Doc/library/functools.rst
Doc/library/functools.rst
+5
-5
Lib/idlelib/EditorWindow.py
Lib/idlelib/EditorWindow.py
+3
-1
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+1
-33
Lib/test/test_itertools.py
Lib/test/test_itertools.py
+1
-116
Lib/unittest/mock.py
Lib/unittest/mock.py
+2
-0
Lib/unittest/test/testmock/testmock.py
Lib/unittest/test/testmock/testmock.py
+4
-0
Lib/urllib/parse.py
Lib/urllib/parse.py
+0
-9
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+2
-3
Modules/itertoolsmodule.c
Modules/itertoolsmodule.c
+1
-46
Objects/abstract.c
Objects/abstract.c
+2
-5
Python/bltinmodule.c
Python/bltinmodule.c
+9
-21
Python/compile.c
Python/compile.c
+5
-2
No files found.
Doc/library/argparse.rst
View file @
5a3c6dbe
This diff is collapsed.
Click to expand it.
Doc/library/functools.rst
View file @
5a3c6dbe
...
...
@@ -79,7 +79,7 @@ The :mod:`functools` module defines the following functions:
Example of an LRU cache for static web content::
@lru_cache(maxsize=
20
)
@lru_cache(maxsize=
32
)
def get_pep(num):
'Retrieve text of a Python Enhancement Proposal'
resource = 'http://www.python.org/dev/peps/pep-%04d/' % num
...
...
@@ -93,8 +93,8 @@ The :mod:`functools` module defines the following functions:
... pep = get_pep(n)
... print(n, len(pep))
>>>
print(get_pep.cache_info()
)
CacheInfo(hits=3, misses=8, maxsize=
20
, currsize=8)
>>>
get_pep.cache_info(
)
CacheInfo(hits=3, misses=8, maxsize=
32
, currsize=8)
Example of efficiently computing
`Fibonacci numbers <http://en.wikipedia.org/wiki/Fibonacci_number>`_
...
...
@@ -108,10 +108,10 @@ The :mod:`functools` module defines the following functions:
return n
return fib(n-1) + fib(n-2)
>>>
print([fib(n) for n in range(16)])
>>>
[fib(n) for n in range(16)]
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]
>>>
print(fib.cache_info()
)
>>>
fib.cache_info(
)
CacheInfo(hits=28, misses=16, maxsize=None, currsize=16)
.. versionadded:: 3.2
...
...
Lib/idlelib/EditorWindow.py
View file @
5a3c6dbe
...
...
@@ -1433,6 +1433,7 @@ class EditorWindow(object):
def
tabify_region_event
(
self
,
event
):
head
,
tail
,
chars
,
lines
=
self
.
get_region
()
tabwidth
=
self
.
_asktabwidth
()
if
tabwidth
is
None
:
return
for
pos
in
range
(
len
(
lines
)):
line
=
lines
[
pos
]
if
line
:
...
...
@@ -1444,6 +1445,7 @@ class EditorWindow(object):
def
untabify_region_event
(
self
,
event
):
head
,
tail
,
chars
,
lines
=
self
.
get_region
()
tabwidth
=
self
.
_asktabwidth
()
if
tabwidth
is
None
:
return
for
pos
in
range
(
len
(
lines
)):
lines
[
pos
]
=
lines
[
pos
].
expandtabs
(
tabwidth
)
self
.
set_region
(
head
,
tail
,
chars
,
lines
)
...
...
@@ -1537,7 +1539,7 @@ class EditorWindow(object):
parent
=
self
.
text
,
initialvalue
=
self
.
indentwidth
,
minvalue
=
2
,
maxvalue
=
16
)
or
self
.
tabwidth
maxvalue
=
16
)
# Guess indentwidth from text content.
# Return guessed indentwidth. This should not be believed unless
...
...
Lib/test/test_builtin.py
View file @
5a3c6dbe
...
...
@@ -1564,40 +1564,8 @@ class TestSorted(unittest.TestCase):
data
=
'The quick Brown fox Jumped over The lazy Dog'
.
split
()
self
.
assertRaises
(
TypeError
,
sorted
,
data
,
None
,
lambda
x
,
y
:
0
)
class
TestRecursionLimit
(
unittest
.
TestCase
):
# Issue #14010
recursionlimit
=
sys
.
getrecursionlimit
()
def
test_filter
(
self
):
it
=
(
0
,
1
)
for
_
in
range
(
self
.
recursionlimit
):
it
=
filter
(
bool
,
it
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
def
test_map
(
self
):
it
=
(
0
,
1
)
for
_
in
range
(
self
.
recursionlimit
):
it
=
map
(
int
,
it
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
def
test_zip
(
self
):
it
=
(
0
,
1
)
for
_
in
range
(
self
.
recursionlimit
):
it
=
zip
(
it
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
def
test_main
(
verbose
=
None
):
test_classes
=
(
BuiltinTest
,
TestSorted
,
TestRecursionLimit
)
test_classes
=
(
BuiltinTest
,
TestSorted
)
run_unittest
(
*
test_classes
)
...
...
Lib/test/test_itertools.py
View file @
5a3c6dbe
...
...
@@ -1808,121 +1808,6 @@ class SubclassWithKwargsTest(unittest.TestCase):
self
.
assertNotIn
(
"does not take keyword arguments"
,
err
.
args
[
0
])
class
TestRecursionLimit
(
unittest
.
TestCase
):
# Issue #14010
recursionlimit
=
sys
.
getrecursionlimit
()
def
test_accumulate
(
self
):
it
=
(
0
,
1
)
for
_
in
range
(
self
.
recursionlimit
):
it
=
accumulate
(
it
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
def
test_chain
(
self
):
it
=
(
0
,
1
)
for
_
in
range
(
self
.
recursionlimit
):
it
=
chain
(
it
,
())
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
def
test_compress
(
self
):
data
=
(
0
,
1
)
selectors
=
(
True
,
True
)
it
=
data
for
_
in
range
(
self
.
recursionlimit
):
it
=
compress
(
it
,
selectors
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
it
=
selectors
for
_
in
range
(
self
.
recursionlimit
):
it
=
compress
(
data
,
it
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
def
test_cycle
(
self
):
it
=
(
0
,
1
)
for
_
in
range
(
self
.
recursionlimit
):
it
=
cycle
(
it
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
range
(
3
):
next
(
it
)
del
it
def
test_dropwhile
(
self
):
it
=
(
0
,
1
,
0
)
for
_
in
range
(
self
.
recursionlimit
):
it
=
dropwhile
(
bool
,
it
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
def
test_filterfalse
(
self
):
it
=
(
0
,
1
)
for
_
in
range
(
self
.
recursionlimit
):
it
=
filterfalse
(
bool
,
it
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
def
test_groupby
(
self
):
key
=
operator
.
itemgetter
(
0
)
it
=
((
0
,
[]),
(
1
,
[]))
for
_
in
range
(
self
.
recursionlimit
):
it
=
groupby
(
it
,
key
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
def
test_islice
(
self
):
it
=
(
0
,
1
)
for
_
in
range
(
self
.
recursionlimit
):
it
=
islice
(
it
,
2
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
def
test_starmap
(
self
):
it
=
'ab'
for
_
in
range
(
self
.
recursionlimit
):
it
=
starmap
(
tuple
,
it
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
def
test_takewhile
(
self
):
it
=
(
1
,
0
)
for
_
in
range
(
self
.
recursionlimit
):
it
=
takewhile
(
bool
,
it
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
def
test_zip_longest
(
self
):
it
=
(
0
,
1
)
for
_
in
range
(
self
.
recursionlimit
):
it
=
zip_longest
(
it
)
with
self
.
assertRaises
(
RuntimeError
):
for
_
in
it
:
pass
del
it
libreftest
=
""" Doctest for examples in the library reference: libitertools.tex
...
...
@@ -2157,7 +2042,7 @@ __test__ = {'libreftest' : libreftest}
def
test_main
(
verbose
=
None
):
test_classes
=
(
TestBasicOps
,
TestVariousIteratorArgs
,
TestGC
,
RegressionTests
,
LengthTransparency
,
SubclassWithKwargsTest
,
TestExamples
,
TestRecursionLimit
)
SubclassWithKwargsTest
,
TestExamples
)
support
.
run_unittest
(
*
test_classes
)
# verify reference counting
...
...
Lib/unittest/mock.py
View file @
5a3c6dbe
...
...
@@ -931,6 +931,8 @@ class CallableMixin(Base):
result
=
next
(
effect
)
if
_is_exception
(
result
):
raise
result
if
result
is
DEFAULT
:
result
=
self
.
return_value
return
result
ret_val
=
effect
(
*
args
,
**
kwargs
)
...
...
Lib/unittest/test/testmock/testmock.py
View file @
5a3c6dbe
...
...
@@ -978,6 +978,10 @@ class MockTest(unittest.TestCase):
self.assertRaises(StopIteration, mock)
self.assertIs(mock.side_effect, this_iter)
def test_side_effect_iterator_default(self):
mock = Mock(return_value=2)
mock.side_effect = iter([1, DEFAULT])
self.assertEqual([mock(), mock()], [1, 2])
def test_assert_has_calls_any_order(self):
mock = Mock()
...
...
Lib/urllib/parse.py
View file @
5a3c6dbe
...
...
@@ -846,7 +846,6 @@ def splittype(url):
"""splittype('type:opaquestring') --> 'type', 'opaquestring'."""
global
_typeprog
if
_typeprog
is
None
:
import
re
_typeprog
=
re
.
compile
(
'^([^/:]+):'
)
match
=
_typeprog
.
match
(
url
)
...
...
@@ -860,7 +859,6 @@ def splithost(url):
"""splithost('//host[:port]/path') --> 'host[:port]', '/path'."""
global
_hostprog
if
_hostprog
is
None
:
import
re
_hostprog
=
re
.
compile
(
'^//([^/?]*)(.*)$'
)
match
=
_hostprog
.
match
(
url
)
...
...
@@ -877,7 +875,6 @@ def splituser(host):
"""splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'."""
global
_userprog
if
_userprog
is
None
:
import
re
_userprog
=
re
.
compile
(
'^(.*)@(.*)$'
)
match
=
_userprog
.
match
(
host
)
...
...
@@ -889,7 +886,6 @@ def splitpasswd(user):
"""splitpasswd('user:passwd') -> 'user', 'passwd'."""
global
_passwdprog
if
_passwdprog
is
None
:
import
re
_passwdprog
=
re
.
compile
(
'^([^:]*):(.*)$'
,
re
.
S
)
match
=
_passwdprog
.
match
(
user
)
...
...
@@ -902,7 +898,6 @@ def splitport(host):
"""splitport('host:port') --> 'host', 'port'."""
global
_portprog
if
_portprog
is
None
:
import
re
_portprog
=
re
.
compile
(
'^(.*):([0-9]+)$'
)
match
=
_portprog
.
match
(
host
)
...
...
@@ -917,7 +912,6 @@ def splitnport(host, defport=-1):
Return None if ':' but not a valid number."""
global
_nportprog
if
_nportprog
is
None
:
import
re
_nportprog
=
re
.
compile
(
'^(.*):(.*)$'
)
match
=
_nportprog
.
match
(
host
)
...
...
@@ -936,7 +930,6 @@ def splitquery(url):
"""splitquery('/path?query') --> '/path', 'query'."""
global
_queryprog
if
_queryprog
is
None
:
import
re
_queryprog
=
re
.
compile
(
'^(.*)
\
?([^?]*)$
'
)
match = _queryprog.match(url)
...
...
@@ -948,7 +941,6 @@ def splittag(url):
"""splittag('
/
path
#tag') --> '/path', 'tag'."""
global
_tagprog
if
_tagprog
is
None
:
import
re
_tagprog
=
re
.
compile
(
'^(.*)#([^#]*)$'
)
match
=
_tagprog
.
match
(
url
)
...
...
@@ -966,7 +958,6 @@ def splitvalue(attr):
"""splitvalue('attr=value') --> 'attr', 'value'."""
global
_valueprog
if
_valueprog
is
None
:
import
re
_valueprog
=
re
.
compile
(
'^([^=]*)=(.*)$'
)
match
=
_valueprog
.
match
(
attr
)
...
...
Misc/ACKS
View file @
5a3c6dbe
...
...
@@ -722,6 +722,7 @@ Luke Kenneth Casson Leighton
Tshepang Lekhonkhobe
Marc-André Lemburg
John Lenton
Kostyantyn Leschenko
Benno Leslie
Christopher Tur Lesniewski-Laas
Alain Leufroy
...
...
Misc/NEWS
View file @
5a3c6dbe
...
...
@@ -10,9 +10,6 @@ What's New in Python 3.4.0 Alpha 1?
Core and Builtins
-----------------
- Issue #14010: Fix a crash when iterating or deleting deeply nested filters
(builting and in itertools module, i.e. map(), itertools.chain(), etc).
- Issue #17469: Fix _Py_GetAllocatedBlocks() and sys.getallocatedblocks()
when running on valgrind.
...
...
@@ -1016,6 +1013,8 @@ _ Issue #17385: Fix quadratic behavior in threading.Condition. The FIFO
IDLE
----
- Issue #16887: IDLE now accepts Cancel in tabify/untabify dialog box.
- Issue #14254: IDLE now handles readline correctly across shell restarts.
- Issue #17614: IDLE no longer raises exception when quickly closing a file.
...
...
Modules/itertoolsmodule.c
View file @
5a3c6dbe
...
...
@@ -54,14 +54,12 @@ static void
groupby_dealloc
(
groupbyobject
*
gbo
)
{
PyObject_GC_UnTrack
(
gbo
);
Py_TRASHCAN_SAFE_BEGIN
(
gbo
)
Py_XDECREF
(
gbo
->
it
);
Py_XDECREF
(
gbo
->
keyfunc
);
Py_XDECREF
(
gbo
->
tgtkey
);
Py_XDECREF
(
gbo
->
currkey
);
Py_XDECREF
(
gbo
->
currvalue
);
Py_TYPE
(
gbo
)
->
tp_free
(
gbo
);
Py_TRASHCAN_SAFE_END
(
gbo
)
}
static
int
...
...
@@ -913,11 +911,9 @@ static void
cycle_dealloc
(
cycleobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
saved
);
Py_XDECREF
(
lz
->
it
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
@@ -1092,11 +1088,9 @@ static void
dropwhile_dealloc
(
dropwhileobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
func
);
Py_XDECREF
(
lz
->
it
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
@@ -1117,10 +1111,7 @@ dropwhile_next(dropwhileobject *lz)
iternext
=
*
Py_TYPE
(
it
)
->
tp_iternext
;
for
(;;)
{
if
(
Py_EnterRecursiveCall
(
" while iterating"
))
return
NULL
;
item
=
iternext
(
it
);
Py_LeaveRecursiveCall
();
if
(
item
==
NULL
)
return
NULL
;
if
(
lz
->
start
==
1
)
...
...
@@ -1266,11 +1257,9 @@ static void
takewhile_dealloc
(
takewhileobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
func
);
Py_XDECREF
(
lz
->
it
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
@@ -1291,10 +1280,7 @@ takewhile_next(takewhileobject *lz)
if
(
lz
->
stop
==
1
)
return
NULL
;
if
(
Py_EnterRecursiveCall
(
" while iterating"
))
return
NULL
;
item
=
(
*
Py_TYPE
(
it
)
->
tp_iternext
)(
it
);
Py_LeaveRecursiveCall
();
if
(
item
==
NULL
)
return
NULL
;
...
...
@@ -1486,10 +1472,8 @@ static void
islice_dealloc
(
isliceobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
it
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
@@ -1510,10 +1494,7 @@ islice_next(isliceobject *lz)
iternext
=
*
Py_TYPE
(
it
)
->
tp_iternext
;
while
(
lz
->
cnt
<
lz
->
next
)
{
if
(
Py_EnterRecursiveCall
(
" while iterating"
))
return
NULL
;
item
=
iternext
(
it
);
Py_LeaveRecursiveCall
();
if
(
item
==
NULL
)
return
NULL
;
Py_DECREF
(
item
);
...
...
@@ -1521,10 +1502,7 @@ islice_next(isliceobject *lz)
}
if
(
stop
!=
-
1
&&
lz
->
cnt
>=
stop
)
return
NULL
;
if
(
Py_EnterRecursiveCall
(
" while iterating"
))
return
NULL
;
item
=
iternext
(
it
);
Py_LeaveRecursiveCall
();
if
(
item
==
NULL
)
return
NULL
;
lz
->
cnt
++
;
...
...
@@ -1675,11 +1653,9 @@ static void
starmap_dealloc
(
starmapobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
func
);
Py_XDECREF
(
lz
->
it
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
@@ -1697,10 +1673,7 @@ starmap_next(starmapobject *lz)
PyObject
*
result
;
PyObject
*
it
=
lz
->
it
;
if
(
Py_EnterRecursiveCall
(
" while iterating"
))
return
NULL
;
args
=
(
*
Py_TYPE
(
it
)
->
tp_iternext
)(
it
);
Py_LeaveRecursiveCall
();
if
(
args
==
NULL
)
return
NULL
;
if
(
!
PyTuple_CheckExact
(
args
))
{
...
...
@@ -1836,11 +1809,9 @@ static void
chain_dealloc
(
chainobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
active
);
Py_XDECREF
(
lz
->
source
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
@@ -3369,12 +3340,10 @@ static void
accumulate_dealloc
(
accumulateobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
binop
);
Py_XDECREF
(
lz
->
total
);
Py_XDECREF
(
lz
->
it
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
@@ -3545,11 +3514,9 @@ static void
compress_dealloc
(
compressobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
data
);
Py_XDECREF
(
lz
->
selectors
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
@@ -3576,16 +3543,11 @@ compress_next(compressobject *lz)
exception first).
*/
if
(
Py_EnterRecursiveCall
(
" while iterating"
))
return
NULL
;
datum
=
datanext
(
data
);
if
(
datum
==
NULL
)
{
Py_LeaveRecursiveCall
();
if
(
datum
==
NULL
)
return
NULL
;
}
selector
=
selectornext
(
selectors
);
Py_LeaveRecursiveCall
();
if
(
selector
==
NULL
)
{
Py_DECREF
(
datum
);
return
NULL
;
...
...
@@ -3712,11 +3674,9 @@ static void
filterfalse_dealloc
(
filterfalseobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
func
);
Py_XDECREF
(
lz
->
it
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
@@ -3737,10 +3697,7 @@ filterfalse_next(filterfalseobject *lz)
iternext
=
*
Py_TYPE
(
it
)
->
tp_iternext
;
for
(;;)
{
if
(
Py_EnterRecursiveCall
(
" while iterating"
))
return
NULL
;
item
=
iternext
(
it
);
Py_LeaveRecursiveCall
();
if
(
item
==
NULL
)
return
NULL
;
...
...
@@ -4304,12 +4261,10 @@ static void
zip_longest_dealloc
(
ziplongestobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
ittuple
);
Py_XDECREF
(
lz
->
result
);
Py_XDECREF
(
lz
->
fillvalue
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
Objects/abstract.c
View file @
5a3c6dbe
...
...
@@ -1238,7 +1238,7 @@ PyNumber_AsSsize_t(PyObject *item, PyObject *err)
to be an int or have an __int__ method. Steals integral's
reference. error_format will be used to create the TypeError if integral
isn't actually an Integral instance. error_format should be a format string
that can accept a char* naming integral's type.
that can accept a char* naming integral's type.
*/
static
PyObject
*
convert_integral_to_int
(
PyObject
*
integral
,
const
char
*
error_format
)
...
...
@@ -1257,7 +1257,7 @@ convert_integral_to_int(PyObject *integral, const char *error_format)
}
PyErr_Format
(
PyExc_TypeError
,
error_format
,
Py_TYPE
(
integral
)
->
tp_name
);
Py_DECREF
(
integral
);
return
NULL
;
return
NULL
;
}
...
...
@@ -2702,10 +2702,7 @@ PyObject *
PyIter_Next
(
PyObject
*
iter
)
{
PyObject
*
result
;
if
(
Py_EnterRecursiveCall
(
" while iterating"
))
return
NULL
;
result
=
(
*
iter
->
ob_type
->
tp_iternext
)(
iter
);
Py_LeaveRecursiveCall
();
if
(
result
==
NULL
&&
PyErr_Occurred
()
&&
PyErr_ExceptionMatches
(
PyExc_StopIteration
))
...
...
Python/bltinmodule.c
View file @
5a3c6dbe
...
...
@@ -391,11 +391,9 @@ static void
filter_dealloc
(
filterobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
func
);
Py_XDECREF
(
lz
->
it
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
@@ -416,10 +414,7 @@ filter_next(filterobject *lz)
iternext
=
*
Py_TYPE
(
it
)
->
tp_iternext
;
for
(;;)
{
if
(
Py_EnterRecursiveCall
(
" while iterating"
))
return
NULL
;
item
=
iternext
(
it
);
Py_LeaveRecursiveCall
();
if
(
item
==
NULL
)
return
NULL
;
...
...
@@ -1036,11 +1031,9 @@ static void
map_dealloc
(
mapobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
iters
);
Py_XDECREF
(
lz
->
func
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
@@ -2227,11 +2220,9 @@ static void
zip_dealloc
(
zipobject
*
lz
)
{
PyObject_GC_UnTrack
(
lz
);
Py_TRASHCAN_SAFE_BEGIN
(
lz
)
Py_XDECREF
(
lz
->
ittuple
);
Py_XDECREF
(
lz
->
result
);
Py_TYPE
(
lz
)
->
tp_free
(
lz
);
Py_TRASHCAN_SAFE_END
(
lz
)
}
static
int
...
...
@@ -2254,15 +2245,15 @@ zip_next(zipobject *lz)
if
(
tuplesize
==
0
)
return
NULL
;
if
(
Py_EnterRecursiveCall
(
" while iterating"
))
return
NULL
;
if
(
Py_REFCNT
(
result
)
==
1
)
{
Py_INCREF
(
result
);
for
(
i
=
0
;
i
<
tuplesize
;
i
++
)
{
it
=
PyTuple_GET_ITEM
(
lz
->
ittuple
,
i
);
item
=
(
*
Py_TYPE
(
it
)
->
tp_iternext
)(
it
);
if
(
item
==
NULL
)
goto
error
;
if
(
item
==
NULL
)
{
Py_DECREF
(
result
);
return
NULL
;
}
olditem
=
PyTuple_GET_ITEM
(
result
,
i
);
PyTuple_SET_ITEM
(
result
,
i
,
item
);
Py_DECREF
(
olditem
);
...
...
@@ -2270,21 +2261,18 @@ zip_next(zipobject *lz)
}
else
{
result
=
PyTuple_New
(
tuplesize
);
if
(
result
==
NULL
)
goto
error
;
return
NULL
;
for
(
i
=
0
;
i
<
tuplesize
;
i
++
)
{
it
=
PyTuple_GET_ITEM
(
lz
->
ittuple
,
i
);
item
=
(
*
Py_TYPE
(
it
)
->
tp_iternext
)(
it
);
if
(
item
==
NULL
)
goto
error
;
if
(
item
==
NULL
)
{
Py_DECREF
(
result
);
return
NULL
;
}
PyTuple_SET_ITEM
(
result
,
i
,
item
);
}
}
Py_LeaveRecursiveCall
();
return
result
;
error:
Py_XDECREF
(
result
);
Py_LeaveRecursiveCall
();
return
NULL
;
}
static
PyObject
*
...
...
Python/compile.c
View file @
5a3c6dbe
...
...
@@ -248,8 +248,11 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
}
plen
-=
ipriv
;
assert
(
1
<=
PY_SSIZE_T_MAX
-
nlen
);
assert
(
1
+
nlen
<=
PY_SSIZE_T_MAX
-
plen
);
if
(
plen
+
nlen
>=
PY_SSIZE_T_MAX
-
1
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"private identifier too large to be mangled"
);
return
NULL
;
}
maxchar
=
PyUnicode_MAX_CHAR_VALUE
(
ident
);
if
(
PyUnicode_MAX_CHAR_VALUE
(
privateobj
)
>
maxchar
)
...
...
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