Skip to content

Commit aa58b63

Browse files
authored
Merge pull request RustPython#2252 from RustPython/coolreader18/misc-altair-fixes
Misc fixes found while trying to get Altair to work
2 parents 25e44cc + 1e68e8b commit aa58b63

16 files changed

+724
-122
lines changed

Lib/_py_abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ABCMeta(type):
3333
_abc_invalidation_counter = 0
3434

3535
def __new__(mcls, name, bases, namespace, **kwargs):
36-
cls = type.__new__(mcls, name, bases, namespace, **kwargs)
36+
cls = super().__new__(mcls, name, bases, namespace, **kwargs)
3737
# Compute set of abstract method names
3838
abstracts = {name
3939
for name, value in namespace.items()

Lib/collections/_defaultdict.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
class defaultdict(dict):
2-
def __new__(cls, *args, **kwargs):
2+
def __init__(self, *args, **kwargs):
33
if len(args) >= 1:
44
default_factory = args[0]
55
args = args[1:]
66
else:
77
default_factory = None
8-
self = dict.__new__(cls, *args, **kwargs)
8+
super().__init__(*args, **kwargs)
99
self.default_factory = default_factory
10-
return self
1110

1211
def __missing__(self, key):
1312
if self.default_factory:

Lib/importlib/_bootstrap_external.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,16 @@ def _write_atomic(path, data, mode=0o666):
261261
# Python 3.7a2 3391 (update GET_AITER #31709)
262262
# Python 3.7a4 3392 (PEP 552: Deterministic pycs #31650)
263263
# Python 3.7b1 3393 (remove STORE_ANNOTATION opcode #32550)
264-
# Python 3.7b5 3394 (restored docstring as the firts stmt in the body;
264+
# Python 3.7b5 3394 (restored docstring as the first stmt in the body;
265265
# this might affected the first line number #32911)
266266
# Python 3.8a1 3400 (move frame block handling to compiler #17611)
267267
# Python 3.8a1 3401 (add END_ASYNC_FOR #33041)
268268
# Python 3.8a1 3410 (PEP570 Python Positional-Only Parameters #36540)
269+
# Python 3.8b2 3411 (Reverse evaluation order of key: value in dict
270+
# comprehensions #35224)
271+
# Python 3.8b2 3412 (Swap the position of positional args and positional
272+
# only args in ast.arguments #37593)
273+
# Python 3.8b4 3413 (Fix "break" and "continue" in "finally" #37830)
269274
#
270275
# MAGIC must change whenever the bytecode emitted by the compiler may no
271276
# longer be understood by older implementations of the eval loop (usually
@@ -963,8 +968,12 @@ def get_filename(self, fullname):
963968

964969
def get_data(self, path):
965970
"""Return the data from path as raw bytes."""
966-
with _io.FileIO(path, 'r') as file:
967-
return file.read()
971+
if isinstance(self, (SourceLoader, ExtensionFileLoader)):
972+
with _io.open_code(str(path)) as file:
973+
return file.read()
974+
else:
975+
with _io.FileIO(path, 'r') as file:
976+
return file.read()
968977

969978
# ResourceReader ABC API.
970979

@@ -1359,6 +1368,19 @@ def find_module(cls, fullname, path=None):
13591368
return None
13601369
return spec.loader
13611370

1371+
@classmethod
1372+
def find_distributions(cls, *args, **kwargs):
1373+
"""
1374+
Find distributions.
1375+
1376+
Return an iterable of all Distribution instances capable of
1377+
loading the metadata for packages matching ``context.name``
1378+
(or all names if ``None`` indicated) along the paths in the list
1379+
of directories ``context.path``.
1380+
"""
1381+
from importlib.metadata import MetadataPathFinder
1382+
return MetadataPathFinder.find_distributions(*args, **kwargs)
1383+
13621384

13631385
class FileFinder:
13641386

0 commit comments

Comments
 (0)