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
2e576f5a
Commit
2e576f5a
authored
Apr 24, 2017
by
Serhiy Storchaka
Committed by
GitHub
Apr 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-30144: Import collections ABC from collections.abc rather than collections. (#1263)
parent
9eb5ca07
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
92 additions
and
87 deletions
+92
-87
Doc/library/http.client.rst
Doc/library/http.client.rst
+1
-1
Doc/reference/datamodel.rst
Doc/reference/datamodel.rst
+3
-3
Lib/asyncio/base_events.py
Lib/asyncio/base_events.py
+2
-1
Lib/cgi.py
Lib/cgi.py
+1
-1
Lib/dbm/dumb.py
Lib/dbm/dumb.py
+2
-2
Lib/http/client.py
Lib/http/client.py
+2
-2
Lib/idlelib/pyparse.py
Lib/idlelib/pyparse.py
+1
-1
Lib/lib2to3/fixes/fix_operator.py
Lib/lib2to3/fixes/fix_operator.py
+2
-2
Lib/locale.py
Lib/locale.py
+2
-2
Lib/logging/__init__.py
Lib/logging/__init__.py
+3
-3
Lib/pathlib.py
Lib/pathlib.py
+1
-1
Lib/selectors.py
Lib/selectors.py
+2
-1
Lib/shelve.py
Lib/shelve.py
+3
-3
Lib/test/test_dictviews.py
Lib/test/test_dictviews.py
+18
-18
Lib/test/test_functools.py
Lib/test/test_functools.py
+20
-19
Lib/test/test_hash.py
Lib/test/test_hash.py
+1
-1
Lib/test/test_pathlib.py
Lib/test/test_pathlib.py
+3
-3
Lib/test/test_statistics.py
Lib/test/test_statistics.py
+3
-2
Lib/test/test_typing.py
Lib/test/test_typing.py
+16
-16
Lib/tracemalloc.py
Lib/tracemalloc.py
+1
-1
Lib/weakref.py
Lib/weakref.py
+3
-3
Lib/xml/etree/ElementTree.py
Lib/xml/etree/ElementTree.py
+2
-1
No files found.
Doc/library/http.client.rst
View file @
2e576f5a
...
...
@@ -372,7 +372,7 @@ also send your request step by step, by using the four functions below.
Section 3.3.1. How the data is encoded is dependent on the type of
*message_body*. If *message_body* implements the :ref:`buffer interface
<bufferobjects>` the encoding will result in a single chunk.
If *message_body* is a :class:`collections.Iterable`, each iteration
If *message_body* is a :class:`collections.
abc.
Iterable`, each iteration
of *message_body* will result in a chunk. If *message_body* is a
:term:`file object`, each call to ``.read()`` will result in a chunk.
The method automatically signals the end of the chunk-encoded data
...
...
Doc/reference/datamodel.rst
View file @
2e576f5a
...
...
@@ -1375,7 +1375,7 @@ Basic customization
:meth:`__hash__` method of a class is ``None``, instances of the class will
raise an appropriate :exc:`TypeError` when a program attempts to retrieve
their hash value, and will also be correctly identified as unhashable when
checking ``isinstance(obj, collections.Hashable)``.
checking ``isinstance(obj, collections.
abc.
Hashable)``.
If a class that overrides :meth:`__eq__` needs to retain the implementation
of :meth:`__hash__` from a parent class, the interpreter must be told this
...
...
@@ -1385,7 +1385,7 @@ Basic customization
support, it should include ``__hash__ = None`` in the class definition.
A class which defines its own :meth:`__hash__` that explicitly raises
a :exc:`TypeError` would be incorrectly identified as hashable by
an ``isinstance(obj, collections.Hashable)`` call.
an ``isinstance(obj, collections.
abc.
Hashable)`` call.
.. note::
...
...
@@ -1981,7 +1981,7 @@ range of items. It is also recommended that mappings provide the methods
:meth:`keys`, :meth:`values`, :meth:`items`, :meth:`get`, :meth:`clear`,
:meth:`setdefault`, :meth:`pop`, :meth:`popitem`, :meth:`!copy`, and
:meth:`update` behaving similar to those for Python's standard dictionary
objects. The :mod:`collections` module provides a
objects. The :mod:`collections
.abc
` module provides a
:class:`~collections.abc.MutableMapping`
abstract base class to help create those methods from a base set of
:meth:`__getitem__`, :meth:`__setitem__`, :meth:`__delitem__`, and :meth:`keys`.
...
...
Lib/asyncio/base_events.py
View file @
2e576f5a
...
...
@@ -14,6 +14,7 @@ to modify the meaning of the API call itself.
"""
import
collections
import
collections.abc
import
concurrent.futures
import
heapq
import
itertools
...
...
@@ -1001,7 +1002,7 @@ class BaseEventLoop(events.AbstractEventLoop):
if
host
==
''
:
hosts
=
[
None
]
elif
(
isinstance
(
host
,
str
)
or
not
isinstance
(
host
,
collections
.
Iterable
)):
not
isinstance
(
host
,
collections
.
abc
.
Iterable
)):
hosts
=
[
host
]
else
:
hosts
=
host
...
...
Lib/cgi.py
View file @
2e576f5a
...
...
@@ -32,7 +32,7 @@ __version__ = "2.6"
# =======
from
io
import
StringIO
,
BytesIO
,
TextIOWrapper
from
collections
import
Mapping
from
collections
.abc
import
Mapping
import
sys
import
os
import
urllib.parse
...
...
Lib/dbm/dumb.py
View file @
2e576f5a
...
...
@@ -24,7 +24,7 @@ is read when the database is opened, and some updates rewrite the whole index)
import
ast
as
_ast
import
io
as
_io
import
os
as
_os
import
collections
import
collections
.abc
__all__
=
[
"error"
,
"open"
]
...
...
@@ -32,7 +32,7 @@ _BLOCKSIZE = 512
error
=
OSError
class
_Database
(
collections
.
MutableMapping
):
class
_Database
(
collections
.
abc
.
MutableMapping
):
# The on-disk directory and data files can remain in mutually
# inconsistent states for an arbitrarily long time (see comments
...
...
Lib/http/client.py
View file @
2e576f5a
...
...
@@ -74,7 +74,7 @@ import http
import
io
import
re
import
socket
import
collections
import
collections
.abc
from
urllib.parse
import
urlsplit
# HTTPMessage, parse_headers(), and the HTTP status code constants are
...
...
@@ -977,7 +977,7 @@ class HTTPConnection:
try
:
self
.
sock
.
sendall
(
data
)
except
TypeError
:
if
isinstance
(
data
,
collections
.
Iterable
):
if
isinstance
(
data
,
collections
.
abc
.
Iterable
):
for
d
in
data
:
self
.
sock
.
sendall
(
d
)
else
:
...
...
Lib/idlelib/pyparse.py
View file @
2e576f5a
from
collections
import
Mapping
from
collections
.abc
import
Mapping
import
re
import
sys
...
...
Lib/lib2to3/fixes/fix_operator.py
View file @
2e576f5a
...
...
@@ -9,7 +9,7 @@ operator.repeat(obj, n) -> operator.mul(obj, n)
operator.irepeat(obj, n) -> operator.imul(obj, n)
"""
import
collections
import
collections
.abc
# Local imports
from
lib2to3
import
fixer_base
...
...
@@ -88,7 +88,7 @@ class FixOperator(fixer_base.BaseFix):
def
_check_method
(
self
,
node
,
results
):
method
=
getattr
(
self
,
"_"
+
results
[
"method"
][
0
].
value
)
if
isinstance
(
method
,
collections
.
Callable
):
if
isinstance
(
method
,
collections
.
abc
.
Callable
):
if
"module"
in
results
:
return
method
else
:
...
...
Lib/locale.py
View file @
2e576f5a
...
...
@@ -14,7 +14,7 @@ import sys
import
encodings
import
encodings.aliases
import
re
import
collections
import
collections
.abc
from
builtins
import
str
as
_builtin_str
import
functools
import
warnings
...
...
@@ -215,7 +215,7 @@ def format_string(f, val, grouping=False, monetary=False):
percents
=
list
(
_percent_re
.
finditer
(
f
))
new_f
=
_percent_re
.
sub
(
'%s'
,
f
)
if
isinstance
(
val
,
collections
.
Mapping
):
if
isinstance
(
val
,
collections
.
abc
.
Mapping
):
new_val
=
[]
for
perc
in
percents
:
if
perc
.
group
()[
-
1
]
==
'%'
:
...
...
Lib/logging/__init__.py
View file @
2e576f5a
...
...
@@ -23,7 +23,7 @@ Copyright (C) 2001-2016 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
"""
import
sys
,
os
,
time
,
io
,
traceback
,
warnings
,
weakref
,
collections
import
sys
,
os
,
time
,
io
,
traceback
,
warnings
,
weakref
,
collections
.
abc
from
string
import
Template
...
...
@@ -273,8 +273,8 @@ class LogRecord(object):
# to hasattr(args[0], '__getitem__'). However, the docs on string
# formatting still seem to suggest a mapping object is required.
# Thus, while not removing the isinstance check, it does now look
# for collections.Mapping rather than, as before, dict.
if
(
args
and
len
(
args
)
==
1
and
isinstance
(
args
[
0
],
collections
.
Mapping
)
# for collections.
abc.
Mapping rather than, as before, dict.
if
(
args
and
len
(
args
)
==
1
and
isinstance
(
args
[
0
],
collections
.
abc
.
Mapping
)
and
args
[
0
]):
args
=
args
[
0
]
self
.
args
=
args
...
...
Lib/pathlib.py
View file @
2e576f5a
...
...
@@ -6,7 +6,7 @@ import os
import
posixpath
import
re
import
sys
from
collections
import
Sequence
from
collections
.abc
import
Sequence
from
errno
import
EINVAL
,
ENOENT
,
ENOTDIR
from
operator
import
attrgetter
from
stat
import
S_ISDIR
,
S_ISLNK
,
S_ISREG
,
S_ISSOCK
,
S_ISBLK
,
S_ISCHR
,
S_ISFIFO
...
...
Lib/selectors.py
View file @
2e576f5a
...
...
@@ -6,7 +6,8 @@ This module allows high-level and efficient I/O multiplexing, built upon the
from
abc
import
ABCMeta
,
abstractmethod
from
collections
import
namedtuple
,
Mapping
from
collections
import
namedtuple
from
collections.abc
import
Mapping
import
math
import
select
import
sys
...
...
Lib/shelve.py
View file @
2e576f5a
...
...
@@ -59,11 +59,11 @@ the persistent dictionary on disk, if feasible).
from
pickle
import
Pickler
,
Unpickler
from
io
import
BytesIO
import
collections
import
collections
.abc
__all__
=
[
"Shelf"
,
"BsdDbShelf"
,
"DbfilenameShelf"
,
"open"
]
class
_ClosedDict
(
collections
.
MutableMapping
):
class
_ClosedDict
(
collections
.
abc
.
MutableMapping
):
'Marker for a closed dict. Access attempts raise a ValueError.'
def
closed
(
self
,
*
args
):
...
...
@@ -74,7 +74,7 @@ class _ClosedDict(collections.MutableMapping):
return
'<Closed Dictionary>'
class
Shelf
(
collections
.
MutableMapping
):
class
Shelf
(
collections
.
abc
.
MutableMapping
):
"""Base class for shelf implementations.
This is initialized with a dictionary-like object.
...
...
Lib/test/test_dictviews.py
View file @
2e576f5a
import
collections
import
collections
.abc
import
copy
import
pickle
import
unittest
...
...
@@ -249,23 +249,23 @@ class DictSetTest(unittest.TestCase):
def
test_abc_registry
(
self
):
d
=
dict
(
a
=
1
)
self
.
assertIsInstance
(
d
.
keys
(),
collections
.
KeysView
)
self
.
assertIsInstance
(
d
.
keys
(),
collections
.
MappingView
)
self
.
assertIsInstance
(
d
.
keys
(),
collections
.
Set
)
self
.
assertIsInstance
(
d
.
keys
(),
collections
.
Sized
)
self
.
assertIsInstance
(
d
.
keys
(),
collections
.
Iterable
)
self
.
assertIsInstance
(
d
.
keys
(),
collections
.
Container
)
self
.
assertIsInstance
(
d
.
values
(),
collections
.
ValuesView
)
self
.
assertIsInstance
(
d
.
values
(),
collections
.
MappingView
)
self
.
assertIsInstance
(
d
.
values
(),
collections
.
Sized
)
self
.
assertIsInstance
(
d
.
items
(),
collections
.
ItemsView
)
self
.
assertIsInstance
(
d
.
items
(),
collections
.
MappingView
)
self
.
assertIsInstance
(
d
.
items
(),
collections
.
Set
)
self
.
assertIsInstance
(
d
.
items
(),
collections
.
Sized
)
self
.
assertIsInstance
(
d
.
items
(),
collections
.
Iterable
)
self
.
assertIsInstance
(
d
.
items
(),
collections
.
Container
)
self
.
assertIsInstance
(
d
.
keys
(),
collections
.
abc
.
KeysView
)
self
.
assertIsInstance
(
d
.
keys
(),
collections
.
abc
.
MappingView
)
self
.
assertIsInstance
(
d
.
keys
(),
collections
.
abc
.
Set
)
self
.
assertIsInstance
(
d
.
keys
(),
collections
.
abc
.
Sized
)
self
.
assertIsInstance
(
d
.
keys
(),
collections
.
abc
.
Iterable
)
self
.
assertIsInstance
(
d
.
keys
(),
collections
.
abc
.
Container
)
self
.
assertIsInstance
(
d
.
values
(),
collections
.
abc
.
ValuesView
)
self
.
assertIsInstance
(
d
.
values
(),
collections
.
abc
.
MappingView
)
self
.
assertIsInstance
(
d
.
values
(),
collections
.
abc
.
Sized
)
self
.
assertIsInstance
(
d
.
items
(),
collections
.
abc
.
ItemsView
)
self
.
assertIsInstance
(
d
.
items
(),
collections
.
abc
.
MappingView
)
self
.
assertIsInstance
(
d
.
items
(),
collections
.
abc
.
Set
)
self
.
assertIsInstance
(
d
.
items
(),
collections
.
abc
.
Sized
)
self
.
assertIsInstance
(
d
.
items
(),
collections
.
abc
.
Iterable
)
self
.
assertIsInstance
(
d
.
items
(),
collections
.
abc
.
Container
)
if
__name__
==
"__main__"
:
...
...
Lib/test/test_functools.py
View file @
2e576f5a
import
abc
import
builtins
import
collections
import
collections.abc
import
copy
from
itertools
import
permutations
import
pickle
...
...
@@ -910,7 +911,7 @@ class TestCmpToKey:
key
=
self
.
cmp_to_key
(
mycmp
)
k
=
key
(
10
)
self
.
assertRaises
(
TypeError
,
hash
,
k
)
self
.
assertNotIsInstance
(
k
,
collections
.
Hashable
)
self
.
assertNotIsInstance
(
k
,
collections
.
abc
.
Hashable
)
@
unittest
.
skipUnless
(
c_functools
,
'requires the C _functools module'
)
...
...
@@ -1707,7 +1708,7 @@ class TestSingleDispatch(unittest.TestCase):
def
test_compose_mro
(
self
):
# None of the examples in this test depend on haystack ordering.
c
=
collections
c
=
collections
.
abc
mro
=
functools
.
_compose_mro
bases
=
[
c
.
Sequence
,
c
.
MutableMapping
,
c
.
Mapping
,
c
.
Set
]
for
haystack
in
permutations
(
bases
):
...
...
@@ -1715,10 +1716,10 @@ class TestSingleDispatch(unittest.TestCase):
self
.
assertEqual
(
m
,
[
dict
,
c
.
MutableMapping
,
c
.
Mapping
,
c
.
Collection
,
c
.
Sized
,
c
.
Iterable
,
c
.
Container
,
object
])
bases
=
[
c
.
Container
,
c
.
Mapping
,
c
.
MutableMapping
,
c
.
OrderedDict
]
bases
=
[
c
.
Container
,
c
.
Mapping
,
c
.
MutableMapping
,
c
ollections
.
OrderedDict
]
for
haystack
in
permutations
(
bases
):
m
=
mro
(
c
.
ChainMap
,
haystack
)
self
.
assertEqual
(
m
,
[
c
.
ChainMap
,
c
.
MutableMapping
,
c
.
Mapping
,
m
=
mro
(
c
ollections
.
ChainMap
,
haystack
)
self
.
assertEqual
(
m
,
[
c
ollections
.
ChainMap
,
c
.
MutableMapping
,
c
.
Mapping
,
c
.
Collection
,
c
.
Sized
,
c
.
Iterable
,
c
.
Container
,
object
])
...
...
@@ -1728,39 +1729,39 @@ class TestSingleDispatch(unittest.TestCase):
# test_mro_conflicts).
bases
=
[
c
.
Container
,
c
.
Sized
,
str
]
for
haystack
in
permutations
(
bases
):
m
=
mro
(
c
.
defaultdict
,
[
c
.
Sized
,
c
.
Container
,
str
])
self
.
assertEqual
(
m
,
[
c
.
defaultdict
,
dict
,
c
.
Sized
,
c
.
Container
,
object
])
m
=
mro
(
c
ollections
.
defaultdict
,
[
c
.
Sized
,
c
.
Container
,
str
])
self
.
assertEqual
(
m
,
[
c
ollections
.
defaultdict
,
dict
,
c
.
Sized
,
c
.
Container
,
object
])
# MutableSequence below is registered directly on D. In other words, it
# precedes MutableMapping which means single dispatch will always
# choose MutableSequence here.
class
D
(
c
.
defaultdict
):
class
D
(
c
ollections
.
defaultdict
):
pass
c
.
MutableSequence
.
register
(
D
)
bases
=
[
c
.
MutableSequence
,
c
.
MutableMapping
]
for
haystack
in
permutations
(
bases
):
m
=
mro
(
D
,
bases
)
self
.
assertEqual
(
m
,
[
D
,
c
.
MutableSequence
,
c
.
Sequence
,
c
.
Reversible
,
c
.
defaultdict
,
dict
,
c
.
MutableMapping
,
c
.
Mapping
,
c
ollections
.
defaultdict
,
dict
,
c
.
MutableMapping
,
c
.
Mapping
,
c
.
Collection
,
c
.
Sized
,
c
.
Iterable
,
c
.
Container
,
object
])
# Container and Callable are registered on different base classes and
# a generic function supporting both should always pick the Callable
# implementation if a C instance is passed.
class
C
(
c
.
defaultdict
):
class
C
(
c
ollections
.
defaultdict
):
def
__call__
(
self
):
pass
bases
=
[
c
.
Sized
,
c
.
Callable
,
c
.
Container
,
c
.
Mapping
]
for
haystack
in
permutations
(
bases
):
m
=
mro
(
C
,
haystack
)
self
.
assertEqual
(
m
,
[
C
,
c
.
Callable
,
c
.
defaultdict
,
dict
,
c
.
Mapping
,
self
.
assertEqual
(
m
,
[
C
,
c
.
Callable
,
c
ollections
.
defaultdict
,
dict
,
c
.
Mapping
,
c
.
Collection
,
c
.
Sized
,
c
.
Iterable
,
c
.
Container
,
object
])
def
test_register_abc
(
self
):
c
=
collections
c
=
collections
.
abc
d
=
{
"a"
:
"b"
}
l
=
[
1
,
2
,
3
]
s
=
{
object
(),
None
}
...
...
@@ -1786,7 +1787,7 @@ class TestSingleDispatch(unittest.TestCase):
self
.
assertEqual
(
g
(
s
),
"sized"
)
self
.
assertEqual
(
g
(
f
),
"sized"
)
self
.
assertEqual
(
g
(
t
),
"sized"
)
g
.
register
(
c
.
ChainMap
,
lambda
obj
:
"chainmap"
)
g
.
register
(
c
ollections
.
ChainMap
,
lambda
obj
:
"chainmap"
)
self
.
assertEqual
(
g
(
d
),
"mutablemapping"
)
# irrelevant ABCs registered
self
.
assertEqual
(
g
(
l
),
"sized"
)
self
.
assertEqual
(
g
(
s
),
"sized"
)
...
...
@@ -1854,7 +1855,7 @@ class TestSingleDispatch(unittest.TestCase):
self
.
assertEqual
(
g
(
t
),
"tuple"
)
def
test_c3_abc
(
self
):
c
=
collections
c
=
collections
.
abc
mro
=
functools
.
_c3_mro
class
A
(
object
):
pass
...
...
@@ -1895,7 +1896,7 @@ class TestSingleDispatch(unittest.TestCase):
self
.
assertEqual
(
fun
(
aa
),
'fun A'
)
def
test_mro_conflicts
(
self
):
c
=
collections
c
=
collections
.
abc
@
functools
.
singledispatch
def
g
(
arg
):
return
"base"
...
...
@@ -1956,7 +1957,7 @@ class TestSingleDispatch(unittest.TestCase):
# MutableMapping's bases implicit as well from defaultdict's
# perspective.
with
self
.
assertRaises
(
RuntimeError
)
as
re_two
:
h
(
c
.
defaultdict
(
lambda
:
0
))
h
(
c
ollections
.
defaultdict
(
lambda
:
0
))
self
.
assertIn
(
str
(
re_two
.
exception
),
((
"Ambiguous dispatch: <class 'collections.abc.Container'> "
...
...
@@ -1964,7 +1965,7 @@ class TestSingleDispatch(unittest.TestCase):
(
"Ambiguous dispatch: <class 'collections.abc.Sized'> "
"or <class 'collections.abc.Container'>"
)),
)
class
R
(
c
.
defaultdict
):
class
R
(
c
ollections
.
defaultdict
):
pass
c
.
MutableSequence
.
register
(
R
)
@
functools
.
singledispatch
...
...
@@ -2041,7 +2042,7 @@ class TestSingleDispatch(unittest.TestCase):
_orig_wkd
=
functools
.
WeakKeyDictionary
td
=
TracingDict
()
functools
.
WeakKeyDictionary
=
lambda
:
td
c
=
collections
c
=
collections
.
abc
@
functools
.
singledispatch
def
g
(
arg
):
return
"base"
...
...
Lib/test/test_hash.py
View file @
2e576f5a
...
...
@@ -8,7 +8,7 @@ import os
import
sys
import
unittest
from
test.support.script_helper
import
assert_python_ok
from
collections
import
Hashable
from
collections
.abc
import
Hashable
IS_64BIT
=
sys
.
maxsize
>
2
**
32
...
...
Lib/test/test_pathlib.py
View file @
2e576f5a
import
collections
import
collections
.abc
import
io
import
os
import
errno
...
...
@@ -1408,7 +1408,7 @@ class _BasePathTest(object):
P
=
self
.
cls
p
=
P
(
BASE
)
it
=
p
.
glob
(
"fileA"
)
self
.
assertIsInstance
(
it
,
collections
.
Iterator
)
self
.
assertIsInstance
(
it
,
collections
.
abc
.
Iterator
)
_check
(
it
,
[
"fileA"
])
_check
(
p
.
glob
(
"fileB"
),
[])
_check
(
p
.
glob
(
"dir*/file*"
),
[
"dirB/fileB"
,
"dirC/fileC"
])
...
...
@@ -1432,7 +1432,7 @@ class _BasePathTest(object):
P
=
self
.
cls
p
=
P
(
BASE
)
it
=
p
.
rglob
(
"fileA"
)
self
.
assertIsInstance
(
it
,
collections
.
Iterator
)
self
.
assertIsInstance
(
it
,
collections
.
abc
.
Iterator
)
_check
(
it
,
[
"fileA"
])
_check
(
p
.
rglob
(
"fileB"
),
[
"dirB/fileB"
])
_check
(
p
.
rglob
(
"*/fileA"
),
[])
...
...
Lib/test/test_statistics.py
View file @
2e576f5a
...
...
@@ -4,6 +4,7 @@ approx_equal function.
"""
import
collections
import
collections.abc
import
decimal
import
doctest
import
math
...
...
@@ -218,8 +219,8 @@ class NumericTestCase(unittest.TestCase):
if
rel
is
None
:
rel
=
self
.
rel
if
(
isinstance
(
first
,
collections
.
Sequence
)
and
isinstance
(
second
,
collections
.
Sequence
)
isinstance
(
first
,
collections
.
abc
.
Sequence
)
and
isinstance
(
second
,
collections
.
abc
.
Sequence
)
):
check
=
self
.
_check_approx_seq
else
:
...
...
Lib/test/test_typing.py
View file @
2e576f5a
...
...
@@ -2023,11 +2023,11 @@ class CollectionsAbcTests(BaseTestCase):
self
.
assertIsSubclass
(
MMC
,
typing
.
Mapping
)
self
.
assertIsInstance
(
MMB
[
KT
,
VT
](),
typing
.
Mapping
)
self
.
assertIsInstance
(
MMB
[
KT
,
VT
](),
collections
.
Mapping
)
self
.
assertIsInstance
(
MMB
[
KT
,
VT
](),
collections
_abc
.
Mapping
)
self
.
assertIsSubclass
(
MMA
,
collections
.
Mapping
)
self
.
assertIsSubclass
(
MMB
,
collections
.
Mapping
)
self
.
assertIsSubclass
(
MMC
,
collections
.
Mapping
)
self
.
assertIsSubclass
(
MMA
,
collections
_abc
.
Mapping
)
self
.
assertIsSubclass
(
MMB
,
collections
_abc
.
Mapping
)
self
.
assertIsSubclass
(
MMC
,
collections
_abc
.
Mapping
)
self
.
assertIsSubclass
(
MMB
[
str
,
str
],
typing
.
Mapping
)
self
.
assertIsSubclass
(
MMC
,
MMA
)
...
...
@@ -2039,9 +2039,9 @@ class CollectionsAbcTests(BaseTestCase):
def
g
():
yield
0
self
.
assertIsSubclass
(
G
,
typing
.
Generator
)
self
.
assertIsSubclass
(
G
,
typing
.
Iterable
)
if
hasattr
(
collections
,
'Generator'
):
self
.
assertIsSubclass
(
G
,
collections
.
Generator
)
self
.
assertIsSubclass
(
G
,
collections
.
Iterable
)
if
hasattr
(
collections
_abc
,
'Generator'
):
self
.
assertIsSubclass
(
G
,
collections
_abc
.
Generator
)
self
.
assertIsSubclass
(
G
,
collections
_abc
.
Iterable
)
self
.
assertNotIsSubclass
(
type
(
g
),
G
)
@
skipUnless
(
PY36
,
'Python 3.6 required'
)
...
...
@@ -2057,15 +2057,15 @@ class CollectionsAbcTests(BaseTestCase):
g
=
ns
[
'g'
]
self
.
assertIsSubclass
(
G
,
typing
.
AsyncGenerator
)
self
.
assertIsSubclass
(
G
,
typing
.
AsyncIterable
)
self
.
assertIsSubclass
(
G
,
collections
.
AsyncGenerator
)
self
.
assertIsSubclass
(
G
,
collections
.
AsyncIterable
)
self
.
assertIsSubclass
(
G
,
collections
_abc
.
AsyncGenerator
)
self
.
assertIsSubclass
(
G
,
collections
_abc
.
AsyncIterable
)
self
.
assertNotIsSubclass
(
type
(
g
),
G
)
instance
=
G
()
self
.
assertIsInstance
(
instance
,
typing
.
AsyncGenerator
)
self
.
assertIsInstance
(
instance
,
typing
.
AsyncIterable
)
self
.
assertIsInstance
(
instance
,
collections
.
AsyncGenerator
)
self
.
assertIsInstance
(
instance
,
collections
.
AsyncIterable
)
self
.
assertIsInstance
(
instance
,
collections
_abc
.
AsyncGenerator
)
self
.
assertIsInstance
(
instance
,
collections
_abc
.
AsyncIterable
)
self
.
assertNotIsInstance
(
type
(
g
),
G
)
self
.
assertNotIsInstance
(
g
,
G
)
...
...
@@ -2102,23 +2102,23 @@ class CollectionsAbcTests(BaseTestCase):
self
.
assertIsSubclass
(
D
,
B
)
class
M
():
...
collections
.
MutableMapping
.
register
(
M
)
collections
_abc
.
MutableMapping
.
register
(
M
)
self
.
assertIsSubclass
(
M
,
typing
.
Mapping
)
def
test_collections_as_base
(
self
):
class
M
(
collections
.
Mapping
):
...
class
M
(
collections
_abc
.
Mapping
):
...
self
.
assertIsSubclass
(
M
,
typing
.
Mapping
)
self
.
assertIsSubclass
(
M
,
typing
.
Iterable
)
class
S
(
collections
.
MutableSequence
):
...
class
S
(
collections
_abc
.
MutableSequence
):
...
self
.
assertIsSubclass
(
S
,
typing
.
MutableSequence
)
self
.
assertIsSubclass
(
S
,
typing
.
Iterable
)
class
I
(
collections
.
Iterable
):
...
class
I
(
collections
_abc
.
Iterable
):
...
self
.
assertIsSubclass
(
I
,
typing
.
Iterable
)
class
A
(
collections
.
Mapping
,
metaclass
=
abc
.
ABCMeta
):
...
class
A
(
collections
_abc
.
Mapping
,
metaclass
=
abc
.
ABCMeta
):
...
class
B
:
...
A
.
register
(
B
)
self
.
assertIsSubclass
(
B
,
typing
.
Mapping
)
...
...
Lib/tracemalloc.py
View file @
2e576f5a
from
collections
import
Sequence
,
Iterable
from
collections
.abc
import
Sequence
,
Iterable
from
functools
import
total_ordering
import
fnmatch
import
linecache
...
...
Lib/weakref.py
View file @
2e576f5a
...
...
@@ -21,7 +21,7 @@ from _weakref import (
from
_weakrefset
import
WeakSet
,
_IterationGuard
import
collections
# Import after _weakref to avoid circular import.
import
collections
.abc
# Import after _weakref to avoid circular import.
import
sys
import
itertools
...
...
@@ -87,7 +87,7 @@ class WeakMethod(ref):
__hash__
=
ref
.
__hash__
class
WeakValueDictionary
(
collections
.
MutableMapping
):
class
WeakValueDictionary
(
collections
.
abc
.
MutableMapping
):
"""Mapping class that references values weakly.
Entries in the dictionary will be discarded when no strong
...
...
@@ -340,7 +340,7 @@ class KeyedRef(ref):
super
().
__init__
(
ob
,
callback
)
class
WeakKeyDictionary
(
collections
.
MutableMapping
):
class
WeakKeyDictionary
(
collections
.
abc
.
MutableMapping
):
""" Mapping class that references keys weakly.
Entries in the dictionary will be discarded when there is no
...
...
Lib/xml/etree/ElementTree.py
View file @
2e576f5a
...
...
@@ -96,6 +96,7 @@ import re
import
warnings
import
io
import
collections
import
collections.abc
import
contextlib
from
.
import
ElementPath
...
...
@@ -1231,7 +1232,7 @@ def iterparse(source, events=None, parser=None):
if
close_source
:
source
.
close
()
class
IterParseIterator
(
collections
.
Iterator
):
class
IterParseIterator
(
collections
.
abc
.
Iterator
):
__next__
=
iterator
().
__next__
it
=
IterParseIterator
()
it
.
root
=
None
...
...
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