Skip to content

Commit 43e3d20

Browse files
authored
Merge pull request #447 from python/master
Sync Fork from Upstream Repo
2 parents 8282500 + 8bbfeb3 commit 43e3d20

40 files changed

+4636
-4650
lines changed

Doc/data/stable_abi.dat

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,6 @@ PyType_GetFlags
616616
PyType_GetModule
617617
PyType_GetModuleState
618618
PyType_GetSlot
619-
PyType_HasFeature
620619
PyType_IsSubtype
621620
PyType_Modified
622621
PyType_Ready

Doc/howto/descriptor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ roughly equivalent to:
10641064
.. testcode::
10651065

10661066
class MethodType:
1067-
"Emulate Py_MethodType in Objects/classobject.c"
1067+
"Emulate PyMethod_Type in Objects/classobject.c"
10681068

10691069
def __init__(self, func, obj):
10701070
self.__func__ = func

Include/methodobject.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ PyAPI_FUNC(PyObject *) PyCMethod_New(PyMethodDef *, PyObject *,
7979

8080
#define METH_COEXIST 0x0040
8181

82-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03100000
83-
#define METH_FASTCALL 0x0080
82+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030a0000
83+
# define METH_FASTCALL 0x0080
8484
#endif
8585

8686
/* This bit is preserved for Stackless Python */
8787
#ifdef STACKLESS
88-
#define METH_STACKLESS 0x0100
88+
# define METH_STACKLESS 0x0100
8989
#else
90-
#define METH_STACKLESS 0x0000
90+
# define METH_STACKLESS 0x0000
9191
#endif
9292

9393
/* METH_METHOD means the function stores an

Lib/compileall.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ def main():
407407
# if flist is provided then load it
408408
if args.flist:
409409
try:
410-
with (sys.stdin if args.flist=='-' else open(args.flist)) as f:
410+
with (sys.stdin if args.flist=='-' else
411+
open(args.flist, encoding="utf-8")) as f:
411412
for line in f:
412413
compile_dests.append(line.strip())
413414
except OSError:

Lib/dis.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,11 @@ def _get_instructions_bytes(code, varnames=None, names=None, constants=None,
338338
argval, argrepr = _get_const_info(arg, constants)
339339
elif op in hasname:
340340
argval, argrepr = _get_name_info(arg, names)
341+
elif op in hasjabs:
342+
argval = arg*2
343+
argrepr = "to " + repr(argval)
341344
elif op in hasjrel:
342-
argval = offset + 2 + arg
345+
argval = offset + 2 + arg*2
343346
argrepr = "to " + repr(argval)
344347
elif op in haslocal:
345348
argval, argrepr = _get_name_info(arg, varnames)
@@ -437,9 +440,9 @@ def findlabels(code):
437440
for offset, op, arg in _unpack_opargs(code):
438441
if arg is not None:
439442
if op in hasjrel:
440-
label = offset + 2 + arg
443+
label = offset + 2 + arg*2
441444
elif op in hasjabs:
442-
label = arg
445+
label = arg*2
443446
else:
444447
continue
445448
if label not in labels:

Lib/importlib/_bootstrap_external.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ def _write_atomic(path, data, mode=0o666):
314314
# Python 3.10a2 3432 (Function annotation for MAKE_FUNCTION is changed from dict to tuple bpo-42202)
315315
# Python 3.10a2 3433 (RERAISE restores f_lasti if oparg != 0)
316316
# Python 3.10a6 3434 (PEP 634: Structural Pattern Matching)
317+
# Python 3.10a7 3435 Use instruction offsets (as opposed to byte offsets).
317318

318319
#
319320
# MAGIC must change whenever the bytecode emitted by the compiler may no

Lib/lib2to3/pgen2/pgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ParserGenerator(object):
1212
def __init__(self, filename, stream=None):
1313
close_stream = None
1414
if stream is None:
15-
stream = open(filename)
15+
stream = open(filename, encoding="utf-8")
1616
close_stream = stream.close
1717
self.filename = filename
1818
self.stream = stream

Lib/multiprocessing/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def _close_stdin():
419419
try:
420420
fd = os.open(os.devnull, os.O_RDONLY)
421421
try:
422-
sys.stdin = open(fd, closefd=False)
422+
sys.stdin = open(fd, encoding="utf-8", closefd=False)
423423
except:
424424
os.close(fd)
425425
raise

Lib/pdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ def main():
17081708
print("The program finished and will be restarted")
17091709
except Restart:
17101710
print("Restarting", mainpyfile, "with arguments:")
1711-
print("\t" + " ".join(args))
1711+
print("\t" + " ".join(sys.argv[1:]))
17121712
except SystemExit:
17131713
# In most cases SystemExit does not warrant a post-mortem session.
17141714
print("The program exited via sys.exit(). Exit status:", end=' ')

Lib/test/test__xxsubinterpreters.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ def _captured_script(script):
2525
indented = script.replace('\n', '\n ')
2626
wrapped = dedent(f"""
2727
import contextlib
28-
with open({w}, 'w') as spipe:
28+
with open({w}, 'w', encoding="utf-8") as spipe:
2929
with contextlib.redirect_stdout(spipe):
3030
{indented}
3131
""")
32-
return wrapped, open(r)
32+
return wrapped, open(r, encoding="utf-8")
3333

3434

3535
def _run_output(interp, request, shared=None):
@@ -45,7 +45,7 @@ def _running(interp):
4545
def run():
4646
interpreters.run_string(interp, dedent(f"""
4747
# wait for "signal"
48-
with open({r}) as rpipe:
48+
with open({r}, encoding="utf-8") as rpipe:
4949
rpipe.read()
5050
"""))
5151

@@ -54,7 +54,7 @@ def run():
5454

5555
yield
5656

57-
with open(w, 'w') as spipe:
57+
with open(w, 'w', encoding="utf-8") as spipe:
5858
spipe.write('done')
5959
t.join()
6060

@@ -806,7 +806,7 @@ def f():
806806
@unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()")
807807
def test_fork(self):
808808
import tempfile
809-
with tempfile.NamedTemporaryFile('w+') as file:
809+
with tempfile.NamedTemporaryFile('w+', encoding="utf-8") as file:
810810
file.write('')
811811
file.flush()
812812

@@ -816,7 +816,7 @@ def test_fork(self):
816816
try:
817817
os.fork()
818818
except RuntimeError:
819-
with open('{file.name}', 'w') as out:
819+
with open('{file.name}', 'w', encoding='utf-8') as out:
820820
out.write('{expected}')
821821
""")
822822
interpreters.run_string(self.id, script)

0 commit comments

Comments
 (0)