Skip to content

Commit ec06423

Browse files
authored
Merge pull request #325 from python/master
Sync Fork from Upstream Repo
2 parents 8ea85ce + 1dd3794 commit ec06423

22 files changed

+323
-128
lines changed

Doc/library/ast.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,7 @@ and classes for traversing abstract syntax trees:
17041704
value=Name(id='data', ctx=Load()),
17051705
slice=Constant(value=node.id),
17061706
ctx=node.ctx
1707-
), node)
1707+
)
17081708

17091709
Keep in mind that if the node you're operating on has child nodes you must
17101710
either transform the child nodes yourself or call the :meth:`generic_visit`

Lib/ast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,11 @@ class NodeTransformer(NodeVisitor):
443443
class RewriteName(NodeTransformer):
444444
445445
def visit_Name(self, node):
446-
return copy_location(Subscript(
446+
return Subscript(
447447
value=Name(id='data', ctx=Load()),
448448
slice=Constant(value=node.id),
449449
ctx=node.ctx
450-
), node)
450+
)
451451
452452
Keep in mind that if the node you're operating on has child nodes you must
453453
either transform the child nodes yourself or call the :meth:`generic_visit`

Lib/lib2to3/fixes/fix_urllib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
("urllib.request",
1414
["URLopener", "FancyURLopener", "urlretrieve",
1515
"_urlopener", "urlopen", "urlcleanup",
16-
"pathname2url", "url2pathname"]),
16+
"pathname2url", "url2pathname", "getproxies"]),
1717
("urllib.parse",
1818
["quote", "quote_plus", "unquote", "unquote_plus",
1919
"urlencode", "splitattr", "splithost", "splitnport",

Lib/lib2to3/tests/test_fixers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,11 @@ def foo():
19131913
"""
19141914
self.check(b, a)
19151915

1916+
def test_single_import(self):
1917+
b = "from urllib import getproxies"
1918+
a = "from urllib.request import getproxies"
19161919

1920+
self.check(b, a)
19171921

19181922
def test_import_module_usage(self):
19191923
for old, changes in self.modules.items():

Lib/pathlib.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,8 @@ def __init__(self, pat, child_parts, flavour):
527527

528528
def _select_from(self, parent_path, is_dir, exists, scandir):
529529
try:
530-
entries = list(scandir(parent_path))
530+
with scandir(parent_path) as scandir_it:
531+
entries = list(scandir_it)
531532
for entry in entries:
532533
if self.dironly:
533534
try:
@@ -557,7 +558,8 @@ def __init__(self, pat, child_parts, flavour):
557558
def _iterate_directories(self, parent_path, is_dir, scandir):
558559
yield parent_path
559560
try:
560-
entries = list(scandir(parent_path))
561+
with scandir(parent_path) as scandir_it:
562+
entries = list(scandir_it)
561563
for entry in entries:
562564
entry_is_dir = False
563565
try:

Lib/unittest/mock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,7 @@ async def _execute_mock_call(self, /, *args, **kwargs):
21712171
# This is nearly just like super(), except for special handling
21722172
# of coroutines
21732173

2174-
_call = self.call_args
2174+
_call = _Call((args, kwargs), two=True)
21752175
self.await_count += 1
21762176
self.await_args = _call
21772177
self.await_args_list.append(_call)

Lib/unittest/test/testmock/testasync.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,17 @@ def inner():
500500
mock.assert_awaited()
501501
self.assertTrue(ran)
502502

503+
async def test_await_args_list_order(self):
504+
async_mock = AsyncMock()
505+
mock2 = async_mock(2)
506+
mock1 = async_mock(1)
507+
await mock1
508+
await mock2
509+
async_mock.assert_has_awaits([call(1), call(2)])
510+
self.assertEqual(async_mock.await_args_list, [call(1), call(2)])
511+
self.assertEqual(async_mock.call_args_list, [call(2), call(1)])
512+
513+
503514
class AsyncMagicMethods(unittest.TestCase):
504515
def test_async_magic_methods_return_async_mocks(self):
505516
m_mock = MagicMock()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Port _locale extension module to multiphase initialization (:pep:`489`).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Port audioop extension module to multiphase initialization (:pep:`489`).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
More reliable use of ``os.scandir()`` in ``Path.glob()``. It no longer emits
2+
a ResourceWarning when interrupted.

0 commit comments

Comments
 (0)