summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-12-27 12:46:59 -0500
committerJason R. Coombs <jaraco@jaraco.com>2020-12-27 12:46:59 -0500
commita78f0158a28734f965218b834ea8c0b166b7353f (patch)
treedca70268e2a41d49658e7eed783c6fc243d119cd
parentec8e6895a3ce9cd69b6ceb75a15fcc74d4a522dc (diff)
parentbf64d9064ab641b1ef9a0c4bda097ebf1204faf4 (diff)
downloadcpython-git-revert-23107-revert-13893-fix-issue-37193.tar.gz
Merge branch 'master' into revert-23107-revert-13893-fix-issue-37193revert-23107-revert-13893-fix-issue-37193
-rw-r--r--.azure-pipelines/ci.yml2
-rw-r--r--.azure-pipelines/docs-steps.yml6
-rw-r--r--.azure-pipelines/pr.yml2
-rw-r--r--.azure-pipelines/windows-release/stage-pack-msix.yml3
-rw-r--r--.azure-pipelines/windows-release/stage-pack-nuget.yml10
-rw-r--r--.azure-pipelines/windows-release/stage-sign.yml2
-rw-r--r--.github/CODEOWNERS7
-rw-r--r--.github/dependabot.yml4
-rw-r--r--.github/workflows/build.yml37
-rw-r--r--.github/workflows/coverage.yml2
-rw-r--r--.github/workflows/doc.yml4
-rw-r--r--.github/workflows/stale.yml19
-rw-r--r--.travis.yml4
-rw-r--r--Doc/Makefile6
-rw-r--r--Doc/c-api/arg.rst3
-rw-r--r--Doc/c-api/init.rst38
-rw-r--r--Doc/c-api/init_config.rst234
-rw-r--r--Doc/c-api/intro.rst2
-rw-r--r--Doc/c-api/module.rst104
-rw-r--r--Doc/c-api/refcounting.rst60
-rw-r--r--Doc/c-api/reflection.rst4
-rw-r--r--Doc/c-api/structures.rst16
-rw-r--r--Doc/c-api/tuple.rst2
-rw-r--r--Doc/c-api/type.rst24
-rw-r--r--Doc/c-api/typeobj.rst29
-rw-r--r--Doc/c-api/weakref.rst6
-rw-r--r--Doc/conf.py3
-rw-r--r--Doc/data/refcounts.dat6
-rw-r--r--Doc/data/stable_abi.dat780
-rw-r--r--Doc/glossary.rst24
-rw-r--r--Doc/howto/argparse.rst23
-rw-r--r--Doc/howto/descriptor.rst653
-rw-r--r--Doc/library/abc.rst3
-rw-r--r--Doc/library/argparse.rst189
-rw-r--r--Doc/library/ast.rst19
-rw-r--r--Doc/library/asyncio-eventloop.rst41
-rw-r--r--Doc/library/asyncio-future.rst6
-rw-r--r--Doc/library/asyncio-policy.rst4
-rw-r--r--Doc/library/asyncio-queue.rst5
-rw-r--r--Doc/library/asyncio-stream.rst27
-rw-r--r--Doc/library/asyncio-subprocess.rst15
-rw-r--r--Doc/library/asyncio-sync.rst39
-rw-r--r--Doc/library/asyncio-task.rst46
-rw-r--r--Doc/library/base64.rst2
-rw-r--r--Doc/library/bz2.rst8
-rw-r--r--Doc/library/collections.abc.rst2
-rw-r--r--Doc/library/collections.rst3
-rw-r--r--Doc/library/compileall.rst4
-rw-r--r--Doc/library/concurrent.futures.rst8
-rw-r--r--Doc/library/contextlib.rst82
-rw-r--r--Doc/library/contextvars.rst4
-rw-r--r--Doc/library/ctypes.rst2
-rw-r--r--Doc/library/datetime.rst4
-rw-r--r--Doc/library/dialog.rst2
-rw-r--r--Doc/library/difflib.rst6
-rw-r--r--Doc/library/dis.rst19
-rw-r--r--Doc/library/doctest.rst54
-rw-r--r--Doc/library/email.contentmanager.rst2
-rw-r--r--Doc/library/email.header.rst2
-rw-r--r--Doc/library/email.policy.rst2
-rw-r--r--Doc/library/enum.rst17
-rw-r--r--Doc/library/exceptions.rst9
-rw-r--r--Doc/library/filecmp.rst8
-rw-r--r--Doc/library/fnmatch.rst2
-rw-r--r--Doc/library/formatter.rst351
-rw-r--r--Doc/library/functions.rst19
-rw-r--r--Doc/library/http.client.rst5
-rw-r--r--Doc/library/http.cookies.rst2
-rw-r--r--Doc/library/imaplib.rst6
-rw-r--r--Doc/library/importlib.rst4
-rw-r--r--Doc/library/index.rst1
-rw-r--r--Doc/library/inspect.rst26
-rw-r--r--Doc/library/io.rst2
-rw-r--r--Doc/library/itertools.rst47
-rw-r--r--Doc/library/logging.config.rst78
-rw-r--r--Doc/library/logging.rst8
-rw-r--r--Doc/library/lzma.rst4
-rw-r--r--Doc/library/misc.rst13
-rw-r--r--Doc/library/mmap.rst2
-rw-r--r--Doc/library/multiprocessing.rst48
-rw-r--r--Doc/library/os.rst161
-rw-r--r--Doc/library/pathlib.rst2
-rw-r--r--Doc/library/pickle.rst12
-rw-r--r--Doc/library/pipes.rst2
-rw-r--r--Doc/library/platform.rst45
-rw-r--r--Doc/library/plistlib.rst8
-rw-r--r--Doc/library/profile.rst8
-rw-r--r--Doc/library/pyclbr.rst7
-rw-r--r--Doc/library/random.rst9
-rw-r--r--Doc/library/shlex.rst14
-rw-r--r--Doc/library/shutil.rst2
-rw-r--r--Doc/library/signal.rst2
-rw-r--r--Doc/library/smtplib.rst4
-rwxr-xr-xDoc/library/socket.rst17
-rw-r--r--Doc/library/sqlite3.rst4
-rw-r--r--Doc/library/statistics.rst21
-rw-r--r--Doc/library/stdtypes.rst10
-rw-r--r--Doc/library/string.rst70
-rw-r--r--Doc/library/subprocess.rst16
-rw-r--r--Doc/library/symtable.rst2
-rw-r--r--Doc/library/sysconfig.rst2
-rw-r--r--Doc/library/tarfile.rst2
-rw-r--r--Doc/library/test.rst4
-rw-r--r--Doc/library/threading.rst27
-rw-r--r--Doc/library/time.rst43
-rw-r--r--Doc/library/tkinter.font.rst7
-rw-r--r--Doc/library/trace.rst50
-rw-r--r--Doc/library/traceback.rst43
-rw-r--r--Doc/library/turtle.rst12
-rw-r--r--Doc/library/types.rst8
-rw-r--r--Doc/library/typing.rst11
-rw-r--r--Doc/library/unittest.mock.rst7
-rw-r--r--Doc/library/unittest.rst3
-rw-r--r--Doc/library/urllib.request.rst5
-rw-r--r--Doc/library/warnings.rst2
-rw-r--r--Doc/library/winreg.rst2
-rw-r--r--Doc/library/xml.dom.minidom.rst4
-rw-r--r--Doc/library/xml.etree.elementtree.rst18
-rw-r--r--Doc/library/zipfile.rst15
-rw-r--r--Doc/library/zipimport.rst53
-rw-r--r--Doc/reference/compound_stmts.rst35
-rw-r--r--Doc/reference/datamodel.rst1
-rw-r--r--Doc/reference/grammar.rst3
-rw-r--r--Doc/reference/simple_stmts.rst2
-rw-r--r--Doc/tools/extensions/c_annotations.py4
-rw-r--r--Doc/tools/extensions/glossary_search.py57
-rw-r--r--Doc/tools/extensions/pyspecific.py7
-rwxr-xr-xDoc/tools/rstlint.py76
-rw-r--r--Doc/tools/static/switchers.js156
-rw-r--r--Doc/tools/templates/dummy.html9
-rw-r--r--Doc/tools/templates/indexsidebar.html8
-rw-r--r--Doc/tools/templates/layout.html10
-rw-r--r--Doc/tools/templates/search.html48
-rw-r--r--Doc/tutorial/datastructures.rst2
-rw-r--r--Doc/tutorial/errors.rst23
-rw-r--r--Doc/tutorial/inputoutput.rst15
-rw-r--r--Doc/using/windows.rst4
-rw-r--r--Doc/whatsnew/3.10.rst293
-rw-r--r--Doc/whatsnew/3.8.rst3
-rw-r--r--Doc/whatsnew/3.9.rst66
-rw-r--r--Grammar/python.gram25
-rw-r--r--Include/abstract.h5
-rw-r--r--Include/boolobject.h4
-rw-r--r--Include/bytesobject.h35
-rw-r--r--Include/cellobject.h2
-rw-r--r--Include/cpython/bytesobject.h2
-rw-r--r--Include/cpython/code.h28
-rw-r--r--Include/cpython/fileutils.h4
-rw-r--r--Include/cpython/initconfig.h10
-rw-r--r--Include/cpython/listobject.h2
-rw-r--r--Include/cpython/object.h17
-rw-r--r--Include/cpython/pylifecycle.h6
-rw-r--r--Include/cpython/pystate.h33
-rw-r--r--Include/cpython/pythonrun.h131
-rw-r--r--Include/cpython/tupleobject.h2
-rw-r--r--Include/internal/pycore_atomic.h6
-rw-r--r--Include/internal/pycore_atomic_funcs.h94
-rw-r--r--Include/internal/pycore_bitutils.h15
-rw-r--r--Include/internal/pycore_ceval.h16
-rw-r--r--Include/internal/pycore_format.h27
-rw-r--r--Include/internal/pycore_import.h2
-rw-r--r--Include/internal/pycore_initconfig.h10
-rw-r--r--Include/internal/pycore_interp.h70
-rw-r--r--Include/internal/pycore_object.h3
-rw-r--r--Include/internal/pycore_pylifecycle.h14
-rw-r--r--Include/internal/pycore_runtime.h7
-rw-r--r--Include/internal/pycore_unionobject.h1
-rw-r--r--Include/internal/pycore_warnings.h2
-rw-r--r--Include/intrcheck.h1
-rw-r--r--Include/methodobject.h2
-rw-r--r--Include/modsupport.h10
-rw-r--r--Include/object.h60
-rw-r--r--Include/objimpl.h10
-rw-r--r--Include/opcode.h2
-rw-r--r--Include/patchlevel.h4
-rw-r--r--Include/pylifecycle.h2
-rw-r--r--Include/pymem.h34
-rw-r--r--Include/pyport.h12
-rw-r--r--Include/pythonrun.h124
-rw-r--r--Include/pytime.h52
-rw-r--r--Include/typeslots.h4
-rw-r--r--Lib/_collections_abc.py116
-rw-r--r--Lib/_osx_support.py78
-rw-r--r--Lib/argparse.py2
-rw-r--r--Lib/ast.py115
-rw-r--r--Lib/asyncio/__init__.py4
-rw-r--r--Lib/asyncio/base_events.py17
-rw-r--r--Lib/asyncio/base_futures.py25
-rw-r--r--Lib/asyncio/events.py14
-rw-r--r--Lib/asyncio/exceptions.py3
-rw-r--r--Lib/asyncio/futures.py2
-rw-r--r--Lib/asyncio/locks.py71
-rw-r--r--Lib/asyncio/mixins.py31
-rw-r--r--Lib/asyncio/queues.py21
-rw-r--r--Lib/asyncio/runners.py3
-rw-r--r--Lib/asyncio/streams.py37
-rw-r--r--Lib/asyncio/subprocess.py30
-rw-r--r--Lib/asyncio/tasks.py92
-rw-r--r--Lib/asyncio/unix_events.py68
-rw-r--r--Lib/asyncore.py16
-rwxr-xr-xLib/cgi.py2
-rw-r--r--Lib/collections/__init__.py2
-rw-r--r--Lib/collections/abc.py1
-rw-r--r--Lib/colorsys.py15
-rw-r--r--Lib/contextlib.py35
-rw-r--r--Lib/ctypes/macholib/dyld.py12
-rw-r--r--Lib/ctypes/test/test_macholib.py15
-rw-r--r--Lib/dis.py35
-rw-r--r--Lib/distutils/command/install.py13
-rw-r--r--Lib/distutils/spawn.py4
-rw-r--r--Lib/distutils/tests/test_build_ext.py12
-rw-r--r--Lib/distutils/tests/test_install.py8
-rw-r--r--Lib/distutils/unixccompiler.py2
-rw-r--r--Lib/doctest.py18
-rw-r--r--Lib/enum.py271
-rw-r--r--Lib/filecmp.py9
-rw-r--r--Lib/fnmatch.py2
-rw-r--r--Lib/formatter.py452
-rw-r--r--Lib/http/client.py5
-rw-r--r--Lib/http/server.py12
-rw-r--r--Lib/idlelib/NEWS.txt9
-rw-r--r--Lib/idlelib/calltip.py6
-rw-r--r--Lib/idlelib/codecontext.py13
-rw-r--r--Lib/idlelib/idle_test/test_calltip.py9
-rw-r--r--Lib/idlelib/idle_test/test_searchengine.py6
-rwxr-xr-xLib/idlelib/pyshell.py10
-rw-r--r--Lib/idlelib/runscript.py26
-rw-r--r--Lib/idlelib/searchengine.py11
-rw-r--r--Lib/importlib/__init__.py2
-rw-r--r--Lib/importlib/_abc.py1
-rw-r--r--Lib/importlib/_bootstrap.py43
-rw-r--r--Lib/importlib/_bootstrap_external.py142
-rw-r--r--Lib/importlib/abc.py1
-rw-r--r--Lib/importlib/machinery.py2
-rw-r--r--Lib/importlib/util.py1
-rw-r--r--Lib/inspect.py101
-rw-r--r--Lib/lib2to3/Grammar.txt52
-rw-r--r--Lib/lib2to3/tests/test_parser.py31
-rw-r--r--Lib/linecache.py11
-rw-r--r--Lib/logging/__init__.py8
-rw-r--r--Lib/opcode.py2
-rw-r--r--Lib/os.py94
-rw-r--r--Lib/pathlib.py5
-rw-r--r--Lib/pickle.py4
-rwxr-xr-xLib/platform.py57
-rw-r--r--Lib/plistlib.py2
-rw-r--r--Lib/posixpath.py3
-rw-r--r--Lib/pprint.py150
-rw-r--r--Lib/pyclbr.py313
-rw-r--r--Lib/pydoc_data/topics.py299
-rw-r--r--Lib/random.py13
-rw-r--r--Lib/shutil.py2
-rw-r--r--Lib/site.py35
-rwxr-xr-xLib/smtpd.py2
-rwxr-xr-xLib/socket.py6
-rw-r--r--Lib/sqlite3/__init__.py14
-rw-r--r--Lib/sqlite3/test/factory.py7
-rw-r--r--Lib/statistics.py46
-rw-r--r--Lib/subprocess.py12
-rw-r--r--Lib/sysconfig.py118
-rwxr-xr-xLib/tarfile.py68
-rw-r--r--Lib/test/_test_atexit.py121
-rw-r--r--Lib/test/_test_eintr.py (renamed from Lib/test/eintrdata/eintr_tester.py)0
-rw-r--r--Lib/test/_test_embed_set_config.py261
-rw-r--r--Lib/test/crashers/bogus_code_obj.py2
-rw-r--r--Lib/test/inspect_fodder.py22
-rw-r--r--Lib/test/support/__init__.py2
-rw-r--r--Lib/test/support/bytecode_helper.py3
-rw-r--r--Lib/test/support/script_helper.py32
-rw-r--r--Lib/test/support/socket_helper.py2
-rw-r--r--Lib/test/test_argparse.py112
-rw-r--r--Lib/test/test_array.py2
-rw-r--r--Lib/test/test_asdl_parser.py6
-rw-r--r--Lib/test/test_ast.py12
-rw-r--r--Lib/test/test_asyncio/functional.py2
-rw-r--r--Lib/test/test_asyncio/test_asyncio_waitfor.py61
-rw-r--r--Lib/test/test_asyncio/test_base_events.py6
-rw-r--r--Lib/test/test_asyncio/test_events.py254
-rw-r--r--Lib/test/test_asyncio/test_futures2.py18
-rw-r--r--Lib/test/test_asyncio/test_locks.py222
-rw-r--r--Lib/test/test_asyncio/test_pep492.py26
-rw-r--r--Lib/test/test_asyncio/test_queues.py160
-rw-r--r--Lib/test/test_asyncio/test_server.py10
-rw-r--r--Lib/test/test_asyncio/test_sslproto.py34
-rw-r--r--Lib/test/test_asyncio/test_streams.py86
-rw-r--r--Lib/test/test_asyncio/test_subprocess.py20
-rw-r--r--Lib/test/test_asyncio/test_tasks.py119
-rw-r--r--Lib/test/test_asyncio/test_unix_events.py261
-rw-r--r--Lib/test/test_asyncio/utils.py7
-rw-r--r--Lib/test/test_asyncore.py2
-rw-r--r--Lib/test/test_atexit.py190
-rw-r--r--Lib/test/test_builtin.py13
-rw-r--r--Lib/test/test_bytes.py1
-rw-r--r--Lib/test/test_capi.py3
-rw-r--r--Lib/test/test_clinic.py26
-rw-r--r--Lib/test/test_cmd_line.py8
-rw-r--r--Lib/test/test_code.py2
-rw-r--r--Lib/test/test_collections.py72
-rw-r--r--Lib/test/test_compile.py115
-rw-r--r--Lib/test/test_contextlib_async.py41
-rw-r--r--Lib/test/test_descr.py10
-rw-r--r--Lib/test/test_dict.py19
-rw-r--r--Lib/test/test_dis.py266
-rw-r--r--Lib/test/test_doctest.py3
-rw-r--r--Lib/test/test_eintr.py21
-rw-r--r--Lib/test/test_embed.py33
-rw-r--r--Lib/test/test_enum.py184
-rw-r--r--Lib/test/test_enumerate.py13
-rw-r--r--Lib/test/test_epoll.py24
-rw-r--r--Lib/test/test_exception_hierarchy.py4
-rw-r--r--Lib/test/test_exceptions.py137
-rw-r--r--Lib/test/test_filecmp.py53
-rw-r--r--Lib/test/test_format.py4
-rw-r--r--Lib/test/test_ftplib.py2
-rw-r--r--Lib/test/test_gdb.py5
-rw-r--r--Lib/test/test_genericalias.py174
-rw-r--r--Lib/test/test_hashlib.py27
-rw-r--r--Lib/test/test_httpservers.py37
-rw-r--r--Lib/test/test_idle.py2
-rw-r--r--Lib/test/test_imaplib.py2
-rw-r--r--Lib/test/test_importlib/builtin/test_loader.py5
-rw-r--r--Lib/test/test_importlib/extension/test_loader.py44
-rw-r--r--Lib/test/test_importlib/frozen/test_loader.py20
-rw-r--r--Lib/test/test_importlib/import_/test___loader__.py39
-rw-r--r--Lib/test/test_importlib/import_/test___package__.py25
-rw-r--r--Lib/test/test_importlib/import_/test_api.py31
-rw-r--r--Lib/test/test_importlib/import_/test_caching.py39
-rw-r--r--Lib/test/test_importlib/import_/test_fromlist.py26
-rw-r--r--Lib/test/test_importlib/import_/test_meta_path.py14
-rw-r--r--Lib/test/test_importlib/test_abc.py84
-rw-r--r--Lib/test/test_importlib/test_api.py16
-rw-r--r--Lib/test/test_importlib/test_spec.py54
-rw-r--r--Lib/test/test_inspect.py54
-rw-r--r--Lib/test/test_itertools.py103
-rw-r--r--Lib/test/test_logging.py9
-rw-r--r--Lib/test/test_mailcap.py2
-rw-r--r--Lib/test/test_named_expressions.py90
-rw-r--r--Lib/test/test_netrc.py90
-rw-r--r--Lib/test/test_opcache.py23
-rw-r--r--Lib/test/test_opcodes.py2
-rw-r--r--Lib/test/test_ordered_dict.py11
-rw-r--r--Lib/test/test_os.py217
-rw-r--r--Lib/test/test_pathlib.py39
-rw-r--r--Lib/test/test_pdb.py3
-rw-r--r--Lib/test/test_peepholer.py15
-rw-r--r--Lib/test/test_peg_generator/test_c_parser.py6
-rw-r--r--Lib/test/test_peg_generator/test_grammar_validator.py51
-rw-r--r--Lib/test/test_pipes.py5
-rw-r--r--Lib/test/test_platform.py113
-rw-r--r--Lib/test/test_popen.py3
-rw-r--r--Lib/test/test_poplib.py2
-rw-r--r--Lib/test/test_posix.py265
-rw-r--r--Lib/test/test_posixpath.py3
-rw-r--r--Lib/test/test_pprint.py13
-rw-r--r--Lib/test/test_pty.py122
-rw-r--r--Lib/test/test_pyclbr.py7
-rw-r--r--Lib/test/test_random.py27
-rw-r--r--Lib/test/test_re.py4
-rw-r--r--Lib/test/test_select.py31
-rw-r--r--Lib/test/test_shutil.py13
-rw-r--r--Lib/test/test_signal.py15
-rw-r--r--Lib/test/test_site.py5
-rw-r--r--Lib/test/test_smtplib.py4
-rwxr-xr-xLib/test/test_socket.py38
-rw-r--r--Lib/test/test_ssl.py9
-rw-r--r--Lib/test/test_stat.py10
-rw-r--r--Lib/test/test_statistics.py21
-rw-r--r--Lib/test/test_subprocess.py35
-rw-r--r--Lib/test/test_sundry.py2
-rw-r--r--Lib/test/test_syntax.py7
-rw-r--r--Lib/test/test_sys.py48
-rw-r--r--Lib/test/test_sys_settrace.py271
-rw-r--r--Lib/test/test_sysconfig.py23
-rw-r--r--Lib/test/test_tarfile.py6
-rw-r--r--Lib/test/test_tcl.py58
-rw-r--r--Lib/test/test_telnetlib.py2
-rw-r--r--Lib/test/test_threading.py70
-rw-r--r--Lib/test/test_time.py30
-rw-r--r--Lib/test/test_timeout.py8
-rw-r--r--Lib/test/test_tools/test_i18n.py70
-rw-r--r--Lib/test/test_traceback.py108
-rw-r--r--Lib/test/test_tracemalloc.py20
-rw-r--r--Lib/test/test_types.py24
-rw-r--r--Lib/test/test_typing.py180
-rw-r--r--Lib/test/test_unicode.py2
-rw-r--r--Lib/test/test_unparse.py42
-rw-r--r--Lib/test/test_urllib2net.py2
-rw-r--r--Lib/test/test_utf8_mode.py27
-rwxr-xr-x[-rw-r--r--]Lib/test/test_uuid.py2
-rw-r--r--Lib/test/test_venv.py11
-rw-r--r--Lib/test/test_xml_etree.py35
-rw-r--r--Lib/test/test_xmlrpc.py4
-rw-r--r--Lib/test/test_xxlimited.py79
-rw-r--r--Lib/test/test_zipfile.py6
-rw-r--r--Lib/test/test_zipimport.py130
-rw-r--r--Lib/threading.py22
-rw-r--r--Lib/tkinter/__init__.py88
-rw-r--r--Lib/tkinter/commondialog.py31
-rw-r--r--Lib/tkinter/dnd.py22
-rw-r--r--Lib/tkinter/font.py16
-rw-r--r--Lib/tkinter/simpledialog.py88
-rw-r--r--Lib/tkinter/test/support.py27
-rw-r--r--Lib/tkinter/test/test_tkinter/test_colorchooser.py39
-rw-r--r--Lib/tkinter/test/test_tkinter/test_font.py49
-rw-r--r--Lib/tkinter/test/test_tkinter/test_images.py45
-rw-r--r--Lib/tkinter/test/test_tkinter/test_messagebox.py38
-rw-r--r--Lib/tkinter/test/test_tkinter/test_misc.py82
-rw-r--r--Lib/tkinter/test/test_tkinter/test_simpledialog.py37
-rw-r--r--Lib/tkinter/test/test_tkinter/test_variables.py17
-rw-r--r--Lib/tkinter/test/test_tkinter/test_widgets.py228
-rw-r--r--Lib/tkinter/test/test_ttk/test_extensions.py32
-rw-r--r--Lib/tkinter/test/test_ttk/test_functions.py7
-rw-r--r--Lib/tkinter/test/test_ttk/test_style.py99
-rw-r--r--Lib/tkinter/test/test_ttk/test_widgets.py140
-rw-r--r--Lib/tkinter/test/widget_tests.py122
-rw-r--r--Lib/tkinter/tix.py15
-rw-r--r--Lib/tkinter/ttk.py52
-rw-r--r--Lib/traceback.py55
-rw-r--r--Lib/tracemalloc.py2
-rw-r--r--Lib/typing.py344
-rw-r--r--Lib/unittest/mock.py44
-rw-r--r--Lib/unittest/test/testmock/testmock.py73
-rw-r--r--Lib/urllib/request.py2
-rwxr-xr-xLib/webbrowser.py2
-rw-r--r--Lib/xml/etree/ElementPath.py31
-rw-r--r--Lib/zipfile.py4
-rw-r--r--Lib/zipimport.py76
-rwxr-xr-xMac/BuildScript/build-installer.py89
-rw-r--r--Mac/BuildScript/openssl-mac-arm64.patch41
-rw-r--r--Mac/BuildScript/resources/ReadMe.rtf12
-rwxr-xr-xMac/BuildScript/scripts/postflight.patch-profile18
-rw-r--r--Mac/README.rst37
-rw-r--r--Mac/Tools/pythonw.c12
-rw-r--r--Makefile.pre.in15
-rw-r--r--Misc/ACKS8
-rw-r--r--Misc/NEWS.d/3.10.0a2.rst912
-rw-r--r--Misc/NEWS.d/3.10.0a3.rst1504
-rw-r--r--Misc/NEWS.d/next/Build/2020-02-28-14-33-15.bpo-29076.Gtixi5.rst1
-rw-r--r--Misc/NEWS.d/next/Build/2020-10-21-18-31-54.bpo-38980.xz7BNd.rst3
-rw-r--r--Misc/NEWS.d/next/Build/2020-12-11-18-04-38.bpo-31904.j3j6d8.rst1
-rw-r--r--Misc/NEWS.d/next/Build/2020-12-13-14-43-10.bpo-42598.7ipr5H.rst2
-rw-r--r--Misc/NEWS.d/next/Build/2020-12-20-02-35-28.bpo-42604.gRd89w.rst4
-rw-r--r--Misc/NEWS.d/next/C API/2020-09-14-10-17-00.bpo-41784.Yl4gI2.rst1
-rw-r--r--Misc/NEWS.d/next/C API/2020-09-28-14-31-07.bpo-41756.ZZ5wJG.rst3
-rw-r--r--Misc/NEWS.d/next/C API/2020-10-09-22-50-46.bpo-41986.JUPE59.rst2
-rw-r--r--Misc/NEWS.d/next/C API/2020-10-10-14-05-24.bpo-40422.sh8IDY.rst1
-rw-r--r--Misc/NEWS.d/next/C API/2020-10-11-05-05-53.bpo-41845.ZFvuQM.rst2
-rw-r--r--Misc/NEWS.d/next/C API/2020-10-11-19-17-44.bpo-40423.GsmgEj.rst3
-rw-r--r--Misc/NEWS.d/next/C API/2020-10-12-20-13-58.bpo-42015.X4H2_V.rst3
-rw-r--r--Misc/NEWS.d/next/C API/2020-10-16-10-47-17.bpo-42157.e3BcPM.rst3
-rw-r--r--Misc/NEWS.d/next/C API/2020-10-21-18-43-06.bpo-42111.9pvtrc.rst2
-rw-r--r--Misc/NEWS.d/next/C API/2020-11-22-13-46-06.bpo-1635741.-fJLzA.rst1
-rw-r--r--Misc/NEWS.d/next/C API/2020-12-09-00-35-25.bpo-32381.Je08Ny.rst3
-rw-r--r--Misc/NEWS.d/next/C API/2020-12-10-10-43-03.bpo-42591.CXNY8G.rst3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-05-13-18-50-27.bpo-39465.j7nl6A.rst3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-05-14-02-55-39.bpo-40521.dIlXsZ.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-05-27-16-08-16.bpo-38605.rcs2uK.rst3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-08-07-13-42-48.bpo-41435.qPWjJA.rst1
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-01-22-44-23.bpo-41902.iLoMVF.rst1
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-02-11-35-33.bpo-41894.ffmtOt.rst3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-02-13-32-05.bpo-41902.ZKTxzW.rst3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-08-09-58-19.bpo-41974.8B-q8O.rst4
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-09-10-55-50.bpo-41979.ImXIk2.rst1
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-10-13-53-52.bpo-41993.YMzixQ.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-12-14-51-59.bpo-42008.ijWw2I.rst1
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-14-16-19-43.bpo-41984.SEtKMr.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-15-21-55-32.bpo-42030.PmU2CA.rst3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-20-04-24-07.bpo-42093.ooZZNh.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-21-14-40-54.bpo-41910.CzBMit.rst1
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-23-02-43-24.bpo-42123.64gJWC.rst3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-25-21-14-18.bpo-42150.b70u_T.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-27-18-32-49.bpo-41659.d4a-8o.rst3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-27-21-34-05.bpo-42143.N6KXUO.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-29-12-49-08.bpo-41796.tkGdHq.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-30-13-11-01.bpo-42206.xxssR8.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-30-22-16-30.bpo-42214.lXskM_.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-10-31-17-50-23.bpo-42218.Dp_Z3v.rst3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-11-01-21-21-38.bpo-42236.MPx-NK.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-11-02-14-39-48.bpo-40077.grY9TG.rst1
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-11-20-00-57-47.bpo-42195.HeqcpS.rst10
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-12-04-17-17-44.bpo-32381.NY5t2S.rst3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-12-09-01-55-10.bpo-42639.5pI5HG.rst3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-12-10-17-06-52.bpo-42615.Je6Q-r.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-12-13-15-23-09.bpo-30858.-f9G4z.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-12-15-18-43-43.bpo-32381.3tIofL.rst2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-12-16-14-44-21.bpo-42246.RtIEY7.rst3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-12-22-20-30-11.bpo-42246.7BrPLg.rst1
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-12-25-23-30-58.bpo-42745.XsFoHS.rst1
-rw-r--r--Misc/NEWS.d/next/Documentation/2019-03-04-18-51-21.bpo-34398.YedUqW.rst2
-rw-r--r--Misc/NEWS.d/next/Documentation/2020-01-22-05-14-53.bpo-39416.uYjhEm.rst1
-rw-r--r--Misc/NEWS.d/next/Documentation/2020-02-24-09-02-05.bpo-39693.QXw0Fm.rst1
-rw-r--r--Misc/NEWS.d/next/Documentation/2020-10-10-01-36-37.bpo-41805.l-CGv5.rst3
-rw-r--r--Misc/NEWS.d/next/Documentation/2020-10-21-02-21-14.bpo-42010.76vJ0u.rst4
-rw-r--r--Misc/NEWS.d/next/Documentation/2020-10-28-21-39-45.bpo-42061._x-0sg.rst1
-rw-r--r--Misc/NEWS.d/next/Documentation/2020-12-16-21-06-16.bpo-17140.1leSEg.rst1
-rw-r--r--Misc/NEWS.d/next/IDLE/2020-04-22-09-37-40.bpo-38439.ieXL-c.rst2
-rw-r--r--Misc/NEWS.d/next/IDLE/2020-06-16-12-16-13.bpo-40511.XkihpM.rst3
-rw-r--r--Misc/NEWS.d/next/IDLE/2020-10-24-21-27-37.bpo-33987.fIh9JL.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2019-12-05-05-22-49.bpo-38976.5MG7Uu.rst4
-rw-r--r--Misc/NEWS.d/next/Library/2020-01-19-18-40-26.bpo-27321.8e6SpM.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-04-21-17-18-33.bpo-34204.9wXTtY.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-05-04-12-16-00.bpo-40492.ONk9Na.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-05-14-16-01-34.bpo-40592.Cmk855.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-05-31-10-48-47.bpo-4356.P8kXqp.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-07-08-09-45-00.bpo-16936.z8o8Pn.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-07-13-19-43-11.bpo-40219.MUoJEP.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-07-19-20-10-41.bpo-41229.p8rJa2.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-08-03-17-54-32.bpo-41462.ek38d_.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-08-11-17-44-07.bpo-31904.cb13ea.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-08-19-08-32-13.bpo-41586.IYjmjK.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-09-04-17-33-04.bpo-30681.LR4fnY.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-09-08-23-41-29.bpo-41747.M6wLKv.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-09-11-16-07-00.bpo-24792.Z-ARra.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-09-13-02-02-18.bpo-39337.L3NXTt.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-09-22-11-07-50.bpo-41831.k-Eop_.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-09-29-16-23-54.bpo-41876.QicdDU.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-09-30-11-05-11.bpo-23706.dHTGjF.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-09-30-13-35-29.bpo-41891.pNAeYI.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-01-21-11-03.bpo-41905._JpjR4.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-02-10-19-49.bpo-41907.wiIEsz.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-03-23-14-50.bpo-41923.Buonw9.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-06-23-59-20.bpo-41960.icQ7Xd.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-07-18-36-03.bpo-41943.Pt55fT.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-08-18-22-28.bpo-41976.Svm0wb.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-11-21-43-03.bpo-39101.-I49Pm.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-12-21-21-24.bpo-42021.8yv_8-.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-15-17-20-37.bpo-42043.OS0p_v.rst4
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-16-07-45-35.bpo-35823.SNQo56.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-16-16-08-04.bpo-28660.eX9pvD.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-16-22-48-01.bpo-19270.jd_gkA.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-17-07-52-53.bpo-41966.gwEQRZ.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-17-12-42-08.bpo-42059.ZGMZ3D.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-17-23-17-18.bpo-42065.85BsRA.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-19-14-02-09.bpo-41491.d1BUWH.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-19-16-53-19.bpo-42089.R1dthW.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-20-23-28-55.bpo-1635741.Iyka3r.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-21-23-45-02.bpo-41052.3N7J2J.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-23-08-54-47.bpo-41490.-Yk6OD.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-23-19-20-14.bpo-42103.C5obK2.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-25-14-48-57.bpo-42090.Ubuc0j.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-25-19-25-02.bpo-42146.6A8uvS.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-26-19-08-07.bpo-42157.Bdpa04.rst4
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-26-23-29-16.bpo-42157.4wuwTe.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-31-01-16-49.bpo-26789.9BdNAt.rst4
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-31-13-28-36.bpo-29566.6aDbty.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-11-02-01-31-15.bpo-42233.YxRj-h.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-11-02-14-10-48.bpo-35455.Q1xTIo.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-11-20-19-00-27.bpo-34463.aJcm56.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-11-22-11-22-28.bpo-42388.LMgM6B.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-11-27-18-09-59.bpo-31904.g8k43d.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-06-12-00-00.bpo-42470.iqtC4L.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-07-13-21-00.bpo-28964.UTQikc.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-08-22-43-35.bpo-42678.ba9ktU.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-09-10-59-16.bpo-42517.FKEVcZ.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-09-14-15-48.bpo-34750.x8TASR.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-09-15-23-28.bpo-31904.g3k5k3.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-09-19-45-32.bpo-42385.boGbjo.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-10-00-09-40.bpo-41559.1l4yjP.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-10-09-24-44.bpo-41877.iJSCvM.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-10-18-36-52.bpo-39717.sK2u0w.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-10-19-49-52.bpo-41877.wiVlPc.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-14-08-23-57.bpo-36541.qdEtZv.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-14-22-31-22.bpo-42639.5Z3iWX.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-15-10-00-04.bpo-42644.XgLCNx.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-15-15-14-29.bpo-42639.uJ3h8I.rst3
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-15-17-51-27.bpo-42630.jf4jBl.rst4
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-16-16-16-33.bpo-37961.jrESEq.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-16-23-28-52.bpo-1635741.Quy3zn.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-19-12-33-38.bpo-9694.CkKK9V.rst2
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-19-17-32-43.bpo-42685.kwZlwp.rst4
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-21-22-59-26.bpo-15303.zozVrq.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-21-23-34-57.bpo-35728.9m-azF.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-22-13-16-43.bpo-25246.GhhCTl.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-22-22-47-22.bpo-42721.I5Ai5L.rst9
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-23-15-16-12.bpo-38308.lB4Sv0.rst1
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-23-19-43-06.bpo-42727.WH3ODh.rst2
-rw-r--r--Misc/NEWS.d/next/Security/2020-10-19-10-56-27.bpo-42051.EU_B7u.rst3
-rw-r--r--Misc/NEWS.d/next/Security/2020-10-23-19-19-30.bpo-42103.cILT66.rst2
-rw-r--r--Misc/NEWS.d/next/Tests/2020-07-30-14-08-58.bpo-41439.yhteoi.rst1
-rw-r--r--Misc/NEWS.d/next/Tests/2020-07-30-18-06-15.bpo-31904.y3d8dk.rst1
-rw-r--r--Misc/NEWS.d/next/Tests/2020-07-30-18-43-05.bpo-41443.834gyg.rst1
-rw-r--r--Misc/NEWS.d/next/Tests/2020-08-03-13-44-37.bpo-41306.VDoWXI.rst1
-rw-r--r--Misc/NEWS.d/next/Tests/2020-10-05-17-43-46.bpo-41944.rf1dYb.rst1
-rw-r--r--Misc/NEWS.d/next/Tests/2020-10-08-14-00-17.bpo-41970.aZ8QFf.rst2
-rw-r--r--Misc/NEWS.d/next/Tests/2020-10-12-00-11-47.bpo-41739.wSCc4K.rst2
-rw-r--r--Misc/NEWS.d/next/Tests/2020-10-29-21-26-46.bpo-42199.KksGCV.rst1
-rw-r--r--Misc/NEWS.d/next/Tests/2020-12-09-15-23-28.bpo-31904.ghj38d.rst1
-rw-r--r--Misc/NEWS.d/next/Tests/2020-12-15-17-38-04.bpo-42641.uzwlF_.rst2
-rw-r--r--Misc/NEWS.d/next/Tests/2020-12-17-15-42-44.bpo-31904.d8g3l0d5.rst1
-rw-r--r--Misc/NEWS.d/next/Tools-Demos/2020-12-16-09-10-32.bpo-42613.J-jnm5.rst2
-rw-r--r--Misc/NEWS.d/next/Tools-Demos/2020-12-23-19-42-11.bpo-42726.a5EkTv.rst2
-rw-r--r--Misc/NEWS.d/next/Windows/2020-05-30-02-46-43.bpo-38324.476M-5.rst1
-rw-r--r--Misc/NEWS.d/next/Windows/2020-08-26-09-35-06.bpo-41557.vt00cQ.rst1
-rw-r--r--Misc/NEWS.d/next/Windows/2020-09-24-23-09-40.bpo-39107.GbUZvD.rst1
-rw-r--r--Misc/NEWS.d/next/Windows/2020-10-18-18-43-45.bpo-38252.7Nlepg.rst1
-rw-r--r--Misc/NEWS.d/next/Windows/2020-10-20-13-19-42.bpo-38439.eMLi-t.rst1
-rw-r--r--Misc/NEWS.d/next/macOS/2020-10-19-12-25-19.bpo-41471.gwA7un.rst1
-rw-r--r--Misc/README.AIX5
-rw-r--r--Modules/_asynciomodule.c57
-rw-r--r--Modules/_blake2/blake2b_impl.c2
-rw-r--r--Modules/_blake2/blake2s_impl.c2
-rw-r--r--Modules/_collectionsmodule.c74
-rw-r--r--Modules/_contextvarsmodule.c21
-rw-r--r--Modules/_csv.c544
-rw-r--r--Modules/_ctypes/_ctypes.c326
-rw-r--r--Modules/_ctypes/callbacks.c46
-rw-r--r--Modules/_ctypes/callproc.c133
-rw-r--r--Modules/_ctypes/cfield.c11
-rw-r--r--Modules/_ctypes/ctypes.h12
-rw-r--r--Modules/_ctypes/malloc_closure.c23
-rw-r--r--Modules/_ctypes/stgdict.c2
-rw-r--r--Modules/_curses_panel.c5
-rw-r--r--Modules/_cursesmodule.c2
-rw-r--r--Modules/_datetimemodule.c220
-rw-r--r--Modules/_decimal/_decimal.c2
-rw-r--r--Modules/_functoolsmodule.c10
-rw-r--r--Modules/_hashopenssl.c53
-rw-r--r--Modules/_localemodule.c5
-rw-r--r--Modules/_lsprof.c4
-rw-r--r--Modules/_multiprocessing/posixshmem.c22
-rw-r--r--Modules/_multiprocessing/semaphore.c2
-rw-r--r--Modules/_operator.c2
-rw-r--r--Modules/_pickle.c26
-rw-r--r--Modules/_posixsubprocess.c85
-rw-r--r--Modules/_queuemodule.c211
-rw-r--r--Modules/_randommodule.c107
-rw-r--r--Modules/_sha3/sha3module.c2
-rw-r--r--Modules/_sqlite/cache.c29
-rw-r--r--Modules/_sqlite/clinic/connection.c.h722
-rw-r--r--Modules/_sqlite/connection.c532
-rw-r--r--Modules/_sqlite/connection.h4
-rw-r--r--Modules/_sqlite/cursor.c33
-rw-r--r--Modules/_sqlite/microprotocols.c11
-rw-r--r--Modules/_sqlite/module.c45
-rw-r--r--Modules/_sqlite/row.c24
-rw-r--r--Modules/_sqlite/statement.c15
-rw-r--r--Modules/_sre.c487
-rw-r--r--Modules/_ssl.c699
-rw-r--r--Modules/_struct.c504
-rw-r--r--Modules/_testbuffer.c4
-rw-r--r--Modules/_testcapimodule.c159
-rw-r--r--Modules/_testinternalcapi.c55
-rw-r--r--Modules/_testmultiphase.c8
-rw-r--r--Modules/_threadmodule.c712
-rw-r--r--Modules/_tkinter.c68
-rw-r--r--Modules/_zoneinfo.c14
-rw-r--r--Modules/arraymodule.c4
-rw-r--r--Modules/atexitmodule.c312
-rw-r--r--Modules/cjkcodecs/multibytecodec.c6
-rw-r--r--Modules/clinic/_queuemodule.c.h58
-rw-r--r--Modules/clinic/_sre.c.h378
-rw-r--r--Modules/clinic/_ssl.c.h16
-rw-r--r--Modules/clinic/_struct.c.h10
-rw-r--r--Modules/clinic/_testmultiphase.c.h7
-rw-r--r--Modules/clinic/itertoolsmodule.c.h33
-rw-r--r--Modules/clinic/posixmodule.c.h246
-rw-r--r--Modules/clinic/selectmodule.c.h6
-rw-r--r--Modules/gcmodule.c90
-rw-r--r--Modules/getpath.c4
-rw-r--r--Modules/grpmodule.c71
-rw-r--r--Modules/itertoolsmodule.c163
-rw-r--r--Modules/main.c143
-rwxr-xr-xModules/makexp_aix44
-rw-r--r--Modules/md5module.c2
-rw-r--r--Modules/mmapmodule.c8
-rw-r--r--Modules/ossaudiodev.c4
-rw-r--r--Modules/overlapped.c2
-rw-r--r--Modules/posixmodule.c1039
-rw-r--r--Modules/pwdmodule.c65
-rw-r--r--Modules/pyexpat.c488
-rw-r--r--Modules/resource.c56
-rw-r--r--Modules/selectmodule.c209
-rw-r--r--Modules/sha1module.c2
-rw-r--r--Modules/sha256module.c2
-rw-r--r--Modules/sha512module.c2
-rw-r--r--Modules/signalmodule.c474
-rw-r--r--Modules/socketmodule.c23
-rw-r--r--Modules/spwdmodule.c84
-rw-r--r--Modules/sre_lib.h4
-rw-r--r--Modules/symtablemodule.c94
-rw-r--r--Modules/timemodule.c293
-rw-r--r--Modules/unicodedata.c2
-rw-r--r--Modules/xxlimited.c379
-rw-r--r--Modules/xxlimited_35.c301
-rw-r--r--Modules/xxmodule.c2
-rw-r--r--Modules/zlibmodule.c2
-rw-r--r--Objects/abstract.c26
-rw-r--r--Objects/bytearrayobject.c39
-rw-r--r--Objects/bytesobject.c63
-rw-r--r--Objects/capsule.c6
-rw-r--r--Objects/clinic/bytearrayobject.c.h4
-rw-r--r--Objects/clinic/bytesobject.c.h4
-rw-r--r--Objects/clinic/codeobject.c.h26
-rw-r--r--Objects/codeobject.c406
-rw-r--r--Objects/complexobject.c2
-rw-r--r--Objects/dictobject.c20
-rw-r--r--Objects/enumobject.c11
-rw-r--r--Objects/exceptions.c4
-rw-r--r--Objects/floatobject.c4
-rw-r--r--Objects/frameobject.c36
-rw-r--r--Objects/funcobject.c19
-rw-r--r--Objects/genericaliasobject.c148
-rw-r--r--Objects/genobject.c57
-rw-r--r--Objects/listobject.c24
-rw-r--r--Objects/lnotab_notes.txt108
-rw-r--r--Objects/longobject.c2
-rw-r--r--Objects/moduleobject.c6
-rw-r--r--Objects/object.c29
-rw-r--r--Objects/odictobject.c17
-rw-r--r--Objects/rangeobject.c4
-rw-r--r--Objects/setobject.c6
-rw-r--r--Objects/stringlib/join.h2
-rw-r--r--Objects/stringlib/unicode_format.h4
-rw-r--r--Objects/structseq.c15
-rw-r--r--Objects/typeobject.c356
-rw-r--r--Objects/typeslots.inc161
-rwxr-xr-xObjects/typeslots.py24
-rw-r--r--Objects/unicodeobject.c246
-rw-r--r--Objects/unionobject.c22
-rw-r--r--PC/_msi.c2
-rw-r--r--PC/launcher.c21
-rw-r--r--PC/layout/main.py2
-rw-r--r--PC/pyconfig.h1
-rw-r--r--PC/python3dll.c16
-rw-r--r--PC/winreg.c6
-rw-r--r--PCbuild/build.bat4
-rw-r--r--PCbuild/env.bat21
-rw-r--r--PCbuild/env.ps12
-rw-r--r--PCbuild/idle.bat18
-rw-r--r--PCbuild/lib.pyproj1
-rw-r--r--PCbuild/pcbuild.proj1
-rw-r--r--PCbuild/prepare_libffi.bat13
-rw-r--r--PCbuild/pyproject.props4
-rw-r--r--PCbuild/pythoncore.vcxproj3
-rw-r--r--PCbuild/pythoncore.vcxproj.filters9
-rw-r--r--PCbuild/readme.txt3
-rw-r--r--PCbuild/rt.bat18
-rw-r--r--PCbuild/xxlimited.vcxproj4
-rw-r--r--PCbuild/xxlimited_35.vcxproj114
-rw-r--r--PCbuild/xxlimited_35.vcxproj.filters13
-rwxr-xr-xParser/asdl_c.py75
-rw-r--r--Parser/parser.c2291
-rw-r--r--Parser/string_parser.c5
-rw-r--r--Parser/tokenizer.c60
-rw-r--r--Programs/_testembed.c50
-rw-r--r--Python/Python-ast.c364
-rw-r--r--Python/_warnings.c111
-rw-r--r--Python/ast_opt.c54
-rw-r--r--Python/bltinmodule.c7
-rw-r--r--Python/bootstrap_hash.c42
-rw-r--r--Python/ceval.c147
-rw-r--r--Python/compile.c947
-rw-r--r--Python/context.c6
-rw-r--r--Python/errors.c21
-rw-r--r--Python/fileutils.c49
-rw-r--r--Python/getargs.c4
-rw-r--r--Python/import.c218
-rw-r--r--Python/importdl.c5
-rw-r--r--Python/importlib.h3509
-rw-r--r--Python/importlib_external.h5125
-rw-r--r--Python/importlib_zipimport.h1905
-rw-r--r--Python/initconfig.c455
-rw-r--r--Python/marshal.c30
-rw-r--r--Python/modsupport.c70
-rw-r--r--Python/opcode_targets.h4
-rw-r--r--Python/pathconfig.c89
-rw-r--r--Python/pylifecycle.c381
-rw-r--r--Python/pystate.c62
-rw-r--r--Python/pystrtod.c4
-rw-r--r--Python/pythonrun.c430
-rw-r--r--Python/pytime.c281
-rw-r--r--Python/symtable.c2
-rw-r--r--Python/sysmodule.c152
-rw-r--r--Python/thread_pthread.h4
-rw-r--r--Python/traceback.c7
-rw-r--r--README.rst2
-rw-r--r--Tools/c-analyzer/c_analyzer/__main__.py27
-rw-r--r--Tools/c-analyzer/c_analyzer/datafiles.py71
-rw-r--r--Tools/c-analyzer/c_analyzer/info.py13
-rw-r--r--Tools/c-analyzer/c_common/fsutil.py120
-rw-r--r--Tools/c-analyzer/c_common/scriptutil.py58
-rw-r--r--Tools/c-analyzer/c_common/tables.py189
-rw-r--r--Tools/c-analyzer/c_parser/__main__.py13
-rw-r--r--Tools/c-analyzer/c_parser/datafiles.py35
-rw-r--r--Tools/c-analyzer/c_parser/info.py44
-rw-r--r--Tools/c-analyzer/c_parser/preprocessor/__main__.py5
-rw-r--r--Tools/c-analyzer/check-c-globals.py1
-rw-r--r--Tools/c-analyzer/cpython/__main__.py137
-rw-r--r--Tools/c-analyzer/cpython/_analyzer.py4
-rw-r--r--Tools/c-analyzer/cpython/_capi.py665
-rw-r--r--Tools/c-analyzer/cpython/_files.py69
-rw-r--r--Tools/c-analyzer/cpython/_parser.py42
-rw-r--r--Tools/c-analyzer/cpython/ignored.tsv2936
-rwxr-xr-xTools/c-analyzer/must-resolve.sh75
-rwxr-xr-xTools/clinic/clinic.py54
-rwxr-xr-xTools/freeze/freeze.py20
-rwxr-xr-xTools/gdb/libpython.py19
-rwxr-xr-xTools/i18n/pygettext.py53
-rw-r--r--Tools/msi/purge.py2
-rw-r--r--Tools/msi/sdktools.psm16
-rw-r--r--Tools/msi/test/test_files.wxs4
-rwxr-xr-xTools/peg_generator/pegen/__main__.py3
-rw-r--r--Tools/peg_generator/pegen/validator.py52
-rw-r--r--Tools/pynche/PyncheWidget.py12
-rwxr-xr-xTools/scripts/smelly.py154
-rwxr-xr-xTools/scripts/stable_abi.py258
-rw-r--r--aclocal.m480
-rwxr-xr-xconfigure157
-rw-r--r--configure.ac99
-rw-r--r--pyconfig.h.in14
-rw-r--r--setup.py152
811 files changed, 37295 insertions, 19364 deletions
diff --git a/.azure-pipelines/ci.yml b/.azure-pipelines/ci.yml
index 531ed060fd..3feb85ae65 100644
--- a/.azure-pipelines/ci.yml
+++ b/.azure-pipelines/ci.yml
@@ -104,7 +104,7 @@ jobs:
matrix:
win32:
arch: win32
- buildOpt:
+ buildOpt: '-p Win32'
testRunTitle: '$(Build.SourceBranchName)-win32'
testRunPlatform: win32
win64:
diff --git a/.azure-pipelines/docs-steps.yml b/.azure-pipelines/docs-steps.yml
index eaf4ad0192..8e72baf2b1 100644
--- a/.azure-pipelines/docs-steps.yml
+++ b/.azure-pipelines/docs-steps.yml
@@ -12,11 +12,11 @@ steps:
inputs:
versionSpec: '>=3.6'
-- script: python -m pip install sphinx==2.2.0 blurb python-docs-theme
+- script: python -m pip install sphinx==3.2.1 blurb python-docs-theme
displayName: 'Install build dependencies'
- ${{ if ne(parameters.latex, 'true') }}:
- - script: make check suspicious html PYTHON=python
+ - script: make check html PYTHON=python
workingDirectory: '$(build.sourcesDirectory)/Doc'
displayName: 'Build documentation'
@@ -31,7 +31,7 @@ steps:
- ${{ if eq(parameters.upload, 'true') }}:
- task: PublishBuildArtifacts@1
displayName: 'Publish docs'
-
+
inputs:
PathToPublish: '$(build.sourcesDirectory)/Doc/build'
ArtifactName: docs
diff --git a/.azure-pipelines/pr.yml b/.azure-pipelines/pr.yml
index 1ffe0a97a2..2e94af3560 100644
--- a/.azure-pipelines/pr.yml
+++ b/.azure-pipelines/pr.yml
@@ -104,7 +104,7 @@ jobs:
matrix:
win32:
arch: win32
- buildOpt:
+ buildOpt: '-p Win32'
testRunTitle: '$(System.PullRequest.TargetBranch)-win32'
testRunPlatform: win32
win64:
diff --git a/.azure-pipelines/windows-release/stage-pack-msix.yml b/.azure-pipelines/windows-release/stage-pack-msix.yml
index 26a5712e84..f967cfdbe3 100644
--- a/.azure-pipelines/windows-release/stage-pack-msix.yml
+++ b/.azure-pipelines/windows-release/stage-pack-msix.yml
@@ -120,10 +120,11 @@ jobs:
artifactName: unsigned_msix
downloadPath: $(Build.BinariesDirectory)
+ # MSIX must be signed and timestamped simultaneously
- powershell: |
$failed = $true
foreach ($retry in 1..3) {
- signtool sign /a /n "$(SigningCertificate)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "$(SigningDescription)" (gi *.msix)
+ signtool sign /a /n "$(SigningCertificate)" /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d "$(SigningDescription)" (gi *.msix)
if ($?) {
$failed = $false
break
diff --git a/.azure-pipelines/windows-release/stage-pack-nuget.yml b/.azure-pipelines/windows-release/stage-pack-nuget.yml
index b100364820..8dfea382c3 100644
--- a/.azure-pipelines/windows-release/stage-pack-nuget.yml
+++ b/.azure-pipelines/windows-release/stage-pack-nuget.yml
@@ -4,7 +4,7 @@ jobs:
condition: and(succeeded(), eq(variables['DoNuget'], 'true'))
pool:
- vmImage: windows-2019
+ name: 'Windows Release'
workspace:
clean: all
@@ -36,6 +36,14 @@ jobs:
nuget pack "$(Build.BinariesDirectory)\layout\python.nuspec" -OutputDirectory $(Build.ArtifactStagingDirectory) -NoPackageAnalysis -NonInteractive
displayName: 'Create nuget package'
+ - powershell: |
+ gci *.nupkg | %{
+ nuget sign "$_" -CertificateSubjectName "$(SigningCertificate)" -Timestamper http://timestamp.digicert.com/ -Overwrite
+ }
+ displayName: 'Sign nuget package'
+ workingDirectory: $(Build.ArtifactStagingDirectory)
+ condition: and(succeeded(), variables['SigningCertificate'])
+
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: nuget'
inputs:
diff --git a/.azure-pipelines/windows-release/stage-sign.yml b/.azure-pipelines/windows-release/stage-sign.yml
index 584772af8b..c21e1c9f2b 100644
--- a/.azure-pipelines/windows-release/stage-sign.yml
+++ b/.azure-pipelines/windows-release/stage-sign.yml
@@ -57,7 +57,7 @@ jobs:
$files = (gi ${{ parameters.Include }} -Exclude ${{ parameters.Exclude }})
$failed = $true
foreach ($retry in 1..10) {
- signtool timestamp /t http://timestamp.verisign.com/scripts/timestamp.dll $files
+ signtool timestamp /tr http://timestamp.digicert.com/ /td sha256 $files
if ($?) {
$failed = $false
break
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 8c76f54af5..19ac3aac71 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -19,6 +19,7 @@ Objects/frameobject.c @markshannon
Objects/call.c @markshannon
Python/ceval.c @markshannon
Python/compile.c @markshannon
+Python/ast_opt.c @isidentical
# Hashing
**/*hashlib* @python/crypto-team @tiran
@@ -84,6 +85,12 @@ Include/pytime.h @pganssle @abalkin
/Lib/test/test_peg_generator/ @pablogsal @lysnikolaou
/Grammar/python.gram @pablogsal @lysnikolaou
+# AST
+Python/ast.c @isidentical
+Parser/asdl.py @isidentical
+Parser/asdl_c.py @isidentical
+Lib/ast.py @isidentical
+
# SQLite 3
**/*sqlite* @berkerpeksag
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index e90677b9f7..d9cbb3c7ec 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -7,3 +7,7 @@ updates:
labels:
- "skip issue"
- "skip news"
+ target_branch:
+ - "master"
+ - "3.9"
+ - "3.8"
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d00c227182..71c307b6c6 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -47,6 +47,37 @@ jobs:
# https://github.com/python/core-workflow/issues/373
git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc)' && echo '::set-output name=run_tests::true' || true
fi
+
+ check_generated_files:
+ name: 'Check if generated files are up to date'
+ runs-on: ubuntu-latest
+ needs: check_source
+ if: needs.check_source.outputs.run_tests == 'true'
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-python@v2
+ - name: Install Dependencies
+ run: sudo ./.github/workflows/posix-deps-apt.sh
+ - name: Build CPython
+ run: |
+ # Build Python with the libpython dynamic library
+ ./configure --with-pydebug --enable-shared
+ make -j4 regen-all
+ - name: Check for changes
+ run: |
+ changes=$(git status --porcelain)
+ # Check for changes in regenerated files
+ if ! test -z "$changes"
+ then
+ echo "Generated files not up to date. Perhaps you forgot to run make regen-all ;)"
+ echo "$changes"
+ exit 1
+ fi
+ - name: Check exported libpython symbols
+ run: make smelly
+ - name: Check limited ABI symbols
+ run: make check-limited-abi
+
build_win32:
name: 'Windows (x86)'
runs-on: windows-latest
@@ -59,7 +90,7 @@ jobs:
- name: Display build info
run: .\python.bat -m test.pythoninfo
- name: Tests
- run: .\PCbuild\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
+ run: .\PCbuild\rt.bat -p Win32 -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
build_win_amd64:
name: 'Windows (x64)'
@@ -73,7 +104,7 @@ jobs:
- name: Display build info
run: .\python.bat -m test.pythoninfo
- name: Tests
- run: .\PCbuild\rt.bat -x64 -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
+ run: .\PCbuild\rt.bat -p x64 -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
build_macos:
name: 'macOS'
@@ -106,7 +137,7 @@ jobs:
run: sudo ./.github/workflows/posix-deps-apt.sh
- name: 'Restore OpenSSL build'
id: cache-openssl
- uses: actions/cache@v2.1.2
+ uses: actions/cache@v2.1.3
with:
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index ed71a01239..11748f0e44 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -32,7 +32,7 @@ jobs:
run: sudo ./.github/workflows/posix-deps-apt.sh
- name: 'Restore OpenSSL build'
id: cache-openssl
- uses: actions/cache@v2.1.2
+ uses: actions/cache@v2.1.3
with:
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml
index 7c6012eed4..82e9645b5b 100644
--- a/.github/workflows/doc.yml
+++ b/.github/workflows/doc.yml
@@ -36,9 +36,9 @@ jobs:
- name: 'Install build dependencies'
run: make -C Doc/ PYTHON=../python venv
- name: 'Build documentation'
- run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" doctest suspicious html
+ run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" doctest html
- name: 'Upload'
- uses: actions/upload-artifact@v2.2.0
+ uses: actions/upload-artifact@v2.2.1
with:
name: doc-html
path: Doc/build/html
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
new file mode 100644
index 0000000000..58c9a4f21c
--- /dev/null
+++ b/.github/workflows/stale.yml
@@ -0,0 +1,19 @@
+name: Mark stale pull requests
+
+on:
+ schedule:
+ - cron: "0 0 * * *"
+
+jobs:
+ stale:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/stale@v3
+ with:
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
+ stale-pr-message: 'This PR is stale because it has been open for 30 days with no activity.'
+ stale-pr-label: 'stale'
+ days-before-stale: 30
+ days-before-close: -1
diff --git a/.travis.yml b/.travis.yml
index 254a4ea35a..547d919974 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -53,7 +53,7 @@ matrix:
- cd Doc
- make venv PYTHON=python
script:
- - make check suspicious html SPHINXOPTS="-q -W -j4"
+ - make check html SPHINXOPTS="-q -W -j4"
- name: "Documentation tests"
os: linux
language: c
@@ -192,6 +192,8 @@ script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./python Tools/scripts/patchcheck.py --travis $TRAVIS_PULL_REQUEST; fi
# Check that all symbols exported by libpython start with "Py" or "_Py"
- make smelly
+ # Check that all symbols in the limited abi are present
+ - make check-limited-abi
# `-r -w` implicitly provided through `make buildbottest`.
- |
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
diff --git a/Doc/Makefile b/Doc/Makefile
index f653d70674..f113dd0653 100644
--- a/Doc/Makefile
+++ b/Doc/Makefile
@@ -202,6 +202,7 @@ dist:
check:
$(PYTHON) tools/rstlint.py -i tools -i $(VENVDIR) -i README.rst
+ $(PYTHON) tools/rstlint.py ../Misc/NEWS.d/next/
serve:
$(PYTHON) ../Tools/scripts/serve.py build/html
@@ -215,12 +216,11 @@ serve:
# for development releases: always build
autobuild-dev:
- make dist SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1 -A switchers=1'
- -make suspicious
+ make dist SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1'
# for quick rebuilds (HTML only)
autobuild-dev-html:
- make html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1 -A switchers=1'
+ make html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1'
# for stable releases: only build if not in pre-release stage (alpha, beta)
# release candidate downloads are okay, since the stable tree can be in that stage
diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst
index bdaae44e24..a91b3c7c95 100644
--- a/Doc/c-api/arg.rst
+++ b/Doc/c-api/arg.rst
@@ -482,7 +482,8 @@ API Functions
*min* and no more than *max*; *min* and *max* may be equal. Additional
arguments must be passed to the function, each of which should be a pointer to a
:c:type:`PyObject*` variable; these will be filled in with the values from
- *args*; they will contain borrowed references. The variables which correspond
+ *args*; they will contain :term:`borrowed references <borrowed reference>`.
+ The variables which correspond
to optional parameters not given by *args* will not be filled in; these should
be initialized by the caller. This function returns true on success and false if
*args* is not a tuple or contains the wrong number of elements; an exception
diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst
index 3ce689203a..5736b83f21 100644
--- a/Doc/c-api/init.rst
+++ b/Doc/c-api/init.rst
@@ -376,6 +376,12 @@ Process-wide parameters
The returned string points into static storage; the caller should not modify its
value.
+ This function should not be called before :c:func:`Py_Initialize`, otherwise
+ it returns ``NULL``.
+
+ .. versionchanged:: 3.10
+ It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
+
.. c:function:: wchar_t* Py_GetPrefix()
@@ -389,6 +395,12 @@ Process-wide parameters
script at build time. The value is available to Python code as ``sys.prefix``.
It is only useful on Unix. See also the next function.
+ This function should not be called before :c:func:`Py_Initialize`, otherwise
+ it returns ``NULL``.
+
+ .. versionchanged:: 3.10
+ It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
+
.. c:function:: wchar_t* Py_GetExecPrefix()
@@ -424,6 +436,12 @@ Process-wide parameters
while having :file:`/usr/local/plat` be a different filesystem for each
platform.
+ This function should not be called before :c:func:`Py_Initialize`, otherwise
+ it returns ``NULL``.
+
+ .. versionchanged:: 3.10
+ It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
+
.. c:function:: wchar_t* Py_GetProgramFullPath()
@@ -437,6 +455,12 @@ Process-wide parameters
static storage; the caller should not modify its value. The value is available
to Python code as ``sys.executable``.
+ This function should not be called before :c:func:`Py_Initialize`, otherwise
+ it returns ``NULL``.
+
+ .. versionchanged:: 3.10
+ It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
+
.. c:function:: wchar_t* Py_GetPath()
@@ -455,8 +479,14 @@ Process-wide parameters
can be (and usually is) modified later to change the search path for loading
modules.
+ This function should not be called before :c:func:`Py_Initialize`, otherwise
+ it returns ``NULL``.
+
.. XXX should give the exact rules
+ .. versionchanged:: 3.10
+ It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
+
.. c:function:: void Py_SetPath(const wchar_t *)
@@ -638,6 +668,12 @@ Process-wide parameters
:c:func:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME`
environment variable if it is set.
+ This function should not be called before :c:func:`Py_Initialize`, otherwise
+ it returns ``NULL``.
+
+ .. versionchanged:: 3.10
+ It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
+
.. _threads:
@@ -1077,7 +1113,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
Get the current frame of the Python thread state *tstate*.
- Return a strong reference. Return ``NULL`` if no frame is currently
+ Return a :term:`strong reference`. Return ``NULL`` if no frame is currently
executing.
See also :c:func:`PyEval_GetFrame`.
diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst
index dad1f90bea..db7c1f4376 100644
--- a/Doc/c-api/init_config.rst
+++ b/Doc/c-api/init_config.rst
@@ -8,46 +8,24 @@ Python Initialization Configuration
.. versionadded:: 3.8
-Structures:
-
-* :c:type:`PyConfig`
-* :c:type:`PyPreConfig`
-* :c:type:`PyStatus`
-* :c:type:`PyWideStringList`
-
-Functions:
-
-* :c:func:`PyConfig_Clear`
-* :c:func:`PyConfig_InitIsolatedConfig`
-* :c:func:`PyConfig_InitPythonConfig`
-* :c:func:`PyConfig_Read`
-* :c:func:`PyConfig_SetArgv`
-* :c:func:`PyConfig_SetBytesArgv`
-* :c:func:`PyConfig_SetBytesString`
-* :c:func:`PyConfig_SetString`
-* :c:func:`PyConfig_SetWideStringList`
-* :c:func:`PyPreConfig_InitIsolatedConfig`
-* :c:func:`PyPreConfig_InitPythonConfig`
-* :c:func:`PyStatus_Error`
-* :c:func:`PyStatus_Exception`
-* :c:func:`PyStatus_Exit`
-* :c:func:`PyStatus_IsError`
-* :c:func:`PyStatus_IsExit`
-* :c:func:`PyStatus_NoMemory`
-* :c:func:`PyStatus_Ok`
-* :c:func:`PyWideStringList_Append`
-* :c:func:`PyWideStringList_Insert`
-* :c:func:`Py_ExitStatusException`
-* :c:func:`Py_InitializeFromConfig`
-* :c:func:`Py_PreInitialize`
-* :c:func:`Py_PreInitializeFromArgs`
-* :c:func:`Py_PreInitializeFromBytesArgs`
-* :c:func:`Py_RunMain`
-* :c:func:`Py_GetArgcArgv`
-
-The preconfiguration (``PyPreConfig`` type) is stored in
-``_PyRuntime.preconfig`` and the configuration (``PyConfig`` type) is stored in
-``PyInterpreterState.config``.
+Python can be initialized with :c:func:`Py_InitializeFromConfig` and the
+:c:type:`PyConfig` structure. It can be preinitialized with
+:c:func:`Py_PreInitialize` and the :c:type:`PyPreConfig` structure.
+
+There are two kinds of configuration:
+
+* The :ref:`Python Configuration <init-python-config>` can be used to build a
+ customized Python which behaves as the regular Python. For example,
+ environments variables and command line arguments are used to configure
+ Python.
+
+* The :ref:`Isolated Configuration <init-isolated-conf>` can be used to embed
+ Python into an application. It isolates Python from the system. For example,
+ environments variables are ignored, the LC_CTYPE locale is left unchanged and
+ no signal handler is registred.
+
+The :c:func:`Py_RunMain` function can be used to write a customized Python
+program.
See also :ref:`Initialization, Finalization, and Threads <initialization>`.
@@ -55,8 +33,47 @@ See also :ref:`Initialization, Finalization, and Threads <initialization>`.
:pep:`587` "Python Initialization Configuration".
+Example
+=======
+
+Example of customized Python always running in isolated mode::
+
+ int main(int argc, char **argv)
+ {
+ PyStatus status;
+
+ PyConfig config;
+ PyConfig_InitPythonConfig(&config);
+ config.isolated = 1;
+
+ /* Decode command line arguments.
+ Implicitly preinitialize Python (in isolated mode). */
+ status = PyConfig_SetBytesArgv(&config, argc, argv);
+ if (PyStatus_Exception(status)) {
+ goto exception;
+ }
+
+ status = Py_InitializeFromConfig(&config);
+ if (PyStatus_Exception(status)) {
+ goto exception;
+ }
+ PyConfig_Clear(&config);
+
+ return Py_RunMain();
+
+ exception:
+ PyConfig_Clear(&config);
+ if (PyStatus_IsExit(status)) {
+ return status.exitcode;
+ }
+ /* Display the error message and exit the process with
+ non-zero exit code */
+ Py_ExitStatusException(status);
+ }
+
+
PyWideStringList
-----------------
+================
.. c:type:: PyWideStringList
@@ -95,7 +112,7 @@ PyWideStringList
List items.
PyStatus
---------
+========
.. c:type:: PyStatus
@@ -128,6 +145,8 @@ PyStatus
Initialization error with a message.
+ *err_msg* must not be ``NULL``.
+
.. c:function:: PyStatus PyStatus_NoMemory(void)
Memory allocation failure (out of memory).
@@ -185,7 +204,7 @@ Example::
PyPreConfig
------------
+===========
.. c:type:: PyPreConfig
@@ -315,7 +334,7 @@ PyPreConfig
.. _c-preinit:
Preinitialize Python with PyPreConfig
--------------------------------------
+=====================================
The preinitialization of Python:
@@ -324,12 +343,17 @@ The preinitialization of Python:
* Set the :ref:`Python UTF-8 Mode <utf8-mode>`
(:c:member:`PyPreConfig.utf8_mode`)
+The current preconfiguration (``PyPreConfig`` type) is stored in
+``_PyRuntime.preconfig``.
+
Functions to preinitialize Python:
.. c:function:: PyStatus Py_PreInitialize(const PyPreConfig *preconfig)
Preinitialize Python from *preconfig* preconfiguration.
+ *preconfig* must not be ``NULL``.
+
.. c:function:: PyStatus Py_PreInitializeFromBytesArgs(const PyPreConfig *preconfig, int argc, char * const *argv)
Preinitialize Python from *preconfig* preconfiguration.
@@ -337,6 +361,8 @@ Functions to preinitialize Python:
Parse *argv* command line arguments (bytes strings) if
:c:member:`~PyPreConfig.parse_argv` of *preconfig* is non-zero.
+ *preconfig* must not be ``NULL``.
+
.. c:function:: PyStatus Py_PreInitializeFromArgs(const PyPreConfig *preconfig, int argc, wchar_t * const * argv)
Preinitialize Python from *preconfig* preconfiguration.
@@ -344,6 +370,8 @@ Functions to preinitialize Python:
Parse *argv* command line arguments (wide strings) if
:c:member:`~PyPreConfig.parse_argv` of *preconfig* is non-zero.
+ *preconfig* must not be ``NULL``.
+
The caller is responsible to handle exceptions (error or exit) using
:c:func:`PyStatus_Exception` and :c:func:`Py_ExitStatusException`.
@@ -386,7 +414,7 @@ the :ref:`Python UTF-8 Mode <utf8-mode>`::
PyConfig
---------
+========
.. c:type:: PyConfig
@@ -447,8 +475,20 @@ PyConfig
Fields which are already initialized are left unchanged.
+ The :c:func:`PyConfig_Read` function only parses
+ :c:member:`PyConfig.argv` arguments once: :c:member:`PyConfig.parse_argv`
+ is set to ``2`` after arguments are parsed. Since Python arguments are
+ strippped from :c:member:`PyConfig.argv`, parsing arguments twice would
+ parse the application options as Python options.
+
:ref:`Preinitialize Python <c-preinit>` if needed.
+ .. versionchanged:: 3.10
+ The :c:member:`PyConfig.argv` arguments are now only parsed once,
+ :c:member:`PyConfig.parse_argv` is set to ``2`` after arguments are
+ parsed, and arguments are only parsed if
+ :c:member:`PyConfig.parse_argv` equals ``1``.
+
.. c:function:: void PyConfig_Clear(PyConfig *config)
Release configuration memory.
@@ -496,7 +536,7 @@ PyConfig
Default: ``NULL``.
- Part of the :ref:`Path Configuration <init-path-config>` output.
+ Part of the :ref:`Python Path Configuration <init-path-config>` output.
.. c:member:: wchar_t* base_executable
@@ -508,7 +548,7 @@ PyConfig
Default: ``NULL``.
- Part of the :ref:`Path Configuration <init-path-config>` output.
+ Part of the :ref:`Python Path Configuration <init-path-config>` output.
.. c:member:: wchar_t* base_prefix
@@ -516,7 +556,7 @@ PyConfig
Default: ``NULL``.
- Part of the :ref:`Path Configuration <init-path-config>` output.
+ Part of the :ref:`Python Path Configuration <init-path-config>` output.
.. c:member:: int buffered_stdio
@@ -598,7 +638,7 @@ PyConfig
Default: ``NULL``.
- Part of the :ref:`Path Configuration <init-path-config>` output.
+ Part of the :ref:`Python Path Configuration <init-path-config>` output.
.. c:member:: wchar_t* executable
@@ -607,7 +647,7 @@ PyConfig
Default: ``NULL``.
- Part of the :ref:`Path Configuration <init-path-config>` output.
+ Part of the :ref:`Python Path Configuration <init-path-config>` output.
.. c:member:: int faulthandler
@@ -690,7 +730,7 @@ PyConfig
Default: ``NULL``.
- Part of the :ref:`Path Configuration <init-path-config>` input.
+ Part of the :ref:`Python Path Configuration <init-path-config>` input.
.. c:member:: int import_time
@@ -781,7 +821,7 @@ PyConfig
Default: value of the ``PLATLIBDIR`` macro which is set at configure time
by ``--with-platlibdir`` (default: ``"lib"``).
- Part of the :ref:`Path Configuration <init-path-config>` input.
+ Part of the :ref:`Python Path Configuration <init-path-config>` input.
.. versionadded:: 3.9
@@ -794,7 +834,7 @@ PyConfig
Default: ``NULL``.
- Part of the :ref:`Path Configuration <init-path-config>` input.
+ Part of the :ref:`Python Path Configuration <init-path-config>` input.
.. c:member:: PyWideStringList module_search_paths
.. c:member:: int module_search_paths_set
@@ -802,14 +842,14 @@ PyConfig
Module search paths: :data:`sys.path`.
If :c:member:`~PyConfig.module_search_paths_set` is equal to 0, the
- function calculating the :ref:`Path Configuration <init-path-config>`
+ function calculating the :ref:`Python Path Configuration <init-path-config>`
overrides the :c:member:`~PyConfig.module_search_paths` and sets
:c:member:`~PyConfig.module_search_paths_set` to ``1``.
Default: empty list (``module_search_paths``) and ``0``
(``module_search_paths_set``).
- Part of the :ref:`Path Configuration <init-path-config>` output.
+ Part of the :ref:`Python Path Configuration <init-path-config>` output.
.. c:member:: int optimization_level
@@ -831,7 +871,7 @@ PyConfig
If :c:member:`~PyConfig.orig_argv` list is empty and
:c:member:`~PyConfig.argv` is not a list only containing an empty
- string, :c:func:`PyConfig_Read()` copies :c:member:`~PyConfig.argv` into
+ string, :c:func:`PyConfig_Read` copies :c:member:`~PyConfig.argv` into
:c:member:`~PyConfig.orig_argv` before modifying
:c:member:`~PyConfig.argv` (if :c:member:`~PyConfig.parse_argv` is
non-zero).
@@ -847,12 +887,22 @@ PyConfig
Parse command line arguments?
- If non-zero, parse :c:member:`~PyConfig.argv` the same way the regular
+ If equals to ``1``, parse :c:member:`~PyConfig.argv` the same way the regular
Python parses :ref:`command line arguments <using-on-cmdline>`, and strip
Python arguments from :c:member:`~PyConfig.argv`.
+ The :c:func:`PyConfig_Read` function only parses
+ :c:member:`PyConfig.argv` arguments once: :c:member:`PyConfig.parse_argv`
+ is set to ``2`` after arguments are parsed. Since Python arguments are
+ strippped from :c:member:`PyConfig.argv`, parsing arguments twice would
+ parse the application options as Python options.
+
Default: ``1`` in Python mode, ``0`` in isolated mode.
+ .. versionchanged:: 3.10
+ The :c:member:`PyConfig.argv` arguments are now only parsed if
+ :c:member:`PyConfig.parse_argv` equals to ``1``.
+
.. c:member:: int parser_debug
Parser debug mode. If greater than 0, turn on parser debugging output (for expert only, depending
@@ -865,7 +915,7 @@ PyConfig
.. c:member:: int pathconfig_warnings
- On Unix, if non-zero, calculating the :ref:`Path Configuration
+ On Unix, if non-zero, calculating the :ref:`Python Path Configuration
<init-path-config>` can log warnings into ``stderr``. If equals to 0,
suppress these warnings.
@@ -873,7 +923,7 @@ PyConfig
Default: ``1`` in Python mode, ``0`` in isolated mode.
- Part of the :ref:`Path Configuration <init-path-config>` input.
+ Part of the :ref:`Python Path Configuration <init-path-config>` input.
.. c:member:: wchar_t* prefix
@@ -882,7 +932,7 @@ PyConfig
Default: ``NULL``.
- Part of the :ref:`Path Configuration <init-path-config>` output.
+ Part of the :ref:`Python Path Configuration <init-path-config>` output.
.. c:member:: wchar_t* program_name
@@ -900,7 +950,7 @@ PyConfig
Default: ``NULL``.
- Part of the :ref:`Path Configuration <init-path-config>` input.
+ Part of the :ref:`Python Path Configuration <init-path-config>` input.
.. c:member:: wchar_t* pycache_prefix
@@ -1106,7 +1156,7 @@ the :option:`-X` command line option.
Initialization with PyConfig
-----------------------------
+============================
Function to initialize Python:
@@ -1121,6 +1171,9 @@ If :c:func:`PyImport_FrozenModules`, :c:func:`PyImport_AppendInittab` or
:c:func:`PyImport_ExtendInittab` are used, they must be set or called after
Python preinitialization and before the Python initialization.
+The current configuration (``PyConfig`` type) is stored in
+``PyInterpreterState.config``.
+
Example setting the program name::
void init_python(void)
@@ -1134,17 +1187,17 @@ Example setting the program name::
status = PyConfig_SetString(&config, &config.program_name,
L"/path/to/my_program");
if (PyStatus_Exception(status)) {
- goto fail;
+ goto exception;
}
status = Py_InitializeFromConfig(&config);
if (PyStatus_Exception(status)) {
- goto fail;
+ goto exception;
}
PyConfig_Clear(&config);
return;
- fail:
+ exception:
PyConfig_Clear(&config);
Py_ExitStatusException(status);
}
@@ -1200,7 +1253,7 @@ configuration, and then override some parameters::
.. _init-isolated-conf:
Isolated Configuration
-----------------------
+======================
:c:func:`PyPreConfig_InitIsolatedConfig` and
:c:func:`PyConfig_InitIsolatedConfig` functions create a configuration to
@@ -1213,7 +1266,7 @@ and user site directory. The C standard streams (ex: ``stdout``) and the
LC_CTYPE locale are left unchanged. Signal handlers are not installed.
Configuration files are still used with this configuration. Set the
-:ref:`Path Configuration <init-path-config>` ("output fields") to ignore these
+:ref:`Python Path Configuration <init-path-config>` ("output fields") to ignore these
configuration files and avoid the function computing the default path
configuration.
@@ -1221,7 +1274,7 @@ configuration.
.. _init-python-config:
Python Configuration
---------------------
+====================
:c:func:`PyPreConfig_InitPythonConfig` and :c:func:`PyConfig_InitPythonConfig`
functions create a configuration to build a customized Python which behaves as
@@ -1235,46 +1288,11 @@ and :ref:`Python UTF-8 Mode <utf8-mode>`
(:pep:`540`) depending on the LC_CTYPE locale, :envvar:`PYTHONUTF8` and
:envvar:`PYTHONCOERCECLOCALE` environment variables.
-Example of customized Python always running in isolated mode::
-
- int main(int argc, char **argv)
- {
- PyStatus status;
-
- PyConfig config;
- PyConfig_InitPythonConfig(&config);
- config.isolated = 1;
-
- /* Decode command line arguments.
- Implicitly preinitialize Python (in isolated mode). */
- status = PyConfig_SetBytesArgv(&config, argc, argv);
- if (PyStatus_Exception(status)) {
- goto fail;
- }
-
- status = Py_InitializeFromConfig(&config);
- if (PyStatus_Exception(status)) {
- goto fail;
- }
- PyConfig_Clear(&config);
-
- return Py_RunMain();
-
- fail:
- PyConfig_Clear(&config);
- if (PyStatus_IsExit(status)) {
- return status.exitcode;
- }
- /* Display the error message and exit the process with
- non-zero exit code */
- Py_ExitStatusException(status);
- }
-
.. _init-path-config:
-Path Configuration
-------------------
+Python Path Configuration
+=========================
:c:type:`PyConfig` contains multiple fields for the path configuration:
@@ -1354,7 +1372,7 @@ The ``__PYVENV_LAUNCHER__`` environment variable is used to set
Py_RunMain()
-------------
+============
.. c:function:: int Py_RunMain(void)
@@ -1374,7 +1392,7 @@ customized Python always running in isolated mode using
Py_GetArgcArgv()
-----------------
+================
.. c:function:: void Py_GetArgcArgv(int *argc, wchar_t ***argv)
@@ -1384,7 +1402,7 @@ Py_GetArgcArgv()
Multi-Phase Initialization Private Provisional API
---------------------------------------------------
+==================================================
This section is a private provisional API introducing multi-phase
initialization, the core feature of the :pep:`432`:
diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst
index 7ca8693afa..bae5ce11b7 100644
--- a/Doc/c-api/intro.rst
+++ b/Doc/c-api/intro.rst
@@ -326,7 +326,7 @@ when it's no longer needed---or passing on this responsibility (usually to its
caller). When a function passes ownership of a reference on to its caller, the
caller is said to receive a *new* reference. When no ownership is transferred,
the caller is said to *borrow* the reference. Nothing needs to be done for a
-borrowed reference.
+:term:`borrowed reference`.
Conversely, when a calling function passes in a reference to an object, there
are two possibilities: the function *steals* a reference to the object, or it
diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst
index 6e9474bfa4..41a705d9e9 100644
--- a/Doc/c-api/module.rst
+++ b/Doc/c-api/module.rst
@@ -264,7 +264,7 @@ of the following two module creation functions:
instead; only use this if you are sure you need it.
Before it is returned from in the initialization function, the resulting module
-object is typically populated using functions like :c:func:`PyModule_AddObject`.
+object is typically populated using functions like :c:func:`PyModule_AddObjectRef`.
.. _multi-phase-initialization:
@@ -437,26 +437,102 @@ a function called from a module execution slot (if using multi-phase
initialization), can use the following functions to help initialize the module
state:
+.. c:function:: int PyModule_AddObjectRef(PyObject *module, const char *name, PyObject *value)
+
+ Add an object to *module* as *name*. This is a convenience function which
+ can be used from the module's initialization function.
+
+ On success, return ``0``. On error, raise an exception and return ``-1``.
+
+ Return ``NULL`` if *value* is ``NULL``. It must be called with an exception
+ raised in this case.
+
+ Example usage::
+
+ static int
+ add_spam(PyObject *module, int value)
+ {
+ PyObject *obj = PyLong_FromLong(value);
+ if (obj == NULL) {
+ return -1;
+ }
+ int res = PyModule_AddObjectRef(module, "spam", obj);
+ Py_DECREF(obj);
+ return res;
+ }
+
+ The example can also be written without checking explicitly if *obj* is
+ ``NULL``::
+
+ static int
+ add_spam(PyObject *module, int value)
+ {
+ PyObject *obj = PyLong_FromLong(value);
+ int res = PyModule_AddObjectRef(module, "spam", obj);
+ Py_XDECREF(obj);
+ return res;
+ }
+
+ Note that ``Py_XDECREF()`` should be used instead of ``Py_DECREF()`` in
+ this case, since *obj* can be ``NULL``.
+
+ .. versionadded:: 3.10
+
+
.. c:function:: int PyModule_AddObject(PyObject *module, const char *name, PyObject *value)
- Add an object to *module* as *name*. This is a convenience function which can
- be used from the module's initialization function. This steals a reference to
- *value* on success. Return ``-1`` on error, ``0`` on success.
+ Similar to :c:func:`PyModule_AddObjectRef`, but steals a reference to
+ *value* on success (if it returns ``0``).
+
+ The new :c:func:`PyModule_AddObjectRef` function is recommended, since it is
+ easy to introduce reference leaks by misusing the
+ :c:func:`PyModule_AddObject` function.
.. note::
- Unlike other functions that steal references, ``PyModule_AddObject()`` only
- decrements the reference count of *value* **on success**.
+ Unlike other functions that steal references, ``PyModule_AddObject()``
+ only decrements the reference count of *value* **on success**.
This means that its return value must be checked, and calling code must
- :c:func:`Py_DECREF` *value* manually on error. Example usage::
-
- Py_INCREF(spam);
- if (PyModule_AddObject(module, "spam", spam) < 0) {
- Py_DECREF(module);
- Py_DECREF(spam);
- return NULL;
- }
+ :c:func:`Py_DECREF` *value* manually on error.
+
+ Example usage::
+
+ static int
+ add_spam(PyObject *module, int value)
+ {
+ PyObject *obj = PyLong_FromLong(value);
+ if (obj == NULL) {
+ return -1;
+ }
+ if (PyModule_AddObject(module, "spam", obj) < 0) {
+ Py_DECREF(obj);
+ return -1;
+ }
+ // PyModule_AddObject() stole a reference to obj:
+ // Py_DECREF(obj) is not needed here
+ return 0;
+ }
+
+ The example can also be written without checking explicitly if *obj* is
+ ``NULL``::
+
+ static int
+ add_spam(PyObject *module, int value)
+ {
+ PyObject *obj = PyLong_FromLong(value);
+ if (PyModule_AddObject(module, "spam", obj) < 0) {
+ Py_XDECREF(obj);
+ return -1;
+ }
+ // PyModule_AddObject() stole a reference to obj:
+ // Py_DECREF(obj) is not needed here
+ return 0;
+ }
+
+ Note that ``Py_XDECREF()`` should be used instead of ``Py_DECREF()`` in
+ this case, since *obj* can be ``NULL``.
+
.. c:function:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value)
diff --git a/Doc/c-api/refcounting.rst b/Doc/c-api/refcounting.rst
index 0df12c67f4..391907c8c2 100644
--- a/Doc/c-api/refcounting.rst
+++ b/Doc/c-api/refcounting.rst
@@ -13,8 +13,14 @@ objects.
.. c:function:: void Py_INCREF(PyObject *o)
- Increment the reference count for object *o*. The object must not be ``NULL``; if
- you aren't sure that it isn't ``NULL``, use :c:func:`Py_XINCREF`.
+ Increment the reference count for object *o*.
+
+ This function is usually used to convert a :term:`borrowed reference` to a
+ :term:`strong reference` in-place. The :c:func:`Py_NewRef` function can be
+ used to create a new :term:`strong reference`.
+
+ The object must not be ``NULL``; if you aren't sure that it isn't
+ ``NULL``, use :c:func:`Py_XINCREF`.
.. c:function:: void Py_XINCREF(PyObject *o)
@@ -22,13 +28,55 @@ objects.
Increment the reference count for object *o*. The object may be ``NULL``, in
which case the macro has no effect.
+ See also :c:func:`Py_XNewRef`.
+
+
+.. c:function:: PyObject* Py_NewRef(PyObject *o)
+
+ Create a new :term:`strong reference` to an object: increment the reference
+ count of the object *o* and return the object *o*.
+
+ When the :term:`strong reference` is no longer needed, :c:func:`Py_DECREF`
+ should be called on it to decrement the object reference count.
+
+ The object *o* must not be ``NULL``; use :c:func:`Py_XNewRef` if *o* can be
+ ``NULL``.
+
+ For example::
+
+ Py_INCREF(obj);
+ self->attr = obj;
+
+ can be written as::
+
+ self->attr = Py_NewRef(obj);
+
+ See also :c:func:`Py_INCREF`.
+
+ .. versionadded:: 3.10
+
+
+.. c:function:: PyObject* Py_XNewRef(PyObject *o)
+
+ Similar to :c:func:`Py_NewRef`, but the object *o* can be NULL.
+
+ If the object *o* is ``NULL``, the function just returns ``NULL``.
+
+ .. versionadded:: 3.10
+
.. c:function:: void Py_DECREF(PyObject *o)
- Decrement the reference count for object *o*. The object must not be ``NULL``; if
- you aren't sure that it isn't ``NULL``, use :c:func:`Py_XDECREF`. If the reference
- count reaches zero, the object's type's deallocation function (which must not be
- ``NULL``) is invoked.
+ Decrement the reference count for object *o*.
+
+ If the reference count reaches zero, the object's type's deallocation
+ function (which must not be ``NULL``) is invoked.
+
+ This function is usually used to delete a :term:`strong reference` before
+ exiting its scope.
+
+ The object must not be ``NULL``; if you aren't sure that it isn't ``NULL``,
+ use :c:func:`Py_XDECREF`.
.. warning::
diff --git a/Doc/c-api/reflection.rst b/Doc/c-api/reflection.rst
index 9207d86012..64ce4d1d0c 100644
--- a/Doc/c-api/reflection.rst
+++ b/Doc/c-api/reflection.rst
@@ -35,7 +35,7 @@ Reflection
Get the *frame* next outer frame.
- Return a strong reference, or ``NULL`` if *frame* has no outer frame.
+ Return a :term:`strong reference`, or ``NULL`` if *frame* has no outer frame.
*frame* must not be ``NULL``.
@@ -46,7 +46,7 @@ Reflection
Get the *frame* code.
- Return a strong reference.
+ Return a :term:`strong reference`.
*frame* must not be ``NULL``. The result (frame code) cannot be ``NULL``.
diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst
index a9e1c6fbcc..37072d30d5 100644
--- a/Doc/c-api/structures.rst
+++ b/Doc/c-api/structures.rst
@@ -66,11 +66,9 @@ the definition of all other Python objects.
Get the type of the Python object *o*.
- Return a borrowed reference.
+ Return a :term:`borrowed reference`.
- .. versionchanged:: 3.10
- :c:func:`Py_TYPE()` is changed to the inline static function.
- Use :c:func:`Py_SET_TYPE()` to set an object type.
+ The :c:func:`Py_SET_TYPE` function must be used to set an object type.
.. c:function:: int Py_IS_TYPE(PyObject *o, PyTypeObject *type)
@@ -108,9 +106,7 @@ the definition of all other Python objects.
Get the size of the Python object *o*.
- .. versionchanged:: 3.10
- :c:func:`Py_SIZE()` is changed to the inline static function.
- Use :c:func:`Py_SET_SIZE()` to set an object size.
+ The :c:func:`Py_SET_SIZE` function must be used to set an object size.
.. c:function:: void Py_SET_SIZE(PyVarObject *o, Py_ssize_t size)
@@ -263,10 +259,12 @@ There are these calling conventions:
of :c:type:`PyObject*` values indicating the arguments and the third
parameter is the number of arguments (the length of the array).
- This is not part of the :ref:`limited API <stable>`.
-
.. versionadded:: 3.7
+ .. versionchanged:: 3.10
+
+ ``METH_FASTCALL`` is now part of the stable ABI.
+
.. data:: METH_FASTCALL | METH_KEYWORDS
diff --git a/Doc/c-api/tuple.rst b/Doc/c-api/tuple.rst
index bf751e44ac..c0c14f480d 100644
--- a/Doc/c-api/tuple.rst
+++ b/Doc/c-api/tuple.rst
@@ -57,7 +57,7 @@ Tuple Objects
.. c:function:: PyObject* PyTuple_GetItem(PyObject *p, Py_ssize_t pos)
Return the object at position *pos* in the tuple pointed to by *p*. If *pos* is
- out of bounds, return ``NULL`` and set an :exc:`IndexError` exception.
+ negative or out of bounds, return ``NULL`` and set an :exc:`IndexError` exception.
.. c:function:: PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos)
diff --git a/Doc/c-api/type.rst b/Doc/c-api/type.rst
index 73f26875d8..a869859dd4 100644
--- a/Doc/c-api/type.rst
+++ b/Doc/c-api/type.rst
@@ -105,10 +105,12 @@ Type Objects
See :c:member:`PyType_Slot.slot` for possible values of the *slot* argument.
- An exception is raised if *type* is not a heap type.
-
.. versionadded:: 3.4
+ .. versionchanged:: 3.10
+ :c:func:`PyType_GetSlot` can now accept all types.
+ Previously, it was limited to heap types.
+
.. c:function:: PyObject* PyType_GetModule(PyTypeObject *type)
Return the module object associated with the given type when the type was
@@ -152,10 +154,10 @@ The following functions and structs are used to create
Creates and returns a heap type object from the *spec*
(:const:`Py_TPFLAGS_HEAPTYPE`).
- If *bases* is a tuple, the created heap type contains all types contained
- in it as base types.
-
- If *bases* is ``NULL``, the *Py_tp_base* slot is used instead.
+ The *bases* argument can be used to specify base classes; it can either
+ be only one class or a tuple of classes.
+ If *bases* is ``NULL``, the *Py_tp_bases* slot is used instead.
+ If that also is ``NULL``, the *Py_tp_base* slot is used instead.
If that also is ``NULL``, the new type derives from :class:`object`.
The *module* argument can be used to record the module in which the new
@@ -169,6 +171,11 @@ The following functions and structs are used to create
.. versionadded:: 3.9
+ .. versionchanged:: 3.10
+
+ The function now accepts a single class as the *bases* argument and
+ ``NULL`` as the ``tp_doc`` slot.
+
.. c:function:: PyObject* PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
Equivalent to ``PyType_FromModuleAndSpec(NULL, spec, bases)``.
@@ -247,7 +254,8 @@ The following functions and structs are used to create
* :c:member:`~PyBufferProcs.bf_getbuffer`
* :c:member:`~PyBufferProcs.bf_releasebuffer`
- Setting :c:data:`Py_tp_bases` may be problematic on some platforms.
+ Setting :c:data:`Py_tp_bases` or :c:data:`Py_tp_base` may be
+ problematic on some platforms.
To avoid issues, use the *bases* argument of
:py:func:`PyType_FromSpecWithBases` instead.
@@ -260,4 +268,4 @@ The following functions and structs are used to create
The desired value of the slot. In most cases, this is a pointer
to a function.
- May not be ``NULL``.
+ Slots other than ``Py_tp_doc`` may not be ``NULL``.
diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst
index ddcb8ae3d0..9efe3aac2e 100644
--- a/Doc/c-api/typeobj.rst
+++ b/Doc/c-api/typeobj.rst
@@ -199,6 +199,8 @@ sub-slots
+---------------------------------------------------------+-----------------------------------+--------------+
| :c:member:`~PyAsyncMethods.am_anext` | :c:type:`unaryfunc` | __anext__ |
+---------------------------------------------------------+-----------------------------------+--------------+
+ | :c:member:`~PyAsyncMethods.am_send` | :c:type:`sendfunc` | |
+ +---------------------------------------------------------+-----------------------------------+--------------+
| |
+---------------------------------------------------------+-----------------------------------+--------------+
| :c:member:`~PyNumberMethods.nb_add` | :c:type:`binaryfunc` | __add__ |
@@ -1168,6 +1170,14 @@ and :c:type:`PyType_Type` effectively act as defaults.)
.. versionadded:: 3.9
+ .. data:: Py_TPFLAGS_HAVE_AM_SEND
+
+ This bit is set when the :c:member:`~PyAsyncMethods.am_send` entry is present in the
+ :c:member:`~PyTypeObject.tp_as_async` slot of type structure.
+
+ .. versionadded:: 3.10
+
+
.. c:member:: const char* PyTypeObject.tp_doc
An optional pointer to a NUL-terminated C string giving the docstring for this
@@ -1213,8 +1223,9 @@ and :c:type:`PyType_Type` effectively act as defaults.)
:func:`~gc.get_referents` function will include it.
.. warning::
- When implementing :c:member:`~PyTypeObject.tp_traverse`, only the members
- that the instance *owns* (by having strong references to them) must be
+ When implementing :c:member:`~PyTypeObject.tp_traverse`, only the
+ members that the instance *owns* (by having :term:`strong references
+ <strong reference>` to them) must be
visited. For instance, if an object supports weak references via the
:c:member:`~PyTypeObject.tp_weaklist` slot, the pointer supporting
the linked list (what *tp_weaklist* points to) must **not** be
@@ -2303,6 +2314,7 @@ Async Object Structures
unaryfunc am_await;
unaryfunc am_aiter;
unaryfunc am_anext;
+ sendfunc am_send;
} PyAsyncMethods;
.. c:member:: unaryfunc PyAsyncMethods.am_await
@@ -2336,6 +2348,15 @@ Async Object Structures
Must return an :term:`awaitable` object. See :meth:`__anext__` for details.
This slot may be set to ``NULL``.
+.. c:member:: sendfunc PyAsyncMethods.am_send
+
+ The signature of this function is::
+
+ PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);
+
+ See :c:func:`PyIter_Send` for details.
+ This slot may be set to ``NULL``.
+
.. _slot-typedefs:
@@ -2431,6 +2452,10 @@ Slot Type typedefs
.. c:type:: PyObject *(*binaryfunc)(PyObject *, PyObject *)
+.. c:type:: PySendResult (*sendfunc)(PyObject *, PyObject *, PyObject **)
+
+ See :c:member:`~PyAsyncMethods.am_send`.
+
.. c:type:: PyObject *(*ternaryfunc)(PyObject *, PyObject *, PyObject *)
.. c:type:: PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t)
diff --git a/Doc/c-api/weakref.rst b/Doc/c-api/weakref.rst
index e3a9bda54d..9205ca620a 100644
--- a/Doc/c-api/weakref.rst
+++ b/Doc/c-api/weakref.rst
@@ -57,10 +57,10 @@ as much as it can.
.. note::
- This function returns a **borrowed reference** to the referenced object.
+ This function returns a :term:`borrowed reference` to the referenced object.
This means that you should always call :c:func:`Py_INCREF` on the object
- except if you know that it cannot be destroyed while you are still
- using it.
+ except when it cannot be destroyed before the last usage of the borrowed
+ reference.
.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
diff --git a/Doc/conf.py b/Doc/conf.py
index 079d17717f..6b88c23a44 100644
--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -15,8 +15,7 @@ sys.path.append(os.path.abspath('includes'))
extensions = ['sphinx.ext.coverage', 'sphinx.ext.doctest',
'pyspecific', 'c_annotations', 'escape4chm',
- 'asdl_highlight', 'peg_highlight']
-
+ 'asdl_highlight', 'peg_highlight', 'glossary_search']
doctest_global_setup = '''
try:
diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat
index d01e99ca5e..8a6ee718a0 100644
--- a/Doc/data/refcounts.dat
+++ b/Doc/data/refcounts.dat
@@ -3007,6 +3007,9 @@ Py_GetVersion:const char*:::
Py_INCREF:void:::
Py_INCREF:PyObject*:o:+1:
+Py_NewRef:void:::
+Py_NewRef:PyObject*:o:+1:
+
Py_Initialize:void:::
Py_IsInitialized:int:::
@@ -3028,6 +3031,9 @@ Py_XDECREF:PyObject*:o:-1:if o is not NULL
Py_XINCREF:void:::
Py_XINCREF:PyObject*:o:+1:if o is not NULL
+Py_XNewRef:void:::
+Py_XNewRef:PyObject*:o:+1:if o is not NULL
+
_PyImport_Fini:void:::
_PyObject_New:PyObject*::+1:
diff --git a/Doc/data/stable_abi.dat b/Doc/data/stable_abi.dat
new file mode 100644
index 0000000000..c2c9c6e11e
--- /dev/null
+++ b/Doc/data/stable_abi.dat
@@ -0,0 +1,780 @@
+# File generated by 'make regen-limited-abi'
+# This is NOT an authoritative list of stable ABI symbols
+PyArg_Parse
+PyArg_ParseTuple
+PyArg_ParseTupleAndKeywords
+PyArg_UnpackTuple
+PyArg_VaParse
+PyArg_VaParseTupleAndKeywords
+PyArg_ValidateKeywordArguments
+PyBaseObject_Type
+PyBool_FromLong
+PyBool_Type
+PyByteArrayIter_Type
+PyByteArray_AsString
+PyByteArray_Concat
+PyByteArray_FromObject
+PyByteArray_FromStringAndSize
+PyByteArray_Resize
+PyByteArray_Size
+PyByteArray_Type
+PyBytesIter_Type
+PyBytes_AsString
+PyBytes_AsStringAndSize
+PyBytes_Concat
+PyBytes_ConcatAndDel
+PyBytes_DecodeEscape
+PyBytes_FromFormat
+PyBytes_FromFormatV
+PyBytes_FromObject
+PyBytes_FromString
+PyBytes_FromStringAndSize
+PyBytes_Repr
+PyBytes_Size
+PyBytes_Type
+PyCFunction_Call
+PyCFunction_GetFlags
+PyCFunction_GetFunction
+PyCFunction_GetSelf
+PyCFunction_NewEx
+PyCFunction_Type
+PyCMethod_New
+PyCallIter_New
+PyCallIter_Type
+PyCallable_Check
+PyCapsule_GetContext
+PyCapsule_GetDestructor
+PyCapsule_GetName
+PyCapsule_GetPointer
+PyCapsule_Import
+PyCapsule_IsValid
+PyCapsule_New
+PyCapsule_SetContext
+PyCapsule_SetDestructor
+PyCapsule_SetName
+PyCapsule_SetPointer
+PyCapsule_Type
+PyClassMethodDescr_Type
+PyCodec_BackslashReplaceErrors
+PyCodec_Decode
+PyCodec_Decoder
+PyCodec_Encode
+PyCodec_Encoder
+PyCodec_IgnoreErrors
+PyCodec_IncrementalDecoder
+PyCodec_IncrementalEncoder
+PyCodec_KnownEncoding
+PyCodec_LookupError
+PyCodec_NameReplaceErrors
+PyCodec_Register
+PyCodec_RegisterError
+PyCodec_ReplaceErrors
+PyCodec_StreamReader
+PyCodec_StreamWriter
+PyCodec_StrictErrors
+PyCodec_Unregister
+PyCodec_XMLCharRefReplaceErrors
+PyComplex_FromDoubles
+PyComplex_ImagAsDouble
+PyComplex_RealAsDouble
+PyComplex_Type
+PyDescr_NewClassMethod
+PyDescr_NewGetSet
+PyDescr_NewMember
+PyDescr_NewMethod
+PyDictItems_Type
+PyDictIterItem_Type
+PyDictIterKey_Type
+PyDictIterValue_Type
+PyDictKeys_Type
+PyDictProxy_New
+PyDictProxy_Type
+PyDictRevIterItem_Type
+PyDictRevIterKey_Type
+PyDictRevIterValue_Type
+PyDictValues_Type
+PyDict_Clear
+PyDict_Contains
+PyDict_Copy
+PyDict_DelItem
+PyDict_DelItemString
+PyDict_GetItem
+PyDict_GetItemString
+PyDict_GetItemWithError
+PyDict_Items
+PyDict_Keys
+PyDict_Merge
+PyDict_MergeFromSeq2
+PyDict_New
+PyDict_Next
+PyDict_SetItem
+PyDict_SetItemString
+PyDict_Size
+PyDict_Type
+PyDict_Update
+PyDict_Values
+PyEllipsis_Type
+PyEnum_Type
+PyErr_BadArgument
+PyErr_BadInternalCall
+PyErr_CheckSignals
+PyErr_Clear
+PyErr_Display
+PyErr_ExceptionMatches
+PyErr_Fetch
+PyErr_Format
+PyErr_FormatV
+PyErr_GetExcInfo
+PyErr_GivenExceptionMatches
+PyErr_NewException
+PyErr_NewExceptionWithDoc
+PyErr_NoMemory
+PyErr_NormalizeException
+PyErr_Occurred
+PyErr_Print
+PyErr_PrintEx
+PyErr_ProgramText
+PyErr_ResourceWarning
+PyErr_Restore
+PyErr_SetExcInfo
+PyErr_SetFromErrno
+PyErr_SetFromErrnoWithFilename
+PyErr_SetFromErrnoWithFilenameObject
+PyErr_SetFromErrnoWithFilenameObjects
+PyErr_SetImportError
+PyErr_SetImportErrorSubclass
+PyErr_SetInterrupt
+PyErr_SetNone
+PyErr_SetObject
+PyErr_SetString
+PyErr_SyntaxLocation
+PyErr_SyntaxLocationEx
+PyErr_WarnEx
+PyErr_WarnExplicit
+PyErr_WarnFormat
+PyErr_WriteUnraisable
+PyEval_AcquireLock
+PyEval_AcquireThread
+PyEval_CallFunction
+PyEval_CallMethod
+PyEval_CallObjectWithKeywords
+PyEval_EvalCode
+PyEval_EvalCodeEx
+PyEval_EvalFrame
+PyEval_EvalFrameEx
+PyEval_GetBuiltins
+PyEval_GetFrame
+PyEval_GetFuncDesc
+PyEval_GetFuncName
+PyEval_GetGlobals
+PyEval_GetLocals
+PyEval_InitThreads
+PyEval_ReleaseLock
+PyEval_ReleaseThread
+PyEval_RestoreThread
+PyEval_SaveThread
+PyEval_ThreadsInitialized
+PyExc_ArithmeticError
+PyExc_AssertionError
+PyExc_AttributeError
+PyExc_BaseException
+PyExc_BlockingIOError
+PyExc_BrokenPipeError
+PyExc_BufferError
+PyExc_BytesWarning
+PyExc_ChildProcessError
+PyExc_ConnectionAbortedError
+PyExc_ConnectionError
+PyExc_ConnectionRefusedError
+PyExc_ConnectionResetError
+PyExc_DeprecationWarning
+PyExc_EOFError
+PyExc_EnvironmentError
+PyExc_Exception
+PyExc_FileExistsError
+PyExc_FileNotFoundError
+PyExc_FloatingPointError
+PyExc_FutureWarning
+PyExc_GeneratorExit
+PyExc_IOError
+PyExc_ImportError
+PyExc_ImportWarning
+PyExc_IndentationError
+PyExc_IndexError
+PyExc_InterruptedError
+PyExc_IsADirectoryError
+PyExc_KeyError
+PyExc_KeyboardInterrupt
+PyExc_LookupError
+PyExc_MemoryError
+PyExc_ModuleNotFoundError
+PyExc_NameError
+PyExc_NotADirectoryError
+PyExc_NotImplementedError
+PyExc_OSError
+PyExc_OverflowError
+PyExc_PendingDeprecationWarning
+PyExc_PermissionError
+PyExc_ProcessLookupError
+PyExc_RecursionError
+PyExc_ReferenceError
+PyExc_ResourceWarning
+PyExc_RuntimeError
+PyExc_RuntimeWarning
+PyExc_StopAsyncIteration
+PyExc_StopIteration
+PyExc_SyntaxError
+PyExc_SyntaxWarning
+PyExc_SystemError
+PyExc_SystemExit
+PyExc_TabError
+PyExc_TimeoutError
+PyExc_TypeError
+PyExc_UnboundLocalError
+PyExc_UnicodeDecodeError
+PyExc_UnicodeEncodeError
+PyExc_UnicodeError
+PyExc_UnicodeTranslateError
+PyExc_UnicodeWarning
+PyExc_UserWarning
+PyExc_ValueError
+PyExc_Warning
+PyExc_ZeroDivisionError
+PyExceptionClass_Name
+PyException_GetCause
+PyException_GetContext
+PyException_GetTraceback
+PyException_SetCause
+PyException_SetContext
+PyException_SetTraceback
+PyFile_FromFd
+PyFile_GetLine
+PyFile_WriteObject
+PyFile_WriteString
+PyFilter_Type
+PyFloat_AsDouble
+PyFloat_FromDouble
+PyFloat_FromString
+PyFloat_GetInfo
+PyFloat_GetMax
+PyFloat_GetMin
+PyFloat_Type
+PyFrame_GetCode
+PyFrame_GetLineNumber
+PyFrozenSet_New
+PyFrozenSet_Type
+PyGC_Collect
+PyGILState_Ensure
+PyGILState_GetThisThreadState
+PyGILState_Release
+PyGetSetDescr_Type
+PyImport_AddModule
+PyImport_AddModuleObject
+PyImport_AppendInittab
+PyImport_ExecCodeModule
+PyImport_ExecCodeModuleEx
+PyImport_ExecCodeModuleObject
+PyImport_ExecCodeModuleWithPathnames
+PyImport_GetImporter
+PyImport_GetMagicNumber
+PyImport_GetMagicTag
+PyImport_GetModule
+PyImport_GetModuleDict
+PyImport_Import
+PyImport_ImportFrozenModule
+PyImport_ImportFrozenModuleObject
+PyImport_ImportModule
+PyImport_ImportModuleLevel
+PyImport_ImportModuleLevelObject
+PyImport_ImportModuleNoBlock
+PyImport_ReloadModule
+PyIndex_Check
+PyInterpreterState_Clear
+PyInterpreterState_Delete
+PyInterpreterState_Get
+PyInterpreterState_GetDict
+PyInterpreterState_GetID
+PyInterpreterState_New
+PyIter_Check
+PyIter_Next
+PyIter_Send
+PyListIter_Type
+PyListRevIter_Type
+PyList_Append
+PyList_AsTuple
+PyList_GetItem
+PyList_GetSlice
+PyList_Insert
+PyList_New
+PyList_Reverse
+PyList_SetItem
+PyList_SetSlice
+PyList_Size
+PyList_Sort
+PyList_Type
+PyLongRangeIter_Type
+PyLong_AsDouble
+PyLong_AsLong
+PyLong_AsLongAndOverflow
+PyLong_AsLongLong
+PyLong_AsLongLongAndOverflow
+PyLong_AsSize_t
+PyLong_AsSsize_t
+PyLong_AsUnsignedLong
+PyLong_AsUnsignedLongLong
+PyLong_AsUnsignedLongLongMask
+PyLong_AsUnsignedLongMask
+PyLong_AsVoidPtr
+PyLong_FromDouble
+PyLong_FromLong
+PyLong_FromLongLong
+PyLong_FromSize_t
+PyLong_FromSsize_t
+PyLong_FromString
+PyLong_FromUnsignedLong
+PyLong_FromUnsignedLongLong
+PyLong_FromVoidPtr
+PyLong_GetInfo
+PyLong_Type
+PyMap_Type
+PyMapping_Check
+PyMapping_GetItemString
+PyMapping_HasKey
+PyMapping_HasKeyString
+PyMapping_Items
+PyMapping_Keys
+PyMapping_Length
+PyMapping_SetItemString
+PyMapping_Size
+PyMapping_Values
+PyMarshal_ReadObjectFromString
+PyMarshal_WriteLongToFile
+PyMarshal_WriteObjectToFile
+PyMarshal_WriteObjectToString
+PyMem_Free
+PyMem_Malloc
+PyMem_Realloc
+PyMemberDescr_Type
+PyMember_GetOne
+PyMember_SetOne
+PyMemoryView_FromMemory
+PyMemoryView_FromObject
+PyMemoryView_GetContiguous
+PyMemoryView_Type
+PyMethodDescr_Type
+PyModuleDef_Init
+PyModuleDef_Type
+PyModule_AddFunctions
+PyModule_AddIntConstant
+PyModule_AddObject
+PyModule_AddObjectRef
+PyModule_AddStringConstant
+PyModule_AddType
+PyModule_Create2
+PyModule_ExecDef
+PyModule_FromDefAndSpec2
+PyModule_GetDef
+PyModule_GetDict
+PyModule_GetFilename
+PyModule_GetFilenameObject
+PyModule_GetName
+PyModule_GetNameObject
+PyModule_GetState
+PyModule_New
+PyModule_NewObject
+PyModule_SetDocString
+PyModule_Type
+PyNumber_Absolute
+PyNumber_Add
+PyNumber_And
+PyNumber_AsSsize_t
+PyNumber_Check
+PyNumber_Divmod
+PyNumber_Float
+PyNumber_FloorDivide
+PyNumber_InPlaceAdd
+PyNumber_InPlaceAnd
+PyNumber_InPlaceFloorDivide
+PyNumber_InPlaceLshift
+PyNumber_InPlaceMatrixMultiply
+PyNumber_InPlaceMultiply
+PyNumber_InPlaceOr
+PyNumber_InPlacePower
+PyNumber_InPlaceRemainder
+PyNumber_InPlaceRshift
+PyNumber_InPlaceSubtract
+PyNumber_InPlaceTrueDivide
+PyNumber_InPlaceXor
+PyNumber_Index
+PyNumber_Invert
+PyNumber_Long
+PyNumber_Lshift
+PyNumber_MatrixMultiply
+PyNumber_Multiply
+PyNumber_Negative
+PyNumber_Or
+PyNumber_Positive
+PyNumber_Power
+PyNumber_Remainder
+PyNumber_Rshift
+PyNumber_Subtract
+PyNumber_ToBase
+PyNumber_TrueDivide
+PyNumber_Xor
+PyOS_AfterFork
+PyOS_AfterFork_Child
+PyOS_AfterFork_Parent
+PyOS_BeforeFork
+PyOS_FSPath
+PyOS_InterruptOccurred
+PyOS_double_to_string
+PyOS_getsig
+PyOS_mystricmp
+PyOS_mystrnicmp
+PyOS_setsig
+PyOS_snprintf
+PyOS_string_to_double
+PyOS_strtol
+PyOS_strtoul
+PyOS_vsnprintf
+PyObject_ASCII
+PyObject_AsFileDescriptor
+PyObject_Bytes
+PyObject_Call
+PyObject_CallFunction
+PyObject_CallFunctionObjArgs
+PyObject_CallMethod
+PyObject_CallMethodObjArgs
+PyObject_CallNoArgs
+PyObject_CallObject
+PyObject_Calloc
+PyObject_ClearWeakRefs
+PyObject_DelItem
+PyObject_DelItemString
+PyObject_Dir
+PyObject_Format
+PyObject_Free
+PyObject_GC_Del
+PyObject_GC_IsFinalized
+PyObject_GC_IsTracked
+PyObject_GC_Track
+PyObject_GC_UnTrack
+PyObject_GenericGetAttr
+PyObject_GenericGetDict
+PyObject_GenericSetAttr
+PyObject_GenericSetDict
+PyObject_GetAttr
+PyObject_GetAttrString
+PyObject_GetItem
+PyObject_GetIter
+PyObject_HasAttr
+PyObject_HasAttrString
+PyObject_Hash
+PyObject_HashNotImplemented
+PyObject_Init
+PyObject_InitVar
+PyObject_IsInstance
+PyObject_IsSubclass
+PyObject_IsTrue
+PyObject_Length
+PyObject_Malloc
+PyObject_Not
+PyObject_Realloc
+PyObject_Repr
+PyObject_RichCompare
+PyObject_RichCompareBool
+PyObject_SelfIter
+PyObject_SetAttr
+PyObject_SetAttrString
+PyObject_SetItem
+PyObject_Size
+PyObject_Str
+PyObject_Type
+PyProperty_Type
+PyRangeIter_Type
+PyRange_Type
+PyReversed_Type
+PySeqIter_New
+PySeqIter_Type
+PySequence_Check
+PySequence_Concat
+PySequence_Contains
+PySequence_Count
+PySequence_DelItem
+PySequence_DelSlice
+PySequence_Fast
+PySequence_GetItem
+PySequence_GetSlice
+PySequence_In
+PySequence_InPlaceConcat
+PySequence_InPlaceRepeat
+PySequence_Index
+PySequence_Length
+PySequence_List
+PySequence_Repeat
+PySequence_SetItem
+PySequence_SetSlice
+PySequence_Size
+PySequence_Tuple
+PySetIter_Type
+PySet_Add
+PySet_Clear
+PySet_Contains
+PySet_Discard
+PySet_New
+PySet_Pop
+PySet_Size
+PySet_Type
+PySlice_AdjustIndices
+PySlice_GetIndices
+PySlice_GetIndicesEx
+PySlice_New
+PySlice_Type
+PySlice_Unpack
+PyState_AddModule
+PyState_FindModule
+PyState_RemoveModule
+PyStructSequence_GetItem
+PyStructSequence_New
+PyStructSequence_NewType
+PyStructSequence_SetItem
+PySuper_Type
+PySys_AddWarnOption
+PySys_AddWarnOptionUnicode
+PySys_AddXOption
+PySys_FormatStderr
+PySys_FormatStdout
+PySys_GetObject
+PySys_GetXOptions
+PySys_HasWarnOptions
+PySys_ResetWarnOptions
+PySys_SetArgv
+PySys_SetArgvEx
+PySys_SetObject
+PySys_SetPath
+PySys_WriteStderr
+PySys_WriteStdout
+PyThreadState_Clear
+PyThreadState_Delete
+PyThreadState_Get
+PyThreadState_GetDict
+PyThreadState_GetFrame
+PyThreadState_GetID
+PyThreadState_GetInterpreter
+PyThreadState_New
+PyThreadState_SetAsyncExc
+PyThreadState_Swap
+PyThread_GetInfo
+PyThread_ReInitTLS
+PyThread_acquire_lock
+PyThread_acquire_lock_timed
+PyThread_allocate_lock
+PyThread_create_key
+PyThread_delete_key
+PyThread_delete_key_value
+PyThread_exit_thread
+PyThread_free_lock
+PyThread_get_key_value
+PyThread_get_stacksize
+PyThread_get_thread_ident
+PyThread_get_thread_native_id
+PyThread_init_thread
+PyThread_release_lock
+PyThread_set_key_value
+PyThread_set_stacksize
+PyThread_start_new_thread
+PyThread_tss_alloc
+PyThread_tss_create
+PyThread_tss_delete
+PyThread_tss_free
+PyThread_tss_get
+PyThread_tss_is_created
+PyThread_tss_set
+PyTraceBack_Here
+PyTraceBack_Print
+PyTraceBack_Type
+PyTupleIter_Type
+PyTuple_GetItem
+PyTuple_GetSlice
+PyTuple_New
+PyTuple_Pack
+PyTuple_SetItem
+PyTuple_Size
+PyTuple_Type
+PyType_ClearCache
+PyType_FromModuleAndSpec
+PyType_FromSpec
+PyType_FromSpecWithBases
+PyType_GenericAlloc
+PyType_GenericNew
+PyType_GetFlags
+PyType_GetModule
+PyType_GetModuleState
+PyType_GetSlot
+PyType_IsSubtype
+PyType_Modified
+PyType_Ready
+PyType_Type
+PyUnicodeDecodeError_Create
+PyUnicodeDecodeError_GetEncoding
+PyUnicodeDecodeError_GetEnd
+PyUnicodeDecodeError_GetObject
+PyUnicodeDecodeError_GetReason
+PyUnicodeDecodeError_GetStart
+PyUnicodeDecodeError_SetEnd
+PyUnicodeDecodeError_SetReason
+PyUnicodeDecodeError_SetStart
+PyUnicodeEncodeError_GetEncoding
+PyUnicodeEncodeError_GetEnd
+PyUnicodeEncodeError_GetObject
+PyUnicodeEncodeError_GetReason
+PyUnicodeEncodeError_GetStart
+PyUnicodeEncodeError_SetEnd
+PyUnicodeEncodeError_SetReason
+PyUnicodeEncodeError_SetStart
+PyUnicodeIter_Type
+PyUnicodeTranslateError_GetEnd
+PyUnicodeTranslateError_GetObject
+PyUnicodeTranslateError_GetReason
+PyUnicodeTranslateError_GetStart
+PyUnicodeTranslateError_SetEnd
+PyUnicodeTranslateError_SetReason
+PyUnicodeTranslateError_SetStart
+PyUnicode_Append
+PyUnicode_AppendAndDel
+PyUnicode_AsASCIIString
+PyUnicode_AsCharmapString
+PyUnicode_AsDecodedObject
+PyUnicode_AsDecodedUnicode
+PyUnicode_AsEncodedObject
+PyUnicode_AsEncodedString
+PyUnicode_AsEncodedUnicode
+PyUnicode_AsLatin1String
+PyUnicode_AsRawUnicodeEscapeString
+PyUnicode_AsUCS4
+PyUnicode_AsUCS4Copy
+PyUnicode_AsUTF16String
+PyUnicode_AsUTF32String
+PyUnicode_AsUTF8AndSize
+PyUnicode_AsUTF8String
+PyUnicode_AsUnicodeEscapeString
+PyUnicode_AsWideChar
+PyUnicode_AsWideCharString
+PyUnicode_BuildEncodingMap
+PyUnicode_Compare
+PyUnicode_CompareWithASCIIString
+PyUnicode_Concat
+PyUnicode_Contains
+PyUnicode_Count
+PyUnicode_Decode
+PyUnicode_DecodeASCII
+PyUnicode_DecodeCharmap
+PyUnicode_DecodeFSDefault
+PyUnicode_DecodeFSDefaultAndSize
+PyUnicode_DecodeLatin1
+PyUnicode_DecodeLocale
+PyUnicode_DecodeLocaleAndSize
+PyUnicode_DecodeRawUnicodeEscape
+PyUnicode_DecodeUTF16
+PyUnicode_DecodeUTF16Stateful
+PyUnicode_DecodeUTF32
+PyUnicode_DecodeUTF32Stateful
+PyUnicode_DecodeUTF7
+PyUnicode_DecodeUTF7Stateful
+PyUnicode_DecodeUTF8
+PyUnicode_DecodeUTF8Stateful
+PyUnicode_DecodeUnicodeEscape
+PyUnicode_EncodeFSDefault
+PyUnicode_EncodeLocale
+PyUnicode_FSConverter
+PyUnicode_FSDecoder
+PyUnicode_Find
+PyUnicode_FindChar
+PyUnicode_Format
+PyUnicode_FromEncodedObject
+PyUnicode_FromFormat
+PyUnicode_FromFormatV
+PyUnicode_FromObject
+PyUnicode_FromOrdinal
+PyUnicode_FromString
+PyUnicode_FromStringAndSize
+PyUnicode_FromWideChar
+PyUnicode_GetDefaultEncoding
+PyUnicode_GetLength
+PyUnicode_GetSize
+PyUnicode_InternFromString
+PyUnicode_InternImmortal
+PyUnicode_InternInPlace
+PyUnicode_IsIdentifier
+PyUnicode_Join
+PyUnicode_Partition
+PyUnicode_RPartition
+PyUnicode_RSplit
+PyUnicode_ReadChar
+PyUnicode_Replace
+PyUnicode_Resize
+PyUnicode_RichCompare
+PyUnicode_Split
+PyUnicode_Splitlines
+PyUnicode_Substring
+PyUnicode_Tailmatch
+PyUnicode_Translate
+PyUnicode_Type
+PyUnicode_WriteChar
+PyWeakref_GetObject
+PyWeakref_NewProxy
+PyWeakref_NewRef
+PyWrapperDescr_Type
+PyWrapper_New
+PyZip_Type
+Py_AddPendingCall
+Py_AtExit
+Py_BuildValue
+Py_BytesMain
+Py_CompileString
+Py_DecRef
+Py_DecodeLocale
+Py_EncodeLocale
+Py_EndInterpreter
+Py_EnterRecursiveCall
+Py_Exit
+Py_FatalError
+Py_FileSystemDefaultEncodeErrors
+Py_FileSystemDefaultEncoding
+Py_Finalize
+Py_FinalizeEx
+Py_FrozenMain
+Py_GenericAlias
+Py_GenericAliasType
+Py_GetBuildInfo
+Py_GetCompiler
+Py_GetCopyright
+Py_GetExecPrefix
+Py_GetPath
+Py_GetPlatform
+Py_GetPrefix
+Py_GetProgramFullPath
+Py_GetProgramName
+Py_GetPythonHome
+Py_GetRecursionLimit
+Py_GetVersion
+Py_HasFileSystemDefaultEncoding
+Py_IncRef
+Py_Initialize
+Py_InitializeEx
+Py_IsInitialized
+Py_LeaveRecursiveCall
+Py_Main
+Py_MakePendingCalls
+Py_NewInterpreter
+Py_NewRef
+Py_ReprEnter
+Py_ReprLeave
+Py_SetPath
+Py_SetProgramName
+Py_SetPythonHome
+Py_SetRecursionLimit
+Py_SymtableString
+Py_UTF8Mode
+Py_VaBuildValue
+Py_XNewRef
diff --git a/Doc/glossary.rst b/Doc/glossary.rst
index 506973e964..0661c82832 100644
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -158,6 +158,18 @@ Glossary
See also :term:`text file` for a file object able to read and write
:class:`str` objects.
+ borrowed reference
+ In Python's C API, a borrowed reference is a reference to an object.
+ It does not modify the object reference count. It becomes a dangling
+ pointer if the object is destroyed. For example, a garbage collection can
+ remove the last :term:`strong reference` to the object and so destroy it.
+
+ Calling :c:func:`Py_INCREF` on the :term:`borrowed reference` is
+ recommended to convert it to a :term:`strong reference` in-place, except
+ when the object cannot be destroyed before the last usage of the borrowed
+ reference. The :c:func:`Py_NewRef` function can be used to create a new
+ :term:`strong reference`.
+
bytes-like object
An object that supports the :ref:`bufferobjects` and can
export a C-:term:`contiguous` buffer. This includes all :class:`bytes`,
@@ -1100,6 +1112,18 @@ Glossary
an :term:`expression` or one of several constructs with a keyword, such
as :keyword:`if`, :keyword:`while` or :keyword:`for`.
+ strong reference
+ In Python's C API, a strong reference is a reference to an object
+ which increments the object's reference count when it is created and
+ decrements the object's reference count when it is deleted.
+
+ The :c:func:`Py_NewRef` function can be used to create a strong reference
+ to an object. Usually, the :c:func:`Py_DECREF` function must be called on
+ the strong reference before exiting the scope of the strong reference, to
+ avoid leaking one reference.
+
+ See also :term:`borrowed reference`.
+
text encoding
A codec which encodes Unicode strings to bytes.
diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst
index 76d8e6be42..a97d10cfe6 100644
--- a/Doc/howto/argparse.rst
+++ b/Doc/howto/argparse.rst
@@ -83,7 +83,7 @@ Following is a result of running the code:
$ python3 prog.py --help
usage: prog.py [-h]
- optional arguments:
+ options:
-h, --help show this help message and exit
$ python3 prog.py --verbose
usage: prog.py [-h]
@@ -130,7 +130,7 @@ And running the code:
positional arguments:
echo
- optional arguments:
+ options:
-h, --help show this help message and exit
$ python3 prog.py foo
foo
@@ -172,7 +172,7 @@ And we get:
positional arguments:
echo echo the string you use here
- optional arguments:
+ options:
-h, --help show this help message and exit
Now, how about doing something even more useful::
@@ -241,7 +241,7 @@ And the output:
$ python3 prog.py --help
usage: prog.py [-h] [--verbosity VERBOSITY]
- optional arguments:
+ options:
-h, --help show this help message and exit
--verbosity VERBOSITY
increase output verbosity
@@ -289,7 +289,7 @@ And the output:
$ python3 prog.py --help
usage: prog.py [-h] [--verbose]
- optional arguments:
+ options:
-h, --help show this help message and exit
--verbose increase output verbosity
@@ -332,7 +332,7 @@ And here goes:
$ python3 prog.py --help
usage: prog.py [-h] [-v]
- optional arguments:
+ options:
-h, --help show this help message and exit
-v, --verbose increase output verbosity
@@ -440,7 +440,7 @@ And the output:
positional arguments:
square display a square of a given number
- optional arguments:
+ options:
-h, --help show this help message and exit
-v {0,1,2}, --verbosity {0,1,2}
increase output verbosity
@@ -468,7 +468,8 @@ verbosity argument (check the output of ``python --help``)::
print(answer)
We have introduced another action, "count",
-to count the number of occurrences of a specific optional arguments:
+to count the number of occurrences of specific options.
+
.. code-block:: shell-session
@@ -489,7 +490,7 @@ to count the number of occurrences of a specific optional arguments:
positional arguments:
square display a square of a given number
- optional arguments:
+ options:
-h, --help show this help message and exit
-v, --verbosity increase output verbosity
$ python3 prog.py 4 -vvv
@@ -626,7 +627,7 @@ Output:
x the base
y the exponent
- optional arguments:
+ options:
-h, --help show this help message and exit
-v, --verbosity
$ python3 prog.py 4 2 -v
@@ -750,7 +751,7 @@ but not both at the same time:
x the base
y the exponent
- optional arguments:
+ options:
-h, --help show this help message and exit
-v, --verbose
-q, --quiet
diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst
index fedf8a8c09..ab5a573c6a 100644
--- a/Doc/howto/descriptor.rst
+++ b/Doc/howto/descriptor.rst
@@ -16,7 +16,7 @@ storage, and deletion.
This guide has four major sections:
1) The "primer" gives a basic overview, moving gently from simple examples,
- adding one feature at a time. It is a great place to start.
+ adding one feature at a time. Start here if you're new to descriptors.
2) The second section shows a complete, practical descriptor example. If you
already know the basics, start there.
@@ -42,21 +42,27 @@ add new capabilities one by one.
Simple example: A descriptor that returns a constant
----------------------------------------------------
-The :class:`Ten` class is a descriptor that always returns the constant ``10``::
+The :class:`Ten` class is a descriptor that always returns the constant ``10``
+from its :meth:`__get__` method:
+.. testcode::
class Ten:
def __get__(self, obj, objtype=None):
return 10
-To use the descriptor, it must be stored as a class variable in another class::
+To use the descriptor, it must be stored as a class variable in another class:
+
+.. testcode::
class A:
x = 5 # Regular class attribute
y = Ten() # Descriptor instance
An interactive session shows the difference between normal attribute lookup
-and descriptor lookup::
+and descriptor lookup:
+
+.. doctest::
>>> a = A() # Make an instance of class A
>>> a.x # Normal attribute lookup
@@ -64,9 +70,11 @@ and descriptor lookup::
>>> a.y # Descriptor lookup
10
-In the ``a.x`` attribute lookup, the dot operator finds the value ``5`` stored
-in the class dictionary. In the ``a.y`` descriptor lookup, the dot operator
-calls the descriptor's :meth:`__get__()` method. That method returns ``10``.
+In the ``a.x`` attribute lookup, the dot operator finds the key ``x`` and the
+value ``5`` in the class dictionary. In the ``a.y`` lookup, the dot operator
+finds a descriptor instance, recognized by its ``__get__`` method, and calls
+that method which returns ``10``.
+
Note that the value ``10`` is not stored in either the class dictionary or the
instance dictionary. Instead, the value ``10`` is computed on demand.
@@ -79,7 +87,10 @@ In the next section, we'll create something more useful, a dynamic lookup.
Dynamic lookups
---------------
-Interesting descriptors typically run computations instead of doing lookups::
+Interesting descriptors typically run computations instead of returning
+constants:
+
+.. testcode::
import os
@@ -98,21 +109,20 @@ Interesting descriptors typically run computations instead of doing lookups::
An interactive session shows that the lookup is dynamic — it computes
different, updated answers each time::
- >>> g = Directory('games')
>>> s = Directory('songs')
+ >>> g = Directory('games')
+ >>> s.size # The songs directory has twenty files
+ 20
>>> g.size # The games directory has three files
3
- >>> os.system('touch games/newfile') # Add a fourth file to the directory
- 0
- >>> g.size # Automatically updated
+ >>> open('games/newfile').close() # Add a fourth file to the directory
+ >>> g.size # File count is automatically updated
4
- >>> s.size # The songs directory has twenty files
- 20
Besides showing how descriptors can run computations, this example also
reveals the purpose of the parameters to :meth:`__get__`. The *self*
parameter is *size*, an instance of *DirectorySize*. The *obj* parameter is
-either *g* or *s*, an instance of *Directory*. It is *obj* parameter that
+either *g* or *s*, an instance of *Directory*. It is the *obj* parameter that
lets the :meth:`__get__` method learn the target directory. The *objtype*
parameter is the class *Directory*.
@@ -128,7 +138,9 @@ the public attribute is accessed.
In the following example, *age* is the public attribute and *_age* is the
private attribute. When the public attribute is accessed, the descriptor logs
-the lookup or update::
+the lookup or update:
+
+.. testcode::
import logging
@@ -158,7 +170,15 @@ the lookup or update::
An interactive session shows that all access to the managed attribute *age* is
-logged, but that the regular attribute *name* is not logged::
+logged, but that the regular attribute *name* is not logged:
+
+.. testcode::
+ :hide:
+
+ import logging, sys
+ logging.basicConfig(level=logging.INFO, stream=sys.stdout, force=True)
+
+.. doctest::
>>> mary = Person('Mary M', 30) # The initial age update is logged
INFO:root:Updating 'age' to 30
@@ -183,7 +203,7 @@ logged, but that the regular attribute *name* is not logged::
INFO:root:Accessing 'age' giving 40
40
-One major issue with this example is the private name *_age* is hardwired in
+One major issue with this example is that the private name *_age* is hardwired in
the *LoggedAgeAccess* class. That means that each instance can only have one
logged attribute and that its name is unchangeable. In the next example,
we'll fix that problem.
@@ -192,13 +212,15 @@ we'll fix that problem.
Customized names
----------------
-When a class uses descriptors, it can inform each descriptor about what
+When a class uses descriptors, it can inform each descriptor about which
variable name was used.
In this example, the :class:`Person` class has two descriptor instances,
*name* and *age*. When the :class:`Person` class is defined, it makes a
callback to :meth:`__set_name__` in *LoggedAccess* so that the field names can
-be recorded, giving each descriptor its own *public_name* and *private_name*::
+be recorded, giving each descriptor its own *public_name* and *private_name*:
+
+.. testcode::
import logging
@@ -208,7 +230,7 @@ be recorded, giving each descriptor its own *public_name* and *private_name*::
def __set_name__(self, owner, name):
self.public_name = name
- self.private_name = f'_{name}'
+ self.private_name = '_' + name
def __get__(self, obj, objtype=None):
value = getattr(obj, self.private_name)
@@ -233,14 +255,24 @@ be recorded, giving each descriptor its own *public_name* and *private_name*::
An interactive session shows that the :class:`Person` class has called
:meth:`__set_name__` so that the field names would be recorded. Here
-we call :func:`vars` to lookup the descriptor without triggering it::
+we call :func:`vars` to look up the descriptor without triggering it:
+
+.. doctest::
>>> vars(vars(Person)['name'])
{'public_name': 'name', 'private_name': '_name'}
>>> vars(vars(Person)['age'])
{'public_name': 'age', 'private_name': '_age'}
-The new class now logs access to both *name* and *age*::
+The new class now logs access to both *name* and *age*:
+
+.. testcode::
+ :hide:
+
+ import logging, sys
+ logging.basicConfig(level=logging.INFO, stream=sys.stdout, force=True)
+
+.. doctest::
>>> pete = Person('Peter P', 10)
INFO:root:Updating 'name' to 'Peter P'
@@ -265,9 +297,10 @@ A :term:`descriptor` is what we call any object that defines :meth:`__get__`,
Optionally, descriptors can have a :meth:`__set_name__` method. This is only
used in cases where a descriptor needs to know either the class where it was
-created or the name of class variable it was assigned to.
+created or the name of class variable it was assigned to. (This method, if
+present, is called even if the class is not a descriptor.)
-Descriptors get invoked by the dot operator during attribute lookup. If a
+Descriptors get invoked by the dot "operator" during attribute lookup. If a
descriptor is accessed indirectly with ``vars(some_class)[descriptor_name]``,
the descriptor instance is returned without invoking it.
@@ -275,7 +308,7 @@ Descriptors only work when used as class variables. When put in instances,
they have no effect.
The main motivation for descriptors is to provide a hook allowing objects
-stored in class variables to control what happens during dotted lookup.
+stored in class variables to control what happens during attribute lookup.
Traditionally, the calling class controls what happens during lookup.
Descriptors invert that relationship and allow the data being looked-up to
@@ -303,14 +336,16 @@ restrictions. If those restrictions aren't met, it raises an exception to
prevent data corruption at its source.
This :class:`Validator` class is both an :term:`abstract base class` and a
-managed attribute descriptor::
+managed attribute descriptor:
+
+.. testcode::
from abc import ABC, abstractmethod
class Validator(ABC):
def __set_name__(self, owner, name):
- self.private_name = f'_{name}'
+ self.private_name = '_' + name
def __get__(self, obj, objtype=None):
return getattr(obj, self.private_name)
@@ -343,7 +378,7 @@ Here are three practical data validation utilities:
user-defined `predicate
<https://en.wikipedia.org/wiki/Predicate_(mathematical_logic)>`_ as well.
-::
+.. testcode::
class OneOf(Validator):
@@ -396,10 +431,12 @@ Here are three practical data validation utilities:
)
-Practical use
--------------
+Practical application
+---------------------
+
+Here's how the data validators can be used in a real class:
-Here's how the data validators can be used in a real class::
+.. testcode::
class Component:
@@ -412,13 +449,30 @@ Here's how the data validators can be used in a real class::
self.kind = kind
self.quantity = quantity
-The descriptors prevent invalid instances from being created::
+The descriptors prevent invalid instances from being created:
+
+.. doctest::
+
+ >>> Component('Widget', 'metal', 5) # Blocked: 'Widget' is not all uppercase
+ Traceback (most recent call last):
+ ...
+ ValueError: Expected <method 'isupper' of 'str' objects> to be true for 'Widget'
- Component('WIDGET', 'metal', 5) # Allowed.
- Component('Widget', 'metal', 5) # Blocked: 'Widget' is not all uppercase
- Component('WIDGET', 'metle', 5) # Blocked: 'metle' is misspelled
- Component('WIDGET', 'metal', -5) # Blocked: -5 is negative
- Component('WIDGET', 'metal', 'V') # Blocked: 'V' isn't a number
+ >>> Component('WIDGET', 'metle', 5) # Blocked: 'metle' is misspelled
+ Traceback (most recent call last):
+ ...
+ ValueError: Expected 'metle' to be one of {'metal', 'plastic', 'wood'}
+
+ >>> Component('WIDGET', 'metal', -5) # Blocked: -5 is negative
+ Traceback (most recent call last):
+ ...
+ ValueError: Expected -5 to be at least 0
+ >>> Component('WIDGET', 'metal', 'V') # Blocked: 'V' isn't a number
+ Traceback (most recent call last):
+ ...
+ TypeError: Expected 'V' to be an int or float
+
+ >>> c = Component('WIDGET', 'metal', 5) # Allowed: The inputs are valid
Technical Tutorial
@@ -435,23 +489,21 @@ Defines descriptors, summarizes the protocol, and shows how descriptors are
called. Provides an example showing how object relational mappings work.
Learning about descriptors not only provides access to a larger toolset, it
-creates a deeper understanding of how Python works and an appreciation for the
-elegance of its design.
+creates a deeper understanding of how Python works.
Definition and introduction
---------------------------
-In general, a descriptor is an object attribute with "binding behavior", one
-whose attribute access has been overridden by methods in the descriptor
-protocol. Those methods are :meth:`__get__`, :meth:`__set__`, and
-:meth:`__delete__`. If any of those methods are defined for an object, it is
-said to be a :term:`descriptor`.
+In general, a descriptor is an attribute value that has one of the methods in
+the descriptor protocol. Those methods are :meth:`__get__`, :meth:`__set__`,
+and :meth:`__delete__`. If any of those methods are defined for an the
+attribute, it is said to be a :term:`descriptor`.
The default behavior for attribute access is to get, set, or delete the
attribute from an object's dictionary. For instance, ``a.x`` has a lookup chain
starting with ``a.__dict__['x']``, then ``type(a).__dict__['x']``, and
-continuing through the base classes of ``type(a)``. If the
+continuing through the method resolution order of ``type(a)``. If the
looked-up value is an object defining one of the descriptor methods, then Python
may override the default behavior and invoke the descriptor method instead.
Where this occurs in the precedence chain depends on which descriptor methods
@@ -479,7 +531,7 @@ as an attribute.
If an object defines :meth:`__set__` or :meth:`__delete__`, it is considered
a data descriptor. Descriptors that only define :meth:`__get__` are called
-non-data descriptors (they are typically used for methods but other uses are
+non-data descriptors (they are often used for methods but other uses are
possible).
Data and non-data descriptors differ in how overrides are calculated with
@@ -504,8 +556,9 @@ But it is more common for a descriptor to be invoked automatically from
attribute access.
The expression ``obj.x`` looks up the attribute ``x`` in the chain of
-namespaces for ``obj``. If the search finds a descriptor, its :meth:`__get__`
-method is invoked according to the precedence rules listed below.
+namespaces for ``obj``. If the search finds a descriptor outside of the
+instance ``__dict__``, its :meth:`__get__` method is invoked according to the
+precedence rules listed below.
The details of invocation depend on whether ``obj`` is an object, class, or
instance of super.
@@ -523,31 +576,145 @@ If a descriptor is found for ``a.x``, then it is invoked with:
``desc.__get__(a, type(a))``.
The logic for a dotted lookup is in :meth:`object.__getattribute__`. Here is
-a pure Python equivalent::
+a pure Python equivalent:
+
+.. testcode::
def object_getattribute(obj, name):
"Emulate PyObject_GenericGetAttr() in Objects/object.c"
null = object()
objtype = type(obj)
- value = getattr(objtype, name, null)
- if value is not null and hasattr(value, '__get__'):
- if hasattr(value, '__set__') or hasattr(value, '__delete__'):
- return value.__get__(obj, objtype) # data descriptor
- try:
- return vars(obj)[name] # instance variable
- except (KeyError, TypeError):
- pass
- if hasattr(value, '__get__'):
- return value.__get__(obj, objtype) # non-data descriptor
- if value is not null:
- return value # class variable
- # Emulate slot_tp_getattr_hook() in Objects/typeobject.c
- if hasattr(objtype, '__getattr__'):
- return objtype.__getattr__(obj, name) # __getattr__ hook
+ cls_var = getattr(objtype, name, null)
+ descr_get = getattr(type(cls_var), '__get__', null)
+ if descr_get is not null:
+ if (hasattr(type(cls_var), '__set__')
+ or hasattr(type(cls_var), '__delete__')):
+ return descr_get(cls_var, obj, objtype) # data descriptor
+ if hasattr(obj, '__dict__') and name in vars(obj):
+ return vars(obj)[name] # instance variable
+ if descr_get is not null:
+ return descr_get(cls_var, obj, objtype) # non-data descriptor
+ if cls_var is not null:
+ return cls_var # class variable
raise AttributeError(name)
-The :exc:`TypeError` exception handler is needed because the instance dictionary
-doesn't exist when its class defines :term:`__slots__`.
+
+.. testcode::
+ :hide:
+
+ # Test the fidelity of object_getattribute() by comparing it with the
+ # normal object.__getattribute__(). The former will be accessed by
+ # square brackets and the latter by the dot operator.
+
+ class Object:
+
+ def __getitem__(obj, name):
+ try:
+ return object_getattribute(obj, name)
+ except AttributeError:
+ if not hasattr(type(obj), '__getattr__'):
+ raise
+ return type(obj).__getattr__(obj, name) # __getattr__
+
+ class DualOperator(Object):
+
+ x = 10
+
+ def __init__(self, z):
+ self.z = z
+
+ @property
+ def p2(self):
+ return 2 * self.x
+
+ @property
+ def p3(self):
+ return 3 * self.x
+
+ def m5(self, y):
+ return 5 * y
+
+ def m7(self, y):
+ return 7 * y
+
+ def __getattr__(self, name):
+ return ('getattr_hook', self, name)
+
+ class DualOperatorWithSlots:
+
+ __getitem__ = Object.__getitem__
+
+ __slots__ = ['z']
+
+ x = 15
+
+ def __init__(self, z):
+ self.z = z
+
+ @property
+ def p2(self):
+ return 2 * self.x
+
+ def m5(self, y):
+ return 5 * y
+
+ def __getattr__(self, name):
+ return ('getattr_hook', self, name)
+
+
+.. doctest::
+ :hide:
+
+ >>> a = DualOperator(11)
+ >>> vars(a).update(p3 = '_p3', m7 = '_m7')
+ >>> a.x == a['x'] == 10
+ True
+ >>> a.z == a['z'] == 11
+ True
+ >>> a.p2 == a['p2'] == 20
+ True
+ >>> a.p3 == a['p3'] == 30
+ True
+ >>> a.m5(100) == a.m5(100) == 500
+ True
+ >>> a.m7 == a['m7'] == '_m7'
+ True
+ >>> a.g == a['g'] == ('getattr_hook', a, 'g')
+ True
+
+ >>> b = DualOperatorWithSlots(22)
+ >>> b.x == b['x'] == 15
+ True
+ >>> b.z == b['z'] == 22
+ True
+ >>> b.p2 == b['p2'] == 30
+ True
+ >>> b.m5(200) == b['m5'](200) == 1000
+ True
+ >>> b.g == b['g'] == ('getattr_hook', b, 'g')
+ True
+
+
+Interestingly, attribute lookup doesn't call :meth:`object.__getattribute__`
+directly. Instead, both the dot operator and the :func:`getattr` function
+perform attribute lookup by way of a helper function:
+
+.. testcode::
+
+ def getattr_hook(obj, name):
+ "Emulate slot_tp_getattr_hook() in Objects/typeobject.c"
+ try:
+ return obj.__getattribute__(name)
+ except AttributeError:
+ if not hasattr(type(obj), '__getattr__'):
+ raise
+ return type(obj).__getattr__(obj, name) # __getattr__
+
+So if :meth:`__getattr__` exists, it is called whenever :meth:`__getattribute__`
+raises :exc:`AttributeError` (either directly or in one of the descriptor calls).
+
+Also, if a user calls :meth:`object.__getattribute__` directly, the
+:meth:`__getattr__` hook is bypassed entirely.
Invocation from a class
@@ -614,8 +781,8 @@ Sometimes it is desirable for a descriptor to know what class variable name it
was assigned to. When a new class is created, the :class:`type` metaclass
scans the dictionary of the new class. If any of the entries are descriptors
and if they define :meth:`__set_name__`, that method is called with two
-arguments. The *owner* is the class where the descriptor is used, the *name*
-is class variable the descriptor was assigned to.
+arguments. The *owner* is the class where the descriptor is used, and the
+*name* is the class variable the descriptor was assigned to.
The implementation details are in :c:func:`type_new()` and
:c:func:`set_names()` in :source:`Objects/typeobject.c`.
@@ -634,7 +801,9 @@ be used to implement an `object relational mapping
The essential idea is that the data is stored in an external database. The
Python instances only hold keys to the database's tables. Descriptors take
-care of lookups or updates::
+care of lookups or updates:
+
+.. testcode::
class Field:
@@ -649,8 +818,11 @@ care of lookups or updates::
conn.execute(self.store, [value, obj.key])
conn.commit()
-We can use the :class:`Field` class to define "models" that describe the schema
-for each table in a database::
+We can use the :class:`Field` class to define `models
+<https://en.wikipedia.org/wiki/Database_model>`_ that describe the schema for
+each table in a database:
+
+.. testcode::
class Movie:
table = 'Movies' # Table name
@@ -671,12 +843,41 @@ for each table in a database::
def __init__(self, key):
self.key = key
-An interactive session shows how data is retrieved from the database and how
-it can be updated::
+To use the models, first connect to the database::
>>> import sqlite3
>>> conn = sqlite3.connect('entertainment.db')
+An interactive session shows how data is retrieved from the database and how
+it can be updated:
+
+.. testsetup::
+
+ song_data = [
+ ('Country Roads', 'John Denver', 1972),
+ ('Me and Bobby McGee', 'Janice Joplin', 1971),
+ ('Coal Miners Daughter', 'Loretta Lynn', 1970),
+ ]
+
+ movie_data = [
+ ('Star Wars', 'George Lucas', 1977),
+ ('Jaws', 'Steven Spielberg', 1975),
+ ('Aliens', 'James Cameron', 1986),
+ ]
+
+ import sqlite3
+
+ conn = sqlite3.connect(':memory:')
+ conn.execute('CREATE TABLE Music (title text, artist text, year integer);')
+ conn.execute('CREATE INDEX MusicNdx ON Music (title);')
+ conn.executemany('INSERT INTO Music VALUES (?, ?, ?);', song_data)
+ conn.execute('CREATE TABLE Movies (title text, director text, year integer);')
+ conn.execute('CREATE INDEX MovieNdx ON Music (title);')
+ conn.executemany('INSERT INTO Movies VALUES (?, ?, ?);', movie_data)
+ conn.commit()
+
+.. doctest::
+
>>> Movie('Star Wars').director
'George Lucas'
>>> jaws = Movie('Jaws')
@@ -690,6 +891,7 @@ it can be updated::
>>> Movie('Star Wars').director
'J.J. Abrams'
+
Pure Python Equivalents
^^^^^^^^^^^^^^^^^^^^^^^
@@ -703,11 +905,13 @@ Properties
----------
Calling :func:`property` is a succinct way of building a data descriptor that
-triggers function calls upon access to an attribute. Its signature is::
+triggers a function call upon access to an attribute. Its signature is::
property(fget=None, fset=None, fdel=None, doc=None) -> property
-The documentation shows a typical use to define a managed attribute ``x``::
+The documentation shows a typical use to define a managed attribute ``x``:
+
+.. testcode::
class C:
def getx(self): return self.__x
@@ -716,7 +920,9 @@ The documentation shows a typical use to define a managed attribute ``x``::
x = property(getx, setx, delx, "I'm the 'x' property.")
To see how :func:`property` is implemented in terms of the descriptor protocol,
-here is a pure Python equivalent::
+here is a pure Python equivalent:
+
+.. testcode::
class Property:
"Emulate PyProperty_Type() in Objects/descrobject.c"
@@ -755,6 +961,57 @@ here is a pure Python equivalent::
def deleter(self, fdel):
return type(self)(self.fget, self.fset, fdel, self.__doc__)
+.. testcode::
+ :hide:
+
+ # Verify the Property() emulation
+
+ class CC:
+ def getx(self):
+ return self.__x
+ def setx(self, value):
+ self.__x = value
+ def delx(self):
+ del self.__x
+ x = Property(getx, setx, delx, "I'm the 'x' property.")
+
+ # Now do it again but use the decorator style
+
+ class CCC:
+ @Property
+ def x(self):
+ return self.__x
+ @x.setter
+ def x(self, value):
+ self.__x = value
+ @x.deleter
+ def x(self):
+ del self.__x
+
+
+.. doctest::
+ :hide:
+
+ >>> cc = CC()
+ >>> hasattr(cc, 'x')
+ False
+ >>> cc.x = 33
+ >>> cc.x
+ 33
+ >>> del cc.x
+ >>> hasattr(cc, 'x')
+ False
+
+ >>> ccc = CCC()
+ >>> hasattr(ccc, 'x')
+ False
+ >>> ccc.x = 333
+ >>> ccc.x == 333
+ True
+ >>> del ccc.x
+ >>> hasattr(ccc, 'x')
+ False
+
The :func:`property` builtin helps whenever a user interface has granted
attribute access and then subsequent changes require the intervention of a
method.
@@ -763,7 +1020,9 @@ For instance, a spreadsheet class may grant access to a cell value through
``Cell('b10').value``. Subsequent improvements to the program require the cell
to be recalculated on every access; however, the programmer does not want to
affect existing client code accessing the attribute directly. The solution is
-to wrap access to the value attribute in a property data descriptor::
+to wrap access to the value attribute in a property data descriptor:
+
+.. testcode::
class Cell:
...
@@ -774,6 +1033,9 @@ to wrap access to the value attribute in a property data descriptor::
self.recalc()
return self._value
+Either the built-in :func:`property` or our :func:`Property` equivalent would
+work in this example.
+
Functions and methods
---------------------
@@ -787,7 +1049,9 @@ prepended to the other arguments. By convention, the instance is called
*self* but could be called *this* or any other variable name.
Methods can be created manually with :class:`types.MethodType` which is
-roughly equivalent to::
+roughly equivalent to:
+
+.. testcode::
class MethodType:
"Emulate Py_MethodType in Objects/classobject.c"
@@ -803,8 +1067,10 @@ roughly equivalent to::
To support automatic creation of methods, functions include the
:meth:`__get__` method for binding methods during attribute access. This
-means that functions are non-data descriptors which return bound methods
-during dotted lookup from an instance. Here's how it works::
+means that functions are non-data descriptors that return bound methods
+during dotted lookup from an instance. Here's how it works:
+
+.. testcode::
class Function:
...
@@ -816,13 +1082,17 @@ during dotted lookup from an instance. Here's how it works::
return MethodType(self, obj)
Running the following class in the interpreter shows how the function
-descriptor works in practice::
+descriptor works in practice:
+
+.. testcode::
class D:
def f(self, x):
return x
-The function has a :term:`qualified name` attribute to support introspection::
+The function has a :term:`qualified name` attribute to support introspection:
+
+.. doctest::
>>> D.f.__qualname__
'D.f'
@@ -850,7 +1120,7 @@ Internally, the bound method stores the underlying function and the bound
instance::
>>> d.f.__func__
- <function D.f at 0x1012e5ae8>
+ <function D.f at 0x00C45070>
>>> d.f.__self__
<__main__.D object at 0x1012e1f98>
@@ -902,20 +1172,26 @@ It can be called either from an object or the class: ``s.erf(1.5) --> .9332`` o
``Sample.erf(1.5) --> .9332``.
Since static methods return the underlying function with no changes, the
-example calls are unexciting::
+example calls are unexciting:
+
+.. testcode::
class E:
@staticmethod
def f(x):
print(x)
+.. doctest::
+
>>> E.f(3)
3
>>> E().f(3)
3
Using the non-data descriptor protocol, a pure Python version of
-:func:`staticmethod` would look like this::
+:func:`staticmethod` would look like this:
+
+.. doctest::
class StaticMethod:
"Emulate PyStaticMethod_Type() in Objects/funcobject.c"
@@ -932,27 +1208,31 @@ Class methods
Unlike static methods, class methods prepend the class reference to the
argument list before calling the function. This format is the same
-for whether the caller is an object or a class::
+for whether the caller is an object or a class:
+
+.. testcode::
class F:
@classmethod
def f(cls, x):
return cls.__name__, x
- >>> print(F.f(3))
+.. doctest::
+
+ >>> F.f(3)
('F', 3)
- >>> print(F().f(3))
+ >>> F().f(3)
('F', 3)
This behavior is useful whenever the method only needs to have a class
-reference and does rely on data stored in a specific instance. One use for
+reference and does not rely on data stored in a specific instance. One use for
class methods is to create alternate class constructors. For example, the
classmethod :func:`dict.fromkeys` creates a new dictionary from a list of
-keys. The pure Python equivalent is::
+keys. The pure Python equivalent is:
- class Dict:
- ...
+.. testcode::
+ class Dict(dict):
@classmethod
def fromkeys(cls, iterable, value=None):
"Emulate dict_fromkeys() in Objects/dictobject.c"
@@ -961,13 +1241,20 @@ keys. The pure Python equivalent is::
d[key] = value
return d
-Now a new dictionary of unique keys can be constructed like this::
+Now a new dictionary of unique keys can be constructed like this:
+
+.. doctest::
- >>> Dict.fromkeys('abracadabra')
- {'a': None, 'r': None, 'b': None, 'c': None, 'd': None}
+ >>> d = Dict.fromkeys('abracadabra')
+ >>> type(d) is Dict
+ True
+ >>> d
+ {'a': None, 'b': None, 'r': None, 'c': None, 'd': None}
Using the non-data descriptor protocol, a pure Python version of
-:func:`classmethod` would look like this::
+:func:`classmethod` would look like this:
+
+.. testcode::
class ClassMethod:
"Emulate PyClassMethod_Type() in Objects/funcobject.c"
@@ -982,9 +1269,31 @@ Using the non-data descriptor protocol, a pure Python version of
return self.f.__get__(cls)
return MethodType(self.f, cls)
+.. testcode::
+ :hide:
+
+ # Verify the emulation works
+ class T:
+ @ClassMethod
+ def cm(cls, x, y):
+ return (cls, x, y)
+
+.. doctest::
+ :hide:
+
+ >>> T.cm(11, 22)
+ (<class 'T'>, 11, 22)
+
+ # Also call it from an instance
+ >>> t = T()
+ >>> t.cm(11, 22)
+ (<class 'T'>, 11, 22)
+
The code path for ``hasattr(obj, '__get__')`` was added in Python 3.9 and
makes it possible for :func:`classmethod` to support chained decorators.
-For example, a classmethod and property could be chained together::
+For example, a classmethod and property could be chained together:
+
+.. testcode::
class G:
@classmethod
@@ -992,6 +1301,12 @@ For example, a classmethod and property could be chained together::
def __doc__(cls):
return f'A doc for {cls.__name__!r}'
+.. doctest::
+
+ >>> G.__doc__
+ "A doc for 'G'"
+
+
Member objects and __slots__
----------------------------
@@ -1000,11 +1315,15 @@ fixed-length array of slot values. From a user point of view that has
several effects:
1. Provides immediate detection of bugs due to misspelled attribute
-assignments. Only attribute names specified in ``__slots__`` are allowed::
+assignments. Only attribute names specified in ``__slots__`` are allowed:
+
+.. testcode::
class Vehicle:
__slots__ = ('id_number', 'make', 'model')
+.. doctest::
+
>>> auto = Vehicle()
>>> auto.id_nubmer = 'VYE483814LQEX'
Traceback (most recent call last):
@@ -1012,11 +1331,13 @@ assignments. Only attribute names specified in ``__slots__`` are allowed::
AttributeError: 'Vehicle' object has no attribute 'id_nubmer'
2. Helps create immutable objects where descriptors manage access to private
-attributes stored in ``__slots__``::
+attributes stored in ``__slots__``:
+
+.. testcode::
class Immutable:
- __slots__ = ('_dept', '_name') # Replace instance dictionary
+ __slots__ = ('_dept', '_name') # Replace the instance dictionary
def __init__(self, dept, name):
self._dept = dept # Store to private attribute
@@ -1030,7 +1351,19 @@ attributes stored in ``__slots__``::
def name(self): # Read-only descriptor
return self._name
- mark = Immutable('Botany', 'Mark Watney') # Create an immutable instance
+.. doctest::
+
+ >>> mark = Immutable('Botany', 'Mark Watney')
+ >>> mark.dept
+ 'Botany'
+ >>> mark.dept = 'Space Pirate'
+ Traceback (most recent call last):
+ ...
+ AttributeError: can't set attribute
+ >>> mark.location = 'Mars'
+ Traceback (most recent call last):
+ ...
+ AttributeError: 'Immutable' object has no attribute 'location'
3. Saves memory. On a 64-bit Linux build, an instance with two attributes
takes 48 bytes with ``__slots__`` and 152 bytes without. This `flyweight
@@ -1038,7 +1371,9 @@ design pattern <https://en.wikipedia.org/wiki/Flyweight_pattern>`_ likely only
matters when a large number of instances are going to be created.
4. Blocks tools like :func:`functools.cached_property` which require an
-instance dictionary to function correctly::
+instance dictionary to function correctly:
+
+.. testcode::
from functools import cached_property
@@ -1050,17 +1385,23 @@ instance dictionary to function correctly::
return 4 * sum((-1.0)**n / (2.0*n + 1.0)
for n in reversed(range(100_000)))
+.. doctest::
+
>>> CP().pi
Traceback (most recent call last):
...
TypeError: No '__dict__' attribute on 'CP' instance to cache 'pi' property.
-It's not possible to create an exact drop-in pure Python version of
+It is not possible to create an exact drop-in pure Python version of
``__slots__`` because it requires direct access to C structures and control
over object memory allocation. However, we can build a mostly faithful
simulation where the actual C structure for slots is emulated by a private
``_slotvalues`` list. Reads and writes to that private structure are managed
-by member descriptors::
+by member descriptors:
+
+.. testcode::
+
+ null = object()
class Member:
@@ -1074,20 +1415,30 @@ by member descriptors::
def __get__(self, obj, objtype=None):
'Emulate member_get() in Objects/descrobject.c'
# Also see PyMember_GetOne() in Python/structmember.c
- return obj._slotvalues[self.offset]
+ value = obj._slotvalues[self.offset]
+ if value is null:
+ raise AttributeError(self.name)
+ return value
def __set__(self, obj, value):
'Emulate member_set() in Objects/descrobject.c'
obj._slotvalues[self.offset] = value
+ def __delete__(self, obj):
+ 'Emulate member_delete() in Objects/descrobject.c'
+ value = obj._slotvalues[self.offset]
+ if value is null:
+ raise AttributeError(self.name)
+ obj._slotvalues[self.offset] = null
+
def __repr__(self):
'Emulate member_repr() in Objects/descrobject.c'
return f'<Member {self.name!r} of {self.clsname!r}>'
The :meth:`type.__new__` method takes care of adding member objects to class
-variables. The :meth:`object.__new__` method takes care of creating instances
-that have slots instead of a instance dictionary. Here is a rough equivalent
-in pure Python::
+variables:
+
+.. testcode::
class Type(type):
'Simulate how the type metaclass adds member objects for slots'
@@ -1100,6 +1451,12 @@ in pure Python::
mapping[name] = Member(name, clsname, offset)
return type.__new__(mcls, clsname, bases, mapping)
+The :meth:`object.__new__` method takes care of creating instances that have
+slots instead of an instance dictionary. Here is a rough simulation in pure
+Python:
+
+.. testcode::
+
class Object:
'Simulate how object.__new__() allocates memory for __slots__'
@@ -1107,13 +1464,35 @@ in pure Python::
'Emulate object_new() in Objects/typeobject.c'
inst = super().__new__(cls)
if hasattr(cls, 'slot_names'):
- inst._slotvalues = [None] * len(cls.slot_names)
+ empty_slots = [null] * len(cls.slot_names)
+ object.__setattr__(inst, '_slotvalues', empty_slots)
return inst
+ def __setattr__(self, name, value):
+ 'Emulate _PyObject_GenericSetAttrWithDict() Objects/object.c'
+ cls = type(self)
+ if hasattr(cls, 'slot_names') and name not in cls.slot_names:
+ raise AttributeError(
+ f'{type(self).__name__!r} object has no attribute {name!r}'
+ )
+ super().__setattr__(name, value)
+
+ def __delattr__(self, name):
+ 'Emulate _PyObject_GenericSetAttrWithDict() Objects/object.c'
+ cls = type(self)
+ if hasattr(cls, 'slot_names') and name not in cls.slot_names:
+ raise AttributeError(
+ f'{type(self).__name__!r} object has no attribute {name!r}'
+ )
+ super().__delattr__(name)
+
To use the simulation in a real class, just inherit from :class:`Object` and
-set the :term:`metaclass` to :class:`Type`::
+set the :term:`metaclass` to :class:`Type`:
+
+.. testcode::
class H(Object, metaclass=Type):
+ 'Instance variables stored in slots'
slot_names = ['x', 'y']
@@ -1123,17 +1502,29 @@ set the :term:`metaclass` to :class:`Type`::
At this point, the metaclass has loaded member objects for *x* and *y*::
- >>> import pprint
- >>> pprint.pp(dict(vars(H)))
+ >>> from pprint import pp
+ >>> pp(dict(vars(H)))
{'__module__': '__main__',
+ '__doc__': 'Instance variables stored in slots',
'slot_names': ['x', 'y'],
'__init__': <function H.__init__ at 0x7fb5d302f9d0>,
'x': <Member 'x' of 'H'>,
- 'y': <Member 'y' of 'H'>,
- '__doc__': None}
+ 'y': <Member 'y' of 'H'>}
+
+.. doctest::
+ :hide:
+
+ # We test this separately because the preceding section is not
+ # doctestable due to the hex memory address for the __init__ function
+ >>> isinstance(vars(H)['x'], Member)
+ True
+ >>> isinstance(vars(H)['y'], Member)
+ True
When instances are created, they have a ``slot_values`` list where the
-attributes are stored::
+attributes are stored:
+
+.. doctest::
>>> h = H(10, 20)
>>> vars(h)
@@ -1142,8 +1533,30 @@ attributes are stored::
>>> vars(h)
{'_slotvalues': [55, 20]}
-Unlike the real ``__slots__``, this simulation does have an instance
-dictionary just to hold the ``_slotvalues`` array. So, unlike the real code,
-this simulation doesn't block assignments to misspelled attributes::
+Misspelled or unassigned attributes will raise an exception:
+
+.. doctest::
- >>> h.xz = 30 # For actual __slots__ this would raise an AttributeError
+ >>> h.xz
+ Traceback (most recent call last):
+ ...
+ AttributeError: 'H' object has no attribute 'xz'
+
+.. doctest::
+ :hide:
+
+ # Examples for deleted attributes are not shown because this section
+ # is already a bit lengthy. We still test that code here.
+ >>> del h.x
+ >>> hasattr(h, 'x')
+ False
+
+ # Also test the code for uninitialized slots
+ >>> class HU(Object, metaclass=Type):
+ ... slot_names = ['x', 'y']
+ ...
+ >>> hu = HU()
+ >>> hasattr(hu, 'x')
+ False
+ >>> hasattr(hu, 'y')
+ False
diff --git a/Doc/library/abc.rst b/Doc/library/abc.rst
index 3a7414d735..1a6ed474ff 100644
--- a/Doc/library/abc.rst
+++ b/Doc/library/abc.rst
@@ -336,6 +336,7 @@ The :mod:`abc` module also provides the following functions:
.. versionadded:: 3.4
.. function:: update_abstractmethods(cls)
+
A function to recalculate an abstract class's abstraction status. This
function should be called if a class's abstract methods have been
implemented or changed after it was created. Usually, this function should
@@ -343,7 +344,7 @@ The :mod:`abc` module also provides the following functions:
Returns *cls*, to allow usage as a class decorator.
- If *cls* is not an instance of ABCMeta, does nothing.
+ If *cls* is not an instance of :class:`ABCMeta`, does nothing.
.. note::
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index 7a7a4cf949..80e0f013df 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -57,7 +57,7 @@ be run at the command line and provides useful help messages:
positional arguments:
N an integer for the accumulator
- optional arguments:
+ options:
-h, --help show this help message and exit
--sum sum the integers (default: find the max)
@@ -217,14 +217,14 @@ The help for this program will display ``myprogram.py`` as the program name
$ python myprogram.py --help
usage: myprogram.py [-h] [--foo FOO]
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO foo help
$ cd ..
$ python subdir/myprogram.py --help
usage: myprogram.py [-h] [--foo FOO]
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO foo help
@@ -235,7 +235,7 @@ To change this default behavior, another value can be supplied using the
>>> parser.print_help()
usage: myprogram [-h]
- optional arguments:
+ options:
-h, --help show this help message and exit
Note that the program name, whether determined from ``sys.argv[0]`` or from the
@@ -249,7 +249,7 @@ specifier.
>>> parser.print_help()
usage: myprogram [-h] [--foo FOO]
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO foo of the myprogram program
@@ -269,7 +269,7 @@ arguments it contains::
positional arguments:
bar bar help
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo [FOO] foo help
@@ -284,7 +284,7 @@ The default message can be overridden with the ``usage=`` keyword argument::
positional arguments:
bar bar help
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo [FOO] foo help
@@ -307,7 +307,7 @@ various arguments::
A foo that bars
- optional arguments:
+ options:
-h, --help show this help message and exit
By default, the description will be line-wrapped so that it fits within the
@@ -329,7 +329,7 @@ argument to :class:`ArgumentParser`::
A foo that bars
- optional arguments:
+ options:
-h, --help show this help message and exit
And that's how you'd foo a bar
@@ -403,7 +403,7 @@ epilog_ texts in command-line help messages::
this description was indented weird but that is okay
- optional arguments:
+ options:
-h, --help show this help message and exit
likewise for this epilog whose whitespace will be cleaned up and whose words
@@ -432,7 +432,7 @@ should not be line-wrapped::
exactly the way
I want it
- optional arguments:
+ options:
-h, --help show this help message and exit
:class:`RawTextHelpFormatter` maintains whitespace for all sorts of help text,
@@ -454,7 +454,7 @@ default values to each of the argument help messages::
positional arguments:
bar BAR! (default: [1, 2, 3])
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO FOO! (default: 42)
@@ -473,7 +473,7 @@ as the regular formatter does)::
positional arguments:
float
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo int
@@ -592,7 +592,7 @@ older arguments with the same option string. To get this behavior, the value
>>> parser.print_help()
usage: PROG [-h] [-f FOO] [--foo FOO]
- optional arguments:
+ options:
-h, --help show this help message and exit
-f FOO old foo help
--foo FOO new foo help
@@ -623,7 +623,7 @@ help will be printed:
$ python myprogram.py --help
usage: myprogram.py [-h] [--foo FOO]
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO foo help
@@ -636,7 +636,7 @@ This can be achieved by passing ``False`` as the ``add_help=`` argument to
>>> parser.print_help()
usage: PROG [--foo FOO]
- optional arguments:
+ options:
--foo FOO foo help
The help option is typically ``-h/--help``. The exception to this is
@@ -649,7 +649,7 @@ the help options::
>>> parser.print_help()
usage: PROG [+h]
- optional arguments:
+ options:
+h, ++help show this help message and exit
@@ -696,7 +696,7 @@ The add_argument() method
* const_ - A constant value required by some action_ and nargs_ selections.
* default_ - The value produced if the argument is absent from the
- command line.
+ command line and if it is absent from the namespace object.
* type_ - The type to which the command-line argument should be converted.
@@ -1006,6 +1006,14 @@ was not present at the command line::
>>> parser.parse_args([])
Namespace(foo=42)
+If the target namespace already has an attribute set, the action *default*
+will not over write it::
+
+ >>> parser = argparse.ArgumentParser()
+ >>> parser.add_argument('--foo', default=42)
+ >>> parser.parse_args([], namespace=argparse.Namespace(foo=101))
+ Namespace(foo=101)
+
If the ``default`` value is a string, the parser parses the value as if it
were a command-line argument. In particular, the parser applies any type_
conversion argument, if provided, before setting the attribute on the
@@ -1042,63 +1050,70 @@ command-line argument was not present::
type
^^^^
-By default, :class:`ArgumentParser` objects read command-line arguments in as simple
+By default, the parser reads command-line arguments in as simple
strings. However, quite often the command-line string should instead be
-interpreted as another type, like a :class:`float` or :class:`int`. The
-``type`` keyword argument of :meth:`~ArgumentParser.add_argument` allows any
-necessary type-checking and type conversions to be performed. Common built-in
-types and functions can be used directly as the value of the ``type`` argument::
+interpreted as another type, such as a :class:`float` or :class:`int`. The
+``type`` keyword for :meth:`~ArgumentParser.add_argument` allows any
+necessary type-checking and type conversions to be performed.
- >>> parser = argparse.ArgumentParser()
- >>> parser.add_argument('foo', type=int)
- >>> parser.add_argument('bar', type=open)
- >>> parser.parse_args('2 temp.txt'.split())
- Namespace(bar=<_io.TextIOWrapper name='temp.txt' encoding='UTF-8'>, foo=2)
+If the type_ keyword is used with the default_ keyword, the type converter
+is only applied if the default is a string.
-See the section on the default_ keyword argument for information on when the
-``type`` argument is applied to default arguments.
+The argument to ``type`` can be any callable that accepts a single string.
+If the function raises :exc:`ArgumentTypeError`, :exc:`TypeError`, or
+:exc:`ValueError`, the exception is caught and a nicely formatted error
+message is displayed. No other exception types are handled.
-To ease the use of various types of files, the argparse module provides the
-factory FileType which takes the ``mode=``, ``bufsize=``, ``encoding=`` and
-``errors=`` arguments of the :func:`open` function. For example,
-``FileType('w')`` can be used to create a writable file::
+Common built-in types and functions can be used as type converters:
- >>> parser = argparse.ArgumentParser()
- >>> parser.add_argument('bar', type=argparse.FileType('w'))
- >>> parser.parse_args(['out.txt'])
- Namespace(bar=<_io.TextIOWrapper name='out.txt' encoding='UTF-8'>)
-
-``type=`` can take any callable that takes a single string argument and returns
-the converted value::
-
- >>> def perfect_square(string):
- ... value = int(string)
- ... sqrt = math.sqrt(value)
- ... if sqrt != int(sqrt):
- ... msg = "%r is not a perfect square" % string
- ... raise argparse.ArgumentTypeError(msg)
- ... return value
+.. testcode::
+
+ import argparse
+ import pathlib
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument('count', type=int)
+ parser.add_argument('distance', type=float)
+ parser.add_argument('street', type=ascii)
+ parser.add_argument('code_point', type=ord)
+ parser.add_argument('source_file', type=open)
+ parser.add_argument('dest_file', type=argparse.FileType('w', encoding='latin-1'))
+ parser.add_argument('datapath', type=pathlib.Path)
+
+User defined functions can be used as well:
+
+.. doctest::
+
+ >>> def hyphenated(string):
+ ... return '-'.join([word[:4] for word in string.casefold().split()])
...
- >>> parser = argparse.ArgumentParser(prog='PROG')
- >>> parser.add_argument('foo', type=perfect_square)
- >>> parser.parse_args(['9'])
- Namespace(foo=9)
- >>> parser.parse_args(['7'])
- usage: PROG [-h] foo
- PROG: error: argument foo: '7' is not a perfect square
+ >>> parser = argparse.ArgumentParser()
+ >>> _ = parser.add_argument('short_title', type=hyphenated)
+ >>> parser.parse_args(['"The Tale of Two Cities"'])
+ Namespace(short_title='"the-tale-of-two-citi')
-The choices_ keyword argument may be more convenient for type checkers that
-simply check against a range of values::
+The :func:`bool` function is not recommended as a type converter. All it does
+is convert empty strings to ``False`` and non-empty strings to ``True``.
+This is usually not what is desired.
- >>> parser = argparse.ArgumentParser(prog='PROG')
- >>> parser.add_argument('foo', type=int, choices=range(5, 10))
- >>> parser.parse_args(['7'])
- Namespace(foo=7)
- >>> parser.parse_args(['11'])
- usage: PROG [-h] {5,6,7,8,9}
- PROG: error: argument foo: invalid choice: 11 (choose from 5, 6, 7, 8, 9)
+In general, the ``type`` keyword is a convenience that should only be used for
+simple conversions that can only raise one of the three supported exceptions.
+Anything with more interesting error-handling or resource management should be
+done downstream after the arguments are parsed.
+
+For example, JSON or YAML conversions have complex error cases that require
+better reporting than can be given by the ``type`` keyword. An
+:exc:`~json.JSONDecodeError` would not be well formatted and a
+:exc:`FileNotFound` exception would not be handled at all.
+
+Even :class:`~argparse.FileType` has its limitations for use with the ``type``
+keyword. If one argument uses *FileType* and then a subsequent argument fails,
+an error is reported but the file is not automatically closed. In this case, it
+would be better to wait until after the parser has run and then use the
+:keyword:`with`-statement to manage the files.
-See the choices_ section for more details.
+For type checkers that simply check against a fixed set of values, consider
+using the choices_ keyword instead.
choices
@@ -1133,20 +1148,14 @@ container should match the type_ specified::
Any container can be passed as the *choices* value, so :class:`list` objects,
:class:`set` objects, and custom containers are all supported.
-This includes :class:`enum.Enum`, which could be used to restrain
-argument's choices; if we reuse previous rock/paper/scissors game example,
-this could be as follows::
-
- >>> from enum import Enum
- >>> class GameMove(Enum):
- ... ROCK = 'rock'
- ... PAPER = 'paper'
- ... SCISSORS = 'scissors'
- ...
- >>> parser = argparse.ArgumentParser(prog='game.py')
- >>> parser.add_argument('move', type=GameMove, choices=GameMove)
- >>> parser.parse_args(['rock'])
- Namespace(move=<GameMove.ROCK: 'rock'>)
+
+Use of :class:`enum.Enum` is not recommended because it is difficult to
+control its appearance in usage, help, and error messages.
+
+Formatted choices overrides the default *metavar* which is normally derived
+from *dest*. This is usually what you want because the user never sees the
+*dest* parameter. If this display isn't desirable (perhaps because there are
+many choices), just specify an explicit metavar_.
required
@@ -1194,7 +1203,7 @@ argument::
positional arguments:
bar one of the bars to be frobbled
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo foo the bars before frobbling
@@ -1212,7 +1221,7 @@ specifiers include the program name, ``%(prog)s`` and most keyword arguments to
positional arguments:
bar the bar to frobble (default: 42)
- optional arguments:
+ options:
-h, --help show this help message and exit
As the help string supports %-formatting, if you want a literal ``%`` to appear
@@ -1226,7 +1235,7 @@ setting the ``help`` value to ``argparse.SUPPRESS``::
>>> parser.print_help()
usage: frobble [-h]
- optional arguments:
+ options:
-h, --help show this help message and exit
@@ -1253,7 +1262,7 @@ will be referred to as ``FOO``. An example::
positional arguments:
bar
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO
@@ -1270,7 +1279,7 @@ An alternative name can be specified with ``metavar``::
positional arguments:
XXX
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo YYY
@@ -1288,7 +1297,7 @@ arguments::
>>> parser.print_help()
usage: PROG [-h] [-x X X] [--foo bar baz]
- optional arguments:
+ options:
-h, --help show this help message and exit
-x X X
--foo bar baz
@@ -1692,7 +1701,7 @@ Sub-commands
a a help
b b help
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo foo help
@@ -1702,13 +1711,13 @@ Sub-commands
positional arguments:
bar bar help
- optional arguments:
+ options:
-h, --help show this help message and exit
>>> parser.parse_args(['b', '--help'])
usage: PROG b [-h] [--baz {X,Y,Z}]
- optional arguments:
+ options:
-h, --help show this help message and exit
--baz {X,Y,Z} baz help
@@ -1725,7 +1734,7 @@ Sub-commands
>>> parser.parse_args(['-h'])
usage: [-h] {foo,bar} ...
- optional arguments:
+ options:
-h, --help show this help message and exit
subcommands:
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
index b8688ae61a..9149a53e0d 100644
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -80,12 +80,13 @@ Node classes
end_col_offset
Instances of :class:`ast.expr` and :class:`ast.stmt` subclasses have
- :attr:`lineno`, :attr:`col_offset`, :attr:`lineno`, and :attr:`col_offset`
- attributes. The :attr:`lineno` and :attr:`end_lineno` are the first and
- last line numbers of source text span (1-indexed so the first line is line 1)
- and the :attr:`col_offset` and :attr:`end_col_offset` are the corresponding
- UTF-8 byte offsets of the first and last tokens that generated the node.
- The UTF-8 offset is recorded because the parser uses UTF-8 internally.
+ :attr:`lineno`, :attr:`col_offset`, :attr:`end_lineno`, and
+ :attr:`end_col_offset` attributes. The :attr:`lineno` and :attr:`end_lineno`
+ are the first and last line numbers of source text span (1-indexed so the
+ first line is line 1) and the :attr:`col_offset` and :attr:`end_col_offset`
+ are the corresponding UTF-8 byte offsets of the first and last tokens that
+ generated the node. The UTF-8 offset is recorded because the parser uses
+ UTF-8 internally.
Note that the end positions are not required by the compiler and are
therefore optional. The end offset is *after* the last symbol, for example
@@ -1575,7 +1576,7 @@ and classes for traversing abstract syntax trees:
Safely evaluate an expression node or a string containing a Python literal or
container display. The string or node provided may only consist of the
following Python literal structures: strings, bytes, numbers, tuples, lists,
- dicts, sets, booleans, and ``None``.
+ dicts, sets, booleans, ``None`` and ``Ellipsis``.
This can be used for safely evaluating strings containing Python values from
untrusted sources without the need to parse the values oneself. It is not
@@ -1587,6 +1588,10 @@ and classes for traversing abstract syntax trees:
sufficiently large/complex string due to stack depth limitations
in Python's AST compiler.
+ It can raise :exc:`ValueError`, :exc:`TypeError`, :exc:`SyntaxError`,
+ :exc:`MemoryError` and :exc:`RecursionError` depending on the malformed
+ input.
+
.. versionchanged:: 3.2
Now allows bytes and set literals.
diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst
index b1e73189a7..7de5a0ab25 100644
--- a/Doc/library/asyncio-eventloop.rst
+++ b/Doc/library/asyncio-eventloop.rst
@@ -321,7 +321,7 @@ Creating Futures and Tasks
.. versionadded:: 3.5.2
-.. method:: loop.create_task(coro, \*, name=None)
+.. method:: loop.create_task(coro, *, name=None)
Schedule the execution of a :ref:`coroutine`.
Return a :class:`Task` object.
@@ -356,7 +356,7 @@ Opening network connections
^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. coroutinemethod:: loop.create_connection(protocol_factory, \
- host=None, port=None, \*, ssl=None, \
+ host=None, port=None, *, ssl=None, \
family=0, proto=0, flags=0, sock=None, \
local_addr=None, server_hostname=None, \
ssl_handshake_timeout=None, \
@@ -482,7 +482,7 @@ Opening network connections
that can be used directly in async/await code.
.. coroutinemethod:: loop.create_datagram_endpoint(protocol_factory, \
- local_addr=None, remote_addr=None, \*, \
+ local_addr=None, remote_addr=None, *, \
family=0, proto=0, flags=0, \
reuse_address=None, reuse_port=None, \
allow_broadcast=None, sock=None)
@@ -559,7 +559,7 @@ Opening network connections
Added support for Windows.
.. coroutinemethod:: loop.create_unix_connection(protocol_factory, \
- path=None, \*, ssl=None, sock=None, \
+ path=None, *, ssl=None, sock=None, \
server_hostname=None, ssl_handshake_timeout=None)
Create a Unix connection.
@@ -592,7 +592,7 @@ Creating network servers
^^^^^^^^^^^^^^^^^^^^^^^^
.. coroutinemethod:: loop.create_server(protocol_factory, \
- host=None, port=None, \*, \
+ host=None, port=None, *, \
family=socket.AF_UNSPEC, \
flags=socket.AI_PASSIVE, \
sock=None, backlog=100, ssl=None, \
@@ -683,7 +683,7 @@ Creating network servers
.. coroutinemethod:: loop.create_unix_server(protocol_factory, path=None, \
- \*, sock=None, backlog=100, ssl=None, \
+ *, sock=None, backlog=100, ssl=None, \
ssl_handshake_timeout=None, start_serving=True)
Similar to :meth:`loop.create_server` but works with the
@@ -708,7 +708,7 @@ Creating network servers
The *path* parameter can now be a :class:`~pathlib.Path` object.
.. coroutinemethod:: loop.connect_accepted_socket(protocol_factory, \
- sock, \*, ssl=None, ssl_handshake_timeout=None)
+ sock, *, ssl=None, ssl_handshake_timeout=None)
Wrap an already accepted connection into a transport/protocol pair.
@@ -773,7 +773,7 @@ TLS Upgrade
^^^^^^^^^^^
.. coroutinemethod:: loop.start_tls(transport, protocol, \
- sslcontext, \*, server_side=False, \
+ sslcontext, *, server_side=False, \
server_hostname=None, ssl_handshake_timeout=None)
Upgrade an existing transport-based connection to TLS.
@@ -806,7 +806,7 @@ TLS Upgrade
Watching file descriptors
^^^^^^^^^^^^^^^^^^^^^^^^^
-.. method:: loop.add_reader(fd, callback, \*args)
+.. method:: loop.add_reader(fd, callback, *args)
Start monitoring the *fd* file descriptor for read availability and
invoke *callback* with the specified arguments once *fd* is available for
@@ -816,7 +816,7 @@ Watching file descriptors
Stop monitoring the *fd* file descriptor for read availability.
-.. method:: loop.add_writer(fd, callback, \*args)
+.. method:: loop.add_writer(fd, callback, *args)
Start monitoring the *fd* file descriptor for write availability and
invoke *callback* with the specified arguments once *fd* is available for
@@ -930,7 +930,7 @@ convenient.
:meth:`loop.create_server` and :func:`start_server`.
.. coroutinemethod:: loop.sock_sendfile(sock, file, offset=0, count=None, \
- \*, fallback=True)
+ *, fallback=True)
Send a file using high-performance :mod:`os.sendfile` if possible.
Return the total number of bytes sent.
@@ -964,7 +964,7 @@ convenient.
DNS
^^^
-.. coroutinemethod:: loop.getaddrinfo(host, port, \*, family=0, \
+.. coroutinemethod:: loop.getaddrinfo(host, port, *, family=0, \
type=0, proto=0, flags=0)
Asynchronous version of :meth:`socket.getaddrinfo`.
@@ -1029,7 +1029,7 @@ Working with pipes
Unix signals
^^^^^^^^^^^^
-.. method:: loop.add_signal_handler(signum, callback, \*args)
+.. method:: loop.add_signal_handler(signum, callback, *args)
Set *callback* as the handler for the *signum* signal.
@@ -1064,7 +1064,7 @@ Unix signals
Executing code in thread or process pools
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-.. awaitablemethod:: loop.run_in_executor(executor, func, \*args)
+.. awaitablemethod:: loop.run_in_executor(executor, func, *args)
Arrange for *func* to be called in the specified executor.
@@ -1184,10 +1184,13 @@ Allows customizing how exceptions are handled in the event loop.
* 'message': Error message;
* 'exception' (optional): Exception object;
* 'future' (optional): :class:`asyncio.Future` instance;
+ * 'task' (optional): :class:`asyncio.Task` instance;
* 'handle' (optional): :class:`asyncio.Handle` instance;
* 'protocol' (optional): :ref:`Protocol <asyncio-protocol>` instance;
* 'transport' (optional): :ref:`Transport <asyncio-transport>` instance;
- * 'socket' (optional): :class:`socket.socket` instance.
+ * 'socket' (optional): :class:`socket.socket` instance;
+ * 'asyncgen' (optional): Asynchronous generator that caused
+ the exception.
.. note::
@@ -1234,9 +1237,9 @@ async/await code consider using the high-level
subprocesses. See :ref:`Subprocess Support on Windows
<asyncio-windows-subprocess>` for details.
-.. coroutinemethod:: loop.subprocess_exec(protocol_factory, \*args, \
+.. coroutinemethod:: loop.subprocess_exec(protocol_factory, *args, \
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
- stderr=subprocess.PIPE, \*\*kwargs)
+ stderr=subprocess.PIPE, **kwargs)
Create a subprocess from one or more string arguments specified by
*args*.
@@ -1316,9 +1319,9 @@ async/await code consider using the high-level
conforms to the :class:`asyncio.SubprocessTransport` base class and
*protocol* is an object instantiated by the *protocol_factory*.
-.. coroutinemethod:: loop.subprocess_shell(protocol_factory, cmd, \*, \
+.. coroutinemethod:: loop.subprocess_shell(protocol_factory, cmd, *, \
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
- stderr=subprocess.PIPE, \*\*kwargs)
+ stderr=subprocess.PIPE, **kwargs)
Create a subprocess from *cmd*, which can be a :class:`str` or a
:class:`bytes` string encoded to the
diff --git a/Doc/library/asyncio-future.rst b/Doc/library/asyncio-future.rst
index e1ac18eaf0..939d4c1a84 100644
--- a/Doc/library/asyncio-future.rst
+++ b/Doc/library/asyncio-future.rst
@@ -31,7 +31,7 @@ Future Functions
.. versionadded:: 3.5
-.. function:: ensure_future(obj, \*, loop=None)
+.. function:: ensure_future(obj, *, loop=None)
Return:
@@ -58,7 +58,7 @@ Future Functions
The function accepts any :term:`awaitable` object.
-.. function:: wrap_future(future, \*, loop=None)
+.. function:: wrap_future(future, *, loop=None)
Wrap a :class:`concurrent.futures.Future` object in a
:class:`asyncio.Future` object.
@@ -67,7 +67,7 @@ Future Functions
Future Object
=============
-.. class:: Future(\*, loop=None)
+.. class:: Future(*, loop=None)
A Future represents an eventual result of an asynchronous
operation. Not thread-safe.
diff --git a/Doc/library/asyncio-policy.rst b/Doc/library/asyncio-policy.rst
index 88e69ceff9..ef6a058850 100644
--- a/Doc/library/asyncio-policy.rst
+++ b/Doc/library/asyncio-policy.rst
@@ -159,7 +159,7 @@ implementation used by the asyncio event loop:
.. class:: AbstractChildWatcher
- .. method:: add_child_handler(pid, callback, \*args)
+ .. method:: add_child_handler(pid, callback, *args)
Register a new child handler.
@@ -209,7 +209,7 @@ implementation used by the asyncio event loop:
It works reliably even when the asyncio event loop is run in a non-main OS thread.
There is no noticeable overhead when handling a big number of children (*O(1)* each
- time a child terminates), but stating a thread per process requires extra memory.
+ time a child terminates), but starting a thread per process requires extra memory.
This watcher is used by default.
diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst
index 524560b691..289ad1b014 100644
--- a/Doc/library/asyncio-queue.rst
+++ b/Doc/library/asyncio-queue.rst
@@ -23,7 +23,7 @@ See also the `Examples`_ section below.
Queue
=====
-.. class:: Queue(maxsize=0, \*, loop=None)
+.. class:: Queue(maxsize=0)
A first in, first out (FIFO) queue.
@@ -36,9 +36,6 @@ Queue
the queue is always known and can be returned by calling the
:meth:`qsize` method.
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
This class is :ref:`not thread safe <asyncio-multithreading>`.
diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst
index b76ed379c7..9b456c1435 100644
--- a/Doc/library/asyncio-stream.rst
+++ b/Doc/library/asyncio-stream.rst
@@ -48,9 +48,9 @@ The following top-level asyncio functions can be used to create
and work with streams:
-.. coroutinefunction:: open_connection(host=None, port=None, \*, \
- loop=None, limit=None, ssl=None, family=0, \
- proto=0, flags=0, sock=None, local_addr=None, \
+.. coroutinefunction:: open_connection(host=None, port=None, *, \
+ limit=None, ssl=None, family=0, proto=0, \
+ flags=0, sock=None, local_addr=None, \
server_hostname=None, ssl_handshake_timeout=None)
Establish a network connection and return a pair of
@@ -59,9 +59,6 @@ and work with streams:
The returned *reader* and *writer* objects are instances of
:class:`StreamReader` and :class:`StreamWriter` classes.
- The *loop* argument is optional and can always be determined
- automatically when this function is awaited from a coroutine.
-
*limit* determines the buffer size limit used by the
returned :class:`StreamReader` instance. By default the *limit*
is set to 64 KiB.
@@ -74,7 +71,7 @@ and work with streams:
The *ssl_handshake_timeout* parameter.
.. coroutinefunction:: start_server(client_connected_cb, host=None, \
- port=None, \*, loop=None, limit=None, \
+ port=None, *, limit=None, \
family=socket.AF_UNSPEC, \
flags=socket.AI_PASSIVE, sock=None, \
backlog=100, ssl=None, reuse_address=None, \
@@ -92,9 +89,6 @@ and work with streams:
:ref:`coroutine function <coroutine>`; if it is a coroutine function,
it will be automatically scheduled as a :class:`Task`.
- The *loop* argument is optional and can always be determined
- automatically when this method is awaited from a coroutine.
-
*limit* determines the buffer size limit used by the
returned :class:`StreamReader` instance. By default the *limit*
is set to 64 KiB.
@@ -109,9 +103,9 @@ and work with streams:
.. rubric:: Unix Sockets
-.. coroutinefunction:: open_unix_connection(path=None, \*, loop=None, \
- limit=None, ssl=None, sock=None, \
- server_hostname=None, ssl_handshake_timeout=None)
+.. coroutinefunction:: open_unix_connection(path=None, *, limit=None, \
+ ssl=None, sock=None, server_hostname=None, \
+ ssl_handshake_timeout=None)
Establish a Unix socket connection and return a pair of
``(reader, writer)``.
@@ -132,9 +126,8 @@ and work with streams:
.. coroutinefunction:: start_unix_server(client_connected_cb, path=None, \
- \*, loop=None, limit=None, sock=None, \
- backlog=100, ssl=None, ssl_handshake_timeout=None, \
- start_serving=True)
+ *, limit=None, sock=None, backlog=100, ssl=None, \
+ ssl_handshake_timeout=None, start_serving=True)
Start a Unix socket server.
@@ -192,7 +185,7 @@ StreamReader
can be read. Use the :attr:`IncompleteReadError.partial`
attribute to get the partially read data.
- .. coroutinemethod:: readuntil(separator=b'\\n')
+ .. coroutinemethod:: readuntil(separator=b'\n')
Read data from the stream until *separator* is found.
diff --git a/Doc/library/asyncio-subprocess.rst b/Doc/library/asyncio-subprocess.rst
index b0330349df..f955a292e1 100644
--- a/Doc/library/asyncio-subprocess.rst
+++ b/Doc/library/asyncio-subprocess.rst
@@ -61,9 +61,8 @@ See also the `Examples`_ subsection.
Creating Subprocesses
=====================
-.. coroutinefunction:: create_subprocess_exec(program, \*args, stdin=None, \
- stdout=None, stderr=None, loop=None, \
- limit=None, \*\*kwds)
+.. coroutinefunction:: create_subprocess_exec(program, *args, stdin=None, \
+ stdout=None, stderr=None, limit=None, **kwds)
Create a subprocess.
@@ -76,13 +75,9 @@ Creating Subprocesses
See the documentation of :meth:`loop.subprocess_exec` for other
parameters.
- .. deprecated-removed:: 3.8 3.10
-
- The *loop* parameter.
.. coroutinefunction:: create_subprocess_shell(cmd, stdin=None, \
- stdout=None, stderr=None, loop=None, \
- limit=None, \*\*kwds)
+ stdout=None, stderr=None, limit=None, **kwds)
Run the *cmd* shell command.
@@ -104,10 +99,6 @@ Creating Subprocesses
escape whitespace and special shell characters in strings that are going
to be used to construct shell commands.
- .. deprecated-removed:: 3.8 3.10
-
- The *loop* parameter.
-
.. note::
Subprocesses are available for Windows if a :class:`ProactorEventLoop` is
diff --git a/Doc/library/asyncio-sync.rst b/Doc/library/asyncio-sync.rst
index 84a52cb2d5..d12630afc6 100644
--- a/Doc/library/asyncio-sync.rst
+++ b/Doc/library/asyncio-sync.rst
@@ -36,7 +36,7 @@ asyncio has the following basic synchronization primitives:
Lock
====
-.. class:: Lock(\*, loop=None)
+.. class:: Lock()
Implements a mutex lock for asyncio tasks. Not thread-safe.
@@ -63,9 +63,6 @@ Lock
finally:
lock.release()
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
.. coroutinemethod:: acquire()
Acquire the lock.
@@ -96,7 +93,7 @@ Lock
Event
=====
-.. class:: Event(\*, loop=None)
+.. class:: Event()
An event object. Not thread-safe.
@@ -104,14 +101,10 @@ Event
that some event has happened.
An Event object manages an internal flag that can be set to *true*
- with the :meth:`set` method and reset to *false* with the
- :meth:`clear` method. The :meth:`wait` method blocks until the
+ with the :meth:`~Event.set` method and reset to *false* with the
+ :meth:`clear` method. The :meth:`~Event.wait` method blocks until the
flag is set to *true*. The flag is set to *false* initially.
-
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
.. _asyncio_example_sync_event:
Example::
@@ -142,7 +135,7 @@ Event
Wait until the event is set.
If the event is set, return ``True`` immediately.
- Otherwise block until another task calls :meth:`set`.
+ Otherwise block until another task calls :meth:`~Event.set`.
.. method:: set()
@@ -155,8 +148,8 @@ Event
Clear (unset) the event.
- Tasks awaiting on :meth:`wait` will now block until the
- :meth:`set` method is called again.
+ Tasks awaiting on :meth:`~Event.wait` will now block until the
+ :meth:`~Event.set` method is called again.
.. method:: is_set()
@@ -166,7 +159,7 @@ Event
Condition
=========
-.. class:: Condition(lock=None, \*, loop=None)
+.. class:: Condition(lock=None)
A Condition object. Not thread-safe.
@@ -184,10 +177,6 @@ Condition
``None``. In the latter case a new Lock object is created
automatically.
-
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
The preferred way to use a Condition is an :keyword:`async with`
statement::
@@ -270,7 +259,7 @@ Condition
Semaphore
=========
-.. class:: Semaphore(value=1, \*, loop=None)
+.. class:: Semaphore(value=1)
A Semaphore object. Not thread-safe.
@@ -284,10 +273,6 @@ Semaphore
internal counter (``1`` by default). If the given value is
less than ``0`` a :exc:`ValueError` is raised.
-
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
The preferred way to use a Semaphore is an :keyword:`async with`
statement::
@@ -332,7 +317,7 @@ Semaphore
BoundedSemaphore
================
-.. class:: BoundedSemaphore(value=1, \*, loop=None)
+.. class:: BoundedSemaphore(value=1)
A bounded semaphore object. Not thread-safe.
@@ -340,10 +325,6 @@ BoundedSemaphore
a :exc:`ValueError` in :meth:`~Semaphore.release` if it
increases the internal counter above the initial *value*.
-
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
---------
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
index eb51c704ce..45e58437e0 100644
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -210,7 +210,7 @@ is :meth:`loop.run_in_executor`.
Running an asyncio Program
==========================
-.. function:: run(coro, \*, debug=False)
+.. function:: run(coro, *, debug=False)
Execute the :term:`coroutine` *coro* and return the result.
@@ -247,7 +247,7 @@ Running an asyncio Program
Creating Tasks
==============
-.. function:: create_task(coro, \*, name=None)
+.. function:: create_task(coro, *, name=None)
Wrap the *coro* :ref:`coroutine <coroutine>` into a :class:`Task`
and schedule its execution. Return the Task object.
@@ -283,7 +283,7 @@ Creating Tasks
Sleeping
========
-.. coroutinefunction:: sleep(delay, result=None, \*, loop=None)
+.. coroutinefunction:: sleep(delay, result=None)
Block for *delay* seconds.
@@ -293,9 +293,6 @@ Sleeping
``sleep()`` always suspends the current task, allowing other tasks
to run.
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
.. _asyncio_example_sleep:
Example of coroutine displaying the current date every second
@@ -319,7 +316,7 @@ Sleeping
Running Tasks Concurrently
==========================
-.. awaitablefunction:: gather(\*aws, loop=None, return_exceptions=False)
+.. awaitablefunction:: gather(*aws, return_exceptions=False)
Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws*
sequence *concurrently*.
@@ -348,9 +345,6 @@ Running Tasks Concurrently
cancellation of one submitted Task/Future to cause other
Tasks/Futures to be cancelled.
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
.. _asyncio_example_gather:
Example::
@@ -403,7 +397,7 @@ Running Tasks Concurrently
Shielding From Cancellation
===========================
-.. awaitablefunction:: shield(aw, \*, loop=None)
+.. awaitablefunction:: shield(aw)
Protect an :ref:`awaitable object <asyncio-awaitables>`
from being :meth:`cancelled <Task.cancel>`.
@@ -436,14 +430,11 @@ Shielding From Cancellation
except CancelledError:
res = None
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
Timeouts
========
-.. coroutinefunction:: wait_for(aw, timeout, \*, loop=None)
+.. coroutinefunction:: wait_for(aw, timeout)
Wait for the *aw* :ref:`awaitable <asyncio-awaitables>`
to complete with a timeout.
@@ -466,9 +457,6 @@ Timeouts
If the wait is cancelled, the future *aw* is also cancelled.
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
.. _asyncio_example_waitfor:
Example::
@@ -500,8 +488,7 @@ Timeouts
Waiting Primitives
==================
-.. coroutinefunction:: wait(aws, \*, loop=None, timeout=None,\
- return_when=ALL_COMPLETED)
+.. coroutinefunction:: wait(aws, *, timeout=None, return_when=ALL_COMPLETED)
Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws*
iterable concurrently and block until the condition specified
@@ -553,10 +540,6 @@ Waiting Primitives
``wait()`` directly is deprecated as it leads to
:ref:`confusing behavior <asyncio_example_wait_coroutine>`.
- .. deprecated-removed:: 3.8 3.10
-
- The *loop* parameter.
-
.. _asyncio_example_wait_coroutine:
.. note::
@@ -590,7 +573,7 @@ Waiting Primitives
deprecated.
-.. function:: as_completed(aws, \*, loop=None, timeout=None)
+.. function:: as_completed(aws, *, timeout=None)
Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws*
iterable concurrently. Return an iterator of coroutines.
@@ -600,9 +583,6 @@ Waiting Primitives
Raises :exc:`asyncio.TimeoutError` if the timeout occurs before
all Futures are done.
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
Example::
for coro in as_completed(aws):
@@ -613,12 +593,12 @@ Waiting Primitives
Running in Threads
==================
-.. coroutinefunction:: to_thread(func, /, \*args, \*\*kwargs)
+.. coroutinefunction:: to_thread(func, /, *args, **kwargs)
Asynchronously run function *func* in a separate thread.
Any \*args and \*\*kwargs supplied for this function are directly passed
- to *func*. Also, the current :class:`contextvars.Context` is propogated,
+ to *func*. Also, the current :class:`contextvars.Context` is propagated,
allowing context variables from the event loop thread to be accessed in the
separate thread.
@@ -743,7 +723,7 @@ Introspection
Task Object
===========
-.. class:: Task(coro, \*, loop=None, name=None)
+.. class:: Task(coro, *, loop=None, name=None)
A :class:`Future-like <Future>` object that runs a Python
:ref:`coroutine <coroutine>`. Not thread-safe.
@@ -909,7 +889,7 @@ Task Object
See the documentation of :meth:`Future.remove_done_callback`
for more details.
- .. method:: get_stack(\*, limit=None)
+ .. method:: get_stack(*, limit=None)
Return the list of stack frames for this Task.
@@ -930,7 +910,7 @@ Task Object
stack are returned, but the oldest frames of a traceback are
returned. (This matches the behavior of the traceback module.)
- .. method:: print_stack(\*, limit=None, file=None)
+ .. method:: print_stack(*, limit=None, file=None)
Print the stack or traceback for this Task.
diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst
index 2f24bb6391..25b3a4ca29 100644
--- a/Doc/library/base64.rst
+++ b/Doc/library/base64.rst
@@ -199,7 +199,7 @@ The modern interface provides:
.. versionadded:: 3.4
-.. function:: a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \\t\\n\\r\\v')
+.. function:: a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v')
Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *b* and
return the decoded :class:`bytes`.
diff --git a/Doc/library/bz2.rst b/Doc/library/bz2.rst
index 85cdc16a7d..637baf49da 100644
--- a/Doc/library/bz2.rst
+++ b/Doc/library/bz2.rst
@@ -266,7 +266,6 @@ Below are some examples of typical usage of the :mod:`bz2` module.
Using :func:`compress` and :func:`decompress` to demonstrate round-trip compression:
>>> import bz2
-
>>> data = b"""\
... Donec rhoncus quis sapien sit amet molestie. Fusce scelerisque vel augue
... nec ullamcorper. Nam rutrum pretium placerat. Aliquam vel tristique lorem,
@@ -275,11 +274,9 @@ Using :func:`compress` and :func:`decompress` to demonstrate round-trip compress
... Aliquam pharetra lacus non risus vehicula rutrum. Maecenas aliquam leo
... felis. Pellentesque semper nunc sit amet nibh ullamcorper, ac elementum
... dolor luctus. Curabitur lacinia mi ornare consectetur vestibulum."""
-
>>> c = bz2.compress(data)
>>> len(data) / len(c) # Data compression ratio
1.513595166163142
-
>>> d = bz2.decompress(c)
>>> data == d # Check equality to original object after round-trip
True
@@ -287,7 +284,6 @@ Using :func:`compress` and :func:`decompress` to demonstrate round-trip compress
Using :class:`BZ2Compressor` for incremental compression:
>>> import bz2
-
>>> def gen_data(chunks=10, chunksize=1000):
... """Yield incremental blocks of chunksize bytes."""
... for _ in range(chunks):
@@ -310,7 +306,6 @@ while ordered, repetitive data usually yields a high compression ratio.
Writing and reading a bzip2-compressed file in binary mode:
>>> import bz2
-
>>> data = b"""\
... Donec rhoncus quis sapien sit amet molestie. Fusce scelerisque vel augue
... nec ullamcorper. Nam rutrum pretium placerat. Aliquam vel tristique lorem,
@@ -319,14 +314,11 @@ Writing and reading a bzip2-compressed file in binary mode:
... Aliquam pharetra lacus non risus vehicula rutrum. Maecenas aliquam leo
... felis. Pellentesque semper nunc sit amet nibh ullamcorper, ac elementum
... dolor luctus. Curabitur lacinia mi ornare consectetur vestibulum."""
-
>>> with bz2.open("myfile.bz2", "wb") as f:
... # Write compressed data to file
... unused = f.write(data)
-
>>> with bz2.open("myfile.bz2", "rb") as f:
... # Decompress data from file
... content = f.read()
-
>>> content == data # Check equality to original object after round-trip
True
diff --git a/Doc/library/collections.abc.rst b/Doc/library/collections.abc.rst
index db0e25bb07..2345e78a17 100644
--- a/Doc/library/collections.abc.rst
+++ b/Doc/library/collections.abc.rst
@@ -291,7 +291,7 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin:
:meth:`_from_iterable` which calls ``cls(iterable)`` to produce a new set.
If the :class:`Set` mixin is being used in a class with a different
constructor signature, you will need to override :meth:`_from_iterable`
- with a classmethod that can construct new instances from
+ with a classmethod or regular method that can construct new instances from
an iterable argument.
(2)
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index f538da5e1c..1293f542b0 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -862,6 +862,9 @@ they add the ability to access fields by name instead of position index.
Named tuple instances do not have per-instance dictionaries, so they are
lightweight and require no more memory than regular tuples.
+ To support pickling, the named tuple class should be assigned to a variable
+ that matches *typename*.
+
.. versionchanged:: 3.1
Added support for *rename*.
diff --git a/Doc/library/compileall.rst b/Doc/library/compileall.rst
index 9b914b1f0d..5c6e68f930 100644
--- a/Doc/library/compileall.rst
+++ b/Doc/library/compileall.rst
@@ -148,7 +148,7 @@ runtime.
Public functions
----------------
-.. function:: compile_dir(dir, maxlevels=sys.getrecursionlimit(), ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, workers=1, invalidation_mode=None, \*, stripdir=None, prependdir=None, limit_sl_dest=None, hardlink_dupes=False)
+.. function:: compile_dir(dir, maxlevels=sys.getrecursionlimit(), ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, workers=1, invalidation_mode=None, *, stripdir=None, prependdir=None, limit_sl_dest=None, hardlink_dupes=False)
Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
files along the way. Return a true value if all the files compiled successfully,
@@ -231,7 +231,7 @@ Public functions
Added *stripdir*, *prependdir*, *limit_sl_dest* and *hardlink_dupes* arguments.
Default value of *maxlevels* was changed from ``10`` to ``sys.getrecursionlimit()``
-.. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, invalidation_mode=None, \*, stripdir=None, prependdir=None, limit_sl_dest=None, hardlink_dupes=False)
+.. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, invalidation_mode=None, *, stripdir=None, prependdir=None, limit_sl_dest=None, hardlink_dupes=False)
Compile the file with path *fullname*. Return a true value if the file
compiled successfully, and a false value otherwise.
diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst
index 675a9ffdd0..d57f8ce23d 100644
--- a/Doc/library/concurrent.futures.rst
+++ b/Doc/library/concurrent.futures.rst
@@ -67,7 +67,7 @@ Executor Objects
.. versionchanged:: 3.5
Added the *chunksize* argument.
- .. method:: shutdown(wait=True, \*, cancel_futures=False)
+ .. method:: shutdown(wait=True, *, cancel_futures=False)
Signal the executor that it should free any resources that it is using
when the currently pending futures are done executing. Calls to
@@ -236,9 +236,9 @@ to a :class:`ProcessPoolExecutor` will result in deadlock.
An :class:`Executor` subclass that executes calls asynchronously using a pool
of at most *max_workers* processes. If *max_workers* is ``None`` or not
given, it will default to the number of processors on the machine.
- If *max_workers* is lower or equal to ``0``, then a :exc:`ValueError`
+ If *max_workers* is less than or equal to ``0``, then a :exc:`ValueError`
will be raised.
- On Windows, *max_workers* must be equal or lower than ``61``. If it is not
+ On Windows, *max_workers* must be less than or equal to ``61``. If it is not
then :exc:`ValueError` will be raised. If *max_workers* is ``None``, then
the default chosen will be at most ``61``, even if more processors are
available.
@@ -250,7 +250,7 @@ to a :class:`ProcessPoolExecutor` will result in deadlock.
each worker process; *initargs* is a tuple of arguments passed to the
initializer. Should *initializer* raise an exception, all currently
pending jobs will raise a :exc:`~concurrent.futures.process.BrokenProcessPool`,
- as well any attempt to submit more jobs to the pool.
+ as well as any attempt to submit more jobs to the pool.
.. versionchanged:: 3.3
When one of the worker processes terminates abruptly, a
diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst
index e42f5a9328..91edbba728 100644
--- a/Doc/library/contextlib.rst
+++ b/Doc/library/contextlib.rst
@@ -126,6 +126,31 @@ Functions and classes provided:
.. versionadded:: 3.7
+ Context managers defined with :func:`asynccontextmanager` can be used
+ either as decorators or with :keyword:`async with` statements::
+
+ import time
+
+ async def timeit():
+ now = time.monotonic()
+ try:
+ yield
+ finally:
+ print(f'it took {time.monotonic() - now}s to run')
+
+ @timeit()
+ async def main():
+ # ... async code ...
+
+ When used as a decorator, a new generator instance is implicitly created on
+ each function call. This allows the otherwise "one-shot" context managers
+ created by :func:`asynccontextmanager` to meet the requirement that context
+ managers support multiple invocations in order to be used as decorators.
+
+ .. versionchanged:: 3.10
+ Async context managers created with :func:`asynccontextmanager` can
+ be used as decorators.
+
.. function:: closing(thing)
@@ -218,8 +243,26 @@ Functions and classes provided:
with cm as file:
# Perform processing on the file
+ It can also be used as a stand-in for
+ :ref:`asynchronous context managers <async-context-managers>`::
+
+ async def send_http(session=None):
+ if not session:
+ # If no http session, create it with aiohttp
+ cm = aiohttp.ClientSession()
+ else:
+ # Caller is responsible for closing the session
+ cm = nullcontext(session)
+
+ async with cm as session:
+ # Send http requests with session
+
.. versionadded:: 3.7
+ .. versionchanged:: 3.10
+ :term:`asynchronous context manager` support was added.
+
+
.. function:: suppress(*exceptions)
@@ -384,6 +427,45 @@ Functions and classes provided:
.. versionadded:: 3.2
+.. class:: AsyncContextDecorator
+
+ Similar to :class:`ContextDecorator` but only for asynchronous functions.
+
+ Example of ``AsyncContextDecorator``::
+
+ from asyncio import run
+ from contextlib import AsyncContextDecorator
+
+ class mycontext(AsyncContextDecorator):
+ async def __aenter__(self):
+ print('Starting')
+ return self
+
+ async def __aexit__(self, *exc):
+ print('Finishing')
+ return False
+
+ >>> @mycontext()
+ ... async def function():
+ ... print('The bit in the middle')
+ ...
+ >>> run(function())
+ Starting
+ The bit in the middle
+ Finishing
+
+ >>> async def function():
+ ... async with mycontext():
+ ... print('The bit in the middle')
+ ...
+ >>> run(function())
+ Starting
+ The bit in the middle
+ Finishing
+
+ .. versionadded:: 3.10
+
+
.. class:: ExitStack()
A context manager that is designed to make it easy to programmatically
diff --git a/Doc/library/contextvars.rst b/Doc/library/contextvars.rst
index 8805661c45..14ac47f4c9 100644
--- a/Doc/library/contextvars.rst
+++ b/Doc/library/contextvars.rst
@@ -26,7 +26,7 @@ See also :pep:`567` for additional details.
Context Variables
-----------------
-.. class:: ContextVar(name, [\*, default])
+.. class:: ContextVar(name, [*, default])
This class is used to declare a new Context Variable, e.g.::
@@ -146,7 +146,7 @@ Manual Context Management
Context implements the :class:`collections.abc.Mapping` interface.
- .. method:: run(callable, \*args, \*\*kwargs)
+ .. method:: run(callable, *args, **kwargs)
Execute ``callable(*args, **kwargs)`` code in the context object
the *run* method is called on. Return the result of the execution
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index bf32d3e549..7313148721 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -2508,7 +2508,7 @@ other data types containing pointer type fields.
Arrays and pointers
^^^^^^^^^^^^^^^^^^^
-.. class:: Array(\*args)
+.. class:: Array(*args)
Abstract base class for arrays.
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index 508bc88e7f..dae0dd7aa5 100644
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -1219,7 +1219,7 @@ Instance methods:
.. method:: datetime.replace(year=self.year, month=self.month, day=self.day, \
hour=self.hour, minute=self.minute, second=self.second, microsecond=self.microsecond, \
- tzinfo=self.tzinfo, * fold=0)
+ tzinfo=self.tzinfo, *, fold=0)
Return a datetime with the same attributes, except for those attributes given
new values by whichever keyword arguments are specified. Note that
@@ -1783,7 +1783,7 @@ Other constructor:
Instance methods:
.. method:: time.replace(hour=self.hour, minute=self.minute, second=self.second, \
- microsecond=self.microsecond, tzinfo=self.tzinfo, * fold=0)
+ microsecond=self.microsecond, tzinfo=self.tzinfo, *, fold=0)
Return a :class:`.time` with the same value, except for those attributes given
new values by whichever keyword arguments are specified. Note that
diff --git a/Doc/library/dialog.rst b/Doc/library/dialog.rst
index dc82a974ce..53f98c1018 100644
--- a/Doc/library/dialog.rst
+++ b/Doc/library/dialog.rst
@@ -198,7 +198,7 @@ These do not emulate the native look-and-feel of the platform.
A subclass of FileDialog that creates a dialog window for selecting a
destination file.
- .. method:: ok_command()
+ .. method:: ok_command()
Test whether or not the selection points to a valid file that is not a
directory. Confirmation is required if an already existing file is
diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst
index aa08988c8b..a5ee0fb538 100644
--- a/Doc/library/difflib.rst
+++ b/Doc/library/difflib.rst
@@ -149,7 +149,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
contains a good example of its use.
-.. function:: context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\\n')
+.. function:: context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n')
Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
generating the delta lines) in context diff format.
@@ -279,7 +279,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
emu
-.. function:: unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\\n')
+.. function:: unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n')
Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
generating the delta lines) in unified diff format.
@@ -321,7 +321,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
See :ref:`difflib-interface` for a more detailed example.
-.. function:: diff_bytes(dfunc, a, b, fromfile=b'', tofile=b'', fromfiledate=b'', tofiledate=b'', n=3, lineterm=b'\\n')
+.. function:: diff_bytes(dfunc, a, b, fromfile=b'', tofile=b'', fromfiledate=b'', tofiledate=b'', n=3, lineterm=b'\n')
Compare *a* and *b* (lists of bytes objects) using *dfunc*; yield a
sequence of delta lines (also bytes) in the format returned by *dfunc*.
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index d0307bd8e9..c09d8338d2 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -708,7 +708,8 @@ iterations of the loop.
.. opcode:: RERAISE
- Re-raises the exception currently on top of the stack.
+ Re-raises the exception currently on top of the stack. If oparg is non-zero,
+ restores ``f_lasti`` of the current frame to its value when the exception was raised.
.. versionadded:: 3.9
@@ -861,7 +862,7 @@ All of the following opcodes use their arguments.
.. opcode:: LIST_TO_TUPLE
- Pops a list from the stack and pushes a tuple containing the same values.
+ Pops a list from the stack and pushes a tuple containing the same values.
.. versionadded:: 3.9
@@ -889,7 +890,7 @@ All of the following opcodes use their arguments.
.. opcode:: DICT_MERGE
- Like :opcode:`DICT_UPDATE` but raises an exception for duplicate keys.
+ Like :opcode:`DICT_UPDATE` but raises an exception for duplicate keys.
.. versionadded:: 3.9
@@ -907,14 +908,14 @@ All of the following opcodes use their arguments.
.. opcode:: IS_OP (invert)
- Performs ``is`` comparison, or ``is not`` if ``invert`` is 1.
+ Performs ``is`` comparison, or ``is not`` if ``invert`` is 1.
.. versionadded:: 3.9
.. opcode:: CONTAINS_OP (invert)
- Performs ``in`` comparison, or ``not in`` if ``invert`` is 1.
+ Performs ``in`` comparison, or ``not in`` if ``invert`` is 1.
.. versionadded:: 3.9
@@ -955,8 +956,8 @@ All of the following opcodes use their arguments.
.. opcode:: JUMP_IF_NOT_EXC_MATCH (target)
- Tests whether the second value on the stack is an exception matching TOS,
- and jumps if it is not. Pops two values from the stack.
+ Tests whether the second value on the stack is an exception matching TOS,
+ and jumps if it is not. Pops two values from the stack.
.. versionadded:: 3.9
@@ -1144,11 +1145,13 @@ All of the following opcodes use their arguments.
* ``0x01`` a tuple of default values for positional-only and
positional-or-keyword parameters in positional order
* ``0x02`` a dictionary of keyword-only parameters' default values
- * ``0x04`` an annotation dictionary
+ * ``0x04`` a tuple of strings containing parameters' annotations
* ``0x08`` a tuple containing cells for free variables, making a closure
* the code associated with the function (at TOS1)
* the :term:`qualified name` of the function (at TOS)
+ .. versionchanged:: 3.10
+ Flag value ``0x04`` is a tuple of strings instead of dictionary
.. opcode:: BUILD_SLICE (argc)
diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst
index a77322f83a..42ad0c9f06 100644
--- a/Doc/library/doctest.rst
+++ b/Doc/library/doctest.rst
@@ -719,36 +719,51 @@ above.
An example's doctest directives modify doctest's behavior for that single
example. Use ``+`` to enable the named behavior, or ``-`` to disable it.
-For example, this test passes::
+For example, this test passes:
- >>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE
+.. doctest::
+ :no-trim-doctest-flags:
+
+ >>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
Without the directive it would fail, both because the actual output doesn't have
two blanks before the single-digit list elements, and because the actual output
is on a single line. This test also passes, and also requires a directive to do
-so::
+so:
+
+.. doctest::
+ :no-trim-doctest-flags:
- >>> print(list(range(20))) # doctest: +ELLIPSIS
+ >>> print(list(range(20))) # doctest: +ELLIPSIS
[0, 1, ..., 18, 19]
Multiple directives can be used on a single physical line, separated by
-commas::
+commas:
- >>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
+.. doctest::
+ :no-trim-doctest-flags:
+
+ >>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
[0, 1, ..., 18, 19]
If multiple directive comments are used for a single example, then they are
-combined::
+combined:
+
+.. doctest::
+ :no-trim-doctest-flags:
- >>> print(list(range(20))) # doctest: +ELLIPSIS
- ... # doctest: +NORMALIZE_WHITESPACE
+ >>> print(list(range(20))) # doctest: +ELLIPSIS
+ ... # doctest: +NORMALIZE_WHITESPACE
[0, 1, ..., 18, 19]
As the previous example shows, you can add ``...`` lines to your example
containing only directives. This can be useful when an example is too long for
-a directive to comfortably fit on the same line::
+a directive to comfortably fit on the same line:
+
+.. doctest::
+ :no-trim-doctest-flags:
>>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40)))
... # doctest: +ELLIPSIS
@@ -793,18 +808,23 @@ instead. Another is to do ::
There are others, but you get the idea.
-Another bad idea is to print things that embed an object address, like ::
+Another bad idea is to print things that embed an object address, like
+
+.. doctest::
- >>> id(1.0) # certain to fail some of the time
+ >>> id(1.0) # certain to fail some of the time # doctest: +SKIP
7948648
>>> class C: pass
- >>> C() # the default repr() for instances embeds an address
- <__main__.C instance at 0x00AC18F0>
+ >>> C() # the default repr() for instances embeds an address # doctest: +SKIP
+ <C object at 0x00AC18F0>
+
+The :const:`ELLIPSIS` directive gives a nice approach for the last example:
-The :const:`ELLIPSIS` directive gives a nice approach for the last example::
+.. doctest::
+ :no-trim-doctest-flags:
- >>> C() #doctest: +ELLIPSIS
- <__main__.C instance at 0x...>
+ >>> C() # doctest: +ELLIPSIS
+ <C object at 0x...>
Floating-point numbers are also subject to small output variations across
platforms, because Python defers to the platform C library for float formatting,
diff --git a/Doc/library/email.contentmanager.rst b/Doc/library/email.contentmanager.rst
index e09c7c0e40..918fc55677 100644
--- a/Doc/library/email.contentmanager.rst
+++ b/Doc/library/email.contentmanager.rst
@@ -116,7 +116,7 @@ Currently the email package provides only one concrete content manager,
decoding the payload to unicode. The default error handler is
``replace``.
- .. method:: set_content(msg, <'str'>, subtype="plain", charset='utf-8' \
+ .. method:: set_content(msg, <'str'>, subtype="plain", charset='utf-8', \
cte=None, \
disposition=None, filename=None, cid=None, \
params=None, headers=None)
diff --git a/Doc/library/email.header.rst b/Doc/library/email.header.rst
index 07152c224f..e093f13893 100644
--- a/Doc/library/email.header.rst
+++ b/Doc/library/email.header.rst
@@ -116,7 +116,7 @@ Here is the :class:`Header` class description:
if *s* is a byte string.
- .. method:: encode(splitchars=';, \\t', maxlinelen=None, linesep='\\n')
+ .. method:: encode(splitchars=';, \t', maxlinelen=None, linesep='\n')
Encode a message header into an RFC-compliant format, possibly wrapping
long lines and encapsulating non-ASCII parts in base64 or quoted-printable
diff --git a/Doc/library/email.policy.rst b/Doc/library/email.policy.rst
index 8e70762598..bf53b9520f 100644
--- a/Doc/library/email.policy.rst
+++ b/Doc/library/email.policy.rst
@@ -210,7 +210,7 @@ added matters. To illustrate::
:meth:`register_defect` method.
- .. attribute:: mangle_from\_
+ .. attribute:: mangle_from_
If :const:`True`, lines starting with *"From "* in the body are
escaped by putting a ``>`` in front of them. This parameter is used when
diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst
index 118002bef1..c532e2caec 100644
--- a/Doc/library/enum.rst
+++ b/Doc/library/enum.rst
@@ -61,16 +61,18 @@ helper, :class:`auto`.
the bitwise operations without losing their :class:`Flag` membership.
.. function:: unique
- :noindex:
+ :noindex:
Enum class decorator that ensures only one name is bound to any one value.
.. class:: auto
- Instances are replaced with an appropriate value for Enum members. By default, the initial value starts at 1.
+ Instances are replaced with an appropriate value for Enum members.
+ :class:`StrEnum` defaults to the lower-cased version of the member name,
+ while other Enums default to 1 and increase from there.
.. versionadded:: 3.6 ``Flag``, ``IntFlag``, ``auto``
-
+.. versionadded:: 3.10 ``StrEnum``
Creating an Enum
----------------
@@ -1164,6 +1166,15 @@ and raise an error if the two do not match::
In Python 2 code the :attr:`_order_` attribute is necessary as definition
order is lost before it can be recorded.
+
+_Private__names
+"""""""""""""""
+
+Private names are not converted to Enum members, but remain normal attributes.
+
+.. versionchanged:: 3.10
+
+
``Enum`` member type
""""""""""""""""""""
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst
index 8fb25a50e2..1028213699 100644
--- a/Doc/library/exceptions.rst
+++ b/Doc/library/exceptions.rst
@@ -90,8 +90,13 @@ The following exceptions are used mostly as base classes for other exceptions.
.. method:: with_traceback(tb)
This method sets *tb* as the new traceback for the exception and returns
- the exception object. It is usually used in exception handling code like
- this::
+ the exception object. It was more commonly used before the exception
+ chaining features of :pep:`3134` became available. The following example
+ shows how we can convert an instance of ``SomeException`` into an
+ instance of ``OtherException`` while preserving the traceback. Once
+ raised, the current frame is pushed onto the traceback of the
+ ``OtherException``, as would have happened to the traceback of the
+ original ``SomeException`` had we allowed it to propagate to the caller.
try:
...
diff --git a/Doc/library/filecmp.rst b/Doc/library/filecmp.rst
index 31b9b4afab..c60603b30a 100644
--- a/Doc/library/filecmp.rst
+++ b/Doc/library/filecmp.rst
@@ -173,7 +173,13 @@ The :class:`dircmp` class
.. attribute:: subdirs
A dictionary mapping names in :attr:`common_dirs` to :class:`dircmp`
- objects.
+ instances (or MyDirCmp instances if this instance is of type MyDirCmp, a
+ subclass of :class:`dircmp`).
+
+ .. versionchanged:: 3.10
+ Previously entries were always :class:`dircmp` instances. Now entries
+ are the same type as *self*, if *self* is a subclass of
+ :class:`dircmp`.
.. attribute:: DEFAULT_IGNORES
diff --git a/Doc/library/fnmatch.rst b/Doc/library/fnmatch.rst
index ce07d326b3..925f08e914 100644
--- a/Doc/library/fnmatch.rst
+++ b/Doc/library/fnmatch.rst
@@ -75,7 +75,7 @@ patterns.
.. function:: filter(names, pattern)
- Return the subset of the list of *names* that match *pattern*. It is the same as
+ Construct a list from those elements of the iterable *names* that match *pattern*. It is the same as
``[n for n in names if fnmatch(n, pattern)]``, but implemented more efficiently.
diff --git a/Doc/library/formatter.rst b/Doc/library/formatter.rst
deleted file mode 100644
index 6c10ac6fab..0000000000
--- a/Doc/library/formatter.rst
+++ /dev/null
@@ -1,351 +0,0 @@
-:mod:`formatter` --- Generic output formatting
-==============================================
-
-.. module:: formatter
- :synopsis: Generic output formatter and device interface.
- :deprecated:
-
-.. deprecated:: 3.4
- Due to lack of usage, the formatter module has been deprecated.
-
---------------
-
-This module supports two interface definitions, each with multiple
-implementations: The *formatter* interface, and the *writer* interface which is
-required by the formatter interface.
-
-Formatter objects transform an abstract flow of formatting events into specific
-output events on writer objects. Formatters manage several stack structures to
-allow various properties of a writer object to be changed and restored; writers
-need not be able to handle relative changes nor any sort of "change back"
-operation. Specific writer properties which may be controlled via formatter
-objects are horizontal alignment, font, and left margin indentations. A
-mechanism is provided which supports providing arbitrary, non-exclusive style
-settings to a writer as well. Additional interfaces facilitate formatting
-events which are not reversible, such as paragraph separation.
-
-Writer objects encapsulate device interfaces. Abstract devices, such as file
-formats, are supported as well as physical devices. The provided
-implementations all work with abstract devices. The interface makes available
-mechanisms for setting the properties which formatter objects manage and
-inserting data into the output.
-
-
-.. _formatter-interface:
-
-The Formatter Interface
------------------------
-
-Interfaces to create formatters are dependent on the specific formatter class
-being instantiated. The interfaces described below are the required interfaces
-which all formatters must support once initialized.
-
-One data element is defined at the module level:
-
-
-.. data:: AS_IS
-
- Value which can be used in the font specification passed to the ``push_font()``
- method described below, or as the new value to any other ``push_property()``
- method. Pushing the ``AS_IS`` value allows the corresponding ``pop_property()``
- method to be called without having to track whether the property was changed.
-
-The following attributes are defined for formatter instance objects:
-
-
-.. attribute:: formatter.writer
-
- The writer instance with which the formatter interacts.
-
-
-.. method:: formatter.end_paragraph(blanklines)
-
- Close any open paragraphs and insert at least *blanklines* before the next
- paragraph.
-
-
-.. method:: formatter.add_line_break()
-
- Add a hard line break if one does not already exist. This does not break the
- logical paragraph.
-
-
-.. method:: formatter.add_hor_rule(*args, **kw)
-
- Insert a horizontal rule in the output. A hard break is inserted if there is
- data in the current paragraph, but the logical paragraph is not broken. The
- arguments and keywords are passed on to the writer's :meth:`send_line_break`
- method.
-
-
-.. method:: formatter.add_flowing_data(data)
-
- Provide data which should be formatted with collapsed whitespace. Whitespace
- from preceding and successive calls to :meth:`add_flowing_data` is considered as
- well when the whitespace collapse is performed. The data which is passed to
- this method is expected to be word-wrapped by the output device. Note that any
- word-wrapping still must be performed by the writer object due to the need to
- rely on device and font information.
-
-
-.. method:: formatter.add_literal_data(data)
-
- Provide data which should be passed to the writer unchanged. Whitespace,
- including newline and tab characters, are considered legal in the value of
- *data*.
-
-
-.. method:: formatter.add_label_data(format, counter)
-
- Insert a label which should be placed to the left of the current left margin.
- This should be used for constructing bulleted or numbered lists. If the
- *format* value is a string, it is interpreted as a format specification for
- *counter*, which should be an integer. The result of this formatting becomes the
- value of the label; if *format* is not a string it is used as the label value
- directly. The label value is passed as the only argument to the writer's
- :meth:`send_label_data` method. Interpretation of non-string label values is
- dependent on the associated writer.
-
- Format specifications are strings which, in combination with a counter value,
- are used to compute label values. Each character in the format string is copied
- to the label value, with some characters recognized to indicate a transform on
- the counter value. Specifically, the character ``'1'`` represents the counter
- value formatter as an Arabic number, the characters ``'A'`` and ``'a'``
- represent alphabetic representations of the counter value in upper and lower
- case, respectively, and ``'I'`` and ``'i'`` represent the counter value in Roman
- numerals, in upper and lower case. Note that the alphabetic and roman
- transforms require that the counter value be greater than zero.
-
-
-.. method:: formatter.flush_softspace()
-
- Send any pending whitespace buffered from a previous call to
- :meth:`add_flowing_data` to the associated writer object. This should be called
- before any direct manipulation of the writer object.
-
-
-.. method:: formatter.push_alignment(align)
-
- Push a new alignment setting onto the alignment stack. This may be
- :const:`AS_IS` if no change is desired. If the alignment value is changed from
- the previous setting, the writer's :meth:`new_alignment` method is called with
- the *align* value.
-
-
-.. method:: formatter.pop_alignment()
-
- Restore the previous alignment.
-
-
-.. method:: formatter.push_font((size, italic, bold, teletype))
-
- Change some or all font properties of the writer object. Properties which are
- not set to :const:`AS_IS` are set to the values passed in while others are
- maintained at their current settings. The writer's :meth:`new_font` method is
- called with the fully resolved font specification.
-
-
-.. method:: formatter.pop_font()
-
- Restore the previous font.
-
-
-.. method:: formatter.push_margin(margin)
-
- Increase the number of left margin indentations by one, associating the logical
- tag *margin* with the new indentation. The initial margin level is ``0``.
- Changed values of the logical tag must be true values; false values other than
- :const:`AS_IS` are not sufficient to change the margin.
-
-
-.. method:: formatter.pop_margin()
-
- Restore the previous margin.
-
-
-.. method:: formatter.push_style(*styles)
-
- Push any number of arbitrary style specifications. All styles are pushed onto
- the styles stack in order. A tuple representing the entire stack, including
- :const:`AS_IS` values, is passed to the writer's :meth:`new_styles` method.
-
-
-.. method:: formatter.pop_style(n=1)
-
- Pop the last *n* style specifications passed to :meth:`push_style`. A tuple
- representing the revised stack, including :const:`AS_IS` values, is passed to
- the writer's :meth:`new_styles` method.
-
-
-.. method:: formatter.set_spacing(spacing)
-
- Set the spacing style for the writer.
-
-
-.. method:: formatter.assert_line_data(flag=1)
-
- Inform the formatter that data has been added to the current paragraph
- out-of-band. This should be used when the writer has been manipulated
- directly. The optional *flag* argument can be set to false if the writer
- manipulations produced a hard line break at the end of the output.
-
-
-.. _formatter-impls:
-
-Formatter Implementations
--------------------------
-
-Two implementations of formatter objects are provided by this module. Most
-applications may use one of these classes without modification or subclassing.
-
-
-.. class:: NullFormatter(writer=None)
-
- A formatter which does nothing. If *writer* is omitted, a :class:`NullWriter`
- instance is created. No methods of the writer are called by
- :class:`NullFormatter` instances. Implementations should inherit from this
- class if implementing a writer interface but don't need to inherit any
- implementation.
-
-
-.. class:: AbstractFormatter(writer)
-
- The standard formatter. This implementation has demonstrated wide applicability
- to many writers, and may be used directly in most circumstances. It has been
- used to implement a full-featured World Wide Web browser.
-
-
-.. _writer-interface:
-
-The Writer Interface
---------------------
-
-Interfaces to create writers are dependent on the specific writer class being
-instantiated. The interfaces described below are the required interfaces which
-all writers must support once initialized. Note that while most applications can
-use the :class:`AbstractFormatter` class as a formatter, the writer must
-typically be provided by the application.
-
-
-.. method:: writer.flush()
-
- Flush any buffered output or device control events.
-
-
-.. method:: writer.new_alignment(align)
-
- Set the alignment style. The *align* value can be any object, but by convention
- is a string or ``None``, where ``None`` indicates that the writer's "preferred"
- alignment should be used. Conventional *align* values are ``'left'``,
- ``'center'``, ``'right'``, and ``'justify'``.
-
-
-.. method:: writer.new_font(font)
-
- Set the font style. The value of *font* will be ``None``, indicating that the
- device's default font should be used, or a tuple of the form ``(size,
- italic, bold, teletype)``. Size will be a string indicating the size of
- font that should be used; specific strings and their interpretation must be
- defined by the application. The *italic*, *bold*, and *teletype* values are
- Boolean values specifying which of those font attributes should be used.
-
-
-.. method:: writer.new_margin(margin, level)
-
- Set the margin level to the integer *level* and the logical tag to *margin*.
- Interpretation of the logical tag is at the writer's discretion; the only
- restriction on the value of the logical tag is that it not be a false value for
- non-zero values of *level*.
-
-
-.. method:: writer.new_spacing(spacing)
-
- Set the spacing style to *spacing*.
-
-
-.. method:: writer.new_styles(styles)
-
- Set additional styles. The *styles* value is a tuple of arbitrary values; the
- value :const:`AS_IS` should be ignored. The *styles* tuple may be interpreted
- either as a set or as a stack depending on the requirements of the application
- and writer implementation.
-
-
-.. method:: writer.send_line_break()
-
- Break the current line.
-
-
-.. method:: writer.send_paragraph(blankline)
-
- Produce a paragraph separation of at least *blankline* blank lines, or the
- equivalent. The *blankline* value will be an integer. Note that the
- implementation will receive a call to :meth:`send_line_break` before this call
- if a line break is needed; this method should not include ending the last line
- of the paragraph. It is only responsible for vertical spacing between
- paragraphs.
-
-
-.. method:: writer.send_hor_rule(*args, **kw)
-
- Display a horizontal rule on the output device. The arguments to this method
- are entirely application- and writer-specific, and should be interpreted with
- care. The method implementation may assume that a line break has already been
- issued via :meth:`send_line_break`.
-
-
-.. method:: writer.send_flowing_data(data)
-
- Output character data which may be word-wrapped and re-flowed as needed. Within
- any sequence of calls to this method, the writer may assume that spans of
- multiple whitespace characters have been collapsed to single space characters.
-
-
-.. method:: writer.send_literal_data(data)
-
- Output character data which has already been formatted for display. Generally,
- this should be interpreted to mean that line breaks indicated by newline
- characters should be preserved and no new line breaks should be introduced. The
- data may contain embedded newline and tab characters, unlike data provided to
- the :meth:`send_formatted_data` interface.
-
-
-.. method:: writer.send_label_data(data)
-
- Set *data* to the left of the current left margin, if possible. The value of
- *data* is not restricted; treatment of non-string values is entirely
- application- and writer-dependent. This method will only be called at the
- beginning of a line.
-
-
-.. _writer-impls:
-
-Writer Implementations
-----------------------
-
-Three implementations of the writer object interface are provided as examples by
-this module. Most applications will need to derive new writer classes from the
-:class:`NullWriter` class.
-
-
-.. class:: NullWriter()
-
- A writer which only provides the interface definition; no actions are taken on
- any methods. This should be the base class for all writers which do not need to
- inherit any implementation methods.
-
-
-.. class:: AbstractWriter()
-
- A writer which can be used in debugging formatters, but not much else. Each
- method simply announces itself by printing its name and arguments on standard
- output.
-
-
-.. class:: DumbWriter(file=None, maxcol=72)
-
- Simple writer class which writes output on the :term:`file object` passed
- in as *file* or, if *file* is omitted, on standard output. The output is
- simply word-wrapped to the number of columns specified by *maxcol*. This
- class is suitable for reflowing a sequence of paragraphs.
-
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index a8a4ca4200..0598a6ce94 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -478,14 +478,15 @@ are always available. They are listed here in alphabetical order.
dictionaries as global and local namespace. If the *globals* dictionary is
present and does not contain a value for the key ``__builtins__``, a
reference to the dictionary of the built-in module :mod:`builtins` is
- inserted under that key before *expression* is parsed. This means that
- *expression* normally has full access to the standard :mod:`builtins`
- module and restricted environments are propagated. If the *locals*
- dictionary is omitted it defaults to the *globals* dictionary. If both
- dictionaries are omitted, the expression is executed with the *globals* and
- *locals* in the environment where :func:`eval` is called. Note, *eval()*
- does not have access to the :term:`nested scopes <nested scope>` (non-locals) in the
- enclosing environment.
+ inserted under that key before *expression* is parsed. That way you can
+ control what builtins are available to the executed code by inserting your
+ own ``__builtins__`` dictionary into *globals* before passing it to
+ :func:`eval`. If the *locals* dictionary is omitted it defaults to the
+ *globals* dictionary. If both dictionaries are omitted, the expression is
+ executed with the *globals* and *locals* in the environment where
+ :func:`eval` is called. Note, *eval()* does not have access to the
+ :term:`nested scopes <nested scope>` (non-locals) in the enclosing
+ environment.
The return value is the result of
the evaluated expression. Syntax errors are reported as exceptions. Example:
@@ -1333,7 +1334,7 @@ are always available. They are listed here in alphabetical order.
supported.
-.. function:: print(*objects, sep=' ', end='\\n', file=sys.stdout, flush=False)
+.. function:: print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
Print *objects* to the text stream *file*, separated by *sep* and followed
by *end*. *sep*, *end*, *file* and *flush*, if present, must be given as keyword
diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst
index 35997db2a9..56f4c0a0d7 100644
--- a/Doc/library/http.client.rst
+++ b/Doc/library/http.client.rst
@@ -99,6 +99,11 @@ The module provides the following classes:
:attr:`ssl.SSLContext.post_handshake_auth` for the default *context* or
when *cert_file* is passed with a custom *context*.
+ .. versionchanged:: 3.10
+ This class now sends an ALPN extension with protocol indicator
+ ``http/1.1`` when no *context* is given. Custom *context* should set
+ ALPN protocols with :meth:`~ssl.SSLContext.set_alpn_protocol`.
+
.. deprecated:: 3.6
*key_file* and *cert_file* are deprecated in favor of *context*.
diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst
index 17792b2005..a2c1eb00d8 100644
--- a/Doc/library/http.cookies.rst
+++ b/Doc/library/http.cookies.rst
@@ -93,7 +93,7 @@ Cookie Objects
:meth:`value_decode` are inverses on the range of *value_decode*.
-.. method:: BaseCookie.output(attrs=None, header='Set-Cookie:', sep='\\r\\n')
+.. method:: BaseCookie.output(attrs=None, header='Set-Cookie:', sep='\r\n')
Return a string representation suitable to be sent as HTTP headers. *attrs* and
*header* are sent to each :class:`Morsel`'s :meth:`output` method. *sep* is used
diff --git a/Doc/library/imaplib.rst b/Doc/library/imaplib.rst
index 02ecfd95d4..65681ec093 100644
--- a/Doc/library/imaplib.rst
+++ b/Doc/library/imaplib.rst
@@ -174,9 +174,9 @@ example of usage.
.. seealso::
- Documents describing the protocol, and sources and binaries for servers
- implementing it, can all be found at the University of Washington's *IMAP
- Information Center* (https://www.washington.edu/imap/).
+ Documents describing the protocol, sources for servers
+ implementing it, by the University of Washington's IMAP Information Center
+ can all be found at (**Source Code**) https://github.com/uw-imap/imap (**Not Maintained**).
.. _imap4-objects:
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 45b62aec9e..f1c444fe82 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -1138,7 +1138,7 @@ find and load modules.
directory for ``''`` (i.e. the empty string).
-.. class:: FileFinder(path, \*loader_details)
+.. class:: FileFinder(path, *loader_details)
A concrete implementation of :class:`importlib.abc.PathEntryFinder` which
caches results from the file system.
@@ -1181,7 +1181,7 @@ find and load modules.
Clear out the internal cache.
- .. classmethod:: path_hook(\*loader_details)
+ .. classmethod:: path_hook(*loader_details)
A class method which returns a closure for use on :attr:`sys.path_hooks`.
An instance of :class:`FileFinder` is returned by the closure using the
diff --git a/Doc/library/index.rst b/Doc/library/index.rst
index bebf7429b0..42f994f8b8 100644
--- a/Doc/library/index.rst
+++ b/Doc/library/index.rst
@@ -72,7 +72,6 @@ the `Python Package Index <https://pypi.org>`_.
custominterp.rst
modules.rst
language.rst
- misc.rst
windows.rst
unix.rst
superseded.rst
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index d00a30ff00..850d6018ba 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -556,7 +556,7 @@ The Signature object represents the call signature of a callable object and its
return annotation. To retrieve a Signature object, use the :func:`signature`
function.
-.. function:: signature(callable, \*, follow_wrapped=True)
+.. function:: signature(callable, *, follow_wrapped=True, globalns=None, localns=None)
Return a :class:`Signature` object for the given ``callable``::
@@ -581,6 +581,9 @@ function.
Raises :exc:`ValueError` if no signature can be provided, and
:exc:`TypeError` if that type of object is not supported.
+ ``globalns`` and ``localns`` are passed into
+ :func:`typing.get_type_hints` when resolving the annotations.
+
A slash(/) in the signature of a function denotes that the parameters prior
to it are positional-only. For more info, see
:ref:`the FAQ entry on positional-only parameters <faq-positional-only-arguments>`.
@@ -590,14 +593,23 @@ function.
``callable`` specifically (``callable.__wrapped__`` will not be used to
unwrap decorated callables.)
+ .. versionadded:: 3.10
+ ``globalns`` and ``localns`` parameters.
+
.. note::
Some callables may not be introspectable in certain implementations of
Python. For example, in CPython, some built-in functions defined in
C provide no metadata about their arguments.
+ .. note::
+
+ Will first try to resolve the annotations, but when it fails and
+ encounters with an error while that operation, the annotations will be
+ returned unchanged (as strings).
+
-.. class:: Signature(parameters=None, \*, return_annotation=Signature.empty)
+.. class:: Signature(parameters=None, *, return_annotation=Signature.empty)
A Signature object represents the call signature of a function and its return
annotation. For each parameter accepted by the function it stores a
@@ -668,11 +680,12 @@ function.
>>> str(new_sig)
"(a, b) -> 'new return anno'"
- .. classmethod:: Signature.from_callable(obj, \*, follow_wrapped=True)
+ .. classmethod:: Signature.from_callable(obj, *, follow_wrapped=True, globalns=None, localns=None)
Return a :class:`Signature` (or its subclass) object for a given callable
``obj``. Pass ``follow_wrapped=False`` to get a signature of ``obj``
- without unwrapping its ``__wrapped__`` chain.
+ without unwrapping its ``__wrapped__`` chain. ``globalns`` and
+ ``localns`` will be used as the namespaces when resolving annotations.
This method simplifies subclassing of :class:`Signature`::
@@ -683,8 +696,11 @@ function.
.. versionadded:: 3.5
+ .. versionadded:: 3.10
+ ``globalns`` and ``localns`` parameters.
+
-.. class:: Parameter(name, kind, \*, default=Parameter.empty, annotation=Parameter.empty)
+.. class:: Parameter(name, kind, *, default=Parameter.empty, annotation=Parameter.empty)
Parameter objects are *immutable*. Instead of modifying a Parameter object,
you can use :meth:`Parameter.replace` to create a modified copy.
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
index aecbec5686..048cb2a7ff 100644
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -964,7 +964,7 @@ Text I/O
.. versionadded:: 3.7
-.. class:: StringIO(initial_value='', newline='\\n')
+.. class:: StringIO(initial_value='', newline='\n')
A text stream using an in-memory text buffer. It inherits
:class:`TextIOBase`.
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index 107bc515a6..03416a0a7f 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -55,6 +55,7 @@ Iterator Arguments Results
:func:`filterfalse` pred, seq elements of seq where pred(elem) is false ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
:func:`groupby` iterable[, key] sub-iterators grouped by value of key(v)
:func:`islice` seq, [start,] stop [, step] elements from seq[start:stop:step] ``islice('ABCDEFG', 2, None) --> C D E F G``
+:func:`pairwise` iterable (p[0], p[1]), (p[1], p[2]) ``pairwise('ABCDEFG') --> AB BC CD DE EF FG``
:func:`starmap` func, seq func(\*seq[0]), func(\*seq[1]), ... ``starmap(pow, [(2,5), (3,2), (10,3)]) --> 32 9 1000``
:func:`takewhile` pred, seq seq[0], seq[1], until pred fails ``takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4``
:func:`tee` it, n it1, it2, ... itn splits one iterator into n
@@ -475,6 +476,22 @@ loops that truncate the stream.
If *start* is ``None``, then iteration starts at zero. If *step* is ``None``,
then the step defaults to one.
+.. function:: pairwise(iterable)
+
+ Return successive overlapping pairs taken from the input *iterable*.
+
+ The number of 2-tuples in the output iterator will be one fewer than the
+ number of inputs. It will be empty if the input iterable has fewer than
+ two values.
+
+ Roughly equivalent to::
+
+ def pairwise(iterable):
+ # pairwise('ABCDEFG') --> AB BC CD DE EF FG
+ a, b = tee(iterable)
+ next(b, None)
+ return zip(a, b)
+
.. function:: permutations(iterable, r=None)
@@ -565,7 +582,7 @@ loops that truncate the stream.
Before :func:`product` runs, it completely consumes the input iterables,
keeping pools of values in memory to generate the products. Accordingly,
- it only useful with finite inputs.
+ it is only useful with finite inputs.
.. function:: repeat(object[, times])
@@ -755,7 +772,7 @@ which incur interpreter overhead.
"Count how many times the predicate is true"
return sum(map(pred, iterable))
- def padnone(iterable):
+ def pad_none(iterable):
"""Returns the sequence elements and then returns None indefinitely.
Useful for emulating the behavior of the built-in map() function.
@@ -769,6 +786,18 @@ which incur interpreter overhead.
def dotproduct(vec1, vec2):
return sum(map(operator.mul, vec1, vec2))
+ def convolve(signal, kernel):
+ # See: https://betterexplained.com/articles/intuitive-convolution/
+ # convolve(data, [0.25, 0.25, 0.25, 0.25]) --> Moving average (blur)
+ # convolve(data, [1, -1]) --> 1st finite difference (1st derivative)
+ # convolve(data, [1, -2, 1]) --> 2nd finite difference (2nd derivative)
+ kernel = list(reversed(kernel))
+ n = len(kernel)
+ window = collections.deque([0] * n, maxlen=n)
+ for x in chain(signal, repeat(0, n-1)):
+ window.append(x)
+ yield sum(map(operator.mul, kernel, window))
+
def flatten(list_of_lists):
"Flatten one level of nesting"
return chain.from_iterable(list_of_lists)
@@ -782,12 +811,6 @@ which incur interpreter overhead.
return starmap(func, repeat(args))
return starmap(func, repeat(args, times))
- def pairwise(iterable):
- "s -> (s0,s1), (s1,s2), (s2, s3), ..."
- a, b = tee(iterable)
- next(b, None)
- return zip(a, b)
-
def grouper(iterable, n, fillvalue=None):
"Collect data into fixed-length chunks or blocks"
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
@@ -809,7 +832,7 @@ which incur interpreter overhead.
nexts = cycle(islice(nexts, num_active))
def partition(pred, iterable):
- 'Use a predicate to partition entries into false entries and true entries'
+ "Use a predicate to partition entries into false entries and true entries"
# partition(is_odd, range(10)) --> 0 2 4 6 8 and 1 3 5 7 9
t1, t2 = tee(iterable)
return filterfalse(pred, t1), filter(pred, t2)
@@ -881,7 +904,7 @@ which incur interpreter overhead.
def random_product(*args, repeat=1):
"Random selection from itertools.product(*args, **kwds)"
pools = [tuple(pool) for pool in args] * repeat
- return tuple(random.choice(pool) for pool in pools)
+ return tuple(map(random.choice, pools))
def random_permutation(iterable, r=None):
"Random selection from itertools.permutations(iterable, r)"
@@ -900,11 +923,11 @@ which incur interpreter overhead.
"Random selection from itertools.combinations_with_replacement(iterable, r)"
pool = tuple(iterable)
n = len(pool)
- indices = sorted(random.randrange(n) for i in range(r))
+ indices = sorted(random.choices(range(n), k=r))
return tuple(pool[i] for i in indices)
def nth_combination(iterable, r, index):
- 'Equivalent to list(combinations(iterable, r))[index]'
+ "Equivalent to list(combinations(iterable, r))[index]"
pool = tuple(iterable)
n = len(pool)
if r < 0 or r > n:
diff --git a/Doc/library/logging.config.rst b/Doc/library/logging.config.rst
index 683d6ed5e8..0b5e2fc2a6 100644
--- a/Doc/library/logging.config.rst
+++ b/Doc/library/logging.config.rst
@@ -35,45 +35,45 @@ in :mod:`logging` itself) and defining handlers which are declared either in
.. function:: dictConfig(config)
- Takes the logging configuration from a dictionary. The contents of
- this dictionary are described in :ref:`logging-config-dictschema`
- below.
-
- If an error is encountered during configuration, this function will
- raise a :exc:`ValueError`, :exc:`TypeError`, :exc:`AttributeError`
- or :exc:`ImportError` with a suitably descriptive message. The
- following is a (possibly incomplete) list of conditions which will
- raise an error:
-
- * A ``level`` which is not a string or which is a string not
- corresponding to an actual logging level.
- * A ``propagate`` value which is not a boolean.
- * An id which does not have a corresponding destination.
- * A non-existent handler id found during an incremental call.
- * An invalid logger name.
- * Inability to resolve to an internal or external object.
-
- Parsing is performed by the :class:`DictConfigurator` class, whose
- constructor is passed the dictionary used for configuration, and
- has a :meth:`configure` method. The :mod:`logging.config` module
- has a callable attribute :attr:`dictConfigClass`
- which is initially set to :class:`DictConfigurator`.
- You can replace the value of :attr:`dictConfigClass` with a
- suitable implementation of your own.
-
- :func:`dictConfig` calls :attr:`dictConfigClass` passing
- the specified dictionary, and then calls the :meth:`configure` method on
- the returned object to put the configuration into effect::
-
- def dictConfig(config):
- dictConfigClass(config).configure()
-
- For example, a subclass of :class:`DictConfigurator` could call
- ``DictConfigurator.__init__()`` in its own :meth:`__init__()`, then
- set up custom prefixes which would be usable in the subsequent
- :meth:`configure` call. :attr:`dictConfigClass` would be bound to
- this new subclass, and then :func:`dictConfig` could be called exactly as
- in the default, uncustomized state.
+ Takes the logging configuration from a dictionary. The contents of
+ this dictionary are described in :ref:`logging-config-dictschema`
+ below.
+
+ If an error is encountered during configuration, this function will
+ raise a :exc:`ValueError`, :exc:`TypeError`, :exc:`AttributeError`
+ or :exc:`ImportError` with a suitably descriptive message. The
+ following is a (possibly incomplete) list of conditions which will
+ raise an error:
+
+ * A ``level`` which is not a string or which is a string not
+ corresponding to an actual logging level.
+ * A ``propagate`` value which is not a boolean.
+ * An id which does not have a corresponding destination.
+ * A non-existent handler id found during an incremental call.
+ * An invalid logger name.
+ * Inability to resolve to an internal or external object.
+
+ Parsing is performed by the :class:`DictConfigurator` class, whose
+ constructor is passed the dictionary used for configuration, and
+ has a :meth:`configure` method. The :mod:`logging.config` module
+ has a callable attribute :attr:`dictConfigClass`
+ which is initially set to :class:`DictConfigurator`.
+ You can replace the value of :attr:`dictConfigClass` with a
+ suitable implementation of your own.
+
+ :func:`dictConfig` calls :attr:`dictConfigClass` passing
+ the specified dictionary, and then calls the :meth:`configure` method on
+ the returned object to put the configuration into effect::
+
+ def dictConfig(config):
+ dictConfigClass(config).configure()
+
+ For example, a subclass of :class:`DictConfigurator` could call
+ ``DictConfigurator.__init__()`` in its own :meth:`__init__()`, then
+ set up custom prefixes which would be usable in the subsequent
+ :meth:`configure` call. :attr:`dictConfigClass` would be bound to
+ this new subclass, and then :func:`dictConfig` could be called exactly as
+ in the default, uncustomized state.
.. versionadded:: 3.2
diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst
index fb8ea705b0..431a5849fa 100644
--- a/Doc/library/logging.rst
+++ b/Doc/library/logging.rst
@@ -1096,8 +1096,8 @@ functions.
suitable value.
.. versionchanged:: 3.7
- The *level* parameter was defaulted to level ``CRITICAL``. See Issue
- #28524 for more information about this change.
+ The *level* parameter was defaulted to level ``CRITICAL``. See
+ :issue:`28524` for more information about this change.
.. function:: addLevelName(level, levelName)
@@ -1174,7 +1174,9 @@ functions.
| | to ``'a'``. |
+--------------+---------------------------------------------+
| *format* | Use the specified format string for the |
- | | handler. |
+ | | handler. Defaults to attributes |
+ | | ``levelname``, ``name`` and ``message`` |
+ | | separated by colons. |
+--------------+---------------------------------------------+
| *datefmt* | Use the specified date/time format, as |
| | accepted by :func:`time.strftime`. |
diff --git a/Doc/library/lzma.rst b/Doc/library/lzma.rst
index 4bfff9c614..633c87873c 100644
--- a/Doc/library/lzma.rst
+++ b/Doc/library/lzma.rst
@@ -33,7 +33,7 @@ from multiple threads, it is necessary to protect it with a lock.
Reading and writing compressed files
------------------------------------
-.. function:: open(filename, mode="rb", \*, format=None, check=-1, preset=None, filters=None, encoding=None, errors=None, newline=None)
+.. function:: open(filename, mode="rb", *, format=None, check=-1, preset=None, filters=None, encoding=None, errors=None, newline=None)
Open an LZMA-compressed file in binary or text mode, returning a :term:`file
object`.
@@ -69,7 +69,7 @@ Reading and writing compressed files
Accepts a :term:`path-like object`.
-.. class:: LZMAFile(filename=None, mode="r", \*, format=None, check=-1, preset=None, filters=None)
+.. class:: LZMAFile(filename=None, mode="r", *, format=None, check=-1, preset=None, filters=None)
Open an LZMA-compressed file in binary mode.
diff --git a/Doc/library/misc.rst b/Doc/library/misc.rst
deleted file mode 100644
index 0943235246..0000000000
--- a/Doc/library/misc.rst
+++ /dev/null
@@ -1,13 +0,0 @@
-.. _misc:
-
-**********************
-Miscellaneous Services
-**********************
-
-The modules described in this chapter provide miscellaneous services that are
-available in all Python versions. Here's an overview:
-
-
-.. toctree::
-
- formatter.rst
diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst
index 698c176537..d9825b47c7 100644
--- a/Doc/library/mmap.rst
+++ b/Doc/library/mmap.rst
@@ -337,6 +337,8 @@ MADV_* Constants
MADV_NOCORE
MADV_CORE
MADV_PROTECT
+ MADV_FREE_REUSABLE
+ MADV_FREE_REUSE
These options can be passed to :meth:`mmap.madvise`. Not every option will
be present on every system.
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
index f8e7556f25..e109b1ebe1 100644
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -98,7 +98,7 @@ to start a process. These *start methods* are
*spawn*
The parent process starts a fresh python interpreter process. The
child process will only inherit those resources necessary to run
- the process objects :meth:`~Process.run` method. In particular,
+ the process object's :meth:`~Process.run` method. In particular,
unnecessary file descriptors and handles from the parent process
will not be inherited. Starting a process using this method is
rather slow compared to using *fork* or *forkserver*.
@@ -2569,9 +2569,9 @@ Address Formats
filesystem.
* An ``'AF_PIPE'`` address is a string of the form
- :samp:`r'\\\\.\\pipe\\{PipeName}'`. To use :func:`Client` to connect to a named
- pipe on a remote computer called *ServerName* one should use an address of the
- form :samp:`r'\\\\{ServerName}\\pipe\\{PipeName}'` instead.
+ :samp:`r'\\\\.\\pipe\\{PipeName}'`. To use :func:`Client` to connect to a named
+ pipe on a remote computer called *ServerName* one should use an address of the
+ form :samp:`r'\\\\{ServerName}\\pipe\\{PipeName}'` instead.
Note that any string beginning with two backslashes is assumed by default to be
an ``'AF_PIPE'`` address rather than an ``'AF_UNIX'`` address.
@@ -2661,6 +2661,46 @@ The :mod:`multiprocessing.dummy` module
:mod:`multiprocessing.dummy` replicates the API of :mod:`multiprocessing` but is
no more than a wrapper around the :mod:`threading` module.
+.. currentmodule:: multiprocessing.pool
+
+In particular, the ``Pool`` function provided by :mod:`multiprocessing.dummy`
+returns an instance of :class:`ThreadPool`, which is a subclass of
+:class:`Pool` that supports all the same method calls but uses a pool of
+worker threads rather than worker processes.
+
+
+.. class:: ThreadPool([processes[, initializer[, initargs]]])
+
+ A thread pool object which controls a pool of worker threads to which jobs
+ can be submitted. :class:`ThreadPool` instances are fully interface
+ compatible with :class:`Pool` instances, and their resources must also be
+ properly managed, either by using the pool as a context manager or by
+ calling :meth:`~multiprocessing.pool.Pool.close` and
+ :meth:`~multiprocessing.pool.Pool.terminate` manually.
+
+ *processes* is the number of worker threads to use. If *processes* is
+ ``None`` then the number returned by :func:`os.cpu_count` is used.
+
+ If *initializer* is not ``None`` then each worker process will call
+ ``initializer(*initargs)`` when it starts.
+
+ Unlike :class:`Pool`, *maxtasksperchild* and *context* cannot be provided.
+
+ .. note::
+
+ A :class:`ThreadPool` shares the same interface as :class:`Pool`, which
+ is designed around a pool of processes and predates the introduction of
+ the :class:`concurrent.futures` module. As such, it inherits some
+ operations that don't make sense for a pool backed by threads, and it
+ has its own type for representing the status of asynchronous jobs,
+ :class:`AsyncResult`, that is not understood by any other libraries.
+
+ Users should generally prefer to use
+ :class:`concurrent.futures.ThreadPoolExecutor`, which has a simpler
+ interface that was designed around threads from the start, and which
+ returns :class:`concurrent.futures.Future` instances that are
+ compatible with many other libraries, including :mod:`asyncio`.
+
.. _multiprocessing-programming:
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index f9f35b3124..35cf7c0a0b 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -32,7 +32,7 @@ Notes on the availability of these functions:
objects, and result in an object of the same type, if a path or file name is
returned.
-* On VxWorks, os.fork, os.execv and os.spawn*p* are not supported.
+* On VxWorks, os.popen, os.fork, os.execv and os.spawn*p* are not supported.
.. note::
@@ -113,6 +113,8 @@ of the UTF-8 encoding:
:ref:`error handler <error-handlers>` being enabled for :data:`sys.stdin`
and :data:`sys.stdout` (:data:`sys.stderr` continues to use
``backslashreplace`` as it does in the default locale-aware mode)
+* On Unix, :func:`os.device_encoding` returns ``'UTF-8'``. rather than the
+ device encoding.
Note that the standard stream settings in UTF-8 mode can be overridden by
:envvar:`PYTHONIOENCODING` (just as they can be in the default locale-aware
@@ -808,6 +810,12 @@ as internal buffering of data.
Return a string describing the encoding of the device associated with *fd*
if it is connected to a terminal; else return :const:`None`.
+ On Unix, if the :ref:`Python UTF-8 Mode <utf8-mode>` is enabled, return
+ ``'UTF-8'`` rather than the device encoding.
+
+ .. versionchanged:: 3.10
+ On Unix, the function now implements the Python UTF-8 Mode.
+
.. function:: dup(fd)
@@ -1315,12 +1323,12 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
.. data:: RWF_APPEND
- Provide a per-write equivalent of the :data:`O_APPEND` :func:`os.open`
- flag. This flag is meaningful only for :func:`os.pwritev`, and its
- effect applies only to the data range written by the system call. The
- *offset* argument does not affect the write operation; the data is always
- appended to the end of the file. However, if the *offset* argument is
- ``-1``, the current file *offset* is updated.
+ Provide a per-write equivalent of the :data:`O_APPEND` :func:`os.open`
+ flag. This flag is meaningful only for :func:`os.pwritev`, and its
+ effect applies only to the data range written by the system call. The
+ *offset* argument does not affect the write operation; the data is always
+ appended to the end of the file. However, if the *offset* argument is
+ ``-1``, the current file *offset* is updated.
.. availability:: Linux 4.16 and newer.
@@ -1411,6 +1419,39 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
.. versionadded:: 3.3
+.. function:: splice(src, dst, count, offset_src=None, offset_dst=None)
+
+ Transfer *count* bytes from file descriptor *src*, starting from offset
+ *offset_src*, to file descriptor *dst*, starting from offset *offset_dst*.
+ At least one of the file descriptors must refer to a pipe. If *offset_src*
+ is None, then *src* is read from the current position; respectively for
+ *offset_dst*. The offset associated to the file descriptor that refers to a
+ pipe must be ``None``. The files pointed by *src* and *dst* must reside in
+ the same filesystem, otherwise an :exc:`OSError` is raised with
+ :attr:`~OSError.errno` set to :data:`errno.EXDEV`.
+
+ This copy is done without the additional cost of transferring data
+ from the kernel to user space and then back into the kernel. Additionally,
+ some filesystems could implement extra optimizations. The copy is done as if
+ both files are opened as binary.
+
+ Upon successful completion, returns the number of bytes spliced to or from
+ the pipe. A return value of 0 means end of input. If *src* refers to a
+ pipe, then this means that there was no data to transfer, and it would not
+ make sense to block because there are no writers connected to the write end
+ of the pipe.
+
+ .. availability:: Linux kernel >= 2.6.17 and glibc >= 2.5
+
+ .. versionadded:: 3.10
+
+
+.. data:: SPLICE_F_MOVE
+ SPLICE_F_NONBLOCK
+ SPLICE_F_MORE
+
+ .. versionadded:: 3.10
+
.. function:: readv(fd, buffers)
Read from a file descriptor *fd* into a number of mutable :term:`bytes-like
@@ -1950,7 +1991,7 @@ features:
Accepts a :term:`path-like object`.
-.. function:: lstat(path, \*, dir_fd=None)
+.. function:: lstat(path, *, dir_fd=None)
Perform the equivalent of an :c:func:`lstat` system call on the given path.
Similar to :func:`~os.stat`, but does not follow symbolic links. Return a
@@ -2457,7 +2498,7 @@ features:
On the first, uncached call, a system call is required on Windows but
not on Unix.
- .. method:: is_dir(\*, follow_symlinks=True)
+ .. method:: is_dir(*, follow_symlinks=True)
Return ``True`` if this entry is a directory or a symbolic link pointing
to a directory; return ``False`` if the entry is or points to any other
@@ -2481,7 +2522,7 @@ features:
This method can raise :exc:`OSError`, such as :exc:`PermissionError`,
but :exc:`FileNotFoundError` is caught and not raised.
- .. method:: is_file(\*, follow_symlinks=True)
+ .. method:: is_file(*, follow_symlinks=True)
Return ``True`` if this entry is a file or a symbolic link pointing to a
file; return ``False`` if the entry is or points to a directory or other
@@ -2511,7 +2552,7 @@ features:
This method can raise :exc:`OSError`, such as :exc:`PermissionError`,
but :exc:`FileNotFoundError` is caught and not raised.
- .. method:: stat(\*, follow_symlinks=True)
+ .. method:: stat(*, follow_symlinks=True)
Return a :class:`stat_result` object for this entry. This method
follows symbolic links by default; to stat a symbolic link add the
@@ -2543,7 +2584,7 @@ features:
for :class:`bytes` paths on Windows.
-.. function:: stat(path, \*, dir_fd=None, follow_symlinks=True)
+.. function:: stat(path, *, dir_fd=None, follow_symlinks=True)
Get the status of a file or a file descriptor. Perform the equivalent of a
:c:func:`stat` system call on the given path. *path* may be specified as
@@ -3268,6 +3309,102 @@ features:
.. versionadded:: 3.8
+.. function:: eventfd(initval[, flags=os.EFD_CLOEXEC])
+
+ Create and return an event file descriptor. The file descriptors supports
+ raw :func:`read` and :func:`write` with a buffer size of 8,
+ :func:`~select.select`, :func:`~select.poll` and similar. See man page
+ :manpage:`eventfd(2)` for more information. By default, the
+ new file descriptor is :ref:`non-inheritable <fd_inheritance>`.
+
+ *initval* is the initial value of the event counter. The initial value
+ must be an 32 bit unsigned integer. Please note that the initial value is
+ limited to a 32 bit unsigned int although the event counter is an unsigned
+ 64 bit integer with a maximum value of 2\ :sup:`64`\ -\ 2.
+
+ *flags* can be constructed from :const:`EFD_CLOEXEC`,
+ :const:`EFD_NONBLOCK`, and :const:`EFD_SEMAPHORE`.
+
+ If :const:`EFD_SEMAPHORE` is specified and the event counter is non-zero,
+ :func:`eventfd_read` returns 1 and decrements the counter by one.
+
+ If :const:`EFD_SEMAPHORE` is not specified and the event counter is
+ non-zero, :func:`eventfd_read` returns the current event counter value and
+ resets the counter to zero.
+
+ If the event counter is zero and :const:`EFD_NONBLOCK` is not
+ specified, :func:`eventfd_read` blocks.
+
+ :func:`eventfd_write` increments the event counter. Write blocks if the
+ write operation would increment the counter to a value larger than
+ 2\ :sup:`64`\ -\ 2.
+
+ Example::
+
+ import os
+
+ # semaphore with start value '1'
+ fd = os.eventfd(1, os.EFD_SEMAPHORE | os.EFC_CLOEXEC)
+ try:
+ # acquire semaphore
+ v = os.eventfd_read(fd)
+ try:
+ do_work()
+ finally:
+ # release semaphore
+ os.eventfd_write(fd, v)
+ finally:
+ os.close(fd)
+
+ .. availability:: Linux 2.6.27 or newer with glibc 2.8 or newer.
+
+ .. versionadded:: 3.10
+
+.. function:: eventfd_read(fd)
+
+ Read value from an :func:`eventfd` file descriptor and return a 64 bit
+ unsigned int. The function does not verify that *fd* is an :func:`eventfd`.
+
+ .. availability:: See :func:`eventfd`
+
+ .. versionadded:: 3.10
+
+.. function:: eventfd_write(fd, value)
+
+ Add value to an :func:`eventfd` file descriptor. *value* must be a 64 bit
+ unsigned int. The function does not verify that *fd* is an :func:`eventfd`.
+
+ .. availability:: See :func:`eventfd`
+
+ .. versionadded:: 3.10
+
+.. data:: EFD_CLOEXEC
+
+ Set close-on-exec flag for new :func:`eventfd` file descriptor.
+
+ .. availability:: See :func:`eventfd`
+
+ .. versionadded:: 3.10
+
+.. data:: EFD_NONBLOCK
+
+ Set :const:`O_NONBLOCK` status flag for new :func:`eventfd` file
+ descriptor.
+
+ .. availability:: See :func:`eventfd`
+
+ .. versionadded:: 3.10
+
+.. data:: EFD_SEMAPHORE
+
+ Provide semaphore-like semantics for reads from a :func:`eventfd` file
+ descriptor. On read the internal counter is decremented by one.
+
+ .. availability:: Linux 2.6.30 or newer with glibc 2.8 or newer.
+
+ .. versionadded:: 3.10
+
+
Linux extended attributes
~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index 9de72bb725..2bbf3aad61 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -336,6 +336,8 @@ Pure paths provide the following methods and properties:
>>> p.parents[2]
PureWindowsPath('c:/')
+ .. versionchanged:: 3.10
+ The parents sequence now supports :term:`slices <slice>` and negative index values.
.. data:: PurePath.parent
diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst
index b7c3452771..be48561ed1 100644
--- a/Doc/library/pickle.rst
+++ b/Doc/library/pickle.rst
@@ -213,7 +213,7 @@ The :mod:`pickle` module provides the following constants:
The :mod:`pickle` module provides the following functions to make the pickling
process more convenient:
-.. function:: dump(obj, file, protocol=None, \*, fix_imports=True, buffer_callback=None)
+.. function:: dump(obj, file, protocol=None, *, fix_imports=True, buffer_callback=None)
Write the pickled representation of the object *obj* to the open
:term:`file object` *file*. This is equivalent to
@@ -225,7 +225,7 @@ process more convenient:
.. versionchanged:: 3.8
The *buffer_callback* argument was added.
-.. function:: dumps(obj, protocol=None, \*, fix_imports=True, buffer_callback=None)
+.. function:: dumps(obj, protocol=None, *, fix_imports=True, buffer_callback=None)
Return the pickled representation of the object *obj* as a :class:`bytes` object,
instead of writing it to a file.
@@ -236,7 +236,7 @@ process more convenient:
.. versionchanged:: 3.8
The *buffer_callback* argument was added.
-.. function:: load(file, \*, fix_imports=True, encoding="ASCII", errors="strict", buffers=None)
+.. function:: load(file, *, fix_imports=True, encoding="ASCII", errors="strict", buffers=None)
Read the pickled representation of an object from the open :term:`file object`
*file* and return the reconstituted object hierarchy specified therein.
@@ -252,7 +252,7 @@ process more convenient:
.. versionchanged:: 3.8
The *buffers* argument was added.
-.. function:: loads(data, /, \*, fix_imports=True, encoding="ASCII", errors="strict", buffers=None)
+.. function:: loads(data, /, *, fix_imports=True, encoding="ASCII", errors="strict", buffers=None)
Return the reconstituted object hierarchy of the pickled representation
*data* of an object. *data* must be a :term:`bytes-like object`.
@@ -296,7 +296,7 @@ The :mod:`pickle` module defines three exceptions:
The :mod:`pickle` module exports three classes, :class:`Pickler`,
:class:`Unpickler` and :class:`PickleBuffer`:
-.. class:: Pickler(file, protocol=None, \*, fix_imports=True, buffer_callback=None)
+.. class:: Pickler(file, protocol=None, *, fix_imports=True, buffer_callback=None)
This takes a binary file for writing a pickle data stream.
@@ -391,7 +391,7 @@ The :mod:`pickle` module exports three classes, :class:`Pickler`,
Use :func:`pickletools.optimize` if you need more compact pickles.
-.. class:: Unpickler(file, \*, fix_imports=True, encoding="ASCII", errors="strict", buffers=None)
+.. class:: Unpickler(file, *, fix_imports=True, encoding="ASCII", errors="strict", buffers=None)
This takes a binary file for reading a pickle data stream.
diff --git a/Doc/library/pipes.rst b/Doc/library/pipes.rst
index 0a22da1f55..57e27a6acf 100644
--- a/Doc/library/pipes.rst
+++ b/Doc/library/pipes.rst
@@ -17,6 +17,8 @@ The :mod:`pipes` module defines a class to abstract the concept of a *pipeline*
Because the module uses :program:`/bin/sh` command lines, a POSIX or compatible
shell for :func:`os.system` and :func:`os.popen` is required.
+.. availability:: Unix. Not available on VxWorks.
+
The :mod:`pipes` module defines the following class:
diff --git a/Doc/library/platform.rst b/Doc/library/platform.rst
index 8e8e3775aa..be86e568c1 100644
--- a/Doc/library/platform.rst
+++ b/Doc/library/platform.rst
@@ -209,13 +209,6 @@ Windows Platform
which means the OS version uses debugging code, i.e. code that checks arguments,
ranges, etc.
- .. note::
-
- This function works best with Mark Hammond's
- :mod:`win32all` package installed, but also on Python 2.3 and
- later (support for this was added in Python 2.6). It obviously
- only runs on Win32 compatible platforms.
-
.. function:: win32_edition()
Returns a string representing the current Windows edition. Possible
@@ -260,3 +253,41 @@ Unix Platforms
using :program:`gcc`.
The file is read and scanned in chunks of *chunksize* bytes.
+
+
+Linux Platforms
+---------------
+
+.. function:: freedesktop_os_release()
+
+ Get operating system identification from ``os-release`` file and return
+ it as a dict. The ``os-release`` file is a `freedesktop.org standard
+ <https://www.freedesktop.org/software/systemd/man/os-release.html>`_ and
+ is available in most Linux distributions. A noticeable exception is
+ Android and Android-based distributions.
+
+ Raises :exc:`OSError` or subclass when neither ``/etc/os-release`` nor
+ ``/usr/lib/os-release`` can be read.
+
+ On success, the function returns a dictionary where keys and values are
+ strings. Values have their special characters like ``"`` and ``$``
+ unquoted. The fields ``NAME``, ``ID``, and ``PRETTY_NAME`` are always
+ defined according to the standard. All other fields are optional. Vendors
+ may include additional fields.
+
+ Note that fields like ``NAME``, ``VERSION``, and ``VARIANT`` are strings
+ suitable for presentation to users. Programs should use fields like
+ ``ID``, ``ID_LIKE``, ``VERSION_ID``, or ``VARIANT_ID`` to identify
+ Linux distributions.
+
+ Example::
+
+ def get_like_distro():
+ info = platform.freedesktop_os_release()
+ ids = [info["ID"]]
+ if "ID_LIKE" in info:
+ # ids are space separated and ordered by precedence
+ ids.extend(info["ID_LIKE"].split())
+ return ids
+
+ .. versionadded:: 3.10
diff --git a/Doc/library/plistlib.rst b/Doc/library/plistlib.rst
index 6def72b373..ce6d4a85bf 100644
--- a/Doc/library/plistlib.rst
+++ b/Doc/library/plistlib.rst
@@ -52,7 +52,7 @@ or :class:`datetime.datetime` objects.
This module defines the following functions:
-.. function:: load(fp, \*, fmt=None, dict_type=dict)
+.. function:: load(fp, *, fmt=None, dict_type=dict)
Read a plist file. *fp* should be a readable and binary file object.
Return the unpacked root object (which usually is a
@@ -80,7 +80,7 @@ This module defines the following functions:
.. versionadded:: 3.4
-.. function:: loads(data, \*, fmt=None, dict_type=dict)
+.. function:: loads(data, *, fmt=None, dict_type=dict)
Load a plist from a bytes object. See :func:`load` for an explanation of
the keyword arguments.
@@ -88,7 +88,7 @@ This module defines the following functions:
.. versionadded:: 3.4
-.. function:: dump(value, fp, \*, fmt=FMT_XML, sort_keys=True, skipkeys=False)
+.. function:: dump(value, fp, *, fmt=FMT_XML, sort_keys=True, skipkeys=False)
Write *value* to a plist file. *Fp* should be a writable, binary
file object.
@@ -116,7 +116,7 @@ This module defines the following functions:
.. versionadded:: 3.4
-.. function:: dumps(value, \*, fmt=FMT_XML, sort_keys=True, skipkeys=False)
+.. function:: dumps(value, *, fmt=FMT_XML, sort_keys=True, skipkeys=False)
Return *value* as a plist-formatted bytes object. See
the documentation for :func:`dump` for an explanation of the keyword
diff --git a/Doc/library/profile.rst b/Doc/library/profile.rst
index 34525a96f5..774d46d0e9 100644
--- a/Doc/library/profile.rst
+++ b/Doc/library/profile.rst
@@ -525,16 +525,16 @@ Analysis of the profiler data is done using the :class:`~pstats.Stats` class.
ordering are identical to the :meth:`~pstats.Stats.print_callers` method.
- .. method:: get_stats_profile()
+ .. method:: get_stats_profile()
This method returns an instance of StatsProfile, which contains a mapping
of function names to instances of FunctionProfile. Each FunctionProfile
instance holds information related to the function's profile such as how
long the function took to run, how many times it was called, etc...
- .. versionadded:: 3.9
- Added the following dataclasses: StatsProfile, FunctionProfile.
- Added the following function: get_stats_profile.
+ .. versionadded:: 3.9
+ Added the following dataclasses: StatsProfile, FunctionProfile.
+ Added the following function: get_stats_profile.
.. _deterministic-profiling:
diff --git a/Doc/library/pyclbr.rst b/Doc/library/pyclbr.rst
index 36e83e85c2..1c40ba4838 100644
--- a/Doc/library/pyclbr.rst
+++ b/Doc/library/pyclbr.rst
@@ -97,6 +97,13 @@ statements. They have the following attributes:
.. versionadded:: 3.7
+.. attribute:: Function.is_async
+
+ ``True`` for functions that are defined with the ``async`` prefix, ``False`` otherwise.
+
+ .. versionadded:: 3.10
+
+
.. _pyclbr-class-objects:
Class Objects
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index c243aced98..fa5c74b40b 100644
--- a/Doc/library/random.rst
+++ b/Doc/library/random.rst
@@ -142,10 +142,11 @@ Functions for integers
.. function:: getrandbits(k)
- Returns a Python integer with *k* random bits. This method is supplied with
- the MersenneTwister generator and some other generators may also provide it
- as an optional part of the API. When available, :meth:`getrandbits` enables
- :meth:`randrange` to handle arbitrarily large ranges.
+ Returns a non-negative Python integer with *k* random bits. This method
+ is supplied with the MersenneTwister generator and some other generators
+ may also provide it as an optional part of the API. When available,
+ :meth:`getrandbits` enables :meth:`randrange` to handle arbitrarily large
+ ranges.
.. versionchanged:: 3.9
This method now accepts zero for *k*.
diff --git a/Doc/library/shlex.rst b/Doc/library/shlex.rst
index 7f7f0c7f12..aab6a54379 100644
--- a/Doc/library/shlex.rst
+++ b/Doc/library/shlex.rst
@@ -61,6 +61,20 @@ The :mod:`shlex` module defines the following functions:
string that can safely be used as one token in a shell command line, for
cases where you cannot use a list.
+ .. _shlex-quote-warning:
+
+ .. warning::
+
+ The ``shlex`` module is **only designed for Unix shells**.
+
+ The :func:`quote` function is not guaranteed to be correct on non-POSIX
+ compliant shells or shells from other operating systems such as Windows.
+ Executing commands quoted by this module on such shells can open up the
+ possibility of a command injection vulnerability.
+
+ Consider using functions that pass command arguments with lists such as
+ :func:`subprocess.run` with ``shell=False``.
+
This idiom would be unsafe:
>>> filename = 'somefile; rm -rf ~'
diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst
index 3f5122760e..435787c276 100644
--- a/Doc/library/shutil.rst
+++ b/Doc/library/shutil.rst
@@ -218,7 +218,7 @@ Directory and files operations
copy the file more efficiently. See
:ref:`shutil-platform-dependent-efficient-copy-operations` section.
-.. function:: ignore_patterns(\*patterns)
+.. function:: ignore_patterns(*patterns)
This factory function creates a function that can be used as a callable for
:func:`copytree`\'s *ignore* argument, ignoring files and directories that
diff --git a/Doc/library/signal.rst b/Doc/library/signal.rst
index 00a730b6b9..84a569d03e 100644
--- a/Doc/library/signal.rst
+++ b/Doc/library/signal.rst
@@ -117,7 +117,7 @@ The variables defined in the :mod:`signal` module are:
Child process stopped or terminated.
- .. availability:: Windows.
+ .. availability:: Unix.
.. data:: SIGCLD
diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst
index b3cc60357f..52220f7a7f 100644
--- a/Doc/library/smtplib.rst
+++ b/Doc/library/smtplib.rst
@@ -32,7 +32,7 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
than a success code, an :exc:`SMTPConnectError` is raised. The optional
*timeout* parameter specifies a timeout in seconds for blocking operations
like the connection attempt (if not specified, the global default timeout
- setting will be used). If the timeout expires, :exc:`socket.timeout` is
+ setting will be used). If the timeout expires, :exc:`TimeoutError` is
raised. The optional source_address parameter allows binding
to some specific source address in a machine with multiple network
interfaces, and/or to some specific source TCP port. It takes a 2-tuple
@@ -115,7 +115,7 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
If the *timeout* parameter is set to be zero, it will raise a
:class:`ValueError` to prevent the creation of a non-blocking socket
-.. class:: LMTP(host='', port=LMTP_PORT, local_hostname=None,
+.. class:: LMTP(host='', port=LMTP_PORT, local_hostname=None, \
source_address=None[, timeout])
The LMTP protocol, which is very similar to ESMTP, is heavily based on the
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index faf8a76251..4511ff9ea4 100755
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -56,12 +56,12 @@ created. Socket addresses are represented as follows:
bytes-like object can be used for either type of address when
passing it as an argument.
- .. versionchanged:: 3.3
- Previously, :const:`AF_UNIX` socket paths were assumed to use UTF-8
- encoding.
+ .. versionchanged:: 3.3
+ Previously, :const:`AF_UNIX` socket paths were assumed to use UTF-8
+ encoding.
- .. versionchanged:: 3.5
- Writable :term:`bytes-like object` is now accepted.
+ .. versionchanged:: 3.5
+ Writable :term:`bytes-like object` is now accepted.
.. _host_port:
@@ -283,6 +283,8 @@ Exceptions
.. exception:: timeout
+ A deprecated alias of :exc:`TimeoutError`.
+
A subclass of :exc:`OSError`, this exception is raised when a timeout
occurs on a socket which has had timeouts enabled via a prior call to
:meth:`~socket.settimeout` (or implicitly through
@@ -292,6 +294,9 @@ Exceptions
.. versionchanged:: 3.3
This class was made a subclass of :exc:`OSError`.
+ .. versionchanged:: 3.10
+ This class was made an alias of :exc:`TimeoutError`.
+
Constants
^^^^^^^^^
@@ -1208,7 +1213,7 @@ to sockets.
address family --- see above.)
If the connection is interrupted by a signal, the method waits until the
- connection completes, or raise a :exc:`socket.timeout` on timeout, if the
+ connection completes, or raise a :exc:`TimeoutError` on timeout, if the
signal handler doesn't raise an exception and the socket is blocking or has
a timeout. For non-blocking sockets, the method raises an
:exc:`InterruptedError` exception if the connection is interrupted by a
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
index 13aa8c512d..c36648775a 100644
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -198,7 +198,9 @@ Module functions and constants
*detect_types* defaults to 0 (i. e. off, no type detection), you can set it to
any combination of :const:`PARSE_DECLTYPES` and :const:`PARSE_COLNAMES` to turn
- type detection on.
+ type detection on. Due to SQLite behaviour, types can't be detected for generated
+ fields (for example ``max(data)``), even when *detect_types* parameter is set. In
+ such case, the returned type is :class:`str`.
By default, *check_same_thread* is :const:`True` and only the creating thread may
use the connection. If set :const:`False`, the returned connection may be shared
diff --git a/Doc/library/statistics.rst b/Doc/library/statistics.rst
index 38a499ab37..6467704006 100644
--- a/Doc/library/statistics.rst
+++ b/Doc/library/statistics.rst
@@ -156,10 +156,11 @@ However, for reading convenience, most of the examples show sorted sequences.
.. versionadded:: 3.8
-.. function:: harmonic_mean(data)
+.. function:: harmonic_mean(data, weights=None)
Return the harmonic mean of *data*, a sequence or iterable of
- real-valued numbers.
+ real-valued numbers. If *weights* is omitted or *None*, then
+ equal weighting is assumed.
The harmonic mean, sometimes called the subcontrary mean, is the
reciprocal of the arithmetic :func:`mean` of the reciprocals of the
@@ -179,17 +180,17 @@ However, for reading convenience, most of the examples show sorted sequences.
>>> harmonic_mean([40, 60])
48.0
- Suppose an investor purchases an equal value of shares in each of
- three companies, with P/E (price/earning) ratios of 2.5, 3 and 10.
- What is the average P/E ratio for the investor's portfolio?
+ Suppose a car travels 40 km/hr for 5 km, and when traffic clears,
+ speeds-up to 60 km/hr for the remaining 30 km of the journey. What
+ is the average speed?
.. doctest::
- >>> harmonic_mean([2.5, 3, 10]) # For an equal investment portfolio.
- 3.6
+ >>> harmonic_mean([40, 60], weights=[5, 30])
+ 56.0
- :exc:`StatisticsError` is raised if *data* is empty, or any element
- is less than zero.
+ :exc:`StatisticsError` is raised if *data* is empty, any element
+ is less than zero, or if the weighted sum isn't positive.
The current algorithm has an early-out when it encounters a zero
in the input. This means that the subsequent inputs are not tested
@@ -197,6 +198,8 @@ However, for reading convenience, most of the examples show sorted sequences.
.. versionadded:: 3.6
+ .. versionchanged:: 3.8
+ Added support for *weights*.
.. function:: median(data)
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 84d5a3a59f..2869378bbd 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -499,7 +499,7 @@ class`. In addition, it provides a few more methods:
.. versionadded:: 3.10
-.. method:: int.to_bytes(length, byteorder, \*, signed=False)
+.. method:: int.to_bytes(length, byteorder, *, signed=False)
Return an array of bytes representing an integer.
@@ -531,7 +531,7 @@ class`. In addition, it provides a few more methods:
.. versionadded:: 3.2
-.. classmethod:: int.from_bytes(bytes, byteorder, \*, signed=False)
+.. classmethod:: int.from_bytes(bytes, byteorder, *, signed=False)
Return the integer represented by the given array of bytes.
@@ -5065,7 +5065,7 @@ instantiated from the type::
>>> class M(type):
... def __or__(self, other):
- ... return "Hello"
+ ... return "Hello"
...
>>> class C(metaclass=M):
... pass
@@ -5353,8 +5353,8 @@ types, where they are relevant. Some of these are not reported by the
.. method:: class.__subclasses__
Each class keeps a list of weak references to its immediate subclasses. This
- method returns a list of all those references still alive.
- Example::
+ method returns a list of all those references still alive. The list is in
+ definition order. Example::
>>> int.__subclasses__()
[<class 'bool'>]
diff --git a/Doc/library/string.rst b/Doc/library/string.rst
index 91f43e9353..54786d0c2a 100644
--- a/Doc/library/string.rst
+++ b/Doc/library/string.rst
@@ -384,10 +384,10 @@ following:
The ``'#'`` option causes the "alternate form" to be used for the
conversion. The alternate form is defined differently for different
-types. This option is only valid for integer, float, complex and
-Decimal types. For integers, when binary, octal, or hexadecimal output
+types. This option is only valid for integer, float and complex
+types. For integers, when binary, octal, or hexadecimal output
is used, this option adds the prefix respective ``'0b'``, ``'0o'``, or
-``'0x'`` to the output value. For floats, complex and Decimal the
+``'0x'`` to the output value. For float and complex the
alternate form causes the result of the conversion to always contain a
decimal-point character, even if no digits follow it. Normally, a
decimal-point character appears in the result of these conversions
@@ -476,20 +476,36 @@ with the floating point presentation types listed below (except
``'n'`` and ``None``). When doing so, :func:`float` is used to convert the
integer to a floating point number before formatting.
-The available presentation types for floating point and decimal values are:
+The available presentation types for :class:`float` and
+:class:`~decimal.Decimal` values are:
+---------+----------------------------------------------------------+
| Type | Meaning |
+=========+==========================================================+
- | ``'e'`` | Exponent notation. Prints the number in scientific |
- | | notation using the letter 'e' to indicate the exponent. |
- | | The default precision is ``6``. |
+ | ``'e'`` | Scientific notation. For a given precision ``p``, |
+ | | formats the number in scientific notation with the |
+ | | letter 'e' separating the coefficient from the exponent. |
+ | | The coefficient has one digit before and ``p`` digits |
+ | | after the decimal point, for a total of ``p + 1`` |
+ | | significant digits. With no precision given, uses a |
+ | | precision of ``6`` digits after the decimal point for |
+ | | :class:`float`, and shows all coefficient digits |
+ | | for :class:`~decimal.Decimal`. If no digits follow the |
+ | | decimal point, the decimal point is also removed unless |
+ | | the ``#`` option is used. |
+---------+----------------------------------------------------------+
- | ``'E'`` | Exponent notation. Same as ``'e'`` except it uses an |
- | | upper case 'E' as the separator character. |
+ | ``'E'`` | Scientific notation. Same as ``'e'`` except it uses |
+ | | an upper case 'E' as the separator character. |
+---------+----------------------------------------------------------+
- | ``'f'`` | Fixed-point notation. Displays the number as a |
- | | fixed-point number. The default precision is ``6``. |
+ | ``'f'`` | Fixed-point notation. For a given precision ``p``, |
+ | | formats the number as a decimal number with exactly |
+ | | ``p`` digits following the decimal point. With no |
+ | | precision given, uses a precision of ``6`` digits after |
+ | | the decimal point for :class:`float`, and uses a |
+ | | precision large enough to show all coefficient digits |
+ | | for :class:`~decimal.Decimal`. If no digits follow the |
+ | | decimal point, the decimal point is also removed unless |
+ | | the ``#`` option is used. |
+---------+----------------------------------------------------------+
| ``'F'`` | Fixed-point notation. Same as ``'f'``, but converts |
| | ``nan`` to ``NAN`` and ``inf`` to ``INF``. |
@@ -498,6 +514,8 @@ The available presentation types for floating point and decimal values are:
| | this rounds the number to ``p`` significant digits and |
| | then formats the result in either fixed-point format |
| | or in scientific notation, depending on its magnitude. |
+ | | A precision of ``0`` is treated as equivalent to a |
+ | | precision of ``1``. |
| | |
| | The precise rules are as follows: suppose that the |
| | result formatted with presentation type ``'e'`` and |
@@ -512,13 +530,19 @@ The available presentation types for floating point and decimal values are:
| | removed if there are no remaining digits following it, |
| | unless the ``'#'`` option is used. |
| | |
+ | | With no precision given, uses a precision of ``6`` |
+ | | significant digits for :class:`float`. For |
+ | | :class:`~decimal.Decimal`, the coefficient of the result |
+ | | is formed from the coefficient digits of the value; |
+ | | scientific notation is used for values smaller than |
+ | | ``1e-6`` in absolute value and values where the place |
+ | | value of the least significant digit is larger than 1, |
+ | | and fixed-point notation is used otherwise. |
+ | | |
| | Positive and negative infinity, positive and negative |
| | zero, and nans, are formatted as ``inf``, ``-inf``, |
| | ``0``, ``-0`` and ``nan`` respectively, regardless of |
| | the precision. |
- | | |
- | | A precision of ``0`` is treated as equivalent to a |
- | | precision of ``1``. The default precision is ``6``. |
+---------+----------------------------------------------------------+
| ``'G'`` | General format. Same as ``'g'`` except switches to |
| | ``'E'`` if the number gets too large. The |
@@ -531,12 +555,18 @@ The available presentation types for floating point and decimal values are:
| ``'%'`` | Percentage. Multiplies the number by 100 and displays |
| | in fixed (``'f'``) format, followed by a percent sign. |
+---------+----------------------------------------------------------+
- | None | Similar to ``'g'``, except that fixed-point notation, |
- | | when used, has at least one digit past the decimal point.|
- | | The default precision is as high as needed to represent |
- | | the particular value. The overall effect is to match the |
- | | output of :func:`str` as altered by the other format |
- | | modifiers. |
+ | None | For :class:`float` this is the same as ``'g'``, except |
+ | | that when fixed-point notation is used to format the |
+ | | result, it always includes at least one digit past the |
+ | | decimal point. The precision used is as large as needed |
+ | | to represent the given value faithfully. |
+ | | |
+ | | For :class:`~decimal.Decimal`, this is the same as |
+ | | either ``'g'`` or ``'G'`` depending on the value of |
+ | | ``context.capitals`` for the current decimal context. |
+ | | |
+ | | The overall effect is to match the output of :func:`str` |
+ | | as altered by the other format modifiers. |
+---------+----------------------------------------------------------+
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index 85d0f46624..07b8ad7765 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -339,7 +339,7 @@ functions.
stderr=None, preexec_fn=None, close_fds=True, shell=False, \
cwd=None, env=None, universal_newlines=None, \
startupinfo=None, creationflags=0, restore_signals=True, \
- start_new_session=False, pass_fds=(), \*, group=None, \
+ start_new_session=False, pass_fds=(), *, group=None, \
extra_groups=None, user=None, umask=-1, \
encoding=None, errors=None, text=None, pipesize=-1)
@@ -718,11 +718,8 @@ If the shell is invoked explicitly, via ``shell=True``, it is the application's
responsibility to ensure that all whitespace and metacharacters are
quoted appropriately to avoid
`shell injection <https://en.wikipedia.org/wiki/Shell_injection#Shell_injection>`_
-vulnerabilities.
-
-When using ``shell=True``, the :func:`shlex.quote` function can be
-used to properly escape whitespace and shell metacharacters in strings
-that are going to be used to construct shell commands.
+vulnerabilities. On :ref:`some platforms <shlex-quote-warning>`, it is possible
+to use :func:`shlex.quote` for this escaping.
Popen Objects
@@ -1190,8 +1187,9 @@ calls these functions.
The arguments shown above are merely some common ones.
The full function signature is largely the same as that of :func:`run` -
most arguments are passed directly through to that interface.
- However, explicitly passing ``input=None`` to inherit the parent's
- standard input file handle is not supported.
+ One API deviation from :func:`run` behavior exists: passing ``input=None``
+ will behave the same as ``input=b''`` (or ``input=''``, depending on other
+ arguments) rather than using the parent's standard input file handle.
By default, this function will return the data as encoded bytes. The actual
encoding of the output data may depend on the command being invoked, so the
@@ -1284,7 +1282,7 @@ be used directly:
becomes::
- output=check_output("dmesg | grep hda", shell=True)
+ output = check_output("dmesg | grep hda", shell=True)
Replacing :func:`os.system`
diff --git a/Doc/library/symtable.rst b/Doc/library/symtable.rst
index c9521d649b..40c1795b08 100644
--- a/Doc/library/symtable.rst
+++ b/Doc/library/symtable.rst
@@ -156,7 +156,7 @@ Examining Symbol Tables
Return ``True`` if the symbol is local to its block.
- .. method:: is_annotated()
+ .. method:: is_annotated()
Return ``True`` if the symbol is annotated.
diff --git a/Doc/library/sysconfig.rst b/Doc/library/sysconfig.rst
index 78a1dfce9a..c9306e9bf9 100644
--- a/Doc/library/sysconfig.rst
+++ b/Doc/library/sysconfig.rst
@@ -32,7 +32,7 @@ can be accessed using :func:`get_config_vars` or :func:`get_config_var`.
Notice that on Windows, it's a much smaller set.
-.. function:: get_config_vars(\*args)
+.. function:: get_config_vars(*args)
With no arguments, return a dictionary of all configuration variables
relevant for the current platform.
diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst
index 7a114fdf5d..13088a10d7 100644
--- a/Doc/library/tarfile.rst
+++ b/Doc/library/tarfile.rst
@@ -37,7 +37,7 @@ Some facts and figures:
Added support for :mod:`lzma` compression.
-.. function:: open(name=None, mode='r', fileobj=None, bufsize=10240, \*\*kwargs)
+.. function:: open(name=None, mode='r', fileobj=None, bufsize=10240, **kwargs)
Return a :class:`TarFile` object for the pathname *name*. For detailed
information on :class:`TarFile` objects and the keyword arguments that are
diff --git a/Doc/library/test.rst b/Doc/library/test.rst
index ce6b868458..e4f779bd83 100644
--- a/Doc/library/test.rst
+++ b/Doc/library/test.rst
@@ -453,7 +453,7 @@ The :mod:`test.support` module defines the following functions:
Define match test with regular expression *patterns*.
-.. function:: run_unittest(\*classes)
+.. function:: run_unittest(*classes)
Execute :class:`unittest.TestCase` subclasses passed to the function. The
function scans the classes for methods starting with the prefix ``test_``
@@ -1599,7 +1599,7 @@ The :mod:`test.support.warnings_helper` module provides support for warnings tes
.. versionadded:: 3.8
-.. function:: check_warnings(\*filters, quiet=True)
+.. function:: check_warnings(*filters, quiet=True)
A convenience wrapper for :func:`warnings.catch_warnings()` that makes it
easier to test that a warning was correctly raised. It is approximately
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index 7eb12fe116..690735469d 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -71,6 +71,13 @@ This module defines the following functions:
.. versionadded:: 3.8
+.. data:: __excepthook__
+
+ Holds the original value of :func:`threading.excepthook`. It is saved so that the
+ original value can be restored in case they happen to get replaced with
+ broken or alternative objects.
+
+ .. versionadded:: 3.10
.. function:: get_ident()
@@ -121,6 +128,17 @@ This module defines the following functions:
:meth:`~Thread.run` method is called.
+.. function:: gettrace()
+
+ .. index::
+ single: trace function
+ single: debugger
+
+ Get the trace function as set by :func:`settrace`.
+
+ .. versionadded:: 3.10
+
+
.. function:: setprofile(func)
.. index:: single: profile function
@@ -130,6 +148,15 @@ This module defines the following functions:
:meth:`~Thread.run` method is called.
+.. function:: getprofile()
+
+ .. index:: single: profile function
+
+ Get the profiler function as set by :func:`setprofile`.
+
+ .. versionadded:: 3.10
+
+
.. function:: stack_size([size])
Return the thread stack size used when creating new threads. The optional
diff --git a/Doc/library/time.rst b/Doc/library/time.rst
index cff6320b52..143f84b565 100644
--- a/Doc/library/time.rst
+++ b/Doc/library/time.rst
@@ -166,6 +166,9 @@ Functions
Return the time of the specified clock *clk_id*. Refer to
:ref:`time-clock-id-constants` for a list of accepted values for *clk_id*.
+ Use :func:`clock_gettime_ns` to avoid the precision loss caused by the
+ :class:`float` type.
+
.. availability:: Unix.
.. versionadded:: 3.3
@@ -185,6 +188,9 @@ Functions
Set the time of the specified clock *clk_id*. Currently,
:data:`CLOCK_REALTIME` is the only accepted value for *clk_id*.
+ Use :func:`clock_settime_ns` to avoid the precision loss caused by the
+ :class:`float` type.
+
.. availability:: Unix.
.. versionadded:: 3.3
@@ -273,10 +279,17 @@ Functions
The reference point of the returned value is undefined, so that only the
difference between the results of consecutive calls is valid.
+ Use :func:`monotonic_ns` to avoid the precision loss caused by the
+ :class:`float` type.
+
.. versionadded:: 3.3
+
.. versionchanged:: 3.5
The function is now always available and always system-wide.
+ .. versionchanged:: 3.10
+ On macOS, the function is now system-wide.
+
.. function:: monotonic_ns() -> int
@@ -295,8 +308,14 @@ Functions
point of the returned value is undefined, so that only the difference between
the results of consecutive calls is valid.
+ Use :func:`perf_counter_ns` to avoid the precision loss caused by the
+ :class:`float` type.
+
.. versionadded:: 3.3
+ .. versionchanged:: 3.10
+ On Windows, the function is now system-wide.
+
.. function:: perf_counter_ns() -> int
Similar to :func:`perf_counter`, but return time as nanoseconds.
@@ -317,6 +336,9 @@ Functions
returned value is undefined, so that only the difference between the results
of consecutive calls is valid.
+ Use :func:`process_time_ns` to avoid the precision loss caused by the
+ :class:`float` type.
+
.. versionadded:: 3.3
.. function:: process_time_ns() -> int
@@ -581,6 +603,17 @@ Functions
:class:`struct_time` object is returned, from which the components
of the calendar date may be accessed as attributes.
+ Use :func:`time_ns` to avoid the precision loss caused by the :class:`float`
+ type.
+
+
+.. function:: time_ns() -> int
+
+ Similar to :func:`~time.time` but returns time as an integer number of nanoseconds
+ since the epoch_.
+
+ .. versionadded:: 3.7
+
.. function:: thread_time() -> float
@@ -595,6 +628,9 @@ Functions
returned value is undefined, so that only the difference between the results
of consecutive calls in the same thread is valid.
+ Use :func:`thread_time_ns` to avoid the precision loss caused by the
+ :class:`float` type.
+
.. availability:: Windows, Linux, Unix systems supporting
``CLOCK_THREAD_CPUTIME_ID``.
@@ -608,13 +644,6 @@ Functions
.. versionadded:: 3.7
-.. function:: time_ns() -> int
-
- Similar to :func:`~time.time` but returns time as an integer number of nanoseconds
- since the epoch_.
-
- .. versionadded:: 3.7
-
.. function:: tzset()
Reset the time conversion rules used by the library routines. The environment
diff --git a/Doc/library/tkinter.font.rst b/Doc/library/tkinter.font.rst
index b0f4505e9e..c7c2b7b566 100644
--- a/Doc/library/tkinter.font.rst
+++ b/Doc/library/tkinter.font.rst
@@ -91,6 +91,9 @@ The different font weights and slants are:
Return the names of defined fonts.
-.. function:: nametofont(name)
+.. function:: nametofont(name, root=None)
- Return a :class:`Font` representation of a tk named font. \ No newline at end of file
+ Return a :class:`Font` representation of a tk named font.
+
+ .. versionchanged:: 3.10
+ The *root* parameter was added.
diff --git a/Doc/library/trace.rst b/Doc/library/trace.rst
index c2732d900b..40cf198f12 100644
--- a/Doc/library/trace.rst
+++ b/Doc/library/trace.rst
@@ -153,47 +153,47 @@ Programmatic Interface
count information. *timing* enables a timestamp relative to when tracing was
started to be displayed.
- .. method:: run(cmd)
+ .. method:: run(cmd)
- Execute the command and gather statistics from the execution with
- the current tracing parameters. *cmd* must be a string or code object,
- suitable for passing into :func:`exec`.
+ Execute the command and gather statistics from the execution with
+ the current tracing parameters. *cmd* must be a string or code object,
+ suitable for passing into :func:`exec`.
- .. method:: runctx(cmd, globals=None, locals=None)
+ .. method:: runctx(cmd, globals=None, locals=None)
- Execute the command and gather statistics from the execution with the
- current tracing parameters, in the defined global and local
- environments. If not defined, *globals* and *locals* default to empty
- dictionaries.
+ Execute the command and gather statistics from the execution with the
+ current tracing parameters, in the defined global and local
+ environments. If not defined, *globals* and *locals* default to empty
+ dictionaries.
- .. method:: runfunc(func, /, *args, **kwds)
+ .. method:: runfunc(func, /, *args, **kwds)
- Call *func* with the given arguments under control of the :class:`Trace`
- object with the current tracing parameters.
+ Call *func* with the given arguments under control of the :class:`Trace`
+ object with the current tracing parameters.
- .. method:: results()
+ .. method:: results()
- Return a :class:`CoverageResults` object that contains the cumulative
- results of all previous calls to ``run``, ``runctx`` and ``runfunc``
- for the given :class:`Trace` instance. Does not reset the accumulated
- trace results.
+ Return a :class:`CoverageResults` object that contains the cumulative
+ results of all previous calls to ``run``, ``runctx`` and ``runfunc``
+ for the given :class:`Trace` instance. Does not reset the accumulated
+ trace results.
.. class:: CoverageResults
A container for coverage results, created by :meth:`Trace.results`. Should
not be created directly by the user.
- .. method:: update(other)
+ .. method:: update(other)
- Merge in data from another :class:`CoverageResults` object.
+ Merge in data from another :class:`CoverageResults` object.
- .. method:: write_results(show_missing=True, summary=False, coverdir=None)
+ .. method:: write_results(show_missing=True, summary=False, coverdir=None)
- Write coverage results. Set *show_missing* to show lines that had no
- hits. Set *summary* to include in the output the coverage summary per
- module. *coverdir* specifies the directory into which the coverage
- result files will be output. If ``None``, the results for each source
- file are placed in its directory.
+ Write coverage results. Set *show_missing* to show lines that had no
+ hits. Set *summary* to include in the output the coverage summary per
+ module. *coverdir* specifies the directory into which the coverage
+ result files will be output. If ``None``, the results for each source
+ file are placed in its directory.
A simple example demonstrating the use of the programmatic interface::
diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst
index 462a6a5566..c233f18d30 100644
--- a/Doc/library/traceback.rst
+++ b/Doc/library/traceback.rst
@@ -36,7 +36,8 @@ The module defines the following functions:
Added negative *limit* support.
-.. function:: print_exception(etype, value, tb, limit=None, file=None, chain=True)
+.. function:: print_exception(exc, /[, value, tb], limit=None, \
+ file=None, chain=True)
Print exception information and stack trace entries from traceback object
*tb* to *file*. This differs from :func:`print_tb` in the following
@@ -45,7 +46,7 @@ The module defines the following functions:
* if *tb* is not ``None``, it prints a header ``Traceback (most recent
call last):``
- * it prints the exception *etype* and *value* after the stack trace
+ * it prints the exception type and *value* after the stack trace
.. index:: single: ^ (caret); marker
@@ -53,6 +54,10 @@ The module defines the following functions:
format, it prints the line where the syntax error occurred with a caret
indicating the approximate position of the error.
+ Since Python 3.10, instead of passing *value* and *tb*, an exception object
+ can be passed as the first argument. If *value* and *tb* are provided, the
+ first argument is ignored in order to provide backwards compatibility.
+
The optional *limit* argument has the same meaning as for :func:`print_tb`.
If *chain* is true (the default), then chained exceptions (the
:attr:`__cause__` or :attr:`__context__` attributes of the exception) will be
@@ -62,6 +67,10 @@ The module defines the following functions:
.. versionchanged:: 3.5
The *etype* argument is ignored and inferred from the type of *value*.
+ .. versionchanged:: 3.10
+ The *etype* parameter has been renamed to *exc* and is now
+ positional-only.
+
.. function:: print_exc(limit=None, file=None, chain=True)
@@ -121,18 +130,26 @@ The module defines the following functions:
text line is not ``None``.
-.. function:: format_exception_only(etype, value)
+.. function:: format_exception_only(exc, /[, value])
+
+ Format the exception part of a traceback using an exception value such as
+ given by ``sys.last_value``. The return value is a list of strings, each
+ ending in a newline. Normally, the list contains a single string; however,
+ for :exc:`SyntaxError` exceptions, it contains several lines that (when
+ printed) display detailed information about where the syntax error occurred.
+ The message indicating which exception occurred is the always last string in
+ the list.
- Format the exception part of a traceback. The arguments are the exception
- type and value such as given by ``sys.last_type`` and ``sys.last_value``.
- The return value is a list of strings, each ending in a newline. Normally,
- the list contains a single string; however, for :exc:`SyntaxError`
- exceptions, it contains several lines that (when printed) display detailed
- information about where the syntax error occurred. The message indicating
- which exception occurred is the always last string in the list.
+ Since Python 3.10, instead of passing *value*, an exception object
+ can be passed as the first argument. If *value* is provided, the first
+ argument is ignored in order to provide backwards compatibility.
+ .. versionchanged:: 3.10
+ The *etype* parameter has been renamed to *exc* and is now
+ positional-only.
-.. function:: format_exception(etype, value, tb, limit=None, chain=True)
+
+.. function:: format_exception(exc, /[, value, tb], limit=None, chain=True)
Format a stack trace and the exception information. The arguments have the
same meaning as the corresponding arguments to :func:`print_exception`. The
@@ -143,6 +160,10 @@ The module defines the following functions:
.. versionchanged:: 3.5
The *etype* argument is ignored and inferred from the type of *value*.
+ .. versionchanged:: 3.10
+ This function's behavior and signature were modified to match
+ :func:`print_exception`.
+
.. function:: format_exc(limit=None, chain=True)
diff --git a/Doc/library/turtle.rst b/Doc/library/turtle.rst
index d3487537df..2084d75b3a 100644
--- a/Doc/library/turtle.rst
+++ b/Doc/library/turtle.rst
@@ -913,8 +913,8 @@ Color control
Set pencolor to the RGB color represented by *r*, *g*, and *b*. Each of
*r*, *g*, and *b* must be in the range 0..colormode.
- If turtleshape is a polygon, the outline of that polygon is drawn with the
- newly set pencolor.
+ If turtleshape is a polygon, the outline of that polygon is drawn with the
+ newly set pencolor.
.. doctest::
:skipif: _tkinter is None
@@ -962,8 +962,8 @@ Color control
Set fillcolor to the RGB color represented by *r*, *g*, and *b*. Each of
*r*, *g*, and *b* must be in the range 0..colormode.
- If turtleshape is a polygon, the interior of that polygon is drawn
- with the newly set fillcolor.
+ If turtleshape is a polygon, the interior of that polygon is drawn
+ with the newly set fillcolor.
.. doctest::
:skipif: _tkinter is None
@@ -1001,8 +1001,8 @@ Color control
Equivalent to ``pencolor(colorstring1)`` and ``fillcolor(colorstring2)``
and analogously if the other input format is used.
- If turtleshape is a polygon, outline and interior of that polygon is drawn
- with the newly set colors.
+ If turtleshape is a polygon, outline and interior of that polygon is drawn
+ with the newly set colors.
.. doctest::
:skipif: _tkinter is None
diff --git a/Doc/library/types.rst b/Doc/library/types.rst
index ad40a9fbf3..8e05f8408e 100644
--- a/Doc/library/types.rst
+++ b/Doc/library/types.rst
@@ -280,6 +280,10 @@ Standard names are defined for the following types:
.. versionadded:: 3.9
+ .. versionchanged:: 3.9.2
+ This type can now be subclassed.
+
+
.. data:: Union
The type of :ref:`union type expressions<types-union>`.
@@ -409,7 +413,9 @@ Additional Utility Classes and Functions
return "{}({})".format(type(self).__name__, ", ".join(items))
def __eq__(self, other):
- return self.__dict__ == other.__dict__
+ if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):
+ return self.__dict__ == other.__dict__
+ return NotImplemented
``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.
However, for a structured record type use :func:`~collections.namedtuple`
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index 9a993c0732..b07bb8943d 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -641,7 +641,7 @@ These can be used as types in annotations using ``[]``, each having a unique syn
:ref:`type variables <generics>`, and unions of any of these types.
For example::
- def new_non_team_user(user_class: Type[Union[BaseUser, ProUser]]): ...
+ def new_non_team_user(user_class: Type[Union[BasicUser, ProUser]]): ...
``Type[Any]`` is equivalent to ``Type`` which in turn is equivalent
to ``type``, which is the root of Python's metaclass hierarchy.
@@ -674,6 +674,12 @@ These can be used as types in annotations using ``[]``, each having a unique syn
.. versionadded:: 3.8
+ .. versionchanged:: 3.9.1
+ ``Literal`` now de-duplicates parameters. Equality comparison of
+ ``Literal`` objects are no longer order dependent. ``Literal`` objects
+ will now raise a :exc:`TypeError` exception during equality comparisons
+ if one of their parameters are not :term:`immutable`.
+
.. data:: ClassVar
Special type construct to mark class variables.
@@ -1706,6 +1712,9 @@ Introspection helpers
For a typing object of the form ``X[Y, Z, ...]`` these functions return
``X`` and ``(Y, Z, ...)``. If ``X`` is a generic alias for a builtin or
:mod:`collections` class, it gets normalized to the original class.
+ If ``X`` is a :class:`Union` or :class:`Literal` contained in another
+ generic type, the order of ``(Y, Z, ...)`` may be different from the order
+ of the original arguments ``[Y, Z, ...]`` due to type caching.
For unsupported objects return ``None`` and ``()`` correspondingly.
Examples::
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index c5360f91f5..f795a2e8c1 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -262,9 +262,10 @@ the *new_callable* argument to :func:`patch`.
this is a new Mock (created on first access). See the
:attr:`return_value` attribute.
- * *unsafe*: By default if any attribute starts with *assert* or
- *assret* will raise an :exc:`AttributeError`. Passing ``unsafe=True``
- will allow access to these attributes.
+ * *unsafe*: By default, accessing any attribute with name starting with
+ *assert*, *assret*, *asert*, *aseert* or *assrt* will raise an
+ :exc:`AttributeError`. Passing ``unsafe=True`` will allow access to
+ these attributes.
.. versionadded:: 3.5
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index 51e10119d3..0a0993518e 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -897,8 +897,7 @@ Test cases
.. method:: assertIs(first, second, msg=None)
assertIsNot(first, second, msg=None)
- Test that *first* and *second* evaluate (or don't evaluate) to the
- same object.
+ Test that *first* and *second* are (or are not) the same object.
.. versionadded:: 3.1
diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst
index b37f230feb..b4435a62ad 100644
--- a/Doc/library/urllib.request.rst
+++ b/Doc/library/urllib.request.rst
@@ -109,6 +109,11 @@ The :mod:`urllib.request` module defines the following functions:
.. versionchanged:: 3.4.3
*context* was added.
+ .. versionchanged:: 3.10
+ HTTPS connection now send an ALPN extension with protocol indicator
+ ``http/1.1`` when no *context* is given. Custom *context* should set
+ ALPN protocols with :meth:`~ssl.SSLContext.set_alpn_protocol`.
+
.. deprecated:: 3.6
*cafile*, *capath* and *cadefault* are deprecated in favor of *context*.
diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst
index a481a3509d..9c1743cad2 100644
--- a/Doc/library/warnings.rst
+++ b/Doc/library/warnings.rst
@@ -491,7 +491,7 @@ Available Functions
Available Context Managers
--------------------------
-.. class:: catch_warnings(\*, record=False, module=None)
+.. class:: catch_warnings(*, record=False, module=None)
A context manager that copies and, upon exit, restores the warnings filter
and the :func:`showwarning` function.
diff --git a/Doc/library/winreg.rst b/Doc/library/winreg.rst
index dccb7db27e..487856a3ac 100644
--- a/Doc/library/winreg.rst
+++ b/Doc/library/winreg.rst
@@ -791,7 +791,7 @@ integer handle, and also disconnect the Windows handle from the handle object.
.. method:: PyHKEY.__enter__()
- PyHKEY.__exit__(\*exc_info)
+ PyHKEY.__exit__(*exc_info)
The HKEY object implements :meth:`~object.__enter__` and
:meth:`~object.__exit__` and thus supports the context protocol for the
diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst
index 2c78cd9392..e1cc967942 100644
--- a/Doc/library/xml.dom.minidom.rst
+++ b/Doc/library/xml.dom.minidom.rst
@@ -132,7 +132,7 @@ module documentation. This section lists the differences between the API and
... # Work with dom.
-.. method:: Node.writexml(writer, indent="", addindent="", newl="",
+.. method:: Node.writexml(writer, indent="", addindent="", newl="", \
encoding=None, standalone=None)
Write XML to the writer object. The writer receives texts but not bytes as input,
@@ -174,7 +174,7 @@ module documentation. This section lists the differences between the API and
The :meth:`toxml` method now preserves the attribute order specified
by the user.
-.. method:: Node.toprettyxml(indent="\\t", newl="\\n", encoding=None,
+.. method:: Node.toprettyxml(indent="\t", newl="\n", encoding=None, \
standalone=None)
Return a pretty-printed version of the document. *indent* specifies the
diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst
index f4bccf6609..87f4ee347d 100644
--- a/Doc/library/xml.etree.elementtree.rst
+++ b/Doc/library/xml.etree.elementtree.rst
@@ -455,6 +455,12 @@ Supported XPath syntax
| | has the given value. The value cannot contain |
| | quotes. |
+-----------------------+------------------------------------------------------+
+| ``[@attrib!='value']``| Selects all elements for which the given attribute |
+| | does not have the given value. The value cannot |
+| | contain quotes. |
+| | |
+| | .. versionadded:: 3.10 |
++-----------------------+------------------------------------------------------+
| ``[tag]`` | Selects all elements that have a child named |
| | ``tag``. Only immediate children are supported. |
+-----------------------+------------------------------------------------------+
@@ -463,10 +469,22 @@ Supported XPath syntax
| | |
| | .. versionadded:: 3.7 |
+-----------------------+------------------------------------------------------+
+| ``[.!='text']`` | Selects all elements whose complete text content, |
+| | including descendants, does not equal the given |
+| | ``text``. |
+| | |
+| | .. versionadded:: 3.10 |
++-----------------------+------------------------------------------------------+
| ``[tag='text']`` | Selects all elements that have a child named |
| | ``tag`` whose complete text content, including |
| | descendants, equals the given ``text``. |
+-----------------------+------------------------------------------------------+
+| ``[tag!='text']`` | Selects all elements that have a child named |
+| | ``tag`` whose complete text content, including |
+| | descendants, does not equal the given ``text``. |
+| | |
+| | .. versionadded:: 3.10 |
++-----------------------+------------------------------------------------------+
| ``[position]`` | Selects all elements that are located at the given |
| | position. The position can be either an integer |
| | (1 is the first position), the expression ``last()`` |
diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst
index 7126d8bd70..3db55e646c 100644
--- a/Doc/library/zipfile.rst
+++ b/Doc/library/zipfile.rst
@@ -483,7 +483,7 @@ Path Objects
Path objects expose the following features of :mod:`pathlib.Path`
objects:
-Path objects are traversable using the ``/`` operator.
+Path objects are traversable using the ``/`` operator or ``joinpath``.
.. attribute:: Path.name
@@ -532,6 +532,19 @@ Path objects are traversable using the ``/`` operator.
Read the current file as bytes.
+.. method:: Path.joinpath(*other)
+
+ Return a new Path object with each of the *other* arguments
+ joined. The following are equivalent::
+
+ >>> Path(...).joinpath('child').joinpath('grandchild')
+ >>> Path(...).joinpath('child', 'grandchild')
+ >>> Path(...) / 'child' / 'grandchild'
+
+ .. versionchanged:: 3.10
+ Prior to 3.10, ``joinpath`` was undocumented and accepted
+ exactly one parameter.
+
.. _pyzipfile-objects:
diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst
index 8ac3fb16bd..62e1e47e98 100644
--- a/Doc/library/zipimport.rst
+++ b/Doc/library/zipimport.rst
@@ -44,8 +44,9 @@ doesn't contain :file:`.pyc` files, importing may be rather slow.
follows the specification in :pep:`273`, but uses an implementation written by Just
van Rossum that uses the import hooks described in :pep:`302`.
- :pep:`302` - New Import Hooks
- The PEP to add the import hooks that help this module work.
+ :mod:`importlib` - The implementation of the import machinery
+ Package providing the relevant protocols for all importers to
+ implement.
This module defines an exception:
@@ -73,7 +74,31 @@ zipimporter Objects
:exc:`ZipImportError` is raised if *archivepath* doesn't point to a valid ZIP
archive.
- .. method:: find_module(fullname[, path])
+ .. method:: create_module(spec)
+
+ Implementation of :meth:`importlib.abc.Loader.create_module` that returns
+ :const:`None` to explicitly request the default semantics.
+
+ .. versionadded:: 3.10
+
+
+ .. method:: exec_module(module)
+
+ Implementation of :meth:`importlib.abc.Loader.exec_module`.
+
+ .. versionadded:: 3.10
+
+
+ .. method:: find_loader(fullname, path=None)
+
+ An implementation of :meth:`importlib.abc.PathEntryFinder.find_loader`.
+
+ .. deprecated:: 3.10
+
+ Use :meth:`find_spec` instead.
+
+
+ .. method:: find_module(fullname, path=None)
Search for a module specified by *fullname*. *fullname* must be the fully
qualified (dotted) module name. It returns the zipimporter instance itself
@@ -81,11 +106,22 @@ zipimporter Objects
*path* argument is ignored---it's there for compatibility with the
importer protocol.
+ .. deprecated:: 3.10
+
+ Use :meth:`find_spec` instead.
+
+
+ .. method:: find_spec(fullname, target=None)
+
+ An implementation of :meth:`importlib.abc.PathEntryFinder.find_spec`.
+
+ .. versionadded:: 3.10
+
.. method:: get_code(fullname)
Return the code object for the specified module. Raise
- :exc:`ZipImportError` if the module couldn't be found.
+ :exc:`ZipImportError` if the module couldn't be imported.
.. method:: get_data(pathname)
@@ -101,7 +137,7 @@ zipimporter Objects
Return the value ``__file__`` would be set to if the specified module
was imported. Raise :exc:`ZipImportError` if the module couldn't be
- found.
+ imported.
.. versionadded:: 3.1
@@ -123,9 +159,12 @@ zipimporter Objects
.. method:: load_module(fullname)
Load the module specified by *fullname*. *fullname* must be the fully
- qualified (dotted) module name. It returns the imported module, or raises
- :exc:`ZipImportError` if it wasn't found.
+ qualified (dotted) module name. Returns the imported module on success,
+ raises :exc:`ZipImportError` on failure.
+
+ .. deprecated:: 3.10
+ Use :meth:`exec_module` instead.
.. attribute:: archive
diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
index 62986cb151..5bba3eea6f 100644
--- a/Doc/reference/compound_stmts.rst
+++ b/Doc/reference/compound_stmts.rst
@@ -254,7 +254,8 @@ present, must be last; it matches any exception. For an except clause with an
expression, that expression is evaluated, and the clause matches the exception
if the resulting object is "compatible" with the exception. An object is
compatible with an exception if it is the class or a base class of the exception
-object or a tuple containing an item compatible with the exception.
+object, or a tuple containing an item that is the class or a base class of
+the exception object.
If no except clause matches the exception, the search for an exception handler
continues in the surrounding code and on the invocation stack. [#]_
@@ -301,9 +302,27 @@ Before an except clause's suite is executed, details about the exception are
stored in the :mod:`sys` module and can be accessed via :func:`sys.exc_info`.
:func:`sys.exc_info` returns a 3-tuple consisting of the exception class, the
exception instance and a traceback object (see section :ref:`types`) identifying
-the point in the program where the exception occurred. :func:`sys.exc_info`
-values are restored to their previous values (before the call) when returning
-from a function that handled an exception.
+the point in the program where the exception occurred. The details about the
+exception accessed via :func:`sys.exc_info` are restored to their previous values
+when leaving an exception handler::
+
+ >>> print(sys.exc_info())
+ (None, None, None)
+ >>> try:
+ ... raise TypeError
+ ... except:
+ ... print(sys.exc_info())
+ ... try:
+ ... raise ValueError
+ ... except:
+ ... print(sys.exc_info())
+ ... print(sys.exc_info())
+ ...
+ (<class 'TypeError'>, TypeError(), <traceback object at 0x10efad080>)
+ (<class 'ValueError'>, ValueError(), <traceback object at 0x10efad040>)
+ (<class 'TypeError'>, TypeError(), <traceback object at 0x10efad080>)
+ >>> print(sys.exc_info())
+ (None, None, None)
.. index::
keyword: else
@@ -796,12 +815,12 @@ The :keyword:`!async for` statement
.. productionlist:: python-grammar
async_for_stmt: "async" `for_stmt`
-An :term:`asynchronous iterable` is able to call asynchronous code in its
-*iter* implementation, and :term:`asynchronous iterator` can call asynchronous
-code in its *next* method.
+An :term:`asynchronous iterable` provides an ``__aiter__`` method that directly
+returns an :term:`asynchronous iterator`, which can call asynchronous code in
+its ``__anext__`` method.
The ``async for`` statement allows convenient iteration over asynchronous
-iterators.
+iterables.
The following code::
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index c882301ad3..62f8529536 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -217,7 +217,6 @@ Ellipsis
There are two types of integers:
Integers (:class:`int`)
-
These represent numbers in an unlimited range, subject to available (virtual)
memory only. For the purpose of shift and mask operations, a binary
representation is assumed, and negative numbers are represented in a variant of
diff --git a/Doc/reference/grammar.rst b/Doc/reference/grammar.rst
index acf83765b5..59b4500583 100644
--- a/Doc/reference/grammar.rst
+++ b/Doc/reference/grammar.rst
@@ -13,7 +13,8 @@ In particular, ``&`` followed by a symbol, token or parenthesized
group indicates a positive lookahead (i.e., is required to match but
not consumed), while ``!`` indicates a negative lookahead (i.e., is
required _not_ to match). We use the ``|`` separator to mean PEG's
-"ordered choice" (written as ``/`` in traditional PEG grammars).
+"ordered choice" (written as ``/`` in traditional PEG grammars). See
+:pep:`617` for more details on the grammar's syntax.
.. literalinclude:: ../../Grammar/python.gram
:language: peg
diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst
index f8ab2e918c..2c6c901402 100644
--- a/Doc/reference/simple_stmts.rst
+++ b/Doc/reference/simple_stmts.rst
@@ -950,7 +950,7 @@ Names listed in a :keyword:`global` statement must not be used in the same code
block textually preceding that :keyword:`!global` statement.
Names listed in a :keyword:`global` statement must not be defined as formal
-parameters or in a :keyword:`for` loop control target, :keyword:`class`
+parameters, or as targets in :keyword:`with` statements or :keyword:`except` clauses, or in a :keyword:`for` target list, :keyword:`class`
definition, function definition, :keyword:`import` statement, or variable
annotation.
diff --git a/Doc/tools/extensions/c_annotations.py b/Doc/tools/extensions/c_annotations.py
index fa8244a8fd..76c9d920cb 100644
--- a/Doc/tools/extensions/c_annotations.py
+++ b/Doc/tools/extensions/c_annotations.py
@@ -79,9 +79,9 @@ class Annotations(dict):
classes=['stableabi']))
if par['objtype'] != 'function':
continue
- if not par[0].has_key('names') or not par[0]['names']:
+ if not par[0].has_key('ids') or not par[0]['ids']:
continue
- name = par[0]['names'][0]
+ name = par[0]['ids'][0]
if name.startswith("c."):
name = name[2:]
entry = self.get(name)
diff --git a/Doc/tools/extensions/glossary_search.py b/Doc/tools/extensions/glossary_search.py
new file mode 100644
index 0000000000..34d227d670
--- /dev/null
+++ b/Doc/tools/extensions/glossary_search.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+"""
+ glossary_search.py
+ ~~~~~~~~~~~~~~~~
+
+ Feature search results for glossary items prominently.
+
+ :license: Python license.
+"""
+from os import path
+from sphinx.addnodes import glossary
+from sphinx.util import logging
+from docutils.nodes import definition_list_item
+import json
+
+
+logger = logging.getLogger(__name__)
+
+
+def process_glossary_nodes(app, doctree, fromdocname):
+ if app.builder.format != 'html':
+ return
+
+ terms = {}
+
+ for node in doctree.traverse(glossary):
+ for glossary_item in node.traverse(definition_list_item):
+ term = glossary_item[0].astext().lower()
+ definition = glossary_item[1]
+
+ rendered = app.builder.render_partial(definition)
+ terms[term] = {
+ 'title': glossary_item[0].astext(),
+ 'body': rendered['html_body']
+ }
+
+ if hasattr(app.env, 'glossary_terms'):
+ app.env.glossary_terms.update(terms)
+ else:
+ app.env.glossary_terms = terms
+
+def on_build_finish(app, exc):
+ if not hasattr(app.env, 'glossary_terms'):
+ return
+ if not app.env.glossary_terms:
+ return
+
+ logger.info('Writing glossary.json', color='green')
+ with open(path.join(app.outdir, '_static', 'glossary.json'), 'w') as f:
+ json.dump(app.env.glossary_terms, f)
+
+
+def setup(app):
+ app.connect('doctree-resolved', process_glossary_nodes)
+ app.connect('build-finished', on_build_finish)
+
+ return {'version': '0.1', 'parallel_read_safe': True}
diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py
index 80fbd96d56..28994399e2 100644
--- a/Doc/tools/extensions/pyspecific.py
+++ b/Doc/tools/extensions/pyspecific.py
@@ -394,7 +394,12 @@ class DeprecatedRemoved(Directive):
translatable=False)
node.append(para)
env = self.state.document.settings.env
- env.get_domain('changeset').note_changeset(node)
+ # deprecated pre-Sphinx-2 method
+ if hasattr(env, 'note_versionchange'):
+ env.note_versionchange('deprecated', version[0], node, self.lineno)
+ # new method
+ else:
+ env.get_domain('changeset').note_changeset(node)
return [node] + messages
diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py
index a3024d6734..cbcb8eb801 100755
--- a/Doc/tools/rstlint.py
+++ b/Doc/tools/rstlint.py
@@ -13,6 +13,7 @@ import os
import re
import sys
import getopt
+from string import ascii_letters
from os.path import join, splitext, abspath, exists
from collections import defaultdict
@@ -128,6 +129,81 @@ def check_leaked_markup(fn, lines):
yield lno+1, 'possibly leaked markup: %r' % line
+def hide_literal_blocks(lines):
+ """Tool to remove literal blocks from given lines.
+
+ It yields empty lines in place of blocks, so line numbers are
+ still meaningful.
+ """
+ in_block = False
+ for line in lines:
+ if line.endswith("::\n"):
+ in_block = True
+ elif in_block:
+ if line == "\n" or line.startswith(" "):
+ line = "\n"
+ else:
+ in_block = False
+ yield line
+
+
+def type_of_explicit_markup(line):
+ if re.match(fr'\.\. {all_directives}::', line):
+ return 'directive'
+ if re.match(r'\.\. \[[0-9]+\] ', line):
+ return 'footnote'
+ if re.match(r'\.\. \[[^\]]+\] ', line):
+ return 'citation'
+ if re.match(r'\.\. _.*[^_]: ', line):
+ return 'target'
+ if re.match(r'\.\. \|[^\|]*\| ', line):
+ return 'substitution_definition'
+ return 'comment'
+
+
+def hide_comments(lines):
+ """Tool to remove comments from given lines.
+
+ It yields empty lines in place of comments, so line numbers are
+ still meaningfull.
+ """
+ in_multiline_comment = False
+ for line in lines:
+ if line == "..\n":
+ in_multiline_comment = True
+ elif in_multiline_comment:
+ if line == "\n" or line.startswith(" "):
+ line = "\n"
+ else:
+ in_multiline_comment = False
+ if line.startswith(".. ") and type_of_explicit_markup(line) == 'comment':
+ line = "\n"
+ yield line
+
+
+
+@checker(".rst", severity=2)
+def check_missing_surrogate_space_on_plural(fn, lines):
+ r"""Check for missing 'backslash-space' between a code sample a letter.
+
+ Good: ``Point``\ s
+ Bad: ``Point``s
+ """
+ in_code_sample = False
+ check_next_one = False
+ for lno, line in enumerate(hide_comments(hide_literal_blocks(lines))):
+ tokens = line.split("``")
+ for token_no, token in enumerate(tokens):
+ if check_next_one:
+ if token[0] in ascii_letters:
+ yield lno + 1, f"Missing backslash-space between code sample and {token!r}."
+ check_next_one = False
+ if token_no == len(tokens) - 1:
+ continue
+ if in_code_sample:
+ check_next_one = True
+ in_code_sample = not in_code_sample
+
def main(argv):
usage = '''\
Usage: %s [-v] [-f] [-s sev] [-i path]* [path]
diff --git a/Doc/tools/static/switchers.js b/Doc/tools/static/switchers.js
deleted file mode 100644
index 1a1c7d0fa5..0000000000
--- a/Doc/tools/static/switchers.js
+++ /dev/null
@@ -1,156 +0,0 @@
-(function() {
- 'use strict';
-
- // Parses versions in URL segments like:
- // "3", "dev", "release/2.7" or "3.6rc2"
- var version_regexs = [
- '(?:\\d)',
- '(?:\\d\\.\\d[\\w\\d\\.]*)',
- '(?:dev)',
- '(?:release/\\d.\\d[\\x\\d\\.]*)'];
-
- var all_versions = {
- '3.10': 'dev (3.10)',
- '3.9': 'pre (3.9)',
- '3.8': '3.8',
- '3.7': '3.7',
- '3.6': '3.6',
- '2.7': '2.7',
- };
-
- var all_languages = {
- 'en': 'English',
- 'fr': 'French',
- 'ja': 'Japanese',
- 'ko': 'Korean',
- 'pt-br': 'Brazilian Portuguese',
- 'zh-cn': 'Simplified Chinese',
- };
-
- function build_version_select(current_version, current_release) {
- var buf = ['<select>'];
-
- $.each(all_versions, function(version, title) {
- buf.push('<option value="' + version + '"');
- if (version == current_version)
- buf.push(' selected="selected">' + current_release + '</option>');
- else
- buf.push('>' + title + '</option>');
- });
-
- buf.push('</select>');
- return buf.join('');
- }
-
- function build_language_select(current_language) {
- var buf = ['<select>'];
-
- $.each(all_languages, function(language, title) {
- if (language == current_language)
- buf.push('<option value="' + language + '" selected="selected">' +
- all_languages[current_language] + '</option>');
- else
- buf.push('<option value="' + language + '">' + title + '</option>');
- });
- if (!(current_language in all_languages)) {
- // In case we're browsing a language that is not yet in all_languages.
- buf.push('<option value="' + current_language + '" selected="selected">' +
- current_language + '</option>');
- all_languages[current_language] = current_language;
- }
- buf.push('</select>');
- return buf.join('');
- }
-
- function navigate_to_first_existing(urls) {
- // Navigate to the first existing URL in urls.
- var url = urls.shift();
- if (urls.length == 0) {
- window.location.href = url;
- return;
- }
- $.ajax({
- url: url,
- success: function() {
- window.location.href = url;
- },
- error: function() {
- navigate_to_first_existing(urls);
- }
- });
- }
-
- function on_version_switch() {
- var selected_version = $(this).children('option:selected').attr('value') + '/';
- var url = window.location.href;
- var current_language = language_segment_from_url(url);
- var current_version = version_segment_in_url(url);
- var new_url = url.replace('.org/' + current_language + current_version,
- '.org/' + current_language + selected_version);
- if (new_url != url) {
- navigate_to_first_existing([
- new_url,
- url.replace('.org/' + current_language + current_version,
- '.org/' + selected_version),
- 'https://docs.python.org/' + current_language + selected_version,
- 'https://docs.python.org/' + selected_version,
- 'https://docs.python.org/'
- ]);
- }
- }
-
- function on_language_switch() {
- var selected_language = $(this).children('option:selected').attr('value') + '/';
- var url = window.location.href;
- var current_language = language_segment_from_url(url);
- var current_version = version_segment_in_url(url);
- if (selected_language == 'en/') // Special 'default' case for english.
- selected_language = '';
- var new_url = url.replace('.org/' + current_language + current_version,
- '.org/' + selected_language + current_version);
- if (new_url != url) {
- navigate_to_first_existing([
- new_url,
- 'https://docs.python.org/'
- ]);
- }
- }
-
- // Returns the path segment of the language as a string, like 'fr/'
- // or '' if not found.
- function language_segment_from_url(url) {
- var language_regexp = '\.org/([a-z]{2}(?:-[a-z]{2})?/)';
- var match = url.match(language_regexp);
- if (match !== null)
- return match[1];
- return '';
- }
-
- // Returns the path segment of the version as a string, like '3.6/'
- // or '' if not found.
- function version_segment_in_url(url) {
- var language_segment = '(?:[a-z]{2}(?:-[a-z]{2})?/)';
- var version_segment = '(?:(?:' + version_regexs.join('|') + ')/)';
- var version_regexp = '\\.org/' + language_segment + '?(' + version_segment + ')';
- var match = url.match(version_regexp);
- if (match !== null)
- return match[1];
- return ''
- }
-
- $(document).ready(function() {
- var release = DOCUMENTATION_OPTIONS.VERSION;
- var language_segment = language_segment_from_url(window.location.href);
- var current_language = language_segment.replace(/\/+$/g, '') || 'en';
- var version = release.substr(0, 3);
- var version_select = build_version_select(version, release);
-
- $('.version_switcher_placeholder').html(version_select);
- $('.version_switcher_placeholder select').bind('change', on_version_switch);
-
- var language_select = build_language_select(current_language);
-
- $('.language_switcher_placeholder').html(language_select);
- $('.language_switcher_placeholder select').bind('change', on_language_switch);
- });
-})();
diff --git a/Doc/tools/templates/dummy.html b/Doc/tools/templates/dummy.html
index 68ae3ad148..3438b44377 100644
--- a/Doc/tools/templates/dummy.html
+++ b/Doc/tools/templates/dummy.html
@@ -6,3 +6,12 @@ In extensions/pyspecific.py:
{% trans %}CPython implementation detail:{% endtrans %}
{% trans %}Deprecated since version {deprecated}, will be removed in version {removed}{% endtrans %}
{% trans %}Deprecated since version {deprecated}, removed in version {removed}{% endtrans %}
+
+
+In docsbuild-scripts, when rewriting indexsidebar.html with actual versions:
+
+{% trans %}in development{% endtrans %}
+{% trans %}pre-release{% endtrans %}
+{% trans %}stable{% endtrans %}
+{% trans %}security-fixes{% endtrans %}
+{% trans %}EOL{% endtrans %}
diff --git a/Doc/tools/templates/indexsidebar.html b/Doc/tools/templates/indexsidebar.html
index 1c1cb5484a..f7bf6d8e49 100644
--- a/Doc/tools/templates/indexsidebar.html
+++ b/Doc/tools/templates/indexsidebar.html
@@ -2,12 +2,8 @@
<p><a href="{{ pathto('download') }}">{% trans %}Download these documents{% endtrans %}</a></p>
<h3>{% trans %}Docs by version{% endtrans %}</h3>
<ul>
- <li><a href="https://docs.python.org/3.10/">{% trans %}Python 3.10 (in development){% endtrans %}</a></li>
- <li><a href="https://docs.python.org/3.9/">{% trans %}Python 3.9 (pre-release){% endtrans %}</a></li>
- <li><a href="https://docs.python.org/3.8/">{% trans %}Python 3.8 (stable){% endtrans %}</a></li>
- <li><a href="https://docs.python.org/3.7/">{% trans %}Python 3.7 (stable){% endtrans %}</a></li>
- <li><a href="https://docs.python.org/3.6/">{% trans %}Python 3.6 (security-fixes){% endtrans %}</a></li>
- <li><a href="https://docs.python.org/2.7/">{% trans %}Python 2.7 (EOL){% endtrans %}</a></li>
+ <li><a href="https://docs.python.org/">{% trans %}Stable{% endtrans %}</a></li>
+ <li><a href="https://docs.python.org/dev/">{% trans %}In development{% endtrans %}</a></li>
<li><a href="https://www.python.org/doc/versions/">{% trans %}All versions{% endtrans %}</a></li>
</ul>
diff --git a/Doc/tools/templates/layout.html b/Doc/tools/templates/layout.html
index 17592d74a4..98ccf42248 100644
--- a/Doc/tools/templates/layout.html
+++ b/Doc/tools/templates/layout.html
@@ -12,22 +12,14 @@
{% block rootrellink %}
{{ super() }}
- <li>
- {%- if switchers is defined %}
- <span class="language_switcher_placeholder">{{ language or 'en' }}</span>
- <span class="version_switcher_placeholder">{{ release }}</span>
- <a href="{{ pathto('index') }}">{% trans %}Documentation {% endtrans %}</a>{{ reldelim1 }}
- {%- else %}
+ <li id="cpython-language-and-version">
<a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}
- {%- endif %}
</li>
{% endblock %}
{% block extrahead %}
<link rel="canonical" href="https://docs.python.org/3/{{pagename}}.html" />
{% if builder != "htmlhelp" %}
- {% if switchers is defined and not embedded %}
- <script type="text/javascript" src="{{ pathto('_static/switchers.js', 1) }}"></script>{% endif %}
{% if pagename == 'whatsnew/changelog' and not embedded %}
<script type="text/javascript" src="{{ pathto('_static/changelog_search.js', 1) }}"></script>{% endif %}
{% endif %}
diff --git a/Doc/tools/templates/search.html b/Doc/tools/templates/search.html
new file mode 100644
index 0000000000..cf20c2e1d4
--- /dev/null
+++ b/Doc/tools/templates/search.html
@@ -0,0 +1,48 @@
+{% extends "!search.html" %}
+{% block extrahead %}
+ {{ super() }}
+ <script type="text/javascript">
+ var GLOSSARY_PAGE = 'glossary.html';
+
+ jQuery(function() {
+ $.getJSON("_static/glossary.json", function(glossary) {
+ var RESULT_TEMPLATE = '<div style="display: none" class="admonition seealso" id="glossary-result">' +
+ ' <p class="topic-title">' +
+ ' <a class="glossary-title" href="#"></a>' +
+ ' </p>' +
+ ' <div class="glossary-body"></div>' +
+ '</div>';
+ $("#search-results").prepend(RESULT_TEMPLATE);
+
+ var params = $.getQueryParameters();
+ if (params.q) {
+ var search_param = params.q[0].toLowerCase();
+ var glossary_item = glossary[search_param];
+ if (glossary_item) {
+ var resultDiv = $("#glossary-result");
+
+ // set up the title text with a link to the glossary page
+ resultDiv.find(".glossary-title").text('Glossary: ' + glossary_item.title);
+ var link_target = search_param.replace(/ /g, '-');
+ resultDiv.find(".glossary-title").attr(
+ 'href', GLOSSARY_PAGE + '#term-' + link_target
+ );
+
+ // rewrite any anchor links (to other glossary terms)
+ // to have a full reference to the glossary page
+ var body = $(glossary_item.body).children();
+ body.find("a[href^='#']").each(function() {
+ var current_url = $(this).attr('href');
+ $(this).attr('href', GLOSSARY_PAGE + current_url);
+ });
+ resultDiv.find(".glossary-body").html(body);
+
+ resultDiv.show();
+ } else {
+ $("#glossary-result").hide('');
+ }
+ }
+ });
+ });
+ </script>
+{% endblock %} \ No newline at end of file
diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst
index ff4c797f66..5c6b65f05e 100644
--- a/Doc/tutorial/datastructures.rst
+++ b/Doc/tutorial/datastructures.rst
@@ -78,7 +78,7 @@ objects:
Return the number of times *x* appears in the list.
-.. method:: list.sort(key=None, reverse=False)
+.. method:: list.sort(*, key=None, reverse=False)
:noindex:
Sort the items of the list in place (the arguments can be used for sort
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
index 0ce96466e8..4a25861a05 100644
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -273,36 +273,35 @@ Exception Chaining
==================
The :keyword:`raise` statement allows an optional :keyword:`from` which enables
-chaining exceptions by setting the ``__cause__`` attribute of the raised
-exception. For example::
+chaining exceptions. For example::
- raise RuntimeError from OSError
+ # exc must be exception instance or None.
+ raise RuntimeError from exc
This can be useful when you are transforming exceptions. For example::
>>> def func():
- ... raise IOError
+ ... raise ConnectionError
...
>>> try:
... func()
- ... except IOError as exc:
+ ... except ConnectionError as exc:
... raise RuntimeError('Failed to open database') from exc
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "<stdin>", line 2, in func
- OSError
+ ConnectionError
<BLANKLINE>
The above exception was the direct cause of the following exception:
<BLANKLINE>
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
- RuntimeError
+ RuntimeError: Failed to open database
-The expression following the :keyword:`from` must be either an exception or
-``None``. Exception chaining happens automatically when an exception is raised
-inside an exception handler or :keyword:`finally` section. Exception chaining
-can be disabled by using ``from None`` idiom:
+Exception chaining happens automatically when an exception is raised inside an
+:keyword:`except` or :keyword:`finally` section. This can be
+disabled by using ``from None`` idiom:
>>> try:
... open('database.sqlite')
@@ -313,6 +312,8 @@ can be disabled by using ``from None`` idiom:
File "<stdin>", line 4, in <module>
RuntimeError
+For more information about chaining mechanics, see :ref:`bltin-exceptions`.
+
.. _tut-userexceptions:
diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
index 366a532e81..4e27cff83c 100644
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -329,11 +329,16 @@ equivalent :keyword:`try`\ -\ :keyword:`finally` blocks::
If you're not using the :keyword:`with` keyword, then you should call
``f.close()`` to close the file and immediately free up any system
-resources used by it. If you don't explicitly close a file, Python's
-garbage collector will eventually destroy the object and close the
-open file for you, but the file may stay open for a while. Another
-risk is that different Python implementations will do this clean-up at
-different times.
+resources used by it.
+
+.. warning::
+ Calling ``f.write()`` without using the :keyword:`!with` keyword or calling
+ ``f.close()`` **might** result in the arguments
+ of ``f.write()`` not being completely written to the disk, even if the
+ program exits successfully.
+
+..
+ See also https://bugs.python.org/issue17852
After a file object is closed, either by a :keyword:`with` statement
or by calling ``f.close()``, attempts to use the file object will
diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst
index 78c1e03f74..265c07c709 100644
--- a/Doc/using/windows.rst
+++ b/Doc/using/windows.rst
@@ -23,8 +23,8 @@ available for application-local distributions.
As specified in :pep:`11`, a Python release only supports a Windows platform
while Microsoft considers the platform under extended support. This means that
-Python |version| supports Windows Vista and newer. If you require Windows XP
-support then please install Python 3.4.
+Python |version| supports Windows 8.1 and newer. If you require Windows 7
+support, please install Python 3.8.
There are a number of different installers available for Windows, each with
certain benefits and downsides.
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 60dee0c6bd..b5fb1e9a62 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -120,8 +120,8 @@ See :pep:`613` for more details.
(Contributed by Mikhail Golubev in :issue:`41923`.)
-PEP604: New Type Union Operator
--------------------------------
+PEP 604: New Type Union Operator
+--------------------------------
A new type union operator was introduced which enables the syntax ``X | Y``.
This provides a cleaner way of expressing 'either type X or type Y' instead of
@@ -154,6 +154,9 @@ Other Language Changes
:meth:`~object.__index__` method).
(Contributed by Serhiy Storchaka in :issue:`37999`.)
+* Assignment expressions can now be used unparenthesized within set literals
+ and set comprehensions, as well as in sequence indexes (but not slices).
+
New Modules
===========
@@ -176,6 +179,31 @@ codecs
Add a :func:`codecs.unregister` function to unregister a codec search function.
(Contributed by Hai Shi in :issue:`41842`.)
+collections.abc
+---------------
+
+The ``__args__`` of the :ref:`parameterized generic <types-genericalias>` for
+:class:`collections.abc.Callable` are now consistent with :data:`typing.Callable`.
+:class:`collections.abc.Callable` generic now flattens type parameters, similar
+to what :data:`typing.Callable` currently does. This means that
+``collections.abc.Callable[[int, str], str]`` will have ``__args__`` of
+``(int, str, str)``; previously this was ``([int, str], str)``. To allow this
+change, :class:`types.GenericAlias` can now be subclassed, and a subclass will
+be returned when subscripting the :class:`collections.abc.Callable` type. Note
+that a :exc:`TypeError` may be raised for invalid forms of parameterizing
+:class:`collections.abc.Callable` which may have passed silently in Python 3.9.
+(Contributed by Ken Jin in :issue:`42195`.)
+
+contextlib
+----------
+
+Add a :func:`contextlib.aclosing` context manager to safely close async generators
+and objects representing asynchronously released resources.
+(Contributed by Joongi Kim and John Belmonte in :issue:`41229`.)
+
+Add asynchronous context manager support to :func:`contextlib.nullcontext`.
+(Contributed by Tom Gringauz in :issue:`41543`.)
+
curses
------
@@ -186,6 +214,12 @@ by :func:`curses.color_content`, :func:`curses.init_color`,
support is provided by the underlying ncurses library.
(Contributed by Jeffrey Kintscher and Hans Petter Jansson in :issue:`36982`.)
+doctest
+-------
+
+When a module does not define ``__loader__``, fall back to ``__spec__.loader``.
+(Contributed by Brett Cannon in :issue:`42133`.)
+
encodings
---------
:func:`encodings.normalize_encoding` now ignores non-ASCII characters.
@@ -198,12 +232,56 @@ Added the *root_dir* and *dir_fd* parameters in :func:`~glob.glob` and
:func:`~glob.iglob` which allow to specify the root directory for searching.
(Contributed by Serhiy Storchaka in :issue:`38144`.)
+inspect
+-------
+
+When a module does not define ``__loader__``, fall back to ``__spec__.loader``.
+(Contributed by Brett Cannon in :issue:`42133`.)
+
+Added *globalns* and *localns* parameters in :func:`~inspect.signature` and
+:meth:`inspect.Signature.from_callable` to retrieve the annotations in given
+local and global namespaces.
+(Contributed by Batuhan Taskaya in :issue:`41960`.)
+
+linecache
+---------
+
+When a module does not define ``__loader__``, fall back to ``__spec__.loader``.
+(Contributed by Brett Cannon in :issue:`42133`.)
+
os
--
Added :func:`os.cpu_count()` support for VxWorks RTOS.
(Contributed by Peixing Xin in :issue:`41440`.)
+Added a new function :func:`os.eventfd` and related helpers to wrap the
+``eventfd2`` syscall on Linux.
+(Contributed by Christian Heimes in :issue:`41001`.)
+
+Added :func:`os.splice()` that allows to move data between two file
+descriptors without copying between kernel address space and user
+address space, where one of the file descriptors must refer to a
+pipe. (Contributed by Pablo Galindo in :issue:`41625`.)
+
+pathlib
+-------
+
+Added slice support to :attr:`PurePath.parents <pathlib.PurePath.parents>`.
+(Contributed by Joshua Cannon in :issue:`35498`)
+
+Added negative indexing support to :attr:`PurePath.parents
+<pathlib.PurePath.parents>`.
+(Contributed by Yaroslav Pankovych in :issue:`21041`)
+
+platform
+--------
+
+Added :func:`platform.freedesktop_os_release()` to retrieve operation system
+identification from `freedesktop.org os-release
+<https://www.freedesktop.org/software/systemd/man/os-release.html>`_ standard file.
+(Contributed by Christian Heimes in :issue:`28468`)
+
py_compile
----------
@@ -217,6 +295,18 @@ The :mod:`shelve` module now uses :data:`pickle.DEFAULT_PROTOCOL` by default
instead of :mod:`pickle` protocol ``3`` when creating shelves.
(Contributed by Zackery Spytz in :issue:`34204`.)
+site
+----
+
+When a module does not define ``__loader__``, fall back to ``__spec__.loader``.
+(Contributed by Brett Cannon in :issue:`42133`.)
+
+socket
+------
+
+The exception :exc:`socket.timeout` is now an alias of :exc:`TimeoutError`.
+(Contributed by Christian Heimes in :issue:`42413`.)
+
sys
---
@@ -224,6 +314,28 @@ Add :data:`sys.orig_argv` attribute: the list of the original command line
arguments passed to the Python executable.
(Contributed by Victor Stinner in :issue:`23427`.)
+threading
+---------
+
+Added :func:`threading.gettrace` and :func:`threading.getprofile` to
+retrieve the functions set by :func:`threading.settrace` and
+:func:`threading.setprofile` respectively.
+(Contributed by Mario Corchero in :issue:`42251`.)
+
+Add :data:`threading.__excepthook__` to allow retrieving the original value
+of :func:`threading.excepthook` in case it is set to a broken or a different
+value.
+(Contributed by Mario Corchero in :issue:`42308`.)
+
+traceback
+---------
+
+The :func:`~traceback.format_exception`,
+:func:`~traceback.format_exception_only`, and
+:func:`~traceback.print_exception` functions can now take an exception object
+as a positional-only argument.
+(Contributed by Zackery Spytz and Matthias Bussonnier in :issue:`26389`.)
+
types
-----
@@ -232,6 +344,32 @@ and :data:`types.NotImplementedType` classes, providing a new set
of types readily interpretable by type checkers.
(Contributed by Bas van Beek in :issue:`41810`.)
+typing
+------
+
+The behavior of :class:`typing.Literal` was changed to conform with :pep:`586`
+and to match the behavior of static type checkers specified in the PEP.
+
+1. ``Literal`` now de-duplicates parameters.
+2. Equality comparisons between ``Literal`` objects are now order independent.
+3. ``Literal`` comparisons now respects types. For example,
+ ``Literal[0] == Literal[False]`` previously evaluated to ``True``. It is
+ now ``False``. To support this change, the internally used type cache now
+ supports differentiating types.
+4. ``Literal`` objects will now raise a :exc:`TypeError` exception during
+ equality comparisons if one of their parameters are not :term:`immutable`.
+ Note that declaring ``Literal`` with mutable parameters will not throw
+ an error::
+
+ >>> from typing import Literal
+ >>> Literal[{0}]
+ >>> Literal[{0}] == Literal[{False}]
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ TypeError: unhashable type: 'set'
+
+(Contributed by Yurii Karabas in :issue:`42345`.)
+
unittest
--------
@@ -246,6 +384,13 @@ Add a :class:`~xml.sax.handler.LexicalHandler` class to the
:mod:`xml.sax.handler` module.
(Contributed by Jonathan Gossage and Zackery Spytz in :issue:`35018`.)
+zipimport
+---------
+Add methods related to :pep:`451`: :meth:`~zipimport.zipimporter.find_spec`,
+:meth:`zipimport.zipimporter.create_module`, and
+:meth:`zipimport.zipimporter.exec_module`.
+(Contributed by Brett Cannon in :issue:`42131`.
+
Optimizations
=============
@@ -269,7 +414,13 @@ Optimizations
with ``gcc`` by up to 30%. See `this article
<https://developers.redhat.com/blog/2020/06/25/red-hat-enterprise-linux-8-2-brings-faster-python-3-8-run-speeds/>`_
for more details. (Contributed by Victor Stinner and Pablo Galindo in
- :issue:`38980`)
+ :issue:`38980`.)
+
+
+* Function parameters and their annotations are no longer computed at runtime,
+ but rather at compilation time. They are stored as a tuple of strings at the
+ bytecode level. It is now around 100% faster to create a function with parameter
+ annotations. (Contributed by Yurii Karabas and Inada Naoki in :issue:`42202`)
Deprecated
==========
@@ -291,6 +442,26 @@ Deprecated
as appropriate to help identify code which needs updating during
this transition.
+* The various ``load_module()`` methods of :mod:`importlib` have been
+ documented as deprecated since Python 3.6, but will now also trigger
+ a :exc:`DeprecationWarning`. Use
+ :meth:`~importlib.abc.Loader.exec_module` instead.
+ (Contributed by Brett Cannon in :issue:`26131`.)
+
+* :meth:`zimport.zipimporter.load_module` has been deprecated in
+ preference for :meth:`~zipimport.zipimporter.exec_module`.
+ (Contributed by Brett Cannon in :issue:`26131`.)
+
+* The use of :meth:`~importlib.abc.Loader.load_module` by the import
+ system now triggers an :exc:`ImportWarning` as
+ :meth:`~importlib.abc.Loader.exec_module` is preferred.
+ (Contributed by Brett Cannon in :issue:`26131`.)
+
+* ``sqlite3.OptimizedUnicode`` has been undocumented and obsolete since Python
+ 3.3, when it was made an alias to :class:`str`. It is now deprecated,
+ scheduled for removal in Python 3.12.
+ (Contributed by Erlend E. Aasland in :issue:`42264`.)
+
Removed
=======
@@ -312,6 +483,27 @@ Removed
moved to the internal C API.
(Contributed by Victor Stinner in :issue:`42157`.)
+* Removed the ``parser`` module, which was deprecated in 3.9 due to the
+ switch to the new PEG parser, as well as all the C source and header files
+ that were only being used by the old parser, including ``node.h``, ``parser.h``,
+ ``graminit.h`` and ``grammar.h``.
+
+* Removed the Public C API functions :c:func:`PyParser_SimpleParseStringFlags`,
+ :c:func:`PyParser_SimpleParseStringFlagsFilename`,
+ :c:func:`PyParser_SimpleParseFileFlags` and :c:func:`PyNode_Compile`
+ that were deprecated in 3.9 due to the switch to the new PEG parser.
+
+* Removed the ``formatter`` module, which was deprecated in Python 3.4.
+ It is somewhat obsolete, little used, and not tested. It was originally
+ scheduled to be removed in Python 3.6, but such removals were delayed until
+ after Python 2.7 EOL. Existing users should copy whatever classes they use
+ into their code.
+ (Contributed by Dong-hee Na and Terry J. Reedy in :issue:`42299`.)
+
+* Removed the :c:func:`PyModule_GetWarningsModule` function that was useless
+ now due to the _warnings module was converted to a builtin module in 2.6.
+ (Contributed by Hai Shi in :issue:`42599`.)
+
Porting to Python 3.10
======================
@@ -320,6 +512,37 @@ This section lists previously described changes and other bugfixes
that may require changes to your code.
+Changes in the Python API
+-------------------------
+
+* The *etype* parameters of the :func:`~traceback.format_exception`,
+ :func:`~traceback.format_exception_only`, and
+ :func:`~traceback.print_exception` functions in the :mod:`traceback` module
+ have been renamed to *exc*.
+ (Contributed by Zackery Spytz and Matthias Bussonnier in :issue:`26389`.)
+
+* :mod:`atexit`: At Python exit, if a callback registered with
+ :func:`atexit.register` fails, its exception is now logged. Previously, only
+ some exceptions were logged, and the last exception was always silently
+ ignored.
+ (Contributed by Victor Stinner in :issue:`42639`.)
+
+* :class:`collections.abc.Callable` generic now flattens type parameters, similar
+ to what :data:`typing.Callable` currently does. This means that
+ ``collections.abc.Callable[[int, str], str]`` will have ``__args__`` of
+ ``(int, str, str)``; previously this was ``([int, str], str)``. Code which
+ accesses the arguments via :func:`typing.get_args` or ``__args__`` need to account
+ for this change. Furthermore, :exc:`TypeError` may be raised for invalid forms
+ of parameterizing :class:`collections.abc.Callable` which may have passed
+ silently in Python 3.9.
+ (Contributed by Ken Jin in :issue:`42195`.)
+
+CPython bytecode changes
+========================
+
+* The ``MAKE_FUNCTION`` instruction accepts tuple of strings as annotations
+ instead of dictionary.
+ (Contributed by Yurii Karabas and Inada Naoki in :issue:`42202`)
Build Changes
=============
@@ -332,6 +555,8 @@ Build Changes
* :mod:`sqlite3` requires SQLite 3.7.3 or higher.
(Contributed by Sergey Fedoseev and Erlend E. Aasland :issue:`40744`.)
+* The :mod:`atexit` module must now always be built as a built-in module.
+ (Contributed by Victor Stinner in :issue:`42639`.)
C API Changes
@@ -366,6 +591,26 @@ New Features
* Added :c:func:`PyUnicode_AsUTF8AndSize` to the limited C API.
(Contributed by Alex Gaynor in :issue:`41784`.)
+* Added :c:func:`PyModule_AddObjectRef` function: similar to
+ :c:func:`PyModule_AddObject` but don't steal a reference to the value on
+ success.
+ (Contributed by Victor Stinner in :issue:`1635741`.)
+
+* Added :c:func:`Py_NewRef` and :c:func:`Py_XNewRef` functions to increment the
+ reference count of an object and return the object.
+ (Contributed by Victor Stinner in :issue:`42262`.)
+
+* The :c:func:`PyType_FromSpecWithBases` and :c:func:`PyType_FromModuleAndSpec`
+ functions now accept a single class as the *bases* argument.
+ (Contributed by Serhiy Storchaka in :issue:`42423`.)
+
+* The :c:func:`PyType_FromModuleAndSpec` function now accepts NULL ``tp_doc``
+ slot.
+ (Contributed by Hai Shi in :issue:`41832`.)
+
+* The :c:func:`PyType_GetSlot` function can accept static types.
+ (Contributed by Hai Shi and Petr Viktorin in :issue:`41073`.)
+
Porting to Python 3.10
----------------------
@@ -377,17 +622,6 @@ Porting to Python 3.10
<arg-parsing>` and the :pep:`353`.
(Contributed by Victor Stinner in :issue:`40943`.)
-* Since :c:func:`Py_TYPE()` is changed to the inline static function,
- ``Py_TYPE(obj) = new_type`` must be replaced with ``Py_SET_TYPE(obj, new_type)``:
- see :c:func:`Py_SET_TYPE()` (available since Python 3.9). For backward
- compatibility, this macro can be used::
-
- #if PY_VERSION_HEX < 0x030900A4
- # define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0)
- #endif
-
- (Contributed by Dong-hee Na in :issue:`39573`.)
-
* Since :c:func:`Py_REFCNT()` is changed to the inline static function,
``Py_REFCNT(obj) = new_refcnt`` must be replaced with ``Py_SET_REFCNT(obj, new_refcnt)``:
see :c:func:`Py_SET_REFCNT()` (available since Python 3.9). For backward
@@ -399,17 +633,6 @@ Porting to Python 3.10
(Contributed by Victor Stinner in :issue:`39573`.)
-* Since :c:func:`Py_SIZE()` is changed to the inline static function,
- ``Py_SIZE(obj) = new_size`` must be replaced with ``Py_SET_SIZE(obj, new_size)``:
- see :c:func:`Py_SET_SIZE()` (available since Python 3.9). For backward
- compatibility, this macro can be used::
-
- #if PY_VERSION_HEX < 0x030900A4
- # define Py_SET_SIZE(obj, size) ((Py_SIZE(obj) = (size)), (void)0)
- #endif
-
- (Contributed by Victor Stinner in :issue:`39573`.)
-
* Calling :c:func:`PyDict_GetItem` without :term:`GIL` held had been allowed
for historical reason. It is no longer allowed.
(Contributed by Victor Stinner in :issue:`40839`.)
@@ -423,6 +646,21 @@ Porting to Python 3.10
``unicodedata.ucnhash_CAPI`` has been moved to the internal C API.
(Contributed by Victor Stinner in :issue:`42157`.)
+* :c:func:`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`,
+ :c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome` and
+ :c:func:`Py_GetProgramName` functions now return ``NULL`` if called before
+ :c:func:`Py_Initialize` (before Python is initialized). Use the new
+ :ref:`Python Initialization Configuration API <init-config>` to get the
+ :ref:`Python Path Configuration. <init-path-config>`.
+ (Contributed by Victor Stinner in :issue:`42260`.)
+
+* :c:func:`PyList_SET_ITEM`, :c:func:`PyTuple_SET_ITEM` and
+ :c:func:`PyCell_SET` macros can no longer be used as l-value or r-value.
+ For example, ``x = PyList_SET_ITEM(a, b, c)`` and
+ ``PyList_SET_ITEM(a, b, c) = x`` now fail with a compiler error. It prevents
+ bugs like ``if (PyList_SET_ITEM (a, b, c) < 0) ...`` test.
+ (Contributed by Zackery Spytz and Victor Stinner in :issue:`30459`.)
+
Deprecated
----------
@@ -471,3 +709,8 @@ Removed
``Py_END_ALLOW_RECURSION`` and the ``recursion_critical`` field of the
:c:type:`PyInterpreterState` structure.
(Contributed by Serhiy Storchaka in :issue:`41936`.)
+
+* Removed the undocumented ``PyOS_InitInterrupts()`` function. Initializing
+ Python already implicitly installs signal handlers: see
+ :c:member:`PyConfig.install_signal_handlers`.
+ (Contributed by Victor Stinner in :issue:`41713`.)
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 6a9fa34156..0b4820f333 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -2113,9 +2113,6 @@ Changes in the C API
(Contributed by Antoine Pitrou in :issue:`32388`.)
-* The :c:func:`PyCode_New` has a new parameter in the second position (*posonlyargcount*)
- to support :pep:`570`, indicating the number of positional-only arguments.
-
* The functions :c:func:`PyNode_AddChild` and :c:func:`PyParser_AddToken` now accept
two additional ``int`` arguments *end_lineno* and *end_col_offset*.
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index a601b16f1c..b94f1bfadd 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -135,8 +135,8 @@ More generally, try to run your tests in the :ref:`Python Development Mode
<devmode>` which helps to prepare your code to make it compatible with the
next Python version.
-Note: a number of pre-existing deprecatations were removed in this version
-of Python as well. Consult the :ref:`removed-in-python-39` section.
+Note: a number of pre-existing deprecations were removed in this version of
+Python as well. Consult the :ref:`removed-in-python-39` section.
New Features
@@ -1454,3 +1454,65 @@ Removed
``PyNullImporter_Type``, ``PyCmpWrapper_Type``, ``PySortWrapper_Type``,
``PyNoArgsFunction``.
(Contributed by Pablo Galindo Salgado in :issue:`39372`.)
+
+Notable changes in Python 3.9.1
+===============================
+
+typing
+------
+
+The behavior of :class:`typing.Literal` was changed to conform with :pep:`586`
+and to match the behavior of static type checkers specified in the PEP.
+
+1. ``Literal`` now de-duplicates parameters.
+2. Equality comparisons between ``Literal`` objects are now order independent.
+3. ``Literal`` comparisons now respect types. For example,
+ ``Literal[0] == Literal[False]`` previously evaluated to ``True``. It is
+ now ``False``. To support this change, the internally used type cache now
+ supports differentiating types.
+4. ``Literal`` objects will now raise a :exc:`TypeError` exception during
+ equality comparisons if one of their parameters are not :term:`immutable`.
+ Note that declaring ``Literal`` with mutable parameters will not throw
+ an error::
+
+ >>> from typing import Literal
+ >>> Literal[{0}]
+ >>> Literal[{0}] == Literal[{False}]
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ TypeError: unhashable type: 'set'
+
+(Contributed by Yurii Karabas in :issue:`42345`.)
+
+macOS 11.0 (Big Sur) and Apple Silicon Mac support
+--------------------------------------------------
+
+As of 3.9.1, Python now fully supports building and running on macOS 11.0
+(Big Sur) and on Apple Silicon Macs (based on the ``ARM64`` architecture).
+A new universal build variant, ``universal2``, is now available to natively
+support both ``ARM64`` and ``Intel 64`` in one set of executables. Binaries
+can also now be built on current versions of macOS to be deployed on a range
+of older macOS versions (tested to 10.9) while making some newer OS
+functions and options conditionally available based on the operating system
+version in use at runtime ("weaklinking").
+
+(Contributed by Ronald Oussoren and Lawrence D'Anna in :issue:`41100`.)
+
+Notable changes in Python 3.9.2
+===============================
+
+collections.abc
+---------------
+
+:class:`collections.abc.Callable` generic now flattens type parameters, similar
+to what :data:`typing.Callable` currently does. This means that
+``collections.abc.Callable[[int, str], str]`` will have ``__args__`` of
+``(int, str, str)``; previously this was ``([int, str], str)``. To allow this
+change, :class:`types.GenericAlias` can now be subclassed, and a subclass will
+be returned when subscripting the :class:`collections.abc.Callable` type.
+Code which accesses the arguments via :func:`typing.get_args` or ``__args__``
+need to account for this change. A :exc:`DeprecationWarning` may be emitted for
+invalid forms of parameterizing :class:`collections.abc.Callable` which may have
+passed silently in Python 3.9.1. This :exc:`DeprecationWarning` will
+become a :exc:`TypeError` in Python 3.10.
+(Contributed by Ken Jin in :issue:`42195`.) \ No newline at end of file
diff --git a/Grammar/python.gram b/Grammar/python.gram
index ae5e4b5d4c..4915cc43e8 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -52,18 +52,18 @@ type_expressions[asdl_expr_seq*]:
| a[asdl_expr_seq*]=','.expression+ {a}
statements[asdl_stmt_seq*]: a=statement+ { (asdl_stmt_seq*)_PyPegen_seq_flatten(p, a) }
-statement[asdl_stmt_seq*]: a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } | a[asdl_stmt_seq*]=simple_stmt { a }
+statement[asdl_stmt_seq*]: a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } | a[asdl_stmt_seq*]=simple_stmts { a }
statement_newline[asdl_stmt_seq*]:
| a=compound_stmt NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) }
- | simple_stmt
+ | simple_stmts
| NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, CHECK(stmt_ty, _Py_Pass(EXTRA))) }
| ENDMARKER { _PyPegen_interactive_exit(p) }
-simple_stmt[asdl_stmt_seq*]:
- | a=small_stmt !';' NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } # Not needed, there for speedup
- | a[asdl_stmt_seq*]=';'.small_stmt+ [';'] NEWLINE { a }
+simple_stmts[asdl_stmt_seq*]:
+ | a=simple_stmt !';' NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } # Not needed, there for speedup
+ | a[asdl_stmt_seq*]=';'.simple_stmt+ [';'] NEWLINE { a }
# NOTE: assignment MUST precede expression, else parsing a simple assignment
# will throw a SyntaxError.
-small_stmt[stmt_ty] (memo):
+simple_stmt[stmt_ty] (memo):
| assignment
| e=star_expressions { _Py_Expr(e, EXTRA) }
| &'return' return_stmt
@@ -308,10 +308,9 @@ class_def_raw[stmt_ty]:
block[asdl_stmt_seq*] (memo):
| NEWLINE INDENT a=statements DEDENT { a }
- | simple_stmt
+ | simple_stmts
| invalid_block
-expressions_list[asdl_expr_seq*]: a[asdl_expr_seq*]=','.star_expression+ [','] { a }
star_expressions[expr_ty]:
| a=star_expression b=(',' c=star_expression { c })+ [','] {
_Py_Tuple(CHECK(asdl_expr_seq*, _PyPegen_seq_insert_in_front(p, a, b)), Load, EXTRA) }
@@ -491,7 +490,7 @@ slices[expr_ty]:
| a[asdl_expr_seq*]=','.slice+ [','] { _Py_Tuple(a, Load, EXTRA) }
slice[expr_ty]:
| a=[expression] ':' b=[expression] c=[':' d=[expression] { d }] { _Py_Slice(a, b, c, EXTRA) }
- | a=expression { a }
+ | a=named_expression { a }
atom[expr_ty]:
| NAME
| 'True' { _Py_Constant(Py_True, NULL, EXTRA) }
@@ -517,11 +516,11 @@ group[expr_ty]:
| '(' a=(yield_expr | named_expression) ')' { a }
| invalid_group
genexp[expr_ty]:
- | '(' a=expression ~ b=for_if_clauses ')' { _Py_GeneratorExp(a, b, EXTRA) }
+ | '(' a=named_expression ~ b=for_if_clauses ')' { _Py_GeneratorExp(a, b, EXTRA) }
| invalid_comprehension
-set[expr_ty]: '{' a=expressions_list '}' { _Py_Set(a, EXTRA) }
+set[expr_ty]: '{' a=star_named_expressions '}' { _Py_Set(a, EXTRA) }
setcomp[expr_ty]:
- | '{' a=expression ~ b=for_if_clauses '}' { _Py_SetComp(a, b, EXTRA) }
+ | '{' a=named_expression ~ b=for_if_clauses '}' { _Py_SetComp(a, b, EXTRA) }
| invalid_comprehension
dict[expr_ty]:
| '{' a=[double_starred_kvpairs] '}' {
@@ -647,7 +646,7 @@ invalid_arguments:
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "Generator expression must be parenthesized") }
| a=args ',' args { _PyPegen_arguments_parsing_error(p, a) }
invalid_kwarg:
- | a=expression '=' {
+ | expression a='=' {
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
a, "expression cannot contain assignment, perhaps you meant \"==\"?") }
invalid_named_expression:
diff --git a/Include/abstract.h b/Include/abstract.h
index 28e576b929..0bd1ca9368 100644
--- a/Include/abstract.h
+++ b/Include/abstract.h
@@ -339,11 +339,6 @@ PyAPI_FUNC(int) PyIter_Check(PyObject *);
PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *);
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
-typedef enum {
- PYGEN_RETURN = 0,
- PYGEN_ERROR = -1,
- PYGEN_NEXT = 1,
-} PySendResult;
/* Takes generator, coroutine or iterator object and sends the value into it.
Returns:
diff --git a/Include/boolobject.h b/Include/boolobject.h
index bb8044a2b0..6673d7206c 100644
--- a/Include/boolobject.h
+++ b/Include/boolobject.h
@@ -22,8 +22,8 @@ PyAPI_DATA(struct _longobject) _Py_FalseStruct, _Py_TrueStruct;
#define Py_True ((PyObject *) &_Py_TrueStruct)
/* Macros for returning Py_True or Py_False, respectively */
-#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
-#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
+#define Py_RETURN_TRUE return Py_NewRef(Py_True)
+#define Py_RETURN_FALSE return Py_NewRef(Py_False)
/* Function to return a bool from a C long */
PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
diff --git a/Include/bytesobject.h b/Include/bytesobject.h
index 5062d8d123..39c241a2dc 100644
--- a/Include/bytesobject.h
+++ b/Include/bytesobject.h
@@ -1,5 +1,5 @@
-/* Bytes (String) object interface */
+/* Bytes object interface */
#ifndef Py_BYTESOBJECT_H
#define Py_BYTESOBJECT_H
@@ -10,23 +10,20 @@ extern "C" {
#include <stdarg.h>
/*
-Type PyBytesObject represents a character string. An extra zero byte is
+Type PyBytesObject represents a byte string. An extra zero byte is
reserved at the end to ensure it is zero-terminated, but a size is
present so strings with null bytes in them can be represented. This
is an immutable object type.
-There are functions to create new string objects, to test
-an object for string-ness, and to get the
-string value. The latter function returns a null pointer
+There are functions to create new bytes objects, to test
+an object for bytes-ness, and to get the
+byte string value. The latter function returns a null pointer
if the object is not of the proper type.
There is a variant that takes an explicit size as well as a
variant that assumes a zero-terminated string. Note that none of the
-functions should be applied to nil objects.
+functions should be applied to NULL pointer.
*/
-/* Caching the hash (ob_shash) saves recalculation of a string's hash value.
- This significantly speeds up dict lookups. */
-
PyAPI_DATA(PyTypeObject) PyBytes_Type;
PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
@@ -50,26 +47,16 @@ PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
const char *, Py_ssize_t,
const char *);
-/* Provides access to the internal data buffer and size of a string
- object or the default encoded version of a Unicode object. Passing
- NULL as *len parameter will force the string buffer to be
- 0-terminated (passing a string with embedded NULL characters will
+/* Provides access to the internal data buffer and size of a bytes object.
+ Passing NULL as len parameter will force the string buffer to be
+ 0-terminated (passing a string with embedded NUL characters will
cause an exception). */
PyAPI_FUNC(int) PyBytes_AsStringAndSize(
- PyObject *obj, /* string or Unicode object */
+ PyObject *obj, /* bytes object */
char **s, /* pointer to buffer variable */
- Py_ssize_t *len /* pointer to length variable or NULL
- (only possible for 0-terminated
- strings) */
+ Py_ssize_t *len /* pointer to length variable or NULL */
);
-/* Flags used by string formatting */
-#define F_LJUST (1<<0)
-#define F_SIGN (1<<1)
-#define F_BLANK (1<<2)
-#define F_ALT (1<<3)
-#define F_ZERO (1<<4)
-
#ifndef Py_LIMITED_API
# define Py_CPYTHON_BYTESOBJECT_H
# include "cpython/bytesobject.h"
diff --git a/Include/cellobject.h b/Include/cellobject.h
index f12aa90a42..81bc784d36 100644
--- a/Include/cellobject.h
+++ b/Include/cellobject.h
@@ -20,7 +20,7 @@ PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);
PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref)
-#define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v)
+#define PyCell_SET(op, v) ((void)(((PyCellObject *)(op))->ob_ref = v))
#ifdef __cplusplus
}
diff --git a/Include/cpython/bytesobject.h b/Include/cpython/bytesobject.h
index f284c5835d..6b3f55224f 100644
--- a/Include/cpython/bytesobject.h
+++ b/Include/cpython/bytesobject.h
@@ -10,7 +10,7 @@ typedef struct {
/* Invariants:
* ob_sval contains space for 'ob_size+1' elements.
* ob_sval[ob_size] == 0.
- * ob_shash is the hash of the string or -1 if not computed yet.
+ * ob_shash is the hash of the byte string or -1 if not computed yet.
*/
} PyBytesObject;
diff --git a/Include/cpython/code.h b/Include/cpython/code.h
index cda28ac6ee..c3065bb8c4 100644
--- a/Include/cpython/code.h
+++ b/Include/cpython/code.h
@@ -38,7 +38,7 @@ struct PyCodeObject {
Py_ssize_t *co_cell2arg; /* Maps cell vars which are arguments. */
PyObject *co_filename; /* unicode (where it was loaded from) */
PyObject *co_name; /* unicode (name, for reference) */
- PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See
+ PyObject *co_linetable; /* string (encoding addr<->lineno mapping) See
Objects/lnotab_notes.txt for details. */
void *co_zombieframe; /* for optimization only (see frameobject.c) */
PyObject *co_weakreflist; /* to support weakrefs to code objects */
@@ -135,16 +135,18 @@ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno);
PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
/* for internal use only */
-typedef struct _addr_pair {
- int ap_lower;
- int ap_upper;
-} PyAddrPair;
+typedef struct _line_offsets {
+ int ar_start;
+ int ar_end;
+ int ar_line;
+ int ar_computed_line;
+ char *lo_next;
+} PyCodeAddressRange;
/* Update *bounds to describe the first and one-past-the-last instructions in the
same line as lasti. Return the number of that line.
*/
-PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co,
- int lasti, PyAddrPair *bounds);
+PyAPI_FUNC(int) _PyCode_CheckLineNumber(int lasti, PyCodeAddressRange *bounds);
/* Create a comparable key used to compare constants taking in account the
* object type. It is used to make sure types are not coerced (e.g., float and
@@ -163,3 +165,15 @@ PyAPI_FUNC(int) _PyCode_GetExtra(PyObject *code, Py_ssize_t index,
void **extra);
PyAPI_FUNC(int) _PyCode_SetExtra(PyObject *code, Py_ssize_t index,
void *extra);
+
+/** API for initializing the line number table. */
+int _PyCode_InitAddressRange(PyCodeObject* co, PyCodeAddressRange *bounds);
+
+/** Out of process API for initializing the line number table. */
+void PyLineTable_InitAddressRange(char *linetable, int firstlineno, PyCodeAddressRange *range);
+
+/** API for traversing the line number table. */
+int PyLineTable_NextAddressRange(PyCodeAddressRange *range);
+int PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);
+
+
diff --git a/Include/cpython/fileutils.h b/Include/cpython/fileutils.h
index e79d03e24f..312fd95828 100644
--- a/Include/cpython/fileutils.h
+++ b/Include/cpython/fileutils.h
@@ -95,10 +95,6 @@ PyAPI_FUNC(FILE *) _Py_wfopen(
const wchar_t *path,
const wchar_t *mode);
-PyAPI_FUNC(FILE*) _Py_fopen(
- const char *pathname,
- const char *mode);
-
PyAPI_FUNC(FILE*) _Py_fopen_obj(
PyObject *path,
const char *mode);
diff --git a/Include/cpython/initconfig.h b/Include/cpython/initconfig.h
index 3a38f77073..666c1e419c 100644
--- a/Include/cpython/initconfig.h
+++ b/Include/cpython/initconfig.h
@@ -41,7 +41,7 @@ PyAPI_FUNC(PyStatus) PyWideStringList_Insert(PyWideStringList *list,
/* --- PyPreConfig ----------------------------------------------- */
-typedef struct {
+typedef struct PyPreConfig {
int _config_init; /* _PyConfigInitEnum value */
/* Parse Py_PreInitializeFromBytesArgs() arguments?
@@ -128,7 +128,7 @@ PyAPI_FUNC(void) PyPreConfig_InitIsolatedConfig(PyPreConfig *config);
/* --- PyConfig ---------------------------------------------- */
/* This structure is best documented in the Doc/c-api/init_config.rst file. */
-typedef struct {
+typedef struct PyConfig {
int _config_init; /* _PyConfigInitEnum value */
int isolated;
@@ -147,8 +147,8 @@ typedef struct {
wchar_t *filesystem_errors;
wchar_t *pycache_prefix;
int parse_argv;
+ PyWideStringList orig_argv;
PyWideStringList argv;
- wchar_t *program_name;
PyWideStringList xoptions;
PyWideStringList warnoptions;
int site_import;
@@ -169,12 +169,13 @@ typedef struct {
int legacy_windows_stdio;
#endif
wchar_t *check_hash_pycs_mode;
- PyWideStringList orig_argv;
/* --- Path configuration inputs ------------ */
int pathconfig_warnings;
+ wchar_t *program_name;
wchar_t *pythonpath_env;
wchar_t *home;
+ wchar_t *platlibdir;
/* --- Path configuration outputs ----------- */
int module_search_paths_set;
@@ -185,7 +186,6 @@ typedef struct {
wchar_t *base_prefix;
wchar_t *exec_prefix;
wchar_t *base_exec_prefix;
- wchar_t *platlibdir;
/* --- Parameter only used by Py_Main() ---------- */
int skip_source_first_line;
diff --git a/Include/cpython/listobject.h b/Include/cpython/listobject.h
index e1b9462d5b..e3239152c4 100644
--- a/Include/cpython/listobject.h
+++ b/Include/cpython/listobject.h
@@ -30,5 +30,5 @@ PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
#define _PyList_CAST(op) (assert(PyList_Check(op)), (PyListObject *)(op))
#define PyList_GET_ITEM(op, i) (_PyList_CAST(op)->ob_item[i])
-#define PyList_SET_ITEM(op, i, v) (_PyList_CAST(op)->ob_item[i] = (v))
+#define PyList_SET_ITEM(op, i, v) ((void)(_PyList_CAST(op)->ob_item[i] = (v)))
#define PyList_GET_SIZE(op) Py_SIZE(_PyList_CAST(op))
diff --git a/Include/cpython/object.h b/Include/cpython/object.h
index 875a600f79..86889f8576 100644
--- a/Include/cpython/object.h
+++ b/Include/cpython/object.h
@@ -35,12 +35,13 @@ PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
_PyObject_{Get,Set,Has}AttrId are __getattr__ versions using _Py_Identifier*.
*/
typedef struct _Py_Identifier {
- struct _Py_Identifier *next;
const char* string;
- PyObject *object;
+ // Index in PyInterpreterState.unicode.ids.array. It is process-wide
+ // unique and must be initialized to -1.
+ Py_ssize_t index;
} _Py_Identifier;
-#define _Py_static_string_init(value) { .next = NULL, .string = value, .object = NULL }
+#define _Py_static_string_init(value) { .string = value, .index = -1 }
#define _Py_static_string(varname, value) static _Py_Identifier varname = _Py_static_string_init(value)
#define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname)
@@ -167,10 +168,13 @@ typedef struct {
objobjargproc mp_ass_subscript;
} PyMappingMethods;
+typedef PySendResult (*sendfunc)(PyObject *iter, PyObject *value, PyObject **result);
+
typedef struct {
unaryfunc am_await;
unaryfunc am_aiter;
unaryfunc am_anext;
+ sendfunc am_send;
} PyAsyncMethods;
typedef struct {
@@ -241,6 +245,7 @@ struct _typeobject {
struct PyMethodDef *tp_methods;
struct PyMemberDef *tp_members;
struct PyGetSetDef *tp_getset;
+ // Strong reference on a heap type, borrowed reference on a static type
struct _typeobject *tp_base;
PyObject *tp_dict;
descrgetfunc tp_descr_get;
@@ -296,6 +301,8 @@ PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, _Py_Identifier *);
PyAPI_FUNC(PyTypeObject *) _PyType_CalculateMetaclass(PyTypeObject *, PyObject *);
PyAPI_FUNC(PyObject *) _PyType_GetDocFromInternalDoc(const char *, const char *);
PyAPI_FUNC(PyObject *) _PyType_GetTextSignatureFromInternalDoc(const char *, const char *);
+struct PyModuleDef;
+PyAPI_FUNC(PyObject *) _PyType_GetModuleByDef(PyTypeObject *, struct PyModuleDef *);
struct _Py_Identifier;
PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
@@ -510,6 +517,8 @@ struct _ts;
/* Python 3.9 private API, invoked by the macros below. */
PyAPI_FUNC(int) _PyTrash_begin(struct _ts *tstate, PyObject *op);
PyAPI_FUNC(void) _PyTrash_end(struct _ts *tstate);
+/* Python 3.10 private API, invoked by the Py_TRASHCAN_BEGIN(). */
+PyAPI_FUNC(int) _PyTrash_cond(PyObject *op, destructor dealloc);
#define PyTrash_UNWIND_LEVEL 50
@@ -533,7 +542,7 @@ PyAPI_FUNC(void) _PyTrash_end(struct _ts *tstate);
#define Py_TRASHCAN_BEGIN(op, dealloc) \
Py_TRASHCAN_BEGIN_CONDITION(op, \
- Py_TYPE(op)->tp_dealloc == (destructor)(dealloc))
+ _PyTrash_cond(_PyObject_CAST(op), (destructor)dealloc))
/* For backwards compatibility, these macros enable the trashcan
* unconditionally */
diff --git a/Include/cpython/pylifecycle.h b/Include/cpython/pylifecycle.h
index f38ec5a4ae..13f7a26ba1 100644
--- a/Include/cpython/pylifecycle.h
+++ b/Include/cpython/pylifecycle.h
@@ -35,15 +35,11 @@ PyAPI_FUNC(int) Py_RunMain(void);
PyAPI_FUNC(void) _Py_NO_RETURN Py_ExitStatusException(PyStatus err);
-/* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level
- * exit functions.
- */
-PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(PyObject *), PyObject *);
-
/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
PyAPI_FUNC(void) _Py_RestoreSignals(void);
PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
+PyAPI_FUNC(int) _Py_FdIsInteractive(FILE *fp, PyObject *filename);
PyAPI_FUNC(void) _Py_SetProgramFullPath(const wchar_t *);
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 25522b4dbe..cfaee890f9 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -54,8 +54,7 @@ struct _ts {
/* Borrowed reference to the current frame (it can be NULL) */
PyFrameObject *frame;
int recursion_depth;
- char overflowed; /* The stack has overflowed. Allow 50 more calls
- to handle the runtime error. */
+ int recursion_headroom; /* Allow 50 more calls to handle any errors. */
int stackcheck_counter;
/* 'tracing' keeps track of the execution depth when tracing/profiling.
@@ -193,6 +192,36 @@ PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameFunc(
PyAPI_FUNC(const PyConfig*) _PyInterpreterState_GetConfig(PyInterpreterState *interp);
+/* Get a copy of the current interpreter configuration.
+
+ Return 0 on success. Raise an exception and return -1 on error.
+
+ The caller must initialize 'config', using PyConfig_InitPythonConfig()
+ for example.
+
+ Python must be preinitialized to call this method.
+ The caller must hold the GIL. */
+PyAPI_FUNC(int) _PyInterpreterState_GetConfigCopy(
+ struct PyConfig *config);
+
+/* Set the configuration of the current interpreter.
+
+ This function should be called during or just after the Python
+ initialization.
+
+ Update the sys module with the new configuration. If the sys module was
+ modified directly after the Python initialization, these changes are lost.
+
+ Some configuration like faulthandler or warnoptions can be updated in the
+ configuration, but don't reconfigure Python (don't enable/disable
+ faulthandler and don't reconfigure warnings filters).
+
+ Return 0 on success. Raise an exception and return -1 on error.
+
+ The configuration should come from _PyInterpreterState_GetConfigCopy(). */
+PyAPI_FUNC(int) _PyInterpreterState_SetConfig(
+ const struct PyConfig *config);
+
// Get the configuration of the currrent interpreter.
// The caller must hold the GIL.
PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
diff --git a/Include/cpython/pythonrun.h b/Include/cpython/pythonrun.h
new file mode 100644
index 0000000000..e396a674bc
--- /dev/null
+++ b/Include/cpython/pythonrun.h
@@ -0,0 +1,131 @@
+#ifndef Py_CPYTHON_PYTHONRUN_H
+# error "this header file must not be included directly"
+#endif
+
+PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
+PyAPI_FUNC(int) _PyRun_SimpleFileObject(
+ FILE *fp,
+ PyObject *filename,
+ int closeit,
+ PyCompilerFlags *flags);
+PyAPI_FUNC(int) PyRun_AnyFileExFlags(
+ FILE *fp,
+ const char *filename, /* decoded from the filesystem encoding */
+ int closeit,
+ PyCompilerFlags *flags);
+PyAPI_FUNC(int) _PyRun_AnyFileObject(
+ FILE *fp,
+ PyObject *filename,
+ int closeit,
+ PyCompilerFlags *flags);
+PyAPI_FUNC(int) PyRun_SimpleFileExFlags(
+ FILE *fp,
+ const char *filename, /* decoded from the filesystem encoding */
+ int closeit,
+ PyCompilerFlags *flags);
+PyAPI_FUNC(int) PyRun_InteractiveOneFlags(
+ FILE *fp,
+ const char *filename, /* decoded from the filesystem encoding */
+ PyCompilerFlags *flags);
+PyAPI_FUNC(int) PyRun_InteractiveOneObject(
+ FILE *fp,
+ PyObject *filename,
+ PyCompilerFlags *flags);
+PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(
+ FILE *fp,
+ const char *filename, /* decoded from the filesystem encoding */
+ PyCompilerFlags *flags);
+PyAPI_FUNC(int) _PyRun_InteractiveLoopObject(
+ FILE *fp,
+ PyObject *filename,
+ PyCompilerFlags *flags);
+
+
+PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
+ PyObject *, PyCompilerFlags *);
+
+PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
+ FILE *fp,
+ const char *filename, /* decoded from the filesystem encoding */
+ int start,
+ PyObject *globals,
+ PyObject *locals,
+ int closeit,
+ PyCompilerFlags *flags);
+
+
+PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
+ const char *str,
+ const char *filename, /* decoded from the filesystem encoding */
+ int start,
+ PyCompilerFlags *flags,
+ int optimize);
+PyAPI_FUNC(PyObject *) Py_CompileStringObject(
+ const char *str,
+ PyObject *filename, int start,
+ PyCompilerFlags *flags,
+ int optimize);
+
+#define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1)
+#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1)
+
+
+PyAPI_FUNC(const char *) _Py_SourceAsString(
+ PyObject *cmd,
+ const char *funcname,
+ const char *what,
+ PyCompilerFlags *cf,
+ PyObject **cmd_copy);
+
+PyAPI_FUNC(struct symtable *) Py_SymtableStringObject(
+ const char *str,
+ PyObject *filename,
+ int start);
+
+PyAPI_FUNC(struct symtable *) _Py_SymtableStringObjectFlags(
+ const char *str,
+ PyObject *filename,
+ int start,
+ PyCompilerFlags *flags);
+
+
+/* A function flavor is also exported by libpython. It is required when
+ libpython is accessed directly rather than using header files which defines
+ macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to
+ export functions in pythonXX.dll. */
+PyAPI_FUNC(PyObject *) PyRun_String(const char *str, int s, PyObject *g, PyObject *l);
+PyAPI_FUNC(int) PyRun_AnyFile(FILE *fp, const char *name);
+PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *fp, const char *name, int closeit);
+PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
+PyAPI_FUNC(int) PyRun_SimpleString(const char *s);
+PyAPI_FUNC(int) PyRun_SimpleFile(FILE *f, const char *p);
+PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *f, const char *p, int c);
+PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *f, const char *p);
+PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *f, const char *p);
+PyAPI_FUNC(PyObject *) PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l);
+PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c);
+PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags);
+
+/* Use macros for a bunch of old variants */
+#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
+#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
+#define PyRun_AnyFileEx(fp, name, closeit) \
+ PyRun_AnyFileExFlags(fp, name, closeit, NULL)
+#define PyRun_AnyFileFlags(fp, name, flags) \
+ PyRun_AnyFileExFlags(fp, name, 0, flags)
+#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
+#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
+#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
+#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
+#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
+#define PyRun_File(fp, p, s, g, l) \
+ PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
+#define PyRun_FileEx(fp, p, s, g, l, c) \
+ PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
+#define PyRun_FileFlags(fp, p, s, g, l, flags) \
+ PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
+
+
+/* Stuff with no proper home (yet) */
+PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
+PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
diff --git a/Include/cpython/tupleobject.h b/Include/cpython/tupleobject.h
index 51dcd4237b..7cada8848c 100644
--- a/Include/cpython/tupleobject.h
+++ b/Include/cpython/tupleobject.h
@@ -23,6 +23,6 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
#define PyTuple_GET_ITEM(op, i) (_PyTuple_CAST(op)->ob_item[i])
/* Macro, *only* to be used to fill in brand new tuples */
-#define PyTuple_SET_ITEM(op, i, v) (_PyTuple_CAST(op)->ob_item[i] = v)
+#define PyTuple_SET_ITEM(op, i, v) ((void)(_PyTuple_CAST(op)->ob_item[i] = v))
PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);
diff --git a/Include/internal/pycore_atomic.h b/Include/internal/pycore_atomic.h
index 1d5c562167..3d42e54464 100644
--- a/Include/internal/pycore_atomic.h
+++ b/Include/internal/pycore_atomic.h
@@ -11,8 +11,8 @@ extern "C" {
#include "dynamic_annotations.h" /* _Py_ANNOTATE_MEMORY_ORDER */
#include "pyconfig.h"
-#if defined(HAVE_STD_ATOMIC)
-#include <stdatomic.h>
+#ifdef HAVE_STD_ATOMIC
+# include <stdatomic.h>
#endif
@@ -62,7 +62,7 @@ typedef struct _Py_atomic_int {
#define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \
atomic_load_explicit(&((ATOMIC_VAL)->_value), ORDER)
-/* Use builtin atomic operations in GCC >= 4.7 */
+// Use builtin atomic operations in GCC >= 4.7 and clang
#elif defined(HAVE_BUILTIN_ATOMIC)
typedef enum _Py_memory_order {
diff --git a/Include/internal/pycore_atomic_funcs.h b/Include/internal/pycore_atomic_funcs.h
new file mode 100644
index 0000000000..a708789cea
--- /dev/null
+++ b/Include/internal/pycore_atomic_funcs.h
@@ -0,0 +1,94 @@
+/* Atomic functions: similar to pycore_atomic.h, but don't need
+ to declare variables as atomic.
+
+ Py_ssize_t type:
+
+ * value = _Py_atomic_size_get(&var)
+ * _Py_atomic_size_set(&var, value)
+
+ Use sequentially-consistent ordering (__ATOMIC_SEQ_CST memory order):
+ enforce total ordering with all other atomic functions.
+*/
+#ifndef Py_ATOMIC_FUNC_H
+#define Py_ATOMIC_FUNC_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef Py_BUILD_CORE
+# error "this header requires Py_BUILD_CORE define"
+#endif
+
+#if defined(_MSC_VER)
+# include <intrin.h> // _InterlockedExchange()
+#endif
+
+
+// Use builtin atomic operations in GCC >= 4.7 and clang
+#ifdef HAVE_BUILTIN_ATOMIC
+
+static inline Py_ssize_t _Py_atomic_size_get(Py_ssize_t *var)
+{
+ return __atomic_load_n(var, __ATOMIC_SEQ_CST);
+}
+
+static inline void _Py_atomic_size_set(Py_ssize_t *var, Py_ssize_t value)
+{
+ __atomic_store_n(var, value, __ATOMIC_SEQ_CST);
+}
+
+#elif defined(_MSC_VER)
+
+static inline Py_ssize_t _Py_atomic_size_get(Py_ssize_t *var)
+{
+#if SIZEOF_VOID_P == 8
+ Py_BUILD_ASSERT(sizeof(__int64) == sizeof(*var));
+ volatile __int64 *volatile_var = (volatile __int64 *)var;
+ __int64 old;
+ do {
+ old = *volatile_var;
+ } while(_InterlockedCompareExchange64(volatile_var, old, old) != old);
+#else
+ Py_BUILD_ASSERT(sizeof(long) == sizeof(*var));
+ volatile long *volatile_var = (volatile long *)var;
+ long old;
+ do {
+ old = *volatile_var;
+ } while(_InterlockedCompareExchange(volatile_var, old, old) != old);
+#endif
+ return old;
+}
+
+static inline void _Py_atomic_size_set(Py_ssize_t *var, Py_ssize_t value)
+{
+#if SIZEOF_VOID_P == 8
+ Py_BUILD_ASSERT(sizeof(__int64) == sizeof(*var));
+ volatile __int64 *volatile_var = (volatile __int64 *)var;
+ _InterlockedExchange64(volatile_var, value);
+#else
+ Py_BUILD_ASSERT(sizeof(long) == sizeof(*var));
+ volatile long *volatile_var = (volatile long *)var;
+ _InterlockedExchange(volatile_var, value);
+#endif
+}
+
+#else
+// Fallback implementation using volatile
+
+static inline Py_ssize_t _Py_atomic_size_get(Py_ssize_t *var)
+{
+ volatile Py_ssize_t *volatile_var = (volatile Py_ssize_t *)var;
+ return *volatile_var;
+}
+
+static inline void _Py_atomic_size_set(Py_ssize_t *var, Py_ssize_t value)
+{
+ volatile Py_ssize_t *volatile_var = (volatile Py_ssize_t *)var;
+ *volatile_var = value;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* Py_ATOMIC_FUNC_H */
diff --git a/Include/internal/pycore_bitutils.h b/Include/internal/pycore_bitutils.h
index 1602fc68d9..e4aa7a3d0d 100644
--- a/Include/internal/pycore_bitutils.h
+++ b/Include/internal/pycore_bitutils.h
@@ -17,12 +17,9 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif
-#if ((defined(__GNUC__) \
- && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))) \
- || (defined(__clang__) \
- && (__clang_major__ >= 4 \
- || (__clang_major__ == 3 && __clang_minor__ >= 2))))
- /* __builtin_bswap16() is available since GCC 4.8 and clang 3.2,
+#if defined(__GNUC__) \
+ && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))
+ /* __builtin_bswap16() is available since GCC 4.8,
__builtin_bswap32() is available since GCC 4.3,
__builtin_bswap64() is available since GCC 4.3. */
# define _PY_HAVE_BUILTIN_BSWAP
@@ -36,7 +33,7 @@ extern "C" {
static inline uint16_t
_Py_bswap16(uint16_t word)
{
-#ifdef _PY_HAVE_BUILTIN_BSWAP
+#if defined(_PY_HAVE_BUILTIN_BSWAP) || _Py__has_builtin(__builtin_bswap16)
return __builtin_bswap16(word);
#elif defined(_MSC_VER)
Py_BUILD_ASSERT(sizeof(word) == sizeof(unsigned short));
@@ -51,7 +48,7 @@ _Py_bswap16(uint16_t word)
static inline uint32_t
_Py_bswap32(uint32_t word)
{
-#ifdef _PY_HAVE_BUILTIN_BSWAP
+#if defined(_PY_HAVE_BUILTIN_BSWAP) || _Py__has_builtin(__builtin_bswap32)
return __builtin_bswap32(word);
#elif defined(_MSC_VER)
Py_BUILD_ASSERT(sizeof(word) == sizeof(unsigned long));
@@ -68,7 +65,7 @@ _Py_bswap32(uint32_t word)
static inline uint64_t
_Py_bswap64(uint64_t word)
{
-#ifdef _PY_HAVE_BUILTIN_BSWAP
+#if defined(_PY_HAVE_BUILTIN_BSWAP) || _Py__has_builtin(__builtin_bswap64)
return __builtin_bswap64(word);
#elif defined(_MSC_VER)
return _byteswap_uint64(word);
diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index bbb667ea32..38fd681f20 100644
--- a/Include/internal/pycore_ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -92,24 +92,8 @@ static inline int _Py_EnterRecursiveCall_inline(const char *where) {
#define Py_EnterRecursiveCall(where) _Py_EnterRecursiveCall_inline(where)
-/* Compute the "lower-water mark" for a recursion limit. When
- * Py_LeaveRecursiveCall() is called with a recursion depth below this mark,
- * the overflowed flag is reset to 0. */
-static inline int _Py_RecursionLimitLowerWaterMark(int limit) {
- if (limit > 200) {
- return (limit - 50);
- }
- else {
- return (3 * (limit >> 2));
- }
-}
-
static inline void _Py_LeaveRecursiveCall(PyThreadState *tstate) {
tstate->recursion_depth--;
- int limit = tstate->interp->ceval.recursion_limit;
- if (tstate->recursion_depth < _Py_RecursionLimitLowerWaterMark(limit)) {
- tstate->overflowed = 0;
- }
}
static inline void _Py_LeaveRecursiveCall_inline(void) {
diff --git a/Include/internal/pycore_format.h b/Include/internal/pycore_format.h
new file mode 100644
index 0000000000..1b8d57539c
--- /dev/null
+++ b/Include/internal/pycore_format.h
@@ -0,0 +1,27 @@
+#ifndef Py_INTERNAL_FORMAT_H
+#define Py_INTERNAL_FORMAT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef Py_BUILD_CORE
+# error "this header requires Py_BUILD_CORE define"
+#endif
+
+/* Format codes
+ * F_LJUST '-'
+ * F_SIGN '+'
+ * F_BLANK ' '
+ * F_ALT '#'
+ * F_ZERO '0'
+ */
+#define F_LJUST (1<<0)
+#define F_SIGN (1<<1)
+#define F_BLANK (1<<2)
+#define F_ALT (1<<3)
+#define F_ZERO (1<<4)
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_INTERNAL_FORMAT_H */
diff --git a/Include/internal/pycore_import.h b/Include/internal/pycore_import.h
index 35a67abeba..fd9fa5ab23 100644
--- a/Include/internal/pycore_import.h
+++ b/Include/internal/pycore_import.h
@@ -13,7 +13,7 @@ PyAPI_FUNC(PyObject *) _PyImport_FindBuiltin(
#ifdef HAVE_FORK
extern PyStatus _PyImport_ReInitLock(void);
#endif
-extern void _PyImport_Cleanup(PyThreadState *tstate);
+extern PyObject* _PyImport_BootstrapImp(PyThreadState *tstate);
#ifdef __cplusplus
}
diff --git a/Include/internal/pycore_initconfig.h b/Include/internal/pycore_initconfig.h
index 457a005860..28cd57030e 100644
--- a/Include/internal/pycore_initconfig.h
+++ b/Include/internal/pycore_initconfig.h
@@ -44,6 +44,8 @@ struct pyruntimestate;
#define _PyStatus_UPDATE_FUNC(err) \
do { err.func = _PyStatus_GET_FUNC(); } while (0)
+PyObject* _PyErr_SetFromPyStatus(PyStatus status);
+
/* --- PyWideStringList ------------------------------------------------ */
#define _PyWideStringList_INIT (PyWideStringList){.length = 0, .items = NULL}
@@ -149,13 +151,19 @@ PyAPI_FUNC(void) _PyConfig_InitCompatConfig(PyConfig *config);
extern PyStatus _PyConfig_Copy(
PyConfig *config,
const PyConfig *config2);
-extern PyStatus _PyConfig_InitPathConfig(PyConfig *config);
+extern PyStatus _PyConfig_InitPathConfig(
+ PyConfig *config,
+ int compute_path_config);
+extern PyStatus _PyConfig_Read(PyConfig *config, int compute_path_config);
extern PyStatus _PyConfig_Write(const PyConfig *config,
struct pyruntimestate *runtime);
extern PyStatus _PyConfig_SetPyArgv(
PyConfig *config,
const _PyArgv *args);
+PyAPI_FUNC(PyObject*) _PyConfig_AsDict(const PyConfig *config);
+PyAPI_FUNC(int) _PyConfig_FromDict(PyConfig *config, PyObject *dict);
+
/* --- Function used for testing ---------------------------------- */
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index 9923b6b03d..58b1126712 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -64,6 +64,11 @@ struct _Py_bytes_state {
PyBytesObject *characters[256];
};
+struct _Py_unicode_ids {
+ Py_ssize_t size;
+ PyObject **array;
+};
+
struct _Py_unicode_state {
// The empty Unicode object is a singleton to improve performance.
PyObject *empty_string;
@@ -71,6 +76,19 @@ struct _Py_unicode_state {
shared as well. */
PyObject *latin1[256];
struct _Py_unicode_fs_codec fs_codec;
+
+ /* This dictionary holds all interned unicode strings. Note that references
+ to strings in this dictionary are *not* counted in the string's ob_refcnt.
+ When the interned string reaches a refcnt of 0 the string deallocation
+ function will delete the reference from this dictionary.
+
+ Another way to look at this is that to say that the actual reference
+ count of a string is: s->ob_refcnt + (s->state ? 2 : 0)
+ */
+ PyObject *interned;
+
+ // Unicode identifiers (_Py_Identifier): see _PyUnicode_FromId()
+ struct _Py_unicode_ids ids;
};
struct _Py_float_state {
@@ -159,6 +177,41 @@ struct _Py_exc_state {
};
+// atexit state
+typedef struct {
+ PyObject *func;
+ PyObject *args;
+ PyObject *kwargs;
+} atexit_callback;
+
+struct atexit_state {
+ atexit_callback **callbacks;
+ int ncallbacks;
+ int callback_len;
+};
+
+
+// Type attribute lookup cache: speed up attribute and method lookups,
+// see _PyType_Lookup().
+struct type_cache_entry {
+ unsigned int version; // initialized from type->tp_version_tag
+ PyObject *name; // reference to exactly a str or None
+ PyObject *value; // borrowed reference or NULL
+};
+
+#define MCACHE_SIZE_EXP 12
+#define MCACHE_STATS 0
+
+struct type_cache {
+ struct type_cache_entry hashtable[1 << MCACHE_SIZE_EXP];
+#if MCACHE_STATS
+ size_t hits;
+ size_t misses;
+ size_t collisions;
+#endif
+};
+
+
/* interpreter state */
#define _PY_NSMALLPOSINTS 257
@@ -190,10 +243,14 @@ struct _is {
struct _ceval_state ceval;
struct _gc_runtime_state gc;
+ // sys.modules dictionary
PyObject *modules;
PyObject *modules_by_index;
+ // Dictionary of the sys module
PyObject *sysdict;
+ // Dictionary of the builtins module
PyObject *builtins;
+ // importlib module
PyObject *importlib;
/* Used in Modules/_threadmodule.c. */
@@ -218,7 +275,7 @@ struct _is {
PyObject *builtins_copy;
PyObject *import_func;
- /* Initialized to PyEval_EvalFrameDefault(). */
+ // Initialized to _PyEval_EvalFrameDefault().
_PyFrameEvalFunction eval_frame;
Py_ssize_t co_extra_user_count;
@@ -229,13 +286,11 @@ struct _is {
PyObject *after_forkers_parent;
PyObject *after_forkers_child;
#endif
- /* AtExit module */
- void (*pyexitfunc)(PyObject *);
- PyObject *pyexitmodule;
uint64_t tstate_next_unique_id;
struct _warnings_runtime_state warnings;
+ struct atexit_state atexit;
PyObject *audit_hooks;
@@ -261,15 +316,10 @@ struct _is {
struct _Py_exc_state exc_state;
struct ast_state ast;
+ struct type_cache type_cache;
};
-/* Used by _PyImport_Cleanup() */
extern void _PyInterpreterState_ClearModules(PyInterpreterState *interp);
-
-extern PyStatus _PyInterpreterState_SetConfig(
- PyInterpreterState *interp,
- const PyConfig *config);
-
extern void _PyInterpreterState_Clear(PyThreadState *tstate);
diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h
index edd0031c3e..3975765a46 100644
--- a/Include/internal/pycore_object.h
+++ b/Include/internal/pycore_object.h
@@ -27,6 +27,9 @@ _PyType_HasFeature(PyTypeObject *type, unsigned long feature) {
return ((type->tp_flags & feature) != 0);
}
+extern void _PyType_InitCache(PyInterpreterState *interp);
+
+
/* Inline functions trading binary compatibility for speed:
_PyObject_Init() is the fast version of PyObject_Init(), and
_PyObject_InitVar() is the fast version of PyObject_InitVar().
diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h
index 6d84e37232..c9e6947ae6 100644
--- a/Include/internal/pycore_pylifecycle.h
+++ b/Include/internal/pycore_pylifecycle.h
@@ -44,11 +44,10 @@ extern PyStatus _PySys_Create(
PyObject **sysmod_p);
extern PyStatus _PySys_ReadPreinitWarnOptions(PyWideStringList *options);
extern PyStatus _PySys_ReadPreinitXOptions(PyConfig *config);
-extern int _PySys_InitMain(PyThreadState *tstate);
+extern int _PySys_UpdateConfig(PyThreadState *tstate);
extern PyStatus _PyExc_Init(PyThreadState *tstate);
extern PyStatus _PyErr_Init(void);
extern PyStatus _PyBuiltins_AddExceptions(PyObject * bltinmod);
-extern PyStatus _PyImportHooks_Init(PyThreadState *tstate);
extern int _PyFloat_Init(void);
extern PyStatus _Py_HashRandomization_Init(const PyConfig *);
@@ -56,6 +55,7 @@ extern PyStatus _PyTypes_Init(void);
extern PyStatus _PyTypes_InitSlotDefs(void);
extern PyStatus _PyImportZip_Init(PyThreadState *tstate);
extern PyStatus _PyGC_Init(PyThreadState *tstate);
+extern PyStatus _PyAtExit_Init(PyThreadState *tstate);
/* Various internal finalizers */
@@ -69,13 +69,14 @@ extern void _PyFloat_Fini(PyThreadState *tstate);
extern void _PySlice_Fini(PyThreadState *tstate);
extern void _PyAsyncGen_Fini(PyThreadState *tstate);
-extern void PyOS_FiniInterrupts(void);
+extern int _PySignal_Init(int install_signal_handlers);
+extern void _PySignal_Fini(void);
extern void _PyExc_Fini(PyThreadState *tstate);
extern void _PyImport_Fini(void);
extern void _PyImport_Fini2(void);
extern void _PyGC_Fini(PyThreadState *tstate);
-extern void _PyType_Fini(void);
+extern void _PyType_Fini(PyThreadState *tstate);
extern void _Py_HashRandomization_Fini(void);
extern void _PyUnicode_Fini(PyThreadState *tstate);
extern void _PyUnicode_ClearInterned(PyThreadState *tstate);
@@ -84,7 +85,8 @@ extern void _PyFaulthandler_Fini(void);
extern void _PyHash_Fini(void);
extern void _PyTraceMalloc_Fini(void);
extern void _PyWarnings_Fini(PyInterpreterState *interp);
-extern void _PyAST_Fini(PyThreadState *tstate);
+extern void _PyAST_Fini(PyInterpreterState *interp);
+extern void _PyAtExit_Fini(PyInterpreterState *interp);
extern PyStatus _PyGILState_Init(PyThreadState *tstate);
extern void _PyGILState_Fini(PyThreadState *tstate);
@@ -109,6 +111,8 @@ PyAPI_FUNC(void) _PyErr_Display(PyObject *file, PyObject *exception,
PyAPI_FUNC(void) _PyThreadState_DeleteCurrent(PyThreadState *tstate);
+extern void _PyAtExit_Call(PyThreadState *tstate);
+
#ifdef __cplusplus
}
#endif
diff --git a/Include/internal/pycore_runtime.h b/Include/internal/pycore_runtime.h
index 3a01d64e63..8c54abbb06 100644
--- a/Include/internal/pycore_runtime.h
+++ b/Include/internal/pycore_runtime.h
@@ -49,6 +49,11 @@ typedef struct _Py_AuditHookEntry {
void *userData;
} _Py_AuditHookEntry;
+struct _Py_unicode_runtime_ids {
+ PyThread_type_lock lock;
+ Py_ssize_t next_index;
+};
+
/* Full Python runtime state */
typedef struct pyruntimestate {
@@ -106,6 +111,8 @@ typedef struct pyruntimestate {
void *open_code_userdata;
_Py_AuditHookEntry *audit_hook_head;
+ struct _Py_unicode_runtime_ids unicode_ids;
+
// XXX Consolidate globals found via the check-c-globals script.
} _PyRuntimeState;
diff --git a/Include/internal/pycore_unionobject.h b/Include/internal/pycore_unionobject.h
index fa8ba6ed94..4d82b6fbea 100644
--- a/Include/internal/pycore_unionobject.h
+++ b/Include/internal/pycore_unionobject.h
@@ -10,6 +10,7 @@ extern "C" {
PyAPI_FUNC(PyObject *) _Py_Union(PyObject *args);
PyAPI_DATA(PyTypeObject) _Py_UnionType;
+PyAPI_FUNC(PyObject *) _Py_union_type_or(PyObject* self, PyObject* param);
#ifdef __cplusplus
}
diff --git a/Include/internal/pycore_warnings.h b/Include/internal/pycore_warnings.h
index cafe305edb..2a473b860c 100644
--- a/Include/internal/pycore_warnings.h
+++ b/Include/internal/pycore_warnings.h
@@ -17,7 +17,7 @@ struct _warnings_runtime_state {
long filters_version;
};
-extern PyStatus _PyWarnings_InitState(PyThreadState *tstate);
+extern int _PyWarnings_InitState(PyThreadState *tstate);
#ifdef __cplusplus
}
diff --git a/Include/intrcheck.h b/Include/intrcheck.h
index 88f2a7076c..b8cc656016 100644
--- a/Include/intrcheck.h
+++ b/Include/intrcheck.h
@@ -5,7 +5,6 @@ extern "C" {
#endif
PyAPI_FUNC(int) PyOS_InterruptOccurred(void);
-PyAPI_FUNC(void) PyOS_InitInterrupts(void);
#ifdef HAVE_FORK
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
PyAPI_FUNC(void) PyOS_BeforeFork(void);
diff --git a/Include/methodobject.h b/Include/methodobject.h
index 12e049b404..5d06d7691b 100644
--- a/Include/methodobject.h
+++ b/Include/methodobject.h
@@ -73,7 +73,7 @@ PyAPI_FUNC(PyObject *) PyCMethod_New(PyMethodDef *, PyObject *,
#define METH_COEXIST 0x0040
-#ifndef Py_LIMITED_API
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03100000
#define METH_FASTCALL 0x0080
#endif
diff --git a/Include/modsupport.h b/Include/modsupport.h
index 4c4aab65ba..f009d586bf 100644
--- a/Include/modsupport.h
+++ b/Include/modsupport.h
@@ -136,7 +136,15 @@ PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
void _PyArg_Fini(void);
#endif /* Py_LIMITED_API */
-PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *);
+// Add an attribute with name 'name' and value 'obj' to the module 'mod.
+// On success, return 0 on success.
+// On error, raise an exception and return -1.
+PyAPI_FUNC(int) PyModule_AddObjectRef(PyObject *mod, const char *name, PyObject *value);
+
+// Similar to PyModule_AddObjectRef() but steal a reference to 'obj'
+// (Py_DECREF(obj)) on success (if it returns 0).
+PyAPI_FUNC(int) PyModule_AddObject(PyObject *mod, const char *, PyObject *value);
+
PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
diff --git a/Include/object.h b/Include/object.h
index 6ee4ee7848..8d0039428e 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -128,16 +128,11 @@ static inline Py_ssize_t _Py_REFCNT(const PyObject *ob) {
#define Py_REFCNT(ob) _Py_REFCNT(_PyObject_CAST_CONST(ob))
-static inline Py_ssize_t _Py_SIZE(const PyVarObject *ob) {
- return ob->ob_size;
-}
-#define Py_SIZE(ob) _Py_SIZE(_PyVarObject_CAST_CONST(ob))
-
+// bpo-39573: The Py_SET_TYPE() function must be used to set an object type.
+#define Py_TYPE(ob) (_PyObject_CAST(ob)->ob_type)
-static inline PyTypeObject* _Py_TYPE(const PyObject *ob) {
- return ob->ob_type;
-}
-#define Py_TYPE(ob) _Py_TYPE(_PyObject_CAST_CONST(ob))
+// bpo-39573: The Py_SET_SIZE() function must be used to set an object size.
+#define Py_SIZE(ob) (_PyVarObject_CAST(ob)->ob_size)
static inline int _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) {
@@ -356,6 +351,11 @@ given type object has a specified feature.
/* Type is abstract and cannot be instantiated */
#define Py_TPFLAGS_IS_ABSTRACT (1UL << 20)
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
+/* Type has am_send entry in tp_as_async slot */
+#define Py_TPFLAGS_HAVE_AM_SEND (1UL << 21)
+#endif
+
/* These flags are used to determine if a type is a subclass. */
#define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24)
#define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25)
@@ -426,7 +426,6 @@ static inline void _Py_INCREF(PyObject *op)
#endif
op->ob_refcnt++;
}
-
#define Py_INCREF(op) _Py_INCREF(_PyObject_CAST(op))
static inline void _Py_DECREF(
@@ -449,7 +448,6 @@ static inline void _Py_DECREF(
_Py_Dealloc(op);
}
}
-
#ifdef Py_REF_DEBUG
# define Py_DECREF(op) _Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op))
#else
@@ -526,6 +524,32 @@ they can have object code that is not dependent on Python compilation flags.
PyAPI_FUNC(void) Py_IncRef(PyObject *);
PyAPI_FUNC(void) Py_DecRef(PyObject *);
+// Create a new strong reference to an object:
+// increment the reference count of the object and return the object.
+PyAPI_FUNC(PyObject*) Py_NewRef(PyObject *obj);
+
+// Similar to Py_NewRef(), but the object can be NULL.
+PyAPI_FUNC(PyObject*) Py_XNewRef(PyObject *obj);
+
+static inline PyObject* _Py_NewRef(PyObject *obj)
+{
+ Py_INCREF(obj);
+ return obj;
+}
+
+static inline PyObject* _Py_XNewRef(PyObject *obj)
+{
+ Py_XINCREF(obj);
+ return obj;
+}
+
+// Py_NewRef() and Py_XNewRef() are exported as functions for the stable ABI.
+// Names overriden with macros by static inline functions for best
+// performances.
+#define Py_NewRef(obj) _Py_NewRef(_PyObject_CAST(obj))
+#define Py_XNewRef(obj) _Py_XNewRef(_PyObject_CAST(obj))
+
+
/*
_Py_NoneStruct is an object of undefined type which can be used in contexts
where NULL (nil) is not suitable (since NULL often means 'error').
@@ -536,7 +560,7 @@ PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */
#define Py_None (&_Py_NoneStruct)
/* Macro for returning Py_None from a function */
-#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#define Py_RETURN_NONE return Py_NewRef(Py_None)
/*
Py_NotImplemented is a singleton used to signal that an operation is
@@ -546,8 +570,7 @@ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
#define Py_NotImplemented (&_Py_NotImplementedStruct)
/* Macro for returning Py_NotImplemented from a function */
-#define Py_RETURN_NOTIMPLEMENTED \
- return Py_INCREF(Py_NotImplemented), Py_NotImplemented
+#define Py_RETURN_NOTIMPLEMENTED return Py_NewRef(Py_NotImplemented)
/* Rich comparison opcodes */
#define Py_LT 0
@@ -557,6 +580,15 @@ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
#define Py_GT 4
#define Py_GE 5
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
+/* Result of calling PyIter_Send */
+typedef enum {
+ PYGEN_RETURN = 0,
+ PYGEN_ERROR = -1,
+ PYGEN_NEXT = 1,
+} PySendResult;
+#endif
+
/*
* Macro for implementing rich comparisons
*
diff --git a/Include/objimpl.h b/Include/objimpl.h
index af537175bf..1408d051ba 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -38,7 +38,7 @@ Functions and macros for modules that implement new object types.
object with room for n items. In addition to the refcount and type pointer
fields, this also fills in the ob_size field.
- - PyObject_Del(op) releases the memory allocated for an object. It does not
+ - PyObject_Free(op) releases the memory allocated for an object. It does not
run a destructor -- it only frees the memory. PyObject_Free is identical.
- PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) don't
@@ -102,7 +102,9 @@ PyAPI_FUNC(void *) PyObject_Realloc(void *ptr, size_t new_size);
PyAPI_FUNC(void) PyObject_Free(void *ptr);
-/* Macros */
+// Deprecated aliases only kept for backward compatibility.
+// PyObject_Del and PyObject_DEL are defined with no parameter to be able to
+// use them as function pointers (ex: tp_free = PyObject_Del).
#define PyObject_MALLOC PyObject_Malloc
#define PyObject_REALLOC PyObject_Realloc
#define PyObject_FREE PyObject_Free
@@ -138,8 +140,8 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
#define PyObject_NewVar(type, typeobj, n) \
( (type *) _PyObject_NewVar((typeobj), (n)) )
-// Alias to PyObject_New(). In Python 3.8, PyObject_NEW() called directly
-// PyObject_MALLOC() with _PyObject_VAR_SIZE().
+// Alias to PyObject_NewVar(). In Python 3.8, PyObject_NEW_VAR() called
+// directly PyObject_MALLOC() with _PyObject_VAR_SIZE().
#define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar(type, typeobj, n)
diff --git a/Include/opcode.h b/Include/opcode.h
index 420c87aa0f..998a5ce492 100644
--- a/Include/opcode.h
+++ b/Include/opcode.h
@@ -30,7 +30,6 @@ extern "C" {
#define BINARY_TRUE_DIVIDE 27
#define INPLACE_FLOOR_DIVIDE 28
#define INPLACE_TRUE_DIVIDE 29
-#define RERAISE 48
#define WITH_EXCEPT_START 49
#define GET_AITER 50
#define GET_ANEXT 51
@@ -96,6 +95,7 @@ extern "C" {
#define LOAD_GLOBAL 116
#define IS_OP 117
#define CONTAINS_OP 118
+#define RERAISE 119
#define JUMP_IF_NOT_EXC_MATCH 121
#define SETUP_FINALLY 122
#define LOAD_FAST 124
diff --git a/Include/patchlevel.h b/Include/patchlevel.h
index eeb23af976..1af225ca09 100644
--- a/Include/patchlevel.h
+++ b/Include/patchlevel.h
@@ -20,10 +20,10 @@
#define PY_MINOR_VERSION 10
#define PY_MICRO_VERSION 0
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
-#define PY_RELEASE_SERIAL 1
+#define PY_RELEASE_SERIAL 3
/* Version as a string */
-#define PY_VERSION "3.10.0a1+"
+#define PY_VERSION "3.10.0a3+"
/*--end constants--*/
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h
index c5368b3c5e..783fcb455e 100644
--- a/Include/pylifecycle.h
+++ b/Include/pylifecycle.h
@@ -32,6 +32,8 @@ PyAPI_FUNC(void) _Py_NO_RETURN Py_Exit(int);
/* Bootstrap __main__ (defined in Modules/main.c) */
PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv);
+PyAPI_FUNC(int) Py_FrozenMain(int argc, char **argv);
+
PyAPI_FUNC(int) Py_BytesMain(int argc, char **argv);
/* In pathconfig.c */
diff --git a/Include/pymem.h b/Include/pymem.h
index 607feb9484..92cd536958 100644
--- a/Include/pymem.h
+++ b/Include/pymem.h
@@ -53,18 +53,6 @@ PyAPI_FUNC(void *) PyMem_Malloc(size_t size);
PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size);
PyAPI_FUNC(void) PyMem_Free(void *ptr);
-/* Macros. */
-
-/* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL
- for malloc(0), which would be treated as an error. Some platforms
- would return a pointer with no memory behind it, which would break
- pymalloc. To solve these problems, allocate an extra byte. */
-/* Returns NULL to indicate error if a negative size or size larger than
- Py_ssize_t can represent is supplied. Helps prevents security holes. */
-#define PyMem_MALLOC(n) PyMem_Malloc(n)
-#define PyMem_REALLOC(p, n) PyMem_Realloc(p, n)
-#define PyMem_FREE(p) PyMem_Free(p)
-
/*
* Type-oriented memory interface
* ==============================
@@ -78,9 +66,6 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr);
#define PyMem_New(type, n) \
( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
( (type *) PyMem_Malloc((n) * sizeof(type)) ) )
-#define PyMem_NEW(type, n) \
- ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
- ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) )
/*
* The value of (p) is always clobbered by this macro regardless of success.
@@ -91,15 +76,18 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr);
#define PyMem_Resize(p, type, n) \
( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
(type *) PyMem_Realloc((p), (n) * sizeof(type)) )
-#define PyMem_RESIZE(p, type, n) \
- ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
- (type *) PyMem_REALLOC((p), (n) * sizeof(type)) )
-/* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used
- * anymore. They're just confusing aliases for PyMem_{Free,FREE} now.
- */
-#define PyMem_Del PyMem_Free
-#define PyMem_DEL PyMem_FREE
+
+// Deprecated aliases only kept for backward compatibility.
+// PyMem_Del and PyMem_DEL are defined with no parameter to be able to use
+// them as function pointers (ex: dealloc = PyMem_Del).
+#define PyMem_MALLOC(n) PyMem_Malloc(n)
+#define PyMem_NEW(type, n) PyMem_New(type, n)
+#define PyMem_REALLOC(p, n) PyMem_Realloc(p, n)
+#define PyMem_RESIZE(p, type, n) PyMem_Resize(p, type, n)
+#define PyMem_FREE(p) PyMem_Free(p)
+#define PyMem_Del PyMem_Free
+#define PyMem_DEL PyMem_Free
#ifndef Py_LIMITED_API
diff --git a/Include/pyport.h b/Include/pyport.h
index 79fc7c4a52..6687849d84 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -869,4 +869,16 @@ extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler;
# define _Py_NO_RETURN
#endif
+
+// Preprocessor check for a builtin preprocessor function. Always return 0
+// if __has_builtin() macro is not defined.
+//
+// __has_builtin() is available on clang and GCC 10.
+#ifdef __has_builtin
+# define _Py__has_builtin(x) __has_builtin(x)
+#else
+# define _Py__has_builtin(x) 0
+#endif
+
+
#endif /* Py_PYPORT_H */
diff --git a/Include/pythonrun.h b/Include/pythonrun.h
index d43734b5a1..cc6c745a4d 100644
--- a/Include/pythonrun.h
+++ b/Include/pythonrun.h
@@ -7,137 +7,21 @@
extern "C" {
#endif
-#ifndef Py_LIMITED_API
-PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
-PyAPI_FUNC(int) PyRun_AnyFileExFlags(
- FILE *fp,
- const char *filename, /* decoded from the filesystem encoding */
- int closeit,
- PyCompilerFlags *flags);
-PyAPI_FUNC(int) PyRun_SimpleFileExFlags(
- FILE *fp,
- const char *filename, /* decoded from the filesystem encoding */
- int closeit,
- PyCompilerFlags *flags);
-PyAPI_FUNC(int) PyRun_InteractiveOneFlags(
- FILE *fp,
- const char *filename, /* decoded from the filesystem encoding */
- PyCompilerFlags *flags);
-PyAPI_FUNC(int) PyRun_InteractiveOneObject(
- FILE *fp,
- PyObject *filename,
- PyCompilerFlags *flags);
-PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(
- FILE *fp,
- const char *filename, /* decoded from the filesystem encoding */
- PyCompilerFlags *flags);
-
-
-PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
- PyObject *, PyCompilerFlags *);
-
-PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
- FILE *fp,
- const char *filename, /* decoded from the filesystem encoding */
- int start,
- PyObject *globals,
- PyObject *locals,
- int closeit,
- PyCompilerFlags *flags);
-#endif
-
-#ifdef Py_LIMITED_API
PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
-#else
-#define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1)
-#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1)
-PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
- const char *str,
- const char *filename, /* decoded from the filesystem encoding */
- int start,
- PyCompilerFlags *flags,
- int optimize);
-PyAPI_FUNC(PyObject *) Py_CompileStringObject(
- const char *str,
- PyObject *filename, int start,
- PyCompilerFlags *flags,
- int optimize);
-#endif
+
PyAPI_FUNC(struct symtable *) Py_SymtableString(
const char *str,
const char *filename, /* decoded from the filesystem encoding */
int start);
-#ifndef Py_LIMITED_API
-PyAPI_FUNC(const char *) _Py_SourceAsString(
- PyObject *cmd,
- const char *funcname,
- const char *what,
- PyCompilerFlags *cf,
- PyObject **cmd_copy);
-
-PyAPI_FUNC(struct symtable *) Py_SymtableStringObject(
- const char *str,
- PyObject *filename,
- int start);
-
-PyAPI_FUNC(struct symtable *) _Py_SymtableStringObjectFlags(
- const char *str,
- PyObject *filename,
- int start,
- PyCompilerFlags *flags);
-#endif
PyAPI_FUNC(void) PyErr_Print(void);
PyAPI_FUNC(void) PyErr_PrintEx(int);
PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
-#ifndef Py_LIMITED_API
-/* A function flavor is also exported by libpython. It is required when
- libpython is accessed directly rather than using header files which defines
- macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to
- export functions in pythonXX.dll. */
-PyAPI_FUNC(PyObject *) PyRun_String(const char *str, int s, PyObject *g, PyObject *l);
-PyAPI_FUNC(int) PyRun_AnyFile(FILE *fp, const char *name);
-PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *fp, const char *name, int closeit);
-PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
-PyAPI_FUNC(int) PyRun_SimpleString(const char *s);
-PyAPI_FUNC(int) PyRun_SimpleFile(FILE *f, const char *p);
-PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *f, const char *p, int c);
-PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *f, const char *p);
-PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *f, const char *p);
-PyAPI_FUNC(PyObject *) PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l);
-PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c);
-PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags);
-
-/* Use macros for a bunch of old variants */
-#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
-#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
-#define PyRun_AnyFileEx(fp, name, closeit) \
- PyRun_AnyFileExFlags(fp, name, closeit, NULL)
-#define PyRun_AnyFileFlags(fp, name, flags) \
- PyRun_AnyFileExFlags(fp, name, 0, flags)
-#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
-#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
-#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
-#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
-#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
-#define PyRun_File(fp, p, s, g, l) \
- PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
-#define PyRun_FileEx(fp, p, s, g, l, c) \
- PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
-#define PyRun_FileFlags(fp, p, s, g, l, flags) \
- PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
-#endif
/* Stuff with no proper home (yet) */
-#ifndef Py_LIMITED_API
-PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
-#endif
PyAPI_DATA(int) (*PyOS_InputHook)(void);
PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
-#ifndef Py_LIMITED_API
-PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
-#endif
/* Stack size, in "pointers" (so we get extra safety margins
on 64-bit platforms). On a 32-bit platform, this translates
@@ -154,6 +38,12 @@ PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
PyAPI_FUNC(int) PyOS_CheckStack(void);
#endif
+#ifndef Py_LIMITED_API
+# define Py_CPYTHON_PYTHONRUN_H
+# include "cpython/pythonrun.h"
+# undef Py_CPYTHON_PYTHONRUN_H
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/Include/pytime.h b/Include/pytime.h
index bdda1da2e6..944170f7d0 100644
--- a/Include/pytime.h
+++ b/Include/pytime.h
@@ -164,22 +164,6 @@ PyAPI_FUNC(_PyTime_t) _PyTime_MulDiv(_PyTime_t ticks,
_PyTime_t mul,
_PyTime_t div);
-/* Get the current time from the system clock.
-
- The function cannot fail. _PyTime_Init() ensures that the system clock
- works. */
-PyAPI_FUNC(_PyTime_t) _PyTime_GetSystemClock(void);
-
-/* Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
- The clock is not affected by system clock updates. The reference point of
- the returned value is undefined, so that only the difference between the
- results of consecutive calls is valid.
-
- The function cannot fail. _PyTime_Init() ensures that a monotonic clock
- is available and works. */
-PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void);
-
-
/* Structure used by time.get_clock_info() */
typedef struct {
const char *implementation;
@@ -189,8 +173,17 @@ typedef struct {
} _Py_clock_info_t;
/* Get the current time from the system clock.
- * Fill clock information if info is not NULL.
- * Raise an exception and return -1 on error, return 0 on success.
+
+ If the internal clock fails, silently ignore the error and return 0.
+ On integer overflow, silently ignore the overflow and truncated the clock to
+ _PyTime_MIN or _PyTime_MAX.
+
+ Use _PyTime_GetSystemClockWithInfo() to check for failure. */
+PyAPI_FUNC(_PyTime_t) _PyTime_GetSystemClock(void);
+
+/* Get the current time from the system clock.
+ * On success, set *t and *info (if not NULL), and return 0.
+ * On error, raise an exception and return -1.
*/
PyAPI_FUNC(int) _PyTime_GetSystemClockWithInfo(
_PyTime_t *t,
@@ -201,6 +194,18 @@ PyAPI_FUNC(int) _PyTime_GetSystemClockWithInfo(
the returned value is undefined, so that only the difference between the
results of consecutive calls is valid.
+ If the internal clock fails, silently ignore the error and return 0.
+ On integer overflow, silently ignore the overflow and truncated the clock to
+ _PyTime_MIN or _PyTime_MAX.
+
+ Use _PyTime_GetMonotonicClockWithInfo() to check for failure. */
+PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void);
+
+/* Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
+ The clock is not affected by system clock updates. The reference point of
+ the returned value is undefined, so that only the difference between the
+ results of consecutive calls is valid.
+
Fill info (if set) with information of the function used to get the time.
Return 0 on success, raise an exception and return -1 on error. */
@@ -209,10 +214,6 @@ PyAPI_FUNC(int) _PyTime_GetMonotonicClockWithInfo(
_Py_clock_info_t *info);
-/* Initialize time.
- Return 0 on success, raise an exception and return -1 on error. */
-PyAPI_FUNC(int) _PyTime_Init(void);
-
/* Converts a timestamp to the Gregorian time, using the local time zone.
Return 0 on success, raise an exception and return -1 on error. */
PyAPI_FUNC(int) _PyTime_localtime(time_t t, struct tm *tm);
@@ -224,8 +225,11 @@ PyAPI_FUNC(int) _PyTime_gmtime(time_t t, struct tm *tm);
/* Get the performance counter: clock with the highest available resolution to
measure a short duration.
- The function cannot fail. _PyTime_Init() ensures that the system clock
- works. */
+ If the internal clock fails, silently ignore the error and return 0.
+ On integer overflow, silently ignore the overflow and truncated the clock to
+ _PyTime_MIN or _PyTime_MAX.
+
+ Use _PyTime_GetPerfCounterWithInfo() to check for failure. */
PyAPI_FUNC(_PyTime_t) _PyTime_GetPerfCounter(void);
/* Get the performance counter: clock with the highest available resolution to
diff --git a/Include/typeslots.h b/Include/typeslots.h
index 64f6fff514..5800d0158b 100644
--- a/Include/typeslots.h
+++ b/Include/typeslots.h
@@ -88,3 +88,7 @@
/* New in 3.5 */
#define Py_tp_finalize 80
#endif
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
+/* New in 3.10 */
+#define Py_am_send 81
+#endif
diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py
index 36cd993000..87302ac76d 100644
--- a/Lib/_collections_abc.py
+++ b/Lib/_collections_abc.py
@@ -10,6 +10,10 @@ from abc import ABCMeta, abstractmethod
import sys
GenericAlias = type(list[int])
+EllipsisType = type(...)
+def _f(): pass
+FunctionType = type(_f)
+del _f
__all__ = ["Awaitable", "Coroutine",
"AsyncIterable", "AsyncIterator", "AsyncGenerator",
@@ -409,6 +413,95 @@ class Collection(Sized, Iterable, Container):
return NotImplemented
+class _CallableGenericAlias(GenericAlias):
+ """ Represent `Callable[argtypes, resulttype]`.
+
+ This sets ``__args__`` to a tuple containing the flattened ``argtypes``
+ followed by ``resulttype``.
+
+ Example: ``Callable[[int, str], float]`` sets ``__args__`` to
+ ``(int, str, float)``.
+ """
+
+ __slots__ = ()
+
+ def __new__(cls, origin, args):
+ return cls.__create_ga(origin, args)
+
+ @classmethod
+ def __create_ga(cls, origin, args):
+ if not isinstance(args, tuple) or len(args) != 2:
+ raise TypeError(
+ "Callable must be used as Callable[[arg, ...], result].")
+ t_args, t_result = args
+ if isinstance(t_args, (list, tuple)):
+ ga_args = tuple(t_args) + (t_result,)
+ # This relaxes what t_args can be on purpose to allow things like
+ # PEP 612 ParamSpec. Responsibility for whether a user is using
+ # Callable[...] properly is deferred to static type checkers.
+ else:
+ ga_args = args
+ return super().__new__(cls, origin, ga_args)
+
+ def __repr__(self):
+ if _has_special_args(self.__args__):
+ return super().__repr__()
+ return (f'collections.abc.Callable'
+ f'[[{", ".join([_type_repr(a) for a in self.__args__[:-1]])}], '
+ f'{_type_repr(self.__args__[-1])}]')
+
+ def __reduce__(self):
+ args = self.__args__
+ if not _has_special_args(args):
+ args = list(args[:-1]), args[-1]
+ return _CallableGenericAlias, (Callable, args)
+
+ def __getitem__(self, item):
+ # Called during TypeVar substitution, returns the custom subclass
+ # rather than the default types.GenericAlias object.
+ ga = super().__getitem__(item)
+ args = ga.__args__
+ # args[0] occurs due to things like Z[[int, str, bool]] from PEP 612
+ if not isinstance(ga.__args__[0], tuple):
+ t_result = ga.__args__[-1]
+ t_args = ga.__args__[:-1]
+ args = (t_args, t_result)
+ return _CallableGenericAlias(Callable, args)
+
+
+def _has_special_args(args):
+ """Checks if args[0] matches either ``...``, ``ParamSpec`` or
+ ``_ConcatenateGenericAlias`` from typing.py
+ """
+ if len(args) != 2:
+ return False
+ obj = args[0]
+ if obj is Ellipsis:
+ return True
+ obj = type(obj)
+ names = ('ParamSpec', '_ConcatenateGenericAlias')
+ return obj.__module__ == 'typing' and any(obj.__name__ == name for name in names)
+
+
+def _type_repr(obj):
+ """Return the repr() of an object, special-casing types (internal helper).
+
+ Copied from :mod:`typing` since collections.abc
+ shouldn't depend on that module.
+ """
+ if isinstance(obj, GenericAlias):
+ return repr(obj)
+ if isinstance(obj, type):
+ if obj.__module__ == 'builtins':
+ return obj.__qualname__
+ return f'{obj.__module__}.{obj.__qualname__}'
+ if obj is Ellipsis:
+ return '...'
+ if isinstance(obj, FunctionType):
+ return obj.__name__
+ return repr(obj)
+
+
class Callable(metaclass=ABCMeta):
__slots__ = ()
@@ -423,14 +516,13 @@ class Callable(metaclass=ABCMeta):
return _check_methods(C, "__call__")
return NotImplemented
- __class_getitem__ = classmethod(GenericAlias)
+ __class_getitem__ = classmethod(_CallableGenericAlias)
### SETS ###
class Set(Collection):
-
"""A set is a finite, iterable container.
This class provides concrete generic implementations of all
@@ -657,17 +749,15 @@ MutableSet.register(set)
class Mapping(Collection):
-
- __slots__ = ()
-
"""A Mapping is a generic container for associating key/value
pairs.
This class provides concrete generic implementations of all
methods except for __getitem__, __iter__, and __len__.
-
"""
+ __slots__ = ()
+
@abstractmethod
def __getitem__(self, key):
raise KeyError
@@ -789,18 +879,16 @@ ValuesView.register(dict_values)
class MutableMapping(Mapping):
-
- __slots__ = ()
-
"""A MutableMapping is a generic container for associating
key/value pairs.
This class provides concrete generic implementations of all
methods except for __getitem__, __setitem__, __delitem__,
__iter__, and __len__.
-
"""
+ __slots__ = ()
+
@abstractmethod
def __setitem__(self, key, value):
raise KeyError
@@ -879,7 +967,6 @@ MutableMapping.register(dict)
class Sequence(Reversible, Collection):
-
"""All the operations on a read-only sequence.
Concrete subclasses must override __new__ or __init__,
@@ -947,7 +1034,6 @@ Sequence.register(memoryview)
class ByteString(Sequence):
-
"""This unifies bytes and bytearray.
XXX Should add all their methods.
@@ -960,16 +1046,14 @@ ByteString.register(bytearray)
class MutableSequence(Sequence):
-
- __slots__ = ()
-
"""All the operations on a read-write sequence.
Concrete subclasses must provide __new__ or __init__,
__getitem__, __setitem__, __delitem__, __len__, and insert().
-
"""
+ __slots__ = ()
+
@abstractmethod
def __setitem__(self, index, value):
raise IndexError
diff --git a/Lib/_osx_support.py b/Lib/_osx_support.py
index e9efce7d7e..37975fe8a3 100644
--- a/Lib/_osx_support.py
+++ b/Lib/_osx_support.py
@@ -52,7 +52,7 @@ def _find_executable(executable, path=None):
return executable
-def _read_output(commandstring):
+def _read_output(commandstring, capture_stderr=False):
"""Output from successful command execution or None"""
# Similar to os.popen(commandstring, "r").read(),
# but without actually using os.popen because that
@@ -67,7 +67,10 @@ def _read_output(commandstring):
os.getpid(),), "w+b")
with contextlib.closing(fp) as fp:
- cmd = "%s 2>/dev/null >'%s'" % (commandstring, fp.name)
+ if capture_stderr:
+ cmd = "%s >'%s' 2>&1" % (commandstring, fp.name)
+ else:
+ cmd = "%s 2>/dev/null >'%s'" % (commandstring, fp.name)
return fp.read().decode('utf-8').strip() if not os.system(cmd) else None
@@ -110,6 +113,26 @@ def _get_system_version():
return _SYSTEM_VERSION
+_SYSTEM_VERSION_TUPLE = None
+def _get_system_version_tuple():
+ """
+ Return the macOS system version as a tuple
+
+ The return value is safe to use to compare
+ two version numbers.
+ """
+ global _SYSTEM_VERSION_TUPLE
+ if _SYSTEM_VERSION_TUPLE is None:
+ osx_version = _get_system_version()
+ if osx_version:
+ try:
+ _SYSTEM_VERSION_TUPLE = tuple(int(i) for i in osx_version.split('.'))
+ except ValueError:
+ _SYSTEM_VERSION_TUPLE = ()
+
+ return _SYSTEM_VERSION_TUPLE
+
+
def _remove_original_values(_config_vars):
"""Remove original unmodified values for testing"""
# This is needed for higher-level cross-platform tests of get_platform.
@@ -125,6 +148,33 @@ def _save_modified_value(_config_vars, cv, newvalue):
_config_vars[_INITPRE + cv] = oldvalue
_config_vars[cv] = newvalue
+
+_cache_default_sysroot = None
+def _default_sysroot(cc):
+ """ Returns the root of the default SDK for this system, or '/' """
+ global _cache_default_sysroot
+
+ if _cache_default_sysroot is not None:
+ return _cache_default_sysroot
+
+ contents = _read_output('%s -c -E -v - </dev/null' % (cc,), True)
+ in_incdirs = False
+ for line in contents.splitlines():
+ if line.startswith("#include <...>"):
+ in_incdirs = True
+ elif line.startswith("End of search list"):
+ in_incdirs = False
+ elif in_incdirs:
+ line = line.strip()
+ if line == '/usr/include':
+ _cache_default_sysroot = '/'
+ elif line.endswith(".sdk/usr/include"):
+ _cache_default_sysroot = line[:-12]
+ if _cache_default_sysroot is None:
+ _cache_default_sysroot = '/'
+
+ return _cache_default_sysroot
+
def _supports_universal_builds():
"""Returns True if universal builds are supported on this system"""
# As an approximation, we assume that if we are running on 10.4 or above,
@@ -132,14 +182,18 @@ def _supports_universal_builds():
# builds, in particular -isysroot and -arch arguments to the compiler. This
# is in support of allowing 10.4 universal builds to run on 10.3.x systems.
- osx_version = _get_system_version()
- if osx_version:
- try:
- osx_version = tuple(int(i) for i in osx_version.split('.'))
- except ValueError:
- osx_version = ''
+ osx_version = _get_system_version_tuple()
return bool(osx_version >= (10, 4)) if osx_version else False
+def _supports_arm64_builds():
+ """Returns True if arm64 builds are supported on this system"""
+ # There are two sets of systems supporting macOS/arm64 builds:
+ # 1. macOS 11 and later, unconditionally
+ # 2. macOS 10.15 with Xcode 12.2 or later
+ # For now the second category is ignored.
+ osx_version = _get_system_version_tuple()
+ return osx_version >= (11, 0) if osx_version else False
+
def _find_appropriate_compiler(_config_vars):
"""Find appropriate C compiler for extension module builds"""
@@ -331,6 +385,12 @@ def compiler_fixup(compiler_so, cc_args):
except ValueError:
break
+ elif not _supports_arm64_builds():
+ # Look for "-arch arm64" and drop that
+ for idx in reversed(range(len(compiler_so))):
+ if compiler_so[idx] == '-arch' and compiler_so[idx+1] == "arm64":
+ del compiler_so[idx:idx+2]
+
if 'ARCHFLAGS' in os.environ and not stripArch:
# User specified different -arch flags in the environ,
# see also distutils.sysconfig
@@ -481,6 +541,8 @@ def get_platform_osx(_config_vars, osname, release, machine):
if len(archs) == 1:
machine = archs[0]
+ elif archs == ('arm64', 'x86_64'):
+ machine = 'universal2'
elif archs == ('i386', 'ppc'):
machine = 'fat'
elif archs == ('i386', 'x86_64'):
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 2fb1da59f9..8a12dea766 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -1719,7 +1719,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
add_group = self.add_argument_group
self._positionals = add_group(_('positional arguments'))
- self._optionals = add_group(_('optional arguments'))
+ self._optionals = add_group(_('options'))
self._subparsers = None
# register types
diff --git a/Lib/ast.py b/Lib/ast.py
index d8bd337370..845c80c2bb 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -63,7 +63,10 @@ def literal_eval(node_or_string):
if isinstance(node_or_string, Expression):
node_or_string = node_or_string.body
def _raise_malformed_node(node):
- raise ValueError(f'malformed node or string: {node!r}')
+ msg = "malformed node or string"
+ if lno := getattr(node, 'lineno', None):
+ msg += f' on line {lno}'
+ raise ValueError(msg + f': {node!r}')
def _convert_num(node):
if not isinstance(node, Constant) or type(node.value) not in (int, float, complex):
_raise_malformed_node(node)
@@ -662,17 +665,23 @@ class _Precedence(IntEnum):
except ValueError:
return self
+
+_SINGLE_QUOTES = ("'", '"')
+_MULTI_QUOTES = ('"""', "'''")
+_ALL_QUOTES = (*_SINGLE_QUOTES, *_MULTI_QUOTES)
+
class _Unparser(NodeVisitor):
"""Methods in this class recursively traverse an AST and
output source code for the abstract syntax; original formatting
is disregarded."""
- def __init__(self):
+ def __init__(self, *, _avoid_backslashes=False):
self._source = []
self._buffer = []
self._precedences = {}
self._type_ignores = {}
self._indent = 0
+ self._avoid_backslashes = _avoid_backslashes
def interleave(self, inter, f, seq):
"""Call f on each item in seq, calling inter() in between."""
@@ -1067,15 +1076,85 @@ class _Unparser(NodeVisitor):
with self.block(extra=self.get_type_comment(node)):
self.traverse(node.body)
+ def _str_literal_helper(
+ self, string, *, quote_types=_ALL_QUOTES, escape_special_whitespace=False
+ ):
+ """Helper for writing string literals, minimizing escapes.
+ Returns the tuple (string literal to write, possible quote types).
+ """
+ def escape_char(c):
+ # \n and \t are non-printable, but we only escape them if
+ # escape_special_whitespace is True
+ if not escape_special_whitespace and c in "\n\t":
+ return c
+ # Always escape backslashes and other non-printable characters
+ if c == "\\" or not c.isprintable():
+ return c.encode("unicode_escape").decode("ascii")
+ return c
+
+ escaped_string = "".join(map(escape_char, string))
+ possible_quotes = quote_types
+ if "\n" in escaped_string:
+ possible_quotes = [q for q in possible_quotes if q in _MULTI_QUOTES]
+ possible_quotes = [q for q in possible_quotes if q not in escaped_string]
+ if not possible_quotes:
+ # If there aren't any possible_quotes, fallback to using repr
+ # on the original string. Try to use a quote from quote_types,
+ # e.g., so that we use triple quotes for docstrings.
+ string = repr(string)
+ quote = next((q for q in quote_types if string[0] in q), string[0])
+ return string[1:-1], [quote]
+ if escaped_string:
+ # Sort so that we prefer '''"''' over """\""""
+ possible_quotes.sort(key=lambda q: q[0] == escaped_string[-1])
+ # If we're using triple quotes and we'd need to escape a final
+ # quote, escape it
+ if possible_quotes[0][0] == escaped_string[-1]:
+ assert len(possible_quotes[0]) == 3
+ escaped_string = escaped_string[:-1] + "\\" + escaped_string[-1]
+ return escaped_string, possible_quotes
+
+ def _write_str_avoiding_backslashes(self, string, *, quote_types=_ALL_QUOTES):
+ """Write string literal value with a best effort attempt to avoid backslashes."""
+ string, quote_types = self._str_literal_helper(string, quote_types=quote_types)
+ quote_type = quote_types[0]
+ self.write(f"{quote_type}{string}{quote_type}")
+
def visit_JoinedStr(self, node):
self.write("f")
- self._fstring_JoinedStr(node, self.buffer_writer)
- self.write(repr(self.buffer))
+ if self._avoid_backslashes:
+ self._fstring_JoinedStr(node, self.buffer_writer)
+ self._write_str_avoiding_backslashes(self.buffer)
+ return
+
+ # If we don't need to avoid backslashes globally (i.e., we only need
+ # to avoid them inside FormattedValues), it's cosmetically preferred
+ # to use escaped whitespace. That is, it's preferred to use backslashes
+ # for cases like: f"{x}\n". To accomplish this, we keep track of what
+ # in our buffer corresponds to FormattedValues and what corresponds to
+ # Constant parts of the f-string, and allow escapes accordingly.
+ buffer = []
+ for value in node.values:
+ meth = getattr(self, "_fstring_" + type(value).__name__)
+ meth(value, self.buffer_writer)
+ buffer.append((self.buffer, isinstance(value, Constant)))
+ new_buffer = []
+ quote_types = _ALL_QUOTES
+ for value, is_constant in buffer:
+ # Repeatedly narrow down the list of possible quote_types
+ value, quote_types = self._str_literal_helper(
+ value, quote_types=quote_types,
+ escape_special_whitespace=is_constant
+ )
+ new_buffer.append(value)
+ value = "".join(new_buffer)
+ quote_type = quote_types[0]
+ self.write(f"{quote_type}{value}{quote_type}")
def visit_FormattedValue(self, node):
self.write("f")
self._fstring_FormattedValue(node, self.buffer_writer)
- self.write(repr(self.buffer))
+ self._write_str_avoiding_backslashes(self.buffer)
def _fstring_JoinedStr(self, node, write):
for value in node.values:
@@ -1090,11 +1169,13 @@ class _Unparser(NodeVisitor):
def _fstring_FormattedValue(self, node, write):
write("{")
- unparser = type(self)()
+ unparser = type(self)(_avoid_backslashes=True)
unparser.set_precedence(_Precedence.TEST.next(), node.value)
expr = unparser.visit(node.value)
if expr.startswith("{"):
write(" ") # Separate pair of opening brackets as "{ {"
+ if "\\" in expr:
+ raise ValueError("Unable to avoid backslash in f-string expression part")
write(expr)
if node.conversion != -1:
conversion = chr(node.conversion)
@@ -1111,33 +1192,17 @@ class _Unparser(NodeVisitor):
self.write(node.id)
def _write_docstring(self, node):
- def esc_char(c):
- if c in ("\n", "\t"):
- # In the AST form, we don't know the author's intentation
- # about how this should be displayed. We'll only escape
- # \n and \t, because they are more likely to be unescaped
- # in the source
- return c
- return c.encode('unicode_escape').decode('ascii')
-
self.fill()
if node.kind == "u":
self.write("u")
-
- value = node.value
- if value:
- # Preserve quotes in the docstring by escaping them
- value = "".join(map(esc_char, value))
- if value[-1] == '"':
- value = value.replace('"', '\\"', -1)
- value = value.replace('"""', '""\\"')
-
- self.write(f'"""{value}"""')
+ self._write_str_avoiding_backslashes(node.value, quote_types=_MULTI_QUOTES)
def _write_constant(self, value):
if isinstance(value, (float, complex)):
# Substitute overflowing decimal literal for AST infinities.
self.write(repr(value).replace("inf", _INFSTR))
+ elif self._avoid_backslashes and isinstance(value, str):
+ self._write_str_avoiding_backslashes(value)
else:
self.write(repr(value))
diff --git a/Lib/asyncio/__init__.py b/Lib/asyncio/__init__.py
index eb84bfb189..200b14c2a3 100644
--- a/Lib/asyncio/__init__.py
+++ b/Lib/asyncio/__init__.py
@@ -20,10 +20,6 @@ from .tasks import *
from .threads import *
from .transports import *
-# Exposed for _asynciomodule.c to implement now deprecated
-# Task.all_tasks() method. This function will be removed in 3.9.
-from .tasks import _all_tasks_compat # NoQA
-
__all__ = (base_events.__all__ +
coroutines.__all__ +
events.__all__ +
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index b2d446a51f..f789635e0f 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -350,7 +350,7 @@ class Server(events.AbstractServer):
self._start_serving()
# Skip one loop iteration so that all 'loop.add_reader'
# go through.
- await tasks.sleep(0, loop=self._loop)
+ await tasks.sleep(0)
async def serve_forever(self):
if self._serving_forever_fut is not None:
@@ -541,8 +541,7 @@ class BaseEventLoop(events.AbstractEventLoop):
results = await tasks.gather(
*[ag.aclose() for ag in closing_agens],
- return_exceptions=True,
- loop=self)
+ return_exceptions=True)
for result, agen in zip(results, closing_agens):
if isinstance(result, Exception):
@@ -1457,7 +1456,7 @@ class BaseEventLoop(events.AbstractEventLoop):
fs = [self._create_server_getaddrinfo(host, port, family=family,
flags=flags)
for host in hosts]
- infos = await tasks.gather(*fs, loop=self)
+ infos = await tasks.gather(*fs)
infos = set(itertools.chain.from_iterable(infos))
completed = False
@@ -1515,7 +1514,7 @@ class BaseEventLoop(events.AbstractEventLoop):
server._start_serving()
# Skip one loop iteration so that all 'loop.add_reader'
# go through.
- await tasks.sleep(0, loop=self)
+ await tasks.sleep(0)
if self._debug:
logger.info("%r is serving", server)
@@ -1525,14 +1524,6 @@ class BaseEventLoop(events.AbstractEventLoop):
self, protocol_factory, sock,
*, ssl=None,
ssl_handshake_timeout=None):
- """Handle an accepted connection.
-
- This is used by servers that accept connections outside of
- asyncio but that use asyncio to handle connections.
-
- This method is a coroutine. When completed, the coroutine
- returns a (transport, protocol) pair.
- """
if sock.type != socket.SOCK_STREAM:
raise ValueError(f'A Stream Socket was expected, got {sock!r}')
diff --git a/Lib/asyncio/base_futures.py b/Lib/asyncio/base_futures.py
index 22f298069c..2c01ac98e1 100644
--- a/Lib/asyncio/base_futures.py
+++ b/Lib/asyncio/base_futures.py
@@ -1,6 +1,7 @@
__all__ = ()
import reprlib
+from _thread import get_ident
from . import format_helpers
@@ -41,6 +42,16 @@ def _format_callbacks(cb):
return f'cb=[{cb}]'
+# bpo-42183: _repr_running is needed for repr protection
+# when a Future or Task result contains itself directly or indirectly.
+# The logic is borrowed from @reprlib.recursive_repr decorator.
+# Unfortunately, the direct decorator usage is impossible because of
+# AttributeError: '_asyncio.Task' object has no attribute '__module__' error.
+#
+# After fixing this thing we can return to the decorator based approach.
+_repr_running = set()
+
+
def _future_repr_info(future):
# (Future) -> str
"""helper function for Future.__repr__"""
@@ -49,9 +60,17 @@ def _future_repr_info(future):
if future._exception is not None:
info.append(f'exception={future._exception!r}')
else:
- # use reprlib to limit the length of the output, especially
- # for very long strings
- result = reprlib.repr(future._result)
+ key = id(future), get_ident()
+ if key in _repr_running:
+ result = '...'
+ else:
+ _repr_running.add(key)
+ try:
+ # use reprlib to limit the length of the output, especially
+ # for very long strings
+ result = reprlib.repr(future._result)
+ finally:
+ _repr_running.discard(key)
info.append(f'result={result}')
if future._callbacks:
info.append(_format_callbacks(future._callbacks))
diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py
index 0dce87b8ec..1a20f362ec 100644
--- a/Lib/asyncio/events.py
+++ b/Lib/asyncio/events.py
@@ -418,6 +418,20 @@ class AbstractEventLoop:
"""
raise NotImplementedError
+ async def connect_accepted_socket(
+ self, protocol_factory, sock,
+ *, ssl=None,
+ ssl_handshake_timeout=None):
+ """Handle an accepted connection.
+
+ This is used by servers that accept connections outside of
+ asyncio, but use asyncio to handle connections.
+
+ This method is a coroutine. When completed, the coroutine
+ returns a (transport, protocol) pair.
+ """
+ raise NotImplementedError
+
async def create_datagram_endpoint(self, protocol_factory,
local_addr=None, remote_addr=None, *,
family=0, proto=0, flags=0,
diff --git a/Lib/asyncio/exceptions.py b/Lib/asyncio/exceptions.py
index e03602ef57..f07e448657 100644
--- a/Lib/asyncio/exceptions.py
+++ b/Lib/asyncio/exceptions.py
@@ -34,8 +34,9 @@ class IncompleteReadError(EOFError):
- expected: total number of expected bytes (or None if unknown)
"""
def __init__(self, partial, expected):
+ r_expected = 'undefined' if expected is None else repr(expected)
super().__init__(f'{len(partial)} bytes read on a total of '
- f'{expected!r} expected bytes')
+ f'{r_expected} expected bytes')
self.partial = partial
self.expected = expected
diff --git a/Lib/asyncio/futures.py b/Lib/asyncio/futures.py
index bed4da52fd..2d22ef66c9 100644
--- a/Lib/asyncio/futures.py
+++ b/Lib/asyncio/futures.py
@@ -115,7 +115,7 @@ class Future:
@_log_traceback.setter
def _log_traceback(self, val):
- if bool(val):
+ if val:
raise ValueError('_log_traceback can only be set to False')
self.__log_traceback = False
diff --git a/Lib/asyncio/locks.py b/Lib/asyncio/locks.py
index f1ce732478..a7453fb1c7 100644
--- a/Lib/asyncio/locks.py
+++ b/Lib/asyncio/locks.py
@@ -3,10 +3,9 @@
__all__ = ('Lock', 'Event', 'Condition', 'Semaphore', 'BoundedSemaphore')
import collections
-import warnings
-from . import events
from . import exceptions
+from . import mixins
class _ContextManagerMixin:
@@ -20,7 +19,7 @@ class _ContextManagerMixin:
self.release()
-class Lock(_ContextManagerMixin):
+class Lock(_ContextManagerMixin, mixins._LoopBoundMixin):
"""Primitive lock objects.
A primitive lock is a synchronization primitive that is not owned
@@ -74,16 +73,10 @@ class Lock(_ContextManagerMixin):
"""
- def __init__(self, *, loop=None):
+ def __init__(self, *, loop=mixins._marker):
+ super().__init__(loop=loop)
self._waiters = None
self._locked = False
- if loop is None:
- self._loop = events.get_event_loop()
- else:
- self._loop = loop
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
def __repr__(self):
res = super().__repr__()
@@ -109,7 +102,7 @@ class Lock(_ContextManagerMixin):
if self._waiters is None:
self._waiters = collections.deque()
- fut = self._loop.create_future()
+ fut = self._get_loop().create_future()
self._waiters.append(fut)
# Finally block should be called before the CancelledError
@@ -161,7 +154,7 @@ class Lock(_ContextManagerMixin):
fut.set_result(True)
-class Event:
+class Event(mixins._LoopBoundMixin):
"""Asynchronous equivalent to threading.Event.
Class implementing event objects. An event manages a flag that can be set
@@ -170,16 +163,10 @@ class Event:
false.
"""
- def __init__(self, *, loop=None):
+ def __init__(self, *, loop=mixins._marker):
+ super().__init__(loop=loop)
self._waiters = collections.deque()
self._value = False
- if loop is None:
- self._loop = events.get_event_loop()
- else:
- self._loop = loop
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
def __repr__(self):
res = super().__repr__()
@@ -220,7 +207,7 @@ class Event:
if self._value:
return True
- fut = self._loop.create_future()
+ fut = self._get_loop().create_future()
self._waiters.append(fut)
try:
await fut
@@ -229,7 +216,7 @@ class Event:
self._waiters.remove(fut)
-class Condition(_ContextManagerMixin):
+class Condition(_ContextManagerMixin, mixins._LoopBoundMixin):
"""Asynchronous equivalent to threading.Condition.
This class implements condition variable objects. A condition variable
@@ -239,18 +226,11 @@ class Condition(_ContextManagerMixin):
A new Lock object is created and used as the underlying lock.
"""
- def __init__(self, lock=None, *, loop=None):
- if loop is None:
- self._loop = events.get_event_loop()
- else:
- self._loop = loop
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
-
+ def __init__(self, lock=None, *, loop=mixins._marker):
+ super().__init__(loop=loop)
if lock is None:
- lock = Lock(loop=loop)
- elif lock._loop is not self._loop:
+ lock = Lock()
+ elif lock._loop is not self._get_loop():
raise ValueError("loop argument must agree with lock")
self._lock = lock
@@ -284,7 +264,7 @@ class Condition(_ContextManagerMixin):
self.release()
try:
- fut = self._loop.create_future()
+ fut = self._get_loop().create_future()
self._waiters.append(fut)
try:
await fut
@@ -351,7 +331,7 @@ class Condition(_ContextManagerMixin):
self.notify(len(self._waiters))
-class Semaphore(_ContextManagerMixin):
+class Semaphore(_ContextManagerMixin, mixins._LoopBoundMixin):
"""A Semaphore implementation.
A semaphore manages an internal counter which is decremented by each
@@ -366,18 +346,12 @@ class Semaphore(_ContextManagerMixin):
ValueError is raised.
"""
- def __init__(self, value=1, *, loop=None):
+ def __init__(self, value=1, *, loop=mixins._marker):
+ super().__init__(loop=loop)
if value < 0:
raise ValueError("Semaphore initial value must be >= 0")
self._value = value
self._waiters = collections.deque()
- if loop is None:
- self._loop = events.get_event_loop()
- else:
- self._loop = loop
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
def __repr__(self):
res = super().__repr__()
@@ -407,7 +381,7 @@ class Semaphore(_ContextManagerMixin):
True.
"""
while self._value <= 0:
- fut = self._loop.create_future()
+ fut = self._get_loop().create_future()
self._waiters.append(fut)
try:
await fut
@@ -436,12 +410,7 @@ class BoundedSemaphore(Semaphore):
above the initial value.
"""
- def __init__(self, value=1, *, loop=None):
- if loop:
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
-
+ def __init__(self, value=1, *, loop=mixins._marker):
self._bound_value = value
super().__init__(value, loop=loop)
diff --git a/Lib/asyncio/mixins.py b/Lib/asyncio/mixins.py
new file mode 100644
index 0000000000..650df05ccc
--- /dev/null
+++ b/Lib/asyncio/mixins.py
@@ -0,0 +1,31 @@
+"""Event loop mixins."""
+
+import threading
+from . import events
+
+_global_lock = threading.Lock()
+
+# Used as a sentinel for loop parameter
+_marker = object()
+
+
+class _LoopBoundMixin:
+ _loop = None
+
+ def __init__(self, *, loop=_marker):
+ if loop is not _marker:
+ raise TypeError(
+ f'As of 3.10, the *loop* parameter was removed from '
+ f'{type(self).__name__}() since it is no longer necessary'
+ )
+
+ def _get_loop(self):
+ loop = events._get_running_loop()
+
+ if self._loop is None:
+ with _global_lock:
+ if self._loop is None:
+ self._loop = loop
+ if loop is not self._loop:
+ raise RuntimeError(f'{self!r} is bound to a different event loop')
+ return loop
diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py
index cd3f7c6a56..a87ec8b215 100644
--- a/Lib/asyncio/queues.py
+++ b/Lib/asyncio/queues.py
@@ -2,10 +2,9 @@ __all__ = ('Queue', 'PriorityQueue', 'LifoQueue', 'QueueFull', 'QueueEmpty')
import collections
import heapq
-import warnings
-from . import events
from . import locks
+from . import mixins
class QueueEmpty(Exception):
@@ -18,7 +17,7 @@ class QueueFull(Exception):
pass
-class Queue:
+class Queue(mixins._LoopBoundMixin):
"""A queue, useful for coordinating producer and consumer coroutines.
If maxsize is less than or equal to zero, the queue size is infinite. If it
@@ -30,14 +29,8 @@ class Queue:
interrupted between calling qsize() and doing an operation on the Queue.
"""
- def __init__(self, maxsize=0, *, loop=None):
- if loop is None:
- self._loop = events.get_event_loop()
- else:
- self._loop = loop
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
+ def __init__(self, maxsize=0, *, loop=mixins._marker):
+ super().__init__(loop=loop)
self._maxsize = maxsize
# Futures.
@@ -45,7 +38,7 @@ class Queue:
# Futures.
self._putters = collections.deque()
self._unfinished_tasks = 0
- self._finished = locks.Event(loop=loop)
+ self._finished = locks.Event()
self._finished.set()
self._init(maxsize)
@@ -122,7 +115,7 @@ class Queue:
slot is available before adding item.
"""
while self.full():
- putter = self._loop.create_future()
+ putter = self._get_loop().create_future()
self._putters.append(putter)
try:
await putter
@@ -160,7 +153,7 @@ class Queue:
If queue is empty, wait until an item is available.
"""
while self.empty():
- getter = self._loop.create_future()
+ getter = self._get_loop().create_future()
self._getters.append(getter)
try:
await getter
diff --git a/Lib/asyncio/runners.py b/Lib/asyncio/runners.py
index 268635d68f..9a5e9a4847 100644
--- a/Lib/asyncio/runners.py
+++ b/Lib/asyncio/runners.py
@@ -60,8 +60,7 @@ def _cancel_all_tasks(loop):
for task in to_cancel:
task.cancel()
- loop.run_until_complete(
- tasks.gather(*to_cancel, loop=loop, return_exceptions=True))
+ loop.run_until_complete(tasks.gather(*to_cancel, return_exceptions=True))
for task in to_cancel:
if task.cancelled():
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py
index 3c80bb8892..96a9f97200 100644
--- a/Lib/asyncio/streams.py
+++ b/Lib/asyncio/streams.py
@@ -23,7 +23,7 @@ _DEFAULT_LIMIT = 2 ** 16 # 64 KiB
async def open_connection(host=None, port=None, *,
- loop=None, limit=_DEFAULT_LIMIT, **kwds):
+ limit=_DEFAULT_LIMIT, **kwds):
"""A wrapper for create_connection() returning a (reader, writer) pair.
The reader returned is a StreamReader instance; the writer is a
@@ -41,12 +41,7 @@ async def open_connection(host=None, port=None, *,
StreamReaderProtocol classes, just copy the code -- there's
really nothing special here except some convenience.)
"""
- if loop is None:
- loop = events.get_event_loop()
- else:
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
+ loop = events.get_running_loop()
reader = StreamReader(limit=limit, loop=loop)
protocol = StreamReaderProtocol(reader, loop=loop)
transport, _ = await loop.create_connection(
@@ -56,7 +51,7 @@ async def open_connection(host=None, port=None, *,
async def start_server(client_connected_cb, host=None, port=None, *,
- loop=None, limit=_DEFAULT_LIMIT, **kwds):
+ limit=_DEFAULT_LIMIT, **kwds):
"""Start a socket server, call back for each client connected.
The first parameter, `client_connected_cb`, takes two parameters:
@@ -78,12 +73,7 @@ async def start_server(client_connected_cb, host=None, port=None, *,
The return value is the same as loop.create_server(), i.e. a
Server object which can be used to stop the service.
"""
- if loop is None:
- loop = events.get_event_loop()
- else:
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
+ loop = events.get_running_loop()
def factory():
reader = StreamReader(limit=limit, loop=loop)
@@ -98,14 +88,10 @@ if hasattr(socket, 'AF_UNIX'):
# UNIX Domain Sockets are supported on this platform
async def open_unix_connection(path=None, *,
- loop=None, limit=_DEFAULT_LIMIT, **kwds):
+ limit=_DEFAULT_LIMIT, **kwds):
"""Similar to `open_connection` but works with UNIX Domain Sockets."""
- if loop is None:
- loop = events.get_event_loop()
- else:
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
+ loop = events.get_running_loop()
+
reader = StreamReader(limit=limit, loop=loop)
protocol = StreamReaderProtocol(reader, loop=loop)
transport, _ = await loop.create_unix_connection(
@@ -114,14 +100,9 @@ if hasattr(socket, 'AF_UNIX'):
return reader, writer
async def start_unix_server(client_connected_cb, path=None, *,
- loop=None, limit=_DEFAULT_LIMIT, **kwds):
+ limit=_DEFAULT_LIMIT, **kwds):
"""Similar to `start_server` but works with UNIX Domain Sockets."""
- if loop is None:
- loop = events.get_event_loop()
- else:
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
+ loop = events.get_running_loop()
def factory():
reader = StreamReader(limit=limit, loop=loop)
diff --git a/Lib/asyncio/subprocess.py b/Lib/asyncio/subprocess.py
index c9506b1583..cd10231f71 100644
--- a/Lib/asyncio/subprocess.py
+++ b/Lib/asyncio/subprocess.py
@@ -1,7 +1,6 @@
__all__ = 'create_subprocess_exec', 'create_subprocess_shell'
import subprocess
-import warnings
from . import events
from . import protocols
@@ -193,24 +192,14 @@ class Process:
stderr = self._read_stream(2)
else:
stderr = self._noop()
- stdin, stdout, stderr = await tasks.gather(stdin, stdout, stderr,
- loop=self._loop)
+ stdin, stdout, stderr = await tasks.gather(stdin, stdout, stderr)
await self.wait()
return (stdout, stderr)
async def create_subprocess_shell(cmd, stdin=None, stdout=None, stderr=None,
- loop=None, limit=streams._DEFAULT_LIMIT,
- **kwds):
- if loop is None:
- loop = events.get_event_loop()
- else:
- warnings.warn("The loop argument is deprecated since Python 3.8 "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning,
- stacklevel=2
- )
-
+ limit=streams._DEFAULT_LIMIT, **kwds):
+ loop = events.get_running_loop()
protocol_factory = lambda: SubprocessStreamProtocol(limit=limit,
loop=loop)
transport, protocol = await loop.subprocess_shell(
@@ -221,16 +210,9 @@ async def create_subprocess_shell(cmd, stdin=None, stdout=None, stderr=None,
async def create_subprocess_exec(program, *args, stdin=None, stdout=None,
- stderr=None, loop=None,
- limit=streams._DEFAULT_LIMIT, **kwds):
- if loop is None:
- loop = events.get_event_loop()
- else:
- warnings.warn("The loop argument is deprecated since Python 3.8 "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning,
- stacklevel=2
- )
+ stderr=None, limit=streams._DEFAULT_LIMIT,
+ **kwds):
+ loop = events.get_running_loop()
protocol_factory = lambda: SubprocessStreamProtocol(limit=limit,
loop=loop)
transport, protocol = await loop.subprocess_exec(
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index ad31f5d597..52f1e6629e 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -61,30 +61,6 @@ def all_tasks(loop=None):
if futures._get_loop(t) is loop and not t.done()}
-def _all_tasks_compat(loop=None):
- # Different from "all_task()" by returning *all* Tasks, including
- # the completed ones. Used to implement deprecated "Tasks.all_task()"
- # method.
- if loop is None:
- loop = events.get_event_loop()
- # Looping over a WeakSet (_all_tasks) isn't safe as it can be updated from another
- # thread while we do so. Therefore we cast it to list prior to filtering. The list
- # cast itself requires iteration, so we repeat it several times ignoring
- # RuntimeErrors (which are not very likely to occur). See issues 34970 and 36607 for
- # details.
- i = 0
- while True:
- try:
- tasks = list(_all_tasks)
- except RuntimeError:
- i += 1
- if i >= 1000:
- raise
- else:
- break
- return {t for t in tasks if futures._get_loop(t) is loop}
-
-
def _set_task_name(task, name):
if name is not None:
try:
@@ -370,7 +346,7 @@ FIRST_EXCEPTION = concurrent.futures.FIRST_EXCEPTION
ALL_COMPLETED = concurrent.futures.ALL_COMPLETED
-async def wait(fs, *, loop=None, timeout=None, return_when=ALL_COMPLETED):
+async def wait(fs, *, timeout=None, return_when=ALL_COMPLETED):
"""Wait for the Futures and coroutines given by fs to complete.
The fs iterable must not be empty.
@@ -393,20 +369,17 @@ async def wait(fs, *, loop=None, timeout=None, return_when=ALL_COMPLETED):
if return_when not in (FIRST_COMPLETED, FIRST_EXCEPTION, ALL_COMPLETED):
raise ValueError(f'Invalid return_when value: {return_when}')
- if loop is None:
- loop = events.get_running_loop()
- else:
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
+ loop = events.get_running_loop()
+
+ fs = set(fs)
- if any(coroutines.iscoroutine(f) for f in set(fs)):
+ if any(coroutines.iscoroutine(f) for f in fs):
warnings.warn("The explicit passing of coroutine objects to "
"asyncio.wait() is deprecated since Python 3.8, and "
"scheduled for removal in Python 3.11.",
DeprecationWarning, stacklevel=2)
- fs = {ensure_future(f, loop=loop) for f in set(fs)}
+ fs = {ensure_future(f, loop=loop) for f in fs}
return await _wait(fs, timeout, return_when, loop)
@@ -416,7 +389,7 @@ def _release_waiter(waiter, *args):
waiter.set_result(None)
-async def wait_for(fut, timeout, *, loop=None):
+async def wait_for(fut, timeout):
"""Wait for the single Future or coroutine to complete, with timeout.
Coroutine will be wrapped in Task.
@@ -429,12 +402,7 @@ async def wait_for(fut, timeout, *, loop=None):
This function is a coroutine.
"""
- if loop is None:
- loop = events.get_running_loop()
- else:
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
+ loop = events.get_running_loop()
if timeout is None:
return await fut
@@ -469,7 +437,10 @@ async def wait_for(fut, timeout, *, loop=None):
return fut.result()
else:
fut.remove_done_callback(cb)
- fut.cancel()
+ # We must ensure that the task is not running
+ # after wait_for() returns.
+ # See https://bugs.python.org/issue32751
+ await _cancel_and_wait(fut, loop=loop)
raise
if fut.done():
@@ -554,7 +525,7 @@ async def _cancel_and_wait(fut, loop):
# This is *not* a @coroutine! It is just an iterator (yielding Futures).
-def as_completed(fs, *, loop=None, timeout=None):
+def as_completed(fs, *, timeout=None):
"""Return an iterator whose values are coroutines.
When waiting for the yielded coroutines you'll get the results (or
@@ -576,14 +547,9 @@ def as_completed(fs, *, loop=None, timeout=None):
raise TypeError(f"expect an iterable of futures, not {type(fs).__name__}")
from .queues import Queue # Import here to avoid circular import problem.
- done = Queue(loop=loop)
+ done = Queue()
- if loop is None:
- loop = events.get_event_loop()
- else:
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
+ loop = events.get_event_loop()
todo = {ensure_future(f, loop=loop) for f in set(fs)}
timeout_handle = None
@@ -628,19 +594,13 @@ def __sleep0():
yield
-async def sleep(delay, result=None, *, loop=None):
+async def sleep(delay, result=None):
"""Coroutine that completes after a given time (in seconds)."""
if delay <= 0:
await __sleep0()
return result
- if loop is None:
- loop = events.get_running_loop()
- else:
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
-
+ loop = events.get_running_loop()
future = loop.create_future()
h = loop.call_later(delay,
futures._set_result_unless_cancelled,
@@ -715,7 +675,7 @@ class _GatheringFuture(futures.Future):
return ret
-def gather(*coros_or_futures, loop=None, return_exceptions=False):
+def gather(*coros_or_futures, return_exceptions=False):
"""Return a future aggregating results from the given coroutines/futures.
Coroutines will be wrapped in a future and scheduled in the event
@@ -746,12 +706,7 @@ def gather(*coros_or_futures, loop=None, return_exceptions=False):
gather won't cancel any other awaitables.
"""
if not coros_or_futures:
- if loop is None:
- loop = events.get_event_loop()
- else:
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
+ loop = events.get_event_loop()
outer = loop.create_future()
outer.set_result([])
return outer
@@ -815,6 +770,7 @@ def gather(*coros_or_futures, loop=None, return_exceptions=False):
children = []
nfuts = 0
nfinished = 0
+ loop = None
for arg in coros_or_futures:
if arg not in arg_to_fut:
fut = ensure_future(arg, loop=loop)
@@ -841,7 +797,7 @@ def gather(*coros_or_futures, loop=None, return_exceptions=False):
return outer
-def shield(arg, *, loop=None):
+def shield(arg):
"""Wait for a future, shielding it from cancellation.
The statement
@@ -867,11 +823,7 @@ def shield(arg, *, loop=None):
except CancelledError:
res = None
"""
- if loop is not None:
- warnings.warn("The loop argument is deprecated since Python 3.8, "
- "and scheduled for removal in Python 3.10.",
- DeprecationWarning, stacklevel=2)
- inner = ensure_future(arg, loop=loop)
+ inner = ensure_future(arg)
if inner.done():
# Shortcut.
return inner
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index f34a5b4b44..e4f445e950 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -44,6 +44,16 @@ def _sighandler_noop(signum, frame):
pass
+def waitstatus_to_exitcode(status):
+ try:
+ return os.waitstatus_to_exitcode(status)
+ except ValueError:
+ # The child exited, but we don't understand its status.
+ # This shouldn't happen, but if it does, let's just
+ # return that status; perhaps that helps debug it.
+ return status
+
+
class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
"""Unix event loop.
@@ -323,7 +333,7 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
server._start_serving()
# Skip one loop iteration so that all 'loop.add_reader'
# go through.
- await tasks.sleep(0, loop=self)
+ await tasks.sleep(0)
return server
@@ -941,7 +951,7 @@ class PidfdChildWatcher(AbstractChildWatcher):
" will report returncode 255",
pid)
else:
- returncode = _compute_returncode(status)
+ returncode = waitstatus_to_exitcode(status)
os.close(pidfd)
callback(pid, returncode, *args)
@@ -956,20 +966,6 @@ class PidfdChildWatcher(AbstractChildWatcher):
return True
-def _compute_returncode(status):
- if os.WIFSIGNALED(status):
- # The child process died because of a signal.
- return -os.WTERMSIG(status)
- elif os.WIFEXITED(status):
- # The child process exited (e.g sys.exit()).
- return os.WEXITSTATUS(status)
- else:
- # The child exited, but we don't understand its status.
- # This shouldn't happen, but if it does, let's just
- # return that status; perhaps that helps debug it.
- return status
-
-
class BaseChildWatcher(AbstractChildWatcher):
def __init__(self):
@@ -1080,7 +1076,7 @@ class SafeChildWatcher(BaseChildWatcher):
# The child process is still alive.
return
- returncode = _compute_returncode(status)
+ returncode = waitstatus_to_exitcode(status)
if self._loop.get_debug():
logger.debug('process %s exited with returncode %s',
expected_pid, returncode)
@@ -1173,7 +1169,7 @@ class FastChildWatcher(BaseChildWatcher):
# A child process is still alive.
return
- returncode = _compute_returncode(status)
+ returncode = waitstatus_to_exitcode(status)
with self._lock:
try:
@@ -1230,13 +1226,15 @@ class MultiLoopChildWatcher(AbstractChildWatcher):
def close(self):
self._callbacks.clear()
- if self._saved_sighandler is not None:
- handler = signal.getsignal(signal.SIGCHLD)
- if handler != self._sig_chld:
- logger.warning("SIGCHLD handler was changed by outside code")
- else:
- signal.signal(signal.SIGCHLD, self._saved_sighandler)
- self._saved_sighandler = None
+ if self._saved_sighandler is None:
+ return
+
+ handler = signal.getsignal(signal.SIGCHLD)
+ if handler != self._sig_chld:
+ logger.warning("SIGCHLD handler was changed by outside code")
+ else:
+ signal.signal(signal.SIGCHLD, self._saved_sighandler)
+ self._saved_sighandler = None
def __enter__(self):
return self
@@ -1263,15 +1261,17 @@ class MultiLoopChildWatcher(AbstractChildWatcher):
# The reason to do it here is that attach_loop() is called from
# unix policy only for the main thread.
# Main thread is required for subscription on SIGCHLD signal
+ if self._saved_sighandler is not None:
+ return
+
+ self._saved_sighandler = signal.signal(signal.SIGCHLD, self._sig_chld)
if self._saved_sighandler is None:
- self._saved_sighandler = signal.signal(signal.SIGCHLD, self._sig_chld)
- if self._saved_sighandler is None:
- logger.warning("Previous SIGCHLD handler was set by non-Python code, "
- "restore to default handler on watcher close.")
- self._saved_sighandler = signal.SIG_DFL
+ logger.warning("Previous SIGCHLD handler was set by non-Python code, "
+ "restore to default handler on watcher close.")
+ self._saved_sighandler = signal.SIG_DFL
- # Set SA_RESTART to limit EINTR occurrences.
- signal.siginterrupt(signal.SIGCHLD, False)
+ # Set SA_RESTART to limit EINTR occurrences.
+ signal.siginterrupt(signal.SIGCHLD, False)
def _do_waitpid_all(self):
for pid in list(self._callbacks):
@@ -1296,7 +1296,7 @@ class MultiLoopChildWatcher(AbstractChildWatcher):
# The child process is still alive.
return
- returncode = _compute_returncode(status)
+ returncode = waitstatus_to_exitcode(status)
debug_log = True
try:
loop, callback, args = self._callbacks.pop(pid)
@@ -1399,7 +1399,7 @@ class ThreadedChildWatcher(AbstractChildWatcher):
"Unknown child process pid %d, will report returncode 255",
pid)
else:
- returncode = _compute_returncode(status)
+ returncode = waitstatus_to_exitcode(status)
if loop.get_debug():
logger.debug('process %s exited with returncode %s',
expected_pid, returncode)
diff --git a/Lib/asyncore.py b/Lib/asyncore.py
index ce16f11a2f..eeea488886 100644
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -113,7 +113,7 @@ def readwrite(obj, flags):
if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL):
obj.handle_close()
except OSError as e:
- if e.args[0] not in _DISCONNECTED:
+ if e.errno not in _DISCONNECTED:
obj.handle_error()
else:
obj.handle_close()
@@ -236,7 +236,7 @@ class dispatcher:
try:
self.addr = sock.getpeername()
except OSError as err:
- if err.args[0] in (ENOTCONN, EINVAL):
+ if err.errno in (ENOTCONN, EINVAL):
# To handle the case where we got an unconnected
# socket.
self.connected = False
@@ -346,7 +346,7 @@ class dispatcher:
except TypeError:
return None
except OSError as why:
- if why.args[0] in (EWOULDBLOCK, ECONNABORTED, EAGAIN):
+ if why.errno in (EWOULDBLOCK, ECONNABORTED, EAGAIN):
return None
else:
raise
@@ -358,9 +358,9 @@ class dispatcher:
result = self.socket.send(data)
return result
except OSError as why:
- if why.args[0] == EWOULDBLOCK:
+ if why.errno == EWOULDBLOCK:
return 0
- elif why.args[0] in _DISCONNECTED:
+ elif why.errno in _DISCONNECTED:
self.handle_close()
return 0
else:
@@ -378,7 +378,7 @@ class dispatcher:
return data
except OSError as why:
# winsock sometimes raises ENOTCONN
- if why.args[0] in _DISCONNECTED:
+ if why.errno in _DISCONNECTED:
self.handle_close()
return b''
else:
@@ -393,7 +393,7 @@ class dispatcher:
try:
self.socket.close()
except OSError as why:
- if why.args[0] not in (ENOTCONN, EBADF):
+ if why.errno not in (ENOTCONN, EBADF):
raise
# log and log_info may be overridden to provide more sophisticated
@@ -557,7 +557,7 @@ def close_all(map=None, ignore_all=False):
try:
x.close()
except OSError as x:
- if x.args[0] == EBADF:
+ if x.errno == EBADF:
pass
elif not ignore_all:
raise
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 77ab703cc0..6018c36086 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -194,7 +194,7 @@ def parse_multipart(fp, pdict, encoding="utf-8", errors="replace"):
value is a list of values for that field. For non-file fields, the value
is a list of strings.
"""
- # RFC 2026, Section 5.1 : The "multipart" boundary delimiters are always
+ # RFC 2046, Section 5.1 : The "multipart" boundary delimiters are always
# represented as 7bit US-ASCII.
boundary = pdict['boundary'].decode('ascii')
ctype = "multipart/form-data; boundary={}".format(boundary)
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index 5d75501645..9c25a2d278 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -1001,7 +1001,7 @@ class ChainMap(_collections_abc.MutableMapping):
def __iter__(self):
d = {}
for mapping in reversed(self.maps):
- d.update(mapping) # reuses stored hash values if possible
+ d.update(dict.fromkeys(mapping)) # reuses stored hash values if possible
return iter(d)
def __contains__(self, key):
diff --git a/Lib/collections/abc.py b/Lib/collections/abc.py
index 891600d16b..86ca8b8a84 100644
--- a/Lib/collections/abc.py
+++ b/Lib/collections/abc.py
@@ -1,2 +1,3 @@
from _collections_abc import *
from _collections_abc import __all__
+from _collections_abc import _CallableGenericAlias
diff --git a/Lib/colorsys.py b/Lib/colorsys.py
index b93e384406..0f52512a67 100644
--- a/Lib/colorsys.py
+++ b/Lib/colorsys.py
@@ -75,17 +75,18 @@ def yiq_to_rgb(y, i, q):
def rgb_to_hls(r, g, b):
maxc = max(r, g, b)
minc = min(r, g, b)
- # XXX Can optimize (maxc+minc) and (maxc-minc)
- l = (minc+maxc)/2.0
+ sumc = (maxc+minc)
+ rangec = (maxc-minc)
+ l = sumc/2.0
if minc == maxc:
return 0.0, l, 0.0
if l <= 0.5:
- s = (maxc-minc) / (maxc+minc)
+ s = rangec / sumc
else:
- s = (maxc-minc) / (2.0-maxc-minc)
- rc = (maxc-r) / (maxc-minc)
- gc = (maxc-g) / (maxc-minc)
- bc = (maxc-b) / (maxc-minc)
+ s = rangec / (2.0-sumc)
+ rc = (maxc-r) / rangec
+ gc = (maxc-g) / rangec
+ bc = (maxc-b) / rangec
if r == maxc:
h = bc-gc
elif g == maxc:
diff --git a/Lib/contextlib.py b/Lib/contextlib.py
index 82ddc1497d..eb5946145b 100644
--- a/Lib/contextlib.py
+++ b/Lib/contextlib.py
@@ -9,7 +9,7 @@ from types import MethodType, GenericAlias
__all__ = ["asynccontextmanager", "contextmanager", "closing", "nullcontext",
"AbstractContextManager", "AbstractAsyncContextManager",
"AsyncExitStack", "ContextDecorator", "ExitStack",
- "redirect_stdout", "redirect_stderr", "suppress"]
+ "redirect_stdout", "redirect_stderr", "suppress", "aclosing"]
class AbstractContextManager(abc.ABC):
@@ -80,6 +80,22 @@ class ContextDecorator(object):
return inner
+class AsyncContextDecorator(object):
+ "A base class or mixin that enables async context managers to work as decorators."
+
+ def _recreate_cm(self):
+ """Return a recreated instance of self.
+ """
+ return self
+
+ def __call__(self, func):
+ @wraps(func)
+ async def inner(*args, **kwds):
+ async with self._recreate_cm():
+ return await func(*args, **kwds)
+ return inner
+
+
class _GeneratorContextManagerBase:
"""Shared functionality for @contextmanager and @asynccontextmanager."""
@@ -167,9 +183,16 @@ class _GeneratorContextManager(_GeneratorContextManagerBase,
class _AsyncGeneratorContextManager(_GeneratorContextManagerBase,
- AbstractAsyncContextManager):
+ AbstractAsyncContextManager,
+ AsyncContextDecorator):
"""Helper for @asynccontextmanager."""
+ def _recreate_cm(self):
+ # _AGCM instances are one-shot context managers, so the
+ # ACM must be recreated each time a decorated function is
+ # called
+ return self.__class__(self.func, self.args, self.kwds)
+
async def __aenter__(self):
try:
return await self.gen.__anext__()
@@ -681,7 +704,7 @@ class AsyncExitStack(_BaseExitStack, AbstractAsyncContextManager):
return received_exc and suppressed_exc
-class nullcontext(AbstractContextManager):
+class nullcontext(AbstractContextManager, AbstractAsyncContextManager):
"""Context manager that does no additional processing.
Used as a stand-in for a normal context manager, when a particular
@@ -700,3 +723,9 @@ class nullcontext(AbstractContextManager):
def __exit__(self, *excinfo):
pass
+
+ async def __aenter__(self):
+ return self.enter_result
+
+ async def __aexit__(self, *excinfo):
+ pass
diff --git a/Lib/ctypes/macholib/dyld.py b/Lib/ctypes/macholib/dyld.py
index 9d86b05876..1c3f8fd38b 100644
--- a/Lib/ctypes/macholib/dyld.py
+++ b/Lib/ctypes/macholib/dyld.py
@@ -6,6 +6,11 @@ import os
from ctypes.macholib.framework import framework_info
from ctypes.macholib.dylib import dylib_info
from itertools import *
+try:
+ from _ctypes import _dyld_shared_cache_contains_path
+except ImportError:
+ def _dyld_shared_cache_contains_path(*args):
+ raise NotImplementedError
__all__ = [
'dyld_find', 'framework_find',
@@ -122,8 +127,15 @@ def dyld_find(name, executable_path=None, env=None):
dyld_executable_path_search(name, executable_path),
dyld_default_search(name, env),
), env):
+
if os.path.isfile(path):
return path
+ try:
+ if _dyld_shared_cache_contains_path(path):
+ return path
+ except NotImplementedError:
+ pass
+
raise ValueError("dylib %s could not be found" % (name,))
def framework_find(fn, executable_path=None, env=None):
diff --git a/Lib/ctypes/test/test_macholib.py b/Lib/ctypes/test/test_macholib.py
index 6b3526951a..a1bac26a7d 100644
--- a/Lib/ctypes/test/test_macholib.py
+++ b/Lib/ctypes/test/test_macholib.py
@@ -45,19 +45,22 @@ def find_lib(name):
class MachOTest(unittest.TestCase):
@unittest.skipUnless(sys.platform == "darwin", 'OSX-specific test')
def test_find(self):
-
- self.assertEqual(find_lib('pthread'),
- '/usr/lib/libSystem.B.dylib')
+ # On Mac OS 11, system dylibs are only present in the shared cache,
+ # so symlinks like libpthread.dylib -> libSystem.B.dylib will not
+ # be resolved by dyld_find
+ self.assertIn(find_lib('pthread'),
+ ('/usr/lib/libSystem.B.dylib', '/usr/lib/libpthread.dylib'))
result = find_lib('z')
# Issue #21093: dyld default search path includes $HOME/lib and
# /usr/local/lib before /usr/lib, which caused test failures if
# a local copy of libz exists in one of them. Now ignore the head
# of the path.
- self.assertRegex(result, r".*/lib/libz\..*.*\.dylib")
+ self.assertRegex(result, r".*/lib/libz.*\.dylib")
- self.assertEqual(find_lib('IOKit'),
- '/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit')
+ self.assertIn(find_lib('IOKit'),
+ ('/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit',
+ '/System/Library/Frameworks/IOKit.framework/IOKit'))
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/dis.py b/Lib/dis.py
index e289e176c7..ccbd65be73 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -384,7 +384,7 @@ def _disassemble_bytes(code, lasti=-1, varnames=None, names=None,
constants=None, cells=None, linestarts=None,
*, file=None, line_offset=0):
# Omit the line number column entirely if we have no line number info
- show_lineno = linestarts is not None
+ show_lineno = bool(linestarts)
if show_lineno:
maxlineno = max(linestarts.values()) + line_offset
if maxlineno >= 1000:
@@ -449,32 +449,15 @@ def findlabels(code):
def findlinestarts(code):
"""Find the offsets in a byte code which are start of lines in the source.
- Generate pairs (offset, lineno) as described in Python/compile.c.
-
+ Generate pairs (offset, lineno)
"""
- byte_increments = code.co_lnotab[0::2]
- line_increments = code.co_lnotab[1::2]
- bytecode_len = len(code.co_code)
-
- lastlineno = None
- lineno = code.co_firstlineno
- addr = 0
- for byte_incr, line_incr in zip(byte_increments, line_increments):
- if byte_incr:
- if lineno != lastlineno:
- yield (addr, lineno)
- lastlineno = lineno
- addr += byte_incr
- if addr >= bytecode_len:
- # The rest of the lnotab byte offsets are past the end of
- # the bytecode, so the lines were optimized away.
- return
- if line_incr >= 0x80:
- # line_increments is an array of 8-bit signed integers
- line_incr -= 0x100
- lineno += line_incr
- if lineno != lastlineno:
- yield (addr, lineno)
+ lastline = None
+ for start, end, line in code.co_lines():
+ if line is not None and line != lastline:
+ lastline = line
+ yield start, line
+ return
+
class Bytecode:
"""The bytecode operations of a piece of code
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index aaa300efa9..bdead133bd 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -17,7 +17,8 @@ from distutils.errors import DistutilsOptionError
from site import USER_BASE
from site import USER_SITE
-HAS_USER_SITE = True
+
+HAS_USER_SITE = (USER_SITE is not None)
WINDOWS_SCHEME = {
'purelib': '$base/Lib/site-packages',
@@ -169,8 +170,9 @@ class install(Command):
self.install_lib = None # set to either purelib or platlib
self.install_scripts = None
self.install_data = None
- self.install_userbase = USER_BASE
- self.install_usersite = USER_SITE
+ if HAS_USER_SITE:
+ self.install_userbase = USER_BASE
+ self.install_usersite = USER_SITE
self.compile = None
self.optimize = None
@@ -343,8 +345,9 @@ class install(Command):
# Convert directories from Unix /-separated syntax to the local
# convention.
self.convert_paths('lib', 'purelib', 'platlib',
- 'scripts', 'data', 'headers',
- 'userbase', 'usersite')
+ 'scripts', 'data', 'headers')
+ if HAS_USER_SITE:
+ self.convert_paths('userbase', 'usersite')
# Deprecated
# Well, we're not actually fully completely finalized yet: we still
diff --git a/Lib/distutils/spawn.py b/Lib/distutils/spawn.py
index 0d1bd0391e..f50edd2da9 100644
--- a/Lib/distutils/spawn.py
+++ b/Lib/distutils/spawn.py
@@ -54,8 +54,8 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0):
global _cfg_target, _cfg_target_split
if _cfg_target is None:
from distutils import sysconfig
- _cfg_target = sysconfig.get_config_var(
- 'MACOSX_DEPLOYMENT_TARGET') or ''
+ _cfg_target = str(sysconfig.get_config_var(
+ 'MACOSX_DEPLOYMENT_TARGET') or '')
if _cfg_target:
_cfg_target_split = [int(x) for x in _cfg_target.split('.')]
if _cfg_target:
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
index f9e0d766d8..a3055c1984 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -456,7 +456,7 @@ class BuildExtTestCase(TempdirManager,
deptarget = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
if deptarget:
# increment the minor version number (i.e. 10.6 -> 10.7)
- deptarget = [int(x) for x in deptarget.split('.')]
+ deptarget = [int(x) for x in str(deptarget).split('.')]
deptarget[-1] += 1
deptarget = '.'.join(str(i) for i in deptarget)
self._try_compile_deployment_target('<', deptarget)
@@ -489,16 +489,20 @@ class BuildExtTestCase(TempdirManager,
# get the deployment target that the interpreter was built with
target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
- target = tuple(map(int, target.split('.')[0:2]))
+ target = tuple(map(int, str(target).split('.')[0:2]))
# format the target value as defined in the Apple
# Availability Macros. We can't use the macro names since
# at least one value we test with will not exist yet.
- if target[1] < 10:
+ if target[:2] < (10, 10):
# for 10.1 through 10.9.x -> "10n0"
target = '%02d%01d0' % target
else:
# for 10.10 and beyond -> "10nn00"
- target = '%02d%02d00' % target
+ if len(target) >= 2:
+ target = '%02d%02d00' % target
+ else:
+ # 11 and later can have no minor version (11 instead of 11.0)
+ target = '%02d0000' % target
deptarget_ext = Extension(
'deptarget',
[deptarget_c],
diff --git a/Lib/distutils/tests/test_install.py b/Lib/distutils/tests/test_install.py
index 51c80e0421..21a7b7c85c 100644
--- a/Lib/distutils/tests/test_install.py
+++ b/Lib/distutils/tests/test_install.py
@@ -8,7 +8,7 @@ import site
from test.support import captured_stdout, run_unittest
from distutils import sysconfig
-from distutils.command.install import install
+from distutils.command.install import install, HAS_USER_SITE
from distutils.command import install as install_module
from distutils.command.build_ext import build_ext
from distutils.command.install import INSTALL_SCHEMES
@@ -66,6 +66,7 @@ class InstallTestCase(support.TempdirManager,
check_path(cmd.install_scripts, os.path.join(destination, "bin"))
check_path(cmd.install_data, destination)
+ @unittest.skipUnless(HAS_USER_SITE, 'need user site')
def test_user_site(self):
# test install with --user
# preparing the environment for the test
@@ -93,8 +94,9 @@ class InstallTestCase(support.TempdirManager,
self.addCleanup(cleanup)
- for key in ('nt_user', 'unix_user'):
- self.assertIn(key, INSTALL_SCHEMES)
+ if HAS_USER_SITE:
+ for key in ('nt_user', 'unix_user'):
+ self.assertIn(key, INSTALL_SCHEMES)
dist = Distribution({'name': 'xx'})
cmd = install(dist)
diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
index 4d7a6de740..f0792de74a 100644
--- a/Lib/distutils/unixccompiler.py
+++ b/Lib/distutils/unixccompiler.py
@@ -290,7 +290,7 @@ class UnixCCompiler(CCompiler):
cflags = sysconfig.get_config_var('CFLAGS')
m = re.search(r'-isysroot\s*(\S+)', cflags)
if m is None:
- sysroot = '/'
+ sysroot = _osx_support._default_sysroot(sysconfig.get_config_var('CC'))
else:
sysroot = m.group(1)
diff --git a/Lib/doctest.py b/Lib/doctest.py
index baa503c83f..5bb35c9715 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -222,13 +222,17 @@ def _load_testfile(filename, package, module_relative, encoding):
if module_relative:
package = _normalize_module(package, 3)
filename = _module_relative_path(package, filename)
- if getattr(package, '__loader__', None) is not None:
- if hasattr(package.__loader__, 'get_data'):
- file_contents = package.__loader__.get_data(filename)
- file_contents = file_contents.decode(encoding)
- # get_data() opens files as 'rb', so one must do the equivalent
- # conversion as universal newlines would do.
- return _newline_convert(file_contents), filename
+ if (loader := getattr(package, '__loader__', None)) is None:
+ try:
+ loader = package.__spec__.loader
+ except AttributeError:
+ pass
+ if hasattr(loader, 'get_data'):
+ file_contents = loader.get_data(filename)
+ file_contents = file_contents.decode(encoding)
+ # get_data() opens files as 'rb', so one must do the equivalent
+ # conversion as universal newlines would do.
+ return _newline_convert(file_contents), filename
with open(filename, encoding=encoding) as f:
return f.read(), filename
diff --git a/Lib/enum.py b/Lib/enum.py
index 40ff25b9cd..75249bfdc1 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -9,32 +9,63 @@ __all__ = [
]
+class _NoInitSubclass:
+ """
+ temporary base class to suppress calling __init_subclass__
+ """
+ @classmethod
+ def __init_subclass__(cls, **kwds):
+ pass
+
def _is_descriptor(obj):
- """Returns True if obj is a descriptor, False otherwise."""
+ """
+ Returns True if obj is a descriptor, False otherwise.
+ """
return (
hasattr(obj, '__get__') or
hasattr(obj, '__set__') or
- hasattr(obj, '__delete__'))
-
+ hasattr(obj, '__delete__')
+ )
def _is_dunder(name):
- """Returns True if a __dunder__ name, False otherwise."""
- return (len(name) > 4 and
+ """
+ Returns True if a __dunder__ name, False otherwise.
+ """
+ return (
+ len(name) > 4 and
name[:2] == name[-2:] == '__' and
name[2] != '_' and
- name[-3] != '_')
-
+ name[-3] != '_'
+ )
def _is_sunder(name):
- """Returns True if a _sunder_ name, False otherwise."""
- return (len(name) > 2 and
+ """
+ Returns True if a _sunder_ name, False otherwise.
+ """
+ return (
+ len(name) > 2 and
name[0] == name[-1] == '_' and
name[1:2] != '_' and
- name[-2:-1] != '_')
-
+ name[-2:-1] != '_'
+ )
+
+def _is_private(cls_name, name):
+ # do not use `re` as `re` imports `enum`
+ pattern = '_%s__' % (cls_name, )
+ if (
+ len(name) >= 5
+ and name.startswith(pattern)
+ and name[len(pattern)] != '_'
+ and (name[-1] != '_' or name[-2] != '_')
+ ):
+ return True
+ else:
+ return False
def _make_class_unpicklable(cls):
- """Make the given class un-picklable."""
+ """
+ Make the given class un-picklable.
+ """
def _break_on_call_reduce(self, proto):
raise TypeError('%r cannot be pickled' % self)
cls.__reduce_ex__ = _break_on_call_reduce
@@ -49,11 +80,11 @@ class auto:
class _EnumDict(dict):
- """Track enum member order and ensure member names are not reused.
+ """
+ Track enum member order and ensure member names are not reused.
EnumMeta will use the names found in self._member_names as the
enumeration member names.
-
"""
def __init__(self):
super().__init__()
@@ -63,21 +94,26 @@ class _EnumDict(dict):
self._auto_called = False
def __setitem__(self, key, value):
- """Changes anything not dundered or not a descriptor.
+ """
+ Changes anything not dundered or not a descriptor.
If an enum member name is used twice, an error is raised; duplicate
values are not checked for.
Single underscore (sunder) names are reserved.
-
"""
- if _is_sunder(key):
+ if _is_private(self._cls_name, key):
+ # do nothing, name will be a normal attribute
+ pass
+ elif _is_sunder(key):
if key not in (
'_order_', '_create_pseudo_member_',
'_generate_next_value_', '_missing_', '_ignore_',
):
- raise ValueError(f'_sunder_ names, such as "{key}", are '
- 'reserved for future Enum use')
+ raise ValueError(
+ '_sunder_ names, such as %r, are reserved for future Enum use'
+ % (key, )
+ )
if key == '_generate_next_value_':
# check if members already defined as auto()
if self._auto_called:
@@ -91,13 +127,16 @@ class _EnumDict(dict):
self._ignore = value
already = set(value) & set(self._member_names)
if already:
- raise ValueError('_ignore_ cannot specify already set names: %r' % (already, ))
+ raise ValueError(
+ '_ignore_ cannot specify already set names: %r'
+ % (already, )
+ )
elif _is_dunder(key):
if key == '__order__':
key = '_order_'
elif key in self._member_names:
# descriptor overwriting an enum?
- raise TypeError('Attempted to reuse key: %r' % key)
+ raise TypeError('%r already defined as: %r' % (key, self[key]))
elif key in self._ignore:
pass
elif not _is_descriptor(value):
@@ -106,35 +145,54 @@ class _EnumDict(dict):
raise TypeError('%r already defined as: %r' % (key, self[key]))
if isinstance(value, auto):
if value.value == _auto_null:
- value.value = self._generate_next_value(key, 1, len(self._member_names), self._last_values[:])
+ value.value = self._generate_next_value(
+ key,
+ 1,
+ len(self._member_names),
+ self._last_values[:],
+ )
self._auto_called = True
value = value.value
self._member_names.append(key)
self._last_values.append(value)
super().__setitem__(key, value)
+ def update(self, members, **more_members):
+ try:
+ for name in members.keys():
+ self[name] = members[name]
+ except AttributeError:
+ for name, value in members:
+ self[name] = value
+ for name, value in more_members.items():
+ self[name] = value
+
# Dummy value for Enum as EnumMeta explicitly checks for it, but of course
# until EnumMeta finishes running the first time the Enum class doesn't exist.
# This is also why there are checks in EnumMeta like `if Enum is not None`
Enum = None
-
class EnumMeta(type):
- """Metaclass for Enum"""
+ """
+ Metaclass for Enum
+ """
@classmethod
- def __prepare__(metacls, cls, bases):
+ def __prepare__(metacls, cls, bases, **kwds):
# check that previous enum members do not exist
metacls._check_for_existing_members(cls, bases)
# create the namespace dict
enum_dict = _EnumDict()
+ enum_dict._cls_name = cls
# inherit previous flags and _generate_next_value_ function
member_type, first_enum = metacls._get_mixins_(cls, bases)
if first_enum is not None:
- enum_dict['_generate_next_value_'] = getattr(first_enum, '_generate_next_value_', None)
+ enum_dict['_generate_next_value_'] = getattr(
+ first_enum, '_generate_next_value_', None,
+ )
return enum_dict
- def __new__(metacls, cls, bases, classdict):
+ def __new__(metacls, cls, bases, classdict, **kwds):
# an Enum class is final once enumeration items have been defined; it
# cannot be mixed with other types (int, float, etc.) if it has an
# inherited __new__ unless a new __new__ is defined (or the resulting
@@ -146,8 +204,9 @@ class EnumMeta(type):
for key in ignore:
classdict.pop(key, None)
member_type, first_enum = metacls._get_mixins_(cls, bases)
- __new__, save_new, use_args = metacls._find_new_(classdict, member_type,
- first_enum)
+ __new__, save_new, use_args = metacls._find_new_(
+ classdict, member_type, first_enum,
+ )
# save enum items into separate mapping so they don't get baked into
# the new class
@@ -168,17 +227,33 @@ class EnumMeta(type):
if '__doc__' not in classdict:
classdict['__doc__'] = 'An enumeration.'
+ # postpone calling __init_subclass__
+ if '__init_subclass__' in classdict and classdict['__init_subclass__'] is None:
+ raise TypeError('%s.__init_subclass__ cannot be None')
+ # remove current __init_subclass__ so previous one can be found with getattr
+ new_init_subclass = classdict.pop('__init_subclass__', None)
# create our new Enum type
- enum_class = super().__new__(metacls, cls, bases, classdict)
+ if bases:
+ bases = (_NoInitSubclass, ) + bases
+ enum_class = super().__new__(metacls, cls, bases, classdict, **kwds)
+ enum_class.__bases__ = enum_class.__bases__[1:] #or (object, )
+ else:
+ enum_class = super().__new__(metacls, cls, bases, classdict, **kwds)
+ old_init_subclass = getattr(enum_class, '__init_subclass__', None)
+ # and restore the new one (if there was one)
+ if new_init_subclass is not None:
+ enum_class.__init_subclass__ = classmethod(new_init_subclass)
enum_class._member_names_ = [] # names in definition order
enum_class._member_map_ = {} # name->value map
enum_class._member_type_ = member_type
# save DynamicClassAttribute attributes from super classes so we know
# if we can take the shortcut of storing members in the class dict
- dynamic_attributes = {k for c in enum_class.mro()
- for k, v in c.__dict__.items()
- if isinstance(v, DynamicClassAttribute)}
+ dynamic_attributes = {
+ k for c in enum_class.mro()
+ for k, v in c.__dict__.items()
+ if isinstance(v, DynamicClassAttribute)
+ }
# Reverse value->name map for hashable values.
enum_class._value2member_map_ = {}
@@ -279,6 +354,9 @@ class EnumMeta(type):
if _order_ != enum_class._member_names_:
raise TypeError('member order does not match _order_')
+ # finally, call parents' __init_subclass__
+ if Enum is not None and old_init_subclass is not None:
+ old_init_subclass(**kwds)
return enum_class
def __bool__(self):
@@ -288,7 +366,8 @@ class EnumMeta(type):
return True
def __call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1):
- """Either returns an existing member, or creates a new enum class.
+ """
+ Either returns an existing member, or creates a new enum class.
This method is used both when an enum class is given a value to match
to an enumeration member (i.e. Color(3)) and for the functional API
@@ -310,12 +389,18 @@ class EnumMeta(type):
not correct, unpickling will fail in some circumstances.
`type`, if set, will be mixed in as the first base class.
-
"""
if names is None: # simple value lookup
return cls.__new__(cls, value)
# otherwise, functional API: we're creating a new Enum type
- return cls._create_(value, names, module=module, qualname=qualname, type=type, start=start)
+ return cls._create_(
+ value,
+ names,
+ module=module,
+ qualname=qualname,
+ type=type,
+ start=start,
+ )
def __contains__(cls, member):
if not isinstance(member, Enum):
@@ -328,22 +413,23 @@ class EnumMeta(type):
# nicer error message when someone tries to delete an attribute
# (see issue19025).
if attr in cls._member_map_:
- raise AttributeError(
- "%s: cannot delete Enum member." % cls.__name__)
+ raise AttributeError("%s: cannot delete Enum member %r." % (cls.__name__, attr))
super().__delattr__(attr)
def __dir__(self):
- return (['__class__', '__doc__', '__members__', '__module__'] +
- self._member_names_)
+ return (
+ ['__class__', '__doc__', '__members__', '__module__']
+ + self._member_names_
+ )
def __getattr__(cls, name):
- """Return the enum member matching `name`
+ """
+ Return the enum member matching `name`
We use __getattr__ instead of descriptors or inserting into the enum
class' __dict__ in order to support `name` and `value` being both
properties for enum members (which live in the class' __dict__) and
enum members themselves.
-
"""
if _is_dunder(name):
raise AttributeError(name)
@@ -356,6 +442,9 @@ class EnumMeta(type):
return cls._member_map_[name]
def __iter__(cls):
+ """
+ Returns members in definition order.
+ """
return (cls._member_map_[name] for name in cls._member_names_)
def __len__(cls):
@@ -363,11 +452,11 @@ class EnumMeta(type):
@property
def __members__(cls):
- """Returns a mapping of member name->value.
+ """
+ Returns a mapping of member name->value.
This mapping lists all enum members, including aliases. Note that this
is a read-only view of the internal mapping.
-
"""
return MappingProxyType(cls._member_map_)
@@ -375,15 +464,18 @@ class EnumMeta(type):
return "<enum %r>" % cls.__name__
def __reversed__(cls):
+ """
+ Returns members in reverse definition order.
+ """
return (cls._member_map_[name] for name in reversed(cls._member_names_))
def __setattr__(cls, name, value):
- """Block attempts to reassign Enum members.
+ """
+ Block attempts to reassign Enum members.
A simple assignment to the class namespace only changes one of the
several possible ways to get an Enum member from the Enum class,
resulting in an inconsistent Enumeration.
-
"""
member_map = cls.__dict__.get('_member_map_', {})
if name in member_map:
@@ -391,7 +483,8 @@ class EnumMeta(type):
super().__setattr__(name, value)
def _create_(cls, class_name, names, *, module=None, qualname=None, type=None, start=1):
- """Convenience method to create a new Enum class.
+ """
+ Convenience method to create a new Enum class.
`names` can be:
@@ -400,7 +493,6 @@ class EnumMeta(type):
* An iterable of member names. Values are incremented by 1 from `start`.
* An iterable of (member name, value) pairs.
* A mapping of member name -> value pairs.
-
"""
metacls = cls.__class__
bases = (cls, ) if type is None else (type, cls)
@@ -481,15 +573,18 @@ class EnumMeta(type):
for chain in bases:
for base in chain.__mro__:
if issubclass(base, Enum) and base._member_names_:
- raise TypeError("%s: cannot extend enumeration %r" % (class_name, base.__name__))
+ raise TypeError(
+ "%s: cannot extend enumeration %r"
+ % (class_name, base.__name__)
+ )
@staticmethod
def _get_mixins_(class_name, bases):
- """Returns the type for creating enum members, and the first inherited
+ """
+ Returns the type for creating enum members, and the first inherited
enum class.
bases: the tuple of bases that was given to __new__
-
"""
if not bases:
return object, Enum
@@ -501,12 +596,16 @@ class EnumMeta(type):
for base in chain.__mro__:
if base is object:
continue
+ elif issubclass(base, Enum):
+ if base._member_type_ is not object:
+ data_types.append(base._member_type_)
+ break
elif '__new__' in base.__dict__:
if issubclass(base, Enum):
continue
data_types.append(candidate or base)
break
- elif not issubclass(base, Enum):
+ else:
candidate = base
if len(data_types) > 1:
raise TypeError('%r: too many data types: %r' % (class_name, data_types))
@@ -528,12 +627,12 @@ class EnumMeta(type):
@staticmethod
def _find_new_(classdict, member_type, first_enum):
- """Returns the __new__ to be used for creating the enum members.
+ """
+ Returns the __new__ to be used for creating the enum members.
classdict: the class dictionary given to __new__
member_type: the data type whose __new__ will be used by default
first_enum: enumeration to check for an overriding __new__
-
"""
# now find the correct __new__, checking to see of one was defined
# by the user; also check earlier enum classes in case a __new__ was
@@ -573,10 +672,10 @@ class EnumMeta(type):
class Enum(metaclass=EnumMeta):
- """Generic enumeration.
+ """
+ Generic enumeration.
Derive from this class to define new enumerations.
-
"""
def __new__(cls, value):
# all enum instances are actually created during class construction
@@ -619,6 +718,14 @@ class Enum(metaclass=EnumMeta):
raise exc
def _generate_next_value_(name, start, count, last_values):
+ """
+ Generate the next value when not given.
+
+ name: the name of the member
+ start: the initial start value or None
+ count: the number of existing members
+ last_value: the last value assigned or None
+ """
for last_value in reversed(last_values):
try:
return last_value + 1
@@ -627,6 +734,9 @@ class Enum(metaclass=EnumMeta):
else:
return start
+ def __init_subclass__(cls, **kwds):
+ super().__init_subclass__(**kwds)
+
@classmethod
def _missing_(cls, value):
return None
@@ -639,6 +749,9 @@ class Enum(metaclass=EnumMeta):
return "%s.%s" % (self.__class__.__name__, self._name_)
def __dir__(self):
+ """
+ Returns all members and all public methods
+ """
added_behavior = [
m
for cls in self.__class__.mro()
@@ -648,12 +761,15 @@ class Enum(metaclass=EnumMeta):
return (['__class__', '__doc__', '__module__'] + added_behavior)
def __format__(self, format_spec):
+ """
+ Returns format using actual value type unless __str__ has been overridden.
+ """
# mixed-in Enums should use the mixed-in type's __format__, otherwise
# we can get strange results with the Enum name showing up instead of
# the value
# pure Enum branch, or branch with __str__ explicitly overridden
- str_overridden = type(self).__str__ != Enum.__str__
+ str_overridden = type(self).__str__ not in (Enum.__str__, Flag.__str__)
if self._member_type_ is object or str_overridden:
cls = str
val = str(self)
@@ -720,12 +836,20 @@ class StrEnum(str, Enum):
__str__ = str.__str__
+ def _generate_next_value_(name, start, count, last_values):
+ """
+ Return the lower-cased version of the member name.
+ """
+ return name.lower()
+
def _reduce_ex_by_name(self, proto):
return self.name
class Flag(Enum):
- """Support for flags"""
+ """
+ Support for flags
+ """
def _generate_next_value_(name, start, count, last_values):
"""
@@ -748,6 +872,9 @@ class Flag(Enum):
@classmethod
def _missing_(cls, value):
+ """
+ Returns member (possibly creating it) if one can be found for value.
+ """
original_value = value
if value < 0:
value = ~value
@@ -777,6 +904,9 @@ class Flag(Enum):
return pseudo_member
def __contains__(self, other):
+ """
+ Returns True if self has at least the same flags set as other.
+ """
if not isinstance(other, self.__class__):
raise TypeError(
"unsupported operand type(s) for 'in': '%s' and '%s'" % (
@@ -784,6 +914,9 @@ class Flag(Enum):
return other._value_ & self._value_ == other._value_
def __iter__(self):
+ """
+ Returns flags in decreasing value order.
+ """
members, extra_flags = _decompose(self.__class__, self.value)
return (m for m in members if m._value_ != 0)
@@ -839,10 +972,15 @@ class Flag(Enum):
class IntFlag(int, Flag):
- """Support for integer-based Flags"""
+ """
+ Support for integer-based Flags
+ """
@classmethod
def _missing_(cls, value):
+ """
+ Returns member (possibly creating it) if one can be found for value.
+ """
if not isinstance(value, int):
raise ValueError("%r is not a valid %s" % (value, cls.__qualname__))
new_member = cls._create_pseudo_member_(value)
@@ -850,6 +988,9 @@ class IntFlag(int, Flag):
@classmethod
def _create_pseudo_member_(cls, value):
+ """
+ Create a composite member iff value contains only members.
+ """
pseudo_member = cls._value2member_map_.get(value, None)
if pseudo_member is None:
need_to_create = [value]
@@ -904,11 +1045,15 @@ class IntFlag(int, Flag):
def _high_bit(value):
- """returns index of highest bit, or -1 if value is zero or negative"""
+ """
+ returns index of highest bit, or -1 if value is zero or negative
+ """
return value.bit_length() - 1
def unique(enumeration):
- """Class decorator for enumerations ensuring unique member values."""
+ """
+ Class decorator for enumerations ensuring unique member values.
+ """
duplicates = []
for name, member in enumeration.__members__.items():
if name != member.name:
@@ -921,7 +1066,9 @@ def unique(enumeration):
return enumeration
def _decompose(flag, value):
- """Extract all members from the value."""
+ """
+ Extract all members from the value.
+ """
# _decompose is only called if the value is not named
not_covered = value
negative = value < 0
diff --git a/Lib/filecmp.py b/Lib/filecmp.py
index 7a4da6beb5..7c47eb022c 100644
--- a/Lib/filecmp.py
+++ b/Lib/filecmp.py
@@ -115,7 +115,9 @@ class dircmp:
same_files: list of identical files.
diff_files: list of filenames which differ.
funny_files: list of files which could not be compared.
- subdirs: a dictionary of dircmp objects, keyed by names in common_dirs.
+ subdirs: a dictionary of dircmp instances (or MyDirCmp instances if this
+ object is of type MyDirCmp, a subclass of dircmp), keyed by names
+ in common_dirs.
"""
def __init__(self, a, b, ignore=None, hide=None): # Initialize
@@ -185,14 +187,15 @@ class dircmp:
self.same_files, self.diff_files, self.funny_files = xx
def phase4(self): # Find out differences between common subdirectories
- # A new dircmp object is created for each common subdirectory,
+ # A new dircmp (or MyDirCmp if dircmp was subclassed) object is created
+ # for each common subdirectory,
# these are stored in a dictionary indexed by filename.
# The hide and ignore properties are inherited from the parent
self.subdirs = {}
for x in self.common_dirs:
a_x = os.path.join(self.left, x)
b_x = os.path.join(self.right, x)
- self.subdirs[x] = dircmp(a_x, b_x, self.ignore, self.hide)
+ self.subdirs[x] = self.__class__(a_x, b_x, self.ignore, self.hide)
def phase4_closure(self): # Recursively call phase4() on subdirectories
self.phase4()
diff --git a/Lib/fnmatch.py b/Lib/fnmatch.py
index 0eb1802bdb..7c52c23067 100644
--- a/Lib/fnmatch.py
+++ b/Lib/fnmatch.py
@@ -52,7 +52,7 @@ def _compile_pattern(pat):
return re.compile(res).match
def filter(names, pat):
- """Return the subset of the list NAMES that match PAT."""
+ """Construct a list from those elements of the iterable NAMES that match PAT."""
result = []
pat = os.path.normcase(pat)
match = _compile_pattern(pat)
diff --git a/Lib/formatter.py b/Lib/formatter.py
deleted file mode 100644
index e2394de8c2..0000000000
--- a/Lib/formatter.py
+++ /dev/null
@@ -1,452 +0,0 @@
-"""Generic output formatting.
-
-Formatter objects transform an abstract flow of formatting events into
-specific output events on writer objects. Formatters manage several stack
-structures to allow various properties of a writer object to be changed and
-restored; writers need not be able to handle relative changes nor any sort
-of ``change back'' operation. Specific writer properties which may be
-controlled via formatter objects are horizontal alignment, font, and left
-margin indentations. A mechanism is provided which supports providing
-arbitrary, non-exclusive style settings to a writer as well. Additional
-interfaces facilitate formatting events which are not reversible, such as
-paragraph separation.
-
-Writer objects encapsulate device interfaces. Abstract devices, such as
-file formats, are supported as well as physical devices. The provided
-implementations all work with abstract devices. The interface makes
-available mechanisms for setting the properties which formatter objects
-manage and inserting data into the output.
-"""
-
-import sys
-import warnings
-warnings.warn('the formatter module is deprecated', DeprecationWarning,
- stacklevel=2)
-
-
-AS_IS = None
-
-
-class NullFormatter:
- """A formatter which does nothing.
-
- If the writer parameter is omitted, a NullWriter instance is created.
- No methods of the writer are called by NullFormatter instances.
-
- Implementations should inherit from this class if implementing a writer
- interface but don't need to inherit any implementation.
-
- """
-
- def __init__(self, writer=None):
- if writer is None:
- writer = NullWriter()
- self.writer = writer
- def end_paragraph(self, blankline): pass
- def add_line_break(self): pass
- def add_hor_rule(self, *args, **kw): pass
- def add_label_data(self, format, counter, blankline=None): pass
- def add_flowing_data(self, data): pass
- def add_literal_data(self, data): pass
- def flush_softspace(self): pass
- def push_alignment(self, align): pass
- def pop_alignment(self): pass
- def push_font(self, x): pass
- def pop_font(self): pass
- def push_margin(self, margin): pass
- def pop_margin(self): pass
- def set_spacing(self, spacing): pass
- def push_style(self, *styles): pass
- def pop_style(self, n=1): pass
- def assert_line_data(self, flag=1): pass
-
-
-class AbstractFormatter:
- """The standard formatter.
-
- This implementation has demonstrated wide applicability to many writers,
- and may be used directly in most circumstances. It has been used to
- implement a full-featured World Wide Web browser.
-
- """
-
- # Space handling policy: blank spaces at the boundary between elements
- # are handled by the outermost context. "Literal" data is not checked
- # to determine context, so spaces in literal data are handled directly
- # in all circumstances.
-
- def __init__(self, writer):
- self.writer = writer # Output device
- self.align = None # Current alignment
- self.align_stack = [] # Alignment stack
- self.font_stack = [] # Font state
- self.margin_stack = [] # Margin state
- self.spacing = None # Vertical spacing state
- self.style_stack = [] # Other state, e.g. color
- self.nospace = 1 # Should leading space be suppressed
- self.softspace = 0 # Should a space be inserted
- self.para_end = 1 # Just ended a paragraph
- self.parskip = 0 # Skipped space between paragraphs?
- self.hard_break = 1 # Have a hard break
- self.have_label = 0
-
- def end_paragraph(self, blankline):
- if not self.hard_break:
- self.writer.send_line_break()
- self.have_label = 0
- if self.parskip < blankline and not self.have_label:
- self.writer.send_paragraph(blankline - self.parskip)
- self.parskip = blankline
- self.have_label = 0
- self.hard_break = self.nospace = self.para_end = 1
- self.softspace = 0
-
- def add_line_break(self):
- if not (self.hard_break or self.para_end):
- self.writer.send_line_break()
- self.have_label = self.parskip = 0
- self.hard_break = self.nospace = 1
- self.softspace = 0
-
- def add_hor_rule(self, *args, **kw):
- if not self.hard_break:
- self.writer.send_line_break()
- self.writer.send_hor_rule(*args, **kw)
- self.hard_break = self.nospace = 1
- self.have_label = self.para_end = self.softspace = self.parskip = 0
-
- def add_label_data(self, format, counter, blankline = None):
- if self.have_label or not self.hard_break:
- self.writer.send_line_break()
- if not self.para_end:
- self.writer.send_paragraph((blankline and 1) or 0)
- if isinstance(format, str):
- self.writer.send_label_data(self.format_counter(format, counter))
- else:
- self.writer.send_label_data(format)
- self.nospace = self.have_label = self.hard_break = self.para_end = 1
- self.softspace = self.parskip = 0
-
- def format_counter(self, format, counter):
- label = ''
- for c in format:
- if c == '1':
- label = label + ('%d' % counter)
- elif c in 'aA':
- if counter > 0:
- label = label + self.format_letter(c, counter)
- elif c in 'iI':
- if counter > 0:
- label = label + self.format_roman(c, counter)
- else:
- label = label + c
- return label
-
- def format_letter(self, case, counter):
- label = ''
- while counter > 0:
- counter, x = divmod(counter-1, 26)
- # This makes a strong assumption that lowercase letters
- # and uppercase letters form two contiguous blocks, with
- # letters in order!
- s = chr(ord(case) + x)
- label = s + label
- return label
-
- def format_roman(self, case, counter):
- ones = ['i', 'x', 'c', 'm']
- fives = ['v', 'l', 'd']
- label, index = '', 0
- # This will die of IndexError when counter is too big
- while counter > 0:
- counter, x = divmod(counter, 10)
- if x == 9:
- label = ones[index] + ones[index+1] + label
- elif x == 4:
- label = ones[index] + fives[index] + label
- else:
- if x >= 5:
- s = fives[index]
- x = x-5
- else:
- s = ''
- s = s + ones[index]*x
- label = s + label
- index = index + 1
- if case == 'I':
- return label.upper()
- return label
-
- def add_flowing_data(self, data):
- if not data: return
- prespace = data[:1].isspace()
- postspace = data[-1:].isspace()
- data = " ".join(data.split())
- if self.nospace and not data:
- return
- elif prespace or self.softspace:
- if not data:
- if not self.nospace:
- self.softspace = 1
- self.parskip = 0
- return
- if not self.nospace:
- data = ' ' + data
- self.hard_break = self.nospace = self.para_end = \
- self.parskip = self.have_label = 0
- self.softspace = postspace
- self.writer.send_flowing_data(data)
-
- def add_literal_data(self, data):
- if not data: return
- if self.softspace:
- self.writer.send_flowing_data(" ")
- self.hard_break = data[-1:] == '\n'
- self.nospace = self.para_end = self.softspace = \
- self.parskip = self.have_label = 0
- self.writer.send_literal_data(data)
-
- def flush_softspace(self):
- if self.softspace:
- self.hard_break = self.para_end = self.parskip = \
- self.have_label = self.softspace = 0
- self.nospace = 1
- self.writer.send_flowing_data(' ')
-
- def push_alignment(self, align):
- if align and align != self.align:
- self.writer.new_alignment(align)
- self.align = align
- self.align_stack.append(align)
- else:
- self.align_stack.append(self.align)
-
- def pop_alignment(self):
- if self.align_stack:
- del self.align_stack[-1]
- if self.align_stack:
- self.align = align = self.align_stack[-1]
- self.writer.new_alignment(align)
- else:
- self.align = None
- self.writer.new_alignment(None)
-
- def push_font(self, font):
- size, i, b, tt = font
- if self.softspace:
- self.hard_break = self.para_end = self.softspace = 0
- self.nospace = 1
- self.writer.send_flowing_data(' ')
- if self.font_stack:
- csize, ci, cb, ctt = self.font_stack[-1]
- if size is AS_IS: size = csize
- if i is AS_IS: i = ci
- if b is AS_IS: b = cb
- if tt is AS_IS: tt = ctt
- font = (size, i, b, tt)
- self.font_stack.append(font)
- self.writer.new_font(font)
-
- def pop_font(self):
- if self.font_stack:
- del self.font_stack[-1]
- if self.font_stack:
- font = self.font_stack[-1]
- else:
- font = None
- self.writer.new_font(font)
-
- def push_margin(self, margin):
- self.margin_stack.append(margin)
- fstack = [m for m in self.margin_stack if m]
- if not margin and fstack:
- margin = fstack[-1]
- self.writer.new_margin(margin, len(fstack))
-
- def pop_margin(self):
- if self.margin_stack:
- del self.margin_stack[-1]
- fstack = [m for m in self.margin_stack if m]
- if fstack:
- margin = fstack[-1]
- else:
- margin = None
- self.writer.new_margin(margin, len(fstack))
-
- def set_spacing(self, spacing):
- self.spacing = spacing
- self.writer.new_spacing(spacing)
-
- def push_style(self, *styles):
- if self.softspace:
- self.hard_break = self.para_end = self.softspace = 0
- self.nospace = 1
- self.writer.send_flowing_data(' ')
- for style in styles:
- self.style_stack.append(style)
- self.writer.new_styles(tuple(self.style_stack))
-
- def pop_style(self, n=1):
- del self.style_stack[-n:]
- self.writer.new_styles(tuple(self.style_stack))
-
- def assert_line_data(self, flag=1):
- self.nospace = self.hard_break = not flag
- self.para_end = self.parskip = self.have_label = 0
-
-
-class NullWriter:
- """Minimal writer interface to use in testing & inheritance.
-
- A writer which only provides the interface definition; no actions are
- taken on any methods. This should be the base class for all writers
- which do not need to inherit any implementation methods.
-
- """
- def __init__(self): pass
- def flush(self): pass
- def new_alignment(self, align): pass
- def new_font(self, font): pass
- def new_margin(self, margin, level): pass
- def new_spacing(self, spacing): pass
- def new_styles(self, styles): pass
- def send_paragraph(self, blankline): pass
- def send_line_break(self): pass
- def send_hor_rule(self, *args, **kw): pass
- def send_label_data(self, data): pass
- def send_flowing_data(self, data): pass
- def send_literal_data(self, data): pass
-
-
-class AbstractWriter(NullWriter):
- """A writer which can be used in debugging formatters, but not much else.
-
- Each method simply announces itself by printing its name and
- arguments on standard output.
-
- """
-
- def new_alignment(self, align):
- print("new_alignment(%r)" % (align,))
-
- def new_font(self, font):
- print("new_font(%r)" % (font,))
-
- def new_margin(self, margin, level):
- print("new_margin(%r, %d)" % (margin, level))
-
- def new_spacing(self, spacing):
- print("new_spacing(%r)" % (spacing,))
-
- def new_styles(self, styles):
- print("new_styles(%r)" % (styles,))
-
- def send_paragraph(self, blankline):
- print("send_paragraph(%r)" % (blankline,))
-
- def send_line_break(self):
- print("send_line_break()")
-
- def send_hor_rule(self, *args, **kw):
- print("send_hor_rule()")
-
- def send_label_data(self, data):
- print("send_label_data(%r)" % (data,))
-
- def send_flowing_data(self, data):
- print("send_flowing_data(%r)" % (data,))
-
- def send_literal_data(self, data):
- print("send_literal_data(%r)" % (data,))
-
-
-class DumbWriter(NullWriter):
- """Simple writer class which writes output on the file object passed in
- as the file parameter or, if file is omitted, on standard output. The
- output is simply word-wrapped to the number of columns specified by
- the maxcol parameter. This class is suitable for reflowing a sequence
- of paragraphs.
-
- """
-
- def __init__(self, file=None, maxcol=72):
- self.file = file or sys.stdout
- self.maxcol = maxcol
- NullWriter.__init__(self)
- self.reset()
-
- def reset(self):
- self.col = 0
- self.atbreak = 0
-
- def send_paragraph(self, blankline):
- self.file.write('\n'*blankline)
- self.col = 0
- self.atbreak = 0
-
- def send_line_break(self):
- self.file.write('\n')
- self.col = 0
- self.atbreak = 0
-
- def send_hor_rule(self, *args, **kw):
- self.file.write('\n')
- self.file.write('-'*self.maxcol)
- self.file.write('\n')
- self.col = 0
- self.atbreak = 0
-
- def send_literal_data(self, data):
- self.file.write(data)
- i = data.rfind('\n')
- if i >= 0:
- self.col = 0
- data = data[i+1:]
- data = data.expandtabs()
- self.col = self.col + len(data)
- self.atbreak = 0
-
- def send_flowing_data(self, data):
- if not data: return
- atbreak = self.atbreak or data[0].isspace()
- col = self.col
- maxcol = self.maxcol
- write = self.file.write
- for word in data.split():
- if atbreak:
- if col + len(word) >= maxcol:
- write('\n')
- col = 0
- else:
- write(' ')
- col = col + 1
- write(word)
- col = col + len(word)
- atbreak = 1
- self.col = col
- self.atbreak = data[-1].isspace()
-
-
-def test(file = None):
- w = DumbWriter()
- f = AbstractFormatter(w)
- if file is not None:
- fp = open(file)
- elif sys.argv[1:]:
- fp = open(sys.argv[1])
- else:
- fp = sys.stdin
- try:
- for line in fp:
- if line == '\n':
- f.end_paragraph(1)
- else:
- f.add_flowing_data(line)
- finally:
- if fp is not sys.stdin:
- fp.close()
- f.end_paragraph(0)
-
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/http/client.py b/Lib/http/client.py
index 15abcfeada..4eca93ef26 100644
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -861,7 +861,7 @@ class HTTPConnection:
the endpoint passed to `set_tunnel`. This done by sending an HTTP
CONNECT request to the proxy server when the connection is established.
- This method must be called before the HTML connection has been
+ This method must be called before the HTTP connection has been
established.
The headers argument should be a mapping of extra HTTP headers to send
@@ -1407,6 +1407,9 @@ else:
self.cert_file = cert_file
if context is None:
context = ssl._create_default_https_context()
+ # send ALPN extension to indicate HTTP/1.1 protocol
+ if self._http_vsn == 11:
+ context.set_alpn_protocols(['http/1.1'])
# enable PHA for TLS 1.3 connections if available
if context.post_handshake_auth is not None:
context.post_handshake_auth = True
diff --git a/Lib/http/server.py b/Lib/http/server.py
index fa204fbc15..94f730ed34 100644
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -414,7 +414,7 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
method = getattr(self, mname)
method()
self.wfile.flush() #actually send the response if not already done.
- except socket.timeout as e:
+ except TimeoutError as e:
#a read or a write timed out. Discard this connection
self.log_error("Request timed out: %r", e)
self.close_connection = True
@@ -1092,8 +1092,7 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
env['PATH_INFO'] = uqrest
env['PATH_TRANSLATED'] = self.translate_path(uqrest)
env['SCRIPT_NAME'] = scriptname
- if query:
- env['QUERY_STRING'] = query
+ env['QUERY_STRING'] = query
env['REMOTE_ADDR'] = self.client_address[0]
authorization = self.headers.get("authorization")
if authorization:
@@ -1123,12 +1122,7 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
referer = self.headers.get('referer')
if referer:
env['HTTP_REFERER'] = referer
- accept = []
- for line in self.headers.getallmatchingheaders('accept'):
- if line[:1] in "\t\n\r ":
- accept.append(line.strip())
- else:
- accept = accept + line[7:].split(',')
+ accept = self.headers.get_all('accept', ())
env['HTTP_ACCEPT'] = ','.join(accept)
ua = self.headers.get('user-agent')
if ua:
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 3ece623b3a..7167314ca7 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -3,6 +3,15 @@ Released on 2021-10-04?
======================================
+bpo-42508: Keep IDLE running on macOS. Remove obsolete workaround
+that prevented running files with shortcuts when using new universal2
+installers built on macOS 11.
+
+bpo-42426: Fix reporting offset of the RE error in searchengine.
+
+bpo-42416: Get docstrings for IDLE calltips more often
+by using inspect.getdoc.
+
bpo-33987: Mostly finish using ttk widgets, mainly for editor,
settings, and searches. Some patches by Mark Roseman.
diff --git a/Lib/idlelib/calltip.py b/Lib/idlelib/calltip.py
index 549e224015..40bc5a0ad7 100644
--- a/Lib/idlelib/calltip.py
+++ b/Lib/idlelib/calltip.py
@@ -165,6 +165,7 @@ def get_argspec(ob):
ob_call = ob.__call__
except BaseException: # Buggy user object could raise anything.
return '' # No popup for non-callables.
+ # For Get_argspecTest.test_buggy_getattr_class, CallA() & CallB().
fob = ob_call if isinstance(ob_call, types.MethodType) else ob
# Initialize argspec and wrap it to get lines.
@@ -185,10 +186,7 @@ def get_argspec(ob):
if len(argspec) > _MAX_COLS else [argspec] if argspec else [])
# Augment lines from docstring, if any, and join to get argspec.
- if isinstance(ob_call, types.MethodType):
- doc = ob_call.__doc__
- else:
- doc = getattr(ob, "__doc__", "")
+ doc = inspect.getdoc(ob)
if doc:
for line in doc.split('\n', _MAX_LINES)[:_MAX_LINES]:
line = line.strip()
diff --git a/Lib/idlelib/codecontext.py b/Lib/idlelib/codecontext.py
index 989b30e599..eb19773f56 100644
--- a/Lib/idlelib/codecontext.py
+++ b/Lib/idlelib/codecontext.py
@@ -7,11 +7,14 @@ the lines which contain the block opening keywords, e.g. 'if', for the
enclosing block. The number of hint lines is determined by the maxlines
variable in the codecontext section of config-extensions.def. Lines which do
not open blocks are not shown in the context hints pane.
+
+For EditorWindows, <<toggle-code-context>> is bound to CodeContext(self).
+toggle_code_context_event.
"""
import re
from sys import maxsize as INFINITY
-import tkinter
+from tkinter import Frame, Text, TclError
from tkinter.constants import NSEW, SUNKEN
from idlelib.config import idleConf
@@ -83,7 +86,7 @@ class CodeContext:
if self.t1 is not None:
try:
self.text.after_cancel(self.t1)
- except tkinter.TclError: # pragma: no cover
+ except TclError: # pragma: no cover
pass
self.t1 = None
@@ -111,7 +114,7 @@ class CodeContext:
padx += widget.tk.getint(info['padx'])
padx += widget.tk.getint(widget.cget('padx'))
border += widget.tk.getint(widget.cget('border'))
- context = self.context = tkinter.Text(
+ context = self.context = Text(
self.editwin.text_frame,
height=1,
width=1, # Don't request more than we get.
@@ -127,7 +130,7 @@ class CodeContext:
line_number_colors = idleConf.GetHighlight(idleConf.CurrentTheme(),
'linenumber')
- self.cell00 = tkinter.Frame(self.editwin.text_frame,
+ self.cell00 = Frame(self.editwin.text_frame,
bg=line_number_colors['background'])
self.cell00.grid(row=0, column=0, sticky=NSEW)
menu_status = 'Hide'
@@ -221,7 +224,7 @@ class CodeContext:
"""
try:
self.context.index("sel.first")
- except tkinter.TclError:
+ except TclError:
lines = len(self.info)
if lines == 1: # No context lines are showing.
newtop = 1
diff --git a/Lib/idlelib/idle_test/test_calltip.py b/Lib/idlelib/idle_test/test_calltip.py
index 489b6899ba..a76829f365 100644
--- a/Lib/idlelib/idle_test/test_calltip.py
+++ b/Lib/idlelib/idle_test/test_calltip.py
@@ -99,7 +99,12 @@ non-overlapping occurrences o...''')
(width=70, initial_indent='', subsequent_indent='', expand_tabs=True,
replace_whitespace=True, fix_sentence_endings=False, break_long_words=True,
drop_whitespace=True, break_on_hyphens=True, tabsize=8, *, max_lines=None,
- placeholder=' [...]')''')
+ placeholder=' [...]')
+Object for wrapping/filling text. The public interface consists of
+the wrap() and fill() methods; the other methods are just there for
+subclasses to override in order to tweak the default behaviour.
+If you want to completely replace the main wrapping algorithm,
+you\'ll probably have to override _wrap_chunks().''')
def test_properly_formated(self):
@@ -241,7 +246,7 @@ bytes() -> empty bytes object''')
__class__ = property({}.__getitem__, {}.__setitem__)
class Object(metaclass=Type):
__slots__ = '__class__'
- for meth, mtip in ((Type, default_tip), (Object, default_tip),
+ for meth, mtip in ((Type, get_spec(type)), (Object, default_tip),
(Object(), '')):
with self.subTest(meth=meth, mtip=mtip):
self.assertEqual(get_spec(meth), mtip)
diff --git a/Lib/idlelib/idle_test/test_searchengine.py b/Lib/idlelib/idle_test/test_searchengine.py
index 3d26d62a95..f8401ce938 100644
--- a/Lib/idlelib/idle_test/test_searchengine.py
+++ b/Lib/idlelib/idle_test/test_searchengine.py
@@ -175,11 +175,13 @@ class SearchEngineTest(unittest.TestCase):
engine.setpat('')
Equal(engine.getprog(), None)
+ Equal(Mbox.showerror.message,
+ 'Error: Empty regular expression')
engine.setpat('+')
engine.revar.set(1)
Equal(engine.getprog(), None)
- self.assertEqual(Mbox.showerror.message,
- 'Error: nothing to repeat at position 0\nPattern: +')
+ Equal(Mbox.showerror.message,
+ 'Error: nothing to repeat\nPattern: +\nOffset: 0')
def test_report_error(self):
showerror = Mbox.showerror
diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py
index b69916dbe8..abe8a85952 100755
--- a/Lib/idlelib/pyshell.py
+++ b/Lib/idlelib/pyshell.py
@@ -463,7 +463,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
self.rpcclt.listening_sock.settimeout(10)
try:
self.rpcclt.accept()
- except socket.timeout:
+ except TimeoutError:
self.display_no_subprocess_error()
return None
self.rpcclt.register("console", self.tkconsole)
@@ -498,7 +498,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
self.spawn_subprocess()
try:
self.rpcclt.accept()
- except socket.timeout:
+ except TimeoutError:
self.display_no_subprocess_error()
return None
self.transfer_path(with_cwd=with_cwd)
@@ -757,7 +757,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
def runcode(self, code):
"Override base class method"
if self.tkconsole.executing:
- self.interp.restart_subprocess()
+ self.restart_subprocess()
self.checklinecache()
debugger = self.debugger
try:
@@ -1061,8 +1061,10 @@ class PyShell(OutputWindow):
(sys.version, sys.platform, self.COPYRIGHT, nosub))
self.text.focus_force()
self.showprompt()
+ # User code should use separate default Tk root window
import tkinter
- tkinter._default_root = None # 03Jan04 KBK What's this?
+ tkinter._support_default_root = True
+ tkinter._default_root = None
return True
def stop_readline(self):
diff --git a/Lib/idlelib/runscript.py b/Lib/idlelib/runscript.py
index a54108794a..028b0dbd21 100644
--- a/Lib/idlelib/runscript.py
+++ b/Lib/idlelib/runscript.py
@@ -11,6 +11,7 @@ TODO: Specify command line arguments in a dialog box.
"""
import os
import tabnanny
+import time
import tokenize
import tkinter.messagebox as tkMessageBox
@@ -42,9 +43,7 @@ class ScriptBinding:
self.root = self.editwin.root
# cli_args is list of strings that extends sys.argv
self.cli_args = []
-
- if macosx.isCocoaTk():
- self.editwin.text_frame.bind('<<run-module-event-2>>', self._run_module_event)
+ self.perf = 0.0 # Workaround for macOS 11 Uni2; see bpo-42508.
def check_module_event(self, event):
if isinstance(self.editwin, outwin.OutputWindow):
@@ -107,24 +106,10 @@ class ScriptBinding:
finally:
shell.set_warning_stream(saved_stream)
- def run_module_event(self, event):
- if macosx.isCocoaTk():
- # Tk-Cocoa in MacOSX is broken until at least
- # Tk 8.5.9, and without this rather
- # crude workaround IDLE would hang when a user
- # tries to run a module using the keyboard shortcut
- # (the menu item works fine).
- self.editwin.text_frame.after(200,
- lambda: self.editwin.text_frame.event_generate(
- '<<run-module-event-2>>'))
- return 'break'
- else:
- return self._run_module_event(event)
-
def run_custom_event(self, event):
- return self._run_module_event(event, customize=True)
+ return self.run_module_event(event, customize=True)
- def _run_module_event(self, event, *, customize=False):
+ def run_module_event(self, event, *, customize=False):
"""Run the module after setting up the environment.
First check the syntax. Next get customization. If OK, make
@@ -133,6 +118,8 @@ class ScriptBinding:
module being executed and also add that directory to its
sys.path if not already included.
"""
+ if macosx.isCocoaTk() and (time.perf_counter() - self.perf < .05):
+ return 'break'
if isinstance(self.editwin, outwin.OutputWindow):
self.editwin.text.bell()
return 'break'
@@ -218,6 +205,7 @@ class ScriptBinding:
# XXX This should really be a function of EditorWindow...
tkMessageBox.showerror(title, message, parent=self.editwin.text)
self.editwin.text.focus_set()
+ self.perf = time.perf_counter()
if __name__ == "__main__":
diff --git a/Lib/idlelib/searchengine.py b/Lib/idlelib/searchengine.py
index 911e7d4691..a50038e282 100644
--- a/Lib/idlelib/searchengine.py
+++ b/Lib/idlelib/searchengine.py
@@ -84,20 +84,17 @@ class SearchEngine:
flags = flags | re.IGNORECASE
try:
prog = re.compile(pat, flags)
- except re.error as what:
- args = what.args
- msg = args[0]
- col = args[1] if len(args) >= 2 else -1
- self.report_error(pat, msg, col)
+ except re.error as e:
+ self.report_error(pat, e.msg, e.pos)
return None
return prog
- def report_error(self, pat, msg, col=-1):
+ def report_error(self, pat, msg, col=None):
# Derived class could override this with something fancier
msg = "Error: " + str(msg)
if pat:
msg = msg + "\nPattern: " + str(pat)
- if col >= 0:
+ if col is not None:
msg = msg + "\nOffset: " + str(col)
tkMessageBox.showerror("Regular expression error",
msg, master=self.root)
diff --git a/Lib/importlib/__init__.py b/Lib/importlib/__init__.py
index bea37d7662..03ff71489a 100644
--- a/Lib/importlib/__init__.py
+++ b/Lib/importlib/__init__.py
@@ -34,7 +34,7 @@ try:
import _frozen_importlib_external as _bootstrap_external
except ImportError:
from . import _bootstrap_external
- _bootstrap_external._setup(_bootstrap)
+ _bootstrap_external._set_bootstrap_module(_bootstrap)
_bootstrap._bootstrap_external = _bootstrap_external
else:
_bootstrap_external.__name__ = 'importlib._bootstrap_external'
diff --git a/Lib/importlib/_abc.py b/Lib/importlib/_abc.py
index fb5ec727ce..7591946a4e 100644
--- a/Lib/importlib/_abc.py
+++ b/Lib/importlib/_abc.py
@@ -35,6 +35,7 @@ class Loader(metaclass=abc.ABCMeta):
"""
if not hasattr(self, 'exec_module'):
raise ImportError
+ # Warning implemented in _load_module_shim().
return _bootstrap._load_module_shim(self, fullname)
def module_repr(self, module):
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index e00b27ece2..e4f893c38c 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -20,10 +20,23 @@ work. One should use importlib as the public-facing version of this module.
# reference any injected objects! This includes not only global code but also
# anything specified at the class level.
+def _object_name(obj):
+ try:
+ return obj.__qualname__
+ except AttributeError:
+ return type(obj).__qualname__
+
# Bootstrap-related code ######################################################
+# Modules injected manually by _setup()
+_thread = None
+_warnings = None
+_weakref = None
+
+# Import done by _install_external_importers()
_bootstrap_external = None
+
def _wrap(new, old):
"""Simple substitute for functools.update_wrapper."""
for replace in ['__module__', '__name__', '__qualname__', '__doc__']:
@@ -265,6 +278,9 @@ def _load_module_shim(self, fullname):
This method is deprecated. Use loader.exec_module instead.
"""
+ msg = ("the load_module() method is deprecated and slated for removal in "
+ "Python 3.12; use exec_module() instead")
+ _warnings.warn(msg, DeprecationWarning)
spec = spec_from_loader(fullname, self)
if fullname in sys.modules:
module = sys.modules[fullname]
@@ -605,9 +621,9 @@ def _exec(spec, module):
else:
_init_module_attrs(spec, module, override=True)
if not hasattr(spec.loader, 'exec_module'):
- # (issue19713) Once BuiltinImporter and ExtensionFileLoader
- # have exec_module() implemented, we can add a deprecation
- # warning here.
+ msg = (f"{_object_name(spec.loader)}.exec_module() not found; "
+ "falling back to load_module()")
+ _warnings.warn(msg, ImportWarning)
spec.loader.load_module(name)
else:
spec.loader.exec_module(module)
@@ -620,9 +636,8 @@ def _exec(spec, module):
def _load_backward_compatible(spec):
- # (issue19713) Once BuiltinImporter and ExtensionFileLoader
- # have exec_module() implemented, we can add a deprecation
- # warning here.
+ # It is assumed that all callers have been warned about using load_module()
+ # appropriately before calling this function.
try:
spec.loader.load_module(spec.name)
except:
@@ -661,6 +676,9 @@ def _load_unlocked(spec):
if spec.loader is not None:
# Not a namespace package.
if not hasattr(spec.loader, 'exec_module'):
+ msg = (f"{_object_name(spec.loader)}.exec_module() not found; "
+ "falling back to load_module()")
+ _warnings.warn(msg, ImportWarning)
return _load_backward_compatible(spec)
module = module_from_spec(spec)
@@ -754,16 +772,16 @@ class BuiltinImporter:
spec = cls.find_spec(fullname, path)
return spec.loader if spec is not None else None
- @classmethod
- def create_module(self, spec):
+ @staticmethod
+ def create_module(spec):
"""Create a built-in module"""
if spec.name not in sys.builtin_module_names:
raise ImportError('{!r} is not a built-in module'.format(spec.name),
name=spec.name)
return _call_with_frames_removed(_imp.create_builtin, spec)
- @classmethod
- def exec_module(self, module):
+ @staticmethod
+ def exec_module(module):
"""Exec a built-in module"""
_call_with_frames_removed(_imp.exec_builtin, module)
@@ -824,8 +842,8 @@ class FrozenImporter:
"""
return cls if _imp.is_frozen(fullname) else None
- @classmethod
- def create_module(cls, spec):
+ @staticmethod
+ def create_module(spec):
"""Use default semantics for module creation."""
@staticmethod
@@ -844,6 +862,7 @@ class FrozenImporter:
This method is deprecated. Use exec_module() instead.
"""
+ # Warning about deprecation implemented in _load_module_shim().
return _load_module_shim(cls, fullname)
@classmethod
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index b08ad032ab..354650011e 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -19,6 +19,36 @@ work. One should use importlib as the public-facing version of this module.
# reference any injected objects! This includes not only global code but also
# anything specified at the class level.
+# Module injected manually by _set_bootstrap_module()
+_bootstrap = None
+
+# Import builtin modules
+import _imp
+import _io
+import sys
+import _warnings
+import marshal
+
+
+_MS_WINDOWS = (sys.platform == 'win32')
+if _MS_WINDOWS:
+ import nt as _os
+ import winreg
+else:
+ import posix as _os
+
+
+if _MS_WINDOWS:
+ path_separators = ['\\', '/']
+else:
+ path_separators = ['/']
+# Assumption made in _path_join()
+assert all(len(sep) == 1 for sep in path_separators)
+path_sep = path_separators[0]
+path_separators = ''.join(path_separators)
+_pathseps_with_colon = {f':{s}' for s in path_separators}
+
+
# Bootstrap-related code ######################################################
_CASE_INSENSITIVE_PLATFORMS_STR_KEY = 'win',
_CASE_INSENSITIVE_PLATFORMS_BYTES_KEY = 'cygwin', 'darwin'
@@ -42,6 +72,8 @@ def _make_relax_case():
return False
return _relax_case
+_relax_case = _make_relax_case()
+
def _pack_uint32(x):
"""Convert a 32-bit integer to little-endian."""
@@ -278,6 +310,9 @@ _code_type = type(_write_atomic.__code__)
# Python 3.9a2 3424 (simplify bytecodes for *value unpacking)
# Python 3.9a2 3425 (simplify bytecodes for **value unpacking)
# Python 3.10a1 3430 (Make 'annotations' future by default)
+# Python 3.10a1 3431 (New line number table format -- PEP 626)
+# Python 3.10a2 3432 (Function annotation for MAKE_FUNCTION is changed from dict to tuple bpo-42202)
+# Python 3.10a2 3433 (RERAISE restores f_lasti if oparg != 0)
#
# MAGIC must change whenever the bytecode emitted by the compiler may no
@@ -287,13 +322,17 @@ _code_type = type(_write_atomic.__code__)
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.
-MAGIC_NUMBER = (3430).to_bytes(2, 'little') + b'\r\n'
+MAGIC_NUMBER = (3433).to_bytes(2, 'little') + b'\r\n'
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c
_PYCACHE = '__pycache__'
_OPT = 'opt-'
-SOURCE_SUFFIXES = ['.py'] # _setup() adds .pyw as needed.
+SOURCE_SUFFIXES = ['.py']
+if _MS_WINDOWS:
+ SOURCE_SUFFIXES.append('.pyw')
+
+EXTENSION_SUFFIXES = _imp.extension_suffixes()
BYTECODE_SUFFIXES = ['.pyc']
# Deprecated.
@@ -468,15 +507,18 @@ def _check_name(method):
raise ImportError('loader for %s cannot handle %s' %
(self.name, name), name=name)
return method(self, name, *args, **kwargs)
- try:
+
+ # FIXME: @_check_name is used to define class methods before the
+ # _bootstrap module is set by _set_bootstrap_module().
+ if _bootstrap is not None:
_wrap = _bootstrap._wrap
- except NameError:
- # XXX yuck
+ else:
def _wrap(new, old):
for replace in ['__module__', '__name__', '__qualname__', '__doc__']:
if hasattr(old, replace):
setattr(new, replace, getattr(old, replace))
new.__dict__.update(old.__dict__)
+
_wrap(_check_name_wrapper, method)
return _check_name_wrapper
@@ -712,10 +754,10 @@ class WindowsRegistryFinder:
REGISTRY_KEY_DEBUG = (
'Software\\Python\\PythonCore\\{sys_version}'
'\\Modules\\{fullname}\\Debug')
- DEBUG_BUILD = False # Changed in _setup()
+ DEBUG_BUILD = (_MS_WINDOWS and '_d.pyd' in EXTENSION_SUFFIXES)
- @classmethod
- def _open_registry(cls, key):
+ @staticmethod
+ def _open_registry(key):
try:
return winreg.OpenKey(winreg.HKEY_CURRENT_USER, key)
except OSError:
@@ -791,7 +833,8 @@ class _LoaderBasics:
_bootstrap._call_with_frames_removed(exec, code, module.__dict__)
def load_module(self, fullname):
- """This module is deprecated."""
+ """This method is deprecated."""
+ # Warning implemented in _load_module_shim().
return _bootstrap._load_module_shim(self, fullname)
@@ -966,7 +1009,7 @@ class FileLoader:
"""
# The only reason for this method is for the name check.
# Issue #14857: Avoid the zero-argument form of super so the implementation
- # of that form can be updated without breaking the frozen module
+ # of that form can be updated without breaking the frozen module.
return super(FileLoader, self).load_module(fullname)
@_check_name
@@ -1059,10 +1102,6 @@ class SourcelessFileLoader(FileLoader, _LoaderBasics):
return None
-# Filled in by _setup().
-EXTENSION_SUFFIXES = []
-
-
class ExtensionFileLoader(FileLoader, _LoaderBasics):
"""Loader for extension modules.
@@ -1183,8 +1222,8 @@ class _NamespaceLoader:
def __init__(self, name, path, path_finder):
self._path = _NamespacePath(name, path, path_finder)
- @classmethod
- def module_repr(cls, module):
+ @staticmethod
+ def module_repr(module):
"""Return repr for the module.
The method is deprecated. The import machinery does the job itself.
@@ -1216,6 +1255,7 @@ class _NamespaceLoader:
# The import system never calls this method.
_bootstrap._verbose_message('namespace module loaded with path {!r}',
self._path)
+ # Warning implemented in _load_module_shim().
return _bootstrap._load_module_shim(self, fullname)
@@ -1225,8 +1265,8 @@ class PathFinder:
"""Meta path finder for sys.path and package __path__ attributes."""
- @classmethod
- def invalidate_caches(cls):
+ @staticmethod
+ def invalidate_caches():
"""Call the invalidate_caches() method on all path entry finders
stored in sys.path_importer_caches (where implemented)."""
for name, finder in list(sys.path_importer_cache.items()):
@@ -1235,8 +1275,8 @@ class PathFinder:
elif hasattr(finder, 'invalidate_caches'):
finder.invalidate_caches()
- @classmethod
- def _path_hooks(cls, path):
+ @staticmethod
+ def _path_hooks(path):
"""Search sys.path_hooks for a finder for 'path'."""
if sys.path_hooks is not None and not sys.path_hooks:
_warnings.warn('sys.path_hooks is empty', ImportWarning)
@@ -1354,8 +1394,8 @@ class PathFinder:
return None
return spec.loader
- @classmethod
- def find_distributions(cls, *args, **kwargs):
+ @staticmethod
+ def find_distributions(*args, **kwargs):
"""
Find distributions.
@@ -1551,66 +1591,14 @@ def _get_supported_file_loaders():
return [extensions, source, bytecode]
-def _setup(_bootstrap_module):
- """Setup the path-based importers for importlib by importing needed
- built-in modules and injecting them into the global namespace.
-
- Other components are extracted from the core bootstrap module.
-
- """
- global sys, _imp, _bootstrap
+def _set_bootstrap_module(_bootstrap_module):
+ global _bootstrap
_bootstrap = _bootstrap_module
- sys = _bootstrap.sys
- _imp = _bootstrap._imp
-
- self_module = sys.modules[__name__]
-
- # Directly load the os module (needed during bootstrap).
- os_details = ('posix', ['/']), ('nt', ['\\', '/'])
- for builtin_os, path_separators in os_details:
- # Assumption made in _path_join()
- assert all(len(sep) == 1 for sep in path_separators)
- path_sep = path_separators[0]
- if builtin_os in sys.modules:
- os_module = sys.modules[builtin_os]
- break
- else:
- try:
- os_module = _bootstrap._builtin_from_name(builtin_os)
- break
- except ImportError:
- continue
- else:
- raise ImportError('importlib requires posix or nt')
-
- setattr(self_module, '_os', os_module)
- setattr(self_module, 'path_sep', path_sep)
- setattr(self_module, 'path_separators', ''.join(path_separators))
- setattr(self_module, '_pathseps_with_colon', {f':{s}' for s in path_separators})
-
- # Directly load built-in modules needed during bootstrap.
- builtin_names = ['_io', '_warnings', 'marshal']
- if builtin_os == 'nt':
- builtin_names.append('winreg')
- for builtin_name in builtin_names:
- if builtin_name not in sys.modules:
- builtin_module = _bootstrap._builtin_from_name(builtin_name)
- else:
- builtin_module = sys.modules[builtin_name]
- setattr(self_module, builtin_name, builtin_module)
-
- # Constants
- setattr(self_module, '_relax_case', _make_relax_case())
- EXTENSION_SUFFIXES.extend(_imp.extension_suffixes())
- if builtin_os == 'nt':
- SOURCE_SUFFIXES.append('.pyw')
- if '_d.pyd' in EXTENSION_SUFFIXES:
- WindowsRegistryFinder.DEBUG_BUILD = True
def _install(_bootstrap_module):
"""Install the path-based import components."""
- _setup(_bootstrap_module)
+ _set_bootstrap_module(_bootstrap_module)
supported_loaders = _get_supported_file_loaders()
sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)])
sys.meta_path.append(PathFinder)
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py
index 97d5afa300..55e70889f2 100644
--- a/Lib/importlib/abc.py
+++ b/Lib/importlib/abc.py
@@ -1,5 +1,4 @@
"""Abstract base classes related to import."""
-from . import _bootstrap
from . import _bootstrap_external
from . import machinery
try:
diff --git a/Lib/importlib/machinery.py b/Lib/importlib/machinery.py
index 1b2b5c9b4f..9a7757fb6e 100644
--- a/Lib/importlib/machinery.py
+++ b/Lib/importlib/machinery.py
@@ -1,7 +1,5 @@
"""The machinery of importlib: finders, loaders, hooks, etc."""
-import _imp
-
from ._bootstrap import ModuleSpec
from ._bootstrap import BuiltinImporter
from ._bootstrap import FrozenImporter
diff --git a/Lib/importlib/util.py b/Lib/importlib/util.py
index 1e44843a68..98a0fa54df 100644
--- a/Lib/importlib/util.py
+++ b/Lib/importlib/util.py
@@ -232,7 +232,6 @@ class _LazyModule(types.ModuleType):
# Figure out exactly what attributes were mutated between the creation
# of the module and now.
attrs_then = self.__spec__.loader_state['__dict__']
- original_type = self.__spec__.loader_state['__class__']
attrs_now = self.__dict__
attrs_updated = {}
for key, value in attrs_now.items():
diff --git a/Lib/inspect.py b/Lib/inspect.py
index ac127cbd72..70c5ef7bb6 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -707,10 +707,13 @@ def getsourcefile(object):
if os.path.exists(filename):
return filename
# only return a non-existent filename if the module has a PEP 302 loader
- if getattr(getmodule(object, filename), '__loader__', None) is not None:
+ module = getmodule(object, filename)
+ if getattr(module, '__loader__', None) is not None:
+ return filename
+ elif getattr(getattr(module, "__spec__", None), "loader", None) is not None:
return filename
# or it is in the linecache
- if filename in linecache.cache:
+ elif filename in linecache.cache:
return filename
def getabsfile(object, _filename=None):
@@ -865,7 +868,12 @@ def findsource(object):
lnum = object.co_firstlineno - 1
pat = re.compile(r'^(\s*def\s)|(\s*async\s+def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)')
while lnum > 0:
- if pat.match(lines[lnum]): break
+ try:
+ line = lines[lnum]
+ except IndexError:
+ raise OSError('lineno is out of bounds')
+ if pat.match(line):
+ break
lnum = lnum - 1
return lines, lnum
raise OSError('could not find code object')
@@ -927,6 +935,7 @@ class BlockFinder:
self.indecorator = False
self.decoratorhasargs = False
self.last = 1
+ self.body_col0 = None
def tokeneater(self, type, token, srowcol, erowcol, line):
if not self.started and not self.indecorator:
@@ -958,6 +967,8 @@ class BlockFinder:
elif self.passline:
pass
elif type == tokenize.INDENT:
+ if self.body_col0 is None and self.started:
+ self.body_col0 = erowcol[1]
self.indent = self.indent + 1
self.passline = True
elif type == tokenize.DEDENT:
@@ -967,6 +978,10 @@ class BlockFinder:
# not e.g. for "if: else:" or "try: finally:" blocks)
if self.indent <= 0:
raise EndOfBlock
+ elif type == tokenize.COMMENT:
+ if self.body_col0 is not None and srowcol[1] >= self.body_col0:
+ # Include comments if indented at least as much as the block
+ self.last = srowcol[0]
elif self.indent == 0 and type not in (tokenize.COMMENT, tokenize.NL):
# any other token on the same indentation level end the previous
# block as well, except the pseudo-tokens COMMENT and NL.
@@ -2122,9 +2137,9 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True):
return cls(parameters, return_annotation=cls.empty)
-def _get_type_hints(func):
+def _get_type_hints(func, **kwargs):
try:
- return typing.get_type_hints(func)
+ return typing.get_type_hints(func, **kwargs)
except Exception:
# First, try to use the get_type_hints to resolve
# annotations. But for keeping the behavior intact
@@ -2149,7 +2164,8 @@ def _signature_from_builtin(cls, func, skip_bound_arg=True):
return _signature_fromstr(cls, func, s, skip_bound_arg)
-def _signature_from_function(cls, func, skip_bound_arg=True):
+def _signature_from_function(cls, func, skip_bound_arg=True,
+ globalns=None, localns=None):
"""Private helper: constructs Signature for the given python function."""
is_duck_function = False
@@ -2175,7 +2191,7 @@ def _signature_from_function(cls, func, skip_bound_arg=True):
positional = arg_names[:pos_count]
keyword_only_count = func_code.co_kwonlyargcount
keyword_only = arg_names[pos_count:pos_count + keyword_only_count]
- annotations = _get_type_hints(func)
+ annotations = _get_type_hints(func, globalns=globalns, localns=localns)
defaults = func.__defaults__
kwdefaults = func.__kwdefaults__
@@ -2247,23 +2263,28 @@ def _signature_from_function(cls, func, skip_bound_arg=True):
def _signature_from_callable(obj, *,
follow_wrapper_chains=True,
skip_bound_arg=True,
+ globalns=None,
+ localns=None,
sigcls):
"""Private helper function to get signature for arbitrary
callable objects.
"""
+ _get_signature_of = functools.partial(_signature_from_callable,
+ follow_wrapper_chains=follow_wrapper_chains,
+ skip_bound_arg=skip_bound_arg,
+ globalns=globalns,
+ localns=localns,
+ sigcls=sigcls)
+
if not callable(obj):
raise TypeError('{!r} is not a callable object'.format(obj))
if isinstance(obj, types.MethodType):
# In this case we skip the first parameter of the underlying
# function (usually `self` or `cls`).
- sig = _signature_from_callable(
- obj.__func__,
- follow_wrapper_chains=follow_wrapper_chains,
- skip_bound_arg=skip_bound_arg,
- sigcls=sigcls)
+ sig = _get_signature_of(obj.__func__)
if skip_bound_arg:
return _signature_bound_method(sig)
@@ -2277,11 +2298,7 @@ def _signature_from_callable(obj, *,
# If the unwrapped object is a *method*, we might want to
# skip its first parameter (self).
# See test_signature_wrapped_bound_method for details.
- return _signature_from_callable(
- obj,
- follow_wrapper_chains=follow_wrapper_chains,
- skip_bound_arg=skip_bound_arg,
- sigcls=sigcls)
+ return _get_signature_of(obj)
try:
sig = obj.__signature__
@@ -2308,11 +2325,7 @@ def _signature_from_callable(obj, *,
# (usually `self`, or `cls`) will not be passed
# automatically (as for boundmethods)
- wrapped_sig = _signature_from_callable(
- partialmethod.func,
- follow_wrapper_chains=follow_wrapper_chains,
- skip_bound_arg=skip_bound_arg,
- sigcls=sigcls)
+ wrapped_sig = _get_signature_of(partialmethod.func)
sig = _signature_get_partial(wrapped_sig, partialmethod, (None,))
first_wrapped_param = tuple(wrapped_sig.parameters.values())[0]
@@ -2331,18 +2344,15 @@ def _signature_from_callable(obj, *,
# If it's a pure Python function, or an object that is duck type
# of a Python function (Cython functions, for instance), then:
return _signature_from_function(sigcls, obj,
- skip_bound_arg=skip_bound_arg)
+ skip_bound_arg=skip_bound_arg,
+ globalns=globalns, localns=localns)
if _signature_is_builtin(obj):
return _signature_from_builtin(sigcls, obj,
skip_bound_arg=skip_bound_arg)
if isinstance(obj, functools.partial):
- wrapped_sig = _signature_from_callable(
- obj.func,
- follow_wrapper_chains=follow_wrapper_chains,
- skip_bound_arg=skip_bound_arg,
- sigcls=sigcls)
+ wrapped_sig = _get_signature_of(obj.func)
return _signature_get_partial(wrapped_sig, obj)
sig = None
@@ -2353,29 +2363,17 @@ def _signature_from_callable(obj, *,
# in its metaclass
call = _signature_get_user_defined_method(type(obj), '__call__')
if call is not None:
- sig = _signature_from_callable(
- call,
- follow_wrapper_chains=follow_wrapper_chains,
- skip_bound_arg=skip_bound_arg,
- sigcls=sigcls)
+ sig = _get_signature_of(call)
else:
# Now we check if the 'obj' class has a '__new__' method
new = _signature_get_user_defined_method(obj, '__new__')
if new is not None:
- sig = _signature_from_callable(
- new,
- follow_wrapper_chains=follow_wrapper_chains,
- skip_bound_arg=skip_bound_arg,
- sigcls=sigcls)
+ sig = _get_signature_of(new)
else:
# Finally, we should have at least __init__ implemented
init = _signature_get_user_defined_method(obj, '__init__')
if init is not None:
- sig = _signature_from_callable(
- init,
- follow_wrapper_chains=follow_wrapper_chains,
- skip_bound_arg=skip_bound_arg,
- sigcls=sigcls)
+ sig = _get_signature_of(init)
if sig is None:
# At this point we know, that `obj` is a class, with no user-
@@ -2421,11 +2419,7 @@ def _signature_from_callable(obj, *,
call = _signature_get_user_defined_method(type(obj), '__call__')
if call is not None:
try:
- sig = _signature_from_callable(
- call,
- follow_wrapper_chains=follow_wrapper_chains,
- skip_bound_arg=skip_bound_arg,
- sigcls=sigcls)
+ sig = _get_signature_of(call)
except ValueError as ex:
msg = 'no signature found for {!r}'.format(obj)
raise ValueError(msg) from ex
@@ -2877,10 +2871,12 @@ class Signature:
return _signature_from_builtin(cls, func)
@classmethod
- def from_callable(cls, obj, *, follow_wrapped=True):
+ def from_callable(cls, obj, *,
+ follow_wrapped=True, globalns=None, localns=None):
"""Constructs Signature for the given callable object."""
return _signature_from_callable(obj, sigcls=cls,
- follow_wrapper_chains=follow_wrapped)
+ follow_wrapper_chains=follow_wrapped,
+ globalns=globalns, localns=localns)
@property
def parameters(self):
@@ -3128,9 +3124,10 @@ class Signature:
return rendered
-def signature(obj, *, follow_wrapped=True):
+def signature(obj, *, follow_wrapped=True, globalns=None, localns=None):
"""Get a signature object for the passed callable."""
- return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
+ return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
+ globalns=globalns, localns=localns)
def _main():
diff --git a/Lib/lib2to3/Grammar.txt b/Lib/lib2to3/Grammar.txt
index e007dc188a..fa7b15061d 100644
--- a/Lib/lib2to3/Grammar.txt
+++ b/Lib/lib2to3/Grammar.txt
@@ -18,15 +18,55 @@ decorated: decorators (classdef | funcdef | async_funcdef)
async_funcdef: ASYNC funcdef
funcdef: 'def' NAME parameters ['->' test] ':' suite
parameters: '(' [typedargslist] ')'
-typedargslist: ((tfpdef ['=' test] ',')*
- ('*' [tname] (',' tname ['=' test])* [',' ['**' tname [',']]] | '**' tname [','])
- | tfpdef ['=' test] (',' tfpdef ['=' test])* [','])
+
+# The following definition for typedarglist is equivalent to this set of rules:
+#
+# arguments = argument (',' argument)*
+# argument = tfpdef ['=' test]
+# kwargs = '**' tname [',']
+# args = '*' [tname]
+# kwonly_kwargs = (',' argument)* [',' [kwargs]]
+# args_kwonly_kwargs = args kwonly_kwargs | kwargs
+# poskeyword_args_kwonly_kwargs = arguments [',' [args_kwonly_kwargs]]
+# typedargslist_no_posonly = poskeyword_args_kwonly_kwargs | args_kwonly_kwargs
+# typedarglist = arguments ',' '/' [',' [typedargslist_no_posonly]])|(typedargslist_no_posonly)"
+#
+# It needs to be fully expanded to allow our LL(1) parser to work on it.
+
+typedargslist: tfpdef ['=' test] (',' tfpdef ['=' test])* ',' '/' [
+ ',' [((tfpdef ['=' test] ',')* ('*' [tname] (',' tname ['=' test])*
+ [',' ['**' tname [',']]] | '**' tname [','])
+ | tfpdef ['=' test] (',' tfpdef ['=' test])* [','])]
+ ] | ((tfpdef ['=' test] ',')* ('*' [tname] (',' tname ['=' test])*
+ [',' ['**' tname [',']]] | '**' tname [','])
+ | tfpdef ['=' test] (',' tfpdef ['=' test])* [','])
+
tname: NAME [':' test]
tfpdef: tname | '(' tfplist ')'
tfplist: tfpdef (',' tfpdef)* [',']
-varargslist: ((vfpdef ['=' test] ',')*
- ('*' [vname] (',' vname ['=' test])* [',' ['**' vname [',']]] | '**' vname [','])
- | vfpdef ['=' test] (',' vfpdef ['=' test])* [','])
+
+# The following definition for varargslist is equivalent to this set of rules:
+#
+# arguments = argument (',' argument )*
+# argument = vfpdef ['=' test]
+# kwargs = '**' vname [',']
+# args = '*' [vname]
+# kwonly_kwargs = (',' argument )* [',' [kwargs]]
+# args_kwonly_kwargs = args kwonly_kwargs | kwargs
+# poskeyword_args_kwonly_kwargs = arguments [',' [args_kwonly_kwargs]]
+# vararglist_no_posonly = poskeyword_args_kwonly_kwargs | args_kwonly_kwargs
+# varargslist = arguments ',' '/' [','[(vararglist_no_posonly)]] | (vararglist_no_posonly)
+#
+# It needs to be fully expanded to allow our LL(1) parser to work on it.
+
+varargslist: vfpdef ['=' test ](',' vfpdef ['=' test])* ',' '/' [',' [
+ ((vfpdef ['=' test] ',')* ('*' [vname] (',' vname ['=' test])*
+ [',' ['**' vname [',']]] | '**' vname [','])
+ | vfpdef ['=' test] (',' vfpdef ['=' test])* [','])
+ ]] | ((vfpdef ['=' test] ',')*
+ ('*' [vname] (',' vname ['=' test])* [',' ['**' vname [',']]]| '**' vname [','])
+ | vfpdef ['=' test] (',' vfpdef ['=' test])* [','])
+
vname: NAME
vfpdef: vname | '(' vfplist ')'
vfplist: vfpdef (',' vfpdef)* [',']
diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py
index ba2bb78733..d5db66b9b1 100644
--- a/Lib/lib2to3/tests/test_parser.py
+++ b/Lib/lib2to3/tests/test_parser.py
@@ -272,6 +272,12 @@ class TestUnpackingGeneralizations(GrammarTest):
def test_dict_display_2(self):
self.validate("""{**{}, 3:4, **{5:6, 7:8}}""")
+ def test_complex_star_expression(self):
+ self.validate("func(* [] or [1])")
+
+ def test_complex_double_star_expression(self):
+ self.validate("func(**{1: 3} if False else {x: x for x in range(3)})")
+
def test_argument_unpacking_1(self):
self.validate("""f(a, *b, *c, d)""")
@@ -630,6 +636,7 @@ class TestLiterals(GrammarTest):
class TestNamedAssignments(GrammarTest):
+ """Also known as the walrus operator."""
def test_named_assignment_if(self):
driver.parse_string("if f := x(): pass\n")
@@ -644,6 +651,30 @@ class TestNamedAssignments(GrammarTest):
driver.parse_string("[(lastNum := num) == 1 for num in [1, 2, 3]]\n")
+class TestPositionalOnlyArgs(GrammarTest):
+
+ def test_one_pos_only_arg(self):
+ driver.parse_string("def one_pos_only_arg(a, /): pass\n")
+
+ def test_all_markers(self):
+ driver.parse_string(
+ "def all_markers(a, b=2, /, c, d=4, *, e=5, f): pass\n")
+
+ def test_all_with_args_and_kwargs(self):
+ driver.parse_string(
+ """def all_markers_with_args_and_kwargs(
+ aa, b, /, _cc, d, *args, e, f_f, **kwargs,
+ ):
+ pass\n""")
+
+ def test_lambda_soup(self):
+ driver.parse_string(
+ "lambda a, b, /, c, d, *args, e, f, **kw: kw\n")
+
+ def test_only_positional_or_keyword(self):
+ driver.parse_string("def func(a,b,/,*,g,e=3): pass\n")
+
+
class TestPickleableException(unittest.TestCase):
def test_ParseError(self):
err = ParseError('msg', 2, None, (1, 'context'))
diff --git a/Lib/linecache.py b/Lib/linecache.py
index fa5dbd09ea..513b17e999 100644
--- a/Lib/linecache.py
+++ b/Lib/linecache.py
@@ -165,9 +165,14 @@ def lazycache(filename, module_globals):
if not filename or (filename.startswith('<') and filename.endswith('>')):
return False
# Try for a __loader__, if available
- if module_globals and '__loader__' in module_globals:
- name = module_globals.get('__name__')
- loader = module_globals['__loader__']
+ if module_globals and '__name__' in module_globals:
+ name = module_globals['__name__']
+ if (loader := module_globals.get('__loader__')) is None:
+ if spec := module_globals.get('__spec__'):
+ try:
+ loader = spec.loader
+ except AttributeError:
+ pass
get_source = getattr(loader, 'get_source', None)
if name and get_source:
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index badfd654b1..50b7378cd6 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -1289,6 +1289,14 @@ class Manager(object):
self.loggerClass = None
self.logRecordFactory = None
+ @property
+ def disable(self):
+ return self._disable
+
+ @disable.setter
+ def disable(self, value):
+ self._disable = _checkLevel(value)
+
def getLogger(self, name):
"""
Get a logger with the specified name (channel name), creating it
diff --git a/Lib/opcode.py b/Lib/opcode.py
index ac1aa535f6..cc321166e7 100644
--- a/Lib/opcode.py
+++ b/Lib/opcode.py
@@ -83,7 +83,6 @@ def_op('BINARY_TRUE_DIVIDE', 27)
def_op('INPLACE_FLOOR_DIVIDE', 28)
def_op('INPLACE_TRUE_DIVIDE', 29)
-def_op('RERAISE', 48)
def_op('WITH_EXCEPT_START', 49)
def_op('GET_AITER', 50)
def_op('GET_ANEXT', 51)
@@ -161,6 +160,7 @@ name_op('LOAD_GLOBAL', 116) # Index in name list
def_op('IS_OP', 117)
def_op('CONTAINS_OP', 118)
+def_op('RERAISE', 119)
jabs_op('JUMP_IF_NOT_EXC_MATCH', 121)
jrel_op('SETUP_FINALLY', 122) # Distance to target address
diff --git a/Lib/os.py b/Lib/os.py
index b794159f86..05e9c32c5a 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -36,7 +36,7 @@ _names = sys.builtin_module_names
__all__ = ["altsep", "curdir", "pardir", "sep", "pathsep", "linesep",
"defpath", "name", "path", "devnull", "SEEK_SET", "SEEK_CUR",
"SEEK_END", "fsencode", "fsdecode", "get_exec_path", "fdopen",
- "popen", "extsep"]
+ "extsep"]
def _exists(name):
return name in globals()
@@ -969,51 +969,55 @@ otherwise return -SIG, where SIG is the signal that killed it. """
__all__.extend(["spawnlp", "spawnlpe"])
-
-# Supply os.popen()
-def popen(cmd, mode="r", buffering=-1):
- if not isinstance(cmd, str):
- raise TypeError("invalid cmd type (%s, expected string)" % type(cmd))
- if mode not in ("r", "w"):
- raise ValueError("invalid mode %r" % mode)
- if buffering == 0 or buffering is None:
- raise ValueError("popen() does not support unbuffered streams")
- import subprocess, io
- if mode == "r":
- proc = subprocess.Popen(cmd,
- shell=True,
- stdout=subprocess.PIPE,
- bufsize=buffering)
- return _wrap_close(io.TextIOWrapper(proc.stdout), proc)
- else:
- proc = subprocess.Popen(cmd,
- shell=True,
- stdin=subprocess.PIPE,
- bufsize=buffering)
- return _wrap_close(io.TextIOWrapper(proc.stdin), proc)
-
-# Helper for popen() -- a proxy for a file whose close waits for the process
-class _wrap_close:
- def __init__(self, stream, proc):
- self._stream = stream
- self._proc = proc
- def close(self):
- self._stream.close()
- returncode = self._proc.wait()
- if returncode == 0:
- return None
- if name == 'nt':
- return returncode
+# VxWorks has no user space shell provided. As a result, running
+# command in a shell can't be supported.
+if sys.platform != 'vxworks':
+ # Supply os.popen()
+ def popen(cmd, mode="r", buffering=-1):
+ if not isinstance(cmd, str):
+ raise TypeError("invalid cmd type (%s, expected string)" % type(cmd))
+ if mode not in ("r", "w"):
+ raise ValueError("invalid mode %r" % mode)
+ if buffering == 0 or buffering is None:
+ raise ValueError("popen() does not support unbuffered streams")
+ import subprocess, io
+ if mode == "r":
+ proc = subprocess.Popen(cmd,
+ shell=True,
+ stdout=subprocess.PIPE,
+ bufsize=buffering)
+ return _wrap_close(io.TextIOWrapper(proc.stdout), proc)
else:
- return returncode << 8 # Shift left to match old behavior
- def __enter__(self):
- return self
- def __exit__(self, *args):
- self.close()
- def __getattr__(self, name):
- return getattr(self._stream, name)
- def __iter__(self):
- return iter(self._stream)
+ proc = subprocess.Popen(cmd,
+ shell=True,
+ stdin=subprocess.PIPE,
+ bufsize=buffering)
+ return _wrap_close(io.TextIOWrapper(proc.stdin), proc)
+
+ # Helper for popen() -- a proxy for a file whose close waits for the process
+ class _wrap_close:
+ def __init__(self, stream, proc):
+ self._stream = stream
+ self._proc = proc
+ def close(self):
+ self._stream.close()
+ returncode = self._proc.wait()
+ if returncode == 0:
+ return None
+ if name == 'nt':
+ return returncode
+ else:
+ return returncode << 8 # Shift left to match old behavior
+ def __enter__(self):
+ return self
+ def __exit__(self, *args):
+ self.close()
+ def __getattr__(self, name):
+ return getattr(self._stream, name)
+ def __iter__(self):
+ return iter(self._stream)
+
+ __all__.append("popen")
# Supply os.fdopen()
def fdopen(fd, *args, **kwargs):
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 178c5b981d..531a699a40 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -630,7 +630,10 @@ class _PathParents(Sequence):
return len(self._parts)
def __getitem__(self, idx):
- if idx < 0 or idx >= len(self):
+ if isinstance(idx, slice):
+ return tuple(self[i] for i in range(*idx.indices(len(self))))
+
+ if idx >= len(self) or idx < -len(self):
raise IndexError(idx)
return self._pathcls._from_parsed_parts(self._drv, self._root,
self._parts[:-idx - 1])
diff --git a/Lib/pickle.py b/Lib/pickle.py
index cbac5f168b..e63a8b6e4d 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -340,7 +340,9 @@ def whichmodule(obj, name):
# Protect the iteration by using a list copy of sys.modules against dynamic
# modules that trigger imports of other modules upon calls to getattr.
for module_name, module in sys.modules.copy().items():
- if module_name == '__main__' or module is None:
+ if (module_name == '__main__'
+ or module_name == '__mp_main__' # bpo-42406
+ or module is None):
continue
try:
if _getattribute(module, name)[0] is obj:
diff --git a/Lib/platform.py b/Lib/platform.py
index 0eb5167d58..1a07b44077 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -1230,6 +1230,63 @@ def platform(aliased=0, terse=0):
_platform_cache[(aliased, terse)] = platform
return platform
+### freedesktop.org os-release standard
+# https://www.freedesktop.org/software/systemd/man/os-release.html
+
+# NAME=value with optional quotes (' or "). The regular expression is less
+# strict than shell lexer, but that's ok.
+_os_release_line = re.compile(
+ "^(?P<name>[a-zA-Z0-9_]+)=(?P<quote>[\"\']?)(?P<value>.*)(?P=quote)$"
+)
+# unescape five special characters mentioned in the standard
+_os_release_unescape = re.compile(r"\\([\\\$\"\'`])")
+# /etc takes precedence over /usr/lib
+_os_release_candidates = ("/etc/os-release", "/usr/lib/os-release")
+_os_release_cache = None
+
+
+def _parse_os_release(lines):
+ # These fields are mandatory fields with well-known defaults
+ # in pratice all Linux distributions override NAME, ID, and PRETTY_NAME.
+ info = {
+ "NAME": "Linux",
+ "ID": "linux",
+ "PRETTY_NAME": "Linux",
+ }
+
+ for line in lines:
+ mo = _os_release_line.match(line)
+ if mo is not None:
+ info[mo.group('name')] = _os_release_unescape.sub(
+ r"\1", mo.group('value')
+ )
+
+ return info
+
+
+def freedesktop_os_release():
+ """Return operation system identification from freedesktop.org os-release
+ """
+ global _os_release_cache
+
+ if _os_release_cache is None:
+ errno = None
+ for candidate in _os_release_candidates:
+ try:
+ with open(candidate, encoding="utf-8") as f:
+ _os_release_cache = _parse_os_release(f)
+ break
+ except OSError as e:
+ errno = e.errno
+ else:
+ raise OSError(
+ errno,
+ f"Unable to read files {', '.join(_os_release_candidates)}"
+ )
+
+ return _os_release_cache.copy()
+
+
### Command line interface
if __name__ == '__main__':
diff --git a/Lib/plistlib.py b/Lib/plistlib.py
index 83b214e9dc..2eeebe4c9a 100644
--- a/Lib/plistlib.py
+++ b/Lib/plistlib.py
@@ -611,7 +611,7 @@ def _count_to_size(count):
elif count < 1 << 16:
return 2
- elif count << 1 << 32:
+ elif count < 1 << 32:
return 4
else:
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index ecb4e5a8f7..62afbd0ccf 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -262,6 +262,9 @@ def expanduser(path):
# password database, return the path unchanged
return path
userhome = pwent.pw_dir
+ # if no user home, return the path unchanged on VxWorks
+ if userhome is None and sys.platform == "vxworks":
+ return path
if isinstance(path, bytes):
userhome = os.fsencode(userhome)
root = b'/'
diff --git a/Lib/pprint.py b/Lib/pprint.py
index 213998e349..a8af50e5a6 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -64,15 +64,15 @@ def pp(object, *args, sort_dicts=False, **kwargs):
def saferepr(object):
"""Version of repr() which can handle recursive data structures."""
- return _safe_repr(object, {}, None, 0, True)[0]
+ return PrettyPrinter()._safe_repr(object, {}, None, 0)[0]
def isreadable(object):
"""Determine if saferepr(object) is readable by eval()."""
- return _safe_repr(object, {}, None, 0, True)[1]
+ return PrettyPrinter()._safe_repr(object, {}, None, 0)[1]
def isrecursive(object):
"""Determine if object requires a recursive representation."""
- return _safe_repr(object, {}, None, 0, True)[2]
+ return PrettyPrinter()._safe_repr(object, {}, None, 0)[2]
class _safe_key:
"""Helper function for key functions when sorting unorderable objects.
@@ -435,7 +435,7 @@ class PrettyPrinter:
and flags indicating whether the representation is 'readable'
and whether the object represents a recursive construct.
"""
- return _safe_repr(object, context, maxlevels, level, self._sort_dicts)
+ return self._safe_repr(object, context, maxlevels, level)
def _pprint_default_dict(self, object, stream, indent, allowance, context, level):
if not len(object):
@@ -518,77 +518,79 @@ class PrettyPrinter:
_dispatch[_collections.UserString.__repr__] = _pprint_user_string
-# Return triple (repr_string, isreadable, isrecursive).
+ def _safe_repr(self, object, context, maxlevels, level):
+ # Return triple (repr_string, isreadable, isrecursive).
+ typ = type(object)
+ if typ in _builtin_scalars:
+ return repr(object), True, False
-def _safe_repr(object, context, maxlevels, level, sort_dicts):
- typ = type(object)
- if typ in _builtin_scalars:
- return repr(object), True, False
-
- r = getattr(typ, "__repr__", None)
- if issubclass(typ, dict) and r is dict.__repr__:
- if not object:
- return "{}", True, False
- objid = id(object)
- if maxlevels and level >= maxlevels:
- return "{...}", False, objid in context
- if objid in context:
- return _recursion(object), False, True
- context[objid] = 1
- readable = True
- recursive = False
- components = []
- append = components.append
- level += 1
- if sort_dicts:
- items = sorted(object.items(), key=_safe_tuple)
- else:
- items = object.items()
- for k, v in items:
- krepr, kreadable, krecur = _safe_repr(k, context, maxlevels, level, sort_dicts)
- vrepr, vreadable, vrecur = _safe_repr(v, context, maxlevels, level, sort_dicts)
- append("%s: %s" % (krepr, vrepr))
- readable = readable and kreadable and vreadable
- if krecur or vrecur:
- recursive = True
- del context[objid]
- return "{%s}" % ", ".join(components), readable, recursive
-
- if (issubclass(typ, list) and r is list.__repr__) or \
- (issubclass(typ, tuple) and r is tuple.__repr__):
- if issubclass(typ, list):
+ r = getattr(typ, "__repr__", None)
+ if issubclass(typ, dict) and r is dict.__repr__:
if not object:
- return "[]", True, False
- format = "[%s]"
- elif len(object) == 1:
- format = "(%s,)"
- else:
- if not object:
- return "()", True, False
- format = "(%s)"
- objid = id(object)
- if maxlevels and level >= maxlevels:
- return format % "...", False, objid in context
- if objid in context:
- return _recursion(object), False, True
- context[objid] = 1
- readable = True
- recursive = False
- components = []
- append = components.append
- level += 1
- for o in object:
- orepr, oreadable, orecur = _safe_repr(o, context, maxlevels, level, sort_dicts)
- append(orepr)
- if not oreadable:
- readable = False
- if orecur:
- recursive = True
- del context[objid]
- return format % ", ".join(components), readable, recursive
-
- rep = repr(object)
- return rep, (rep and not rep.startswith('<')), False
+ return "{}", True, False
+ objid = id(object)
+ if maxlevels and level >= maxlevels:
+ return "{...}", False, objid in context
+ if objid in context:
+ return _recursion(object), False, True
+ context[objid] = 1
+ readable = True
+ recursive = False
+ components = []
+ append = components.append
+ level += 1
+ if self._sort_dicts:
+ items = sorted(object.items(), key=_safe_tuple)
+ else:
+ items = object.items()
+ for k, v in items:
+ krepr, kreadable, krecur = self.format(
+ k, context, maxlevels, level)
+ vrepr, vreadable, vrecur = self.format(
+ v, context, maxlevels, level)
+ append("%s: %s" % (krepr, vrepr))
+ readable = readable and kreadable and vreadable
+ if krecur or vrecur:
+ recursive = True
+ del context[objid]
+ return "{%s}" % ", ".join(components), readable, recursive
+
+ if (issubclass(typ, list) and r is list.__repr__) or \
+ (issubclass(typ, tuple) and r is tuple.__repr__):
+ if issubclass(typ, list):
+ if not object:
+ return "[]", True, False
+ format = "[%s]"
+ elif len(object) == 1:
+ format = "(%s,)"
+ else:
+ if not object:
+ return "()", True, False
+ format = "(%s)"
+ objid = id(object)
+ if maxlevels and level >= maxlevels:
+ return format % "...", False, objid in context
+ if objid in context:
+ return _recursion(object), False, True
+ context[objid] = 1
+ readable = True
+ recursive = False
+ components = []
+ append = components.append
+ level += 1
+ for o in object:
+ orepr, oreadable, orecur = self.format(
+ o, context, maxlevels, level)
+ append(orepr)
+ if not oreadable:
+ readable = False
+ if orecur:
+ recursive = True
+ del context[objid]
+ return format % ", ".join(components), readable, recursive
+
+ rep = repr(object)
+ return rep, (rep and not rep.startswith('<')), False
_builtin_scalars = frozenset({str, bytes, bytearray, int, float, complex,
bool, type(None)})
@@ -604,7 +606,7 @@ def _perfcheck(object=None):
object = [("string", (1, 2), [3, 4], {5: 6, 7: 8})] * 100000
p = PrettyPrinter()
t1 = time.perf_counter()
- _safe_repr(object, {}, None, 0, True)
+ p._safe_repr(object, {}, None, 0, True)
t2 = time.perf_counter()
p.pformat(object)
t3 = time.perf_counter()
diff --git a/Lib/pyclbr.py b/Lib/pyclbr.py
index 99a17343fb..f0c8381946 100644
--- a/Lib/pyclbr.py
+++ b/Lib/pyclbr.py
@@ -25,7 +25,9 @@ has the following attributes:
children -- nested objects contained in this object.
The 'children' attribute is a dictionary mapping names to objects.
-Instances of Function describe functions with the attributes from _Object.
+Instances of Function describe functions with the attributes from _Object,
+plus the following:
+ is_async -- if a function is defined with an 'async' prefix
Instances of Class describe classes with the attributes from _Object,
plus the following:
@@ -38,11 +40,10 @@ are recognized and imported modules are scanned as well, this
shouldn't happen often.
"""
-import io
+import ast
+import copy
import sys
import importlib.util
-import tokenize
-from token import NAME, DEDENT, OP
__all__ = ["readmodule", "readmodule_ex", "Class", "Function"]
@@ -58,41 +59,33 @@ class _Object:
self.lineno = lineno
self.parent = parent
self.children = {}
-
- def _addchild(self, name, obj):
- self.children[name] = obj
-
+ if parent is not None:
+ parent.children[name] = self
class Function(_Object):
"Information about a Python function, including methods."
- def __init__(self, module, name, file, lineno, parent=None):
- _Object.__init__(self, module, name, file, lineno, parent)
-
+ def __init__(self, module, name, file, lineno, parent=None, is_async=False):
+ super().__init__(module, name, file, lineno, parent)
+ self.is_async = is_async
+ if isinstance(parent, Class):
+ parent.methods[name] = lineno
class Class(_Object):
"Information about a Python class."
- def __init__(self, module, name, super, file, lineno, parent=None):
- _Object.__init__(self, module, name, file, lineno, parent)
- self.super = [] if super is None else super
+ def __init__(self, module, name, super_, file, lineno, parent=None):
+ super().__init__(module, name, file, lineno, parent)
+ self.super = super_ or []
self.methods = {}
- def _addmethod(self, name, lineno):
- self.methods[name] = lineno
-
-
-def _nest_function(ob, func_name, lineno):
+# These 2 functions are used in these tests
+# Lib/test/test_pyclbr, Lib/idlelib/idle_test/test_browser.py
+def _nest_function(ob, func_name, lineno, is_async=False):
"Return a Function after nesting within ob."
- newfunc = Function(ob.module, func_name, ob.file, lineno, ob)
- ob._addchild(func_name, newfunc)
- if isinstance(ob, Class):
- ob._addmethod(func_name, lineno)
- return newfunc
+ return Function(ob.module, func_name, ob.file, lineno, ob, is_async)
def _nest_class(ob, class_name, lineno, super=None):
"Return a Class after nesting within ob."
- newclass = Class(ob.module, class_name, super, ob.file, lineno, ob)
- ob._addchild(class_name, newclass)
- return newclass
+ return Class(ob.module, class_name, super, ob.file, lineno, ob)
def readmodule(module, path=None):
"""Return Class objects for the top-level classes in module.
@@ -179,187 +172,95 @@ def _readmodule(module, path, inpackage=None):
return _create_tree(fullmodule, path, fname, source, tree, inpackage)
-def _create_tree(fullmodule, path, fname, source, tree, inpackage):
- """Return the tree for a particular module.
-
- fullmodule (full module name), inpackage+module, becomes o.module.
- path is passed to recursive calls of _readmodule.
- fname becomes o.file.
- source is tokenized. Imports cause recursive calls to _readmodule.
- tree is {} or {'__path__': <submodule search locations>}.
- inpackage, None or string, is passed to recursive calls of _readmodule.
-
- The effect of recursive calls is mutation of global _modules.
- """
- f = io.StringIO(source)
+class _ModuleBrowser(ast.NodeVisitor):
+ def __init__(self, module, path, file, tree, inpackage):
+ self.path = path
+ self.tree = tree
+ self.file = file
+ self.module = module
+ self.inpackage = inpackage
+ self.stack = []
+
+ def visit_ClassDef(self, node):
+ bases = []
+ for base in node.bases:
+ name = ast.unparse(base)
+ if name in self.tree:
+ # We know this super class.
+ bases.append(self.tree[name])
+ elif len(names := name.split(".")) > 1:
+ # Super class form is module.class:
+ # look in module for class.
+ *_, module, class_ = names
+ if module in _modules:
+ bases.append(_modules[module].get(class_, name))
+ else:
+ bases.append(name)
+
+ parent = self.stack[-1] if self.stack else None
+ class_ = Class(
+ self.module, node.name, bases, self.file, node.lineno, parent
+ )
+ if parent is None:
+ self.tree[node.name] = class_
+ self.stack.append(class_)
+ self.generic_visit(node)
+ self.stack.pop()
+
+ def visit_FunctionDef(self, node, *, is_async=False):
+ parent = self.stack[-1] if self.stack else None
+ function = Function(
+ self.module, node.name, self.file, node.lineno, parent, is_async
+ )
+ if parent is None:
+ self.tree[node.name] = function
+ self.stack.append(function)
+ self.generic_visit(node)
+ self.stack.pop()
+
+ def visit_AsyncFunctionDef(self, node):
+ self.visit_FunctionDef(node, is_async=True)
+
+ def visit_Import(self, node):
+ if node.col_offset != 0:
+ return
+
+ for module in node.names:
+ try:
+ try:
+ _readmodule(module.name, self.path, self.inpackage)
+ except ImportError:
+ _readmodule(module.name, [])
+ except (ImportError, SyntaxError):
+ # If we can't find or parse the imported module,
+ # too bad -- don't die here.
+ continue
+
+ def visit_ImportFrom(self, node):
+ if node.col_offset != 0:
+ return
+ try:
+ module = "." * node.level
+ if node.module:
+ module += node.module
+ module = _readmodule(module, self.path, self.inpackage)
+ except (ImportError, SyntaxError):
+ return
+
+ for name in node.names:
+ if name.name in module:
+ self.tree[name.asname or name.name] = module[name.name]
+ elif name.name == "*":
+ for import_name, import_value in module.items():
+ if import_name.startswith("_"):
+ continue
+ self.tree[import_name] = import_value
- stack = [] # Initialize stack of (class, indent) pairs.
- g = tokenize.generate_tokens(f.readline)
- try:
- for tokentype, token, start, _end, _line in g:
- if tokentype == DEDENT:
- lineno, thisindent = start
- # Close previous nested classes and defs.
- while stack and stack[-1][1] >= thisindent:
- del stack[-1]
- elif token == 'def':
- lineno, thisindent = start
- # Close previous nested classes and defs.
- while stack and stack[-1][1] >= thisindent:
- del stack[-1]
- tokentype, func_name, start = next(g)[0:3]
- if tokentype != NAME:
- continue # Skip def with syntax error.
- cur_func = None
- if stack:
- cur_obj = stack[-1][0]
- cur_func = _nest_function(cur_obj, func_name, lineno)
- else:
- # It is just a function.
- cur_func = Function(fullmodule, func_name, fname, lineno)
- tree[func_name] = cur_func
- stack.append((cur_func, thisindent))
- elif token == 'class':
- lineno, thisindent = start
- # Close previous nested classes and defs.
- while stack and stack[-1][1] >= thisindent:
- del stack[-1]
- tokentype, class_name, start = next(g)[0:3]
- if tokentype != NAME:
- continue # Skip class with syntax error.
- # Parse what follows the class name.
- tokentype, token, start = next(g)[0:3]
- inherit = None
- if token == '(':
- names = [] # Initialize list of superclasses.
- level = 1
- super = [] # Tokens making up current superclass.
- while True:
- tokentype, token, start = next(g)[0:3]
- if token in (')', ',') and level == 1:
- n = "".join(super)
- if n in tree:
- # We know this super class.
- n = tree[n]
- else:
- c = n.split('.')
- if len(c) > 1:
- # Super class form is module.class:
- # look in module for class.
- m = c[-2]
- c = c[-1]
- if m in _modules:
- d = _modules[m]
- if c in d:
- n = d[c]
- names.append(n)
- super = []
- if token == '(':
- level += 1
- elif token == ')':
- level -= 1
- if level == 0:
- break
- elif token == ',' and level == 1:
- pass
- # Only use NAME and OP (== dot) tokens for type name.
- elif tokentype in (NAME, OP) and level == 1:
- super.append(token)
- # Expressions in the base list are not supported.
- inherit = names
- if stack:
- cur_obj = stack[-1][0]
- cur_class = _nest_class(
- cur_obj, class_name, lineno, inherit)
- else:
- cur_class = Class(fullmodule, class_name, inherit,
- fname, lineno)
- tree[class_name] = cur_class
- stack.append((cur_class, thisindent))
- elif token == 'import' and start[1] == 0:
- modules = _getnamelist(g)
- for mod, _mod2 in modules:
- try:
- # Recursively read the imported module.
- if inpackage is None:
- _readmodule(mod, path)
- else:
- try:
- _readmodule(mod, path, inpackage)
- except ImportError:
- _readmodule(mod, [])
- except:
- # If we can't find or parse the imported module,
- # too bad -- don't die here.
- pass
- elif token == 'from' and start[1] == 0:
- mod, token = _getname(g)
- if not mod or token != "import":
- continue
- names = _getnamelist(g)
- try:
- # Recursively read the imported module.
- d = _readmodule(mod, path, inpackage)
- except:
- # If we can't find or parse the imported module,
- # too bad -- don't die here.
- continue
- # Add any classes that were defined in the imported module
- # to our name space if they were mentioned in the list.
- for n, n2 in names:
- if n in d:
- tree[n2 or n] = d[n]
- elif n == '*':
- # Don't add names that start with _.
- for n in d:
- if n[0] != '_':
- tree[n] = d[n]
- except StopIteration:
- pass
-
- f.close()
- return tree
-
-
-def _getnamelist(g):
- """Return list of (dotted-name, as-name or None) tuples for token source g.
-
- An as-name is the name that follows 'as' in an as clause.
- """
- names = []
- while True:
- name, token = _getname(g)
- if not name:
- break
- if token == 'as':
- name2, token = _getname(g)
- else:
- name2 = None
- names.append((name, name2))
- while token != "," and "\n" not in token:
- token = next(g)[1]
- if token != ",":
- break
- return names
-
-
-def _getname(g):
- "Return (dotted-name or None, next-token) tuple for token source g."
- parts = []
- tokentype, token = next(g)[0:2]
- if tokentype != NAME and token != '*':
- return (None, token)
- parts.append(token)
- while True:
- tokentype, token = next(g)[0:2]
- if token != '.':
- break
- tokentype, token = next(g)[0:2]
- if tokentype != NAME:
- break
- parts.append(token)
- return (".".join(parts), token)
+def _create_tree(fullmodule, path, fname, source, tree, inpackage):
+ mbrowser = _ModuleBrowser(fullmodule, path, fname, tree, inpackage)
+ mbrowser.visit(ast.parse(source))
+ return mbrowser.tree
def _main():
diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py
index 1fdb1ae859..49630bb4b8 100644
--- a/Lib/pydoc_data/topics.py
+++ b/Lib/pydoc_data/topics.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Autogenerated by Sphinx on Mon Oct 5 18:27:28 2020
+# Autogenerated by Sphinx on Mon Dec 7 19:34:00 2020
topics = {'assert': 'The "assert" statement\n'
'**********************\n'
'\n'
@@ -433,11 +433,9 @@ topics = {'assert': 'The "assert" statement\n'
'\n'
'Execution of Python coroutines can be suspended and resumed at '
'many\n'
- 'points (see *coroutine*). Inside the body of a coroutine '
- 'function,\n'
- '"await" and "async" identifiers become reserved keywords; "await"\n'
- 'expressions, "async for" and "async with" can only be used in\n'
- 'coroutine function bodies.\n'
+ 'points (see *coroutine*). "await" expressions, "async for" and '
+ '"async\n'
+ 'with" can only be used in the body of a coroutine function.\n'
'\n'
'Functions defined with "async def" syntax are always coroutine\n'
'functions, even if they do not contain "await" or "async" '
@@ -453,6 +451,10 @@ topics = {'assert': 'The "assert" statement\n'
' do_stuff()\n'
' await some_coroutine()\n'
'\n'
+ 'Changed in version 3.7: "await" and "async" are now keywords;\n'
+ 'previously they were only treated as such inside the body of a\n'
+ 'coroutine function.\n'
+ '\n'
'\n'
'The "async for" statement\n'
'=========================\n'
@@ -700,6 +702,11 @@ topics = {'assert': 'The "assert" statement\n'
'syntax or\n'
' built-in functions. See Special method lookup.\n'
'\n'
+ ' For certain sensitive attribute accesses, raises an '
+ 'auditing event\n'
+ ' "object.__getattr__" with arguments "obj" and '
+ '"name".\n'
+ '\n'
'object.__setattr__(self, name, value)\n'
'\n'
' Called when an attribute assignment is attempted. '
@@ -716,6 +723,11 @@ topics = {'assert': 'The "assert" statement\n'
'for example,\n'
' "object.__setattr__(self, name, value)".\n'
'\n'
+ ' For certain sensitive attribute assignments, raises '
+ 'an auditing\n'
+ ' event "object.__setattr__" with arguments "obj", '
+ '"name", "value".\n'
+ '\n'
'object.__delattr__(self, name)\n'
'\n'
' Like "__setattr__()" but for attribute deletion '
@@ -724,6 +736,11 @@ topics = {'assert': 'The "assert" statement\n'
'obj.name" is\n'
' meaningful for the object.\n'
'\n'
+ ' For certain sensitive attribute deletions, raises an '
+ 'auditing event\n'
+ ' "object.__delattr__" with arguments "obj" and '
+ '"name".\n'
+ '\n'
'object.__dir__(self)\n'
'\n'
' Called when "dir()" is called on the object. A '
@@ -1464,8 +1481,8 @@ topics = {'assert': 'The "assert" statement\n'
'\n'
' Called when the instance is “called” as a function; if '
'this method\n'
- ' is defined, "x(arg1, arg2, ...)" is a shorthand for\n'
- ' "x.__call__(arg1, arg2, ...)".\n',
+ ' is defined, "x(arg1, arg2, ...)" roughly translates to\n'
+ ' "type(x).__call__(x, arg1, ...)".\n',
'calls': 'Calls\n'
'*****\n'
'\n'
@@ -2766,20 +2783,11 @@ topics = {'assert': 'The "assert" statement\n'
'parameter list. These annotations can be any valid Python '
'expression.\n'
'The presence of annotations does not change the semantics of a\n'
- 'function. The annotation values are available as values of a\n'
+ 'function. The annotation values are available as string values '
+ 'in a\n'
'dictionary keyed by the parameters’ names in the '
'"__annotations__"\n'
- 'attribute of the function object. If the "annotations" import '
- 'from\n'
- '"__future__" is used, annotations are preserved as strings at '
- 'runtime\n'
- 'which enables postponed evaluation. Otherwise, they are '
- 'evaluated\n'
- 'when the function definition is executed. In this case '
- 'annotations\n'
- 'may be evaluated in a different order than they appear in the '
- 'source\n'
- 'code.\n'
+ 'attribute of the function object.\n'
'\n'
'It is also possible to create anonymous functions (functions not '
'bound\n'
@@ -2949,12 +2957,9 @@ topics = {'assert': 'The "assert" statement\n'
'\n'
'Execution of Python coroutines can be suspended and resumed at '
'many\n'
- 'points (see *coroutine*). Inside the body of a coroutine '
- 'function,\n'
- '"await" and "async" identifiers become reserved keywords; '
- '"await"\n'
- 'expressions, "async for" and "async with" can only be used in\n'
- 'coroutine function bodies.\n'
+ 'points (see *coroutine*). "await" expressions, "async for" and '
+ '"async\n'
+ 'with" can only be used in the body of a coroutine function.\n'
'\n'
'Functions defined with "async def" syntax are always coroutine\n'
'functions, even if they do not contain "await" or "async" '
@@ -2970,6 +2975,10 @@ topics = {'assert': 'The "assert" statement\n'
' do_stuff()\n'
' await some_coroutine()\n'
'\n'
+ 'Changed in version 3.7: "await" and "async" are now keywords;\n'
+ 'previously they were only treated as such inside the body of a\n'
+ 'coroutine function.\n'
+ '\n'
'\n'
'The "async for" statement\n'
'-------------------------\n'
@@ -3461,16 +3470,21 @@ topics = {'assert': 'The "assert" statement\n'
' on the value to determine if the result is true or '
'false.\n'
'\n'
- ' By default, "__ne__()" delegates to "__eq__()" and '
- 'inverts the\n'
- ' result unless it is "NotImplemented". There are no '
- 'other implied\n'
- ' relationships among the comparison operators, for '
- 'example, the\n'
- ' truth of "(x<y or x==y)" does not imply "x<=y". To '
- 'automatically\n'
- ' generate ordering operations from a single root '
- 'operation, see\n'
+ ' By default, "object" implements "__eq__()" by using '
+ '"is", returning\n'
+ ' "NotImplemented" in the case of a false comparison: '
+ '"True if x is y\n'
+ ' else NotImplemented". For "__ne__()", by default it '
+ 'delegates to\n'
+ ' "__eq__()" and inverts the result unless it is '
+ '"NotImplemented".\n'
+ ' There are no other implied relationships among the '
+ 'comparison\n'
+ ' operators or default implementations; for example, the '
+ 'truth of\n'
+ ' "(x<y or x==y)" does not imply "x<=y". To automatically '
+ 'generate\n'
+ ' ordering operations from a single root operation, see\n'
' "functools.total_ordering()".\n'
'\n'
' See the paragraph on "__hash__()" for some important '
@@ -5287,24 +5301,23 @@ topics = {'assert': 'The "assert" statement\n'
'for the\n'
'conversion. The alternate form is defined differently for '
'different\n'
- 'types. This option is only valid for integer, float, '
- 'complex and\n'
- 'Decimal types. For integers, when binary, octal, or '
- 'hexadecimal output\n'
- 'is used, this option adds the prefix respective "\'0b\'", '
- '"\'0o\'", or\n'
- '"\'0x\'" to the output value. For floats, complex and '
- 'Decimal the\n'
- 'alternate form causes the result of the conversion to '
- 'always contain a\n'
- 'decimal-point character, even if no digits follow it. '
- 'Normally, a\n'
- 'decimal-point character appears in the result of these '
- 'conversions\n'
- 'only if a digit follows it. In addition, for "\'g\'" and '
- '"\'G\'"\n'
- 'conversions, trailing zeros are not removed from the '
- 'result.\n'
+ 'types. This option is only valid for integer, float and '
+ 'complex\n'
+ 'types. For integers, when binary, octal, or hexadecimal '
+ 'output is\n'
+ 'used, this option adds the prefix respective "\'0b\'", '
+ '"\'0o\'", or "\'0x\'"\n'
+ 'to the output value. For float and complex the alternate '
+ 'form causes\n'
+ 'the result of the conversion to always contain a '
+ 'decimal-point\n'
+ 'character, even if no digits follow it. Normally, a '
+ 'decimal-point\n'
+ 'character appears in the result of these conversions only '
+ 'if a digit\n'
+ 'follows it. In addition, for "\'g\'" and "\'G\'" '
+ 'conversions, trailing\n'
+ 'zeros are not removed from the result.\n'
'\n'
'The "\',\'" option signals the use of a comma for a '
'thousands separator.\n'
@@ -5442,9 +5455,8 @@ topics = {'assert': 'The "assert" statement\n'
'the integer\n'
'to a floating point number before formatting.\n'
'\n'
- 'The available presentation types for floating point and '
- 'decimal values\n'
- 'are:\n'
+ 'The available presentation types for "float" and "Decimal" '
+ 'values are:\n'
'\n'
' '
'+-----------+------------------------------------------------------------+\n'
@@ -5453,24 +5465,50 @@ topics = {'assert': 'The "assert" statement\n'
'|\n'
' '
'|===========|============================================================|\n'
- ' | "\'e\'" | Exponent notation. Prints the number in '
- 'scientific |\n'
- ' | | notation using the letter ‘e’ to indicate '
- 'the exponent. |\n'
- ' | | The default precision is '
- '"6". |\n'
+ ' | "\'e\'" | Scientific notation. For a given '
+ 'precision "p", formats |\n'
+ ' | | the number in scientific notation with the '
+ 'letter ‘e’ |\n'
+ ' | | separating the coefficient from the '
+ 'exponent. The |\n'
+ ' | | coefficient has one digit before and "p" '
+ 'digits after the |\n'
+ ' | | decimal point, for a total of "p + 1" '
+ 'significant digits. |\n'
+ ' | | With no precision given, uses a precision '
+ 'of "6" digits |\n'
+ ' | | after the decimal point for "float", and '
+ 'shows all |\n'
+ ' | | coefficient digits for "Decimal". If no '
+ 'digits follow the |\n'
+ ' | | decimal point, the decimal point is also '
+ 'removed unless |\n'
+ ' | | the "#" option is '
+ 'used. |\n'
' '
'+-----------+------------------------------------------------------------+\n'
- ' | "\'E\'" | Exponent notation. Same as "\'e\'" '
- 'except it uses an upper |\n'
+ ' | "\'E\'" | Scientific notation. Same as "\'e\'" '
+ 'except it uses an upper |\n'
' | | case ‘E’ as the separator '
'character. |\n'
' '
'+-----------+------------------------------------------------------------+\n'
- ' | "\'f\'" | Fixed-point notation. Displays the '
- 'number as a fixed-point |\n'
- ' | | number. The default precision is '
- '"6". |\n'
+ ' | "\'f\'" | Fixed-point notation. For a given '
+ 'precision "p", formats |\n'
+ ' | | the number as a decimal number with '
+ 'exactly "p" digits |\n'
+ ' | | following the decimal point. With no '
+ 'precision given, uses |\n'
+ ' | | a precision of "6" digits after the '
+ 'decimal point for |\n'
+ ' | | "float", and uses a precision large enough '
+ 'to show all |\n'
+ ' | | coefficient digits for "Decimal". If no '
+ 'digits follow the |\n'
+ ' | | decimal point, the decimal point is also '
+ 'removed unless |\n'
+ ' | | the "#" option is '
+ 'used. |\n'
' '
'+-----------+------------------------------------------------------------+\n'
' | "\'F\'" | Fixed-point notation. Same as "\'f\'", '
@@ -5516,9 +5554,14 @@ topics = {'assert': 'The "assert" statement\n'
' | | regardless of the precision. A precision '
'of "0" is |\n'
' | | treated as equivalent to a precision of '
- '"1". The default |\n'
- ' | | precision is '
- '"6". |\n'
+ '"1". With no |\n'
+ ' | | precision given, uses a precision of "6" '
+ 'significant |\n'
+ ' | | digits for "float", and shows all '
+ 'coefficient digits for |\n'
+ ' | | '
+ '"Decimal". '
+ '|\n'
' '
'+-----------+------------------------------------------------------------+\n'
' | "\'G\'" | General format. Same as "\'g\'" except '
@@ -5859,20 +5902,11 @@ topics = {'assert': 'The "assert" statement\n'
'parameter list. These annotations can be any valid Python '
'expression.\n'
'The presence of annotations does not change the semantics of a\n'
- 'function. The annotation values are available as values of a\n'
+ 'function. The annotation values are available as string values '
+ 'in a\n'
'dictionary keyed by the parameters’ names in the '
'"__annotations__"\n'
- 'attribute of the function object. If the "annotations" import '
- 'from\n'
- '"__future__" is used, annotations are preserved as strings at '
- 'runtime\n'
- 'which enables postponed evaluation. Otherwise, they are '
- 'evaluated\n'
- 'when the function definition is executed. In this case '
- 'annotations\n'
- 'may be evaluated in a different order than they appear in the '
- 'source\n'
- 'code.\n'
+ 'attribute of the function object.\n'
'\n'
'It is also possible to create anonymous functions (functions not '
'bound\n'
@@ -6395,8 +6429,8 @@ topics = {'assert': 'The "assert" statement\n'
'\n'
'* other future statements.\n'
'\n'
- 'The only feature in Python 3.7 that requires using the future\n'
- 'statement is "annotations".\n'
+ 'The only feature that requires using the future statement is\n'
+ '"annotations" (see **PEP 563**).\n'
'\n'
'All historical features enabled by the future statement are still\n'
'recognized by Python 3. The list includes "absolute_import",\n'
@@ -8242,16 +8276,21 @@ topics = {'assert': 'The "assert" statement\n'
' on the value to determine if the result is true or '
'false.\n'
'\n'
- ' By default, "__ne__()" delegates to "__eq__()" and '
- 'inverts the\n'
- ' result unless it is "NotImplemented". There are no other '
- 'implied\n'
- ' relationships among the comparison operators, for '
- 'example, the\n'
- ' truth of "(x<y or x==y)" does not imply "x<=y". To '
- 'automatically\n'
- ' generate ordering operations from a single root '
- 'operation, see\n'
+ ' By default, "object" implements "__eq__()" by using "is", '
+ 'returning\n'
+ ' "NotImplemented" in the case of a false comparison: "True '
+ 'if x is y\n'
+ ' else NotImplemented". For "__ne__()", by default it '
+ 'delegates to\n'
+ ' "__eq__()" and inverts the result unless it is '
+ '"NotImplemented".\n'
+ ' There are no other implied relationships among the '
+ 'comparison\n'
+ ' operators or default implementations; for example, the '
+ 'truth of\n'
+ ' "(x<y or x==y)" does not imply "x<=y". To automatically '
+ 'generate\n'
+ ' ordering operations from a single root operation, see\n'
' "functools.total_ordering()".\n'
'\n'
' See the paragraph on "__hash__()" for some important '
@@ -8481,6 +8520,10 @@ topics = {'assert': 'The "assert" statement\n'
'syntax or\n'
' built-in functions. See Special method lookup.\n'
'\n'
+ ' For certain sensitive attribute accesses, raises an '
+ 'auditing event\n'
+ ' "object.__getattr__" with arguments "obj" and "name".\n'
+ '\n'
'object.__setattr__(self, name, value)\n'
'\n'
' Called when an attribute assignment is attempted. This '
@@ -8497,6 +8540,11 @@ topics = {'assert': 'The "assert" statement\n'
'example,\n'
' "object.__setattr__(self, name, value)".\n'
'\n'
+ ' For certain sensitive attribute assignments, raises an '
+ 'auditing\n'
+ ' event "object.__setattr__" with arguments "obj", "name", '
+ '"value".\n'
+ '\n'
'object.__delattr__(self, name)\n'
'\n'
' Like "__setattr__()" but for attribute deletion instead '
@@ -8505,6 +8553,10 @@ topics = {'assert': 'The "assert" statement\n'
'obj.name" is\n'
' meaningful for the object.\n'
'\n'
+ ' For certain sensitive attribute deletions, raises an '
+ 'auditing event\n'
+ ' "object.__delattr__" with arguments "obj" and "name".\n'
+ '\n'
'object.__dir__(self)\n'
'\n'
' Called when "dir()" is called on the object. A sequence '
@@ -9298,8 +9350,8 @@ topics = {'assert': 'The "assert" statement\n'
'\n'
' Called when the instance is “called” as a function; if '
'this method\n'
- ' is defined, "x(arg1, arg2, ...)" is a shorthand for\n'
- ' "x.__call__(arg1, arg2, ...)".\n'
+ ' is defined, "x(arg1, arg2, ...)" roughly translates to\n'
+ ' "type(x).__call__(x, arg1, ...)".\n'
'\n'
'\n'
'Emulating container types\n'
@@ -11054,9 +11106,10 @@ topics = {'assert': 'The "assert" statement\n'
'subscriptions': 'Subscriptions\n'
'*************\n'
'\n'
- 'A subscription selects an item of a sequence (string, tuple '
- 'or list)\n'
- 'or mapping (dictionary) object:\n'
+ 'Subscription of a sequence (string, tuple or list) or '
+ 'mapping\n'
+ '(dictionary) object usually selects an item from the '
+ 'collection:\n'
'\n'
' subscription ::= primary "[" expression_list "]"\n'
'\n'
@@ -11107,7 +11160,13 @@ topics = {'assert': 'The "assert" statement\n'
'\n'
'A string’s items are characters. A character is not a '
'separate data\n'
- 'type but a string of exactly one character.\n',
+ 'type but a string of exactly one character.\n'
+ '\n'
+ 'Subscription of certain *classes* or *types* creates a '
+ 'generic alias.\n'
+ 'In this case, user-defined classes can support subscription '
+ 'by\n'
+ 'providing a "__class_getitem__()" classmethod.\n',
'truth': 'Truth Value Testing\n'
'*******************\n'
'\n'
@@ -11353,6 +11412,27 @@ topics = {'assert': 'The "assert" statement\n'
'representation\n'
' in computers.\n'
'\n'
+ ' The string representations of the numeric classes, computed by\n'
+ ' "__repr__()" and "__str__()", have the following properties:\n'
+ '\n'
+ ' * They are valid numeric literals which, when passed to their '
+ 'class\n'
+ ' constructor, produce an object having the value of the '
+ 'original\n'
+ ' numeric.\n'
+ '\n'
+ ' * The representation is in base 10, when possible.\n'
+ '\n'
+ ' * Leading zeros, possibly excepting a single zero before a '
+ 'decimal\n'
+ ' point, are not shown.\n'
+ '\n'
+ ' * Trailing zeros, possibly excepting a single zero after a '
+ 'decimal\n'
+ ' point, are not shown.\n'
+ '\n'
+ ' * A sign is shown only when the number is negative.\n'
+ '\n'
' Python distinguishes between integers, floating point numbers, '
'and\n'
' complex numbers:\n'
@@ -12404,6 +12484,21 @@ topics = {'assert': 'The "assert" statement\n'
'positional\n'
' argument and a possibly empty set of keyword arguments.\n'
'\n'
+ ' Dictionaries can be created by several means:\n'
+ '\n'
+ ' * Use a comma-separated list of "key: value" pairs within '
+ 'braces:\n'
+ ' "{\'jack\': 4098, \'sjoerd\': 4127}" or "{4098: '
+ "'jack', 4127:\n"
+ ' \'sjoerd\'}"\n'
+ '\n'
+ ' * Use a dict comprehension: "{}", "{x: x ** 2 for x in '
+ 'range(10)}"\n'
+ '\n'
+ ' * Use the type constructor: "dict()", "dict([(\'foo\', '
+ "100), ('bar',\n"
+ ' 200)])", "dict(foo=100, bar=200)"\n'
+ '\n'
' If no positional argument is given, an empty dictionary '
'is created.\n'
' If a positional argument is given and it is a mapping '
diff --git a/Lib/random.py b/Lib/random.py
index 139e8a40bb..66433baa8c 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -424,13 +424,14 @@ class Random(_random.Random):
# too many calls to _randbelow(), making them slower and
# causing them to eat more entropy than necessary.
- if isinstance(population, _Set):
- _warn('Sampling from a set deprecated\n'
- 'since Python 3.9 and will be removed in a subsequent version.',
- DeprecationWarning, 2)
- population = tuple(population)
if not isinstance(population, _Sequence):
- raise TypeError("Population must be a sequence. For dicts or sets, use sorted(d).")
+ if isinstance(population, _Set):
+ _warn('Sampling from a set deprecated\n'
+ 'since Python 3.9 and will be removed in a subsequent version.',
+ DeprecationWarning, 2)
+ population = tuple(population)
+ else:
+ raise TypeError("Population must be a sequence. For dicts or sets, use sorted(d).")
n = len(population)
if counts is not None:
cum_counts = list(_accumulate(counts))
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 223e9a8a70..f0e833dc97 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -711,7 +711,7 @@ def rmtree(path, ignore_errors=False, onerror=None):
try:
fd = os.open(path, os.O_RDONLY)
except Exception:
- onerror(os.lstat, path, sys.exc_info())
+ onerror(os.open, path, sys.exc_info())
return
try:
if os.path.samestat(orig_st, os.fstat(fd)):
diff --git a/Lib/site.py b/Lib/site.py
index 4d3b869fff..5f1b31e73d 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -105,8 +105,15 @@ def makepath(*paths):
def abs_paths():
"""Set all module __file__ and __cached__ attributes to an absolute path"""
for m in set(sys.modules.values()):
- if (getattr(getattr(m, '__loader__', None), '__module__', None) not in
- ('_frozen_importlib', '_frozen_importlib_external')):
+ loader_module = None
+ try:
+ loader_module = m.__loader__.__module__
+ except AttributeError:
+ try:
+ loader_module = m.__spec__.loader.__module__
+ except AttributeError:
+ pass
+ if loader_module not in {'_frozen_importlib', '_frozen_importlib_external'}:
continue # don't mess with a PEP 302-supplied __file__
try:
m.__file__ = os.path.abspath(m.__file__)
@@ -257,6 +264,10 @@ def _getuserbase():
if env_base:
return env_base
+ # VxWorks has no home directories
+ if sys.platform == "vxworks":
+ return None
+
def joinuser(*args):
return os.path.expanduser(os.path.join(*args))
@@ -304,11 +315,14 @@ def getusersitepackages():
If the global variable ``USER_SITE`` is not initialized yet, this
function will also set it.
"""
- global USER_SITE
+ global USER_SITE, ENABLE_USER_SITE
userbase = getuserbase() # this will also set USER_BASE
if USER_SITE is None:
- USER_SITE = _get_path(userbase)
+ if userbase is None:
+ ENABLE_USER_SITE = False # disable user site and return None
+ else:
+ USER_SITE = _get_path(userbase)
return USER_SITE
@@ -623,11 +637,14 @@ def _script():
for dir in sys.path:
print(" %r," % (dir,))
print("]")
- print("USER_BASE: %r (%s)" % (user_base,
- "exists" if os.path.isdir(user_base) else "doesn't exist"))
- print("USER_SITE: %r (%s)" % (user_site,
- "exists" if os.path.isdir(user_site) else "doesn't exist"))
- print("ENABLE_USER_SITE: %r" % ENABLE_USER_SITE)
+ def exists(path):
+ if path is not None and os.path.isdir(path):
+ return "exists"
+ else:
+ return "doesn't exist"
+ print(f"USER_BASE: {user_base!r} ({exists(user_base)})")
+ print(f"USER_SITE: {user_site!r} ({exists(user_site)})")
+ print(f"ENABLE_USER_SITE: {ENABLE_USER_SITE!r}")
sys.exit(0)
buffer = []
diff --git a/Lib/smtpd.py b/Lib/smtpd.py
index 8f1a22e937..1e2adc87a2 100755
--- a/Lib/smtpd.py
+++ b/Lib/smtpd.py
@@ -163,7 +163,7 @@ class SMTPChannel(asynchat.async_chat):
# a race condition may occur if the other end is closing
# before we can get the peername
self.close()
- if err.args[0] != errno.ENOTCONN:
+ if err.errno != errno.ENOTCONN:
raise
return
print('Peer:', repr(self.peer), file=DEBUGSTREAM)
diff --git a/Lib/socket.py b/Lib/socket.py
index cafa573a30..5276cc8ba3 100755
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -377,7 +377,7 @@ class socket(_socket.socket):
try:
while True:
if timeout and not selector_select(timeout):
- raise _socket.timeout('timed out')
+ raise TimeoutError('timed out')
if count:
blocksize = count - total_sent
if blocksize <= 0:
@@ -706,7 +706,7 @@ class SocketIO(io.RawIOBase):
self._timeout_occurred = True
raise
except error as e:
- if e.args[0] in _blocking_errnos:
+ if e.errno in _blocking_errnos:
return None
raise
@@ -722,7 +722,7 @@ class SocketIO(io.RawIOBase):
return self._sock.send(b)
except error as e:
# XXX what about EINTR?
- if e.args[0] in _blocking_errnos:
+ if e.errno in _blocking_errnos:
return None
raise
diff --git a/Lib/sqlite3/__init__.py b/Lib/sqlite3/__init__.py
index 6c91df27cc..f001c0678e 100644
--- a/Lib/sqlite3/__init__.py
+++ b/Lib/sqlite3/__init__.py
@@ -21,3 +21,17 @@
# 3. This notice may not be removed or altered from any source distribution.
from sqlite3.dbapi2 import *
+
+
+# bpo-42264: OptimizedUnicode was deprecated in Python 3.10. It's scheduled
+# for removal in Python 3.12.
+def __getattr__(name):
+ if name == "OptimizedUnicode":
+ import warnings
+ msg = ("""
+ OptimizedUnicode is deprecated and will be removed in Python 3.12.
+ Since Python 3.3 it has simply been an alias for 'str'.
+ """)
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
+ return str
+ raise AttributeError(f"module 'sqlite3' has no attribute '{name}'")
diff --git a/Lib/sqlite3/test/factory.py b/Lib/sqlite3/test/factory.py
index 95dd24bdfa..d91997333b 100644
--- a/Lib/sqlite3/test/factory.py
+++ b/Lib/sqlite3/test/factory.py
@@ -254,9 +254,10 @@ class TextFactoryTests(unittest.TestCase):
self.assertTrue(row[0].endswith("reich"), "column must contain original data")
def CheckOptimizedUnicode(self):
- # In py3k, str objects are always returned when text_factory
- # is OptimizedUnicode
- self.con.text_factory = sqlite.OptimizedUnicode
+ # OptimizedUnicode is deprecated as of Python 3.10
+ with self.assertWarns(DeprecationWarning) as cm:
+ self.con.text_factory = sqlite.OptimizedUnicode
+ self.assertIn("factory.py", cm.filename)
austria = "sterreich"
germany = "Deutchland"
a_row = self.con.execute("select ?", (austria,)).fetchone()
diff --git a/Lib/statistics.py b/Lib/statistics.py
index f9d3802ec5..4b054b9611 100644
--- a/Lib/statistics.py
+++ b/Lib/statistics.py
@@ -106,7 +106,7 @@ import random
from fractions import Fraction
from decimal import Decimal
-from itertools import groupby
+from itertools import groupby, repeat
from bisect import bisect_left, bisect_right
from math import hypot, sqrt, fabs, exp, erf, tau, log, fsum
from operator import itemgetter
@@ -364,37 +364,37 @@ def geometric_mean(data):
' containing positive numbers') from None
-def harmonic_mean(data):
+def harmonic_mean(data, weights=None):
"""Return the harmonic mean of data.
The harmonic mean, sometimes called the subcontrary mean, is the
reciprocal of the arithmetic mean of the reciprocals of the data,
and is often appropriate when averaging quantities which are rates
- or ratios, for example speeds. Example:
+ or ratios, for example speeds.
- Suppose an investor purchases an equal value of shares in each of
- three companies, with P/E (price/earning) ratios of 2.5, 3 and 10.
- What is the average P/E ratio for the investor's portfolio?
+ Suppose a car travels 40 km/hr for 5 km and then speeds-up to
+ 60 km/hr for another 5 km. What is the average speed?
- >>> harmonic_mean([2.5, 3, 10]) # For an equal investment portfolio.
- 3.6
+ >>> harmonic_mean([40, 60])
+ 48.0
- Using the arithmetic mean would give an average of about 5.167, which
- is too high.
+ Suppose a car travels 40 km/hr for 5 km, and when traffic clears,
+ speeds-up to 60 km/hr for the remaining 30 km of the journey. What
+ is the average speed?
+
+ >>> harmonic_mean([40, 60], weights=[5, 30])
+ 56.0
If ``data`` is empty, or any element is less than zero,
``harmonic_mean`` will raise ``StatisticsError``.
"""
- # For a justification for using harmonic mean for P/E ratios, see
- # http://fixthepitch.pellucid.com/comps-analysis-the-missing-harmony-of-summary-statistics/
- # http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2621087
if iter(data) is data:
data = list(data)
errmsg = 'harmonic mean does not support negative values'
n = len(data)
if n < 1:
raise StatisticsError('harmonic_mean requires at least one data point')
- elif n == 1:
+ elif n == 1 and weights is None:
x = data[0]
if isinstance(x, (numbers.Real, Decimal)):
if x < 0:
@@ -402,13 +402,23 @@ def harmonic_mean(data):
return x
else:
raise TypeError('unsupported type')
+ if weights is None:
+ weights = repeat(1, n)
+ sum_weights = n
+ else:
+ if iter(weights) is weights:
+ weights = list(weights)
+ if len(weights) != n:
+ raise StatisticsError('Number of weights does not match data size')
+ _, sum_weights, _ = _sum(w for w in _fail_neg(weights, errmsg))
try:
- T, total, count = _sum(1 / x for x in _fail_neg(data, errmsg))
+ data = _fail_neg(data, errmsg)
+ T, total, count = _sum(w / x if w else 0 for w, x in zip(weights, data))
except ZeroDivisionError:
return 0
- assert count == n
- return _convert(n / total, T)
-
+ if total <= 0:
+ raise StatisticsError('Weighted sum must be positive')
+ return _convert(sum_weights / total, T)
# FIXME: investigate ways to calculate medians without sorting? Quickselect?
def median(data):
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 6a6c2fc98e..aa107cb60e 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -420,7 +420,11 @@ def check_output(*popenargs, timeout=None, **kwargs):
if 'input' in kwargs and kwargs['input'] is None:
# Explicitly passing input=None was previously equivalent to passing an
# empty string. That is maintained here for backwards compatibility.
- kwargs['input'] = '' if kwargs.get('universal_newlines', False) else b''
+ if kwargs.get('universal_newlines') or kwargs.get('text'):
+ empty = ''
+ else:
+ empty = b''
+ kwargs['input'] = empty
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
**kwargs).stdout
@@ -2078,7 +2082,11 @@ class Popen(object):
# The race condition can still happen if the race condition
# described above happens between the returncode test
# and the kill() call.
- os.kill(self.pid, sig)
+ try:
+ os.kill(self.pid, sig)
+ except ProcessLookupError:
+ # Supress the race condition error; bpo-40550.
+ pass
def terminate(self):
"""Terminate the process with SIGTERM
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index 6c87b06634..c1aaf79a67 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -51,34 +51,65 @@ _INSTALL_SCHEMES = {
'scripts': '{base}/Scripts',
'data': '{base}',
},
- # NOTE: When modifying "purelib" scheme, update site._get_path() too.
- 'nt_user': {
- 'stdlib': '{userbase}/Python{py_version_nodot_plat}',
- 'platstdlib': '{userbase}/Python{py_version_nodot_plat}',
- 'purelib': '{userbase}/Python{py_version_nodot_plat}/site-packages',
- 'platlib': '{userbase}/Python{py_version_nodot_plat}/site-packages',
- 'include': '{userbase}/Python{py_version_nodot_plat}/Include',
- 'scripts': '{userbase}/Python{py_version_nodot_plat}/Scripts',
- 'data': '{userbase}',
- },
- 'posix_user': {
- 'stdlib': '{userbase}/{platlibdir}/python{py_version_short}',
- 'platstdlib': '{userbase}/{platlibdir}/python{py_version_short}',
- 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
- 'platlib': '{userbase}/{platlibdir}/python{py_version_short}/site-packages',
- 'include': '{userbase}/include/python{py_version_short}',
- 'scripts': '{userbase}/bin',
- 'data': '{userbase}',
- },
- 'osx_framework_user': {
- 'stdlib': '{userbase}/lib/python',
- 'platstdlib': '{userbase}/lib/python',
- 'purelib': '{userbase}/lib/python/site-packages',
- 'platlib': '{userbase}/lib/python/site-packages',
- 'include': '{userbase}/include',
- 'scripts': '{userbase}/bin',
- 'data': '{userbase}',
- },
+ }
+
+
+# NOTE: site.py has copy of this function.
+# Sync it when modify this function.
+def _getuserbase():
+ env_base = os.environ.get("PYTHONUSERBASE", None)
+ if env_base:
+ return env_base
+
+ # VxWorks has no home directories
+ if sys.platform == "vxworks":
+ return None
+
+ def joinuser(*args):
+ return os.path.expanduser(os.path.join(*args))
+
+ if os.name == "nt":
+ base = os.environ.get("APPDATA") or "~"
+ return joinuser(base, "Python")
+
+ if sys.platform == "darwin" and sys._framework:
+ return joinuser("~", "Library", sys._framework,
+ "%d.%d" % sys.version_info[:2])
+
+ return joinuser("~", ".local")
+
+_HAS_USER_BASE = (_getuserbase() is not None)
+
+if _HAS_USER_BASE:
+ _INSTALL_SCHEMES |= {
+ # NOTE: When modifying "purelib" scheme, update site._get_path() too.
+ 'nt_user': {
+ 'stdlib': '{userbase}/Python{py_version_nodot_plat}',
+ 'platstdlib': '{userbase}/Python{py_version_nodot_plat}',
+ 'purelib': '{userbase}/Python{py_version_nodot_plat}/site-packages',
+ 'platlib': '{userbase}/Python{py_version_nodot_plat}/site-packages',
+ 'include': '{userbase}/Python{py_version_nodot_plat}/Include',
+ 'scripts': '{userbase}/Python{py_version_nodot_plat}/Scripts',
+ 'data': '{userbase}',
+ },
+ 'posix_user': {
+ 'stdlib': '{userbase}/{platlibdir}/python{py_version_short}',
+ 'platstdlib': '{userbase}/{platlibdir}/python{py_version_short}',
+ 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
+ 'platlib': '{userbase}/{platlibdir}/python{py_version_short}/site-packages',
+ 'include': '{userbase}/include/python{py_version_short}',
+ 'scripts': '{userbase}/bin',
+ 'data': '{userbase}',
+ },
+ 'osx_framework_user': {
+ 'stdlib': '{userbase}/lib/python',
+ 'platstdlib': '{userbase}/lib/python',
+ 'purelib': '{userbase}/lib/python/site-packages',
+ 'platlib': '{userbase}/lib/python/site-packages',
+ 'include': '{userbase}/include',
+ 'scripts': '{userbase}/bin',
+ 'data': '{userbase}',
+ },
}
_SCHEME_KEYS = ('stdlib', 'platstdlib', 'purelib', 'platlib', 'include',
@@ -183,25 +214,6 @@ def _get_default_scheme():
return os.name
-# NOTE: site.py has copy of this function.
-# Sync it when modify this function.
-def _getuserbase():
- env_base = os.environ.get("PYTHONUSERBASE", None)
- if env_base:
- return env_base
-
- def joinuser(*args):
- return os.path.expanduser(os.path.join(*args))
-
- if os.name == "nt":
- base = os.environ.get("APPDATA") or "~"
- return joinuser(base, "Python")
-
- if sys.platform == "darwin" and sys._framework:
- return joinuser("~", "Library", sys._framework,
- "%d.%d" % sys.version_info[:2])
-
- return joinuser("~", ".local")
def _parse_makefile(filename, vars=None):
@@ -424,10 +436,11 @@ def _init_posix(vars):
def _init_non_posix(vars):
"""Initialize the module as appropriate for NT"""
# set basic install directories
+ import _imp
vars['LIBDEST'] = get_path('stdlib')
vars['BINLIBDEST'] = get_path('platstdlib')
vars['INCLUDEPY'] = get_path('include')
- vars['EXT_SUFFIX'] = '.pyd'
+ vars['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
vars['EXE'] = '.exe'
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
@@ -557,10 +570,11 @@ def get_config_vars(*args):
SO = _CONFIG_VARS.get('EXT_SUFFIX')
if SO is not None:
_CONFIG_VARS['SO'] = SO
- # Setting 'userbase' is done below the call to the
- # init function to enable using 'get_config_var' in
- # the init-function.
- _CONFIG_VARS['userbase'] = _getuserbase()
+ if _HAS_USER_BASE:
+ # Setting 'userbase' is done below the call to the
+ # init function to enable using 'get_config_var' in
+ # the init-function.
+ _CONFIG_VARS['userbase'] = _getuserbase()
# Always convert srcdir to an absolute path
srcdir = _CONFIG_VARS.get('srcdir', _PROJECT_BASE)
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index e42279470d..395c0f1d30 100755
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -200,6 +200,7 @@ def itn(n, digits=8, format=DEFAULT_FORMAT):
# base-256 representation. This allows values up to (256**(digits-1))-1.
# A 0o200 byte indicates a positive number, a 0o377 byte a negative
# number.
+ original_n = n
n = int(n)
if 0 <= n < 8 ** (digits - 1):
s = bytes("%0*o" % (digits - 1, n), "ascii") + NUL
@@ -363,7 +364,7 @@ class _Stream:
try:
import zlib
except ImportError:
- raise CompressionError("zlib module is not available")
+ raise CompressionError("zlib module is not available") from None
self.zlib = zlib
self.crc = zlib.crc32(b"")
if mode == "r":
@@ -376,7 +377,7 @@ class _Stream:
try:
import bz2
except ImportError:
- raise CompressionError("bz2 module is not available")
+ raise CompressionError("bz2 module is not available") from None
if mode == "r":
self.dbuf = b""
self.cmp = bz2.BZ2Decompressor()
@@ -388,7 +389,7 @@ class _Stream:
try:
import lzma
except ImportError:
- raise CompressionError("lzma module is not available")
+ raise CompressionError("lzma module is not available") from None
if mode == "r":
self.dbuf = b""
self.cmp = lzma.LZMADecompressor()
@@ -541,8 +542,8 @@ class _Stream:
break
try:
buf = self.cmp.decompress(buf)
- except self.exception:
- raise ReadError("invalid compressed data")
+ except self.exception as e:
+ raise ReadError("invalid compressed data") from e
t.append(buf)
c += len(buf)
t = b"".join(t)
@@ -1164,8 +1165,8 @@ class TarInfo(object):
# Fetch the next header and process it.
try:
next = self.fromtarfile(tarfile)
- except HeaderError:
- raise SubsequentHeaderError("missing or bad subsequent header")
+ except HeaderError as e:
+ raise SubsequentHeaderError(str(e)) from None
# Patch the TarInfo object from the next header with
# the longname information.
@@ -1277,8 +1278,8 @@ class TarInfo(object):
# Fetch the next header.
try:
next = self.fromtarfile(tarfile)
- except HeaderError:
- raise SubsequentHeaderError("missing or bad subsequent header")
+ except HeaderError as e:
+ raise SubsequentHeaderError(str(e)) from None
# Process GNU sparse information.
if "GNU.sparse.map" in pax_headers:
@@ -1533,7 +1534,7 @@ class TarFile(object):
self.fileobj.seek(self.offset)
break
except HeaderError as e:
- raise ReadError(str(e))
+ raise ReadError(str(e)) from None
if self.mode in ("a", "w", "x"):
self._loaded = True
@@ -1669,21 +1670,21 @@ class TarFile(object):
try:
from gzip import GzipFile
except ImportError:
- raise CompressionError("gzip module is not available")
+ raise CompressionError("gzip module is not available") from None
try:
fileobj = GzipFile(name, mode + "b", compresslevel, fileobj)
- except OSError:
+ except OSError as e:
if fileobj is not None and mode == 'r':
- raise ReadError("not a gzip file")
+ raise ReadError("not a gzip file") from e
raise
try:
t = cls.taropen(name, mode, fileobj, **kwargs)
- except OSError:
+ except OSError as e:
fileobj.close()
if mode == 'r':
- raise ReadError("not a gzip file")
+ raise ReadError("not a gzip file") from e
raise
except:
fileobj.close()
@@ -1702,16 +1703,16 @@ class TarFile(object):
try:
from bz2 import BZ2File
except ImportError:
- raise CompressionError("bz2 module is not available")
+ raise CompressionError("bz2 module is not available") from None
fileobj = BZ2File(fileobj or name, mode, compresslevel=compresslevel)
try:
t = cls.taropen(name, mode, fileobj, **kwargs)
- except (OSError, EOFError):
+ except (OSError, EOFError) as e:
fileobj.close()
if mode == 'r':
- raise ReadError("not a bzip2 file")
+ raise ReadError("not a bzip2 file") from e
raise
except:
fileobj.close()
@@ -1730,16 +1731,16 @@ class TarFile(object):
try:
from lzma import LZMAFile, LZMAError
except ImportError:
- raise CompressionError("lzma module is not available")
+ raise CompressionError("lzma module is not available") from None
fileobj = LZMAFile(fileobj or name, mode, preset=preset)
try:
t = cls.taropen(name, mode, fileobj, **kwargs)
- except (LZMAError, EOFError):
+ except (LZMAError, EOFError) as e:
fileobj.close()
if mode == 'r':
- raise ReadError("not an lzma file")
+ raise ReadError("not an lzma file") from e
raise
except:
fileobj.close()
@@ -2237,6 +2238,9 @@ class TarFile(object):
try:
# For systems that support symbolic and hard links.
if tarinfo.issym():
+ if os.path.lexists(targetpath):
+ # Avoid FileExistsError on following os.symlink.
+ os.unlink(targetpath)
os.symlink(tarinfo.linkname, targetpath)
else:
# See extract().
@@ -2250,7 +2254,7 @@ class TarFile(object):
self._extract_member(self._find_link_target(tarinfo),
targetpath)
except KeyError:
- raise ExtractError("unable to resolve link inside archive")
+ raise ExtractError("unable to resolve link inside archive") from None
def chown(self, tarinfo, targetpath, numeric_owner):
"""Set owner of targetpath according to tarinfo. If numeric_owner
@@ -2278,16 +2282,16 @@ class TarFile(object):
os.lchown(targetpath, u, g)
else:
os.chown(targetpath, u, g)
- except OSError:
- raise ExtractError("could not change owner")
+ except OSError as e:
+ raise ExtractError("could not change owner") from e
def chmod(self, tarinfo, targetpath):
"""Set file permissions of targetpath according to tarinfo.
"""
try:
os.chmod(targetpath, tarinfo.mode)
- except OSError:
- raise ExtractError("could not change mode")
+ except OSError as e:
+ raise ExtractError("could not change mode") from e
def utime(self, tarinfo, targetpath):
"""Set modification time of targetpath according to tarinfo.
@@ -2296,8 +2300,8 @@ class TarFile(object):
return
try:
os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime))
- except OSError:
- raise ExtractError("could not change modification time")
+ except OSError as e:
+ raise ExtractError("could not change modification time") from e
#--------------------------------------------------------------------------
def next(self):
@@ -2333,15 +2337,15 @@ class TarFile(object):
self.offset += BLOCKSIZE
continue
elif self.offset == 0:
- raise ReadError(str(e))
+ raise ReadError(str(e)) from None
except EmptyHeaderError:
if self.offset == 0:
- raise ReadError("empty file")
+ raise ReadError("empty file") from None
except TruncatedHeaderError as e:
if self.offset == 0:
- raise ReadError(str(e))
+ raise ReadError(str(e)) from None
except SubsequentHeaderError as e:
- raise ReadError(str(e))
+ raise ReadError(str(e)) from None
break
if tarinfo is not None:
diff --git a/Lib/test/_test_atexit.py b/Lib/test/_test_atexit.py
new file mode 100644
index 0000000000..a316585311
--- /dev/null
+++ b/Lib/test/_test_atexit.py
@@ -0,0 +1,121 @@
+"""
+Tests run by test_atexit in a subprocess since it clears atexit callbacks.
+"""
+import atexit
+import sys
+import unittest
+from test import support
+
+
+class GeneralTest(unittest.TestCase):
+ def setUp(self):
+ atexit._clear()
+
+ def tearDown(self):
+ atexit._clear()
+
+ def assert_raises_unraisable(self, exc_type, func, *args):
+ with support.catch_unraisable_exception() as cm:
+ atexit.register(func, *args)
+ atexit._run_exitfuncs()
+
+ self.assertEqual(cm.unraisable.object, func)
+ self.assertEqual(cm.unraisable.exc_type, exc_type)
+ self.assertEqual(type(cm.unraisable.exc_value), exc_type)
+
+ def test_order(self):
+ # Check that callbacks are called in reverse order with the expected
+ # positional and keyword arguments.
+ calls = []
+
+ def func1(*args, **kwargs):
+ calls.append(('func1', args, kwargs))
+
+ def func2(*args, **kwargs):
+ calls.append(('func2', args, kwargs))
+
+ # be sure args are handled properly
+ atexit.register(func1, 1, 2)
+ atexit.register(func2)
+ atexit.register(func2, 3, key="value")
+ atexit._run_exitfuncs()
+
+ self.assertEqual(calls,
+ [('func2', (3,), {'key': 'value'}),
+ ('func2', (), {}),
+ ('func1', (1, 2), {})])
+
+ def test_badargs(self):
+ def func():
+ pass
+
+ # func() has no parameter, but it's called with 2 parameters
+ self.assert_raises_unraisable(TypeError, func, 1 ,2)
+
+ def test_raise(self):
+ def raise_type_error():
+ raise TypeError
+
+ self.assert_raises_unraisable(TypeError, raise_type_error)
+
+ def test_raise_unnormalized(self):
+ # bpo-10756: Make sure that an unnormalized exception is handled
+ # properly.
+ def div_zero():
+ 1 / 0
+
+ self.assert_raises_unraisable(ZeroDivisionError, div_zero)
+
+ def test_exit(self):
+ self.assert_raises_unraisable(SystemExit, sys.exit)
+
+ def test_stress(self):
+ a = [0]
+ def inc():
+ a[0] += 1
+
+ for i in range(128):
+ atexit.register(inc)
+ atexit._run_exitfuncs()
+
+ self.assertEqual(a[0], 128)
+
+ def test_clear(self):
+ a = [0]
+ def inc():
+ a[0] += 1
+
+ atexit.register(inc)
+ atexit._clear()
+ atexit._run_exitfuncs()
+
+ self.assertEqual(a[0], 0)
+
+ def test_unregister(self):
+ a = [0]
+ def inc():
+ a[0] += 1
+ def dec():
+ a[0] -= 1
+
+ for i in range(4):
+ atexit.register(inc)
+ atexit.register(dec)
+ atexit.unregister(inc)
+ atexit._run_exitfuncs()
+
+ self.assertEqual(a[0], -1)
+
+ def test_bound_methods(self):
+ l = []
+ atexit.register(l.append, 5)
+ atexit._run_exitfuncs()
+ self.assertEqual(l, [5])
+
+ atexit.unregister(l.append)
+ atexit._run_exitfuncs()
+ self.assertEqual(l, [5])
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/Lib/test/eintrdata/eintr_tester.py b/Lib/test/_test_eintr.py
index e43b59d064..e43b59d064 100644
--- a/Lib/test/eintrdata/eintr_tester.py
+++ b/Lib/test/_test_eintr.py
diff --git a/Lib/test/_test_embed_set_config.py b/Lib/test/_test_embed_set_config.py
new file mode 100644
index 0000000000..82c5d82982
--- /dev/null
+++ b/Lib/test/_test_embed_set_config.py
@@ -0,0 +1,261 @@
+# bpo-42260: Test _PyInterpreterState_GetConfigCopy()
+# and _PyInterpreterState_SetConfig().
+#
+# Test run in a subinterpreter since set_config(get_config())
+# does reset sys attributes to their state of the Python startup
+# (before the site module is run).
+
+import _testinternalcapi
+import os
+import sys
+import unittest
+
+
+MS_WINDOWS = (os.name == 'nt')
+MAX_HASH_SEED = 4294967295
+
+class SetConfigTests(unittest.TestCase):
+ def setUp(self):
+ self.old_config = _testinternalcapi.get_config()
+ self.sys_copy = dict(sys.__dict__)
+
+ def tearDown(self):
+ _testinternalcapi.set_config(self.old_config)
+ sys.__dict__.clear()
+ sys.__dict__.update(self.sys_copy)
+
+ def set_config(self, **kwargs):
+ _testinternalcapi.set_config(self.old_config | kwargs)
+
+ def check(self, **kwargs):
+ self.set_config(**kwargs)
+ for key, value in kwargs.items():
+ self.assertEqual(getattr(sys, key), value,
+ (key, value))
+
+ def test_set_invalid(self):
+ invalid_uint = -1
+ NULL = None
+ invalid_wstr = NULL
+ # PyWideStringList strings must be non-NULL
+ invalid_wstrlist = ["abc", NULL, "def"]
+
+ type_tests = []
+ value_tests = [
+ # enum
+ ('_config_init', 0),
+ ('_config_init', 4),
+ # unsigned long
+ ("hash_seed", -1),
+ ("hash_seed", MAX_HASH_SEED + 1),
+ ]
+
+ # int (unsigned)
+ options = [
+ '_config_init',
+ 'isolated',
+ 'use_environment',
+ 'dev_mode',
+ 'install_signal_handlers',
+ 'use_hash_seed',
+ 'faulthandler',
+ 'tracemalloc',
+ 'import_time',
+ 'show_ref_count',
+ 'dump_refs',
+ 'malloc_stats',
+ 'parse_argv',
+ 'site_import',
+ 'bytes_warning',
+ 'inspect',
+ 'interactive',
+ 'optimization_level',
+ 'parser_debug',
+ 'write_bytecode',
+ 'verbose',
+ 'quiet',
+ 'user_site_directory',
+ 'configure_c_stdio',
+ 'buffered_stdio',
+ 'pathconfig_warnings',
+ 'module_search_paths_set',
+ 'skip_source_first_line',
+ '_install_importlib',
+ '_init_main',
+ '_isolated_interpreter',
+ ]
+ if MS_WINDOWS:
+ options.append('legacy_windows_stdio')
+ for key in options:
+ value_tests.append((key, invalid_uint))
+ type_tests.append((key, "abc"))
+ type_tests.append((key, 2.0))
+
+ # wchar_t*
+ for key in (
+ 'filesystem_encoding',
+ 'filesystem_errors',
+ 'stdio_encoding',
+ 'stdio_errors',
+ 'check_hash_pycs_mode',
+ 'program_name',
+ 'platlibdir',
+ # optional wstr:
+ # 'pythonpath_env'
+ # 'home'
+ # 'pycache_prefix'
+ # 'run_command'
+ # 'run_module'
+ # 'run_filename'
+ # 'executable'
+ # 'prefix'
+ # 'exec_prefix'
+ # 'base_executable'
+ # 'base_prefix'
+ # 'base_exec_prefix'
+ ):
+ value_tests.append((key, invalid_wstr))
+ type_tests.append((key, b'bytes'))
+ type_tests.append((key, 123))
+
+ # PyWideStringList
+ for key in (
+ 'orig_argv',
+ 'argv',
+ 'xoptions',
+ 'warnoptions',
+ 'module_search_paths',
+ ):
+ value_tests.append((key, invalid_wstrlist))
+ type_tests.append((key, 123))
+ type_tests.append((key, "abc"))
+ type_tests.append((key, [123]))
+ type_tests.append((key, [b"bytes"]))
+
+
+ if MS_WINDOWS:
+ value_tests.append(('legacy_windows_stdio', invalid_uint))
+
+ for exc_type, tests in (
+ (ValueError, value_tests),
+ (TypeError, type_tests),
+ ):
+ for key, value in tests:
+ config = self.old_config | {key: value}
+ with self.subTest(key=key, value=value, exc_type=exc_type):
+ with self.assertRaises(exc_type):
+ _testinternalcapi.set_config(config)
+
+ def test_flags(self):
+ for sys_attr, key, value in (
+ ("debug", "parser_debug", 1),
+ ("inspect", "inspect", 2),
+ ("interactive", "interactive", 3),
+ ("optimize", "optimization_level", 4),
+ ("verbose", "verbose", 1),
+ ("bytes_warning", "bytes_warning", 10),
+ ("quiet", "quiet", 11),
+ ("isolated", "isolated", 12),
+ ):
+ with self.subTest(sys=sys_attr, key=key, value=value):
+ self.set_config(**{key: value, 'parse_argv': 0})
+ self.assertEqual(getattr(sys.flags, sys_attr), value)
+
+ self.set_config(write_bytecode=0)
+ self.assertEqual(sys.flags.dont_write_bytecode, True)
+ self.assertEqual(sys.dont_write_bytecode, True)
+
+ self.set_config(write_bytecode=1)
+ self.assertEqual(sys.flags.dont_write_bytecode, False)
+ self.assertEqual(sys.dont_write_bytecode, False)
+
+ self.set_config(user_site_directory=0, isolated=0)
+ self.assertEqual(sys.flags.no_user_site, 1)
+ self.set_config(user_site_directory=1, isolated=0)
+ self.assertEqual(sys.flags.no_user_site, 0)
+
+ self.set_config(site_import=0)
+ self.assertEqual(sys.flags.no_site, 1)
+ self.set_config(site_import=1)
+ self.assertEqual(sys.flags.no_site, 0)
+
+ self.set_config(dev_mode=0)
+ self.assertEqual(sys.flags.dev_mode, False)
+ self.set_config(dev_mode=1)
+ self.assertEqual(sys.flags.dev_mode, True)
+
+ self.set_config(use_environment=0, isolated=0)
+ self.assertEqual(sys.flags.ignore_environment, 1)
+ self.set_config(use_environment=1, isolated=0)
+ self.assertEqual(sys.flags.ignore_environment, 0)
+
+ self.set_config(use_hash_seed=1, hash_seed=0)
+ self.assertEqual(sys.flags.hash_randomization, 0)
+ self.set_config(use_hash_seed=0, hash_seed=0)
+ self.assertEqual(sys.flags.hash_randomization, 1)
+ self.set_config(use_hash_seed=1, hash_seed=123)
+ self.assertEqual(sys.flags.hash_randomization, 1)
+
+ def test_options(self):
+ self.check(warnoptions=[])
+ self.check(warnoptions=["default", "ignore"])
+
+ self.set_config(xoptions=[])
+ self.assertEqual(sys._xoptions, {})
+ self.set_config(xoptions=["dev", "tracemalloc=5"])
+ self.assertEqual(sys._xoptions, {"dev": True, "tracemalloc": "5"})
+
+ def test_pathconfig(self):
+ self.check(
+ executable='executable',
+ prefix="prefix",
+ base_prefix="base_prefix",
+ exec_prefix="exec_prefix",
+ base_exec_prefix="base_exec_prefix",
+ platlibdir="platlibdir")
+
+ self.set_config(base_executable="base_executable")
+ self.assertEqual(sys._base_executable, "base_executable")
+
+ # When base_xxx is NULL, value is copied from xxxx
+ self.set_config(
+ executable='executable',
+ prefix="prefix",
+ exec_prefix="exec_prefix",
+ base_executable=None,
+ base_prefix=None,
+ base_exec_prefix=None)
+ self.assertEqual(sys._base_executable, "executable")
+ self.assertEqual(sys.base_prefix, "prefix")
+ self.assertEqual(sys.base_exec_prefix, "exec_prefix")
+
+ def test_path(self):
+ self.set_config(module_search_paths_set=1,
+ module_search_paths=['a', 'b', 'c'])
+ self.assertEqual(sys.path, ['a', 'b', 'c'])
+
+ # Leave sys.path unchanged if module_search_paths_set=0
+ self.set_config(module_search_paths_set=0,
+ module_search_paths=['new_path'])
+ self.assertEqual(sys.path, ['a', 'b', 'c'])
+
+ def test_argv(self):
+ self.set_config(parse_argv=0,
+ argv=['python_program', 'args'],
+ orig_argv=['orig', 'orig_args'])
+ self.assertEqual(sys.argv, ['python_program', 'args'])
+ self.assertEqual(sys.orig_argv, ['orig', 'orig_args'])
+
+ self.set_config(parse_argv=0,
+ argv=[],
+ orig_argv=[])
+ self.assertEqual(sys.argv, [''])
+ self.assertEqual(sys.orig_argv, [])
+
+ def test_pycache_prefix(self):
+ self.check(pycache_prefix=None)
+ self.check(pycache_prefix="pycache_prefix")
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/Lib/test/crashers/bogus_code_obj.py b/Lib/test/crashers/bogus_code_obj.py
index 198d229491..e71b3582cf 100644
--- a/Lib/test/crashers/bogus_code_obj.py
+++ b/Lib/test/crashers/bogus_code_obj.py
@@ -14,6 +14,6 @@ the user build or load random bytecodes anyway. Otherwise, this is a
import types
-co = types.CodeType(0, 0, 0, 0, 0, b'\x04\x71\x00\x00',
+co = types.CodeType(0, 0, 0, 0, 0, 0, b'\x04\x00\x71\x00',
(), (), (), '', '', 1, b'')
exec(co)
diff --git a/Lib/test/inspect_fodder.py b/Lib/test/inspect_fodder.py
index 96a0257bfd..e1287a3159 100644
--- a/Lib/test/inspect_fodder.py
+++ b/Lib/test/inspect_fodder.py
@@ -91,3 +91,25 @@ class Callable:
custom_method = Callable().as_method_of(42)
del Callable
+
+# line 95
+class WhichComments:
+ # line 97
+ # before f
+ def f(self):
+ # line 100
+ # start f
+ return 1
+ # line 103
+ # end f
+ # line 105
+ # after f
+
+ # before asyncf - line 108
+ async def asyncf(self):
+ # start asyncf
+ return 2
+ # end asyncf
+ # after asyncf - line 113
+ # end of WhichComments - line 114
+ # after WhichComments - line 115
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 4ba749454c..5a45d78be9 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -421,7 +421,7 @@ is_jython = sys.platform.startswith('java')
is_android = hasattr(sys, 'getandroidapilevel')
-if sys.platform != 'win32':
+if sys.platform not in ('win32', 'vxworks'):
unix_shell = '/system/bin/sh' if is_android else '/bin/sh'
else:
unix_shell = None
diff --git a/Lib/test/support/bytecode_helper.py b/Lib/test/support/bytecode_helper.py
index 348e277c16..471d4a68f9 100644
--- a/Lib/test/support/bytecode_helper.py
+++ b/Lib/test/support/bytecode_helper.py
@@ -35,7 +35,8 @@ class BytecodeTestCase(unittest.TestCase):
disassembly = self.get_disassembly_as_string(x)
if argval is _UNSPECIFIED:
msg = '%s occurs in bytecode:\n%s' % (opname, disassembly)
+ self.fail(msg)
elif instr.argval == argval:
msg = '(%s,%r) occurs in bytecode:\n%s'
msg = msg % (opname, argval, disassembly)
- self.fail(msg)
+ self.fail(msg)
diff --git a/Lib/test/support/script_helper.py b/Lib/test/support/script_helper.py
index 09bb586dcf..6d699c8486 100644
--- a/Lib/test/support/script_helper.py
+++ b/Lib/test/support/script_helper.py
@@ -11,12 +11,14 @@ import py_compile
import zipfile
from importlib.util import source_from_cache
+from test import support
from test.support.import_helper import make_legacy_pyc
# Cached result of the expensive test performed in the function below.
__cached_interp_requires_environment = None
+
def interpreter_requires_environment():
"""
Returns True if our sys.executable interpreter requires environment
@@ -136,12 +138,14 @@ def run_python_until_end(*args, **env_vars):
rc = proc.returncode
return _PythonRunResult(rc, out, err), cmd_line
+
def _assert_python(expected_success, /, *args, **env_vars):
res, cmd_line = run_python_until_end(*args, **env_vars)
if (res.rc and expected_success) or (not res.rc and not expected_success):
res.fail(cmd_line)
return res
+
def assert_python_ok(*args, **env_vars):
"""
Assert that running the interpreter with `args` and optional environment
@@ -155,6 +159,7 @@ def assert_python_ok(*args, **env_vars):
"""
return _assert_python(True, *args, **env_vars)
+
def assert_python_failure(*args, **env_vars):
"""
Assert that running the interpreter with `args` and optional environment
@@ -165,6 +170,7 @@ def assert_python_failure(*args, **env_vars):
"""
return _assert_python(False, *args, **env_vars)
+
def spawn_python(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw):
"""Run a Python subprocess with the given arguments.
@@ -187,6 +193,7 @@ def spawn_python(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw):
stdout=stdout, stderr=stderr,
**kw)
+
def kill_python(p):
"""Run the given Popen process until completion and return stdout."""
p.stdin.close()
@@ -198,6 +205,7 @@ def kill_python(p):
subprocess._cleanup()
return data
+
def make_script(script_dir, script_basename, source, omit_suffix=False):
script_filename = script_basename
if not omit_suffix:
@@ -209,6 +217,7 @@ def make_script(script_dir, script_basename, source, omit_suffix=False):
importlib.invalidate_caches()
return script_name
+
def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None):
zip_filename = zip_basename+os.extsep+'zip'
zip_name = os.path.join(zip_dir, zip_filename)
@@ -228,10 +237,12 @@ def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None):
# zip_file.printdir()
return zip_name, os.path.join(zip_name, name_in_zip)
+
def make_pkg(pkg_dir, init_source=''):
os.mkdir(pkg_dir)
make_script(pkg_dir, '__init__', init_source)
+
def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
source, depth=1, compiled=False):
unlink = []
@@ -260,3 +271,24 @@ def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
# print 'Contents of %r:' % zip_name
# zip_file.printdir()
return zip_name, os.path.join(zip_name, script_name_in_zip)
+
+
+def run_test_script(script):
+ # use -u to try to get the full output if the test hangs or crash
+ if support.verbose:
+ def title(text):
+ return f"===== {text} ======"
+
+ name = f"script {os.path.basename(script)}"
+ print()
+ print(title(name), flush=True)
+ # In verbose mode, the child process inherit stdout and stdout,
+ # to see output in realtime and reduce the risk of losing output.
+ args = [sys.executable, "-E", "-X", "faulthandler", "-u", script, "-v"]
+ proc = subprocess.run(args)
+ print(title(f"{name} completed: exit code {proc.returncode}"),
+ flush=True)
+ if proc.returncode:
+ raise AssertionError(f"{name} failed")
+ else:
+ assert_python_ok("-u", script, "-v")
diff --git a/Lib/test/support/socket_helper.py b/Lib/test/support/socket_helper.py
index 7070c12c25..e78712b74b 100644
--- a/Lib/test/support/socket_helper.py
+++ b/Lib/test/support/socket_helper.py
@@ -225,7 +225,7 @@ def transient_internet(resource_name, *, timeout=_NOT_SET, errnos=()):
def filter_error(err):
n = getattr(err, 'errno', None)
- if (isinstance(err, socket.timeout) or
+ if (isinstance(err, TimeoutError) or
(isinstance(err, socket.gaierror) and n in gai_errnos) or
(isinstance(err, urllib.error.HTTPError) and
500 <= err.code <= 599) or
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index e98c15b11a..ec9711e4f6 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -2078,7 +2078,7 @@ class TestAddSubparsers(TestCase):
bar bar help
{1,2,3} command help
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo foo help
'''))
@@ -2097,7 +2097,7 @@ class TestAddSubparsers(TestCase):
bar bar help
{1,2,3} command help
- optional arguments:
+ options:
-h, --help show this help message and exit
++foo foo help
'''))
@@ -2114,7 +2114,7 @@ class TestAddSubparsers(TestCase):
main description
- optional arguments:
+ options:
-h, --help show this help message and exit
--non-breaking help message containing non-breaking spaces shall not
wrap\N{NO-BREAK SPACE}at non-breaking spaces
@@ -2133,7 +2133,7 @@ class TestAddSubparsers(TestCase):
bar bar help
{1,2,3} command help
- optional arguments:
+ options:
+h, ++help show this help message and exit
++foo foo help
'''))
@@ -2154,7 +2154,7 @@ class TestAddSubparsers(TestCase):
2 2 help
3 3 help
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo foo help
'''))
@@ -2179,7 +2179,7 @@ class TestAddSubparsers(TestCase):
positional arguments:
bar bar help
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo foo help
@@ -2203,7 +2203,7 @@ class TestAddSubparsers(TestCase):
positional arguments:
{a,b,c} x help
- optional arguments:
+ options:
-h, --help show this help message and exit
-w W w help
'''))
@@ -2217,7 +2217,7 @@ class TestAddSubparsers(TestCase):
positional arguments:
z z help
- optional arguments:
+ options:
-h, --help show this help message and exit
-y {1,2,3} y help
'''))
@@ -2249,7 +2249,7 @@ class TestAddSubparsers(TestCase):
positional arguments:
bar bar help
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo foo help
@@ -2437,7 +2437,7 @@ class TestParentParsers(TestCase):
a
z
- optional arguments:
+ options:
-h, --help show this help message and exit
-b B
--w W
@@ -2467,7 +2467,7 @@ class TestParentParsers(TestCase):
self.assertEqual(parser_help, textwrap.dedent('''\
usage: {}{}[-h] [-w W] [-x X] [-y Y | -z Z]
- optional arguments:
+ options:
-h, --help show this help message and exit
-y Y
-z Z
@@ -2512,7 +2512,7 @@ class TestMutuallyExclusiveGroupErrors(TestCase):
expected = '''\
usage: PROG [-h] [--foo | --bar] [--soup | --nuts]
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo
--bar
@@ -2597,7 +2597,7 @@ class TestMutuallyExclusiveSimple(MEMixin, TestCase):
'''
help = '''\
- optional arguments:
+ options:
-h, --help show this help message and exit
--bar BAR bar help
--baz [BAZ] baz help
@@ -2638,7 +2638,7 @@ class TestMutuallyExclusiveLong(MEMixin, TestCase):
'''
help = '''\
- optional arguments:
+ options:
-h, --help show this help message and exit
--abcde ABCDE abcde help
--fghij FGHIJ fghij help
@@ -2674,7 +2674,7 @@ class TestMutuallyExclusiveFirstSuppressed(MEMixin, TestCase):
'''
help = '''\
- optional arguments:
+ options:
-h, --help show this help message and exit
-y y help
'''
@@ -2711,7 +2711,7 @@ class TestMutuallyExclusiveManySuppressed(MEMixin, TestCase):
'''
help = '''\
- optional arguments:
+ options:
-h, --help show this help message and exit
'''
@@ -2754,7 +2754,7 @@ class TestMutuallyExclusiveOptionalAndPositional(MEMixin, TestCase):
positional arguments:
badger BADGER
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO
--spam SPAM SPAM
@@ -2793,7 +2793,7 @@ class TestMutuallyExclusiveOptionalsMixed(MEMixin, TestCase):
'''
help = '''\
- optional arguments:
+ options:
-h, --help show this help message and exit
-x x help
-a a help
@@ -2832,7 +2832,7 @@ class TestMutuallyExclusiveInGroup(MEMixin, TestCase):
'''
help = '''\
- optional arguments:
+ options:
-h, --help show this help message and exit
Titled group:
@@ -2877,7 +2877,7 @@ class TestMutuallyExclusiveOptionalsAndPositionalsMixed(MEMixin, TestCase):
x x help
a a help
- optional arguments:
+ options:
-h, --help show this help message and exit
-y y help
-b b help
@@ -2908,7 +2908,7 @@ class TestMutuallyExclusiveNested(MEMixin, TestCase):
help = '''\
- optional arguments:
+ options:
-h, --help show this help message and exit
-a A
-b B
@@ -3226,7 +3226,7 @@ class TestHelpBiggerOptionals(HelpTestCase):
foo FOO HELP
bar BAR HELP
- optional arguments:
+ options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-x X HELP
@@ -3271,7 +3271,7 @@ class TestShortColumns(HelpTestCase):
bar
BAR HELP
- optional arguments:
+ options:
-h, --help
show this
help
@@ -3321,7 +3321,7 @@ class TestHelpBiggerOptionalGroups(HelpTestCase):
foo FOO HELP
bar BAR HELP
- optional arguments:
+ options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-x X HELP
@@ -3362,7 +3362,7 @@ class TestHelpBiggerPositionals(HelpTestCase):
ekiekiekifekang EKI HELP
bar BAR HELP
- optional arguments:
+ options:
-h, --help show this help message and exit
-x X HELP
--y Y Y HELP
@@ -3409,7 +3409,7 @@ multiple
positional arguments:
yyy normal y help
- optional arguments:
+ options:
-h, --help show this help message and exit
-x XX oddly formatted -x help
@@ -3449,7 +3449,7 @@ DD DD DD
YHYH YHYH
YHYH YHYH YHYH YHYH YHYH YHYH YHYH YH
- optional arguments:
+ options:
-h, --help show this help message and exit
-x XX XHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH \
HXXHH HXXHH
@@ -3492,7 +3492,7 @@ DD DD DD
YHYH YHYH
YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YH
- optional arguments:
+ options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-x XXXXXXXXXXXXXXXXXXXXXXXXX
@@ -3554,7 +3554,7 @@ class TestHelpUsage(HelpTestCase):
b b
c c
- optional arguments:
+ options:
-h, --help show this help message and exit
-w W [W ...] w
-x [X ...] x
@@ -3623,7 +3623,7 @@ class TestHelpUsageLongProg(HelpTestCase):
a
b
- optional arguments:
+ options:
-h, --help show this help message and exit
-w W
-x X
@@ -3657,7 +3657,7 @@ class TestHelpUsageLongProgOptionsWrap(HelpTestCase):
a
b
- optional arguments:
+ options:
-h, --help show this help message and exit
-w WWWWWWWWWWWWWWWWWWWWWWWWW
-x XXXXXXXXXXXXXXXXXXXXXXXXX
@@ -3720,7 +3720,7 @@ class TestHelpUsageOptionalsWrap(HelpTestCase):
b
c
- optional arguments:
+ options:
-h, --help show this help message and exit
-w WWWWWWWWWWWWWWWWWWWWWWWWW
-x XXXXXXXXXXXXXXXXXXXXXXXXX
@@ -3755,7 +3755,7 @@ class TestHelpUsagePositionalsWrap(HelpTestCase):
bbbbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccccc
- optional arguments:
+ options:
-h, --help show this help message and exit
-x X
-y Y
@@ -3791,7 +3791,7 @@ class TestHelpUsageOptionalsPositionalsWrap(HelpTestCase):
bbbbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccccc
- optional arguments:
+ options:
-h, --help show this help message and exit
-x XXXXXXXXXXXXXXXXXXXXXXXXX
-y YYYYYYYYYYYYYYYYYYYYYYYYY
@@ -3817,7 +3817,7 @@ class TestHelpUsageOptionalsOnlyWrap(HelpTestCase):
'''
help = usage + '''\
- optional arguments:
+ options:
-h, --help show this help message and exit
-x XXXXXXXXXXXXXXXXXXXXXXXXX
-y YYYYYYYYYYYYYYYYYYYYYYYYY
@@ -3882,7 +3882,7 @@ class TestHelpVariableExpansion(HelpTestCase):
spam spam PROG None
badger badger PROG 0.5
- optional arguments:
+ options:
-h, --help show this help message and exit
-x X x PROG None int %
-y y PROG 42 XXX
@@ -3907,7 +3907,7 @@ class TestHelpVariableExpansionUsageSupplied(HelpTestCase):
''')
help = usage + '''\
- optional arguments:
+ options:
-h, --help show this help message and exit
'''
version = ''
@@ -3939,7 +3939,7 @@ class TestHelpSuppressUsage(HelpTestCase):
positional arguments:
spam spam help
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO foo help
'''
@@ -3986,7 +3986,7 @@ class TestHelpSuppressOptionalGroup(HelpTestCase):
positional arguments:
spam spam help
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO foo help
'''
@@ -4007,7 +4007,7 @@ class TestHelpSuppressPositional(HelpTestCase):
'''
help = usage + '''\
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO foo help
'''
@@ -4027,7 +4027,7 @@ class TestHelpRequiredOptional(HelpTestCase):
'''
help = usage + '''\
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO foo help
'''
@@ -4048,7 +4048,7 @@ class TestHelpAlternatePrefixChars(HelpTestCase):
'''
help = usage + '''\
- optional arguments:
+ options:
^^foo foo help
;b BAR, ;;bar BAR bar help
'''
@@ -4072,7 +4072,7 @@ class TestHelpNoHelpOptional(HelpTestCase):
positional arguments:
spam spam help
- optional arguments:
+ options:
--foo FOO foo help
'''
version = ''
@@ -4095,7 +4095,7 @@ class TestHelpNone(HelpTestCase):
positional arguments:
spam
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO
'''
@@ -4119,7 +4119,7 @@ class TestHelpTupleMetavar(HelpTestCase):
'''
help = usage + '''\
- optional arguments:
+ options:
-h, --help show this help message and exit
-w W1 [W2 ...] w
-x [X1 [X2 ...]] x
@@ -4163,7 +4163,7 @@ class TestHelpRawText(HelpTestCase):
positional arguments:
spam spam help
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO foo help should also
appear as given here
@@ -4212,7 +4212,7 @@ class TestHelpRawDescription(HelpTestCase):
positional arguments:
spam spam help
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO foo help should not retain this odd formatting
@@ -4254,7 +4254,7 @@ class TestHelpArgumentDefaults(HelpTestCase):
spam spam help
badger badger help (default: wooden)
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO foo help - oh and by the way, None
--bar bar help (default: False)
@@ -4279,7 +4279,7 @@ class TestHelpVersionAction(HelpTestCase):
description
- optional arguments:
+ options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
'''
@@ -4305,7 +4305,7 @@ class TestHelpVersionActionSuppress(HelpTestCase):
positional arguments:
spam spam help
- optional arguments:
+ options:
-h, --help show this help message and exit
--foo FOO foo help
'''
@@ -4331,7 +4331,7 @@ class TestHelpSubparsersOrdering(HelpTestCase):
positional arguments:
{a,b,c,d,e}
- optional arguments:
+ options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
'''
@@ -4372,7 +4372,7 @@ class TestHelpSubparsersWithHelpOrdering(HelpTestCase):
d d subcommand help
e e subcommand help
- optional arguments:
+ options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
'''
@@ -4404,7 +4404,7 @@ class TestHelpMetavarTypeFormatter(HelpTestCase):
positional arguments:
int
- optional arguments:
+ options:
-h, --help show this help message and exit
-b custom_type
-c SOME FLOAT
@@ -4596,7 +4596,7 @@ class TestConflictHandling(TestCase):
self.assertEqual(parser.format_help(), textwrap.dedent('''\
usage: PROG [-h] [-x X]
- optional arguments:
+ options:
-h, --help show this help message and exit
-x X NEW X
'''))
@@ -4606,7 +4606,7 @@ class TestConflictHandling(TestCase):
self.assertEqual(parser.format_help(), textwrap.dedent('''\
usage: PROG [-h] [-x X] [--spam NEW_SPAM]
- optional arguments:
+ options:
-h, --help show this help message and exit
-x X NEW X
--spam NEW_SPAM
@@ -5337,7 +5337,7 @@ class TestWrappingMetavar(TestCase):
usage: this_is_spammy_prog_with_a_long_name_sorry_about_the_name
[-h] [--proxy <http[s]://example:1234>]
- optional arguments:
+ options:
-h, --help show this help message and exit
--proxy <http[s]://example:1234>
'''))
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index c423f54548..77a0c64a88 100644
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -393,7 +393,7 @@ class BaseTest:
a.insert(0, self.outside)
self.assertEqual(list(exhit), [])
# The iterator index points past the 0th position so inserting
- # an element in the beggining does not make it appear.
+ # an element in the beginning does not make it appear.
self.assertEqual(list(empit), [])
self.assertEqual(list(a), [self.outside] + list(self.example))
diff --git a/Lib/test/test_asdl_parser.py b/Lib/test/test_asdl_parser.py
index 2c14817aae..d2c2b51334 100644
--- a/Lib/test/test_asdl_parser.py
+++ b/Lib/test/test_asdl_parser.py
@@ -1,6 +1,7 @@
"""Tests for the asdl parser in Parser/asdl.py"""
import importlib.machinery
+import importlib.util
import os
from os.path import dirname
import sys
@@ -26,7 +27,10 @@ class TestAsdlParser(unittest.TestCase):
sys.path.insert(0, parser_dir)
loader = importlib.machinery.SourceFileLoader(
'asdl', os.path.join(parser_dir, 'asdl.py'))
- cls.asdl = loader.load_module()
+ spec = importlib.util.spec_from_loader('asdl', loader)
+ module = importlib.util.module_from_spec(spec)
+ loader.exec_module(module)
+ cls.asdl = module
cls.mod = cls.asdl.parse(os.path.join(parser_dir, 'Python.asdl'))
cls.assertTrue(cls.asdl.check(cls.mod), 'Module validation failed')
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index be4b0f78ce..451f40d1f8 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -1011,6 +1011,18 @@ Module(
self.assertEqual(ast.literal_eval(" \t -1"), -1)
self.assertRaises(IndentationError, ast.literal_eval, "\n -1")
+ def test_literal_eval_malformed_lineno(self):
+ msg = r'malformed node or string on line 3:'
+ with self.assertRaisesRegex(ValueError, msg):
+ ast.literal_eval("{'a': 1,\n'b':2,\n'c':++3,\n'd':4}")
+
+ node = ast.UnaryOp(
+ ast.UAdd(), ast.UnaryOp(ast.UAdd(), ast.Constant(6)))
+ self.assertIsNone(getattr(node, 'lineno', None))
+ msg = r'malformed node or string:'
+ with self.assertRaisesRegex(ValueError, msg):
+ ast.literal_eval(node)
+
def test_bad_integer(self):
# issue13436: Bad error message with invalid numeric values
body = [ast.ImportFrom(module='time',
diff --git a/Lib/test/test_asyncio/functional.py b/Lib/test/test_asyncio/functional.py
index 5cd0659387..74490a869d 100644
--- a/Lib/test/test_asyncio/functional.py
+++ b/Lib/test/test_asyncio/functional.py
@@ -248,7 +248,7 @@ class TestThreadedServer(SocketThread):
conn, addr = self._sock.accept()
except BlockingIOError:
continue
- except socket.timeout:
+ except TimeoutError:
if not self._active:
return
else:
diff --git a/Lib/test/test_asyncio/test_asyncio_waitfor.py b/Lib/test/test_asyncio/test_asyncio_waitfor.py
new file mode 100644
index 0000000000..2ca64abbeb
--- /dev/null
+++ b/Lib/test/test_asyncio/test_asyncio_waitfor.py
@@ -0,0 +1,61 @@
+import asyncio
+import unittest
+import time
+
+def tearDownModule():
+ asyncio.set_event_loop_policy(None)
+
+
+class SlowTask:
+ """ Task will run for this defined time, ignoring cancel requests """
+ TASK_TIMEOUT = 0.2
+
+ def __init__(self):
+ self.exited = False
+
+ async def run(self):
+ exitat = time.monotonic() + self.TASK_TIMEOUT
+
+ while True:
+ tosleep = exitat - time.monotonic()
+ if tosleep <= 0:
+ break
+
+ try:
+ await asyncio.sleep(tosleep)
+ except asyncio.CancelledError:
+ pass
+
+ self.exited = True
+
+class AsyncioWaitForTest(unittest.TestCase):
+
+ async def atest_asyncio_wait_for_cancelled(self):
+ t = SlowTask()
+
+ waitfortask = asyncio.create_task(asyncio.wait_for(t.run(), t.TASK_TIMEOUT * 2))
+ await asyncio.sleep(0)
+ waitfortask.cancel()
+ await asyncio.wait({waitfortask})
+
+ self.assertTrue(t.exited)
+
+ def test_asyncio_wait_for_cancelled(self):
+ asyncio.run(self.atest_asyncio_wait_for_cancelled())
+
+ async def atest_asyncio_wait_for_timeout(self):
+ t = SlowTask()
+
+ try:
+ await asyncio.wait_for(t.run(), t.TASK_TIMEOUT / 2)
+ except asyncio.TimeoutError:
+ pass
+
+ self.assertTrue(t.exited)
+
+ def test_asyncio_wait_for_timeout(self):
+ asyncio.run(self.atest_asyncio_wait_for_timeout())
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
index f74dabc2db..e40e7999b6 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -1160,9 +1160,7 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
@unittest.skipUnless(socket_helper.IPV6_ENABLED, 'no IPv6 support')
def test_create_server_ipv6(self):
async def main():
- with self.assertWarns(DeprecationWarning):
- srv = await asyncio.start_server(
- lambda: None, '::1', 0, loop=self.loop)
+ srv = await asyncio.start_server(lambda: None, '::1', 0)
try:
self.assertGreater(len(srv.sockets), 0)
finally:
@@ -1747,6 +1745,8 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
MyDatagramProto, allow_broadcast=True, sock=FakeSock())
self.assertRaises(ValueError, self.loop.run_until_complete, fut)
+ @unittest.skipIf(sys.platform == 'vxworks',
+ "SO_BROADCAST is enabled by default on VxWorks")
def test_create_datagram_endpoint_sockopts(self):
# Socket options should not be applied unless asked for.
# SO_REUSEPORT is not available on all platforms.
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index b8fe466cd5..6523a79b4a 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -22,7 +22,7 @@ import unittest
from unittest import mock
import weakref
-if sys.platform != 'win32':
+if sys.platform not in ('win32', 'vxworks'):
import tty
import asyncio
@@ -206,8 +206,8 @@ class MySubprocessProtocol(asyncio.SubprocessProtocol):
self.disconnects = {fd: loop.create_future() for fd in range(3)}
self.data = {1: b'', 2: b''}
self.returncode = None
- self.got_data = {1: asyncio.Event(loop=loop),
- 2: asyncio.Event(loop=loop)}
+ self.got_data = {1: asyncio.Event(),
+ 2: asyncio.Event()}
def connection_made(self, transport):
self.transport = transport
@@ -294,11 +294,8 @@ class EventLoopTestsMixin:
self.loop.stop()
self.loop.call_later(0.1, callback, 'hello world')
- t0 = time.monotonic()
self.loop.run_forever()
- t1 = time.monotonic()
self.assertEqual(results, ['hello world'])
- self.assertTrue(0.08 <= t1-t0 <= 0.8, t1-t0)
def test_call_soon(self):
results = []
@@ -468,6 +465,8 @@ class EventLoopTestsMixin:
self.assertFalse(self.loop.remove_signal_handler(signal.SIGINT))
@unittest.skipUnless(hasattr(signal, 'SIGALRM'), 'No SIGALRM')
+ @unittest.skipUnless(hasattr(signal, 'setitimer'),
+ 'need signal.setitimer()')
def test_signal_handling_while_selecting(self):
# Test with a signal actually arriving during a select() call.
caught = 0
@@ -485,6 +484,8 @@ class EventLoopTestsMixin:
self.assertEqual(caught, 1)
@unittest.skipUnless(hasattr(signal, 'SIGALRM'), 'No SIGALRM')
+ @unittest.skipUnless(hasattr(signal, 'setitimer'),
+ 'need signal.setitimer()')
def test_signal_handling_args(self):
some_args = (42,)
caught = 0
@@ -1374,6 +1375,7 @@ class EventLoopTestsMixin:
@unittest.skipUnless(sys.platform != 'win32',
"Don't support pipes for Windows")
+ @unittest.skipUnless(hasattr(os, 'openpty'), 'need os.openpty()')
def test_read_pty_output(self):
proto = MyReadPipeProto(loop=self.loop)
@@ -1471,6 +1473,7 @@ class EventLoopTestsMixin:
@unittest.skipUnless(sys.platform != 'win32',
"Don't support pipes for Windows")
+ @unittest.skipUnless(hasattr(os, 'openpty'), 'need os.openpty()')
# select, poll and kqueue don't support character devices (PTY) on Mac OS X
# older than 10.6 (Snow Leopard)
@support.requires_mac_ver(10, 6)
@@ -1515,6 +1518,7 @@ class EventLoopTestsMixin:
@unittest.skipUnless(sys.platform != 'win32',
"Don't support pipes for Windows")
+ @unittest.skipUnless(hasattr(os, 'openpty'), 'need os.openpty()')
# select, poll and kqueue don't support character devices (PTY) on Mac OS X
# older than 10.6 (Snow Leopard)
@support.requires_mac_ver(10, 6)
@@ -1740,20 +1744,20 @@ class SubprocessTestsMixin:
connect = self.loop.subprocess_exec(
functools.partial(MySubprocessProtocol, self.loop),
sys.executable, prog)
- with self.assertWarns(DeprecationWarning):
- transp, proto = self.loop.run_until_complete(connect)
- self.assertIsInstance(proto, MySubprocessProtocol)
- self.loop.run_until_complete(proto.connected)
- self.assertEqual('CONNECTED', proto.state)
- stdin = transp.get_pipe_transport(0)
- stdin.write(b'Python The Winner')
- self.loop.run_until_complete(proto.got_data[1].wait())
- with test_utils.disable_logger():
- transp.close()
- self.loop.run_until_complete(proto.completed)
- self.check_killed(proto.returncode)
- self.assertEqual(b'Python The Winner', proto.data[1])
+ transp, proto = self.loop.run_until_complete(connect)
+ self.assertIsInstance(proto, MySubprocessProtocol)
+ self.loop.run_until_complete(proto.connected)
+ self.assertEqual('CONNECTED', proto.state)
+
+ stdin = transp.get_pipe_transport(0)
+ stdin.write(b'Python The Winner')
+ self.loop.run_until_complete(proto.got_data[1].wait())
+ with test_utils.disable_logger():
+ transp.close()
+ self.loop.run_until_complete(proto.completed)
+ self.check_killed(proto.returncode)
+ self.assertEqual(b'Python The Winner', proto.data[1])
def test_subprocess_interactive(self):
prog = os.path.join(os.path.dirname(__file__), 'echo.py')
@@ -1762,51 +1766,48 @@ class SubprocessTestsMixin:
functools.partial(MySubprocessProtocol, self.loop),
sys.executable, prog)
- with self.assertWarns(DeprecationWarning):
- transp, proto = self.loop.run_until_complete(connect)
- self.assertIsInstance(proto, MySubprocessProtocol)
- self.loop.run_until_complete(proto.connected)
- self.assertEqual('CONNECTED', proto.state)
+ transp, proto = self.loop.run_until_complete(connect)
+ self.assertIsInstance(proto, MySubprocessProtocol)
+ self.loop.run_until_complete(proto.connected)
+ self.assertEqual('CONNECTED', proto.state)
- stdin = transp.get_pipe_transport(0)
- stdin.write(b'Python ')
- self.loop.run_until_complete(proto.got_data[1].wait())
- proto.got_data[1].clear()
- self.assertEqual(b'Python ', proto.data[1])
+ stdin = transp.get_pipe_transport(0)
+ stdin.write(b'Python ')
+ self.loop.run_until_complete(proto.got_data[1].wait())
+ proto.got_data[1].clear()
+ self.assertEqual(b'Python ', proto.data[1])
- stdin.write(b'The Winner')
- self.loop.run_until_complete(proto.got_data[1].wait())
- self.assertEqual(b'Python The Winner', proto.data[1])
+ stdin.write(b'The Winner')
+ self.loop.run_until_complete(proto.got_data[1].wait())
+ self.assertEqual(b'Python The Winner', proto.data[1])
- with test_utils.disable_logger():
- transp.close()
- self.loop.run_until_complete(proto.completed)
- self.check_killed(proto.returncode)
+ with test_utils.disable_logger():
+ transp.close()
+ self.loop.run_until_complete(proto.completed)
+ self.check_killed(proto.returncode)
def test_subprocess_shell(self):
- with self.assertWarns(DeprecationWarning):
- connect = self.loop.subprocess_shell(
- functools.partial(MySubprocessProtocol, self.loop),
- 'echo Python')
- transp, proto = self.loop.run_until_complete(connect)
- self.assertIsInstance(proto, MySubprocessProtocol)
- self.loop.run_until_complete(proto.connected)
+ connect = self.loop.subprocess_shell(
+ functools.partial(MySubprocessProtocol, self.loop),
+ 'echo Python')
+ transp, proto = self.loop.run_until_complete(connect)
+ self.assertIsInstance(proto, MySubprocessProtocol)
+ self.loop.run_until_complete(proto.connected)
- transp.get_pipe_transport(0).close()
- self.loop.run_until_complete(proto.completed)
- self.assertEqual(0, proto.returncode)
- self.assertTrue(all(f.done() for f in proto.disconnects.values()))
- self.assertEqual(proto.data[1].rstrip(b'\r\n'), b'Python')
- self.assertEqual(proto.data[2], b'')
- transp.close()
+ transp.get_pipe_transport(0).close()
+ self.loop.run_until_complete(proto.completed)
+ self.assertEqual(0, proto.returncode)
+ self.assertTrue(all(f.done() for f in proto.disconnects.values()))
+ self.assertEqual(proto.data[1].rstrip(b'\r\n'), b'Python')
+ self.assertEqual(proto.data[2], b'')
+ transp.close()
def test_subprocess_exitcode(self):
connect = self.loop.subprocess_shell(
functools.partial(MySubprocessProtocol, self.loop),
'exit 7', stdin=None, stdout=None, stderr=None)
- with self.assertWarns(DeprecationWarning):
- transp, proto = self.loop.run_until_complete(connect)
+ transp, proto = self.loop.run_until_complete(connect)
self.assertIsInstance(proto, MySubprocessProtocol)
self.loop.run_until_complete(proto.completed)
self.assertEqual(7, proto.returncode)
@@ -1816,8 +1817,8 @@ class SubprocessTestsMixin:
connect = self.loop.subprocess_shell(
functools.partial(MySubprocessProtocol, self.loop),
'exit 7', stdin=None, stdout=None, stderr=None)
- with self.assertWarns(DeprecationWarning):
- transp, proto = self.loop.run_until_complete(connect)
+
+ transp, proto = self.loop.run_until_complete(connect)
self.assertIsInstance(proto, MySubprocessProtocol)
self.assertIsNone(transp.get_pipe_transport(0))
self.assertIsNone(transp.get_pipe_transport(1))
@@ -1833,15 +1834,14 @@ class SubprocessTestsMixin:
functools.partial(MySubprocessProtocol, self.loop),
sys.executable, prog)
- with self.assertWarns(DeprecationWarning):
- transp, proto = self.loop.run_until_complete(connect)
- self.assertIsInstance(proto, MySubprocessProtocol)
- self.loop.run_until_complete(proto.connected)
+ transp, proto = self.loop.run_until_complete(connect)
+ self.assertIsInstance(proto, MySubprocessProtocol)
+ self.loop.run_until_complete(proto.connected)
- transp.kill()
- self.loop.run_until_complete(proto.completed)
- self.check_killed(proto.returncode)
- transp.close()
+ transp.kill()
+ self.loop.run_until_complete(proto.completed)
+ self.check_killed(proto.returncode)
+ transp.close()
def test_subprocess_terminate(self):
prog = os.path.join(os.path.dirname(__file__), 'echo.py')
@@ -1850,15 +1850,14 @@ class SubprocessTestsMixin:
functools.partial(MySubprocessProtocol, self.loop),
sys.executable, prog)
- with self.assertWarns(DeprecationWarning):
- transp, proto = self.loop.run_until_complete(connect)
- self.assertIsInstance(proto, MySubprocessProtocol)
- self.loop.run_until_complete(proto.connected)
+ transp, proto = self.loop.run_until_complete(connect)
+ self.assertIsInstance(proto, MySubprocessProtocol)
+ self.loop.run_until_complete(proto.connected)
- transp.terminate()
- self.loop.run_until_complete(proto.completed)
- self.check_terminated(proto.returncode)
- transp.close()
+ transp.terminate()
+ self.loop.run_until_complete(proto.completed)
+ self.check_terminated(proto.returncode)
+ transp.close()
@unittest.skipIf(sys.platform == 'win32', "Don't have SIGHUP")
def test_subprocess_send_signal(self):
@@ -1873,15 +1872,15 @@ class SubprocessTestsMixin:
functools.partial(MySubprocessProtocol, self.loop),
sys.executable, prog)
- with self.assertWarns(DeprecationWarning):
- transp, proto = self.loop.run_until_complete(connect)
- self.assertIsInstance(proto, MySubprocessProtocol)
- self.loop.run_until_complete(proto.connected)
- transp.send_signal(signal.SIGHUP)
- self.loop.run_until_complete(proto.completed)
- self.assertEqual(-signal.SIGHUP, proto.returncode)
- transp.close()
+ transp, proto = self.loop.run_until_complete(connect)
+ self.assertIsInstance(proto, MySubprocessProtocol)
+ self.loop.run_until_complete(proto.connected)
+
+ transp.send_signal(signal.SIGHUP)
+ self.loop.run_until_complete(proto.completed)
+ self.assertEqual(-signal.SIGHUP, proto.returncode)
+ transp.close()
finally:
signal.signal(signal.SIGHUP, old_handler)
@@ -1892,20 +1891,19 @@ class SubprocessTestsMixin:
functools.partial(MySubprocessProtocol, self.loop),
sys.executable, prog)
- with self.assertWarns(DeprecationWarning):
- transp, proto = self.loop.run_until_complete(connect)
- self.assertIsInstance(proto, MySubprocessProtocol)
- self.loop.run_until_complete(proto.connected)
+ transp, proto = self.loop.run_until_complete(connect)
+ self.assertIsInstance(proto, MySubprocessProtocol)
+ self.loop.run_until_complete(proto.connected)
- stdin = transp.get_pipe_transport(0)
- stdin.write(b'test')
+ stdin = transp.get_pipe_transport(0)
+ stdin.write(b'test')
- self.loop.run_until_complete(proto.completed)
+ self.loop.run_until_complete(proto.completed)
- transp.close()
- self.assertEqual(b'OUT:test', proto.data[1])
- self.assertTrue(proto.data[2].startswith(b'ERR:test'), proto.data[2])
- self.assertEqual(0, proto.returncode)
+ transp.close()
+ self.assertEqual(b'OUT:test', proto.data[1])
+ self.assertTrue(proto.data[2].startswith(b'ERR:test'), proto.data[2])
+ self.assertEqual(0, proto.returncode)
def test_subprocess_stderr_redirect_to_stdout(self):
prog = os.path.join(os.path.dirname(__file__), 'echo2.py')
@@ -1914,23 +1912,23 @@ class SubprocessTestsMixin:
functools.partial(MySubprocessProtocol, self.loop),
sys.executable, prog, stderr=subprocess.STDOUT)
- with self.assertWarns(DeprecationWarning):
- transp, proto = self.loop.run_until_complete(connect)
- self.assertIsInstance(proto, MySubprocessProtocol)
- self.loop.run_until_complete(proto.connected)
- stdin = transp.get_pipe_transport(0)
- self.assertIsNotNone(transp.get_pipe_transport(1))
- self.assertIsNone(transp.get_pipe_transport(2))
+ transp, proto = self.loop.run_until_complete(connect)
+ self.assertIsInstance(proto, MySubprocessProtocol)
+ self.loop.run_until_complete(proto.connected)
- stdin.write(b'test')
- self.loop.run_until_complete(proto.completed)
- self.assertTrue(proto.data[1].startswith(b'OUT:testERR:test'),
- proto.data[1])
- self.assertEqual(b'', proto.data[2])
+ stdin = transp.get_pipe_transport(0)
+ self.assertIsNotNone(transp.get_pipe_transport(1))
+ self.assertIsNone(transp.get_pipe_transport(2))
- transp.close()
- self.assertEqual(0, proto.returncode)
+ stdin.write(b'test')
+ self.loop.run_until_complete(proto.completed)
+ self.assertTrue(proto.data[1].startswith(b'OUT:testERR:test'),
+ proto.data[1])
+ self.assertEqual(b'', proto.data[2])
+
+ transp.close()
+ self.assertEqual(0, proto.returncode)
def test_subprocess_close_client_stream(self):
prog = os.path.join(os.path.dirname(__file__), 'echo3.py')
@@ -1938,33 +1936,33 @@ class SubprocessTestsMixin:
connect = self.loop.subprocess_exec(
functools.partial(MySubprocessProtocol, self.loop),
sys.executable, prog)
- with self.assertWarns(DeprecationWarning):
- transp, proto = self.loop.run_until_complete(connect)
- self.assertIsInstance(proto, MySubprocessProtocol)
- self.loop.run_until_complete(proto.connected)
- stdin = transp.get_pipe_transport(0)
- stdout = transp.get_pipe_transport(1)
- stdin.write(b'test')
- self.loop.run_until_complete(proto.got_data[1].wait())
- self.assertEqual(b'OUT:test', proto.data[1])
+ transp, proto = self.loop.run_until_complete(connect)
+ self.assertIsInstance(proto, MySubprocessProtocol)
+ self.loop.run_until_complete(proto.connected)
- stdout.close()
- self.loop.run_until_complete(proto.disconnects[1])
- stdin.write(b'xxx')
- self.loop.run_until_complete(proto.got_data[2].wait())
- if sys.platform != 'win32':
- self.assertEqual(b'ERR:BrokenPipeError', proto.data[2])
- else:
- # After closing the read-end of a pipe, writing to the
- # write-end using os.write() fails with errno==EINVAL and
- # GetLastError()==ERROR_INVALID_NAME on Windows!?! (Using
- # WriteFile() we get ERROR_BROKEN_PIPE as expected.)
- self.assertEqual(b'ERR:OSError', proto.data[2])
- with test_utils.disable_logger():
- transp.close()
- self.loop.run_until_complete(proto.completed)
- self.check_killed(proto.returncode)
+ stdin = transp.get_pipe_transport(0)
+ stdout = transp.get_pipe_transport(1)
+ stdin.write(b'test')
+ self.loop.run_until_complete(proto.got_data[1].wait())
+ self.assertEqual(b'OUT:test', proto.data[1])
+
+ stdout.close()
+ self.loop.run_until_complete(proto.disconnects[1])
+ stdin.write(b'xxx')
+ self.loop.run_until_complete(proto.got_data[2].wait())
+ if sys.platform != 'win32':
+ self.assertEqual(b'ERR:BrokenPipeError', proto.data[2])
+ else:
+ # After closing the read-end of a pipe, writing to the
+ # write-end using os.write() fails with errno==EINVAL and
+ # GetLastError()==ERROR_INVALID_NAME on Windows!?! (Using
+ # WriteFile() we get ERROR_BROKEN_PIPE as expected.)
+ self.assertEqual(b'ERR:OSError', proto.data[2])
+ with test_utils.disable_logger():
+ transp.close()
+ self.loop.run_until_complete(proto.completed)
+ self.check_killed(proto.returncode)
def test_subprocess_wait_no_same_group(self):
# start the new process in a new session
diff --git a/Lib/test/test_asyncio/test_futures2.py b/Lib/test/test_asyncio/test_futures2.py
new file mode 100644
index 0000000000..13dbc70327
--- /dev/null
+++ b/Lib/test/test_asyncio/test_futures2.py
@@ -0,0 +1,18 @@
+# IsolatedAsyncioTestCase based tests
+import asyncio
+import unittest
+
+
+class FutureTests(unittest.IsolatedAsyncioTestCase):
+ async def test_recursive_repr_for_pending_tasks(self):
+ # The call crashes if the guard for recursive call
+ # in base_futures:_future_repr_info is absent
+ # See Also: https://bugs.python.org/issue42183
+
+ async def func():
+ return asyncio.all_tasks()
+
+ # The repr() call should not raise RecursiveError at first.
+ # The check for returned string is not very reliable but
+ # exact comparison for the whole string is even weaker.
+ self.assertIn('...', repr(await asyncio.wait_for(func(), timeout=10)))
diff --git a/Lib/test/test_asyncio/test_locks.py b/Lib/test/test_asyncio/test_locks.py
index 8c93fae2b5..6194cd0617 100644
--- a/Lib/test/test_asyncio/test_locks.py
+++ b/Lib/test/test_asyncio/test_locks.py
@@ -26,24 +26,8 @@ class LockTests(test_utils.TestCase):
super().setUp()
self.loop = self.new_test_loop()
- def test_ctor_loop(self):
- loop = mock.Mock()
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=loop)
- self.assertIs(lock._loop, loop)
-
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=self.loop)
- self.assertIs(lock._loop, self.loop)
-
- def test_ctor_noloop(self):
- asyncio.set_event_loop(self.loop)
- lock = asyncio.Lock()
- self.assertIs(lock._loop, self.loop)
-
def test_repr(self):
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=self.loop)
+ lock = asyncio.Lock()
self.assertTrue(repr(lock).endswith('[unlocked]>'))
self.assertTrue(RGX_REPR.match(repr(lock)))
@@ -52,9 +36,9 @@ class LockTests(test_utils.TestCase):
self.assertTrue(RGX_REPR.match(repr(lock)))
def test_lock(self):
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=self.loop)
+ lock = asyncio.Lock()
+ with self.assertWarns(DeprecationWarning):
@asyncio.coroutine
def acquire_lock():
return (yield from lock)
@@ -67,17 +51,34 @@ class LockTests(test_utils.TestCase):
self.assertFalse(lock.locked())
+ def test_lock_doesnt_accept_loop_parameter(self):
+ primitives_cls = [
+ asyncio.Lock,
+ asyncio.Condition,
+ asyncio.Event,
+ asyncio.Semaphore,
+ asyncio.BoundedSemaphore,
+ ]
+
+ for cls in primitives_cls:
+ with self.assertRaisesRegex(
+ TypeError,
+ rf'As of 3.10, the \*loop\* parameter was removed from '
+ rf'{cls.__name__}\(\) since it is no longer necessary'
+ ):
+ cls(loop=self.loop)
+
def test_lock_by_with_statement(self):
loop = asyncio.new_event_loop() # don't use TestLoop quirks
self.set_event_loop(loop)
- with self.assertWarns(DeprecationWarning):
- primitives = [
- asyncio.Lock(loop=loop),
- asyncio.Condition(loop=loop),
- asyncio.Semaphore(loop=loop),
- asyncio.BoundedSemaphore(loop=loop),
- ]
+ primitives = [
+ asyncio.Lock(),
+ asyncio.Condition(),
+ asyncio.Semaphore(),
+ asyncio.BoundedSemaphore(),
+ ]
+ with self.assertWarns(DeprecationWarning):
@asyncio.coroutine
def test(lock):
yield from asyncio.sleep(0.01)
@@ -95,8 +96,7 @@ class LockTests(test_utils.TestCase):
self.assertFalse(primitive.locked())
def test_acquire(self):
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=self.loop)
+ lock = asyncio.Lock()
result = []
self.assertTrue(self.loop.run_until_complete(lock.acquire()))
@@ -147,8 +147,7 @@ class LockTests(test_utils.TestCase):
self.assertTrue(t3.result())
def test_acquire_cancel(self):
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=self.loop)
+ lock = asyncio.Lock()
self.assertTrue(self.loop.run_until_complete(lock.acquire()))
task = self.loop.create_task(lock.acquire())
@@ -173,8 +172,7 @@ class LockTests(test_utils.TestCase):
# B's waiter; instead, it should move on to C's waiter.
# Setup: A has the lock, b and c are waiting.
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=self.loop)
+ lock = asyncio.Lock()
async def lockit(name, blocker):
await lock.acquire()
@@ -210,8 +208,7 @@ class LockTests(test_utils.TestCase):
# Issue 32734
# Acquire 4 locks, cancel second, release first
# and 2 locks are taken at once.
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=self.loop)
+ lock = asyncio.Lock()
lock_count = 0
call_count = 0
@@ -256,8 +253,7 @@ class LockTests(test_utils.TestCase):
self.assertTrue(t3.cancelled())
def test_finished_waiter_cancelled(self):
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=self.loop)
+ lock = asyncio.Lock()
ta = self.loop.create_task(lock.acquire())
test_utils.run_briefly(self.loop)
@@ -279,14 +275,12 @@ class LockTests(test_utils.TestCase):
self.assertTrue(tb.cancelled())
def test_release_not_acquired(self):
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=self.loop)
+ lock = asyncio.Lock()
self.assertRaises(RuntimeError, lock.release)
def test_release_no_waiters(self):
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=self.loop)
+ lock = asyncio.Lock()
self.loop.run_until_complete(lock.acquire())
self.assertTrue(lock.locked())
@@ -312,24 +306,8 @@ class EventTests(test_utils.TestCase):
super().setUp()
self.loop = self.new_test_loop()
- def test_ctor_loop(self):
- loop = mock.Mock()
- with self.assertWarns(DeprecationWarning):
- ev = asyncio.Event(loop=loop)
- self.assertIs(ev._loop, loop)
-
- with self.assertWarns(DeprecationWarning):
- ev = asyncio.Event(loop=self.loop)
- self.assertIs(ev._loop, self.loop)
-
- def test_ctor_noloop(self):
- asyncio.set_event_loop(self.loop)
- ev = asyncio.Event()
- self.assertIs(ev._loop, self.loop)
-
def test_repr(self):
- with self.assertWarns(DeprecationWarning):
- ev = asyncio.Event(loop=self.loop)
+ ev = asyncio.Event()
self.assertTrue(repr(ev).endswith('[unset]>'))
match = RGX_REPR.match(repr(ev))
self.assertEqual(match.group('extras'), 'unset')
@@ -343,8 +321,7 @@ class EventTests(test_utils.TestCase):
self.assertTrue(RGX_REPR.match(repr(ev)))
def test_wait(self):
- with self.assertWarns(DeprecationWarning):
- ev = asyncio.Event(loop=self.loop)
+ ev = asyncio.Event()
self.assertFalse(ev.is_set())
result = []
@@ -381,16 +358,14 @@ class EventTests(test_utils.TestCase):
self.assertIsNone(t3.result())
def test_wait_on_set(self):
- with self.assertWarns(DeprecationWarning):
- ev = asyncio.Event(loop=self.loop)
+ ev = asyncio.Event()
ev.set()
res = self.loop.run_until_complete(ev.wait())
self.assertTrue(res)
def test_wait_cancel(self):
- with self.assertWarns(DeprecationWarning):
- ev = asyncio.Event(loop=self.loop)
+ ev = asyncio.Event()
wait = self.loop.create_task(ev.wait())
self.loop.call_soon(wait.cancel)
@@ -400,8 +375,7 @@ class EventTests(test_utils.TestCase):
self.assertFalse(ev._waiters)
def test_clear(self):
- with self.assertWarns(DeprecationWarning):
- ev = asyncio.Event(loop=self.loop)
+ ev = asyncio.Event()
self.assertFalse(ev.is_set())
ev.set()
@@ -411,8 +385,7 @@ class EventTests(test_utils.TestCase):
self.assertFalse(ev.is_set())
def test_clear_with_waiters(self):
- with self.assertWarns(DeprecationWarning):
- ev = asyncio.Event(loop=self.loop)
+ ev = asyncio.Event()
result = []
async def c1(result):
@@ -446,23 +419,8 @@ class ConditionTests(test_utils.TestCase):
super().setUp()
self.loop = self.new_test_loop()
- def test_ctor_loop(self):
- loop = mock.Mock()
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=loop)
- self.assertIs(cond._loop, loop)
-
- cond = asyncio.Condition(loop=self.loop)
- self.assertIs(cond._loop, self.loop)
-
- def test_ctor_noloop(self):
- asyncio.set_event_loop(self.loop)
- cond = asyncio.Condition()
- self.assertIs(cond._loop, self.loop)
-
def test_wait(self):
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=self.loop)
+ cond = asyncio.Condition()
result = []
async def c1(result):
@@ -525,8 +483,7 @@ class ConditionTests(test_utils.TestCase):
self.assertTrue(t3.result())
def test_wait_cancel(self):
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=self.loop)
+ cond = asyncio.Condition()
self.loop.run_until_complete(cond.acquire())
wait = self.loop.create_task(cond.wait())
@@ -538,8 +495,7 @@ class ConditionTests(test_utils.TestCase):
self.assertTrue(cond.locked())
def test_wait_cancel_contested(self):
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=self.loop)
+ cond = asyncio.Condition()
self.loop.run_until_complete(cond.acquire())
self.assertTrue(cond.locked())
@@ -565,10 +521,11 @@ class ConditionTests(test_utils.TestCase):
def test_wait_cancel_after_notify(self):
# See bpo-32841
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=self.loop)
waited = False
+ cond = asyncio.Condition()
+ cond._loop = self.loop
+
async def wait_on_cond():
nonlocal waited
async with cond:
@@ -590,15 +547,13 @@ class ConditionTests(test_utils.TestCase):
self.assertTrue(waited)
def test_wait_unacquired(self):
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=self.loop)
+ cond = asyncio.Condition()
self.assertRaises(
RuntimeError,
self.loop.run_until_complete, cond.wait())
def test_wait_for(self):
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=self.loop)
+ cond = asyncio.Condition()
presult = False
def predicate():
@@ -635,8 +590,7 @@ class ConditionTests(test_utils.TestCase):
self.assertTrue(t.result())
def test_wait_for_unacquired(self):
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=self.loop)
+ cond = asyncio.Condition()
# predicate can return true immediately
res = self.loop.run_until_complete(cond.wait_for(lambda: [1, 2, 3]))
@@ -648,8 +602,7 @@ class ConditionTests(test_utils.TestCase):
cond.wait_for(lambda: False))
def test_notify(self):
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=self.loop)
+ cond = asyncio.Condition()
result = []
async def c1(result):
@@ -701,8 +654,7 @@ class ConditionTests(test_utils.TestCase):
self.assertTrue(t3.result())
def test_notify_all(self):
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=self.loop)
+ cond = asyncio.Condition()
result = []
@@ -738,18 +690,15 @@ class ConditionTests(test_utils.TestCase):
self.assertTrue(t2.result())
def test_notify_unacquired(self):
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=self.loop)
+ cond = asyncio.Condition()
self.assertRaises(RuntimeError, cond.notify)
def test_notify_all_unacquired(self):
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=self.loop)
+ cond = asyncio.Condition()
self.assertRaises(RuntimeError, cond.notify_all)
def test_repr(self):
- with self.assertWarns(DeprecationWarning):
- cond = asyncio.Condition(loop=self.loop)
+ cond = asyncio.Condition()
self.assertTrue('unlocked' in repr(cond))
self.assertTrue(RGX_REPR.match(repr(cond)))
@@ -775,9 +724,8 @@ class ConditionTests(test_utils.TestCase):
self.loop.run_until_complete(f())
def test_explicit_lock(self):
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=self.loop)
- cond = asyncio.Condition(lock, loop=self.loop)
+ lock = asyncio.Lock()
+ cond = asyncio.Condition(lock)
self.assertIs(cond._lock, lock)
self.assertIs(cond._loop, lock._loop)
@@ -785,23 +733,27 @@ class ConditionTests(test_utils.TestCase):
def test_ambiguous_loops(self):
loop = self.new_test_loop()
self.addCleanup(loop.close)
- with self.assertWarns(DeprecationWarning):
- lock = asyncio.Lock(loop=self.loop)
+
+ lock = asyncio.Lock()
+ lock._loop = loop
+
+ async def _create_condition():
with self.assertRaises(ValueError):
- asyncio.Condition(lock, loop=loop)
+ asyncio.Condition(lock)
+
+ self.loop.run_until_complete(_create_condition())
def test_timeout_in_block(self):
loop = asyncio.new_event_loop()
self.addCleanup(loop.close)
async def task_timeout():
- condition = asyncio.Condition(loop=loop)
+ condition = asyncio.Condition()
async with condition:
with self.assertRaises(asyncio.TimeoutError):
await asyncio.wait_for(condition.wait(), timeout=0.5)
- with self.assertWarns(DeprecationWarning):
- loop.run_until_complete(task_timeout())
+ loop.run_until_complete(task_timeout())
class SemaphoreTests(test_utils.TestCase):
@@ -810,29 +762,12 @@ class SemaphoreTests(test_utils.TestCase):
super().setUp()
self.loop = self.new_test_loop()
- def test_ctor_loop(self):
- loop = mock.Mock()
- with self.assertWarns(DeprecationWarning):
- sem = asyncio.Semaphore(loop=loop)
- self.assertIs(sem._loop, loop)
-
- with self.assertWarns(DeprecationWarning):
- sem = asyncio.Semaphore(loop=self.loop)
- self.assertIs(sem._loop, self.loop)
-
- def test_ctor_noloop(self):
- asyncio.set_event_loop(self.loop)
- sem = asyncio.Semaphore()
- self.assertIs(sem._loop, self.loop)
-
def test_initial_value_zero(self):
- with self.assertWarns(DeprecationWarning):
- sem = asyncio.Semaphore(0, loop=self.loop)
+ sem = asyncio.Semaphore(0)
self.assertTrue(sem.locked())
def test_repr(self):
- with self.assertWarns(DeprecationWarning):
- sem = asyncio.Semaphore(loop=self.loop)
+ sem = asyncio.Semaphore()
self.assertTrue(repr(sem).endswith('[unlocked, value:1]>'))
self.assertTrue(RGX_REPR.match(repr(sem)))
@@ -850,8 +785,7 @@ class SemaphoreTests(test_utils.TestCase):
self.assertTrue(RGX_REPR.match(repr(sem)))
def test_semaphore(self):
- with self.assertWarns(DeprecationWarning):
- sem = asyncio.Semaphore(loop=self.loop)
+ sem = asyncio.Semaphore()
self.assertEqual(1, sem._value)
with self.assertWarns(DeprecationWarning):
@@ -872,8 +806,7 @@ class SemaphoreTests(test_utils.TestCase):
self.assertRaises(ValueError, asyncio.Semaphore, -1)
def test_acquire(self):
- with self.assertWarns(DeprecationWarning):
- sem = asyncio.Semaphore(3, loop=self.loop)
+ sem = asyncio.Semaphore(3)
result = []
self.assertTrue(self.loop.run_until_complete(sem.acquire()))
@@ -934,8 +867,7 @@ class SemaphoreTests(test_utils.TestCase):
self.loop.run_until_complete(asyncio.gather(*race_tasks))
def test_acquire_cancel(self):
- with self.assertWarns(DeprecationWarning):
- sem = asyncio.Semaphore(loop=self.loop)
+ sem = asyncio.Semaphore()
self.loop.run_until_complete(sem.acquire())
acquire = self.loop.create_task(sem.acquire())
@@ -947,8 +879,7 @@ class SemaphoreTests(test_utils.TestCase):
all(waiter.done() for waiter in sem._waiters))
def test_acquire_cancel_before_awoken(self):
- with self.assertWarns(DeprecationWarning):
- sem = asyncio.Semaphore(value=0, loop=self.loop)
+ sem = asyncio.Semaphore(value=0)
t1 = self.loop.create_task(sem.acquire())
t2 = self.loop.create_task(sem.acquire())
@@ -970,8 +901,7 @@ class SemaphoreTests(test_utils.TestCase):
test_utils.run_briefly(self.loop)
def test_acquire_hang(self):
- with self.assertWarns(DeprecationWarning):
- sem = asyncio.Semaphore(value=0, loop=self.loop)
+ sem = asyncio.Semaphore(value=0)
t1 = self.loop.create_task(sem.acquire())
t2 = self.loop.create_task(sem.acquire())
@@ -985,14 +915,12 @@ class SemaphoreTests(test_utils.TestCase):
self.assertTrue(sem.locked())
def test_release_not_acquired(self):
- with self.assertWarns(DeprecationWarning):
- sem = asyncio.BoundedSemaphore(loop=self.loop)
+ sem = asyncio.BoundedSemaphore()
self.assertRaises(ValueError, sem.release)
def test_release_no_waiters(self):
- with self.assertWarns(DeprecationWarning):
- sem = asyncio.Semaphore(loop=self.loop)
+ sem = asyncio.Semaphore()
self.loop.run_until_complete(sem.acquire())
self.assertTrue(sem.locked())
diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py
index c5e3a5c148..4bd50f4123 100644
--- a/Lib/test/test_asyncio/test_pep492.py
+++ b/Lib/test/test_asyncio/test_pep492.py
@@ -43,13 +43,12 @@ class BaseTest(test_utils.TestCase):
class LockTests(BaseTest):
def test_context_manager_async_with(self):
- with self.assertWarns(DeprecationWarning):
- primitives = [
- asyncio.Lock(loop=self.loop),
- asyncio.Condition(loop=self.loop),
- asyncio.Semaphore(loop=self.loop),
- asyncio.BoundedSemaphore(loop=self.loop),
- ]
+ primitives = [
+ asyncio.Lock(),
+ asyncio.Condition(),
+ asyncio.Semaphore(),
+ asyncio.BoundedSemaphore(),
+ ]
async def test(lock):
await asyncio.sleep(0.01)
@@ -66,13 +65,12 @@ class LockTests(BaseTest):
self.assertFalse(primitive.locked())
def test_context_manager_with_await(self):
- with self.assertWarns(DeprecationWarning):
- primitives = [
- asyncio.Lock(loop=self.loop),
- asyncio.Condition(loop=self.loop),
- asyncio.Semaphore(loop=self.loop),
- asyncio.BoundedSemaphore(loop=self.loop),
- ]
+ primitives = [
+ asyncio.Lock(),
+ asyncio.Condition(),
+ asyncio.Semaphore(),
+ asyncio.BoundedSemaphore(),
+ ]
async def test(lock):
await asyncio.sleep(0.01)
diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py
index 5c9aaa82c3..0a0b529f62 100644
--- a/Lib/test/test_asyncio/test_queues.py
+++ b/Lib/test/test_asyncio/test_queues.py
@@ -35,14 +35,13 @@ class QueueBasicTests(_QueueTestBase):
loop = self.new_test_loop(gen)
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=loop)
+ q = asyncio.Queue()
self.assertTrue(fn(q).startswith('<Queue'), fn(q))
id_is_present = hex(id(q)) in fn(q)
self.assertEqual(expect_id, id_is_present)
async def add_getter():
- q = asyncio.Queue(loop=loop)
+ q = asyncio.Queue()
# Start a task that waits to get.
loop.create_task(q.get())
# Let it start waiting.
@@ -51,11 +50,10 @@ class QueueBasicTests(_QueueTestBase):
# resume q.get coroutine to finish generator
q.put_nowait(0)
- with self.assertWarns(DeprecationWarning):
- loop.run_until_complete(add_getter())
+ loop.run_until_complete(add_getter())
async def add_putter():
- q = asyncio.Queue(maxsize=1, loop=loop)
+ q = asyncio.Queue(maxsize=1)
q.put_nowait(1)
# Start a task that waits to put.
loop.create_task(q.put(2))
@@ -65,27 +63,11 @@ class QueueBasicTests(_QueueTestBase):
# resume q.put coroutine to finish generator
q.get_nowait()
- with self.assertWarns(DeprecationWarning):
- loop.run_until_complete(add_putter())
- q = asyncio.Queue(loop=loop)
+ loop.run_until_complete(add_putter())
+ q = asyncio.Queue()
q.put_nowait(1)
self.assertTrue('_queue=[1]' in fn(q))
- def test_ctor_loop(self):
- loop = mock.Mock()
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=loop)
- self.assertIs(q._loop, loop)
-
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop)
- self.assertIs(q._loop, self.loop)
-
- def test_ctor_noloop(self):
- asyncio.set_event_loop(self.loop)
- q = asyncio.Queue()
- self.assertIs(q._loop, self.loop)
-
def test_repr(self):
self._test_repr_or_str(repr, True)
@@ -93,8 +75,7 @@ class QueueBasicTests(_QueueTestBase):
self._test_repr_or_str(str, False)
def test_empty(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop)
+ q = asyncio.Queue()
self.assertTrue(q.empty())
q.put_nowait(1)
self.assertFalse(q.empty())
@@ -102,18 +83,15 @@ class QueueBasicTests(_QueueTestBase):
self.assertTrue(q.empty())
def test_full(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop)
+ q = asyncio.Queue()
self.assertFalse(q.full())
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(maxsize=1, loop=self.loop)
+ q = asyncio.Queue(maxsize=1)
q.put_nowait(1)
self.assertTrue(q.full())
def test_order(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop)
+ q = asyncio.Queue()
for i in [1, 3, 2]:
q.put_nowait(i)
@@ -131,8 +109,7 @@ class QueueBasicTests(_QueueTestBase):
loop = self.new_test_loop(gen)
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(maxsize=2, loop=loop)
+ q = asyncio.Queue(maxsize=2)
self.assertEqual(2, q.maxsize)
have_been_put = []
@@ -166,8 +143,7 @@ class QueueBasicTests(_QueueTestBase):
class QueueGetTests(_QueueTestBase):
def test_blocking_get(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop)
+ q = asyncio.Queue()
q.put_nowait(1)
async def queue_get():
@@ -177,8 +153,7 @@ class QueueGetTests(_QueueTestBase):
self.assertEqual(1, res)
def test_get_with_putters(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(1, loop=self.loop)
+ q = asyncio.Queue(1)
q.put_nowait(1)
waiter = self.loop.create_future()
@@ -198,9 +173,8 @@ class QueueGetTests(_QueueTestBase):
loop = self.new_test_loop(gen)
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=loop)
- started = asyncio.Event(loop=loop)
+ q = asyncio.Queue()
+ started = asyncio.Event()
finished = False
async def queue_get():
@@ -224,14 +198,12 @@ class QueueGetTests(_QueueTestBase):
self.assertAlmostEqual(0.01, loop.time())
def test_nonblocking_get(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop)
+ q = asyncio.Queue()
q.put_nowait(1)
self.assertEqual(1, q.get_nowait())
def test_nonblocking_get_exception(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop)
+ q = asyncio.Queue()
self.assertRaises(asyncio.QueueEmpty, q.get_nowait)
def test_get_cancelled(self):
@@ -245,8 +217,7 @@ class QueueGetTests(_QueueTestBase):
loop = self.new_test_loop(gen)
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=loop)
+ q = asyncio.Queue()
async def queue_get():
return await asyncio.wait_for(q.get(), 0.051)
@@ -261,8 +232,7 @@ class QueueGetTests(_QueueTestBase):
self.assertAlmostEqual(0.06, loop.time())
def test_get_cancelled_race(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop)
+ q = asyncio.Queue()
t1 = self.loop.create_task(q.get())
t2 = self.loop.create_task(q.get())
@@ -276,8 +246,7 @@ class QueueGetTests(_QueueTestBase):
self.assertEqual(t2.result(), 'a')
def test_get_with_waiting_putters(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop, maxsize=1)
+ q = asyncio.Queue(maxsize=1)
self.loop.create_task(q.put('a'))
self.loop.create_task(q.put('b'))
test_utils.run_briefly(self.loop)
@@ -286,6 +255,7 @@ class QueueGetTests(_QueueTestBase):
def test_why_are_getters_waiting(self):
# From issue #268.
+ asyncio.set_event_loop(self.loop)
async def consumer(queue, num_expected):
for _ in range(num_expected):
@@ -298,13 +268,16 @@ class QueueGetTests(_QueueTestBase):
queue_size = 1
producer_num_items = 5
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(queue_size, loop=self.loop)
+ async def create_queue():
+ queue = asyncio.Queue(queue_size)
+ queue._get_loop()
+ return queue
+
+ q = self.loop.run_until_complete(create_queue())
self.loop.run_until_complete(
asyncio.gather(producer(q, producer_num_items),
- consumer(q, producer_num_items),
- loop=self.loop),
+ consumer(q, producer_num_items)),
)
def test_cancelled_getters_not_being_held_in_self_getters(self):
@@ -320,8 +293,7 @@ class QueueGetTests(_QueueTestBase):
except asyncio.TimeoutError:
pass
- with self.assertWarns(DeprecationWarning):
- queue = asyncio.Queue(loop=self.loop, maxsize=5)
+ queue = asyncio.Queue(maxsize=5)
self.loop.run_until_complete(self.loop.create_task(consumer(queue)))
self.assertEqual(len(queue._getters), 0)
@@ -329,8 +301,7 @@ class QueueGetTests(_QueueTestBase):
class QueuePutTests(_QueueTestBase):
def test_blocking_put(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop)
+ q = asyncio.Queue()
async def queue_put():
# No maxsize, won't block.
@@ -347,9 +318,8 @@ class QueuePutTests(_QueueTestBase):
loop = self.new_test_loop(gen)
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(maxsize=1, loop=loop)
- started = asyncio.Event(loop=loop)
+ q = asyncio.Queue(maxsize=1)
+ started = asyncio.Event()
finished = False
async def queue_put():
@@ -371,8 +341,7 @@ class QueuePutTests(_QueueTestBase):
self.assertAlmostEqual(0.01, loop.time())
def test_nonblocking_put(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop)
+ q = asyncio.Queue()
q.put_nowait(1)
self.assertEqual(1, q.get_nowait())
@@ -383,8 +352,7 @@ class QueuePutTests(_QueueTestBase):
loop = self.new_test_loop(gen)
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=loop)
+ q = asyncio.Queue()
reader = loop.create_task(q.get())
@@ -413,8 +381,7 @@ class QueuePutTests(_QueueTestBase):
loop = self.new_test_loop(gen)
loop.set_debug(True)
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=loop)
+ q = asyncio.Queue()
reader1 = loop.create_task(q.get())
reader2 = loop.create_task(q.get())
@@ -444,8 +411,7 @@ class QueuePutTests(_QueueTestBase):
loop = self.new_test_loop(gen)
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(1, loop=loop)
+ q = asyncio.Queue(1)
q.put_nowait(1)
@@ -469,21 +435,18 @@ class QueuePutTests(_QueueTestBase):
self.assertEqual(q.qsize(), 0)
def test_nonblocking_put_exception(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(maxsize=1, loop=self.loop)
+ q = asyncio.Queue(maxsize=1, )
q.put_nowait(1)
self.assertRaises(asyncio.QueueFull, q.put_nowait, 2)
def test_float_maxsize(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(maxsize=1.3, loop=self.loop)
+ q = asyncio.Queue(maxsize=1.3, )
q.put_nowait(1)
q.put_nowait(2)
self.assertTrue(q.full())
self.assertRaises(asyncio.QueueFull, q.put_nowait, 3)
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(maxsize=1.3, loop=self.loop)
+ q = asyncio.Queue(maxsize=1.3, )
async def queue_put():
await q.put(1)
@@ -492,8 +455,7 @@ class QueuePutTests(_QueueTestBase):
self.loop.run_until_complete(queue_put())
def test_put_cancelled(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop)
+ q = asyncio.Queue()
async def queue_put():
await q.put(1)
@@ -508,8 +470,7 @@ class QueuePutTests(_QueueTestBase):
self.assertTrue(t.result())
def test_put_cancelled_race(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop, maxsize=1)
+ q = asyncio.Queue(maxsize=1)
put_a = self.loop.create_task(q.put('a'))
put_b = self.loop.create_task(q.put('b'))
@@ -529,8 +490,7 @@ class QueuePutTests(_QueueTestBase):
self.loop.run_until_complete(put_b)
def test_put_with_waiting_getters(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue(loop=self.loop)
+ q = asyncio.Queue()
t = self.loop.create_task(q.get())
test_utils.run_briefly(self.loop)
self.loop.run_until_complete(q.put('a'))
@@ -538,9 +498,14 @@ class QueuePutTests(_QueueTestBase):
def test_why_are_putters_waiting(self):
# From issue #265.
+ asyncio.set_event_loop(self.loop)
+
+ async def create_queue():
+ q = asyncio.Queue(2)
+ q._get_loop()
+ return q
- with self.assertWarns(DeprecationWarning):
- queue = asyncio.Queue(2, loop=self.loop)
+ queue = self.loop.run_until_complete(create_queue())
async def putter(item):
await queue.put(item)
@@ -555,8 +520,7 @@ class QueuePutTests(_QueueTestBase):
t1 = putter(1)
t2 = putter(2)
t3 = putter(3)
- self.loop.run_until_complete(
- asyncio.gather(getter(), t0, t1, t2, t3, loop=self.loop))
+ self.loop.run_until_complete(asyncio.gather(getter(), t0, t1, t2, t3))
def test_cancelled_puts_not_being_held_in_self_putters(self):
def a_generator():
@@ -566,8 +530,7 @@ class QueuePutTests(_QueueTestBase):
loop = self.new_test_loop(a_generator)
# Full queue.
- with self.assertWarns(DeprecationWarning):
- queue = asyncio.Queue(loop=loop, maxsize=1)
+ queue = asyncio.Queue(maxsize=1)
queue.put_nowait(1)
# Task waiting for space to put an item in the queue.
@@ -590,8 +553,7 @@ class QueuePutTests(_QueueTestBase):
loop = self.new_test_loop(gen)
# Full Queue.
- with self.assertWarns(DeprecationWarning):
- queue = asyncio.Queue(1, loop=loop)
+ queue = asyncio.Queue(1)
queue.put_nowait(1)
# Task waiting for space to put a item in the queue.
@@ -614,8 +576,7 @@ class QueuePutTests(_QueueTestBase):
class LifoQueueTests(_QueueTestBase):
def test_order(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.LifoQueue(loop=self.loop)
+ q = asyncio.LifoQueue()
for i in [1, 3, 2]:
q.put_nowait(i)
@@ -626,8 +587,7 @@ class LifoQueueTests(_QueueTestBase):
class PriorityQueueTests(_QueueTestBase):
def test_order(self):
- with self.assertWarns(DeprecationWarning):
- q = asyncio.PriorityQueue(loop=self.loop)
+ q = asyncio.PriorityQueue()
for i in [1, 3, 2]:
q.put_nowait(i)
@@ -640,13 +600,11 @@ class _QueueJoinTestMixin:
q_class = None
def test_task_done_underflow(self):
- with self.assertWarns(DeprecationWarning):
- q = self.q_class(loop=self.loop)
+ q = self.q_class()
self.assertRaises(ValueError, q.task_done)
def test_task_done(self):
- with self.assertWarns(DeprecationWarning):
- q = self.q_class(loop=self.loop)
+ q = self.q_class()
for i in range(100):
q.put_nowait(i)
@@ -681,8 +639,7 @@ class _QueueJoinTestMixin:
self.loop.run_until_complete(asyncio.wait(tasks))
def test_join_empty_queue(self):
- with self.assertWarns(DeprecationWarning):
- q = self.q_class(loop=self.loop)
+ q = self.q_class()
# Test that a queue join()s successfully, and before anything else
# (done twice for insurance).
@@ -694,8 +651,7 @@ class _QueueJoinTestMixin:
self.loop.run_until_complete(join())
def test_format(self):
- with self.assertWarns(DeprecationWarning):
- q = self.q_class(loop=self.loop)
+ q = self.q_class()
self.assertEqual(q._format(), 'maxsize=0')
q._unfinished_tasks = 2
diff --git a/Lib/test/test_asyncio/test_server.py b/Lib/test/test_asyncio/test_server.py
index 2de4dcad17..860d62d52e 100644
--- a/Lib/test/test_asyncio/test_server.py
+++ b/Lib/test/test_asyncio/test_server.py
@@ -45,9 +45,8 @@ class BaseStartServer(func_tests.FunctionalTestCaseMixin):
async with srv:
await srv.serve_forever()
- with self.assertWarns(DeprecationWarning):
- srv = self.loop.run_until_complete(asyncio.start_server(
- serve, socket_helper.HOSTv4, 0, loop=self.loop, start_serving=False))
+ srv = self.loop.run_until_complete(asyncio.start_server(
+ serve, socket_helper.HOSTv4, 0, start_serving=False))
self.assertFalse(srv.is_serving())
@@ -102,9 +101,8 @@ class SelectorStartServerTests(BaseStartServer, unittest.TestCase):
await srv.serve_forever()
with test_utils.unix_socket_path() as addr:
- with self.assertWarns(DeprecationWarning):
- srv = self.loop.run_until_complete(asyncio.start_unix_server(
- serve, addr, loop=self.loop, start_serving=False))
+ srv = self.loop.run_until_complete(asyncio.start_unix_server(
+ serve, addr, start_serving=False))
main_task = self.loop.create_task(main(srv))
diff --git a/Lib/test/test_asyncio/test_sslproto.py b/Lib/test/test_asyncio/test_sslproto.py
index 948820c82f..e87863eb71 100644
--- a/Lib/test/test_asyncio/test_sslproto.py
+++ b/Lib/test/test_asyncio/test_sslproto.py
@@ -657,13 +657,11 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin):
sock.close()
async def client(addr):
- with self.assertWarns(DeprecationWarning):
- reader, writer = await asyncio.open_connection(
- *addr,
- ssl=client_sslctx,
- server_hostname='',
- loop=self.loop,
- ssl_handshake_timeout=1.0)
+ reader, writer = await asyncio.open_connection(
+ *addr,
+ ssl=client_sslctx,
+ server_hostname='',
+ ssl_handshake_timeout=1.0)
with self.tcp_server(server,
max_clients=1,
@@ -697,13 +695,11 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin):
sock.close()
async def client(addr):
- with self.assertWarns(DeprecationWarning):
- reader, writer = await asyncio.open_connection(
- *addr,
- ssl=client_sslctx,
- server_hostname='',
- loop=self.loop,
- ssl_handshake_timeout=support.LOOPBACK_TIMEOUT)
+ reader, writer = await asyncio.open_connection(
+ *addr,
+ ssl=client_sslctx,
+ server_hostname='',
+ ssl_handshake_timeout=support.LOOPBACK_TIMEOUT)
with self.tcp_server(server,
max_clients=1,
@@ -734,12 +730,10 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin):
sock.close()
async def client(addr):
- with self.assertWarns(DeprecationWarning):
- reader, writer = await asyncio.open_connection(
- *addr,
- ssl=client_sslctx,
- server_hostname='',
- loop=self.loop)
+ reader, writer = await asyncio.open_connection(
+ *addr,
+ ssl=client_sslctx,
+ server_hostname='')
self.assertEqual(await reader.readline(), b'A\n')
writer.write(b'B')
diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py
index 1e9d115661..aa39779775 100644
--- a/Lib/test/test_asyncio/test_streams.py
+++ b/Lib/test/test_asyncio/test_streams.py
@@ -48,8 +48,7 @@ class StreamTests(test_utils.TestCase):
def _basetest_open_connection(self, open_connection_fut):
messages = []
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
- with self.assertWarns(DeprecationWarning):
- reader, writer = self.loop.run_until_complete(open_connection_fut)
+ reader, writer = self.loop.run_until_complete(open_connection_fut)
writer.write(b'GET / HTTP/1.0\r\n\r\n')
f = reader.readline()
data = self.loop.run_until_complete(f)
@@ -62,23 +61,20 @@ class StreamTests(test_utils.TestCase):
def test_open_connection(self):
with test_utils.run_test_server() as httpd:
- conn_fut = asyncio.open_connection(*httpd.address,
- loop=self.loop)
+ conn_fut = asyncio.open_connection(*httpd.address)
self._basetest_open_connection(conn_fut)
@socket_helper.skip_unless_bind_unix_socket
def test_open_unix_connection(self):
with test_utils.run_test_unix_server() as httpd:
- conn_fut = asyncio.open_unix_connection(httpd.address,
- loop=self.loop)
+ conn_fut = asyncio.open_unix_connection(httpd.address)
self._basetest_open_connection(conn_fut)
def _basetest_open_connection_no_loop_ssl(self, open_connection_fut):
messages = []
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
try:
- with self.assertWarns(DeprecationWarning):
- reader, writer = self.loop.run_until_complete(open_connection_fut)
+ reader, writer = self.loop.run_until_complete(open_connection_fut)
finally:
asyncio.set_event_loop(None)
writer.write(b'GET / HTTP/1.0\r\n\r\n')
@@ -94,8 +90,7 @@ class StreamTests(test_utils.TestCase):
with test_utils.run_test_server(use_ssl=True) as httpd:
conn_fut = asyncio.open_connection(
*httpd.address,
- ssl=test_utils.dummy_ssl_context(),
- loop=self.loop)
+ ssl=test_utils.dummy_ssl_context())
self._basetest_open_connection_no_loop_ssl(conn_fut)
@@ -107,15 +102,14 @@ class StreamTests(test_utils.TestCase):
httpd.address,
ssl=test_utils.dummy_ssl_context(),
server_hostname='',
- loop=self.loop)
+ )
self._basetest_open_connection_no_loop_ssl(conn_fut)
def _basetest_open_connection_error(self, open_connection_fut):
messages = []
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
- with self.assertWarns(DeprecationWarning):
- reader, writer = self.loop.run_until_complete(open_connection_fut)
+ reader, writer = self.loop.run_until_complete(open_connection_fut)
writer._protocol.connection_lost(ZeroDivisionError())
f = reader.read()
with self.assertRaises(ZeroDivisionError):
@@ -126,15 +120,13 @@ class StreamTests(test_utils.TestCase):
def test_open_connection_error(self):
with test_utils.run_test_server() as httpd:
- conn_fut = asyncio.open_connection(*httpd.address,
- loop=self.loop)
+ conn_fut = asyncio.open_connection(*httpd.address)
self._basetest_open_connection_error(conn_fut)
@socket_helper.skip_unless_bind_unix_socket
def test_open_unix_connection_error(self):
with test_utils.run_test_unix_server() as httpd:
- conn_fut = asyncio.open_unix_connection(httpd.address,
- loop=self.loop)
+ conn_fut = asyncio.open_unix_connection(httpd.address)
self._basetest_open_connection_error(conn_fut)
def test_feed_empty_data(self):
@@ -452,12 +444,14 @@ class StreamTests(test_utils.TestCase):
def test_readuntil_eof(self):
stream = asyncio.StreamReader(loop=self.loop)
- stream.feed_data(b'some dataAA')
+ data = b'some dataAA'
+ stream.feed_data(data)
stream.feed_eof()
- with self.assertRaises(asyncio.IncompleteReadError) as cm:
+ with self.assertRaisesRegex(asyncio.IncompleteReadError,
+ 'undefined expected bytes') as cm:
self.loop.run_until_complete(stream.readuntil(b'AAA'))
- self.assertEqual(cm.exception.partial, b'some dataAA')
+ self.assertEqual(cm.exception.partial, data)
self.assertIsNone(cm.exception.expected)
self.assertEqual(b'', stream._buffer)
@@ -596,8 +590,7 @@ class StreamTests(test_utils.TestCase):
sock = socket.create_server(('127.0.0.1', 0))
self.server = self.loop.run_until_complete(
asyncio.start_server(self.handle_client,
- sock=sock,
- loop=self.loop))
+ sock=sock))
return sock.getsockname()
def handle_client_callback(self, client_reader, client_writer):
@@ -610,8 +603,7 @@ class StreamTests(test_utils.TestCase):
sock.close()
self.server = self.loop.run_until_complete(
asyncio.start_server(self.handle_client_callback,
- host=addr[0], port=addr[1],
- loop=self.loop))
+ host=addr[0], port=addr[1]))
return addr
def stop(self):
@@ -621,9 +613,7 @@ class StreamTests(test_utils.TestCase):
self.server = None
async def client(addr):
- with self.assertWarns(DeprecationWarning):
- reader, writer = await asyncio.open_connection(
- *addr, loop=self.loop)
+ reader, writer = await asyncio.open_connection(*addr)
# send a line
writer.write(b"hello world!\n")
# read it back
@@ -637,16 +627,14 @@ class StreamTests(test_utils.TestCase):
# test the server variant with a coroutine as client handler
server = MyServer(self.loop)
- with self.assertWarns(DeprecationWarning):
- addr = server.start()
+ addr = server.start()
msg = self.loop.run_until_complete(self.loop.create_task(client(addr)))
server.stop()
self.assertEqual(msg, b"hello world!\n")
# test the server variant with a callback as client handler
server = MyServer(self.loop)
- with self.assertWarns(DeprecationWarning):
- addr = server.start_callback()
+ addr = server.start_callback()
msg = self.loop.run_until_complete(self.loop.create_task(client(addr)))
server.stop()
self.assertEqual(msg, b"hello world!\n")
@@ -673,8 +661,7 @@ class StreamTests(test_utils.TestCase):
def start(self):
self.server = self.loop.run_until_complete(
asyncio.start_unix_server(self.handle_client,
- path=self.path,
- loop=self.loop))
+ path=self.path))
def handle_client_callback(self, client_reader, client_writer):
self.loop.create_task(self.handle_client(client_reader,
@@ -682,8 +669,7 @@ class StreamTests(test_utils.TestCase):
def start_callback(self):
start = asyncio.start_unix_server(self.handle_client_callback,
- path=self.path,
- loop=self.loop)
+ path=self.path)
self.server = self.loop.run_until_complete(start)
def stop(self):
@@ -693,9 +679,7 @@ class StreamTests(test_utils.TestCase):
self.server = None
async def client(path):
- with self.assertWarns(DeprecationWarning):
- reader, writer = await asyncio.open_unix_connection(
- path, loop=self.loop)
+ reader, writer = await asyncio.open_unix_connection(path)
# send a line
writer.write(b"hello world!\n")
# read it back
@@ -710,8 +694,7 @@ class StreamTests(test_utils.TestCase):
# test the server variant with a coroutine as client handler
with test_utils.unix_socket_path() as path:
server = MyServer(self.loop, path)
- with self.assertWarns(DeprecationWarning):
- server.start()
+ server.start()
msg = self.loop.run_until_complete(
self.loop.create_task(client(path)))
server.stop()
@@ -720,8 +703,7 @@ class StreamTests(test_utils.TestCase):
# test the server variant with a callback as client handler
with test_utils.unix_socket_path() as path:
server = MyServer(self.loop, path)
- with self.assertWarns(DeprecationWarning):
- server.start_callback()
+ server.start_callback()
msg = self.loop.run_until_complete(
self.loop.create_task(client(path)))
server.stop()
@@ -809,9 +791,7 @@ os.close(fd)
clt.close()
async def client(host, port):
- with self.assertWarns(DeprecationWarning):
- reader, writer = await asyncio.open_connection(
- host, port, loop=self.loop)
+ reader, writer = await asyncio.open_connection(host, port)
while True:
writer.write(b"foo\n")
@@ -895,9 +875,8 @@ os.close(fd)
def test_wait_closed_on_close(self):
with test_utils.run_test_server() as httpd:
- with self.assertWarns(DeprecationWarning):
- rd, wr = self.loop.run_until_complete(
- asyncio.open_connection(*httpd.address, loop=self.loop))
+ rd, wr = self.loop.run_until_complete(
+ asyncio.open_connection(*httpd.address))
wr.write(b'GET / HTTP/1.0\r\n\r\n')
f = rd.readline()
@@ -913,9 +892,8 @@ os.close(fd)
def test_wait_closed_on_close_with_unread_data(self):
with test_utils.run_test_server() as httpd:
- with self.assertWarns(DeprecationWarning):
- rd, wr = self.loop.run_until_complete(
- asyncio.open_connection(*httpd.address, loop=self.loop))
+ rd, wr = self.loop.run_until_complete(
+ asyncio.open_connection(*httpd.address))
wr.write(b'GET / HTTP/1.0\r\n\r\n')
f = rd.readline()
@@ -972,10 +950,8 @@ os.close(fd)
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
with test_utils.run_test_server() as httpd:
- with self.assertWarns(DeprecationWarning):
- rd, wr = self.loop.run_until_complete(
- asyncio.open_connection(*httpd.address,
- loop=self.loop))
+ rd, wr = self.loop.run_until_complete(
+ asyncio.open_connection(*httpd.address))
wr.close()
f = wr.wait_closed()
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
index 177a02cdcc..225a3babc8 100644
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -635,26 +635,6 @@ class SubprocessMixin:
self.assertIsNone(self.loop.run_until_complete(execute()))
- def test_exec_loop_deprecated(self):
- async def go():
- with self.assertWarns(DeprecationWarning):
- proc = await asyncio.create_subprocess_exec(
- sys.executable, '-c', 'pass',
- loop=self.loop,
- )
- await proc.wait()
- self.loop.run_until_complete(go())
-
- def test_shell_loop_deprecated(self):
- async def go():
- with self.assertWarns(DeprecationWarning):
- proc = await asyncio.create_subprocess_shell(
- "exit 0",
- loop=self.loop,
- )
- await proc.wait()
- self.loop.run_until_complete(go())
-
if sys.platform != 'win32':
# Unix
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index 74fc1e4a42..7c2e85ceef 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -155,7 +155,7 @@ class BaseTaskTests:
self.loop.run_until_complete(
asyncio.gather(*[
self.new_task(self.loop, run()) for _ in range(100)
- ], loop=self.loop))
+ ]))
def test_other_loop_future(self):
other_loop = asyncio.new_event_loop()
@@ -1548,6 +1548,30 @@ class BaseTaskTests:
loop.advance_time(10)
loop.run_until_complete(asyncio.wait([a, b]))
+ def test_wait_with_iterator_of_tasks(self):
+
+ def gen():
+ when = yield
+ self.assertAlmostEqual(0.1, when)
+ when = yield 0
+ self.assertAlmostEqual(0.15, when)
+ yield 0.15
+
+ loop = self.new_test_loop(gen)
+
+ a = self.new_task(loop, asyncio.sleep(0.1))
+ b = self.new_task(loop, asyncio.sleep(0.15))
+
+ async def foo():
+ done, pending = await asyncio.wait(iter([b, a]))
+ self.assertEqual(done, set([a, b]))
+ self.assertEqual(pending, set())
+ return 42
+
+ res = loop.run_until_complete(self.new_task(loop, foo()))
+ self.assertEqual(res, 42)
+ self.assertAlmostEqual(0.15, loop.time())
+
def test_as_completed(self):
def gen():
@@ -1579,19 +1603,18 @@ class BaseTaskTests:
async def foo():
values = []
- for f in asyncio.as_completed([b, c, a], loop=loop):
+ for f in asyncio.as_completed([b, c, a]):
values.append(await f)
return values
- with self.assertWarns(DeprecationWarning):
- res = loop.run_until_complete(self.new_task(loop, foo()))
+
+ res = loop.run_until_complete(self.new_task(loop, foo()))
self.assertAlmostEqual(0.15, loop.time())
self.assertTrue('a' in res[:2])
self.assertTrue('b' in res[:2])
self.assertEqual(res[2], 'c')
# Doing it again should take no time and exercise a different path.
- with self.assertWarns(DeprecationWarning):
- res = loop.run_until_complete(self.new_task(loop, foo()))
+ res = loop.run_until_complete(self.new_task(loop, foo()))
self.assertAlmostEqual(0.15, loop.time())
def test_as_completed_with_timeout(self):
@@ -1609,7 +1632,7 @@ class BaseTaskTests:
async def foo():
values = []
- for f in asyncio.as_completed([a, b], timeout=0.12, loop=loop):
+ for f in asyncio.as_completed([a, b], timeout=0.12):
if values:
loop.advance_time(0.02)
try:
@@ -1619,8 +1642,7 @@ class BaseTaskTests:
values.append((2, exc))
return values
- with self.assertWarns(DeprecationWarning):
- res = loop.run_until_complete(self.new_task(loop, foo()))
+ res = loop.run_until_complete(self.new_task(loop, foo()))
self.assertEqual(len(res), 2, res)
self.assertEqual(res[0], (1, 'a'))
self.assertEqual(res[1][0], 2)
@@ -1643,12 +1665,11 @@ class BaseTaskTests:
a = asyncio.sleep(0.01, 'a')
async def foo():
- for f in asyncio.as_completed([a], timeout=1, loop=loop):
+ for f in asyncio.as_completed([a], timeout=1):
v = await f
self.assertEqual(v, 'a')
- with self.assertWarns(DeprecationWarning):
- loop.run_until_complete(self.new_task(loop, foo()))
+ loop.run_until_complete(self.new_task(loop, foo()))
def test_as_completed_reverse_wait(self):
@@ -1658,13 +1679,13 @@ class BaseTaskTests:
yield 0
loop = self.new_test_loop(gen)
+ asyncio.set_event_loop(loop)
a = asyncio.sleep(0.05, 'a')
b = asyncio.sleep(0.10, 'b')
fs = {a, b}
- with self.assertWarns(DeprecationWarning):
- futs = list(asyncio.as_completed(fs, loop=loop))
+ futs = list(asyncio.as_completed(fs))
self.assertEqual(len(futs), 2)
x = loop.run_until_complete(futs[1])
@@ -1685,12 +1706,13 @@ class BaseTaskTests:
yield 0.05
loop = self.new_test_loop(gen)
+ asyncio.set_event_loop(loop)
a = asyncio.sleep(0.05, 'a')
b = asyncio.sleep(0.05, 'b')
fs = {a, b}
- with self.assertWarns(DeprecationWarning):
- futs = list(asyncio.as_completed(fs, loop=loop))
+
+ futs = list(asyncio.as_completed(fs))
self.assertEqual(len(futs), 2)
waiter = asyncio.wait(futs)
# Deprecation from passing coros in futs to asyncio.wait()
@@ -1710,14 +1732,12 @@ class BaseTaskTests:
def runner():
result = []
c = coro('ham')
- for f in asyncio.as_completed([c, c, coro('spam')],
- loop=self.loop):
+ for f in asyncio.as_completed([c, c, coro('spam')]):
result.append((yield from f))
return result
- with self.assertWarns(DeprecationWarning):
- fut = self.new_task(self.loop, runner())
- self.loop.run_until_complete(fut)
+ fut = self.new_task(self.loop, runner())
+ self.loop.run_until_complete(fut)
result = fut.result()
self.assertEqual(set(result), {'ham', 'spam'})
self.assertEqual(len(result), 2)
@@ -1994,7 +2014,7 @@ class BaseTaskTests:
self.assertIsNone(asyncio.current_task(loop=self.loop))
async def coro(loop):
- self.assertIs(asyncio.current_task(loop=loop), task)
+ self.assertIs(asyncio.current_task(), task)
self.assertIs(asyncio.current_task(None), task)
self.assertIs(asyncio.current_task(), task)
@@ -2010,16 +2030,16 @@ class BaseTaskTests:
fut2 = self.new_future(self.loop)
async def coro1(loop):
- self.assertTrue(asyncio.current_task(loop=loop) is task1)
+ self.assertTrue(asyncio.current_task() is task1)
await fut1
- self.assertTrue(asyncio.current_task(loop=loop) is task1)
+ self.assertTrue(asyncio.current_task() is task1)
fut2.set_result(True)
async def coro2(loop):
- self.assertTrue(asyncio.current_task(loop=loop) is task2)
+ self.assertTrue(asyncio.current_task() is task2)
fut1.set_result(True)
await fut2
- self.assertTrue(asyncio.current_task(loop=loop) is task2)
+ self.assertTrue(asyncio.current_task() is task2)
task1 = self.new_task(self.loop, coro1(self.loop))
task2 = self.new_task(self.loop, coro2(self.loop))
@@ -2186,10 +2206,10 @@ class BaseTaskTests:
# as_completed() expects a list of futures, not a future instance
self.assertRaises(TypeError, self.loop.run_until_complete,
- asyncio.as_completed(fut, loop=self.loop))
+ asyncio.as_completed(fut))
coro = coroutine_function()
self.assertRaises(TypeError, self.loop.run_until_complete,
- asyncio.as_completed(coro, loop=self.loop))
+ asyncio.as_completed(coro))
coro.close()
def test_wait_invalid_args(self):
@@ -2487,6 +2507,7 @@ class BaseTaskTests:
"""Ensure that a gathering future refuses to be cancelled once all
children are done"""
loop = asyncio.new_event_loop()
+ asyncio.set_event_loop(loop)
self.addCleanup(loop.close)
fut = self.new_future(loop)
@@ -2494,7 +2515,7 @@ class BaseTaskTests:
# gathering task is done at the same time as the child future
def child_coro():
return (yield from fut)
- gather_future = asyncio.gather(child_coro(), loop=loop)
+ gather_future = asyncio.gather(child_coro())
gather_task = asyncio.ensure_future(gather_future, loop=loop)
cancel_result = None
@@ -2531,8 +2552,7 @@ class BaseTaskTests:
while True:
time += 0.05
await asyncio.gather(asyncio.sleep(0.05),
- return_exceptions=True,
- loop=loop)
+ return_exceptions=True)
if time > 1:
return
@@ -2747,7 +2767,7 @@ class BaseTaskTests:
task = loop.create_task(sub(random.randint(0, 10)))
tasks.append(task)
- await asyncio.gather(*tasks, loop=loop)
+ await asyncio.gather(*tasks)
loop = asyncio.new_event_loop()
try:
@@ -3304,9 +3324,6 @@ class FutureGatherTests(GatherTestsBase, test_utils.TestCase):
self._run_loop(self.one_loop)
self.assertTrue(fut.done())
self.assertEqual(fut.result(), [])
- with self.assertWarns(DeprecationWarning):
- fut = asyncio.gather(*seq_or_iter, loop=self.other_loop)
- self.assertIs(fut._loop, self.other_loop)
def test_constructor_empty_sequence(self):
self._check_empty_sequence([])
@@ -3319,8 +3336,6 @@ class FutureGatherTests(GatherTestsBase, test_utils.TestCase):
fut2 = self.other_loop.create_future()
with self.assertRaises(ValueError):
asyncio.gather(fut1, fut2)
- with self.assertRaises(ValueError):
- asyncio.gather(fut1, loop=self.other_loop)
def test_constructor_homogenous_futures(self):
children = [self.other_loop.create_future() for i in range(3)]
@@ -3328,7 +3343,7 @@ class FutureGatherTests(GatherTestsBase, test_utils.TestCase):
self.assertIs(fut._loop, self.other_loop)
self._run_loop(self.other_loop)
self.assertFalse(fut.done())
- fut = asyncio.gather(*children, loop=self.other_loop)
+ fut = asyncio.gather(*children)
self.assertIs(fut._loop, self.other_loop)
self._run_loop(self.other_loop)
self.assertFalse(fut.done())
@@ -3399,9 +3414,10 @@ class CoroutineGatherTests(GatherTestsBase, test_utils.TestCase):
self.one_loop.run_until_complete(fut)
self.set_event_loop(self.other_loop, cleanup=False)
+ asyncio.set_event_loop(self.other_loop)
gen3 = coro()
gen4 = coro()
- fut2 = asyncio.gather(gen3, gen4, loop=self.other_loop)
+ fut2 = asyncio.gather(gen3, gen4)
self.assertIs(fut2._loop, self.other_loop)
self.other_loop.run_until_complete(fut2)
@@ -3411,7 +3427,7 @@ class CoroutineGatherTests(GatherTestsBase, test_utils.TestCase):
def coro(s):
return s
c = coro('abc')
- fut = asyncio.gather(c, c, coro('def'), c, loop=self.one_loop)
+ fut = asyncio.gather(c, c, coro('def'), c)
self._run_loop(self.one_loop)
self.assertEqual(fut.result(), ['abc', 'abc', 'def', 'abc'])
@@ -3431,7 +3447,7 @@ class CoroutineGatherTests(GatherTestsBase, test_utils.TestCase):
async def outer():
nonlocal proof, gatherer
- gatherer = asyncio.gather(child1, child2, loop=self.one_loop)
+ gatherer = asyncio.gather(child1, child2)
await gatherer
proof += 100
@@ -3458,7 +3474,7 @@ class CoroutineGatherTests(GatherTestsBase, test_utils.TestCase):
b = self.one_loop.create_future()
async def outer():
- await asyncio.gather(inner(a), inner(b), loop=self.one_loop)
+ await asyncio.gather(inner(a), inner(b))
f = asyncio.ensure_future(outer(), loop=self.one_loop)
test_utils.run_briefly(self.one_loop)
@@ -3597,11 +3613,6 @@ class SleepTests(test_utils.TestCase):
self.loop.run_until_complete(coro())
self.assertEqual(result, 11)
- def test_loop_argument_is_deprecated(self):
- # Remove test when loop argument is removed in Python 3.10
- with self.assertWarns(DeprecationWarning):
- self.loop.run_until_complete(asyncio.sleep(0.01, loop=self.loop))
-
class WaitTests(test_utils.TestCase):
def setUp(self):
@@ -3614,18 +3625,6 @@ class WaitTests(test_utils.TestCase):
self.loop = None
super().tearDown()
- def test_loop_argument_is_deprecated_in_wait(self):
- # Remove test when loop argument is removed in Python 3.10
- with self.assertWarns(DeprecationWarning):
- self.loop.run_until_complete(
- asyncio.wait([coroutine_function()], loop=self.loop))
-
- def test_loop_argument_is_deprecated_in_wait_for(self):
- # Remove test when loop argument is removed in Python 3.10
- with self.assertWarns(DeprecationWarning):
- self.loop.run_until_complete(
- asyncio.wait_for(coroutine_function(), 0.01, loop=self.loop))
-
def test_coro_is_deprecated_in_wait(self):
# Remove test when passing coros to asyncio.wait() is removed in 3.11
with self.assertWarns(DeprecationWarning):
@@ -3677,7 +3676,7 @@ class CompatibilityTests(test_utils.TestCase):
return 'ok2'
async def inner():
- return await asyncio.gather(coro1(), coro2(), loop=self.loop)
+ return await asyncio.gather(coro1(), coro2())
result = self.loop.run_until_complete(inner())
self.assertEqual(['ok1', 'ok2'], result)
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
index 2c7d52a15b..643638564e 100644
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -1,6 +1,5 @@
"""Tests for unix_events.py."""
-import collections
import contextlib
import errno
import io
@@ -30,6 +29,15 @@ from test.test_asyncio import utils as test_utils
MOCK_ANY = mock.ANY
+def EXITCODE(exitcode):
+ return 32768 + exitcode
+
+
+def SIGNAL(signum):
+ assert 1 <= signum <= 68
+ return 32768 - signum
+
+
def tearDownModule():
asyncio.set_event_loop_policy(None)
@@ -1125,15 +1133,6 @@ class BaseChildWatcherTests(unittest.TestCase):
NotImplementedError, watcher._do_waitpid, f)
-WaitPidMocks = collections.namedtuple("WaitPidMocks",
- ("waitpid",
- "WIFEXITED",
- "WIFSIGNALED",
- "WEXITSTATUS",
- "WTERMSIG",
- ))
-
-
class ChildWatcherTestsMixin:
ignore_warnings = mock.patch.object(log.logger, "warning")
@@ -1164,22 +1163,16 @@ class ChildWatcherTestsMixin:
else:
raise ChildProcessError()
- def add_zombie(self, pid, returncode):
- self.zombies[pid] = returncode + 32768
-
- def WIFEXITED(self, status):
- return status >= 32768
+ def add_zombie(self, pid, status):
+ self.zombies[pid] = status
- def WIFSIGNALED(self, status):
- return 32700 < status < 32768
-
- def WEXITSTATUS(self, status):
- self.assertTrue(self.WIFEXITED(status))
- return status - 32768
-
- def WTERMSIG(self, status):
- self.assertTrue(self.WIFSIGNALED(status))
- return 32768 - status
+ def waitstatus_to_exitcode(self, status):
+ if status > 32768:
+ return status - 32768
+ elif 32700 < status < 32768:
+ return status - 32768
+ else:
+ return status
def test_create_watcher(self):
self.m_add_signal_handler.assert_called_once_with(
@@ -1191,19 +1184,13 @@ class ChildWatcherTestsMixin:
return mock.patch(target, wraps=wrapper,
new_callable=mock.Mock)
- with patch('os.WTERMSIG', self.WTERMSIG) as m_WTERMSIG, \
- patch('os.WEXITSTATUS', self.WEXITSTATUS) as m_WEXITSTATUS, \
- patch('os.WIFSIGNALED', self.WIFSIGNALED) as m_WIFSIGNALED, \
- patch('os.WIFEXITED', self.WIFEXITED) as m_WIFEXITED, \
+ with patch('asyncio.unix_events.waitstatus_to_exitcode', self.waitstatus_to_exitcode), \
patch('os.waitpid', self.waitpid) as m_waitpid:
- func(self, WaitPidMocks(m_waitpid,
- m_WIFEXITED, m_WIFSIGNALED,
- m_WEXITSTATUS, m_WTERMSIG,
- ))
+ func(self, m_waitpid)
return wrapped_func
@waitpid_mocks
- def test_sigchld(self, m):
+ def test_sigchld(self, m_waitpid):
# register a child
callback = mock.Mock()
@@ -1212,59 +1199,36 @@ class ChildWatcherTestsMixin:
self.watcher.add_child_handler(42, callback, 9, 10, 14)
self.assertFalse(callback.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# child is running
self.watcher._sig_chld()
self.assertFalse(callback.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# child terminates (returncode 12)
self.running = False
- self.add_zombie(42, 12)
+ self.add_zombie(42, EXITCODE(12))
self.watcher._sig_chld()
- self.assertTrue(m.WIFEXITED.called)
- self.assertTrue(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
callback.assert_called_once_with(42, 12, 9, 10, 14)
- m.WIFSIGNALED.reset_mock()
- m.WIFEXITED.reset_mock()
- m.WEXITSTATUS.reset_mock()
callback.reset_mock()
# ensure that the child is effectively reaped
- self.add_zombie(42, 13)
+ self.add_zombie(42, EXITCODE(13))
with self.ignore_warnings:
self.watcher._sig_chld()
self.assertFalse(callback.called)
- self.assertFalse(m.WTERMSIG.called)
-
- m.WIFSIGNALED.reset_mock()
- m.WIFEXITED.reset_mock()
- m.WEXITSTATUS.reset_mock()
# sigchld called again
self.zombies.clear()
self.watcher._sig_chld()
self.assertFalse(callback.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
@waitpid_mocks
- def test_sigchld_two_children(self, m):
+ def test_sigchld_two_children(self, m_waitpid):
callback1 = mock.Mock()
callback2 = mock.Mock()
@@ -1275,10 +1239,6 @@ class ChildWatcherTestsMixin:
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# register child 2
with self.watcher:
@@ -1286,34 +1246,20 @@ class ChildWatcherTestsMixin:
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# children are running
self.watcher._sig_chld()
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# child 1 terminates (signal 3)
- self.add_zombie(43, -3)
+ self.add_zombie(43, SIGNAL(3))
self.watcher._sig_chld()
callback1.assert_called_once_with(43, -3, 7, 8)
self.assertFalse(callback2.called)
- self.assertTrue(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertTrue(m.WTERMSIG.called)
- m.WIFSIGNALED.reset_mock()
- m.WIFEXITED.reset_mock()
- m.WTERMSIG.reset_mock()
callback1.reset_mock()
# child 2 still running
@@ -1321,40 +1267,25 @@ class ChildWatcherTestsMixin:
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# child 2 terminates (code 108)
- self.add_zombie(44, 108)
+ self.add_zombie(44, EXITCODE(108))
self.running = False
self.watcher._sig_chld()
callback2.assert_called_once_with(44, 108, 147, 18)
self.assertFalse(callback1.called)
- self.assertTrue(m.WIFEXITED.called)
- self.assertTrue(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
- m.WIFSIGNALED.reset_mock()
- m.WIFEXITED.reset_mock()
- m.WEXITSTATUS.reset_mock()
callback2.reset_mock()
# ensure that the children are effectively reaped
- self.add_zombie(43, 14)
- self.add_zombie(44, 15)
+ self.add_zombie(43, EXITCODE(14))
+ self.add_zombie(44, EXITCODE(15))
with self.ignore_warnings:
self.watcher._sig_chld()
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WTERMSIG.called)
-
- m.WIFSIGNALED.reset_mock()
- m.WIFEXITED.reset_mock()
- m.WEXITSTATUS.reset_mock()
# sigchld called again
self.zombies.clear()
@@ -1362,13 +1293,9 @@ class ChildWatcherTestsMixin:
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
@waitpid_mocks
- def test_sigchld_two_children_terminating_together(self, m):
+ def test_sigchld_two_children_terminating_together(self, m_waitpid):
callback1 = mock.Mock()
callback2 = mock.Mock()
@@ -1379,10 +1306,6 @@ class ChildWatcherTestsMixin:
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# register child 2
with self.watcher:
@@ -1390,60 +1313,43 @@ class ChildWatcherTestsMixin:
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# children are running
self.watcher._sig_chld()
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# child 1 terminates (code 78)
# child 2 terminates (signal 5)
- self.add_zombie(45, 78)
- self.add_zombie(46, -5)
+ self.add_zombie(45, EXITCODE(78))
+ self.add_zombie(46, SIGNAL(5))
self.running = False
self.watcher._sig_chld()
callback1.assert_called_once_with(45, 78, 17, 8)
callback2.assert_called_once_with(46, -5, 1147, 18)
- self.assertTrue(m.WIFSIGNALED.called)
- self.assertTrue(m.WIFEXITED.called)
- self.assertTrue(m.WEXITSTATUS.called)
- self.assertTrue(m.WTERMSIG.called)
-
- m.WIFSIGNALED.reset_mock()
- m.WIFEXITED.reset_mock()
- m.WTERMSIG.reset_mock()
- m.WEXITSTATUS.reset_mock()
+
callback1.reset_mock()
callback2.reset_mock()
# ensure that the children are effectively reaped
- self.add_zombie(45, 14)
- self.add_zombie(46, 15)
+ self.add_zombie(45, EXITCODE(14))
+ self.add_zombie(46, EXITCODE(15))
with self.ignore_warnings:
self.watcher._sig_chld()
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WTERMSIG.called)
@waitpid_mocks
- def test_sigchld_race_condition(self, m):
+ def test_sigchld_race_condition(self, m_waitpid):
# register a child
callback = mock.Mock()
with self.watcher:
# child terminates before being registered
- self.add_zombie(50, 4)
+ self.add_zombie(50, EXITCODE(4))
self.watcher._sig_chld()
self.watcher.add_child_handler(50, callback, 1, 12)
@@ -1452,14 +1358,14 @@ class ChildWatcherTestsMixin:
callback.reset_mock()
# ensure that the child is effectively reaped
- self.add_zombie(50, -1)
+ self.add_zombie(50, SIGNAL(1))
with self.ignore_warnings:
self.watcher._sig_chld()
self.assertFalse(callback.called)
@waitpid_mocks
- def test_sigchld_replace_handler(self, m):
+ def test_sigchld_replace_handler(self, m_waitpid):
callback1 = mock.Mock()
callback2 = mock.Mock()
@@ -1470,10 +1376,6 @@ class ChildWatcherTestsMixin:
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# register the same child again
with self.watcher:
@@ -1481,38 +1383,27 @@ class ChildWatcherTestsMixin:
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# child terminates (signal 8)
self.running = False
- self.add_zombie(51, -8)
+ self.add_zombie(51, SIGNAL(8))
self.watcher._sig_chld()
callback2.assert_called_once_with(51, -8, 21)
self.assertFalse(callback1.called)
- self.assertTrue(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertTrue(m.WTERMSIG.called)
- m.WIFSIGNALED.reset_mock()
- m.WIFEXITED.reset_mock()
- m.WTERMSIG.reset_mock()
callback2.reset_mock()
# ensure that the child is effectively reaped
- self.add_zombie(51, 13)
+ self.add_zombie(51, EXITCODE(13))
with self.ignore_warnings:
self.watcher._sig_chld()
self.assertFalse(callback1.called)
self.assertFalse(callback2.called)
- self.assertFalse(m.WTERMSIG.called)
@waitpid_mocks
- def test_sigchld_remove_handler(self, m):
+ def test_sigchld_remove_handler(self, m_waitpid):
callback = mock.Mock()
# register a child
@@ -1521,30 +1412,22 @@ class ChildWatcherTestsMixin:
self.watcher.add_child_handler(52, callback, 1984)
self.assertFalse(callback.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# unregister the child
self.watcher.remove_child_handler(52)
self.assertFalse(callback.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# child terminates (code 99)
self.running = False
- self.add_zombie(52, 99)
+ self.add_zombie(52, EXITCODE(99))
with self.ignore_warnings:
self.watcher._sig_chld()
self.assertFalse(callback.called)
@waitpid_mocks
- def test_sigchld_unknown_status(self, m):
+ def test_sigchld_unknown_status(self, m_waitpid):
callback = mock.Mock()
# register a child
@@ -1553,10 +1436,6 @@ class ChildWatcherTestsMixin:
self.watcher.add_child_handler(53, callback, -19)
self.assertFalse(callback.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# terminate with unknown status
self.zombies[53] = 1178
@@ -1564,24 +1443,18 @@ class ChildWatcherTestsMixin:
self.watcher._sig_chld()
callback.assert_called_once_with(53, 1178, -19)
- self.assertTrue(m.WIFEXITED.called)
- self.assertTrue(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
callback.reset_mock()
- m.WIFEXITED.reset_mock()
- m.WIFSIGNALED.reset_mock()
# ensure that the child is effectively reaped
- self.add_zombie(53, 101)
+ self.add_zombie(53, EXITCODE(101))
with self.ignore_warnings:
self.watcher._sig_chld()
self.assertFalse(callback.called)
@waitpid_mocks
- def test_remove_child_handler(self, m):
+ def test_remove_child_handler(self, m_waitpid):
callback1 = mock.Mock()
callback2 = mock.Mock()
callback3 = mock.Mock()
@@ -1602,9 +1475,9 @@ class ChildWatcherTestsMixin:
self.assertFalse(self.watcher.remove_child_handler(55))
# all children terminate
- self.add_zombie(54, 0)
- self.add_zombie(55, 1)
- self.add_zombie(56, 2)
+ self.add_zombie(54, EXITCODE(0))
+ self.add_zombie(55, EXITCODE(1))
+ self.add_zombie(56, EXITCODE(2))
self.running = False
with self.ignore_warnings:
self.watcher._sig_chld()
@@ -1614,7 +1487,7 @@ class ChildWatcherTestsMixin:
callback3.assert_called_once_with(56, 2, 3)
@waitpid_mocks
- def test_sigchld_unhandled_exception(self, m):
+ def test_sigchld_unhandled_exception(self, m_waitpid):
callback = mock.Mock()
# register a child
@@ -1623,7 +1496,7 @@ class ChildWatcherTestsMixin:
self.watcher.add_child_handler(57, callback)
# raise an exception
- m.waitpid.side_effect = ValueError
+ m_waitpid.side_effect = ValueError
with mock.patch.object(log.logger,
'error') as m_error:
@@ -1632,7 +1505,7 @@ class ChildWatcherTestsMixin:
self.assertTrue(m_error.called)
@waitpid_mocks
- def test_sigchld_child_reaped_elsewhere(self, m):
+ def test_sigchld_child_reaped_elsewhere(self, m_waitpid):
# register a child
callback = mock.Mock()
@@ -1641,19 +1514,15 @@ class ChildWatcherTestsMixin:
self.watcher.add_child_handler(58, callback)
self.assertFalse(callback.called)
- self.assertFalse(m.WIFEXITED.called)
- self.assertFalse(m.WIFSIGNALED.called)
- self.assertFalse(m.WEXITSTATUS.called)
- self.assertFalse(m.WTERMSIG.called)
# child terminates
self.running = False
- self.add_zombie(58, 4)
+ self.add_zombie(58, EXITCODE(4))
# waitpid is called elsewhere
os.waitpid(58, os.WNOHANG)
- m.waitpid.reset_mock()
+ m_waitpid.reset_mock()
# sigchld
with self.ignore_warnings:
@@ -1667,7 +1536,7 @@ class ChildWatcherTestsMixin:
callback.assert_called_once_with(58, 255)
@waitpid_mocks
- def test_sigchld_unknown_pid_during_registration(self, m):
+ def test_sigchld_unknown_pid_during_registration(self, m_waitpid):
# register two children
callback1 = mock.Mock()
callback2 = mock.Mock()
@@ -1675,9 +1544,9 @@ class ChildWatcherTestsMixin:
with self.ignore_warnings, self.watcher:
self.running = True
# child 1 terminates
- self.add_zombie(591, 7)
+ self.add_zombie(591, EXITCODE(7))
# an unknown child terminates
- self.add_zombie(593, 17)
+ self.add_zombie(593, EXITCODE(17))
self.watcher._sig_chld()
@@ -1688,7 +1557,7 @@ class ChildWatcherTestsMixin:
self.assertFalse(callback2.called)
@waitpid_mocks
- def test_set_loop(self, m):
+ def test_set_loop(self, m_waitpid):
# register a child
callback = mock.Mock()
@@ -1713,13 +1582,13 @@ class ChildWatcherTestsMixin:
# child terminates
self.running = False
- self.add_zombie(60, 9)
+ self.add_zombie(60, EXITCODE(9))
self.watcher._sig_chld()
callback.assert_called_once_with(60, 9)
@waitpid_mocks
- def test_set_loop_race_condition(self, m):
+ def test_set_loop_race_condition(self, m_waitpid):
# register 3 children
callback1 = mock.Mock()
callback2 = mock.Mock()
@@ -1746,8 +1615,8 @@ class ChildWatcherTestsMixin:
signal.SIGCHLD)
# child 1 & 2 terminate
- self.add_zombie(61, 11)
- self.add_zombie(62, -5)
+ self.add_zombie(61, EXITCODE(11))
+ self.add_zombie(62, SIGNAL(5))
# SIGCHLD was not caught
self.assertFalse(callback1.called)
@@ -1773,7 +1642,7 @@ class ChildWatcherTestsMixin:
# child 3 terminates
self.running = False
- self.add_zombie(622, 19)
+ self.add_zombie(622, EXITCODE(19))
self.watcher._sig_chld()
self.assertFalse(callback1.called)
@@ -1781,16 +1650,16 @@ class ChildWatcherTestsMixin:
callback3.assert_called_once_with(622, 19)
@waitpid_mocks
- def test_close(self, m):
+ def test_close(self, m_waitpid):
# register two children
callback1 = mock.Mock()
with self.watcher:
self.running = True
# child 1 terminates
- self.add_zombie(63, 9)
+ self.add_zombie(63, EXITCODE(9))
# other child terminates
- self.add_zombie(65, 18)
+ self.add_zombie(65, EXITCODE(18))
self.watcher._sig_chld()
self.watcher.add_child_handler(63, callback1)
diff --git a/Lib/test/test_asyncio/utils.py b/Lib/test/test_asyncio/utils.py
index 34da7390e1..67180f7eb3 100644
--- a/Lib/test/test_asyncio/utils.py
+++ b/Lib/test/test_asyncio/utils.py
@@ -541,17 +541,10 @@ class TestCase(unittest.TestCase):
self.set_event_loop(loop)
return loop
- def unpatch_get_running_loop(self):
- events._get_running_loop = self._get_running_loop
-
def setUp(self):
- self._get_running_loop = events._get_running_loop
- events._get_running_loop = lambda: None
self._thread_cleanup = threading_helper.threading_setup()
def tearDown(self):
- self.unpatch_get_running_loop()
-
events.set_event_loop(None)
# Detect CPython bug #23353: ensure that yield/yield-from is not used
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py
index 06c6bc2e99..3bd904d177 100644
--- a/Lib/test/test_asyncore.py
+++ b/Lib/test/test_asyncore.py
@@ -69,7 +69,7 @@ def capture_server(evt, buf, serv):
try:
serv.listen()
conn, addr = serv.accept()
- except socket.timeout:
+ except TimeoutError:
pass
else:
n = 200
diff --git a/Lib/test/test_atexit.py b/Lib/test/test_atexit.py
index 3105f6c378..e0feef7c65 100644
--- a/Lib/test/test_atexit.py
+++ b/Lib/test/test_atexit.py
@@ -1,162 +1,22 @@
-import sys
-import unittest
-import io
import atexit
import os
+import sys
+import textwrap
+import unittest
from test import support
from test.support import script_helper
-### helpers
-def h1():
- print("h1")
-
-def h2():
- print("h2")
-
-def h3():
- print("h3")
-
-def h4(*args, **kwargs):
- print("h4", args, kwargs)
-
-def raise1():
- raise TypeError
-
-def raise2():
- raise SystemError
-
-def exit():
- raise SystemExit
-
class GeneralTest(unittest.TestCase):
+ def test_general(self):
+ # Run _test_atexit.py in a subprocess since it calls atexit._clear()
+ script = support.findfile("_test_atexit.py")
+ script_helper.run_test_script(script)
- def setUp(self):
- self.save_stdout = sys.stdout
- self.save_stderr = sys.stderr
- self.stream = io.StringIO()
- sys.stdout = sys.stderr = self.stream
- atexit._clear()
-
- def tearDown(self):
- sys.stdout = self.save_stdout
- sys.stderr = self.save_stderr
- atexit._clear()
-
- def test_args(self):
- # be sure args are handled properly
- atexit.register(h1)
- atexit.register(h4)
- atexit.register(h4, 4, kw="abc")
- atexit._run_exitfuncs()
-
- self.assertEqual(self.stream.getvalue(),
- "h4 (4,) {'kw': 'abc'}\nh4 () {}\nh1\n")
-
- def test_badargs(self):
- atexit.register(lambda: 1, 0, 0, (x for x in (1,2)), 0, 0)
- self.assertRaises(TypeError, atexit._run_exitfuncs)
-
- def test_order(self):
- # be sure handlers are executed in reverse order
- atexit.register(h1)
- atexit.register(h2)
- atexit.register(h3)
- atexit._run_exitfuncs()
-
- self.assertEqual(self.stream.getvalue(), "h3\nh2\nh1\n")
-
- def test_raise(self):
- # be sure raises are handled properly
- atexit.register(raise1)
- atexit.register(raise2)
-
- self.assertRaises(TypeError, atexit._run_exitfuncs)
-
- def test_raise_unnormalized(self):
- # Issue #10756: Make sure that an unnormalized exception is
- # handled properly
- atexit.register(lambda: 1 / 0)
-
- self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs)
- self.assertIn("ZeroDivisionError", self.stream.getvalue())
-
- def test_exit(self):
- # be sure a SystemExit is handled properly
- atexit.register(exit)
-
- self.assertRaises(SystemExit, atexit._run_exitfuncs)
- self.assertEqual(self.stream.getvalue(), '')
-
- def test_print_tracebacks(self):
- # Issue #18776: the tracebacks should be printed when errors occur.
- def f():
- 1/0 # one
- def g():
- 1/0 # two
- def h():
- 1/0 # three
- atexit.register(f)
- atexit.register(g)
- atexit.register(h)
-
- self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs)
- stderr = self.stream.getvalue()
- self.assertEqual(stderr.count("ZeroDivisionError"), 3)
- self.assertIn("# one", stderr)
- self.assertIn("# two", stderr)
- self.assertIn("# three", stderr)
-
- def test_stress(self):
- a = [0]
- def inc():
- a[0] += 1
-
- for i in range(128):
- atexit.register(inc)
- atexit._run_exitfuncs()
-
- self.assertEqual(a[0], 128)
-
- def test_clear(self):
- a = [0]
- def inc():
- a[0] += 1
-
- atexit.register(inc)
- atexit._clear()
- atexit._run_exitfuncs()
-
- self.assertEqual(a[0], 0)
-
- def test_unregister(self):
- a = [0]
- def inc():
- a[0] += 1
- def dec():
- a[0] -= 1
-
- for i in range(4):
- atexit.register(inc)
- atexit.register(dec)
- atexit.unregister(inc)
- atexit._run_exitfuncs()
-
- self.assertEqual(a[0], -1)
-
- def test_bound_methods(self):
- l = []
- atexit.register(l.append, 5)
- atexit._run_exitfuncs()
- self.assertEqual(l, [5])
-
- atexit.unregister(l.append)
- atexit._run_exitfuncs()
- self.assertEqual(l, [5])
-
+class FunctionalTest(unittest.TestCase):
def test_shutdown(self):
# Actually test the shutdown mechanism in a subprocess
- code = """if 1:
+ code = textwrap.dedent("""
import atexit
def f(msg):
@@ -164,11 +24,29 @@ class GeneralTest(unittest.TestCase):
atexit.register(f, "one")
atexit.register(f, "two")
- """
+ """)
res = script_helper.assert_python_ok("-c", code)
self.assertEqual(res.out.decode().splitlines(), ["two", "one"])
self.assertFalse(res.err)
+ def test_atexit_instances(self):
+ # bpo-42639: It is safe to have more than one atexit instance.
+ code = textwrap.dedent("""
+ import sys
+ import atexit as atexit1
+ del sys.modules['atexit']
+ import atexit as atexit2
+ del sys.modules['atexit']
+
+ assert atexit2 is not atexit1
+
+ atexit1.register(print, "atexit1")
+ atexit2.register(print, "atexit2")
+ """)
+ res = script_helper.assert_python_ok("-c", code)
+ self.assertEqual(res.out.decode().splitlines(), ["atexit2", "atexit1"])
+ self.assertFalse(res.err)
+
@support.cpython_only
class SubinterpreterTest(unittest.TestCase):
@@ -178,13 +56,13 @@ class SubinterpreterTest(unittest.TestCase):
# take care to free callbacks in its per-subinterpreter module
# state.
n = atexit._ncallbacks()
- code = r"""if 1:
+ code = textwrap.dedent(r"""
import atexit
def f():
pass
atexit.register(f)
del atexit
- """
+ """)
ret = support.run_in_subinterp(code)
self.assertEqual(ret, 0)
self.assertEqual(atexit._ncallbacks(), n)
@@ -193,13 +71,13 @@ class SubinterpreterTest(unittest.TestCase):
# Similar to the above, but with a refcycle through the atexit
# module.
n = atexit._ncallbacks()
- code = r"""if 1:
+ code = textwrap.dedent(r"""
import atexit
def f():
pass
atexit.register(f)
atexit.__atexit = atexit
- """
+ """)
ret = support.run_in_subinterp(code)
self.assertEqual(ret, 0)
self.assertEqual(atexit._ncallbacks(), n)
@@ -210,13 +88,13 @@ class SubinterpreterTest(unittest.TestCase):
expected = b"The test has passed!"
r, w = os.pipe()
- code = r"""if 1:
+ code = textwrap.dedent(r"""
import os
import atexit
def callback():
os.write({:d}, b"The test has passed!")
atexit.register(callback)
- """.format(w)
+ """.format(w))
ret = support.run_in_subinterp(code)
os.close(w)
self.assertEqual(os.read(r, len(expected)), expected)
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index edb4ec092e..8c9573731a 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -6,6 +6,7 @@ import builtins
import collections
import decimal
import fractions
+import gc
import io
import locale
import os
@@ -1756,6 +1757,18 @@ class BuiltinTest(unittest.TestCase):
l8 = self.iter_error(zip(Iter(3), "AB", strict=True), ValueError)
self.assertEqual(l8, [(2, "A"), (1, "B")])
+ @support.cpython_only
+ def test_zip_result_gc(self):
+ # bpo-42536: zip's tuple-reuse speed trick breaks the GC's assumptions
+ # about what can be untracked. Make sure we re-track result tuples
+ # whenever we reuse them.
+ it = zip([[]])
+ gc.collect()
+ # That GC collection probably untracked the recycled internal result
+ # tuple, which is initialized to (None,). Make sure it's re-tracked when
+ # it's mutated and returned from __next__:
+ self.assertTrue(gc.is_tracked(next(it)))
+
def test_format(self):
# Test the basic machinery of the format() builtin. Don't test
# the specifics of the various formatters
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index e61228d1a2..d550abfc65 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -1036,6 +1036,7 @@ class BytesTest(BaseBytesTest, unittest.TestCase):
c_char_p)
PyBytes_FromFormat = pythonapi.PyBytes_FromFormat
+ PyBytes_FromFormat.argtypes = (c_char_p,)
PyBytes_FromFormat.restype = py_object
# basic tests
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index db62b47100..a4ebe4a0a1 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -405,6 +405,9 @@ class CAPITest(unittest.TestCase):
self.assertEqual(_testcapi.HeapDocCType.__doc__, "somedoc")
self.assertEqual(_testcapi.HeapDocCType.__text_signature__, "(arg1, arg2)")
+ def test_null_type_doc(self):
+ self.assertEqual(_testcapi.NullTpDocType.__doc__, None)
+
def test_subclass_of_heap_gc_ctype_with_tpdealloc_decrefs_once(self):
class HeapGcCTypeSubclass(_testcapi.HeapGcCType):
def __init__(self):
diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py
index 80b9aec7c2..4aa9691a48 100644
--- a/Lib/test/test_clinic.py
+++ b/Lib/test/test_clinic.py
@@ -795,17 +795,29 @@ class ClinicExternalTest(TestCase):
maxDiff = None
def test_external(self):
+ # bpo-42398: Test that the destination file is left unchanged if the
+ # content does not change. Moreover, check also that the file
+ # modification time does not change in this case.
source = support.findfile('clinic.test')
with open(source, 'r', encoding='utf-8') as f:
- original = f.read()
- with os_helper.temp_dir() as testdir:
- testfile = os.path.join(testdir, 'clinic.test.c')
+ orig_contents = f.read()
+
+ with os_helper.temp_dir() as tmp_dir:
+ testfile = os.path.join(tmp_dir, 'clinic.test.c')
with open(testfile, 'w', encoding='utf-8') as f:
- f.write(original)
- clinic.parse_file(testfile, force=True)
+ f.write(orig_contents)
+ old_mtime_ns = os.stat(testfile).st_mtime_ns
+
+ clinic.parse_file(testfile)
+
with open(testfile, 'r', encoding='utf-8') as f:
- result = f.read()
- self.assertEqual(result, original)
+ new_contents = f.read()
+ new_mtime_ns = os.stat(testfile).st_mtime_ns
+
+ self.assertEqual(new_contents, orig_contents)
+ # Don't change the file modification time
+ # if the content does not change
+ self.assertEqual(new_mtime_ns, old_mtime_ns)
if __name__ == "__main__":
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index fa3329efa2..f12dff3202 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -153,6 +153,14 @@ class CmdLineTest(unittest.TestCase):
% (os_helper.FS_NONASCII, ord(os_helper.FS_NONASCII)))
assert_python_ok('-c', command)
+ @unittest.skipUnless(os_helper.FS_NONASCII, 'need os_helper.FS_NONASCII')
+ def test_coding(self):
+ # bpo-32381: the -c command ignores the coding cookie
+ ch = os_helper.FS_NONASCII
+ cmd = f"# coding: latin1\nprint(ascii('{ch}'))"
+ res = assert_python_ok('-c', cmd)
+ self.assertEqual(res.out.rstrip(), ascii(ch).encode('ascii'))
+
# On Windows, pass bytes to subprocess doesn't test how Python decodes the
# command line, but how subprocess does decode bytes to unicode. Python
# doesn't decode the command line because Windows provides directly the
diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py
index ac3dde7456..467e8e5e33 100644
--- a/Lib/test/test_code.py
+++ b/Lib/test/test_code.py
@@ -258,7 +258,7 @@ class CodeTest(unittest.TestCase):
("co_cellvars", ("cellvar",)),
("co_filename", "newfilename"),
("co_name", "newname"),
- ("co_lnotab", code2.co_lnotab),
+ ("co_linetable", code2.co_linetable),
):
with self.subTest(attr=attr, value=value):
new_code = code.replace(**{attr: value})
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 7c7f8655b0..a1ca958257 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -196,6 +196,22 @@ class TestChainMap(unittest.TestCase):
('e', 55), ('f', 666), ('g', 777), ('h', 88888),
('i', 9999), ('j', 0)])
+ def test_iter_not_calling_getitem_on_maps(self):
+ class DictWithGetItem(UserDict):
+ def __init__(self, *args, **kwds):
+ self.called = False
+ UserDict.__init__(self, *args, **kwds)
+ def __getitem__(self, item):
+ self.called = True
+ UserDict.__getitem__(self, item)
+
+ d = DictWithGetItem(a=1)
+ c = ChainMap(d)
+ d.called = False
+
+ set(c) # iterate over chain map
+ self.assertFalse(d.called, '__getitem__ was called')
+
def test_dict_coercion(self):
d = ChainMap(dict(a=1, b=2), dict(b=20, c=30))
self.assertEqual(dict(d), dict(a=1, b=2, c=30))
@@ -1559,6 +1575,62 @@ class TestCollectionABCs(ABCTestCase):
# coerce both to a real set then check equality
self.assertSetEqual(set(s1), set(s2))
+ def test_Set_from_iterable(self):
+ """Verify _from_iterable overriden to an instance method works."""
+ class SetUsingInstanceFromIterable(MutableSet):
+ def __init__(self, values, created_by):
+ if not created_by:
+ raise ValueError(f'created_by must be specified')
+ self.created_by = created_by
+ self._values = set(values)
+
+ def _from_iterable(self, values):
+ return type(self)(values, 'from_iterable')
+
+ def __contains__(self, value):
+ return value in self._values
+
+ def __iter__(self):
+ yield from self._values
+
+ def __len__(self):
+ return len(self._values)
+
+ def add(self, value):
+ self._values.add(value)
+
+ def discard(self, value):
+ self._values.discard(value)
+
+ impl = SetUsingInstanceFromIterable([1, 2, 3], 'test')
+
+ actual = impl - {1}
+ self.assertIsInstance(actual, SetUsingInstanceFromIterable)
+ self.assertEqual('from_iterable', actual.created_by)
+ self.assertEqual({2, 3}, actual)
+
+ actual = impl | {4}
+ self.assertIsInstance(actual, SetUsingInstanceFromIterable)
+ self.assertEqual('from_iterable', actual.created_by)
+ self.assertEqual({1, 2, 3, 4}, actual)
+
+ actual = impl & {2}
+ self.assertIsInstance(actual, SetUsingInstanceFromIterable)
+ self.assertEqual('from_iterable', actual.created_by)
+ self.assertEqual({2}, actual)
+
+ actual = impl ^ {3, 4}
+ self.assertIsInstance(actual, SetUsingInstanceFromIterable)
+ self.assertEqual('from_iterable', actual.created_by)
+ self.assertEqual({1, 2, 4}, actual)
+
+ # NOTE: ixor'ing with a list is important here: internally, __ixor__
+ # only calls _from_iterable if the other value isn't already a Set.
+ impl ^= [3, 4]
+ self.assertIsInstance(impl, SetUsingInstanceFromIterable)
+ self.assertEqual('test', impl.created_by)
+ self.assertEqual({1, 2, 4}, impl)
+
def test_Set_interoperability_with_real_sets(self):
# Issue: 8743
class ListSet(Set):
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 6055192bf7..3e826b9acc 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -155,8 +155,8 @@ if 1:
def test_leading_newlines(self):
s256 = "".join(["\n"] * 256 + ["spam"])
co = compile(s256, 'fn', 'exec')
- self.assertEqual(co.co_firstlineno, 257)
- self.assertEqual(co.co_lnotab, bytes())
+ self.assertEqual(co.co_firstlineno, 1)
+ self.assertEqual(list(co.co_lines()), [(0, 8, 257)])
def test_literals_with_leading_zeroes(self):
for arg in ["077787", "0xj", "0x.", "0e", "090000000000000",
@@ -728,10 +728,10 @@ if 1:
for func in funcs:
opcodes = list(dis.get_instructions(func))
- self.assertEqual(2, len(opcodes))
- self.assertEqual('LOAD_CONST', opcodes[0].opname)
- self.assertEqual(None, opcodes[0].argval)
- self.assertEqual('RETURN_VALUE', opcodes[1].opname)
+ self.assertLessEqual(len(opcodes), 3)
+ self.assertEqual('LOAD_CONST', opcodes[-2].opname)
+ self.assertEqual(None, opcodes[-2].argval)
+ self.assertEqual('RETURN_VALUE', opcodes[-1].opname)
def test_false_while_loop(self):
def break_in_while():
@@ -752,6 +752,81 @@ if 1:
self.assertEqual(None, opcodes[0].argval)
self.assertEqual('RETURN_VALUE', opcodes[1].opname)
+ def test_consts_in_conditionals(self):
+ def and_true(x):
+ return True and x
+
+ def and_false(x):
+ return False and x
+
+ def or_true(x):
+ return True or x
+
+ def or_false(x):
+ return False or x
+
+ funcs = [and_true, and_false, or_true, or_false]
+
+ # Check that condition is removed.
+ for func in funcs:
+ with self.subTest(func=func):
+ opcodes = list(dis.get_instructions(func))
+ self.assertEqual(2, len(opcodes))
+ self.assertIn('LOAD_', opcodes[0].opname)
+ self.assertEqual('RETURN_VALUE', opcodes[1].opname)
+
+ def test_lineno_after_implicit_return(self):
+ TRUE = True
+ # Don't use constant True or False, as compiler will remove test
+ def if1(x):
+ x()
+ if TRUE:
+ pass
+ def if2(x):
+ x()
+ if TRUE:
+ pass
+ else:
+ pass
+ def if3(x):
+ x()
+ if TRUE:
+ pass
+ else:
+ return None
+ def if4(x):
+ x()
+ if not TRUE:
+ pass
+ funcs = [ if1, if2, if3, if4]
+ lastlines = [ 3, 3, 3, 2]
+ frame = None
+ def save_caller_frame():
+ nonlocal frame
+ frame = sys._getframe(1)
+ for func, lastline in zip(funcs, lastlines, strict=True):
+ with self.subTest(func=func):
+ func(save_caller_frame)
+ self.assertEqual(frame.f_lineno-frame.f_code.co_firstlineno, lastline)
+
+ def test_lineno_after_no_code(self):
+ def no_code1():
+ "doc string"
+
+ def no_code2():
+ a: int
+
+ for func in (no_code1, no_code2):
+ with self.subTest(func=func):
+ code = func.__code__
+ lines = list(code.co_lines())
+ self.assertEqual(len(lines), 1)
+ start, end, line = lines[0]
+ self.assertEqual(start, 0)
+ self.assertEqual(end, len(code.co_code))
+ self.assertEqual(line, code.co_firstlineno)
+
+
def test_big_dict_literal(self):
# The compiler has a flushing point in "compiler_dict" that calls compiles
# a portion of the dictionary literal when the loop that iterates over the items
@@ -762,6 +837,34 @@ if 1:
the_dict = "{" + ",".join(f"{x}:{x}" for x in range(dict_size)) + "}"
self.assertEqual(len(eval(the_dict)), dict_size)
+ def test_redundant_jump_in_if_else_break(self):
+ # Check if bytecode containing jumps that simply point to the next line
+ # is generated around if-else-break style structures. See bpo-42615.
+
+ def if_else_break():
+ val = 1
+ while True:
+ if val > 0:
+ val -= 1
+ else:
+ break
+ val = -1
+
+ INSTR_SIZE = 2
+ HANDLED_JUMPS = (
+ 'POP_JUMP_IF_FALSE',
+ 'POP_JUMP_IF_TRUE',
+ 'JUMP_ABSOLUTE',
+ 'JUMP_FORWARD',
+ )
+
+ for line, instr in enumerate(dis.Bytecode(if_else_break)):
+ if instr.opname == 'JUMP_FORWARD':
+ self.assertNotEqual(instr.arg, 0)
+ elif instr.opname in HANDLED_JUMPS:
+ self.assertNotEqual(instr.arg, (line + 1)*INSTR_SIZE)
+
+
class TestExpressionStackSize(unittest.TestCase):
# These tests check that the computed stack size for a code object
# stays within reasonable bounds (see issue #21523 for an example
diff --git a/Lib/test/test_contextlib_async.py b/Lib/test/test_contextlib_async.py
index 3765f6cbf2..290ef05b82 100644
--- a/Lib/test/test_contextlib_async.py
+++ b/Lib/test/test_contextlib_async.py
@@ -1,5 +1,7 @@
import asyncio
-from contextlib import aclosing, asynccontextmanager, AbstractAsyncContextManager, AsyncExitStack
+from contextlib import (
+ asynccontextmanager, AbstractAsyncContextManager,
+ AsyncExitStack, nullcontext, aclosing)
import functools
from test import support
import unittest
@@ -278,6 +280,33 @@ class AsyncContextManagerTestCase(unittest.TestCase):
async with woohoo(self=11, func=22, args=33, kwds=44) as target:
self.assertEqual(target, (11, 22, 33, 44))
+ @_async_test
+ async def test_recursive(self):
+ depth = 0
+ ncols = 0
+
+ @asynccontextmanager
+ async def woohoo():
+ nonlocal ncols
+ ncols += 1
+
+ nonlocal depth
+ before = depth
+ depth += 1
+ yield
+ depth -= 1
+ self.assertEqual(depth, before)
+
+ @woohoo()
+ async def recursive():
+ if depth < 10:
+ await recursive()
+
+ await recursive()
+
+ self.assertEqual(ncols, 10)
+ self.assertEqual(depth, 0)
+
class AclosingTestCase(unittest.TestCase):
@@ -510,5 +539,15 @@ class TestAsyncExitStack(TestBaseExitStack, unittest.TestCase):
self.assertIsInstance(inner_exc.__context__, ZeroDivisionError)
+class TestAsyncNullcontext(unittest.TestCase):
+ @_async_test
+ async def test_async_nullcontext(self):
+ class C:
+ pass
+ c = C()
+ async with nullcontext(c) as c_in:
+ self.assertIs(c_in, c)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 307416c330..f0048f42f8 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -4,6 +4,8 @@ import gc
import itertools
import math
import pickle
+import random
+import string
import sys
import types
import unittest
@@ -845,6 +847,14 @@ class ClassPropertiesAndMethods(unittest.TestCase):
self.fail("inheriting from ModuleType and str at the same time "
"should fail")
+ # Issue 34805: Verify that definition order is retained
+ def random_name():
+ return ''.join(random.choices(string.ascii_letters, k=10))
+ class A:
+ pass
+ subclasses = [type(random_name(), (A,), {}) for i in range(100)]
+ self.assertEqual(A.__subclasses__(), subclasses)
+
def test_multiple_inheritance(self):
# Testing multiple inheritance...
class C(object):
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 9ff8b7d501..4b31cdc794 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1452,6 +1452,25 @@ class DictTest(unittest.TestCase):
d = CustomReversedDict(pairs)
self.assertEqual(pairs[::-1], list(dict(d).items()))
+ @support.cpython_only
+ def test_dict_items_result_gc(self):
+ # bpo-42536: dict.items's tuple-reuse speed trick breaks the GC's
+ # assumptions about what can be untracked. Make sure we re-track result
+ # tuples whenever we reuse them.
+ it = iter({None: []}.items())
+ gc.collect()
+ # That GC collection probably untracked the recycled internal result
+ # tuple, which is initialized to (None, None). Make sure it's re-tracked
+ # when it's mutated and returned from __next__:
+ self.assertTrue(gc.is_tracked(next(it)))
+
+ @support.cpython_only
+ def test_dict_items_result_gc(self):
+ # Same as test_dict_items_result_gc above, but reversed.
+ it = reversed({None: []}.items())
+ gc.collect()
+ self.assertTrue(gc.is_tracked(next(it)))
+
class CAPITest(unittest.TestCase):
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index bbaddd57d2..0383124464 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -131,12 +131,14 @@ dis_bug708901 = """\
12 STORE_FAST 0 (res)
%3d 14 JUMP_ABSOLUTE 10
- >> 16 LOAD_CONST 0 (None)
+
+%3d >> 16 LOAD_CONST 0 (None)
18 RETURN_VALUE
""" % (bug708901.__code__.co_firstlineno + 1,
bug708901.__code__.co_firstlineno + 2,
bug708901.__code__.co_firstlineno + 1,
- bug708901.__code__.co_firstlineno + 3)
+ bug708901.__code__.co_firstlineno + 3,
+ bug708901.__code__.co_firstlineno + 1)
def bug1333982(x=[]):
@@ -145,30 +147,38 @@ def bug1333982(x=[]):
pass
dis_bug1333982 = """\
-%3d 0 LOAD_CONST 1 (0)
- 2 POP_JUMP_IF_TRUE 26
- 4 LOAD_ASSERTION_ERROR
- 6 LOAD_CONST 2 (<code object <listcomp> at 0x..., file "%s", line %d>)
- 8 LOAD_CONST 3 ('bug1333982.<locals>.<listcomp>')
- 10 MAKE_FUNCTION 0
- 12 LOAD_FAST 0 (x)
- 14 GET_ITER
- 16 CALL_FUNCTION 1
-
-%3d 18 LOAD_CONST 4 (1)
-
-%3d 20 BINARY_ADD
- 22 CALL_FUNCTION 1
- 24 RAISE_VARARGS 1
-
-%3d >> 26 LOAD_CONST 0 (None)
- 28 RETURN_VALUE
+%3d 0 LOAD_ASSERTION_ERROR
+ 2 LOAD_CONST 2 (<code object <listcomp> at 0x..., file "%s", line %d>)
+ 4 LOAD_CONST 3 ('bug1333982.<locals>.<listcomp>')
+ 6 MAKE_FUNCTION 0
+ 8 LOAD_FAST 0 (x)
+ 10 GET_ITER
+ 12 CALL_FUNCTION 1
+
+%3d 14 LOAD_CONST 4 (1)
+
+%3d 16 BINARY_ADD
+ 18 CALL_FUNCTION 1
+ 20 RAISE_VARARGS 1
""" % (bug1333982.__code__.co_firstlineno + 1,
__file__,
bug1333982.__code__.co_firstlineno + 1,
bug1333982.__code__.co_firstlineno + 2,
- bug1333982.__code__.co_firstlineno + 1,
- bug1333982.__code__.co_firstlineno + 3)
+ bug1333982.__code__.co_firstlineno + 1)
+
+
+def bug42562():
+ pass
+
+
+# Set line number for 'pass' to None
+bug42562.__code__ = bug42562.__code__.replace(co_linetable=b'\x04\x80\xff\x80')
+
+
+dis_bug42562 = """\
+ 0 LOAD_CONST 0 (None)
+ 2 RETURN_VALUE
+"""
_BIG_LINENO_FORMAT = """\
%3d 0 LOAD_GLOBAL 0 (spam)
@@ -259,55 +269,60 @@ dis_compound_stmt_str = """\
1 0 LOAD_CONST 0 (0)
2 STORE_NAME 0 (x)
- 3 >> 4 LOAD_NAME 0 (x)
- 6 LOAD_CONST 1 (1)
- 8 INPLACE_ADD
- 10 STORE_NAME 0 (x)
- 12 JUMP_ABSOLUTE 4
- 14 LOAD_CONST 2 (None)
- 16 RETURN_VALUE
+ 2 4 NOP
+
+ 3 >> 6 LOAD_NAME 0 (x)
+ 8 LOAD_CONST 1 (1)
+ 10 INPLACE_ADD
+ 12 STORE_NAME 0 (x)
+
+ 2 14 JUMP_ABSOLUTE 6
"""
dis_traceback = """\
-%3d 0 SETUP_FINALLY 12 (to 14)
+%3d 0 SETUP_FINALLY 14 (to 16)
%3d 2 LOAD_CONST 1 (1)
4 LOAD_CONST 2 (0)
--> 6 BINARY_TRUE_DIVIDE
8 POP_TOP
10 POP_BLOCK
- 12 JUMP_FORWARD 42 (to 56)
-
-%3d >> 14 DUP_TOP
- 16 LOAD_GLOBAL 0 (Exception)
- 18 JUMP_IF_NOT_EXC_MATCH 54
- 20 POP_TOP
- 22 STORE_FAST 0 (e)
- 24 POP_TOP
- 26 SETUP_FINALLY 18 (to 46)
-
-%3d 28 LOAD_FAST 0 (e)
- 30 LOAD_ATTR 1 (__traceback__)
- 32 STORE_FAST 1 (tb)
- 34 POP_BLOCK
- 36 POP_EXCEPT
- 38 LOAD_CONST 0 (None)
- 40 STORE_FAST 0 (e)
- 42 DELETE_FAST 0 (e)
- 44 JUMP_FORWARD 10 (to 56)
- >> 46 LOAD_CONST 0 (None)
- 48 STORE_FAST 0 (e)
- 50 DELETE_FAST 0 (e)
- 52 RERAISE
- >> 54 RERAISE
-
-%3d >> 56 LOAD_FAST 1 (tb)
- 58 RETURN_VALUE
+
+%3d 12 LOAD_FAST 1 (tb)
+ 14 RETURN_VALUE
+
+%3d >> 16 DUP_TOP
+ 18 LOAD_GLOBAL 0 (Exception)
+ 20 JUMP_IF_NOT_EXC_MATCH 58
+ 22 POP_TOP
+ 24 STORE_FAST 0 (e)
+ 26 POP_TOP
+ 28 SETUP_FINALLY 20 (to 50)
+
+%3d 30 LOAD_FAST 0 (e)
+ 32 LOAD_ATTR 1 (__traceback__)
+ 34 STORE_FAST 1 (tb)
+ 36 POP_BLOCK
+ 38 POP_EXCEPT
+ 40 LOAD_CONST 0 (None)
+ 42 STORE_FAST 0 (e)
+ 44 DELETE_FAST 0 (e)
+
+%3d 46 LOAD_FAST 1 (tb)
+ 48 RETURN_VALUE
+ >> 50 LOAD_CONST 0 (None)
+ 52 STORE_FAST 0 (e)
+ 54 DELETE_FAST 0 (e)
+ 56 RERAISE 1
+
+%3d >> 58 RERAISE 0
""" % (TRACEBACK_CODE.co_firstlineno + 1,
TRACEBACK_CODE.co_firstlineno + 2,
+ TRACEBACK_CODE.co_firstlineno + 5,
TRACEBACK_CODE.co_firstlineno + 3,
TRACEBACK_CODE.co_firstlineno + 4,
- TRACEBACK_CODE.co_firstlineno + 5)
+ TRACEBACK_CODE.co_firstlineno + 5,
+ TRACEBACK_CODE.co_firstlineno + 3)
def _fstring(a, b, c, d):
return f'{a} {b:4} {c!r} {d!r:4}'
@@ -351,18 +366,14 @@ dis_tryfinally = """\
%3d 6 LOAD_FAST 1 (b)
8 CALL_FUNCTION 0
10 POP_TOP
-
-%3d 12 RETURN_VALUE
-
-%3d >> 14 LOAD_FAST 1 (b)
+ 12 RETURN_VALUE
+ >> 14 LOAD_FAST 1 (b)
16 CALL_FUNCTION 0
18 POP_TOP
- 20 RERAISE
+ 20 RERAISE 0
""" % (_tryfinally.__code__.co_firstlineno + 1,
_tryfinally.__code__.co_firstlineno + 2,
_tryfinally.__code__.co_firstlineno + 4,
- _tryfinally.__code__.co_firstlineno + 2,
- _tryfinally.__code__.co_firstlineno + 4,
)
dis_tryfinallyconst = """\
@@ -373,19 +384,15 @@ dis_tryfinallyconst = """\
%3d 4 LOAD_FAST 0 (b)
6 CALL_FUNCTION 0
8 POP_TOP
-
-%3d 10 LOAD_CONST 1 (1)
+ 10 LOAD_CONST 1 (1)
12 RETURN_VALUE
-
-%3d >> 14 LOAD_FAST 0 (b)
+ >> 14 LOAD_FAST 0 (b)
16 CALL_FUNCTION 0
18 POP_TOP
- 20 RERAISE
+ 20 RERAISE 0
""" % (_tryfinallyconst.__code__.co_firstlineno + 1,
_tryfinallyconst.__code__.co_firstlineno + 2,
_tryfinallyconst.__code__.co_firstlineno + 4,
- _tryfinallyconst.__code__.co_firstlineno + 2,
- _tryfinallyconst.__code__.co_firstlineno + 4,
)
def _g(x):
@@ -522,6 +529,9 @@ class DisTests(unittest.TestCase):
self.do_disassembly_test(bug1333982, dis_bug1333982)
+ def test_bug_42562(self):
+ self.do_disassembly_test(bug42562, dis_bug42562)
+
def test_big_linenos(self):
def func(count):
namespace = {}
@@ -674,8 +684,15 @@ class DisWithFileTests(DisTests):
return output.getvalue()
+if sys.flags.optimize:
+ code_info_consts = "0: None"
+else:
+ code_info_consts = (
+ """0: 'Formatted details of methods, functions, or code.'
+ 1: None"""
+)
-code_info_code_info = """\
+code_info_code_info = f"""\
Name: code_info
Filename: (.*)
Argument count: 1
@@ -685,13 +702,13 @@ Number of locals: 1
Stack size: 3
Flags: OPTIMIZED, NEWLOCALS, NOFREE
Constants:
- 0: %r
+ {code_info_consts}
Names:
0: _format_code_info
1: _get_code_object
Variable names:
- 0: x""" % (('Formatted details of methods, functions, or code.',)
- if sys.flags.optimize < 2 else (None,))
+ 0: x"""
+
@staticmethod
def tricky(a, b, /, x, y, z=True, *args, c, d, e=[], **kwds):
@@ -1006,17 +1023,17 @@ expected_opinfo_jumpy = [
Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=30, starts_line=7, is_jump_target=True),
Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=6, argrepr='6', offset=32, starts_line=None, is_jump_target=False),
Instruction(opname='COMPARE_OP', opcode=107, arg=4, argval='>', argrepr='>', offset=34, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=8, argval=8, argrepr='', offset=36, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=42, argval=42, argrepr='', offset=36, starts_line=None, is_jump_target=False),
Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=38, starts_line=8, is_jump_target=False),
Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=52, argval=52, argrepr='', offset=40, starts_line=None, is_jump_target=False),
- Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=8, argval=8, argrepr='', offset=42, starts_line=None, is_jump_target=False),
+ Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=8, argval=8, argrepr='', offset=42, starts_line=None, is_jump_target=True),
Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=44, starts_line=10, is_jump_target=True),
Instruction(opname='LOAD_CONST', opcode=100, arg=4, argval='I can haz else clause?', argrepr="'I can haz else clause?'", offset=46, starts_line=None, is_jump_target=False),
Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=48, starts_line=None, is_jump_target=False),
Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=50, starts_line=None, is_jump_target=False),
Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=52, starts_line=11, is_jump_target=True),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=94, argval=94, argrepr='', offset=54, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=56, starts_line=12, is_jump_target=False),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=96, argval=96, argrepr='', offset=54, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=56, starts_line=12, is_jump_target=True),
Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=58, starts_line=None, is_jump_target=False),
Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=60, starts_line=None, is_jump_target=False),
Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=62, starts_line=None, is_jump_target=False),
@@ -1032,34 +1049,34 @@ expected_opinfo_jumpy = [
Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=82, starts_line=16, is_jump_target=True),
Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=4, argrepr='4', offset=84, starts_line=None, is_jump_target=False),
Instruction(opname='COMPARE_OP', opcode=107, arg=0, argval='<', argrepr='<', offset=86, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=52, argval=52, argrepr='', offset=88, starts_line=None, is_jump_target=False),
- Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=102, argval=102, argrepr='', offset=90, starts_line=17, is_jump_target=False),
- Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=52, argval=52, argrepr='', offset=92, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=94, starts_line=19, is_jump_target=True),
- Instruction(opname='LOAD_CONST', opcode=100, arg=6, argval='Who let lolcatz into this test suite?', argrepr="'Who let lolcatz into this test suite?'", offset=96, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=98, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=100, starts_line=None, is_jump_target=False),
- Instruction(opname='SETUP_FINALLY', opcode=122, arg=96, argval=200, argrepr='to 200', offset=102, starts_line=20, is_jump_target=True),
- Instruction(opname='SETUP_FINALLY', opcode=122, arg=12, argval=118, argrepr='to 118', offset=104, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=1, argrepr='1', offset=106, starts_line=21, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=7, argval=0, argrepr='0', offset=108, starts_line=None, is_jump_target=False),
- Instruction(opname='BINARY_TRUE_DIVIDE', opcode=27, arg=None, argval=None, argrepr='', offset=110, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=112, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=114, starts_line=None, is_jump_target=False),
- Instruction(opname='JUMP_FORWARD', opcode=110, arg=26, argval=144, argrepr='to 144', offset=116, starts_line=None, is_jump_target=False),
- Instruction(opname='DUP_TOP', opcode=4, arg=None, argval=None, argrepr='', offset=118, starts_line=22, is_jump_target=True),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=2, argval='ZeroDivisionError', argrepr='ZeroDivisionError', offset=120, starts_line=None, is_jump_target=False),
- Instruction(opname='JUMP_IF_NOT_EXC_MATCH', opcode=121, arg=142, argval=142, argrepr='', offset=122, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=124, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=92, argval=92, argrepr='', offset=88, starts_line=None, is_jump_target=False),
+ Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=104, argval=104, argrepr='', offset=90, starts_line=17, is_jump_target=False),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=92, starts_line=11, is_jump_target=True),
+ Instruction(opname='POP_JUMP_IF_TRUE', opcode=115, arg=56, argval=56, argrepr='', offset=94, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=96, starts_line=19, is_jump_target=True),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=6, argval='Who let lolcatz into this test suite?', argrepr="'Who let lolcatz into this test suite?'", offset=98, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=100, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=102, starts_line=None, is_jump_target=False),
+ Instruction(opname='SETUP_FINALLY', opcode=122, arg=96, argval=202, argrepr='to 202', offset=104, starts_line=20, is_jump_target=True),
+ Instruction(opname='SETUP_FINALLY', opcode=122, arg=12, argval=120, argrepr='to 120', offset=106, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=1, argrepr='1', offset=108, starts_line=21, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=7, argval=0, argrepr='0', offset=110, starts_line=None, is_jump_target=False),
+ Instruction(opname='BINARY_TRUE_DIVIDE', opcode=27, arg=None, argval=None, argrepr='', offset=112, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=114, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=116, starts_line=None, is_jump_target=False),
+ Instruction(opname='JUMP_FORWARD', opcode=110, arg=24, argval=144, argrepr='to 144', offset=118, starts_line=None, is_jump_target=False),
+ Instruction(opname='DUP_TOP', opcode=4, arg=None, argval=None, argrepr='', offset=120, starts_line=22, is_jump_target=True),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=2, argval='ZeroDivisionError', argrepr='ZeroDivisionError', offset=122, starts_line=None, is_jump_target=False),
+ Instruction(opname='JUMP_IF_NOT_EXC_MATCH', opcode=121, arg=212, argval=212, argrepr='', offset=124, starts_line=None, is_jump_target=False),
Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=126, starts_line=None, is_jump_target=False),
Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=128, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=130, starts_line=23, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=8, argval='Here we go, here we go, here we go...', argrepr="'Here we go, here we go, here we go...'", offset=132, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=134, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=136, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=138, starts_line=None, is_jump_target=False),
- Instruction(opname='JUMP_FORWARD', opcode=110, arg=46, argval=188, argrepr='to 188', offset=140, starts_line=None, is_jump_target=False),
- Instruction(opname='RERAISE', opcode=48, arg=None, argval=None, argrepr='', offset=142, starts_line=None, is_jump_target=True),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=130, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=132, starts_line=23, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=8, argval='Here we go, here we go, here we go...', argrepr="'Here we go, here we go, here we go...'", offset=134, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=136, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=138, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=140, starts_line=None, is_jump_target=False),
+ Instruction(opname='JUMP_FORWARD', opcode=110, arg=44, argval=188, argrepr='to 188', offset=142, starts_line=None, is_jump_target=False),
Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=144, starts_line=25, is_jump_target=True),
Instruction(opname='SETUP_WITH', opcode=143, arg=24, argval=172, argrepr='to 172', offset=146, starts_line=None, is_jump_target=False),
Instruction(opname='STORE_FAST', opcode=125, arg=1, argval='dodgy', argrepr='dodgy', offset=148, starts_line=None, is_jump_target=False),
@@ -1076,7 +1093,7 @@ expected_opinfo_jumpy = [
Instruction(opname='JUMP_FORWARD', opcode=110, arg=16, argval=188, argrepr='to 188', offset=170, starts_line=None, is_jump_target=False),
Instruction(opname='WITH_EXCEPT_START', opcode=49, arg=None, argval=None, argrepr='', offset=172, starts_line=None, is_jump_target=True),
Instruction(opname='POP_JUMP_IF_TRUE', opcode=115, arg=178, argval=178, argrepr='', offset=174, starts_line=None, is_jump_target=False),
- Instruction(opname='RERAISE', opcode=48, arg=None, argval=None, argrepr='', offset=176, starts_line=None, is_jump_target=False),
+ Instruction(opname='RERAISE', opcode=119, arg=1, argval=1, argrepr='', offset=176, starts_line=None, is_jump_target=False),
Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=178, starts_line=None, is_jump_target=True),
Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=180, starts_line=None, is_jump_target=False),
Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=182, starts_line=None, is_jump_target=False),
@@ -1087,14 +1104,14 @@ expected_opinfo_jumpy = [
Instruction(opname='LOAD_CONST', opcode=100, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=192, starts_line=None, is_jump_target=False),
Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=194, starts_line=None, is_jump_target=False),
Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=196, starts_line=None, is_jump_target=False),
- Instruction(opname='JUMP_FORWARD', opcode=110, arg=10, argval=210, argrepr='to 210', offset=198, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=200, starts_line=None, is_jump_target=True),
- Instruction(opname='LOAD_CONST', opcode=100, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=202, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=204, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=206, starts_line=None, is_jump_target=False),
- Instruction(opname='RERAISE', opcode=48, arg=None, argval=None, argrepr='', offset=208, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=210, starts_line=None, is_jump_target=True),
- Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=212, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=198, starts_line=None, is_jump_target=False),
+ Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=200, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=202, starts_line=None, is_jump_target=True),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=204, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=206, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=208, starts_line=None, is_jump_target=False),
+ Instruction(opname='RERAISE', opcode=119, arg=0, argval=0, argrepr='', offset=210, starts_line=None, is_jump_target=False),
+ Instruction(opname='RERAISE', opcode=119, arg=0, argval=0, argrepr='', offset=212, starts_line=22, is_jump_target=True),
]
# One last piece of inspect fodder to check the default line number handling
@@ -1196,5 +1213,24 @@ class BytecodeTests(unittest.TestCase):
b = dis.Bytecode.from_traceback(tb)
self.assertEqual(b.dis(), dis_traceback)
+
+class TestBytecodeTestCase(BytecodeTestCase):
+ def test_assert_not_in_with_op_not_in_bytecode(self):
+ code = compile("a = 1", "<string>", "exec")
+ self.assertInBytecode(code, "LOAD_CONST", 1)
+ self.assertNotInBytecode(code, "LOAD_NAME")
+ self.assertNotInBytecode(code, "LOAD_NAME", "a")
+
+ def test_assert_not_in_with_arg_not_in_bytecode(self):
+ code = compile("a = 1", "<string>", "exec")
+ self.assertInBytecode(code, "LOAD_CONST")
+ self.assertInBytecode(code, "LOAD_CONST", 1)
+ self.assertNotInBytecode(code, "LOAD_CONST", 2)
+
+ def test_assert_not_in_with_arg_in_bytecode(self):
+ code = compile("a = 1", "<string>", "exec")
+ with self.assertRaises(AssertionError):
+ self.assertNotInBytecode(code, "LOAD_CONST", 1)
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index bff20f9cac..6a5013f5b8 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -3039,10 +3039,11 @@ Invalid file name:
... '-m', 'doctest', 'nosuchfile')
>>> rc, out
(1, b'')
+ >>> # The exact error message changes depending on the platform.
>>> print(normalize(err)) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
- FileNotFoundError: [Errno ...] No such file or directory: 'nosuchfile'
+ FileNotFoundError: [Errno ...] ...nosuchfile...
Invalid doctest option:
diff --git a/Lib/test/test_eintr.py b/Lib/test/test_eintr.py
index a5f8f6465e..528147802b 100644
--- a/Lib/test/test_eintr.py
+++ b/Lib/test/test_eintr.py
@@ -1,9 +1,6 @@
import os
import signal
-import subprocess
-import sys
import unittest
-
from test import support
from test.support import script_helper
@@ -15,22 +12,8 @@ class EINTRTests(unittest.TestCase):
def test_all(self):
# Run the tester in a sub-process, to make sure there is only one
# thread (for reliable signal delivery).
- tester = support.findfile("eintr_tester.py", subdir="eintrdata")
- # use -u to try to get the full output if the test hangs or crash
- args = ["-u", tester, "-v"]
- if support.verbose:
- print()
- print("--- run eintr_tester.py ---", flush=True)
- # In verbose mode, the child process inherit stdout and stdout,
- # to see output in realtime and reduce the risk of losing output.
- args = [sys.executable, "-E", "-X", "faulthandler", *args]
- proc = subprocess.run(args)
- print(f"--- eintr_tester.py completed: "
- f"exit code {proc.returncode} ---", flush=True)
- if proc.returncode:
- self.fail("eintr_tester.py failed")
- else:
- script_helper.assert_python_ok("-u", tester, "-v")
+ script = support.findfile("_test_eintr.py")
+ script_helper.run_test_script(script)
if __name__ == "__main__":
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index 31dc39fd9e..a7d912178a 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -30,6 +30,8 @@ API_PYTHON = 2
# _PyCoreConfig_InitIsolatedConfig()
API_ISOLATED = 3
+MAX_HASH_SEED = 4294967295
+
def debug_build(program):
program = os.path.basename(program)
@@ -382,6 +384,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'exec_prefix': GET_DEFAULT_CONFIG,
'base_exec_prefix': GET_DEFAULT_CONFIG,
'module_search_paths': GET_DEFAULT_CONFIG,
+ 'module_search_paths_set': 1,
'platlibdir': sys.platlibdir,
'site_import': 1,
@@ -419,7 +422,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
CONFIG_PYTHON = dict(CONFIG_COMPAT,
_config_init=API_PYTHON,
configure_c_stdio=1,
- parse_argv=1,
+ parse_argv=2,
)
CONFIG_ISOLATED = dict(CONFIG_COMPAT,
_config_init=API_ISOLATED,
@@ -797,7 +800,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'-X', 'cmdline_xoption',
'-c', 'pass',
'arg2'],
- 'parse_argv': 1,
+ 'parse_argv': 2,
'xoptions': [
'config_xoption1=3',
'config_xoption2=',
@@ -1042,7 +1045,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'orig_argv': ['python3', '-c', code, 'arg2'],
'program_name': './python3',
'run_command': code + '\n',
- 'parse_argv': 1,
+ 'parse_argv': 2,
}
self.check_all_configs("test_init_run_main", config, api=API_PYTHON)
@@ -1056,7 +1059,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'arg2'],
'program_name': './python3',
'run_command': code + '\n',
- 'parse_argv': 1,
+ 'parse_argv': 2,
'_init_main': 0,
}
self.check_all_configs("test_init_main", config,
@@ -1065,7 +1068,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
def test_init_parse_argv(self):
config = {
- 'parse_argv': 1,
+ 'parse_argv': 2,
'argv': ['-c', 'arg1', '-v', 'arg3'],
'orig_argv': ['./argv0', '-E', '-c', 'pass', 'arg1', '-v', 'arg3'],
'program_name': './argv0',
@@ -1394,11 +1397,31 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
self.check_all_configs("test_init_warnoptions", config, preconfig,
api=API_PYTHON)
+ def test_init_set_config(self):
+ config = {
+ '_init_main': 0,
+ 'bytes_warning': 2,
+ 'warnoptions': ['error::BytesWarning'],
+ }
+ self.check_all_configs("test_init_set_config", config,
+ api=API_ISOLATED)
+
def test_get_argc_argv(self):
self.run_embedded_interpreter("test_get_argc_argv")
# ignore output
+class SetConfigTests(unittest.TestCase):
+ def test_set_config(self):
+ # bpo-42260: Test _PyInterpreterState_SetConfig()
+ cmd = [sys.executable, '-I', '-m', 'test._test_embed_set_config']
+ proc = subprocess.run(cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ self.assertEqual(proc.returncode, 0,
+ (proc.returncode, proc.stdout, proc.stderr))
+
+
class AuditingTests(EmbeddingTestsMixin, unittest.TestCase):
def test_open_code_hook(self):
self.run_embedded_interpreter("test_open_code_hook")
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index 3431040f98..19b4fa5464 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -429,7 +429,7 @@ class TestEnum(unittest.TestCase):
def test_reserved__sunder_(self):
with self.assertRaisesRegex(
ValueError,
- '_sunder_ names, such as "_bad_", are reserved',
+ "_sunder_ names, such as '_bad_', are reserved",
):
class Bad(Enum):
_bad_ = 1
@@ -585,12 +585,15 @@ class TestEnum(unittest.TestCase):
class Test1Enum(MyMethodEnum, int, MyStrEnum):
One = 1
Two = 2
+ self.assertTrue(Test1Enum._member_type_ is int)
self.assertEqual(str(Test1Enum.One), 'MyStr')
+ self.assertEqual(format(Test1Enum.One, ''), 'MyStr')
#
class Test2Enum(MyStrEnum, MyMethodEnum):
One = 1
Two = 2
self.assertEqual(str(Test2Enum.One), 'MyStr')
+ self.assertEqual(format(Test1Enum.One, ''), 'MyStr')
def test_inherited_data_type(self):
class HexInt(int):
@@ -1146,6 +1149,7 @@ class TestEnum(unittest.TestCase):
class auto_enum(type(Enum)):
def __new__(metacls, cls, bases, classdict):
temp = type(classdict)()
+ temp._cls_name = cls
names = set(classdict._member_names)
i = 0
for k in classdict._member_names:
@@ -2021,6 +2025,32 @@ class TestEnum(unittest.TestCase):
REVERT_ALL = "REVERT_ALL"
RETRY = "RETRY"
+ def test_multiple_mixin_inherited(self):
+ class MyInt(int):
+ def __new__(cls, value):
+ return super().__new__(cls, value)
+
+ class HexMixin:
+ def __repr__(self):
+ return hex(self)
+
+ class MyIntEnum(HexMixin, MyInt, enum.Enum):
+ pass
+
+ class Foo(MyIntEnum):
+ TEST = 1
+ self.assertTrue(isinstance(Foo.TEST, MyInt))
+ self.assertEqual(repr(Foo.TEST), "0x1")
+
+ class Fee(MyIntEnum):
+ TEST = 1
+ def __new__(cls, value):
+ value += 1
+ member = int.__new__(cls, value)
+ member._value_ = value
+ return member
+ self.assertEqual(Fee.TEST, 2)
+
def test_empty_globals(self):
# bpo-35717: sys._getframe(2).f_globals['__name__'] fails with KeyError
# when using compile and exec because f_globals is empty
@@ -2088,6 +2118,111 @@ class TestEnum(unittest.TestCase):
class ThirdFailedStrEnum(StrEnum):
one = '1'
two = b'2', 'ascii', 9
+
+ def test_init_subclass_calling(self):
+ class MyEnum(Enum):
+ def __init_subclass__(cls, **kwds):
+ super(MyEnum, cls).__init_subclass__(**kwds)
+ self.assertFalse(cls.__dict__.get('_test', False))
+ cls._test1 = 'MyEnum'
+ #
+ class TheirEnum(MyEnum):
+ def __init_subclass__(cls, **kwds):
+ super().__init_subclass__(**kwds)
+ cls._test2 = 'TheirEnum'
+ class WhoseEnum(TheirEnum):
+ def __init_subclass__(cls, **kwds):
+ pass
+ class NoEnum(WhoseEnum):
+ ONE = 1
+ self.assertEqual(TheirEnum.__dict__['_test1'], 'MyEnum')
+ self.assertEqual(WhoseEnum.__dict__['_test1'], 'MyEnum')
+ self.assertEqual(WhoseEnum.__dict__['_test2'], 'TheirEnum')
+ self.assertFalse(NoEnum.__dict__.get('_test1', False))
+ self.assertFalse(NoEnum.__dict__.get('_test2', False))
+ #
+ class OurEnum(MyEnum):
+ def __init_subclass__(cls, **kwds):
+ cls._test2 = 'OurEnum'
+ class WhereEnum(OurEnum):
+ def __init_subclass__(cls, **kwds):
+ pass
+ class NeverEnum(WhereEnum):
+ ONE = 'one'
+ self.assertEqual(OurEnum.__dict__['_test1'], 'MyEnum')
+ self.assertFalse(WhereEnum.__dict__.get('_test1', False))
+ self.assertEqual(WhereEnum.__dict__['_test2'], 'OurEnum')
+ self.assertFalse(NeverEnum.__dict__.get('_test1', False))
+ self.assertFalse(NeverEnum.__dict__.get('_test2', False))
+
+ def test_init_subclass_parameter(self):
+ class multiEnum(Enum):
+ def __init_subclass__(cls, multi):
+ for member in cls:
+ member._as_parameter_ = multi * member.value
+ class E(multiEnum, multi=3):
+ A = 1
+ B = 2
+ self.assertEqual(E.A._as_parameter_, 3)
+ self.assertEqual(E.B._as_parameter_, 6)
+
+ @unittest.skipUnless(
+ sys.version_info[:2] == (3, 9),
+ 'private variables are now normal attributes',
+ )
+ def test_warning_for_private_variables(self):
+ with self.assertWarns(DeprecationWarning):
+ class Private(Enum):
+ __corporal = 'Radar'
+ self.assertEqual(Private._Private__corporal.value, 'Radar')
+ try:
+ with self.assertWarns(DeprecationWarning):
+ class Private(Enum):
+ __major_ = 'Hoolihan'
+ except ValueError:
+ pass
+
+ def test_private_variable_is_normal_attribute(self):
+ class Private(Enum):
+ __corporal = 'Radar'
+ __major_ = 'Hoolihan'
+ self.assertEqual(Private._Private__corporal, 'Radar')
+ self.assertEqual(Private._Private__major_, 'Hoolihan')
+
+ def test_strenum_auto(self):
+ class Strings(StrEnum):
+ ONE = auto()
+ TWO = auto()
+ self.assertEqual([Strings.ONE, Strings.TWO], ['one', 'two'])
+
+
+ def test_dynamic_members_with_static_methods(self):
+ #
+ foo_defines = {'FOO_CAT': 'aloof', 'BAR_DOG': 'friendly', 'FOO_HORSE': 'big'}
+ class Foo(Enum):
+ vars().update({
+ k: v
+ for k, v in foo_defines.items()
+ if k.startswith('FOO_')
+ })
+ def upper(self):
+ return self.value.upper()
+ self.assertEqual(list(Foo), [Foo.FOO_CAT, Foo.FOO_HORSE])
+ self.assertEqual(Foo.FOO_CAT.value, 'aloof')
+ self.assertEqual(Foo.FOO_HORSE.upper(), 'BIG')
+ #
+ with self.assertRaisesRegex(TypeError, "'FOO_CAT' already defined as: 'aloof'"):
+ class FooBar(Enum):
+ vars().update({
+ k: v
+ for k, v in foo_defines.items()
+ if k.startswith('FOO_')
+ },
+ **{'FOO_CAT': 'small'},
+ )
+ def upper(self):
+ return self.value.upper()
+
class TestOrder(unittest.TestCase):
@@ -2225,6 +2360,11 @@ class TestFlag(unittest.TestCase):
self.assertEqual(repr(~(Open.RO | Open.CE)), '<Open.AC: 3>')
self.assertEqual(repr(~(Open.WO | Open.CE)), '<Open.RW: 2>')
+ def test_format(self):
+ Perm = self.Perm
+ self.assertEqual(format(Perm.R, ''), 'Perm.R')
+ self.assertEqual(format(Perm.R | Perm.X, ''), 'Perm.R|X')
+
def test_or(self):
Perm = self.Perm
for i in Perm:
@@ -2539,6 +2679,42 @@ class TestFlag(unittest.TestCase):
'at least one thread failed while creating composite members')
self.assertEqual(256, len(seen), 'too many composite members created')
+ def test_init_subclass(self):
+ class MyEnum(Flag):
+ def __init_subclass__(cls, **kwds):
+ super().__init_subclass__(**kwds)
+ self.assertFalse(cls.__dict__.get('_test', False))
+ cls._test1 = 'MyEnum'
+ #
+ class TheirEnum(MyEnum):
+ def __init_subclass__(cls, **kwds):
+ super(TheirEnum, cls).__init_subclass__(**kwds)
+ cls._test2 = 'TheirEnum'
+ class WhoseEnum(TheirEnum):
+ def __init_subclass__(cls, **kwds):
+ pass
+ class NoEnum(WhoseEnum):
+ ONE = 1
+ self.assertEqual(TheirEnum.__dict__['_test1'], 'MyEnum')
+ self.assertEqual(WhoseEnum.__dict__['_test1'], 'MyEnum')
+ self.assertEqual(WhoseEnum.__dict__['_test2'], 'TheirEnum')
+ self.assertFalse(NoEnum.__dict__.get('_test1', False))
+ self.assertFalse(NoEnum.__dict__.get('_test2', False))
+ #
+ class OurEnum(MyEnum):
+ def __init_subclass__(cls, **kwds):
+ cls._test2 = 'OurEnum'
+ class WhereEnum(OurEnum):
+ def __init_subclass__(cls, **kwds):
+ pass
+ class NeverEnum(WhereEnum):
+ ONE = 1
+ self.assertEqual(OurEnum.__dict__['_test1'], 'MyEnum')
+ self.assertFalse(WhereEnum.__dict__.get('_test1', False))
+ self.assertEqual(WhereEnum.__dict__['_test2'], 'OurEnum')
+ self.assertFalse(NeverEnum.__dict__.get('_test1', False))
+ self.assertFalse(NeverEnum.__dict__.get('_test2', False))
+
class TestIntFlag(unittest.TestCase):
"""Tests of the IntFlags."""
@@ -2564,6 +2740,7 @@ class TestIntFlag(unittest.TestCase):
def test_type(self):
Perm = self.Perm
+ self.assertTrue(Perm._member_type_ is int)
Open = self.Open
for f in Perm:
self.assertTrue(isinstance(f, Perm))
@@ -2643,6 +2820,11 @@ class TestIntFlag(unittest.TestCase):
self.assertEqual(repr(~(Open.WO | Open.CE)), '<Open.RW: -524290>')
self.assertEqual(repr(Open(~4)), '<Open.CE|AC|RW|WO: -5>')
+ def test_format(self):
+ Perm = self.Perm
+ self.assertEqual(format(Perm.R, ''), '4')
+ self.assertEqual(format(Perm.R | Perm.X, ''), '5')
+
def test_or(self):
Perm = self.Perm
for i in Perm:
diff --git a/Lib/test/test_enumerate.py b/Lib/test/test_enumerate.py
index 5785cb4649..906bfc21a2 100644
--- a/Lib/test/test_enumerate.py
+++ b/Lib/test/test_enumerate.py
@@ -2,6 +2,7 @@ import unittest
import operator
import sys
import pickle
+import gc
from test import support
@@ -134,6 +135,18 @@ class EnumerateTestCase(unittest.TestCase, PickleTest):
self.assertEqual(len(set(map(id, list(enumerate(self.seq))))), len(self.seq))
self.assertEqual(len(set(map(id, enumerate(self.seq)))), min(1,len(self.seq)))
+ @support.cpython_only
+ def test_enumerate_result_gc(self):
+ # bpo-42536: enumerate's tuple-reuse speed trick breaks the GC's
+ # assumptions about what can be untracked. Make sure we re-track result
+ # tuples whenever we reuse them.
+ it = self.enum([[]])
+ gc.collect()
+ # That GC collection probably untracked the recycled internal result
+ # tuple, which is initialized to (None, None). Make sure it's re-tracked
+ # when it's mutated and returned from __next__:
+ self.assertTrue(gc.is_tracked(next(it)))
+
class MyEnum(enumerate):
pass
diff --git a/Lib/test/test_epoll.py b/Lib/test/test_epoll.py
index 10f148fe5c..b623852f9e 100644
--- a/Lib/test/test_epoll.py
+++ b/Lib/test/test_epoll.py
@@ -160,44 +160,42 @@ class TestEPoll(unittest.TestCase):
self.fail("epoll on closed fd didn't raise EBADF")
def test_control_and_wait(self):
+ # create the epoll object
client, server = self._connected_pair()
-
ep = select.epoll(16)
ep.register(server.fileno(),
select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
ep.register(client.fileno(),
select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
+ # EPOLLOUT
now = time.monotonic()
events = ep.poll(1, 4)
then = time.monotonic()
self.assertFalse(then - now > 0.1, then - now)
- events.sort()
expected = [(client.fileno(), select.EPOLLOUT),
(server.fileno(), select.EPOLLOUT)]
- expected.sort()
-
- self.assertEqual(events, expected)
+ self.assertEqual(sorted(events), sorted(expected))
- events = ep.poll(timeout=2.1, maxevents=4)
+ # no event
+ events = ep.poll(timeout=0.1, maxevents=4)
self.assertFalse(events)
- client.send(b"Hello!")
- server.send(b"world!!!")
+ # send: EPOLLIN and EPOLLOUT
+ client.sendall(b"Hello!")
+ server.sendall(b"world!!!")
now = time.monotonic()
- events = ep.poll(1, 4)
+ events = ep.poll(1.0, 4)
then = time.monotonic()
self.assertFalse(then - now > 0.01)
- events.sort()
expected = [(client.fileno(), select.EPOLLIN | select.EPOLLOUT),
(server.fileno(), select.EPOLLIN | select.EPOLLOUT)]
- expected.sort()
-
- self.assertEqual(events, expected)
+ self.assertEqual(sorted(events), sorted(expected))
+ # unregister, modify
ep.unregister(client.fileno())
ep.modify(server.fileno(), select.EPOLLOUT)
now = time.monotonic()
diff --git a/Lib/test/test_exception_hierarchy.py b/Lib/test/test_exception_hierarchy.py
index 43b4af8403..89fe9ddcef 100644
--- a/Lib/test/test_exception_hierarchy.py
+++ b/Lib/test/test_exception_hierarchy.py
@@ -40,10 +40,10 @@ class HierarchyTest(unittest.TestCase):
self.assertIs(EnvironmentError, OSError)
def test_socket_errors(self):
- self.assertIs(socket.error, IOError)
+ self.assertIs(socket.error, OSError)
self.assertIs(socket.gaierror.__base__, OSError)
self.assertIs(socket.herror.__base__, OSError)
- self.assertIs(socket.timeout.__base__, OSError)
+ self.assertIs(socket.timeout, TimeoutError)
def test_select_error(self):
self.assertIs(select.error, OSError)
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 4dbf5fe5d5..864422390a 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -252,7 +252,7 @@ class ExceptionTests(unittest.TestCase):
check('from __future__ import doesnt_exist', 1, 1)
check('from __future__ import braces', 1, 1)
check('x=1\nfrom __future__ import division', 2, 1)
- check('foo(1=2)', 1, 5)
+ check('foo(1=2)', 1, 6)
check('def f():\n x, y: int', 2, 3)
check('[*x for x in xs]', 1, 2)
check('foo(x for x in range(10), 100)', 1, 5)
@@ -1046,7 +1046,7 @@ class ExceptionTests(unittest.TestCase):
# tstate->recursion_depth is equal to (recursion_limit - 1)
# and is equal to recursion_limit when _gen_throw() calls
# PyErr_NormalizeException().
- recurse(setrecursionlimit(depth + 2) - depth - 1)
+ recurse(setrecursionlimit(depth + 2) - depth)
finally:
sys.setrecursionlimit(recursionlimit)
print('Done.')
@@ -1076,6 +1076,54 @@ class ExceptionTests(unittest.TestCase):
b'while normalizing an exception', err)
self.assertIn(b'Done.', out)
+
+ def test_recursion_in_except_handler(self):
+
+ def set_relative_recursion_limit(n):
+ depth = 1
+ while True:
+ try:
+ sys.setrecursionlimit(depth)
+ except RecursionError:
+ depth += 1
+ else:
+ break
+ sys.setrecursionlimit(depth+n)
+
+ def recurse_in_except():
+ try:
+ 1/0
+ except:
+ recurse_in_except()
+
+ def recurse_after_except():
+ try:
+ 1/0
+ except:
+ pass
+ recurse_after_except()
+
+ def recurse_in_body_and_except():
+ try:
+ recurse_in_body_and_except()
+ except:
+ recurse_in_body_and_except()
+
+ recursionlimit = sys.getrecursionlimit()
+ try:
+ set_relative_recursion_limit(10)
+ for func in (recurse_in_except, recurse_after_except, recurse_in_body_and_except):
+ with self.subTest(func=func):
+ try:
+ func()
+ except RecursionError:
+ pass
+ else:
+ self.fail("Should have raised a RecursionError")
+ finally:
+ sys.setrecursionlimit(recursionlimit)
+
+
@cpython_only
def test_recursion_normalizing_with_no_memory(self):
# Issue #30697. Test that in the abort that occurs when there is no
@@ -1112,7 +1160,7 @@ class ExceptionTests(unittest.TestCase):
except MemoryError as e:
tb = e.__traceback__
else:
- self.fail("Should have raises a MemoryError")
+ self.fail("Should have raised a MemoryError")
return traceback.format_tb(tb)
tb1 = raiseMemError()
@@ -1440,5 +1488,88 @@ class ImportErrorTests(unittest.TestCase):
self.assertEqual(exc.path, orig.path)
+class PEP626Tests(unittest.TestCase):
+
+ def lineno_after_raise(self, f, line):
+ try:
+ f()
+ except Exception as ex:
+ t = ex.__traceback__
+ while t.tb_next:
+ t = t.tb_next
+ frame = t.tb_frame
+ self.assertEqual(frame.f_lineno-frame.f_code.co_firstlineno, line)
+
+ def test_lineno_after_raise_simple(self):
+ def simple():
+ 1/0
+ pass
+ self.lineno_after_raise(simple, 1)
+
+ def test_lineno_after_raise_in_except(self):
+ def in_except():
+ try:
+ 1/0
+ except:
+ 1/0
+ pass
+ self.lineno_after_raise(in_except, 4)
+
+ def test_lineno_after_other_except(self):
+ def other_except():
+ try:
+ 1/0
+ except TypeError as ex:
+ pass
+ self.lineno_after_raise(other_except, 3)
+
+ def test_lineno_in_named_except(self):
+ def in_named_except():
+ try:
+ 1/0
+ except Exception as ex:
+ 1/0
+ pass
+ self.lineno_after_raise(in_named_except, 4)
+
+ def test_lineno_in_try(self):
+ def in_try():
+ try:
+ 1/0
+ finally:
+ pass
+ self.lineno_after_raise(in_try, 4)
+
+ def test_lineno_in_finally_normal(self):
+ def in_finally_normal():
+ try:
+ pass
+ finally:
+ 1/0
+ pass
+ self.lineno_after_raise(in_finally_normal, 4)
+
+ def test_lineno_in_finally_except(self):
+ def in_finally_except():
+ try:
+ 1/0
+ finally:
+ 1/0
+ pass
+ self.lineno_after_raise(in_finally_except, 4)
+
+ def test_lineno_after_with(self):
+ class Noop:
+ def __enter__(self):
+ return self
+ def __exit__(self, *args):
+ pass
+ def after_with():
+ with Noop():
+ 1/0
+ pass
+ self.lineno_after_raise(after_with, 2)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/test/test_filecmp.py b/Lib/test/test_filecmp.py
index ca9b4f354a..fa4f67b6eb 100644
--- a/Lib/test/test_filecmp.py
+++ b/Lib/test/test_filecmp.py
@@ -66,6 +66,8 @@ class DirCompareTestCase(unittest.TestCase):
for dir in (self.dir, self.dir_same, self.dir_diff, self.dir_ignored):
shutil.rmtree(dir, True)
os.mkdir(dir)
+ subdir_path = os.path.join(dir, 'subdir')
+ os.mkdir(subdir_path)
if self.caseinsensitive and dir is self.dir_same:
fn = 'FiLe' # Verify case-insensitive comparison
else:
@@ -110,6 +112,11 @@ class DirCompareTestCase(unittest.TestCase):
"Comparing mismatched directories fails")
+ def _assert_lists(self, actual, expected):
+ """Assert that two lists are equal, up to ordering."""
+ self.assertEqual(sorted(actual), sorted(expected))
+
+
def test_dircmp(self):
# Check attributes for comparison of two identical directories
left_dir, right_dir = self.dir, self.dir_same
@@ -117,10 +124,13 @@ class DirCompareTestCase(unittest.TestCase):
self.assertEqual(d.left, left_dir)
self.assertEqual(d.right, right_dir)
if self.caseinsensitive:
- self.assertEqual([d.left_list, d.right_list],[['file'], ['FiLe']])
+ self._assert_lists(d.left_list, ['file', 'subdir'])
+ self._assert_lists(d.right_list, ['FiLe', 'subdir'])
else:
- self.assertEqual([d.left_list, d.right_list],[['file'], ['file']])
- self.assertEqual(d.common, ['file'])
+ self._assert_lists(d.left_list, ['file', 'subdir'])
+ self._assert_lists(d.right_list, ['file', 'subdir'])
+ self._assert_lists(d.common, ['file', 'subdir'])
+ self._assert_lists(d.common_dirs, ['subdir'])
self.assertEqual(d.left_only, [])
self.assertEqual(d.right_only, [])
self.assertEqual(d.same_files, ['file'])
@@ -128,6 +138,7 @@ class DirCompareTestCase(unittest.TestCase):
expected_report = [
"diff {} {}".format(self.dir, self.dir_same),
"Identical files : ['file']",
+ "Common subdirectories : ['subdir']",
]
self._assert_report(d.report, expected_report)
@@ -136,9 +147,10 @@ class DirCompareTestCase(unittest.TestCase):
d = filecmp.dircmp(left_dir, right_dir)
self.assertEqual(d.left, left_dir)
self.assertEqual(d.right, right_dir)
- self.assertEqual(d.left_list, ['file'])
- self.assertEqual(d.right_list, ['file', 'file2'])
- self.assertEqual(d.common, ['file'])
+ self._assert_lists(d.left_list, ['file', 'subdir'])
+ self._assert_lists(d.right_list, ['file', 'file2', 'subdir'])
+ self._assert_lists(d.common, ['file', 'subdir'])
+ self._assert_lists(d.common_dirs, ['subdir'])
self.assertEqual(d.left_only, [])
self.assertEqual(d.right_only, ['file2'])
self.assertEqual(d.same_files, ['file'])
@@ -147,6 +159,7 @@ class DirCompareTestCase(unittest.TestCase):
"diff {} {}".format(self.dir, self.dir_diff),
"Only in {} : ['file2']".format(self.dir_diff),
"Identical files : ['file']",
+ "Common subdirectories : ['subdir']",
]
self._assert_report(d.report, expected_report)
@@ -159,9 +172,9 @@ class DirCompareTestCase(unittest.TestCase):
d = filecmp.dircmp(left_dir, right_dir)
self.assertEqual(d.left, left_dir)
self.assertEqual(d.right, right_dir)
- self.assertEqual(d.left_list, ['file', 'file2'])
- self.assertEqual(d.right_list, ['file'])
- self.assertEqual(d.common, ['file'])
+ self._assert_lists(d.left_list, ['file', 'file2', 'subdir'])
+ self._assert_lists(d.right_list, ['file', 'subdir'])
+ self._assert_lists(d.common, ['file', 'subdir'])
self.assertEqual(d.left_only, ['file2'])
self.assertEqual(d.right_only, [])
self.assertEqual(d.same_files, ['file'])
@@ -170,6 +183,7 @@ class DirCompareTestCase(unittest.TestCase):
"diff {} {}".format(self.dir, self.dir_diff),
"Only in {} : ['file2']".format(self.dir),
"Identical files : ['file']",
+ "Common subdirectories : ['subdir']",
]
self._assert_report(d.report, expected_report)
@@ -183,24 +197,45 @@ class DirCompareTestCase(unittest.TestCase):
"diff {} {}".format(self.dir, self.dir_diff),
"Identical files : ['file']",
"Differing files : ['file2']",
+ "Common subdirectories : ['subdir']",
]
self._assert_report(d.report, expected_report)
+ def test_dircmp_subdirs_type(self):
+ """Check that dircmp.subdirs respects subclassing."""
+ class MyDirCmp(filecmp.dircmp):
+ pass
+ d = MyDirCmp(self.dir, self.dir_diff)
+ sub_dirs = d.subdirs
+ self.assertEqual(list(sub_dirs.keys()), ['subdir'])
+ sub_dcmp = sub_dirs['subdir']
+ self.assertEqual(type(sub_dcmp), MyDirCmp)
+
def test_report_partial_closure(self):
left_dir, right_dir = self.dir, self.dir_same
d = filecmp.dircmp(left_dir, right_dir)
+ left_subdir = os.path.join(left_dir, 'subdir')
+ right_subdir = os.path.join(right_dir, 'subdir')
expected_report = [
"diff {} {}".format(self.dir, self.dir_same),
"Identical files : ['file']",
+ "Common subdirectories : ['subdir']",
+ '',
+ "diff {} {}".format(left_subdir, right_subdir),
]
self._assert_report(d.report_partial_closure, expected_report)
def test_report_full_closure(self):
left_dir, right_dir = self.dir, self.dir_same
d = filecmp.dircmp(left_dir, right_dir)
+ left_subdir = os.path.join(left_dir, 'subdir')
+ right_subdir = os.path.join(right_dir, 'subdir')
expected_report = [
"diff {} {}".format(self.dir, self.dir_same),
"Identical files : ['file']",
+ "Common subdirectories : ['subdir']",
+ '',
+ "diff {} {}".format(left_subdir, right_subdir),
]
self._assert_report(d.report_full_closure, expected_report)
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index 9653e46ecc..6679bd3d88 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -275,9 +275,9 @@ class FormatTest(unittest.TestCase):
test_exc_common('% %s', 1, ValueError,
"unsupported format character '%' (0x25) at index 2")
test_exc_common('%d', '1', TypeError,
- "%d format: a number is required, not str")
+ "%d format: a real number is required, not str")
test_exc_common('%d', b'1', TypeError,
- "%d format: a number is required, not bytes")
+ "%d format: a real number is required, not bytes")
test_exc_common('%x', '1', TypeError,
"%x format: an integer is required, not str")
test_exc_common('%x', 3.14, TypeError,
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py
index 39658f22aa..2424911c7a 100644
--- a/Lib/test/test_ftplib.py
+++ b/Lib/test/test_ftplib.py
@@ -1036,7 +1036,7 @@ class TestTimeouts(TestCase):
self.evt.set()
try:
conn, addr = self.sock.accept()
- except socket.timeout:
+ except TimeoutError:
pass
else:
conn.sendall(b"1 Hola mundo\n")
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index 44cb9a0f07..22c75bae98 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -51,11 +51,6 @@ if gdb_major_version < 7:
"embedding. Saw %s.%s:\n%s"
% (gdb_major_version, gdb_minor_version,
gdb_version))
-if (gdb_major_version, gdb_minor_version) >= (9, 2):
- # gdb 9.2 on Fedora Rawhide is not reliable, see:
- # * https://bugs.python.org/issue41473
- # * https://bugzilla.redhat.com/show_bug.cgi?id=1866884
- raise unittest.SkipTest("https://bugzilla.redhat.com/show_bug.cgi?id=1866884")
if not sysconfig.is_python_build():
raise unittest.SkipTest("test_gdb only works on source builds at the moment.")
diff --git a/Lib/test/test_genericalias.py b/Lib/test/test_genericalias.py
index 2979cfb550..fd024dcec8 100644
--- a/Lib/test/test_genericalias.py
+++ b/Lib/test/test_genericalias.py
@@ -47,46 +47,45 @@ V = TypeVar('V')
class BaseTest(unittest.TestCase):
"""Test basics."""
+ generic_types = [type, tuple, list, dict, set, frozenset, enumerate,
+ defaultdict, deque,
+ SequenceMatcher,
+ dircmp,
+ FileInput,
+ OrderedDict, Counter, UserDict, UserList,
+ Pattern, Match,
+ partial, partialmethod, cached_property,
+ AbstractContextManager, AbstractAsyncContextManager,
+ Awaitable, Coroutine,
+ AsyncIterable, AsyncIterator,
+ AsyncGenerator, Generator,
+ Iterable, Iterator,
+ Reversible,
+ Container, Collection,
+ Mailbox, _PartialFile,
+ ContextVar, Token,
+ Field,
+ Set, MutableSet,
+ Mapping, MutableMapping, MappingView,
+ KeysView, ItemsView, ValuesView,
+ Sequence, MutableSequence,
+ MappingProxyType, AsyncGeneratorType,
+ DirEntry,
+ chain,
+ TemporaryDirectory, SpooledTemporaryFile,
+ Queue, SimpleQueue,
+ _AssertRaisesContext,
+ SplitResult, ParseResult,
+ ValueProxy, ApplyResult,
+ WeakSet, ReferenceType, ref,
+ ShareableList, MPSimpleQueue,
+ Future, _WorkItem,
+ Morsel]
+ if ctypes is not None:
+ generic_types.extend((ctypes.Array, ctypes.LibraryLoader))
def test_subscriptable(self):
- types = [type, tuple, list, dict, set, frozenset, enumerate,
- defaultdict, deque,
- SequenceMatcher,
- dircmp,
- FileInput,
- OrderedDict, Counter, UserDict, UserList,
- Pattern, Match,
- partial, partialmethod, cached_property,
- AbstractContextManager, AbstractAsyncContextManager,
- Awaitable, Coroutine,
- AsyncIterable, AsyncIterator,
- AsyncGenerator, Generator,
- Iterable, Iterator,
- Reversible,
- Container, Collection,
- Callable,
- Mailbox, _PartialFile,
- ContextVar, Token,
- Field,
- Set, MutableSet,
- Mapping, MutableMapping, MappingView,
- KeysView, ItemsView, ValuesView,
- Sequence, MutableSequence,
- MappingProxyType, AsyncGeneratorType,
- DirEntry,
- chain,
- TemporaryDirectory, SpooledTemporaryFile,
- Queue, SimpleQueue,
- _AssertRaisesContext,
- SplitResult, ParseResult,
- ValueProxy, ApplyResult,
- WeakSet, ReferenceType, ref,
- ShareableList, MPSimpleQueue,
- Future, _WorkItem,
- Morsel]
- if ctypes is not None:
- types.extend((ctypes.Array, ctypes.LibraryLoader))
- for t in types:
+ for t in self.generic_types:
if t is None:
continue
tname = t.__name__
@@ -293,5 +292,104 @@ class BaseTest(unittest.TestCase):
for generic_alias_property in ("__origin__", "__args__", "__parameters__"):
self.assertIn(generic_alias_property, dir_of_gen_alias)
+ def test_weakref(self):
+ for t in self.generic_types:
+ if t is None:
+ continue
+ tname = t.__name__
+ with self.subTest(f"Testing {tname}"):
+ alias = t[int]
+ self.assertEqual(ref(alias)(), alias)
+
+ def test_no_kwargs(self):
+ # bpo-42576
+ with self.assertRaises(TypeError):
+ GenericAlias(bad=float)
+
+ def test_subclassing_types_genericalias(self):
+ class SubClass(GenericAlias): ...
+ alias = SubClass(list, int)
+ class Bad(GenericAlias):
+ def __new__(cls, *args, **kwargs):
+ super().__new__(cls, *args, **kwargs)
+
+ self.assertEqual(alias, list[int])
+ with self.assertRaises(TypeError):
+ Bad(list, int, bad=int)
+
+ def test_abc_callable(self):
+ # A separate test is needed for Callable since it uses a subclass of
+ # GenericAlias.
+ alias = Callable[[int, str], float]
+ with self.subTest("Testing subscription"):
+ self.assertIs(alias.__origin__, Callable)
+ self.assertEqual(alias.__args__, (int, str, float))
+ self.assertEqual(alias.__parameters__, ())
+
+ with self.subTest("Testing instance checks"):
+ self.assertIsInstance(alias, GenericAlias)
+
+ with self.subTest("Testing weakref"):
+ self.assertEqual(ref(alias)(), alias)
+
+ with self.subTest("Testing pickling"):
+ s = pickle.dumps(alias)
+ loaded = pickle.loads(s)
+ self.assertEqual(alias.__origin__, loaded.__origin__)
+ self.assertEqual(alias.__args__, loaded.__args__)
+ self.assertEqual(alias.__parameters__, loaded.__parameters__)
+
+ with self.subTest("Testing TypeVar substitution"):
+ C1 = Callable[[int, T], T]
+ C2 = Callable[[K, T], V]
+ C3 = Callable[..., T]
+ self.assertEqual(C1[str], Callable[[int, str], str])
+ self.assertEqual(C2[int, float, str], Callable[[int, float], str])
+ self.assertEqual(C3[int], Callable[..., int])
+
+ # multi chaining
+ C4 = C2[int, V, str]
+ self.assertEqual(repr(C4).split(".")[-1], "Callable[[int, ~V], str]")
+ self.assertEqual(repr(C4[dict]).split(".")[-1], "Callable[[int, dict], str]")
+ self.assertEqual(C4[dict], Callable[[int, dict], str])
+
+ with self.subTest("Testing type erasure"):
+ class C1(Callable):
+ def __call__(self):
+ return None
+ a = C1[[int], T]
+ self.assertIs(a().__class__, C1)
+ self.assertEqual(a().__orig_class__, C1[[int], T])
+
+ # bpo-42195
+ with self.subTest("Testing collections.abc.Callable's consistency "
+ "with typing.Callable"):
+ c1 = typing.Callable[[int, str], dict]
+ c2 = Callable[[int, str], dict]
+ self.assertEqual(c1.__args__, c2.__args__)
+ self.assertEqual(hash(c1.__args__), hash(c2.__args__))
+
+ with self.subTest("Testing ParamSpec uses"):
+ P = typing.ParamSpec('P')
+ C1 = Callable[P, T]
+ # substitution
+ self.assertEqual(C1[int, str], Callable[[int], str])
+ self.assertEqual(C1[[int, str], str], Callable[[int, str], str])
+ self.assertEqual(repr(C1).split(".")[-1], "Callable[~P, ~T]")
+ self.assertEqual(repr(C1[int, str]).split(".")[-1], "Callable[[int], str]")
+
+ C2 = Callable[P, int]
+ # special case in PEP 612 where
+ # X[int, str, float] == X[[int, str, float]]
+ self.assertEqual(C2[int, str, float], C2[[int, str, float]])
+ self.assertEqual(repr(C2).split(".")[-1], "Callable[~P, int]")
+ self.assertEqual(repr(C2[int, str]).split(".")[-1], "Callable[[int, str], int]")
+
+ with self.subTest("Testing Concatenate uses"):
+ P = typing.ParamSpec('P')
+ C1 = Callable[typing.Concatenate[int, P], int]
+ self.assertEqual(repr(C1), "collections.abc.Callable"
+ "[typing.Concatenate[int, ~P], int]")
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index 4551011f5c..f50a455926 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -26,17 +26,26 @@ from http.client import HTTPException
# Were we compiled --with-pydebug or with #define Py_DEBUG?
COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
-c_hashlib = import_fresh_module('hashlib', fresh=['_hashlib'])
-py_hashlib = import_fresh_module('hashlib', blocked=['_hashlib'])
-
+# default builtin hash module
+default_builtin_hashes = {'md5', 'sha1', 'sha256', 'sha512', 'sha3', 'blake2'}
+# --with-builtin-hashlib-hashes override
builtin_hashes = sysconfig.get_config_var("PY_BUILTIN_HASHLIB_HASHES")
if builtin_hashes is None:
- builtin_hashes = {'md5', 'sha1', 'sha256', 'sha512', 'sha3', 'blake2'}
+ builtin_hashes = default_builtin_hashes
else:
builtin_hashes = {
m.strip() for m in builtin_hashes.strip('"').lower().split(",")
}
+# hashlib with and without OpenSSL backend for PBKDF2
+# only import builtin_hashlib when all builtin hashes are available.
+# Otherwise import prints noise on stderr
+openssl_hashlib = import_fresh_module('hashlib', fresh=['_hashlib'])
+if builtin_hashes == default_builtin_hashes:
+ builtin_hashlib = import_fresh_module('hashlib', blocked=['_hashlib'])
+else:
+ builtin_hashlib = None
+
try:
from _hashlib import HASH, HASHXOF, openssl_md_meth_names
except ImportError:
@@ -1032,16 +1041,16 @@ class KDFTests(unittest.TestCase):
iterations=1, dklen=None)
self.assertEqual(out, self.pbkdf2_results['sha1'][0][0])
+ @unittest.skipIf(builtin_hashlib is None, "test requires builtin_hashlib")
def test_pbkdf2_hmac_py(self):
- self._test_pbkdf2_hmac(py_hashlib.pbkdf2_hmac, builtin_hashes)
+ self._test_pbkdf2_hmac(builtin_hashlib.pbkdf2_hmac, builtin_hashes)
- @unittest.skipUnless(hasattr(c_hashlib, 'pbkdf2_hmac'),
+ @unittest.skipUnless(hasattr(openssl_hashlib, 'pbkdf2_hmac'),
' test requires OpenSSL > 1.0')
def test_pbkdf2_hmac_c(self):
- self._test_pbkdf2_hmac(c_hashlib.pbkdf2_hmac, openssl_md_meth_names)
-
+ self._test_pbkdf2_hmac(openssl_hashlib.pbkdf2_hmac, openssl_md_meth_names)
- @unittest.skipUnless(hasattr(c_hashlib, 'scrypt'),
+ @unittest.skipUnless(hasattr(hashlib, 'scrypt'),
' test requires OpenSSL > 1.1')
def test_scrypt(self):
for password, salt, n, r, p, expected in self.scrypt_test_vectors:
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 2859abb21f..c3d7c8feb1 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -3,7 +3,7 @@
Written by Cody A.W. Somerville <cody-somerville@ubuntu.com>,
Josip Dzolonga, and Michael Otteneder for the 2007/08 GHOP contest.
"""
-
+from collections import OrderedDict
from http.server import BaseHTTPRequestHandler, HTTPServer, \
SimpleHTTPRequestHandler, CGIHTTPRequestHandler
from http import server, HTTPStatus
@@ -19,7 +19,7 @@ import shutil
import email.message
import email.utils
import html
-import http.client
+import http, http.client
import urllib.parse
import tempfile
import time
@@ -588,6 +588,15 @@ print()
print(os.environ["%s"])
"""
+cgi_file6 = """\
+#!%s
+import os
+
+print("Content-type: text/plain")
+print()
+print(repr(os.environ))
+"""
+
@unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0,
"This test can't be run reliably as root (issue #13308).")
@@ -666,6 +675,11 @@ class CGIHTTPServerTestCase(BaseTestCase):
file5.write(cgi_file1 % self.pythonexe)
os.chmod(self.file5_path, 0o777)
+ self.file6_path = os.path.join(self.cgi_dir, 'file6.py')
+ with open(self.file6_path, 'w', encoding='utf-8') as file6:
+ file6.write(cgi_file6 % self.pythonexe)
+ os.chmod(self.file6_path, 0o777)
+
os.chdir(self.parent_dir)
def tearDown(self):
@@ -685,6 +699,8 @@ class CGIHTTPServerTestCase(BaseTestCase):
os.remove(self.file4_path)
if self.file5_path:
os.remove(self.file5_path)
+ if self.file6_path:
+ os.remove(self.file6_path)
os.rmdir(self.cgi_child_dir)
os.rmdir(self.cgi_dir)
os.rmdir(self.cgi_dir_in_sub_dir)
@@ -818,6 +834,23 @@ class CGIHTTPServerTestCase(BaseTestCase):
finally:
CGIHTTPRequestHandler.cgi_directories.remove('/sub/dir/cgi-bin')
+ def test_accept(self):
+ browser_accept = \
+ 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
+ tests = (
+ ((('Accept', browser_accept),), browser_accept),
+ ((), ''),
+ # Hack case to get two values for the one header
+ ((('Accept', 'text/html'), ('ACCEPT', 'text/plain')),
+ 'text/html,text/plain'),
+ )
+ for headers, expected in tests:
+ headers = OrderedDict(headers)
+ with self.subTest(headers):
+ res = self.request('/cgi-bin/file6.py', 'GET', headers=headers)
+ self.assertEqual(http.HTTPStatus.OK, res.status)
+ expected = f"'HTTP_ACCEPT': {expected!r}"
+ self.assertIn(expected.encode('ascii'), res.read())
class SocketlessRequestHandler(SimpleHTTPRequestHandler):
diff --git a/Lib/test/test_idle.py b/Lib/test/test_idle.py
index b205d35649..8756b76633 100644
--- a/Lib/test/test_idle.py
+++ b/Lib/test/test_idle.py
@@ -20,5 +20,5 @@ from idlelib.idle_test import load_tests
if __name__ == '__main__':
tk.NoDefaultRoot()
unittest.main(exit=False)
- tk._support_default_root = 1
+ tk._support_default_root = True
tk._default_root = None
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py
index 96bcb09261..0cab7897a9 100644
--- a/Lib/test/test_imaplib.py
+++ b/Lib/test/test_imaplib.py
@@ -476,7 +476,7 @@ class NewIMAPTestsMixin():
_, server = self._setup(TimeoutHandler)
addr = server.server_address[1]
- with self.assertRaises(socket.timeout):
+ with self.assertRaises(TimeoutError):
client = self.imap_class("localhost", addr, timeout=0.001)
def test_with_statement(self):
diff --git a/Lib/test/test_importlib/builtin/test_loader.py b/Lib/test/test_importlib/builtin/test_loader.py
index b1349ec5da..f6b6d97cd5 100644
--- a/Lib/test/test_importlib/builtin/test_loader.py
+++ b/Lib/test/test_importlib/builtin/test_loader.py
@@ -6,6 +6,7 @@ machinery = util.import_importlib('importlib.machinery')
import sys
import types
import unittest
+import warnings
@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
class LoaderTests(abc.LoaderTests):
@@ -24,7 +25,9 @@ class LoaderTests(abc.LoaderTests):
self.assertIn(module.__name__, sys.modules)
def load_module(self, name):
- return self.machinery.BuiltinImporter.load_module(name)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ return self.machinery.BuiltinImporter.load_module(name)
def test_module(self):
# Common case.
diff --git a/Lib/test/test_importlib/extension/test_loader.py b/Lib/test/test_importlib/extension/test_loader.py
index abd612fcd9..22cf2dac5f 100644
--- a/Lib/test/test_importlib/extension/test_loader.py
+++ b/Lib/test/test_importlib/extension/test_loader.py
@@ -1,3 +1,4 @@
+from warnings import catch_warnings
from .. import abc
from .. import util
@@ -7,6 +8,7 @@ import os.path
import sys
import types
import unittest
+import warnings
import importlib.util
import importlib
from test.support.script_helper import assert_python_failure
@@ -20,14 +22,18 @@ class LoaderTests(abc.LoaderTests):
util.EXTENSIONS.file_path)
def load_module(self, fullname):
- return self.loader.load_module(fullname)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ return self.loader.load_module(fullname)
def test_load_module_API(self):
# Test the default argument for load_module().
- self.loader.load_module()
- self.loader.load_module(None)
- with self.assertRaises(ImportError):
- self.load_module('XXX')
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ self.loader.load_module()
+ self.loader.load_module(None)
+ with self.assertRaises(ImportError):
+ self.load_module('XXX')
def test_equality(self):
other = self.machinery.ExtensionFileLoader(util.EXTENSIONS.name,
@@ -94,6 +100,21 @@ class MultiPhaseExtensionModuleTests(abc.LoaderTests):
self.loader = self.machinery.ExtensionFileLoader(
self.name, self.spec.origin)
+ def load_module(self):
+ '''Load the module from the test extension'''
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ return self.loader.load_module(self.name)
+
+ def load_module_by_name(self, fullname):
+ '''Load a module from the test extension by name'''
+ origin = self.spec.origin
+ loader = self.machinery.ExtensionFileLoader(fullname, origin)
+ spec = importlib.util.spec_from_loader(fullname, loader)
+ module = importlib.util.module_from_spec(spec)
+ loader.exec_module(module)
+ return module
+
# No extension module as __init__ available for testing.
test_package = None
@@ -157,19 +178,6 @@ class MultiPhaseExtensionModuleTests(abc.LoaderTests):
with self.assertRaises(SystemError):
module.call_state_registration_func(2)
- def load_module(self):
- '''Load the module from the test extension'''
- return self.loader.load_module(self.name)
-
- def load_module_by_name(self, fullname):
- '''Load a module from the test extension by name'''
- origin = self.spec.origin
- loader = self.machinery.ExtensionFileLoader(fullname, origin)
- spec = importlib.util.spec_from_loader(fullname, loader)
- module = importlib.util.module_from_spec(spec)
- loader.exec_module(module)
- return module
-
def test_load_submodule(self):
'''Test loading a simulated submodule'''
module = self.load_module_by_name('pkg.' + self.name)
diff --git a/Lib/test/test_importlib/frozen/test_loader.py b/Lib/test/test_importlib/frozen/test_loader.py
index 29ecff1774..8eaffa798a 100644
--- a/Lib/test/test_importlib/frozen/test_loader.py
+++ b/Lib/test/test_importlib/frozen/test_loader.py
@@ -161,19 +161,23 @@ class LoaderTests(abc.LoaderTests):
"<module '__hello__' (frozen)>")
def test_module_repr_indirect(self):
- with util.uncache('__hello__'), captured_stdout():
- module = self.machinery.FrozenImporter.load_module('__hello__')
- self.assertEqual(repr(module),
- "<module '__hello__' (frozen)>")
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ with util.uncache('__hello__'), captured_stdout():
+ module = self.machinery.FrozenImporter.load_module('__hello__')
+ self.assertEqual(repr(module),
+ "<module '__hello__' (frozen)>")
# No way to trigger an error in a frozen module.
test_state_after_failure = None
def test_unloadable(self):
- assert self.machinery.FrozenImporter.find_module('_not_real') is None
- with self.assertRaises(ImportError) as cm:
- self.machinery.FrozenImporter.load_module('_not_real')
- self.assertEqual(cm.exception.name, '_not_real')
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ assert self.machinery.FrozenImporter.find_module('_not_real') is None
+ with self.assertRaises(ImportError) as cm:
+ self.machinery.FrozenImporter.load_module('_not_real')
+ self.assertEqual(cm.exception.name, '_not_real')
(Frozen_LoaderTests,
diff --git a/Lib/test/test_importlib/import_/test___loader__.py b/Lib/test/test_importlib/import_/test___loader__.py
index 4b18093cf9..ecd83c6567 100644
--- a/Lib/test/test_importlib/import_/test___loader__.py
+++ b/Lib/test/test_importlib/import_/test___loader__.py
@@ -2,6 +2,7 @@ from importlib import machinery
import sys
import types
import unittest
+import warnings
from .. import util
@@ -45,25 +46,29 @@ class LoaderMock:
class LoaderAttributeTests:
def test___loader___missing(self):
- module = types.ModuleType('blah')
- try:
- del module.__loader__
- except AttributeError:
- pass
- loader = LoaderMock()
- loader.module = module
- with util.uncache('blah'), util.import_state(meta_path=[loader]):
- module = self.__import__('blah')
- self.assertEqual(loader, module.__loader__)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ module = types.ModuleType('blah')
+ try:
+ del module.__loader__
+ except AttributeError:
+ pass
+ loader = LoaderMock()
+ loader.module = module
+ with util.uncache('blah'), util.import_state(meta_path=[loader]):
+ module = self.__import__('blah')
+ self.assertEqual(loader, module.__loader__)
def test___loader___is_None(self):
- module = types.ModuleType('blah')
- module.__loader__ = None
- loader = LoaderMock()
- loader.module = module
- with util.uncache('blah'), util.import_state(meta_path=[loader]):
- returned_module = self.__import__('blah')
- self.assertEqual(loader, module.__loader__)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ module = types.ModuleType('blah')
+ module.__loader__ = None
+ loader = LoaderMock()
+ loader.module = module
+ with util.uncache('blah'), util.import_state(meta_path=[loader]):
+ returned_module = self.__import__('blah')
+ self.assertEqual(loader, module.__loader__)
(Frozen_Tests,
diff --git a/Lib/test/test_importlib/import_/test___package__.py b/Lib/test/test_importlib/import_/test___package__.py
index 761b256b38..4a2b34e5f6 100644
--- a/Lib/test/test_importlib/import_/test___package__.py
+++ b/Lib/test/test_importlib/import_/test___package__.py
@@ -98,6 +98,16 @@ class FakeSpec:
class Using__package__PEP302(Using__package__):
mock_modules = util.mock_modules
+ def test_using___package__(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_using___package__()
+
+ def test_spec_fallback(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_spec_fallback()
+
(Frozen_UsingPackagePEP302,
Source_UsingPackagePEP302
@@ -155,6 +165,21 @@ class Setting__package__:
class Setting__package__PEP302(Setting__package__, unittest.TestCase):
mock_modules = util.mock_modules
+ def test_top_level(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_top_level()
+
+ def test_package(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_package()
+
+ def test_submodule(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_submodule()
+
class Setting__package__PEP451(Setting__package__, unittest.TestCase):
mock_modules = util.mock_spec
diff --git a/Lib/test/test_importlib/import_/test_api.py b/Lib/test/test_importlib/import_/test_api.py
index 0cd9de4daf..35c26977ea 100644
--- a/Lib/test/test_importlib/import_/test_api.py
+++ b/Lib/test/test_importlib/import_/test_api.py
@@ -4,6 +4,7 @@ from importlib import machinery
import sys
import types
import unittest
+import warnings
PKG_NAME = 'fine'
SUBMOD_NAME = 'fine.bogus'
@@ -100,6 +101,36 @@ class APITest:
class OldAPITests(APITest):
bad_finder_loader = BadLoaderFinder
+ def test_raises_ModuleNotFoundError(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_raises_ModuleNotFoundError()
+
+ def test_name_requires_rparition(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_name_requires_rparition()
+
+ def test_negative_level(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_negative_level()
+
+ def test_nonexistent_fromlist_entry(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_nonexistent_fromlist_entry()
+
+ def test_fromlist_load_error_propagates(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_fromlist_load_error_propagates
+
+ def test_blocked_fromlist(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_blocked_fromlist()
+
(Frozen_OldAPITests,
Source_OldAPITests
diff --git a/Lib/test/test_importlib/import_/test_caching.py b/Lib/test/test_importlib/import_/test_caching.py
index 8079add5b2..0f987b2210 100644
--- a/Lib/test/test_importlib/import_/test_caching.py
+++ b/Lib/test/test_importlib/import_/test_caching.py
@@ -3,6 +3,7 @@ from .. import util
import sys
from types import MethodType
import unittest
+import warnings
class UseCache:
@@ -63,30 +64,36 @@ class ImportlibUseCache(UseCache, unittest.TestCase):
# to when to use the module in sys.modules and when not to.
def test_using_cache_after_loader(self):
# [from cache on return]
- with self.create_mock('module') as mock:
- with util.import_state(meta_path=[mock]):
- module = self.__import__('module')
- self.assertEqual(id(module), id(sys.modules['module']))
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ with self.create_mock('module') as mock:
+ with util.import_state(meta_path=[mock]):
+ module = self.__import__('module')
+ self.assertEqual(id(module), id(sys.modules['module']))
# See test_using_cache_after_loader() for reasoning.
def test_using_cache_for_assigning_to_attribute(self):
# [from cache to attribute]
- with self.create_mock('pkg.__init__', 'pkg.module') as importer:
- with util.import_state(meta_path=[importer]):
- module = self.__import__('pkg.module')
- self.assertTrue(hasattr(module, 'module'))
- self.assertEqual(id(module.module),
- id(sys.modules['pkg.module']))
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ with self.create_mock('pkg.__init__', 'pkg.module') as importer:
+ with util.import_state(meta_path=[importer]):
+ module = self.__import__('pkg.module')
+ self.assertTrue(hasattr(module, 'module'))
+ self.assertEqual(id(module.module),
+ id(sys.modules['pkg.module']))
# See test_using_cache_after_loader() for reasoning.
def test_using_cache_for_fromlist(self):
# [from cache for fromlist]
- with self.create_mock('pkg.__init__', 'pkg.module') as importer:
- with util.import_state(meta_path=[importer]):
- module = self.__import__('pkg', fromlist=['module'])
- self.assertTrue(hasattr(module, 'module'))
- self.assertEqual(id(module.module),
- id(sys.modules['pkg.module']))
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ with self.create_mock('pkg.__init__', 'pkg.module') as importer:
+ with util.import_state(meta_path=[importer]):
+ module = self.__import__('pkg', fromlist=['module'])
+ self.assertTrue(hasattr(module, 'module'))
+ self.assertEqual(id(module.module),
+ id(sys.modules['pkg.module']))
if __name__ == '__main__':
diff --git a/Lib/test/test_importlib/import_/test_fromlist.py b/Lib/test/test_importlib/import_/test_fromlist.py
index 018c172176..deb21710a6 100644
--- a/Lib/test/test_importlib/import_/test_fromlist.py
+++ b/Lib/test/test_importlib/import_/test_fromlist.py
@@ -24,7 +24,7 @@ class ReturnValue:
def test_return_from_from_import(self):
# [from return]
- with util.mock_modules('pkg.__init__', 'pkg.module')as importer:
+ with util.mock_spec('pkg.__init__', 'pkg.module')as importer:
with util.import_state(meta_path=[importer]):
module = self.__import__('pkg.module', fromlist=['attr'])
self.assertEqual(module.__name__, 'pkg.module')
@@ -52,14 +52,14 @@ class HandlingFromlist:
def test_object(self):
# [object case]
- with util.mock_modules('module') as importer:
+ with util.mock_spec('module') as importer:
with util.import_state(meta_path=[importer]):
module = self.__import__('module', fromlist=['attr'])
self.assertEqual(module.__name__, 'module')
def test_nonexistent_object(self):
# [bad object]
- with util.mock_modules('module') as importer:
+ with util.mock_spec('module') as importer:
with util.import_state(meta_path=[importer]):
module = self.__import__('module', fromlist=['non_existent'])
self.assertEqual(module.__name__, 'module')
@@ -67,7 +67,7 @@ class HandlingFromlist:
def test_module_from_package(self):
# [module]
- with util.mock_modules('pkg.__init__', 'pkg.module') as importer:
+ with util.mock_spec('pkg.__init__', 'pkg.module') as importer:
with util.import_state(meta_path=[importer]):
module = self.__import__('pkg', fromlist=['module'])
self.assertEqual(module.__name__, 'pkg')
@@ -75,7 +75,7 @@ class HandlingFromlist:
self.assertEqual(module.module.__name__, 'pkg.module')
def test_nonexistent_from_package(self):
- with util.mock_modules('pkg.__init__') as importer:
+ with util.mock_spec('pkg.__init__') as importer:
with util.import_state(meta_path=[importer]):
module = self.__import__('pkg', fromlist=['non_existent'])
self.assertEqual(module.__name__, 'pkg')
@@ -87,7 +87,7 @@ class HandlingFromlist:
# ModuleNotFoundError propagate.
def module_code():
import i_do_not_exist
- with util.mock_modules('pkg.__init__', 'pkg.mod',
+ with util.mock_spec('pkg.__init__', 'pkg.mod',
module_code={'pkg.mod': module_code}) as importer:
with util.import_state(meta_path=[importer]):
with self.assertRaises(ModuleNotFoundError) as exc:
@@ -95,14 +95,14 @@ class HandlingFromlist:
self.assertEqual('i_do_not_exist', exc.exception.name)
def test_empty_string(self):
- with util.mock_modules('pkg.__init__', 'pkg.mod') as importer:
+ with util.mock_spec('pkg.__init__', 'pkg.mod') as importer:
with util.import_state(meta_path=[importer]):
module = self.__import__('pkg.mod', fromlist=[''])
self.assertEqual(module.__name__, 'pkg.mod')
def basic_star_test(self, fromlist=['*']):
# [using *]
- with util.mock_modules('pkg.__init__', 'pkg.module') as mock:
+ with util.mock_spec('pkg.__init__', 'pkg.module') as mock:
with util.import_state(meta_path=[mock]):
mock['pkg'].__all__ = ['module']
module = self.__import__('pkg', fromlist=fromlist)
@@ -119,7 +119,7 @@ class HandlingFromlist:
def test_star_with_others(self):
# [using * with others]
- context = util.mock_modules('pkg.__init__', 'pkg.module1', 'pkg.module2')
+ context = util.mock_spec('pkg.__init__', 'pkg.module1', 'pkg.module2')
with context as mock:
with util.import_state(meta_path=[mock]):
mock['pkg'].__all__ = ['module1']
@@ -131,7 +131,7 @@ class HandlingFromlist:
self.assertEqual(module.module2.__name__, 'pkg.module2')
def test_nonexistent_in_all(self):
- with util.mock_modules('pkg.__init__') as importer:
+ with util.mock_spec('pkg.__init__') as importer:
with util.import_state(meta_path=[importer]):
importer['pkg'].__all__ = ['non_existent']
module = self.__import__('pkg', fromlist=['*'])
@@ -139,7 +139,7 @@ class HandlingFromlist:
self.assertFalse(hasattr(module, 'non_existent'))
def test_star_in_all(self):
- with util.mock_modules('pkg.__init__') as importer:
+ with util.mock_spec('pkg.__init__') as importer:
with util.import_state(meta_path=[importer]):
importer['pkg'].__all__ = ['*']
module = self.__import__('pkg', fromlist=['*'])
@@ -147,7 +147,7 @@ class HandlingFromlist:
self.assertFalse(hasattr(module, '*'))
def test_invalid_type(self):
- with util.mock_modules('pkg.__init__') as importer:
+ with util.mock_spec('pkg.__init__') as importer:
with util.import_state(meta_path=[importer]), \
warnings.catch_warnings():
warnings.simplefilter('error', BytesWarning)
@@ -157,7 +157,7 @@ class HandlingFromlist:
self.__import__('pkg', fromlist=iter([b'attr']))
def test_invalid_type_in_all(self):
- with util.mock_modules('pkg.__init__') as importer:
+ with util.mock_spec('pkg.__init__') as importer:
with util.import_state(meta_path=[importer]), \
warnings.catch_warnings():
warnings.simplefilter('error', BytesWarning)
diff --git a/Lib/test/test_importlib/import_/test_meta_path.py b/Lib/test/test_importlib/import_/test_meta_path.py
index 5a41e8968a..5730119fe9 100644
--- a/Lib/test/test_importlib/import_/test_meta_path.py
+++ b/Lib/test/test_importlib/import_/test_meta_path.py
@@ -100,8 +100,20 @@ class CallSignature:
self.assertEqual(args[0], mod_name)
self.assertIs(args[1], path)
+class CallSignoreSuppressImportWarning(CallSignature):
-class CallSignaturePEP302(CallSignature):
+ def test_no_path(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_no_path()
+
+ def test_with_path(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ super().test_no_path()
+
+
+class CallSignaturePEP302(CallSignoreSuppressImportWarning):
mock_modules = util.mock_modules
finder_name = 'find_module'
diff --git a/Lib/test/test_importlib/test_abc.py b/Lib/test/test_importlib/test_abc.py
index 605738fae2..d8b9fc89f2 100644
--- a/Lib/test/test_importlib/test_abc.py
+++ b/Lib/test/test_importlib/test_abc.py
@@ -458,32 +458,36 @@ class LoaderLoadModuleTests:
return SpecLoader()
def test_fresh(self):
- loader = self.loader()
- name = 'blah'
- with test_util.uncache(name):
- loader.load_module(name)
- module = loader.found
- self.assertIs(sys.modules[name], module)
- self.assertEqual(loader, module.__loader__)
- self.assertEqual(loader, module.__spec__.loader)
- self.assertEqual(name, module.__name__)
- self.assertEqual(name, module.__spec__.name)
- self.assertIsNotNone(module.__path__)
- self.assertIsNotNone(module.__path__,
- module.__spec__.submodule_search_locations)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ loader = self.loader()
+ name = 'blah'
+ with test_util.uncache(name):
+ loader.load_module(name)
+ module = loader.found
+ self.assertIs(sys.modules[name], module)
+ self.assertEqual(loader, module.__loader__)
+ self.assertEqual(loader, module.__spec__.loader)
+ self.assertEqual(name, module.__name__)
+ self.assertEqual(name, module.__spec__.name)
+ self.assertIsNotNone(module.__path__)
+ self.assertIsNotNone(module.__path__,
+ module.__spec__.submodule_search_locations)
def test_reload(self):
- name = 'blah'
- loader = self.loader()
- module = types.ModuleType(name)
- module.__spec__ = self.util.spec_from_loader(name, loader)
- module.__loader__ = loader
- with test_util.uncache(name):
- sys.modules[name] = module
- loader.load_module(name)
- found = loader.found
- self.assertIs(found, sys.modules[name])
- self.assertIs(module, sys.modules[name])
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ name = 'blah'
+ loader = self.loader()
+ module = types.ModuleType(name)
+ module.__spec__ = self.util.spec_from_loader(name, loader)
+ module.__loader__ = loader
+ with test_util.uncache(name):
+ sys.modules[name] = module
+ loader.load_module(name)
+ found = loader.found
+ self.assertIs(found, sys.modules[name])
+ self.assertIs(module, sys.modules[name])
(Frozen_LoaderLoadModuleTests,
@@ -837,25 +841,29 @@ class SourceOnlyLoaderTests(SourceLoaderTestHarness):
# Loading a module should set __name__, __loader__, __package__,
# __path__ (for packages), __file__, and __cached__.
# The module should also be put into sys.modules.
- with test_util.uncache(self.name):
- with warnings.catch_warnings():
- warnings.simplefilter('ignore', DeprecationWarning)
- module = self.loader.load_module(self.name)
- self.verify_module(module)
- self.assertEqual(module.__path__, [os.path.dirname(self.path)])
- self.assertIn(self.name, sys.modules)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ with test_util.uncache(self.name):
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ module = self.loader.load_module(self.name)
+ self.verify_module(module)
+ self.assertEqual(module.__path__, [os.path.dirname(self.path)])
+ self.assertIn(self.name, sys.modules)
def test_package_settings(self):
# __package__ needs to be set, while __path__ is set on if the module
# is a package.
# Testing the values for a package are covered by test_load_module.
- self.setUp(is_package=False)
- with test_util.uncache(self.name):
- with warnings.catch_warnings():
- warnings.simplefilter('ignore', DeprecationWarning)
- module = self.loader.load_module(self.name)
- self.verify_module(module)
- self.assertFalse(hasattr(module, '__path__'))
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ self.setUp(is_package=False)
+ with test_util.uncache(self.name):
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ module = self.loader.load_module(self.name)
+ self.verify_module(module)
+ self.assertFalse(hasattr(module, '__path__'))
def test_get_source_encoding(self):
# Source is considered encoded in UTF-8 by default unless otherwise
diff --git a/Lib/test/test_importlib/test_api.py b/Lib/test/test_importlib/test_api.py
index fd60634e09..3f06a10ba9 100644
--- a/Lib/test/test_importlib/test_api.py
+++ b/Lib/test/test_importlib/test_api.py
@@ -20,7 +20,7 @@ class ImportModuleTests:
def test_module_import(self):
# Test importing a top-level module.
- with test_util.mock_modules('top_level') as mock:
+ with test_util.mock_spec('top_level') as mock:
with test_util.import_state(meta_path=[mock]):
module = self.init.import_module('top_level')
self.assertEqual(module.__name__, 'top_level')
@@ -30,7 +30,7 @@ class ImportModuleTests:
pkg_name = 'pkg'
pkg_long_name = '{0}.__init__'.format(pkg_name)
name = '{0}.mod'.format(pkg_name)
- with test_util.mock_modules(pkg_long_name, name) as mock:
+ with test_util.mock_spec(pkg_long_name, name) as mock:
with test_util.import_state(meta_path=[mock]):
module = self.init.import_module(name)
self.assertEqual(module.__name__, name)
@@ -42,7 +42,7 @@ class ImportModuleTests:
module_name = 'mod'
absolute_name = '{0}.{1}'.format(pkg_name, module_name)
relative_name = '.{0}'.format(module_name)
- with test_util.mock_modules(pkg_long_name, absolute_name) as mock:
+ with test_util.mock_spec(pkg_long_name, absolute_name) as mock:
with test_util.import_state(meta_path=[mock]):
self.init.import_module(pkg_name)
module = self.init.import_module(relative_name, pkg_name)
@@ -50,7 +50,7 @@ class ImportModuleTests:
def test_deep_relative_package_import(self):
modules = ['a.__init__', 'a.b.__init__', 'a.c']
- with test_util.mock_modules(*modules) as mock:
+ with test_util.mock_spec(*modules) as mock:
with test_util.import_state(meta_path=[mock]):
self.init.import_module('a')
self.init.import_module('a.b')
@@ -63,7 +63,7 @@ class ImportModuleTests:
pkg_name = 'pkg'
pkg_long_name = '{0}.__init__'.format(pkg_name)
name = '{0}.mod'.format(pkg_name)
- with test_util.mock_modules(pkg_long_name, name) as mock:
+ with test_util.mock_spec(pkg_long_name, name) as mock:
with test_util.import_state(meta_path=[mock]):
self.init.import_module(pkg_name)
module = self.init.import_module(name, pkg_name)
@@ -88,7 +88,7 @@ class ImportModuleTests:
b_load_count += 1
code = {'a': load_a, 'a.b': load_b}
modules = ['a.__init__', 'a.b']
- with test_util.mock_modules(*modules, module_code=code) as mock:
+ with test_util.mock_spec(*modules, module_code=code) as mock:
with test_util.import_state(meta_path=[mock]):
self.init.import_module('a.b')
self.assertEqual(b_load_count, 1)
@@ -212,8 +212,8 @@ class ReloadTests:
module = type(sys)('top_level')
module.spam = 3
sys.modules['top_level'] = module
- mock = test_util.mock_modules('top_level',
- module_code={'top_level': code})
+ mock = test_util.mock_spec('top_level',
+ module_code={'top_level': code})
with mock:
with test_util.import_state(meta_path=[mock]):
module = self.init.import_module('top_level')
diff --git a/Lib/test/test_importlib/test_spec.py b/Lib/test/test_importlib/test_spec.py
index eed90f29f9..b57eb6c0ff 100644
--- a/Lib/test/test_importlib/test_spec.py
+++ b/Lib/test/test_importlib/test_spec.py
@@ -303,32 +303,38 @@ class ModuleSpecMethodsTests:
self.assertNotIn(self.spec.name, sys.modules)
def test_load_legacy(self):
- self.spec.loader = LegacyLoader()
- with CleanImport(self.spec.name):
- loaded = self.bootstrap._load(self.spec)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ self.spec.loader = LegacyLoader()
+ with CleanImport(self.spec.name):
+ loaded = self.bootstrap._load(self.spec)
- self.assertEqual(loaded.ham, -1)
+ self.assertEqual(loaded.ham, -1)
def test_load_legacy_attributes(self):
- self.spec.loader = LegacyLoader()
- with CleanImport(self.spec.name):
- loaded = self.bootstrap._load(self.spec)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ self.spec.loader = LegacyLoader()
+ with CleanImport(self.spec.name):
+ loaded = self.bootstrap._load(self.spec)
- self.assertIs(loaded.__loader__, self.spec.loader)
- self.assertEqual(loaded.__package__, self.spec.parent)
- self.assertIs(loaded.__spec__, self.spec)
+ self.assertIs(loaded.__loader__, self.spec.loader)
+ self.assertEqual(loaded.__package__, self.spec.parent)
+ self.assertIs(loaded.__spec__, self.spec)
def test_load_legacy_attributes_immutable(self):
module = object()
- class ImmutableLoader(TestLoader):
- def load_module(self, name):
- sys.modules[name] = module
- return module
- self.spec.loader = ImmutableLoader()
- with CleanImport(self.spec.name):
- loaded = self.bootstrap._load(self.spec)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ class ImmutableLoader(TestLoader):
+ def load_module(self, name):
+ sys.modules[name] = module
+ return module
+ self.spec.loader = ImmutableLoader()
+ with CleanImport(self.spec.name):
+ loaded = self.bootstrap._load(self.spec)
- self.assertIs(sys.modules[self.spec.name], module)
+ self.assertIs(sys.modules[self.spec.name], module)
# reload()
@@ -382,11 +388,13 @@ class ModuleSpecMethodsTests:
self.assertFalse(hasattr(loaded, '__cached__'))
def test_reload_legacy(self):
- self.spec.loader = LegacyLoader()
- with CleanImport(self.spec.name):
- loaded = self.bootstrap._load(self.spec)
- reloaded = self.bootstrap._exec(self.spec, loaded)
- installed = sys.modules[self.spec.name]
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", ImportWarning)
+ self.spec.loader = LegacyLoader()
+ with CleanImport(self.spec.name):
+ loaded = self.bootstrap._load(self.spec)
+ reloaded = self.bootstrap._exec(self.spec, loaded)
+ installed = sys.modules[self.spec.name]
self.assertEqual(loaded.ham, -1)
self.assertIs(reloaded, loaded)
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 71c4f27d27..706fcbe343 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -390,6 +390,7 @@ class TestRetrievingSourceCode(GetSourceBase):
('ParrotDroppings', mod.ParrotDroppings),
('StupidGit', mod.StupidGit),
('Tit', mod.MalodorousPervert),
+ ('WhichComments', mod.WhichComments),
])
tree = inspect.getclasstree([cls[1] for cls in classes])
self.assertEqual(tree,
@@ -403,7 +404,8 @@ class TestRetrievingSourceCode(GetSourceBase):
[(mod.FesteringGob, (mod.MalodorousPervert,
mod.ParrotDroppings))
]
- ]
+ ],
+ (mod.WhichComments, (object,),)
]
])
tree = inspect.getclasstree([cls[1] for cls in classes], True)
@@ -415,7 +417,8 @@ class TestRetrievingSourceCode(GetSourceBase):
[(mod.FesteringGob, (mod.MalodorousPervert,
mod.ParrotDroppings))
]
- ]
+ ],
+ (mod.WhichComments, (object,),)
]
])
@@ -646,6 +649,18 @@ class TestOneliners(GetSourceBase):
# as argument to another function.
self.assertSourceEqual(mod2.anonymous, 55, 55)
+class TestBlockComments(GetSourceBase):
+ fodderModule = mod
+
+ def test_toplevel_class(self):
+ self.assertSourceEqual(mod.WhichComments, 96, 114)
+
+ def test_class_method(self):
+ self.assertSourceEqual(mod.WhichComments.f, 99, 104)
+
+ def test_class_async_method(self):
+ self.assertSourceEqual(mod.WhichComments.asyncf, 109, 112)
+
class TestBuggyCases(GetSourceBase):
fodderModule = mod2
@@ -697,6 +712,17 @@ class TestBuggyCases(GetSourceBase):
self.assertRaises(IOError, inspect.findsource, co)
self.assertRaises(IOError, inspect.getsource, co)
+ def test_findsource_with_out_of_bounds_lineno(self):
+ mod_len = len(inspect.getsource(mod))
+ src = '\n' * 2* mod_len + "def f(): pass"
+ co = compile(src, mod.__file__, "exec")
+ g, l = {}, {}
+ eval(co, g, l)
+ func = l['f']
+ self.assertEqual(func.__code__.co_firstlineno, 1+2*mod_len)
+ with self.assertRaisesRegex(IOError, "lineno is out of bounds"):
+ inspect.findsource(func)
+
def test_getsource_on_method(self):
self.assertSourceEqual(mod2.ClassWithMethod.method, 118, 119)
@@ -3224,6 +3250,26 @@ class TestSignatureObject(unittest.TestCase):
p2 = inspect.signature(lambda y, x: None).parameters
self.assertNotEqual(p1, p2)
+ def test_signature_annotations_with_local_namespaces(self):
+ class Foo: ...
+ def func(foo: Foo) -> int: pass
+ def func2(foo: Foo, bar: Bar) -> int: pass
+
+ for signature_func in (inspect.signature, inspect.Signature.from_callable):
+ with self.subTest(signature_func = signature_func):
+ sig1 = signature_func(func)
+ self.assertEqual(sig1.return_annotation, 'int')
+ self.assertEqual(sig1.parameters['foo'].annotation, 'Foo')
+
+ sig2 = signature_func(func, localns=locals())
+ self.assertEqual(sig2.return_annotation, int)
+ self.assertEqual(sig2.parameters['foo'].annotation, Foo)
+
+ sig3 = signature_func(func2, globalns={'Bar': int}, localns=locals())
+ self.assertEqual(sig3.return_annotation, int)
+ self.assertEqual(sig3.parameters['foo'].annotation, Foo)
+ self.assertEqual(sig3.parameters['bar'].annotation, int)
+
class TestParameterObject(unittest.TestCase):
def test_signature_parameter_kinds(self):
@@ -4014,8 +4060,8 @@ def foo():
def test_main():
run_unittest(
- TestDecorators, TestRetrievingSourceCode, TestOneliners, TestBuggyCases,
- TestInterpreterStack, TestClassesAndFunctions, TestPredicates,
+ TestDecorators, TestRetrievingSourceCode, TestOneliners, TestBlockComments,
+ TestBuggyCases, TestInterpreterStack, TestClassesAndFunctions, TestPredicates,
TestGetcallargsFunctions, TestGetcallargsMethods,
TestGetcallargsUnboundMethods, TestGetattrStatic, TestGetGeneratorState,
TestNoEOL, TestSignatureObject, TestSignatureBind, TestParameterObject,
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index eaa6197bec..a99b5e2bb7 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -12,6 +12,8 @@ from functools import reduce
import sys
import struct
import threading
+import gc
+
maxsize = support.MAX_Py_ssize_t
minsize = -maxsize-1
@@ -1024,6 +1026,25 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(next(it), (1, 2))
self.assertRaises(RuntimeError, next, it)
+ def test_pairwise(self):
+ self.assertEqual(list(pairwise('')), [])
+ self.assertEqual(list(pairwise('a')), [])
+ self.assertEqual(list(pairwise('ab')),
+ [('a', 'b')]),
+ self.assertEqual(list(pairwise('abcde')),
+ [('a', 'b'), ('b', 'c'), ('c', 'd'), ('d', 'e')])
+ self.assertEqual(list(pairwise(range(10_000))),
+ list(zip(range(10_000), range(1, 10_000))))
+
+ with self.assertRaises(TypeError):
+ pairwise() # too few arguments
+ with self.assertRaises(TypeError):
+ pairwise('abc', 10) # too many arguments
+ with self.assertRaises(TypeError):
+ pairwise(iterable='abc') # keyword arguments
+ with self.assertRaises(TypeError):
+ pairwise(None) # non-iterable argument
+
def test_product(self):
for args, result in [
([], [()]), # zero iterables
@@ -1554,6 +1575,51 @@ class TestBasicOps(unittest.TestCase):
self.assertRaises(StopIteration, next, f(lambda x:x, []))
self.assertRaises(StopIteration, next, f(lambda x:x, StopNow()))
+ @support.cpython_only
+ def test_combinations_result_gc(self):
+ # bpo-42536: combinations's tuple-reuse speed trick breaks the GC's
+ # assumptions about what can be untracked. Make sure we re-track result
+ # tuples whenever we reuse them.
+ it = combinations([None, []], 1)
+ next(it)
+ gc.collect()
+ # That GC collection probably untracked the recycled internal result
+ # tuple, which has the value (None,). Make sure it's re-tracked when
+ # it's mutated and returned from __next__:
+ self.assertTrue(gc.is_tracked(next(it)))
+
+ @support.cpython_only
+ def test_combinations_with_replacement_result_gc(self):
+ # Ditto for combinations_with_replacement.
+ it = combinations_with_replacement([None, []], 1)
+ next(it)
+ gc.collect()
+ self.assertTrue(gc.is_tracked(next(it)))
+
+ @support.cpython_only
+ def test_permutations_result_gc(self):
+ # Ditto for permutations.
+ it = permutations([None, []], 1)
+ next(it)
+ gc.collect()
+ self.assertTrue(gc.is_tracked(next(it)))
+
+ @support.cpython_only
+ def test_product_result_gc(self):
+ # Ditto for product.
+ it = product([None, []])
+ next(it)
+ gc.collect()
+ self.assertTrue(gc.is_tracked(next(it)))
+
+ @support.cpython_only
+ def test_zip_longest_result_gc(self):
+ # Ditto for zip_longest.
+ it = zip_longest([[]])
+ gc.collect()
+ self.assertTrue(gc.is_tracked(next(it)))
+
+
class TestExamples(unittest.TestCase):
def test_accumulate(self):
@@ -1787,6 +1853,10 @@ class TestGC(unittest.TestCase):
a = []
self.makecycle(islice([a]*2, None), a)
+ def test_pairwise(self):
+ a = []
+ self.makecycle(pairwise([a]*5), a)
+
def test_permutations(self):
a = []
self.makecycle(permutations([1,2,a,3], 3), a)
@@ -1995,6 +2065,17 @@ class TestVariousIteratorArgs(unittest.TestCase):
self.assertRaises(TypeError, islice, N(s), 10)
self.assertRaises(ZeroDivisionError, list, islice(E(s), 10))
+ def test_pairwise(self):
+ for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
+ for g in (G, I, Ig, S, L, R):
+ seq = list(g(s))
+ expected = list(zip(seq, seq[1:]))
+ actual = list(pairwise(g(s)))
+ self.assertEqual(actual, expected)
+ self.assertRaises(TypeError, pairwise, X(s))
+ self.assertRaises(TypeError, pairwise, N(s))
+ self.assertRaises(ZeroDivisionError, list, pairwise(E(s)))
+
def test_starmap(self):
for s in (range(10), range(0), range(100), (7,11), range(20,50,5)):
for g in (G, I, Ig, S, L, R):
@@ -2290,7 +2371,7 @@ Samuele
... "Count how many times the predicate is true"
... return sum(map(pred, iterable))
->>> def padnone(iterable):
+>>> def pad_none(iterable):
... "Returns the sequence elements and then returns None indefinitely"
... return chain(iterable, repeat(None))
@@ -2312,15 +2393,6 @@ Samuele
... else:
... return starmap(func, repeat(args, times))
->>> def pairwise(iterable):
-... "s -> (s0,s1), (s1,s2), (s2, s3), ..."
-... a, b = tee(iterable)
-... try:
-... next(b)
-... except StopIteration:
-... pass
-... return zip(a, b)
-
>>> def grouper(n, iterable, fillvalue=None):
... "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
... args = [iter(iterable)] * n
@@ -2451,16 +2523,7 @@ True
>>> take(5, map(int, repeatfunc(random.random)))
[0, 0, 0, 0, 0]
->>> list(pairwise('abcd'))
-[('a', 'b'), ('b', 'c'), ('c', 'd')]
-
->>> list(pairwise([]))
-[]
-
->>> list(pairwise('a'))
-[]
-
->>> list(islice(padnone('abc'), 0, 6))
+>>> list(islice(pad_none('abc'), 0, 6))
['a', 'b', 'c', None, None, None]
>>> list(ncycles('abc', 3))
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index e2196736dc..859baa4738 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -4219,6 +4219,15 @@ class ModuleLevelMiscTest(BaseTest):
logging.disable(83)
self.assertEqual(logging.root.manager.disable, 83)
+ self.assertRaises(ValueError, logging.disable, "doesnotexists")
+
+ class _NotAnIntOrString:
+ pass
+
+ self.assertRaises(TypeError, logging.disable, _NotAnIntOrString())
+
+ logging.disable("WARN")
+
# test the default value introduced in 3.7
# (Issue #28524)
logging.disable()
diff --git a/Lib/test/test_mailcap.py b/Lib/test/test_mailcap.py
index 51a0c7da8b..ef9cad498a 100644
--- a/Lib/test/test_mailcap.py
+++ b/Lib/test/test_mailcap.py
@@ -4,6 +4,7 @@ import copy
import test.support
from test.support import os_helper
import unittest
+import sys
# Location of mailcap file
MAILCAPFILE = test.support.findfile("mailcap.txt")
@@ -214,6 +215,7 @@ class FindmatchTest(unittest.TestCase):
self._run_cases(cases)
@unittest.skipUnless(os.name == "posix", "Requires 'test' command on system")
+ @unittest.skipIf(sys.platform == "vxworks", "'test' command is not supported on VxWorks")
def test_test(self):
# findmatch() will automatically check any "test" conditions and skip
# the entry if the check fails.
diff --git a/Lib/test/test_named_expressions.py b/Lib/test/test_named_expressions.py
index c813830ce6..5908f12108 100644
--- a/Lib/test/test_named_expressions.py
+++ b/Lib/test/test_named_expressions.py
@@ -113,7 +113,7 @@ class NamedExpressionInvalidTest(unittest.TestCase):
"assignment expression within a comprehension cannot be used in a class body"):
exec(code, {}, {})
- def test_named_expression_invalid_rebinding_comprehension_iteration_variable(self):
+ def test_named_expression_invalid_rebinding_list_comprehension_iteration_variable(self):
cases = [
("Local reuse", 'i', "[i := 0 for i in range(5)]"),
("Nested reuse", 'j', "[[(j := 0) for i in range(5)] for j in range(5)]"),
@@ -130,7 +130,7 @@ class NamedExpressionInvalidTest(unittest.TestCase):
with self.assertRaisesRegex(SyntaxError, msg):
exec(code, {}, {})
- def test_named_expression_invalid_rebinding_comprehension_inner_loop(self):
+ def test_named_expression_invalid_rebinding_list_comprehension_inner_loop(self):
cases = [
("Inner reuse", 'j', "[i for i in range(5) if (j := 0) for j in range(5)]"),
("Inner unpacking reuse", 'j', "[i for i in range(5) if (j := 0) for j, k in [(0, 1)]]"),
@@ -145,7 +145,7 @@ class NamedExpressionInvalidTest(unittest.TestCase):
with self.assertRaisesRegex(SyntaxError, msg):
exec(f"lambda: {code}", {}) # Function scope
- def test_named_expression_invalid_comprehension_iterable_expression(self):
+ def test_named_expression_invalid_list_comprehension_iterable_expression(self):
cases = [
("Top level", "[i for i in (i := range(5))]"),
("Inside tuple", "[i for i in (2, 3, i := range(5))]"),
@@ -167,6 +167,60 @@ class NamedExpressionInvalidTest(unittest.TestCase):
with self.assertRaisesRegex(SyntaxError, msg):
exec(f"lambda: {code}", {}) # Function scope
+ def test_named_expression_invalid_rebinding_set_comprehension_iteration_variable(self):
+ cases = [
+ ("Local reuse", 'i', "{i := 0 for i in range(5)}"),
+ ("Nested reuse", 'j', "{{(j := 0) for i in range(5)} for j in range(5)}"),
+ ("Reuse inner loop target", 'j', "{(j := 0) for i in range(5) for j in range(5)}"),
+ ("Unpacking reuse", 'i', "{i := 0 for i, j in {(0, 1)}}"),
+ ("Reuse in loop condition", 'i', "{i+1 for i in range(5) if (i := 0)}"),
+ ("Unreachable reuse", 'i', "{False or (i:=0) for i in range(5)}"),
+ ("Unreachable nested reuse", 'i',
+ "{(i, j) for i in range(5) for j in range(5) if True or (i:=10)}"),
+ ]
+ for case, target, code in cases:
+ msg = f"assignment expression cannot rebind comprehension iteration variable '{target}'"
+ with self.subTest(case=case):
+ with self.assertRaisesRegex(SyntaxError, msg):
+ exec(code, {}, {})
+
+ def test_named_expression_invalid_rebinding_set_comprehension_inner_loop(self):
+ cases = [
+ ("Inner reuse", 'j', "{i for i in range(5) if (j := 0) for j in range(5)}"),
+ ("Inner unpacking reuse", 'j', "{i for i in range(5) if (j := 0) for j, k in {(0, 1)}}"),
+ ]
+ for case, target, code in cases:
+ msg = f"comprehension inner loop cannot rebind assignment expression target '{target}'"
+ with self.subTest(case=case):
+ with self.assertRaisesRegex(SyntaxError, msg):
+ exec(code, {}) # Module scope
+ with self.assertRaisesRegex(SyntaxError, msg):
+ exec(code, {}, {}) # Class scope
+ with self.assertRaisesRegex(SyntaxError, msg):
+ exec(f"lambda: {code}", {}) # Function scope
+
+ def test_named_expression_invalid_set_comprehension_iterable_expression(self):
+ cases = [
+ ("Top level", "{i for i in (i := range(5))}"),
+ ("Inside tuple", "{i for i in (2, 3, i := range(5))}"),
+ ("Inside list", "{i for i in {2, 3, i := range(5)}}"),
+ ("Different name", "{i for i in (j := range(5))}"),
+ ("Lambda expression", "{i for i in (lambda:(j := range(5)))()}"),
+ ("Inner loop", "{i for i in range(5) for j in (i := range(5))}"),
+ ("Nested comprehension", "{i for i in {j for j in (k := range(5))}}"),
+ ("Nested comprehension condition", "{i for i in {j for j in range(5) if (j := True)}}"),
+ ("Nested comprehension body", "{i for i in {(j := True) for j in range(5)}}"),
+ ]
+ msg = "assignment expression cannot be used in a comprehension iterable expression"
+ for case, code in cases:
+ with self.subTest(case=case):
+ with self.assertRaisesRegex(SyntaxError, msg):
+ exec(code, {}) # Module scope
+ with self.assertRaisesRegex(SyntaxError, msg):
+ exec(code, {}, {}) # Class scope
+ with self.assertRaisesRegex(SyntaxError, msg):
+ exec(f"lambda: {code}", {}) # Function scope
+
class NamedExpressionAssignmentTest(unittest.TestCase):
@@ -271,6 +325,27 @@ class NamedExpressionAssignmentTest(unittest.TestCase):
fib = {(c := a): (a := b) + (b := a + c) - b for __ in range(6)}
self.assertEqual(fib, {1: 2, 2: 3, 3: 5, 5: 8, 8: 13, 13: 21})
+ def test_named_expression_assignment_17(self):
+ a = [1]
+ element = a[b:=0]
+ self.assertEqual(b, 0)
+ self.assertEqual(element, a[0])
+
+ def test_named_expression_assignment_18(self):
+ class TwoDimensionalList:
+ def __init__(self, two_dimensional_list):
+ self.two_dimensional_list = two_dimensional_list
+
+ def __getitem__(self, index):
+ return self.two_dimensional_list[index[0]][index[1]]
+
+ a = TwoDimensionalList([[1], [2]])
+ element = a[b:=0, c:=0]
+ self.assertEqual(b, 0)
+ self.assertEqual(c, 0)
+ self.assertEqual(element, a.two_dimensional_list[b][c])
+
+
class NamedExpressionScopeTest(unittest.TestCase):
@@ -513,6 +588,15 @@ spam()"""
self.assertEqual(nonlocal_var, None)
f()
+ def test_named_expression_scope_in_genexp(self):
+ a = 1
+ b = [1, 2, 3, 4]
+ genexp = (c := i + a for i in b)
+
+ self.assertNotIn("c", locals())
+ for idx, elem in enumerate(genexp):
+ self.assertEqual(elem, b[idx] + a)
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_netrc.py b/Lib/test/test_netrc.py
index 2bd46aa745..90ef5cd363 100644
--- a/Lib/test/test_netrc.py
+++ b/Lib/test/test_netrc.py
@@ -109,62 +109,56 @@ class NetrcTestCase(unittest.TestCase):
def test_security(self):
# This test is incomplete since we are normally not run as root and
# therefore can't test the file ownership being wrong.
- d = os_helper.TESTFN
- os.mkdir(d)
- self.addCleanup(os_helper.rmtree, d)
- fn = os.path.join(d, '.netrc')
- with open(fn, 'wt') as f:
- f.write("""\
- machine foo.domain.com login bar password pass
- default login foo password pass
- """)
- with os_helper.EnvironmentVarGuard() as environ:
- environ.set('HOME', d)
- os.chmod(fn, 0o600)
- nrc = netrc.netrc()
- self.assertEqual(nrc.hosts['foo.domain.com'],
- ('bar', None, 'pass'))
- os.chmod(fn, 0o622)
- self.assertRaises(netrc.NetrcParseError, netrc.netrc)
+ with os_helper.temp_cwd(None) as d:
+ fn = os.path.join(d, '.netrc')
+ with open(fn, 'wt') as f:
+ f.write("""\
+ machine foo.domain.com login bar password pass
+ default login foo password pass
+ """)
+ with os_helper.EnvironmentVarGuard() as environ:
+ environ.set('HOME', d)
+ os.chmod(fn, 0o600)
+ nrc = netrc.netrc()
+ self.assertEqual(nrc.hosts['foo.domain.com'],
+ ('bar', None, 'pass'))
+ os.chmod(fn, 0o622)
+ self.assertRaises(netrc.NetrcParseError, netrc.netrc)
def test_file_not_found_in_home(self):
- d = os_helper.TESTFN
- os.mkdir(d)
- self.addCleanup(os_helper.rmtree, d)
- with os_helper.EnvironmentVarGuard() as environ:
- environ.set('HOME', d)
- self.assertRaises(FileNotFoundError, netrc.netrc)
+ with os_helper.temp_cwd(None) as d:
+ with os_helper.EnvironmentVarGuard() as environ:
+ environ.set('HOME', d)
+ self.assertRaises(FileNotFoundError, netrc.netrc)
def test_file_not_found_explicit(self):
self.assertRaises(FileNotFoundError, netrc.netrc,
file='unlikely_netrc')
def test_home_not_set(self):
- fake_home = os_helper.TESTFN
- os.mkdir(fake_home)
- self.addCleanup(os_helper.rmtree, fake_home)
- fake_netrc_path = os.path.join(fake_home, '.netrc')
- with open(fake_netrc_path, 'w') as f:
- f.write('machine foo.domain.com login bar password pass')
- os.chmod(fake_netrc_path, 0o600)
-
- orig_expanduser = os.path.expanduser
- called = []
-
- def fake_expanduser(s):
- called.append(s)
- with os_helper.EnvironmentVarGuard() as environ:
- environ.set('HOME', fake_home)
- environ.set('USERPROFILE', fake_home)
- result = orig_expanduser(s)
- return result
-
- with support.swap_attr(os.path, 'expanduser', fake_expanduser):
- nrc = netrc.netrc()
- login, account, password = nrc.authenticators('foo.domain.com')
- self.assertEqual(login, 'bar')
-
- self.assertTrue(called)
+ with os_helper.temp_cwd(None) as fake_home:
+ fake_netrc_path = os.path.join(fake_home, '.netrc')
+ with open(fake_netrc_path, 'w') as f:
+ f.write('machine foo.domain.com login bar password pass')
+ os.chmod(fake_netrc_path, 0o600)
+
+ orig_expanduser = os.path.expanduser
+ called = []
+
+ def fake_expanduser(s):
+ called.append(s)
+ with os_helper.EnvironmentVarGuard() as environ:
+ environ.set('HOME', fake_home)
+ environ.set('USERPROFILE', fake_home)
+ result = orig_expanduser(s)
+ return result
+
+ with support.swap_attr(os.path, 'expanduser', fake_expanduser):
+ nrc = netrc.netrc()
+ login, account, password = nrc.authenticators('foo.domain.com')
+ self.assertEqual(login, 'bar')
+
+ self.assertTrue(called)
if __name__ == "__main__":
diff --git a/Lib/test/test_opcache.py b/Lib/test/test_opcache.py
new file mode 100644
index 0000000000..61f337d70e
--- /dev/null
+++ b/Lib/test/test_opcache.py
@@ -0,0 +1,23 @@
+import unittest
+
+class TestLoadAttrCache(unittest.TestCase):
+ def test_descriptor_added_after_optimization(self):
+ class Descriptor:
+ pass
+
+ class C:
+ def __init__(self):
+ self.x = 1
+ x = Descriptor()
+
+ def f(o):
+ return o.x
+
+ o = C()
+ for i in range(1025):
+ assert f(o) == 1
+
+ Descriptor.__get__ = lambda self, instance, value: 2
+ Descriptor.__set__ = lambda *args: None
+
+ self.assertEqual(f(o), 2)
diff --git a/Lib/test/test_opcodes.py b/Lib/test/test_opcodes.py
index 1152eb65bb..e510364721 100644
--- a/Lib/test/test_opcodes.py
+++ b/Lib/test/test_opcodes.py
@@ -27,7 +27,7 @@ class OpcodeTest(unittest.TestCase):
with open(ann_module.__file__) as f:
txt = f.read()
co = compile(txt, ann_module.__file__, 'exec')
- self.assertEqual(co.co_firstlineno, 3)
+ self.assertEqual(co.co_firstlineno, 1)
except OSError:
pass
diff --git a/Lib/test/test_ordered_dict.py b/Lib/test/test_ordered_dict.py
index 31759f20d2..eb404463e9 100644
--- a/Lib/test/test_ordered_dict.py
+++ b/Lib/test/test_ordered_dict.py
@@ -700,6 +700,17 @@ class OrderedDictTests:
with self.assertRaises(ValueError):
a |= "BAD"
+ @support.cpython_only
+ def test_ordered_dict_items_result_gc(self):
+ # bpo-42536: OrderedDict.items's tuple-reuse speed trick breaks the GC's
+ # assumptions about what can be untracked. Make sure we re-track result
+ # tuples whenever we reuse them.
+ it = iter(self.OrderedDict({None: []}).items())
+ gc.collect()
+ # That GC collection probably untracked the recycled internal result
+ # tuple, which is initialized to (None, None). Make sure it's re-tracked
+ # when it's mutated and returned from __next__:
+ self.assertTrue(gc.is_tracked(next(it)))
class PurePythonOrderedDictTests(OrderedDictTests, unittest.TestCase):
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 5126c84cf3..08d7ab8a30 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -15,10 +15,12 @@ import locale
import mmap
import os
import pickle
+import select
import shutil
import signal
import socket
import stat
+import struct
import subprocess
import sys
import sysconfig
@@ -59,6 +61,7 @@ try:
except ImportError:
INT_MAX = PY_SSIZE_T_MAX = sys.maxsize
+
from test.support.script_helper import assert_python_ok
from test.support import unix_shell
from test.support.os_helper import FakePath
@@ -90,6 +93,11 @@ def create_file(filename, content=b'content'):
fp.write(content)
+# bpo-41625: On AIX, splice() only works with a socket, not with a pipe.
+requires_splice_pipe = unittest.skipIf(sys.platform.startswith("aix"),
+ 'on AIX, splice() only accepts sockets')
+
+
class MiscTests(unittest.TestCase):
def test_getcwd(self):
cwd = os.getcwd()
@@ -108,6 +116,10 @@ class MiscTests(unittest.TestCase):
# than MAX_PATH if long paths support is disabled:
# see RtlAreLongPathsEnabled().
min_len = 2000 # characters
+ # On VxWorks, PATH_MAX is defined as 1024 bytes. Creating a path
+ # longer than PATH_MAX will fail.
+ if sys.platform == 'vxworks':
+ min_len = 1000
dirlen = 200 # characters
dirname = 'python_test_dir_'
dirname = dirname + ('a' * (dirlen - len(dirname)))
@@ -378,6 +390,126 @@ class FileTests(unittest.TestCase):
self.assertEqual(read[out_seek:],
data[in_skip:in_skip+i])
+ @unittest.skipUnless(hasattr(os, 'splice'), 'test needs os.splice()')
+ def test_splice_invalid_values(self):
+ with self.assertRaises(ValueError):
+ os.splice(0, 1, -10)
+
+ @unittest.skipUnless(hasattr(os, 'splice'), 'test needs os.splice()')
+ @requires_splice_pipe
+ def test_splice(self):
+ TESTFN2 = os_helper.TESTFN + ".3"
+ data = b'0123456789'
+
+ create_file(os_helper.TESTFN, data)
+ self.addCleanup(os_helper.unlink, os_helper.TESTFN)
+
+ in_file = open(os_helper.TESTFN, 'rb')
+ self.addCleanup(in_file.close)
+ in_fd = in_file.fileno()
+
+ read_fd, write_fd = os.pipe()
+ self.addCleanup(lambda: os.close(read_fd))
+ self.addCleanup(lambda: os.close(write_fd))
+
+ try:
+ i = os.splice(in_fd, write_fd, 5)
+ except OSError as e:
+ # Handle the case in which Python was compiled
+ # in a system with the syscall but without support
+ # in the kernel.
+ if e.errno != errno.ENOSYS:
+ raise
+ self.skipTest(e)
+ else:
+ # The number of copied bytes can be less than
+ # the number of bytes originally requested.
+ self.assertIn(i, range(0, 6));
+
+ self.assertEqual(os.read(read_fd, 100), data[:i])
+
+ @unittest.skipUnless(hasattr(os, 'splice'), 'test needs os.splice()')
+ @requires_splice_pipe
+ def test_splice_offset_in(self):
+ TESTFN4 = os_helper.TESTFN + ".4"
+ data = b'0123456789'
+ bytes_to_copy = 6
+ in_skip = 3
+
+ create_file(os_helper.TESTFN, data)
+ self.addCleanup(os_helper.unlink, os_helper.TESTFN)
+
+ in_file = open(os_helper.TESTFN, 'rb')
+ self.addCleanup(in_file.close)
+ in_fd = in_file.fileno()
+
+ read_fd, write_fd = os.pipe()
+ self.addCleanup(lambda: os.close(read_fd))
+ self.addCleanup(lambda: os.close(write_fd))
+
+ try:
+ i = os.splice(in_fd, write_fd, bytes_to_copy, offset_src=in_skip)
+ except OSError as e:
+ # Handle the case in which Python was compiled
+ # in a system with the syscall but without support
+ # in the kernel.
+ if e.errno != errno.ENOSYS:
+ raise
+ self.skipTest(e)
+ else:
+ # The number of copied bytes can be less than
+ # the number of bytes originally requested.
+ self.assertIn(i, range(0, bytes_to_copy+1));
+
+ read = os.read(read_fd, 100)
+ # 012 are skipped (in_skip)
+ # 345678 are copied in the file (in_skip + bytes_to_copy)
+ self.assertEqual(read, data[in_skip:in_skip+i])
+
+ @unittest.skipUnless(hasattr(os, 'splice'), 'test needs os.splice()')
+ @requires_splice_pipe
+ def test_splice_offset_out(self):
+ TESTFN4 = os_helper.TESTFN + ".4"
+ data = b'0123456789'
+ bytes_to_copy = 6
+ out_seek = 3
+
+ create_file(os_helper.TESTFN, data)
+ self.addCleanup(os_helper.unlink, os_helper.TESTFN)
+
+ read_fd, write_fd = os.pipe()
+ self.addCleanup(lambda: os.close(read_fd))
+ self.addCleanup(lambda: os.close(write_fd))
+ os.write(write_fd, data)
+
+ out_file = open(TESTFN4, 'w+b')
+ self.addCleanup(os_helper.unlink, TESTFN4)
+ self.addCleanup(out_file.close)
+ out_fd = out_file.fileno()
+
+ try:
+ i = os.splice(read_fd, out_fd, bytes_to_copy, offset_dst=out_seek)
+ except OSError as e:
+ # Handle the case in which Python was compiled
+ # in a system with the syscall but without support
+ # in the kernel.
+ if e.errno != errno.ENOSYS:
+ raise
+ self.skipTest(e)
+ else:
+ # The number of copied bytes can be less than
+ # the number of bytes originally requested.
+ self.assertIn(i, range(0, bytes_to_copy+1));
+
+ with open(TESTFN4, 'rb') as in_file:
+ read = in_file.read()
+ # seeked bytes (5) are zero'ed
+ self.assertEqual(read[:out_seek], b'\x00'*out_seek)
+ # 012 are skipped (in_skip)
+ # 345678 are copied in the file (in_skip + bytes_to_copy)
+ self.assertEqual(read[out_seek:], data[:i])
+
+
# Test attributes on return values from os.*stat* family.
class StatAttributeTests(unittest.TestCase):
def setUp(self):
@@ -859,6 +991,7 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
# Bug 1110478
@unittest.skipUnless(unix_shell and os.path.exists(unix_shell),
'requires a shell')
+ @unittest.skipUnless(hasattr(os, 'popen'), "needs os.popen()")
def test_update2(self):
os.environ.clear()
os.environ.update(HELLO="World")
@@ -868,6 +1001,7 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
@unittest.skipUnless(unix_shell and os.path.exists(unix_shell),
'requires a shell')
+ @unittest.skipUnless(hasattr(os, 'popen'), "needs os.popen()")
def test_os_popen_iter(self):
with os.popen("%s -c 'echo \"line1\nline2\nline3\"'"
% unix_shell) as popen:
@@ -3528,6 +3662,89 @@ class MemfdCreateTests(unittest.TestCase):
self.assertFalse(os.get_inheritable(fd2))
+@unittest.skipUnless(hasattr(os, 'eventfd'), 'requires os.eventfd')
+@support.requires_linux_version(2, 6, 30)
+class EventfdTests(unittest.TestCase):
+ def test_eventfd_initval(self):
+ def pack(value):
+ """Pack as native uint64_t
+ """
+ return struct.pack("@Q", value)
+ size = 8 # read/write 8 bytes
+ initval = 42
+ fd = os.eventfd(initval)
+ self.assertNotEqual(fd, -1)
+ self.addCleanup(os.close, fd)
+ self.assertFalse(os.get_inheritable(fd))
+
+ # test with raw read/write
+ res = os.read(fd, size)
+ self.assertEqual(res, pack(initval))
+
+ os.write(fd, pack(23))
+ res = os.read(fd, size)
+ self.assertEqual(res, pack(23))
+
+ os.write(fd, pack(40))
+ os.write(fd, pack(2))
+ res = os.read(fd, size)
+ self.assertEqual(res, pack(42))
+
+ # test with eventfd_read/eventfd_write
+ os.eventfd_write(fd, 20)
+ os.eventfd_write(fd, 3)
+ res = os.eventfd_read(fd)
+ self.assertEqual(res, 23)
+
+ def test_eventfd_semaphore(self):
+ initval = 2
+ flags = os.EFD_CLOEXEC | os.EFD_SEMAPHORE | os.EFD_NONBLOCK
+ fd = os.eventfd(initval, flags)
+ self.assertNotEqual(fd, -1)
+ self.addCleanup(os.close, fd)
+
+ # semaphore starts has initval 2, two reads return '1'
+ res = os.eventfd_read(fd)
+ self.assertEqual(res, 1)
+ res = os.eventfd_read(fd)
+ self.assertEqual(res, 1)
+ # third read would block
+ with self.assertRaises(BlockingIOError):
+ os.eventfd_read(fd)
+ with self.assertRaises(BlockingIOError):
+ os.read(fd, 8)
+
+ # increase semaphore counter, read one
+ os.eventfd_write(fd, 1)
+ res = os.eventfd_read(fd)
+ self.assertEqual(res, 1)
+ # next read would block, too
+ with self.assertRaises(BlockingIOError):
+ os.eventfd_read(fd)
+
+ def test_eventfd_select(self):
+ flags = os.EFD_CLOEXEC | os.EFD_NONBLOCK
+ fd = os.eventfd(0, flags)
+ self.assertNotEqual(fd, -1)
+ self.addCleanup(os.close, fd)
+
+ # counter is zero, only writeable
+ rfd, wfd, xfd = select.select([fd], [fd], [fd], 0)
+ self.assertEqual((rfd, wfd, xfd), ([], [fd], []))
+
+ # counter is non-zero, read and writeable
+ os.eventfd_write(fd, 23)
+ rfd, wfd, xfd = select.select([fd], [fd], [fd], 0)
+ self.assertEqual((rfd, wfd, xfd), ([fd], [fd], []))
+ self.assertEqual(os.eventfd_read(fd), 23)
+
+ # counter at max, only readable
+ os.eventfd_write(fd, (2**64) - 2)
+ rfd, wfd, xfd = select.select([fd], [fd], [fd], 0)
+ self.assertEqual((rfd, wfd, xfd), ([fd], [], []))
+ os.eventfd_read(fd)
+
+
class OSErrorTests(unittest.TestCase):
def setUp(self):
class Str(str):
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index 17292dc1ab..9be72941d3 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -440,9 +440,18 @@ class _BasePurePathTest(object):
self.assertEqual(par[0], P('a/b'))
self.assertEqual(par[1], P('a'))
self.assertEqual(par[2], P('.'))
+ self.assertEqual(par[-1], P('.'))
+ self.assertEqual(par[-2], P('a'))
+ self.assertEqual(par[-3], P('a/b'))
+ self.assertEqual(par[0:1], (P('a/b'),))
+ self.assertEqual(par[:2], (P('a/b'), P('a')))
+ self.assertEqual(par[:-1], (P('a/b'), P('a')))
+ self.assertEqual(par[1:], (P('a'), P('.')))
+ self.assertEqual(par[::2], (P('a/b'), P('.')))
+ self.assertEqual(par[::-1], (P('.'), P('a'), P('a/b')))
self.assertEqual(list(par), [P('a/b'), P('a'), P('.')])
with self.assertRaises(IndexError):
- par[-1]
+ par[-4]
with self.assertRaises(IndexError):
par[3]
with self.assertRaises(TypeError):
@@ -454,6 +463,12 @@ class _BasePurePathTest(object):
self.assertEqual(par[0], P('/a/b'))
self.assertEqual(par[1], P('/a'))
self.assertEqual(par[2], P('/'))
+ self.assertEqual(par[0:1], (P('/a/b'),))
+ self.assertEqual(par[:2], (P('/a/b'), P('/a')))
+ self.assertEqual(par[:-1], (P('/a/b'), P('/a')))
+ self.assertEqual(par[1:], (P('/a'), P('/')))
+ self.assertEqual(par[::2], (P('/a/b'), P('/')))
+ self.assertEqual(par[::-1], (P('/'), P('/a'), P('/a/b')))
self.assertEqual(list(par), [P('/a/b'), P('/a'), P('/')])
with self.assertRaises(IndexError):
par[3]
@@ -905,6 +920,12 @@ class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase):
self.assertEqual(len(par), 2)
self.assertEqual(par[0], P('z:a'))
self.assertEqual(par[1], P('z:'))
+ self.assertEqual(par[0:1], (P('z:a'),))
+ self.assertEqual(par[:-1], (P('z:a'),))
+ self.assertEqual(par[:2], (P('z:a'), P('z:')))
+ self.assertEqual(par[1:], (P('z:'),))
+ self.assertEqual(par[::2], (P('z:a'),))
+ self.assertEqual(par[::-1], (P('z:'), P('z:a')))
self.assertEqual(list(par), [P('z:a'), P('z:')])
with self.assertRaises(IndexError):
par[2]
@@ -913,6 +934,12 @@ class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase):
self.assertEqual(len(par), 2)
self.assertEqual(par[0], P('z:/a'))
self.assertEqual(par[1], P('z:/'))
+ self.assertEqual(par[0:1], (P('z:/a'),))
+ self.assertEqual(par[0:-1], (P('z:/a'),))
+ self.assertEqual(par[:2], (P('z:/a'), P('z:/')))
+ self.assertEqual(par[1:], (P('z:/'),))
+ self.assertEqual(par[::2], (P('z:/a'),))
+ self.assertEqual(par[::-1], (P('z:/'), P('z:/a'),))
self.assertEqual(list(par), [P('z:/a'), P('z:/')])
with self.assertRaises(IndexError):
par[2]
@@ -921,6 +948,12 @@ class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase):
self.assertEqual(len(par), 2)
self.assertEqual(par[0], P('//a/b/c'))
self.assertEqual(par[1], P('//a/b'))
+ self.assertEqual(par[0:1], (P('//a/b/c'),))
+ self.assertEqual(par[0:-1], (P('//a/b/c'),))
+ self.assertEqual(par[:2], (P('//a/b/c'), P('//a/b')))
+ self.assertEqual(par[1:], (P('//a/b'),))
+ self.assertEqual(par[::2], (P('//a/b/c'),))
+ self.assertEqual(par[::-1], (P('//a/b'), P('//a/b/c')))
self.assertEqual(list(par), [P('//a/b/c'), P('//a/b')])
with self.assertRaises(IndexError):
par[2]
@@ -2186,6 +2219,8 @@ class _BasePathTest(object):
self.assertIs((P / 'fileA\x00').is_fifo(), False)
@unittest.skipUnless(hasattr(os, "mkfifo"), "os.mkfifo() required")
+ @unittest.skipIf(sys.platform == "vxworks",
+ "fifo requires special path on VxWorks")
def test_is_fifo_true(self):
P = self.cls(BASE, 'myfifo')
try:
@@ -2432,6 +2467,8 @@ class PosixPathTest(_BasePathTest, unittest.TestCase):
@unittest.skipUnless(hasattr(pwd, 'getpwall'),
'pwd module does not expose getpwall()')
+ @unittest.skipIf(sys.platform == "vxworks",
+ "no home directory on VxWorks")
def test_expanduser(self):
P = self.cls
import_helper.import_module('pwd')
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index e56451360d..4bb574fc5b 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -1645,9 +1645,10 @@ def bœr():
'debug doesnotexist',
'c',
])
- stdout, _ = self.run_pdb_script('', commands + '\n')
+ stdout, _ = self.run_pdb_script('pass', commands + '\n')
self.assertEqual(stdout.splitlines()[1:], [
+ '-> pass',
'(Pdb) *** SyntaxError: unexpected EOF while parsing',
'(Pdb) ENTERING RECURSIVE DEBUGGER',
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index 92a82cc54f..4034154e4d 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -409,21 +409,6 @@ class TestTranforms(BytecodeTestCase):
self.assertLessEqual(len(returns), 6)
self.check_lnotab(f)
- def test_elim_jump_after_return2(self):
- # Eliminate dead code: jumps immediately after returns can't be reached
- def f(cond1, cond2):
- while 1:
- if cond1: return 4
- self.assertNotInBytecode(f, 'JUMP_FORWARD')
- # There should be one jump for the while loop.
- jumps = [instr for instr in dis.get_instructions(f)
- if 'JUMP' in instr.opname]
- self.assertEqual(len(jumps), 1)
- returns = [instr for instr in dis.get_instructions(f)
- if instr.opname == 'RETURN_VALUE']
- self.assertLessEqual(len(returns), 2)
- self.check_lnotab(f)
-
def test_make_function_doesnt_bail(self):
def f():
def g()->1+1:
diff --git a/Lib/test/test_peg_generator/test_c_parser.py b/Lib/test/test_peg_generator/test_c_parser.py
index 0dffedca78..67bb851211 100644
--- a/Lib/test/test_peg_generator/test_c_parser.py
+++ b/Lib/test/test_peg_generator/test_c_parser.py
@@ -1,3 +1,4 @@
+import sysconfig
import textwrap
import unittest
from distutils.tests.support import TempdirManager
@@ -8,6 +9,11 @@ from test import support
from test.support import os_helper
from test.support.script_helper import assert_python_ok
+_py_cflags_nodist = sysconfig.get_config_var('PY_CFLAGS_NODIST')
+_pgo_flag = sysconfig.get_config_var('PGO_PROF_USE_FLAG')
+if _pgo_flag and _py_cflags_nodist and _pgo_flag in _py_cflags_nodist:
+ raise unittest.SkipTest("peg_generator test disabled under PGO build")
+
test_tools.skip_if_missing("peg_generator")
with test_tools.imports_under_tool("peg_generator"):
from pegen.grammar_parser import GeneratedParser as GrammarParser
diff --git a/Lib/test/test_peg_generator/test_grammar_validator.py b/Lib/test/test_peg_generator/test_grammar_validator.py
new file mode 100644
index 0000000000..2e72ff8df2
--- /dev/null
+++ b/Lib/test/test_peg_generator/test_grammar_validator.py
@@ -0,0 +1,51 @@
+import unittest
+from test import test_tools
+
+test_tools.skip_if_missing('peg_generator')
+with test_tools.imports_under_tool('peg_generator'):
+ from pegen.grammar_parser import GeneratedParser as GrammarParser
+ from pegen.validator import SubRuleValidator, ValidationError
+ from pegen.testutil import parse_string
+ from pegen.grammar import Grammar
+
+
+class TestPegen(unittest.TestCase):
+ def test_rule_with_no_collision(self) -> None:
+ grammar_source = """
+ start: bad_rule
+ sum:
+ | NAME '-' NAME
+ | NAME '+' NAME
+ """
+ grammar: Grammar = parse_string(grammar_source, GrammarParser)
+ validator = SubRuleValidator(grammar)
+ for rule_name, rule in grammar.rules.items():
+ validator.validate_rule(rule_name, rule)
+
+ def test_rule_with_simple_collision(self) -> None:
+ grammar_source = """
+ start: bad_rule
+ sum:
+ | NAME '+' NAME
+ | NAME '+' NAME ';'
+ """
+ grammar: Grammar = parse_string(grammar_source, GrammarParser)
+ validator = SubRuleValidator(grammar)
+ with self.assertRaises(ValidationError):
+ for rule_name, rule in grammar.rules.items():
+ validator.validate_rule(rule_name, rule)
+
+ def test_rule_with_collision_after_some_other_rules(self) -> None:
+ grammar_source = """
+ start: bad_rule
+ sum:
+ | NAME '+' NAME
+ | NAME '*' NAME ';'
+ | NAME '-' NAME
+ | NAME '+' NAME ';'
+ """
+ grammar: Grammar = parse_string(grammar_source, GrammarParser)
+ validator = SubRuleValidator(grammar)
+ with self.assertRaises(ValidationError):
+ for rule_name, rule in grammar.rules.items():
+ validator.validate_rule(rule_name, rule)
diff --git a/Lib/test/test_pipes.py b/Lib/test/test_pipes.py
index 7d8cd54ba0..6a13b36d1c 100644
--- a/Lib/test/test_pipes.py
+++ b/Lib/test/test_pipes.py
@@ -3,13 +3,16 @@ import os
import string
import unittest
import shutil
-from test.support import run_unittest, reap_children
+from test.support import run_unittest, reap_children, unix_shell
from test.support.os_helper import TESTFN, unlink
if os.name != 'posix':
raise unittest.SkipTest('pipes module only works on posix')
+if not (unix_shell and os.path.exists(unix_shell)):
+ raise unittest.SkipTest('pipes module requires a shell')
+
TESTFN2 = TESTFN + "2"
# tr a-z A-Z is not portable, so make the ranges explicit
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index b5d21e5461..2c6fbee8b6 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -8,12 +8,70 @@ from unittest import mock
from test import support
from test.support import os_helper
+FEDORA_OS_RELEASE = """\
+NAME=Fedora
+VERSION="32 (Thirty Two)"
+ID=fedora
+VERSION_ID=32
+VERSION_CODENAME=""
+PLATFORM_ID="platform:f32"
+PRETTY_NAME="Fedora 32 (Thirty Two)"
+ANSI_COLOR="0;34"
+LOGO=fedora-logo-icon
+CPE_NAME="cpe:/o:fedoraproject:fedora:32"
+HOME_URL="https://fedoraproject.org/"
+DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/"
+SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
+BUG_REPORT_URL="https://bugzilla.redhat.com/"
+REDHAT_BUGZILLA_PRODUCT="Fedora"
+REDHAT_BUGZILLA_PRODUCT_VERSION=32
+REDHAT_SUPPORT_PRODUCT="Fedora"
+REDHAT_SUPPORT_PRODUCT_VERSION=32
+PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
+"""
+
+UBUNTU_OS_RELEASE = """\
+NAME="Ubuntu"
+VERSION="20.04.1 LTS (Focal Fossa)"
+ID=ubuntu
+ID_LIKE=debian
+PRETTY_NAME="Ubuntu 20.04.1 LTS"
+VERSION_ID="20.04"
+HOME_URL="https://www.ubuntu.com/"
+SUPPORT_URL="https://help.ubuntu.com/"
+BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
+PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
+VERSION_CODENAME=focal
+UBUNTU_CODENAME=focal
+"""
+
+TEST_OS_RELEASE = r"""
+# test data
+ID_LIKE="egg spam viking"
+EMPTY=
+# comments and empty lines are ignored
+
+SINGLE_QUOTE='single'
+EMPTY_SINGLE=''
+DOUBLE_QUOTE="double"
+EMPTY_DOUBLE=""
+QUOTES="double\'s"
+SPECIALS="\$\`\\\'\""
+# invalid lines
+=invalid
+=
+INVALID
+IN-VALID=value
+IN VALID=value
+"""
+
class PlatformTest(unittest.TestCase):
def clear_caches(self):
platform._platform_cache.clear()
platform._sys_version_cache.clear()
platform._uname_cache = None
+ platform._os_release_cache = None
def test_architecture(self):
res = platform.architecture()
@@ -238,7 +296,10 @@ class PlatformTest(unittest.TestCase):
# On Snow Leopard, sw_vers reports 10.6.0 as 10.6
if len_diff > 0:
expect_list.extend(['0'] * len_diff)
- self.assertEqual(result_list, expect_list)
+ # For compatibility with older binaries, macOS 11.x may report
+ # itself as '10.16' rather than '11.x.y'.
+ if result_list != ['10', '16']:
+ self.assertEqual(result_list, expect_list)
# res[1] claims to contain
# (version, dev_stage, non_release_version)
@@ -246,7 +307,7 @@ class PlatformTest(unittest.TestCase):
self.assertEqual(res[1], ('', '', ''))
if sys.byteorder == 'little':
- self.assertIn(res[2], ('i386', 'x86_64'))
+ self.assertIn(res[2], ('i386', 'x86_64', 'arm64'))
else:
self.assertEqual(res[2], 'PowerPC')
@@ -379,6 +440,54 @@ class PlatformTest(unittest.TestCase):
self.assertEqual(platform.platform(terse=1), expected_terse)
self.assertEqual(platform.platform(), expected)
+ def test_freedesktop_os_release(self):
+ self.addCleanup(self.clear_caches)
+ self.clear_caches()
+
+ if any(os.path.isfile(fn) for fn in platform._os_release_candidates):
+ info = platform.freedesktop_os_release()
+ self.assertIn("NAME", info)
+ self.assertIn("ID", info)
+
+ info["CPYTHON_TEST"] = "test"
+ self.assertNotIn(
+ "CPYTHON_TEST",
+ platform.freedesktop_os_release()
+ )
+ else:
+ with self.assertRaises(OSError):
+ platform.freedesktop_os_release()
+
+ def test_parse_os_release(self):
+ info = platform._parse_os_release(FEDORA_OS_RELEASE.splitlines())
+ self.assertEqual(info["NAME"], "Fedora")
+ self.assertEqual(info["ID"], "fedora")
+ self.assertNotIn("ID_LIKE", info)
+ self.assertEqual(info["VERSION_CODENAME"], "")
+
+ info = platform._parse_os_release(UBUNTU_OS_RELEASE.splitlines())
+ self.assertEqual(info["NAME"], "Ubuntu")
+ self.assertEqual(info["ID"], "ubuntu")
+ self.assertEqual(info["ID_LIKE"], "debian")
+ self.assertEqual(info["VERSION_CODENAME"], "focal")
+
+ info = platform._parse_os_release(TEST_OS_RELEASE.splitlines())
+ expected = {
+ "ID": "linux",
+ "NAME": "Linux",
+ "PRETTY_NAME": "Linux",
+ "ID_LIKE": "egg spam viking",
+ "EMPTY": "",
+ "DOUBLE_QUOTE": "double",
+ "EMPTY_DOUBLE": "",
+ "SINGLE_QUOTE": "single",
+ "EMPTY_SINGLE": "",
+ "QUOTES": "double's",
+ "SPECIALS": "$`\\'\"",
+ }
+ self.assertEqual(info, expected)
+ self.assertEqual(len(info["SPECIALS"]), 5)
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py
index ab1bc77655..cac2f6177f 100644
--- a/Lib/test/test_popen.py
+++ b/Lib/test/test_popen.py
@@ -7,6 +7,9 @@ import unittest
from test import support
import os, sys
+if not hasattr(os, 'popen'):
+ raise unittest.SkipTest("need os.popen()")
+
# Test that command-lines get down as we expect.
# To do this we execute:
# python -c "import sys;print(sys.argv)" {rest_of_commandline}
diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py
index 2ac345ddd6..548868362a 100644
--- a/Lib/test/test_poplib.py
+++ b/Lib/test/test_poplib.py
@@ -501,7 +501,7 @@ class TestTimeouts(TestCase):
conn, addr = serv.accept()
conn.send(b"+ Hola mundo\n")
conn.close()
- except socket.timeout:
+ except TimeoutError:
pass
finally:
serv.close()
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index f57c88234b..588c86994b 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -642,12 +642,17 @@ class PosixTester(unittest.TestCase):
@unittest.skipUnless(hasattr(posix, 'mkfifo'), "don't have mkfifo()")
def test_mkfifo(self):
- os_helper.unlink(os_helper.TESTFN)
+ if sys.platform == "vxworks":
+ fifo_path = os.path.join("/fifos/", os_helper.TESTFN)
+ else:
+ fifo_path = os_helper.TESTFN
+ os_helper.unlink(fifo_path)
+ self.addCleanup(os_helper.unlink, fifo_path)
try:
- posix.mkfifo(os_helper.TESTFN, stat.S_IRUSR | stat.S_IWUSR)
+ posix.mkfifo(fifo_path, stat.S_IRUSR | stat.S_IWUSR)
except PermissionError as e:
self.skipTest('posix.mkfifo(): %s' % e)
- self.assertTrue(stat.S_ISFIFO(posix.stat(os_helper.TESTFN).st_mode))
+ self.assertTrue(stat.S_ISFIFO(posix.stat(fifo_path).st_mode))
@unittest.skipUnless(hasattr(posix, 'mknod') and hasattr(stat, 'S_IFIFO'),
"don't have mknod()/S_IFIFO")
@@ -719,11 +724,20 @@ class PosixTester(unittest.TestCase):
chown_func(first_param, uid, -1)
check_stat(uid, gid)
- if uid == 0:
+ if sys.platform == "vxworks":
+ # On VxWorks, root user id is 1 and 0 means no login user:
+ # both are super users.
+ is_root = (uid in (0, 1))
+ else:
+ is_root = (uid == 0)
+ if is_root:
# Try an amusingly large uid/gid to make sure we handle
# large unsigned values. (chown lets you use any
# uid/gid you like, even if they aren't defined.)
#
+ # On VxWorks uid_t is defined as unsigned short. A big
+ # value greater than 65535 will result in underflow error.
+ #
# This problem keeps coming up:
# http://bugs.python.org/issue1747858
# http://bugs.python.org/issue4591
@@ -733,7 +747,7 @@ class PosixTester(unittest.TestCase):
# This part of the test only runs when run as root.
# Only scary people run their tests as root.
- big_value = 2**31
+ big_value = (2**31 if sys.platform != "vxworks" else 2**15)
chown_func(first_param, big_value, big_value)
check_stat(big_value, big_value)
chown_func(first_param, -1, -1)
@@ -1040,6 +1054,7 @@ class PosixTester(unittest.TestCase):
@unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()")
+ @unittest.skipUnless(hasattr(os, 'popen'), "test needs os.popen()")
def test_getgroups(self):
with os.popen('id -G 2>/dev/null') as idg:
groups = idg.read().strip()
@@ -1056,7 +1071,7 @@ class PosixTester(unittest.TestCase):
if sys.platform == 'darwin':
import sysconfig
dt = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') or '10.0'
- if tuple(int(n) for n in dt.split('.')[0:2]) < (10, 6):
+ if tuple(int(n) for n in str(dt).split('.')[0:2]) < (10, 6):
raise unittest.SkipTest("getgroups(2) is broken prior to 10.6")
# 'id -G' and 'os.getgroups()' should return the same
@@ -1089,7 +1104,8 @@ class PosixTester(unittest.TestCase):
finally:
posix.close(f)
- @unittest.skipUnless(os.chown in os.supports_dir_fd, "test needs dir_fd support in os.chown()")
+ @unittest.skipUnless(hasattr(os, 'chown') and (os.chown in os.supports_dir_fd),
+ "test needs dir_fd support in os.chown()")
def test_chown_dir_fd(self):
os_helper.unlink(os_helper.TESTFN)
os_helper.create_empty_file(os_helper.TESTFN)
@@ -1184,7 +1200,9 @@ class PosixTester(unittest.TestCase):
posix.close(f)
os_helper.rmtree(os_helper.TESTFN + 'dir')
- @unittest.skipUnless((os.mknod in os.supports_dir_fd) and hasattr(stat, 'S_IFIFO'),
+ @unittest.skipUnless(hasattr(os, 'mknod')
+ and (os.mknod in os.supports_dir_fd)
+ and hasattr(stat, 'S_IFIFO'),
"test requires both stat.S_IFIFO and dir_fd support for os.mknod()")
def test_mknod_dir_fd(self):
# Test using mknodat() to create a FIFO (the only use specified
@@ -1217,7 +1235,8 @@ class PosixTester(unittest.TestCase):
posix.close(a)
posix.close(b)
- @unittest.skipUnless(os.readlink in os.supports_dir_fd, "test needs dir_fd support in os.readlink()")
+ @unittest.skipUnless(hasattr(os, 'readlink') and (os.readlink in os.supports_dir_fd),
+ "test needs dir_fd support in os.readlink()")
def test_readlink_dir_fd(self):
os.symlink(os_helper.TESTFN, os_helper.TESTFN + 'link')
f = posix.open(posix.getcwd(), posix.O_RDONLY)
@@ -1925,6 +1944,233 @@ class TestPosixSpawnP(unittest.TestCase, _PosixSpawnMixin):
assert_python_ok(*args, PATH=path)
+@unittest.skipUnless(sys.platform == "darwin", "test weak linking on macOS")
+class TestPosixWeaklinking(unittest.TestCase):
+ # These test cases verify that weak linking support on macOS works
+ # as expected. These cases only test new behaviour introduced by weak linking,
+ # regular behaviour is tested by the normal test cases.
+ #
+ # See the section on Weak Linking in Mac/README.txt for more information.
+ def setUp(self):
+ import sysconfig
+ import platform
+
+ config_vars = sysconfig.get_config_vars()
+ self.available = { nm for nm in config_vars if nm.startswith("HAVE_") and config_vars[nm] }
+ self.mac_ver = tuple(int(part) for part in platform.mac_ver()[0].split("."))
+
+ def _verify_available(self, name):
+ if name not in self.available:
+ raise unittest.SkipTest(f"{name} not weak-linked")
+
+ def test_pwritev(self):
+ self._verify_available("HAVE_PWRITEV")
+ if self.mac_ver >= (10, 16):
+ self.assertTrue(hasattr(os, "pwritev"), "os.pwritev is not available")
+ self.assertTrue(hasattr(os, "preadv"), "os.readv is not available")
+
+ else:
+ self.assertFalse(hasattr(os, "pwritev"), "os.pwritev is available")
+ self.assertFalse(hasattr(os, "preadv"), "os.readv is available")
+
+ def test_stat(self):
+ self._verify_available("HAVE_FSTATAT")
+ if self.mac_ver >= (10, 10):
+ self.assertIn("HAVE_FSTATAT", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_FSTATAT", posix._have_functions)
+
+ with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
+ os.stat("file", dir_fd=0)
+
+ def test_access(self):
+ self._verify_available("HAVE_FACCESSAT")
+ if self.mac_ver >= (10, 10):
+ self.assertIn("HAVE_FACCESSAT", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_FACCESSAT", posix._have_functions)
+
+ with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
+ os.access("file", os.R_OK, dir_fd=0)
+
+ with self.assertRaisesRegex(NotImplementedError, "follow_symlinks unavailable"):
+ os.access("file", os.R_OK, follow_symlinks=False)
+
+ with self.assertRaisesRegex(NotImplementedError, "effective_ids unavailable"):
+ os.access("file", os.R_OK, effective_ids=True)
+
+ def test_chmod(self):
+ self._verify_available("HAVE_FCHMODAT")
+ if self.mac_ver >= (10, 10):
+ self.assertIn("HAVE_FCHMODAT", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_FCHMODAT", posix._have_functions)
+ self.assertIn("HAVE_LCHMOD", posix._have_functions)
+
+ with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
+ os.chmod("file", 0o644, dir_fd=0)
+
+ def test_chown(self):
+ self._verify_available("HAVE_FCHOWNAT")
+ if self.mac_ver >= (10, 10):
+ self.assertIn("HAVE_FCHOWNAT", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_FCHOWNAT", posix._have_functions)
+ self.assertIn("HAVE_LCHOWN", posix._have_functions)
+
+ with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
+ os.chown("file", 0, 0, dir_fd=0)
+
+ def test_link(self):
+ self._verify_available("HAVE_LINKAT")
+ if self.mac_ver >= (10, 10):
+ self.assertIn("HAVE_LINKAT", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_LINKAT", posix._have_functions)
+
+ with self.assertRaisesRegex(NotImplementedError, "src_dir_fd unavailable"):
+ os.link("source", "target", src_dir_fd=0)
+
+ with self.assertRaisesRegex(NotImplementedError, "dst_dir_fd unavailable"):
+ os.link("source", "target", dst_dir_fd=0)
+
+ with self.assertRaisesRegex(NotImplementedError, "src_dir_fd unavailable"):
+ os.link("source", "target", src_dir_fd=0, dst_dir_fd=0)
+
+ # issue 41355: !HAVE_LINKAT code path ignores the follow_symlinks flag
+ with os_helper.temp_dir() as base_path:
+ link_path = os.path.join(base_path, "link")
+ target_path = os.path.join(base_path, "target")
+ source_path = os.path.join(base_path, "source")
+
+ with open(source_path, "w") as fp:
+ fp.write("data")
+
+ os.symlink("target", link_path)
+
+ # Calling os.link should fail in the link(2) call, and
+ # should not reject *follow_symlinks* (to match the
+ # behaviour you'd get when building on a platform without
+ # linkat)
+ with self.assertRaises(FileExistsError):
+ os.link(source_path, link_path, follow_symlinks=True)
+
+ with self.assertRaises(FileExistsError):
+ os.link(source_path, link_path, follow_symlinks=False)
+
+
+ def test_listdir_scandir(self):
+ self._verify_available("HAVE_FDOPENDIR")
+ if self.mac_ver >= (10, 10):
+ self.assertIn("HAVE_FDOPENDIR", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_FDOPENDIR", posix._have_functions)
+
+ with self.assertRaisesRegex(TypeError, "listdir: path should be string, bytes, os.PathLike or None, not int"):
+ os.listdir(0)
+
+ with self.assertRaisesRegex(TypeError, "scandir: path should be string, bytes, os.PathLike or None, not int"):
+ os.scandir(0)
+
+ def test_mkdir(self):
+ self._verify_available("HAVE_MKDIRAT")
+ if self.mac_ver >= (10, 10):
+ self.assertIn("HAVE_MKDIRAT", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_MKDIRAT", posix._have_functions)
+
+ with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
+ os.mkdir("dir", dir_fd=0)
+
+ def test_rename_replace(self):
+ self._verify_available("HAVE_RENAMEAT")
+ if self.mac_ver >= (10, 10):
+ self.assertIn("HAVE_RENAMEAT", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_RENAMEAT", posix._have_functions)
+
+ with self.assertRaisesRegex(NotImplementedError, "src_dir_fd and dst_dir_fd unavailable"):
+ os.rename("a", "b", src_dir_fd=0)
+
+ with self.assertRaisesRegex(NotImplementedError, "src_dir_fd and dst_dir_fd unavailable"):
+ os.rename("a", "b", dst_dir_fd=0)
+
+ with self.assertRaisesRegex(NotImplementedError, "src_dir_fd and dst_dir_fd unavailable"):
+ os.replace("a", "b", src_dir_fd=0)
+
+ with self.assertRaisesRegex(NotImplementedError, "src_dir_fd and dst_dir_fd unavailable"):
+ os.replace("a", "b", dst_dir_fd=0)
+
+ def test_unlink_rmdir(self):
+ self._verify_available("HAVE_UNLINKAT")
+ if self.mac_ver >= (10, 10):
+ self.assertIn("HAVE_UNLINKAT", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_UNLINKAT", posix._have_functions)
+
+ with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
+ os.unlink("path", dir_fd=0)
+
+ with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
+ os.rmdir("path", dir_fd=0)
+
+ def test_open(self):
+ self._verify_available("HAVE_OPENAT")
+ if self.mac_ver >= (10, 10):
+ self.assertIn("HAVE_OPENAT", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_OPENAT", posix._have_functions)
+
+ with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
+ os.open("path", os.O_RDONLY, dir_fd=0)
+
+ def test_readlink(self):
+ self._verify_available("HAVE_READLINKAT")
+ if self.mac_ver >= (10, 10):
+ self.assertIn("HAVE_READLINKAT", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_READLINKAT", posix._have_functions)
+
+ with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
+ os.readlink("path", dir_fd=0)
+
+ def test_symlink(self):
+ self._verify_available("HAVE_SYMLINKAT")
+ if self.mac_ver >= (10, 10):
+ self.assertIn("HAVE_SYMLINKAT", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_SYMLINKAT", posix._have_functions)
+
+ with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
+ os.symlink("a", "b", dir_fd=0)
+
+ def test_utime(self):
+ self._verify_available("HAVE_FUTIMENS")
+ self._verify_available("HAVE_UTIMENSAT")
+ if self.mac_ver >= (10, 13):
+ self.assertIn("HAVE_FUTIMENS", posix._have_functions)
+ self.assertIn("HAVE_UTIMENSAT", posix._have_functions)
+
+ else:
+ self.assertNotIn("HAVE_FUTIMENS", posix._have_functions)
+ self.assertNotIn("HAVE_UTIMENSAT", posix._have_functions)
+
+ with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
+ os.utime("path", dir_fd=0)
+
+
def test_main():
try:
support.run_unittest(
@@ -1932,6 +2178,7 @@ def test_main():
PosixGroupsTester,
TestPosixSpawn,
TestPosixSpawnP,
+ TestPosixWeaklinking
)
finally:
support.reap_children()
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index 42fd8ef8b1..e18d01f463 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -1,5 +1,6 @@
import os
import posixpath
+import sys
import unittest
from posixpath import realpath, abspath, dirname, basename
from test import test_genericpath
@@ -262,6 +263,8 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.expanduser("~/"), "/")
self.assertEqual(posixpath.expanduser("~/foo"), "/foo")
+ @unittest.skipIf(sys.platform == "vxworks",
+ "no home directory on VxWorks")
def test_expanduser_pwd(self):
pwd = import_helper.import_module('pwd')
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py
index 8ee18e8fef..c4a8578a9f 100644
--- a/Lib/test/test_pprint.py
+++ b/Lib/test/test_pprint.py
@@ -453,12 +453,23 @@ AdvancedNamespace(the=0,
dog=8)""")
def test_subclassing(self):
+ # length(repr(obj)) > width
o = {'names with spaces': 'should be presented using repr()',
'others.should.not.be': 'like.this'}
exp = """\
{'names with spaces': 'should be presented using repr()',
others.should.not.be: like.this}"""
- self.assertEqual(DottedPrettyPrinter().pformat(o), exp)
+
+ dotted_printer = DottedPrettyPrinter()
+ self.assertEqual(dotted_printer.pformat(o), exp)
+
+ # length(repr(obj)) < width
+ o1 = ['with space']
+ exp1 = "['with space']"
+ self.assertEqual(dotted_printer.pformat(o1), exp1)
+ o2 = ['without.space']
+ exp2 = "[without.space]"
+ self.assertEqual(dotted_printer.pformat(o2), exp2)
def test_set_reprs(self):
self.assertEqual(pprint.pformat(set()), 'set()')
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
index 7ca0557800..190d8d787a 100644
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -14,9 +14,21 @@ import socket
import io # readline
import unittest
+import struct
+import tty
+import fcntl
+import warnings
+
TEST_STRING_1 = b"I wish to buy a fish license.\n"
TEST_STRING_2 = b"For my pet fish, Eric.\n"
+try:
+ _TIOCGWINSZ = tty.TIOCGWINSZ
+ _TIOCSWINSZ = tty.TIOCSWINSZ
+ _HAVE_WINSZ = True
+except AttributeError:
+ _HAVE_WINSZ = False
+
if verbose:
def debug(msg):
print(msg)
@@ -60,6 +72,21 @@ def _readline(fd):
reader = io.FileIO(fd, mode='rb', closefd=False)
return reader.readline()
+def expectedFailureIfStdinIsTTY(fun):
+ # avoid isatty()
+ try:
+ tty.tcgetattr(pty.STDIN_FILENO)
+ return unittest.expectedFailure(fun)
+ except tty.error:
+ pass
+ return fun
+
+def _get_term_winsz(fd):
+ s = struct.pack("HHHH", 0, 0, 0, 0)
+ return fcntl.ioctl(fd, _TIOCGWINSZ, s)
+
+def _set_term_winsz(fd, winsz):
+ fcntl.ioctl(fd, _TIOCSWINSZ, winsz)
# Marginal testing of pty suite. Cannot do extensive 'do or fail' testing
@@ -78,6 +105,20 @@ class PtyTest(unittest.TestCase):
self.addCleanup(signal.alarm, 0)
signal.alarm(10)
+ # Save original stdin window size
+ self.stdin_rows = None
+ self.stdin_cols = None
+ if _HAVE_WINSZ:
+ try:
+ stdin_dim = os.get_terminal_size(pty.STDIN_FILENO)
+ self.stdin_rows = stdin_dim.lines
+ self.stdin_cols = stdin_dim.columns
+ old_stdin_winsz = struct.pack("HHHH", self.stdin_rows,
+ self.stdin_cols, 0, 0)
+ self.addCleanup(_set_term_winsz, pty.STDIN_FILENO, old_stdin_winsz)
+ except OSError:
+ pass
+
def handle_sig(self, sig, frame):
self.fail("isatty hung")
@@ -86,26 +127,70 @@ class PtyTest(unittest.TestCase):
# bpo-38547: if the process is the session leader, os.close(master_fd)
# of "master_fd, slave_name = pty.master_open()" raises SIGHUP
# signal: just ignore the signal.
+ #
+ # NOTE: the above comment is from an older version of the test;
+ # master_open() is not being used anymore.
pass
- def test_basic(self):
+ @expectedFailureIfStdinIsTTY
+ def test_openpty(self):
try:
- debug("Calling master_open()")
- master_fd, slave_name = pty.master_open()
- debug("Got master_fd '%d', slave_name '%s'" %
- (master_fd, slave_name))
- debug("Calling slave_open(%r)" % (slave_name,))
- slave_fd = pty.slave_open(slave_name)
- debug("Got slave_fd '%d'" % slave_fd)
+ mode = tty.tcgetattr(pty.STDIN_FILENO)
+ except tty.error:
+ # not a tty or bad/closed fd
+ debug("tty.tcgetattr(pty.STDIN_FILENO) failed")
+ mode = None
+
+ new_stdin_winsz = None
+ if self.stdin_rows != None and self.stdin_cols != None:
+ try:
+ # Modify pty.STDIN_FILENO window size; we need to
+ # check if pty.openpty() is able to set pty slave
+ # window size accordingly.
+ debug("Setting pty.STDIN_FILENO window size")
+ debug(f"original size: (rows={self.stdin_rows}, cols={self.stdin_cols})")
+ target_stdin_rows = self.stdin_rows + 1
+ target_stdin_cols = self.stdin_cols + 1
+ debug(f"target size: (rows={target_stdin_rows}, cols={target_stdin_cols})")
+ target_stdin_winsz = struct.pack("HHHH", target_stdin_rows,
+ target_stdin_cols, 0, 0)
+ _set_term_winsz(pty.STDIN_FILENO, target_stdin_winsz)
+
+ # Were we able to set the window size
+ # of pty.STDIN_FILENO successfully?
+ new_stdin_winsz = _get_term_winsz(pty.STDIN_FILENO)
+ self.assertEqual(new_stdin_winsz, target_stdin_winsz,
+ "pty.STDIN_FILENO window size unchanged")
+ except OSError:
+ warnings.warn("Failed to set pty.STDIN_FILENO window size")
+ pass
+
+ try:
+ debug("Calling pty.openpty()")
+ try:
+ master_fd, slave_fd = pty.openpty(mode, new_stdin_winsz)
+ except TypeError:
+ master_fd, slave_fd = pty.openpty()
+ debug(f"Got master_fd '{master_fd}', slave_fd '{slave_fd}'")
except OSError:
# " An optional feature could not be imported " ... ?
raise unittest.SkipTest("Pseudo-terminals (seemingly) not functional.")
- self.assertTrue(os.isatty(slave_fd), 'slave_fd is not a tty')
+ self.assertTrue(os.isatty(slave_fd), "slave_fd is not a tty")
+
+ if mode:
+ self.assertEqual(tty.tcgetattr(slave_fd), mode,
+ "openpty() failed to set slave termios")
+ if new_stdin_winsz:
+ self.assertEqual(_get_term_winsz(slave_fd), new_stdin_winsz,
+ "openpty() failed to set slave window size")
# Solaris requires reading the fd before anything is returned.
# My guess is that since we open and close the slave fd
# in master_open(), we need to read the EOF.
+ #
+ # NOTE: the above comment is from an older version of the test;
+ # master_open() is not being used anymore.
# Ensure the fd is non-blocking in case there's nothing to read.
blocking = os.get_blocking(master_fd)
@@ -222,8 +307,22 @@ class PtyTest(unittest.TestCase):
os.close(master_fd)
- # pty.fork() passed.
+ def test_master_read(self):
+ debug("Calling pty.openpty()")
+ master_fd, slave_fd = pty.openpty()
+ debug(f"Got master_fd '{master_fd}', slave_fd '{slave_fd}'")
+ debug("Closing slave_fd")
+ os.close(slave_fd)
+
+ debug("Reading from master_fd")
+ try:
+ data = os.read(master_fd, 1)
+ except OSError: # Linux
+ data = b""
+
+ os.close(master_fd)
+ self.assertEqual(data, b"")
class SmallPtyTests(unittest.TestCase):
"""These tests don't spawn children or hang."""
@@ -262,8 +361,9 @@ class SmallPtyTests(unittest.TestCase):
self.files.extend(socketpair)
return socketpair
- def _mock_select(self, rfds, wfds, xfds):
+ def _mock_select(self, rfds, wfds, xfds, timeout=0):
# This will raise IndexError when no more expected calls exist.
+ # This ignores the timeout
self.assertEqual(self.select_rfds_lengths.pop(0), len(rfds))
return self.select_rfds_results.pop(0), [], []
diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py
index 869799cfa9..2c7afa994f 100644
--- a/Lib/test/test_pyclbr.py
+++ b/Lib/test/test_pyclbr.py
@@ -150,9 +150,6 @@ class PyclbrTest(TestCase):
self.checkModule('difflib', ignore=("Match",))
def test_decorators(self):
- # XXX: See comment in pyclbr_input.py for a test that would fail
- # if it were not commented out.
- #
self.checkModule('test.pyclbr_input', ignore=['om'])
def test_nested(self):
@@ -160,10 +157,10 @@ class PyclbrTest(TestCase):
# Set arguments for descriptor creation and _creat_tree call.
m, p, f, t, i = 'test', '', 'test.py', {}, None
source = dedent("""\
- def f0:
+ def f0():
def f1(a,b,c):
def f2(a=1, b=2, c=3): pass
- return f1(a,b,d)
+ return f1(a,b,d)
class c1: pass
class C0:
"Test class."
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 0c1fdeec99..e7f911d128 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -11,7 +11,7 @@ from functools import partial
from math import log, exp, pi, fsum, sin, factorial
from test import support
from fractions import Fraction
-from collections import Counter
+from collections import abc, Counter
class TestBasicOps:
# Superclass with tests common to all generators.
@@ -163,6 +163,22 @@ class TestBasicOps:
population = {10, 20, 30, 40, 50, 60, 70}
self.gen.sample(population, k=5)
+ def test_sample_on_seqsets(self):
+ class SeqSet(abc.Sequence, abc.Set):
+ def __init__(self, items):
+ self._items = items
+
+ def __len__(self):
+ return len(self._items)
+
+ def __getitem__(self, index):
+ return self._items[index]
+
+ population = SeqSet([2, 4, 1, 3])
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", DeprecationWarning)
+ self.gen.sample(population, k=2)
+
def test_sample_with_counts(self):
sample = self.gen.sample
@@ -398,6 +414,15 @@ class TestBasicOps:
r = _random.Random()
self.assertRaises(TypeError, pickle.dumps, r, proto)
+ @test.support.cpython_only
+ def test_bug_42008(self):
+ # _random.Random should call seed with first element of arg tuple
+ import _random
+ r1 = _random.Random()
+ r1.seed(8675309)
+ r2 = _random.Random(8675309)
+ self.assertEqual(r1.random(), r2.random())
+
def test_bug_1727780(self):
# verify that version-2-pickles can be loaded
# fine, whether they are created on 32-bit or 64-bit
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 1bfbcb853c..c1d02cfaf0 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -2197,6 +2197,10 @@ class ImplementationTest(unittest.TestCase):
self.assertEqual(f("ababba"), [0, 0, 1, 2, 0, 1])
self.assertEqual(f("abcabdac"), [0, 0, 0, 1, 2, 0, 1, 0])
+ def test_signedness(self):
+ self.assertGreaterEqual(sre_compile.MAXREPEAT, 0)
+ self.assertGreaterEqual(sre_compile.MAXGROUPS, 0)
+
class ExternalTests(unittest.TestCase):
diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py
index 458998a62f..f63564e6b0 100644
--- a/Lib/test/test_select.py
+++ b/Lib/test/test_select.py
@@ -1,7 +1,9 @@
import errno
import os
import select
+import subprocess
import sys
+import textwrap
import unittest
from test import support
@@ -44,17 +46,27 @@ class SelectTestCase(unittest.TestCase):
self.assertIsNot(r, x)
self.assertIsNot(w, x)
+ @unittest.skipUnless(hasattr(os, 'popen'), "need os.popen()")
def test_select(self):
- cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
- with os.popen(cmd) as p:
- for tout in (0, 1, 2, 4, 8, 16) + (None,)*10:
+ code = textwrap.dedent('''
+ import time
+ for i in range(10):
+ print("testing...", flush=True)
+ time.sleep(0.050)
+ ''')
+ cmd = [sys.executable, '-I', '-c', code]
+ with subprocess.Popen(cmd, stdout=subprocess.PIPE) as proc:
+ pipe = proc.stdout
+ for timeout in (0, 1, 2, 4, 8, 16) + (None,)*10:
if support.verbose:
- print('timeout =', tout)
- rfd, wfd, xfd = select.select([p], [], [], tout)
- if (rfd, wfd, xfd) == ([], [], []):
+ print(f'timeout = {timeout}')
+ rfd, wfd, xfd = select.select([pipe], [], [], timeout)
+ self.assertEqual(wfd, [])
+ self.assertEqual(xfd, [])
+ if not rfd:
continue
- if (rfd, wfd, xfd) == ([p], [], []):
- line = p.readline()
+ if rfd == [pipe]:
+ line = pipe.readline()
if support.verbose:
print(repr(line))
if not line:
@@ -62,7 +74,8 @@ class SelectTestCase(unittest.TestCase):
print('EOF')
break
continue
- self.fail('Unexpected return values from select():', rfd, wfd, xfd)
+ self.fail('Unexpected return values from select():',
+ rfd, wfd, xfd)
# Issue 16230: Crash on select resized list
def test_select_mutated(self):
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 890f2c7d40..df8dcdcce6 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -280,10 +280,7 @@ class TestRmTree(BaseTest, unittest.TestCase):
filename = os.path.join(tmpdir, "tstfile")
with self.assertRaises(NotADirectoryError) as cm:
shutil.rmtree(filename)
- # The reason for this rather odd construct is that Windows sprinkles
- # a \*.* at the end of file names. But only sometimes on some buildbots
- possible_args = [filename, os.path.join(filename, '*.*')]
- self.assertIn(cm.exception.filename, possible_args)
+ self.assertEqual(cm.exception.filename, filename)
self.assertTrue(os.path.exists(filename))
# test that ignore_errors option is honored
shutil.rmtree(filename, ignore_errors=True)
@@ -296,11 +293,11 @@ class TestRmTree(BaseTest, unittest.TestCase):
self.assertIs(errors[0][0], os.scandir)
self.assertEqual(errors[0][1], filename)
self.assertIsInstance(errors[0][2][1], NotADirectoryError)
- self.assertIn(errors[0][2][1].filename, possible_args)
+ self.assertEqual(errors[0][2][1].filename, filename)
self.assertIs(errors[1][0], os.rmdir)
self.assertEqual(errors[1][1], filename)
self.assertIsInstance(errors[1][2][1], NotADirectoryError)
- self.assertIn(errors[1][2][1].filename, possible_args)
+ self.assertEqual(errors[1][2][1].filename, filename)
@unittest.skipIf(sys.platform[:6] == 'cygwin',
@@ -683,6 +680,8 @@ class TestCopyTree(BaseTest, unittest.TestCase):
# Issue #3002: copyfile and copytree block indefinitely on named pipes
@unittest.skipUnless(hasattr(os, "mkfifo"), 'requires os.mkfifo()')
@os_helper.skip_unless_symlink
+ @unittest.skipIf(sys.platform == "vxworks",
+ "fifo requires special path on VxWorks")
def test_copytree_named_pipe(self):
os.mkdir(TESTFN)
try:
@@ -1206,6 +1205,8 @@ class TestCopy(BaseTest, unittest.TestCase):
# Issue #3002: copyfile and copytree block indefinitely on named pipes
@unittest.skipUnless(hasattr(os, "mkfifo"), 'requires os.mkfifo()')
+ @unittest.skipIf(sys.platform == "vxworks",
+ "fifo requires special path on VxWorks")
def test_copyfile_named_pipe(self):
try:
os.mkfifo(TESTFN)
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index c656790632..6a43fe7037 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -519,16 +519,20 @@ class WakeupSocketSignalTests(unittest.TestCase):
else:
write.setblocking(False)
- # Start with large chunk size to reduce the
- # number of send needed to fill the buffer.
written = 0
- for chunk_size in (2 ** 16, 2 ** 8, 1):
+ if sys.platform == "vxworks":
+ CHUNK_SIZES = (1,)
+ else:
+ # Start with large chunk size to reduce the
+ # number of send needed to fill the buffer.
+ CHUNK_SIZES = (2 ** 16, 2 ** 8, 1)
+ for chunk_size in CHUNK_SIZES:
chunk = b"x" * chunk_size
try:
while True:
write.send(chunk)
written += chunk_size
- except (BlockingIOError, socket.timeout):
+ except (BlockingIOError, TimeoutError):
pass
print(f"%s bytes written into the socketpair" % written, flush=True)
@@ -595,6 +599,7 @@ class WakeupSocketSignalTests(unittest.TestCase):
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
+@unittest.skipUnless(hasattr(signal, 'siginterrupt'), "needs signal.siginterrupt()")
class SiginterruptTest(unittest.TestCase):
def readpipe_interrupted(self, interrupt):
@@ -680,6 +685,8 @@ class SiginterruptTest(unittest.TestCase):
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
+@unittest.skipUnless(hasattr(signal, 'getitimer') and hasattr(signal, 'setitimer'),
+ "needs signal.getitimer() and signal.setitimer()")
class ItimerTest(unittest.TestCase):
def setUp(self):
self.hndl_called = False
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 2e70880f56..6060288248 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -36,6 +36,7 @@ if sys.flags.no_site:
import site
+HAS_USER_SITE = (site.USER_SITE is not None)
OLD_SYS_PATH = None
@@ -195,6 +196,7 @@ class HelperFunctionsTests(unittest.TestCase):
def test__getuserbase(self):
self.assertEqual(site._getuserbase(), sysconfig._getuserbase())
+ @unittest.skipUnless(HAS_USER_SITE, 'need user site')
def test_get_path(self):
if sys.platform == 'darwin' and sys._framework:
scheme = 'osx_framework_user'
@@ -244,6 +246,7 @@ class HelperFunctionsTests(unittest.TestCase):
self.assertEqual(rc, 1,
"User base not set by PYTHONUSERBASE")
+ @unittest.skipUnless(HAS_USER_SITE, 'need user site')
def test_getuserbase(self):
site.USER_BASE = None
user_base = site.getuserbase()
@@ -261,6 +264,7 @@ class HelperFunctionsTests(unittest.TestCase):
self.assertTrue(site.getuserbase().startswith('xoxo'),
site.getuserbase())
+ @unittest.skipUnless(HAS_USER_SITE, 'need user site')
def test_getusersitepackages(self):
site.USER_SITE = None
site.USER_BASE = None
@@ -295,6 +299,7 @@ class HelperFunctionsTests(unittest.TestCase):
wanted = os.path.join('xoxo', 'lib', 'site-packages')
self.assertEqual(dirs[1], wanted)
+ @unittest.skipUnless(HAS_USER_SITE, 'need user site')
def test_no_home_directory(self):
# bpo-10496: getuserbase() and getusersitepackages() must not fail if
# the current user has no home directory (if expanduser() returns the
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 7816ed3488..91985384ec 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -40,7 +40,7 @@ def server(evt, buf, serv):
evt.set()
try:
conn, addr = serv.accept()
- except socket.timeout:
+ except TimeoutError:
pass
else:
n = 500
@@ -193,7 +193,7 @@ def debugging_server(serv, serv_evt, client_evt):
n -= 1
- except socket.timeout:
+ except TimeoutError:
pass
finally:
if not client_evt.is_set():
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 80638325ba..e4af713b4c 100755
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1611,7 +1611,7 @@ class GeneralModuleTests(unittest.TestCase):
if with_timeout:
signal.signal(signal.SIGALRM, ok_handler)
signal.alarm(1)
- self.assertRaises(socket.timeout, c.sendall,
+ self.assertRaises(TimeoutError, c.sendall,
b"x" * support.SOCK_MAX_SIZE)
finally:
signal.alarm(0)
@@ -1738,6 +1738,7 @@ class GeneralModuleTests(unittest.TestCase):
@unittest.skipUnless(socket_helper.IPV6_ENABLED, 'IPv6 required for this test.')
@unittest.skipIf(sys.platform == 'win32', 'does not work on Windows')
@unittest.skipIf(AIX, 'Symbolic scope id does not work')
+ @unittest.skipUnless(hasattr(socket, 'if_nameindex'), "test needs socket.if_nameindex()")
def test_getaddrinfo_ipv6_scopeid_symbolic(self):
# Just pick up any network interface (Linux, Mac OS X)
(ifindex, test_interface) = socket.if_nameindex()[0]
@@ -1770,6 +1771,7 @@ class GeneralModuleTests(unittest.TestCase):
@unittest.skipUnless(socket_helper.IPV6_ENABLED, 'IPv6 required for this test.')
@unittest.skipIf(sys.platform == 'win32', 'does not work on Windows')
@unittest.skipIf(AIX, 'Symbolic scope id does not work')
+ @unittest.skipUnless(hasattr(socket, 'if_nameindex'), "test needs socket.if_nameindex()")
def test_getnameinfo_ipv6_scopeid_symbolic(self):
# Just pick up any network interface.
(ifindex, test_interface) = socket.if_nameindex()[0]
@@ -2966,7 +2968,7 @@ class SendmsgStreamTests(SendmsgTests):
try:
while True:
self.sendmsgToServer([b"a"*512])
- except socket.timeout:
+ except TimeoutError:
pass
except OSError as exc:
if exc.errno != errno.ENOMEM:
@@ -2974,7 +2976,7 @@ class SendmsgStreamTests(SendmsgTests):
# bpo-33937 the test randomly fails on Travis CI with
# "OSError: [Errno 12] Cannot allocate memory"
else:
- self.fail("socket.timeout not raised")
+ self.fail("TimeoutError not raised")
finally:
self.misc_event.set()
@@ -3109,7 +3111,7 @@ class RecvmsgGenericTests(SendrecvmsgBase):
# Check that timeout works.
try:
self.serv_sock.settimeout(0.03)
- self.assertRaises(socket.timeout,
+ self.assertRaises(TimeoutError,
self.doRecvmsg, self.serv_sock, len(MSG))
finally:
self.misc_event.set()
@@ -4827,7 +4829,7 @@ class FileObjectClassTestCase(SocketConnectedTest):
self.cli_conn.settimeout(1)
self.read_file.read(3)
# First read raises a timeout
- self.assertRaises(socket.timeout, self.read_file.read, 1)
+ self.assertRaises(TimeoutError, self.read_file.read, 1)
# Second read is disallowed
with self.assertRaises(OSError) as ctx:
self.read_file.read(1)
@@ -5092,7 +5094,7 @@ class NetworkConnectionNoServer(unittest.TestCase):
class MockSocket(socket.socket):
def connect(self, *args):
- raise socket.timeout('timed out')
+ raise TimeoutError('timed out')
@contextlib.contextmanager
def mocked_socket_module(self):
@@ -5142,13 +5144,13 @@ class NetworkConnectionNoServer(unittest.TestCase):
with self.mocked_socket_module():
try:
socket.create_connection((HOST, 1234))
- except socket.timeout:
+ except TimeoutError:
pass
except OSError as exc:
if socket_helper.IPV6_ENABLED or exc.errno != errno.EAFNOSUPPORT:
raise
else:
- self.fail('socket.timeout not raised')
+ self.fail('TimeoutError not raised')
class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
@@ -5250,7 +5252,7 @@ class NetworkConnectionBehaviourTest(SocketTCPTest, ThreadableTest):
def _testOutsideTimeout(self):
self.cli = sock = socket.create_connection((HOST, self.port), timeout=1)
- self.assertRaises(socket.timeout, lambda: sock.recv(5))
+ self.assertRaises(TimeoutError, lambda: sock.recv(5))
class TCPTimeoutTest(SocketTCPTest):
@@ -5259,7 +5261,7 @@ class TCPTimeoutTest(SocketTCPTest):
def raise_timeout(*args, **kwargs):
self.serv.settimeout(1.0)
self.serv.accept()
- self.assertRaises(socket.timeout, raise_timeout,
+ self.assertRaises(TimeoutError, raise_timeout,
"Error generating a timeout exception (TCP)")
def testTimeoutZero(self):
@@ -5267,7 +5269,7 @@ class TCPTimeoutTest(SocketTCPTest):
try:
self.serv.settimeout(0.0)
foo = self.serv.accept()
- except socket.timeout:
+ except TimeoutError:
self.fail("caught timeout instead of error (TCP)")
except OSError:
ok = True
@@ -5292,7 +5294,7 @@ class TCPTimeoutTest(SocketTCPTest):
try:
signal.alarm(2) # POSIX allows alarm to be up to 1 second early
foo = self.serv.accept()
- except socket.timeout:
+ except TimeoutError:
self.fail("caught timeout instead of Alarm")
except Alarm:
pass
@@ -5316,7 +5318,7 @@ class UDPTimeoutTest(SocketUDPTest):
def raise_timeout(*args, **kwargs):
self.serv.settimeout(1.0)
self.serv.recv(1024)
- self.assertRaises(socket.timeout, raise_timeout,
+ self.assertRaises(TimeoutError, raise_timeout,
"Error generating a timeout exception (UDP)")
def testTimeoutZero(self):
@@ -5324,7 +5326,7 @@ class UDPTimeoutTest(SocketUDPTest):
try:
self.serv.settimeout(0.0)
foo = self.serv.recv(1024)
- except socket.timeout:
+ except TimeoutError:
self.fail("caught timeout instead of error (UDP)")
except OSError:
ok = True
@@ -5341,7 +5343,7 @@ class UDPLITETimeoutTest(SocketUDPLITETest):
def raise_timeout(*args, **kwargs):
self.serv.settimeout(1.0)
self.serv.recv(1024)
- self.assertRaises(socket.timeout, raise_timeout,
+ self.assertRaises(TimeoutError, raise_timeout,
"Error generating a timeout exception (UDPLITE)")
def testTimeoutZero(self):
@@ -5349,7 +5351,7 @@ class UDPLITETimeoutTest(SocketUDPLITETest):
try:
self.serv.settimeout(0.0)
foo = self.serv.recv(1024)
- except socket.timeout:
+ except TimeoutError:
self.fail("caught timeout instead of error (UDPLITE)")
except OSError:
ok = True
@@ -5365,6 +5367,8 @@ class TestExceptions(unittest.TestCase):
self.assertTrue(issubclass(socket.herror, OSError))
self.assertTrue(issubclass(socket.gaierror, OSError))
self.assertTrue(issubclass(socket.timeout, OSError))
+ self.assertIs(socket.error, OSError)
+ self.assertIs(socket.timeout, TimeoutError)
def test_setblocking_invalidfd(self):
# Regression test for issue #28471
@@ -6167,7 +6171,7 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
with socket.create_connection(address) as sock:
sock.settimeout(0.01)
meth = self.meth_from_sock(sock)
- self.assertRaises(socket.timeout, meth, file)
+ self.assertRaises(TimeoutError, meth, file)
def testWithTimeoutTriggeredSend(self):
conn = self.accept_conn()
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 26eec969a8..67850c34e0 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -391,7 +391,7 @@ class BasicSocketTests(unittest.TestCase):
ssl.RAND_add(b"this is a random bytes object", 75.0)
ssl.RAND_add(bytearray(b"this is a random bytearray object"), 75.0)
- @unittest.skipUnless(os.name == 'posix', 'requires posix')
+ @unittest.skipUnless(hasattr(os, 'fork'), 'need os.fork')
def test_random_fork(self):
status = ssl.RAND_status()
if not status:
@@ -2574,7 +2574,7 @@ class ThreadedEchoServer(threading.Thread):
handler = self.ConnectionHandler(self, newconn, connaddr)
handler.start()
handler.join()
- except socket.timeout:
+ except TimeoutError:
pass
except KeyboardInterrupt:
self.stop()
@@ -3691,7 +3691,7 @@ class ThreadedTests(unittest.TestCase):
c.settimeout(0.2)
c.connect((host, port))
# Will attempt handshake and time out
- self.assertRaisesRegex(socket.timeout, "timed out",
+ self.assertRaisesRegex(TimeoutError, "timed out",
test_wrap_socket, c)
finally:
c.close()
@@ -3700,7 +3700,7 @@ class ThreadedTests(unittest.TestCase):
c = test_wrap_socket(c)
c.settimeout(0.2)
# Will attempt handshake and time out
- self.assertRaisesRegex(socket.timeout, "timed out",
+ self.assertRaisesRegex(TimeoutError, "timed out",
c.connect, (host, port))
finally:
c.close()
@@ -3854,6 +3854,7 @@ class ThreadedTests(unittest.TestCase):
@requires_minimum_version
@requires_tls_version('TLSv1_2')
+ @requires_tls_version('TLSv1')
def test_min_max_version_mismatch(self):
client_context, server_context, hostname = testing_context()
# client 1.0, server 1.2 (mismatch)
diff --git a/Lib/test/test_stat.py b/Lib/test/test_stat.py
index 83d09e17f9..2e1e2c349c 100644
--- a/Lib/test/test_stat.py
+++ b/Lib/test/test_stat.py
@@ -2,6 +2,7 @@ import unittest
import os
import socket
import sys
+from test.support import os_helper
from test.support import socket_helper
from test.support.import_helper import import_fresh_module
from test.support.os_helper import TESTFN
@@ -173,11 +174,16 @@ class TestFilemode:
@unittest.skipUnless(hasattr(os, 'mkfifo'), 'os.mkfifo not available')
def test_fifo(self):
+ if sys.platform == "vxworks":
+ fifo_path = os.path.join("/fifos/", TESTFN)
+ else:
+ fifo_path = TESTFN
+ self.addCleanup(os_helper.unlink, fifo_path)
try:
- os.mkfifo(TESTFN, 0o700)
+ os.mkfifo(fifo_path, 0o700)
except PermissionError as e:
self.skipTest('os.mkfifo(): %s' % e)
- st_mode, modestr = self.get_mode()
+ st_mode, modestr = self.get_mode(fifo_path)
self.assertEqual(modestr, 'prwx------')
self.assertS_IS("FIFO", st_mode)
diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py
index 997110732a..4b8686b681 100644
--- a/Lib/test/test_statistics.py
+++ b/Lib/test/test_statistics.py
@@ -1599,6 +1599,27 @@ class TestHarmonicMean(NumericTestCase, AverageMixin, UnivariateTypeMixin):
actual = self.func(data*2)
self.assertApproxEqual(actual, expected)
+ def test_with_weights(self):
+ self.assertEqual(self.func([40, 60], [5, 30]), 56.0) # common case
+ self.assertEqual(self.func([40, 60],
+ weights=[5, 30]), 56.0) # keyword argument
+ self.assertEqual(self.func(iter([40, 60]),
+ iter([5, 30])), 56.0) # iterator inputs
+ self.assertEqual(
+ self.func([Fraction(10, 3), Fraction(23, 5), Fraction(7, 2)], [5, 2, 10]),
+ self.func([Fraction(10, 3)] * 5 +
+ [Fraction(23, 5)] * 2 +
+ [Fraction(7, 2)] * 10))
+ self.assertEqual(self.func([10], [7]), 10) # n=1 fast path
+ with self.assertRaises(TypeError):
+ self.func([1, 2, 3], [1, (), 3]) # non-numeric weight
+ with self.assertRaises(statistics.StatisticsError):
+ self.func([1, 2, 3], [1, 2]) # wrong number of weights
+ with self.assertRaises(statistics.StatisticsError):
+ self.func([10], [0]) # no non-zero weights
+ with self.assertRaises(statistics.StatisticsError):
+ self.func([10, 20], [0, 0]) # no non-zero weights
+
class TestMedian(NumericTestCase, AverageMixin):
# Common tests for median and all median.* functions.
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index e25474abed..70b54f4155 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -204,6 +204,28 @@ class ProcessTestCase(BaseTestCase):
input=b'pear')
self.assertIn(b'PEAR', output)
+ def test_check_output_input_none(self):
+ """input=None has a legacy meaning of input='' on check_output."""
+ output = subprocess.check_output(
+ [sys.executable, "-c",
+ "import sys; print('XX' if sys.stdin.read() else '')"],
+ input=None)
+ self.assertNotIn(b'XX', output)
+
+ def test_check_output_input_none_text(self):
+ output = subprocess.check_output(
+ [sys.executable, "-c",
+ "import sys; print('XX' if sys.stdin.read() else '')"],
+ input=None, text=True)
+ self.assertNotIn('XX', output)
+
+ def test_check_output_input_none_universal_newlines(self):
+ output = subprocess.check_output(
+ [sys.executable, "-c",
+ "import sys; print('XX' if sys.stdin.read() else '')"],
+ input=None, universal_newlines=True)
+ self.assertNotIn('XX', output)
+
def test_check_output_stdout_arg(self):
# check_output() refuses to accept 'stdout' argument
with self.assertRaises(ValueError) as c:
@@ -3229,6 +3251,19 @@ class POSIXProcessTestCase(BaseTestCase):
# so Popen failed to read it and uses a default returncode instead.
self.assertIsNotNone(proc.returncode)
+ def test_send_signal_race2(self):
+ # bpo-40550: the process might exist between the returncode check and
+ # the kill operation
+ p = subprocess.Popen([sys.executable, '-c', 'exit(1)'])
+
+ # wait for process to exit
+ while not p.returncode:
+ p.poll()
+
+ with mock.patch.object(p, 'poll', new=lambda: None):
+ p.returncode = None
+ p.send_signal(signal.SIGTERM)
+
def test_communicate_repeated_call_after_stdout_close(self):
proc = subprocess.Popen([sys.executable, '-c',
'import os, time; os.close(1), time.sleep(2)'],
diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py
index 04e572c00a..aab074b8a9 100644
--- a/Lib/test/test_sundry.py
+++ b/Lib/test/test_sundry.py
@@ -9,7 +9,7 @@ import unittest
class TestUntestedModules(unittest.TestCase):
def test_untested_modules_can_be_imported(self):
- untested = ('encodings', 'formatter')
+ untested = ('encodings',)
with warnings_helper.check_warnings(quiet=True):
for name in untested:
try:
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 91ca1db43a..d8255607dc 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -802,6 +802,13 @@ class SyntaxTestCase(unittest.TestCase):
else:
self.fail("compile() did not raise SyntaxError")
+ def test_expression_with_assignment(self):
+ self._check_error(
+ "print(end1 + end2 = ' ')",
+ 'expression cannot contain assignment, perhaps you meant "=="?',
+ offset=19
+ )
+
def test_curly_brace_after_primary_raises_immediately(self):
self._check_error("f{", "invalid syntax", mode="single")
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 332ed8f550..3860656c18 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -221,7 +221,7 @@ class SysModuleTest(unittest.TestCase):
def f():
f()
try:
- for depth in (10, 25, 50, 75, 100, 250, 1000):
+ for depth in (50, 75, 100, 250, 1000):
try:
sys.setrecursionlimit(depth)
except RecursionError:
@@ -231,17 +231,17 @@ class SysModuleTest(unittest.TestCase):
# Issue #5392: test stack overflow after hitting recursion
# limit twice
- self.assertRaises(RecursionError, f)
- self.assertRaises(RecursionError, f)
+ with self.assertRaises(RecursionError):
+ f()
+ with self.assertRaises(RecursionError):
+ f()
finally:
sys.setrecursionlimit(oldlimit)
@test.support.cpython_only
def test_setrecursionlimit_recursion_depth(self):
# Issue #25274: Setting a low recursion limit must be blocked if the
- # current recursion depth is already higher than the "lower-water
- # mark". Otherwise, it may not be possible anymore to
- # reset the overflowed flag to 0.
+ # current recursion depth is already higher than limit.
from _testinternalcapi import get_recursion_depth
@@ -262,42 +262,10 @@ class SysModuleTest(unittest.TestCase):
sys.setrecursionlimit(1000)
for limit in (10, 25, 50, 75, 100, 150, 200):
- # formula extracted from _Py_RecursionLimitLowerWaterMark()
- if limit > 200:
- depth = limit - 50
- else:
- depth = limit * 3 // 4
- set_recursion_limit_at_depth(depth, limit)
+ set_recursion_limit_at_depth(limit, limit)
finally:
sys.setrecursionlimit(oldlimit)
- # The error message is specific to CPython
- @test.support.cpython_only
- def test_recursionlimit_fatalerror(self):
- # A fatal error occurs if a second recursion limit is hit when recovering
- # from a first one.
- code = textwrap.dedent("""
- import sys
-
- def f():
- try:
- f()
- except RecursionError:
- f()
-
- sys.setrecursionlimit(%d)
- f()""")
- with test.support.SuppressCrashReport():
- for i in (50, 1000):
- sub = subprocess.Popen([sys.executable, '-c', code % i],
- stderr=subprocess.PIPE)
- err = sub.communicate()[1]
- self.assertTrue(sub.returncode, sub.returncode)
- self.assertIn(
- b"Fatal Python error: _Py_CheckRecursiveCall: "
- b"Cannot recover from stack overflow",
- err)
-
def test_getwindowsversion(self):
# Raise SkipTest if sys doesn't have getwindowsversion attribute
test.support.get_attribute(sys, "getwindowsversion")
@@ -1407,7 +1375,7 @@ class SizeofTest(unittest.TestCase):
check(int, s)
# class
s = vsize(fmt + # PyTypeObject
- '3P' # PyAsyncMethods
+ '4P' # PyAsyncMethods
'36P' # PyNumberMethods
'3P' # PyMappingMethods
'10P' # PySequenceMethods
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index dd4418dd98..50b5672e35 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -53,9 +53,8 @@ basic.events = [(0, 'call'),
# following that clause?
-# Some constructs like "while 0:", "if 0:" or "if 1:...else:..." are optimized
-# away. No code # exists for them, so the line numbers skip directly from
-# "del x" to "x = 1".
+# Some constructs like "while 0:", "if 0:" or "if 1:...else:..." could be optimized
+# away. Make sure that those lines aren't skipped.
def arigo_example0():
x = 1
del x
@@ -66,6 +65,7 @@ def arigo_example0():
arigo_example0.events = [(0, 'call'),
(1, 'line'),
(2, 'line'),
+ (3, 'line'),
(5, 'line'),
(5, 'return')]
@@ -79,6 +79,7 @@ def arigo_example1():
arigo_example1.events = [(0, 'call'),
(1, 'line'),
(2, 'line'),
+ (3, 'line'),
(5, 'line'),
(5, 'return')]
@@ -94,6 +95,7 @@ def arigo_example2():
arigo_example2.events = [(0, 'call'),
(1, 'line'),
(2, 'line'),
+ (3, 'line'),
(4, 'line'),
(7, 'line'),
(7, 'return')]
@@ -220,8 +222,7 @@ ireturn_example.events = [(0, 'call'),
(2, 'line'),
(3, 'line'),
(4, 'line'),
- (6, 'line'),
- (6, 'return')]
+ (4, 'return')]
# Tight loop with while(1) example (SF #765624)
def tightloop_example():
@@ -237,9 +238,13 @@ tightloop_example.events = [(0, 'call'),
(1, 'line'),
(2, 'line'),
(3, 'line'),
+ (4, 'line'),
(5, 'line'),
+ (4, 'line'),
(5, 'line'),
+ (4, 'line'),
(5, 'line'),
+ (4, 'line'),
(5, 'line'),
(5, 'exception'),
(6, 'line'),
@@ -602,6 +607,17 @@ class TraceTestCase(unittest.TestCase):
self.compare_events(doit_async.__code__.co_firstlineno,
tracer.events, events)
+ def test_21_repeated_pass(self):
+ def func():
+ pass
+ pass
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (2, 'return')])
+
def test_loop_in_try_except(self):
# https://bugs.python.org/issue41670
@@ -619,6 +635,245 @@ class TraceTestCase(unittest.TestCase):
(3, 'line'),
(3, 'return')])
+ def test_try_except_no_exception(self):
+
+ def func():
+ try:
+ 2
+ except:
+ 4
+ finally:
+ 6
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (6, 'line'),
+ (6, 'return')])
+
+ def test_nested_loops(self):
+
+ def func():
+ for i in range(2):
+ for j in range(2):
+ a = i + j
+ return a == 1
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (3, 'line'),
+ (2, 'line'),
+ (3, 'line'),
+ (2, 'line'),
+ (1, 'line'),
+ (2, 'line'),
+ (3, 'line'),
+ (2, 'line'),
+ (3, 'line'),
+ (2, 'line'),
+ (1, 'line'),
+ (4, 'line'),
+ (4, 'return')])
+
+ def test_if_break(self):
+
+ def func():
+ seq = [1, 0]
+ while seq:
+ n = seq.pop()
+ if n:
+ break # line 5
+ else:
+ n = 99
+ return n # line 8
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (3, 'line'),
+ (4, 'line'),
+ (2, 'line'),
+ (3, 'line'),
+ (4, 'line'),
+ (5, 'line'),
+ (8, 'line'),
+ (8, 'return')])
+
+ def test_break_through_finally(self):
+
+ def func():
+ a, c, d, i = 1, 1, 1, 99
+ try:
+ for i in range(3):
+ try:
+ a = 5
+ if i > 0:
+ break # line 7
+ a = 8
+ finally:
+ c = 10
+ except:
+ d = 12 # line 12
+ assert a == 5 and c == 10 and d == 1 # line 13
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (3, 'line'),
+ (4, 'line'),
+ (5, 'line'),
+ (6, 'line'),
+ (8, 'line'),
+ (10, 'line'),
+ (3, 'line'),
+ (4, 'line'),
+ (5, 'line'),
+ (6, 'line'),
+ (7, 'line'),
+ (10, 'line'),
+ (13, 'line'),
+ (13, 'return')])
+
+ def test_continue_through_finally(self):
+
+ def func():
+ a, b, c, d, i = 1, 1, 1, 1, 99
+ try:
+ for i in range(2):
+ try:
+ a = 5
+ if i > 0:
+ continue # line 7
+ b = 8
+ finally:
+ c = 10
+ except:
+ d = 12 # line 12
+ assert (a, b, c, d) == (5, 8, 10, 1) # line 13
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (3, 'line'),
+ (4, 'line'),
+ (5, 'line'),
+ (6, 'line'),
+ (8, 'line'),
+ (10, 'line'),
+ (3, 'line'),
+ (4, 'line'),
+ (5, 'line'),
+ (6, 'line'),
+ (7, 'line'),
+ (10, 'line'),
+ (3, 'line'),
+ (13, 'line'),
+ (13, 'return')])
+
+ def test_return_through_finally(self):
+
+ def func():
+ try:
+ return 2
+ finally:
+ 4
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (4, 'line'),
+ (4, 'return')])
+
+ def test_try_except_with_wrong_type(self):
+
+ def func():
+ try:
+ 2/0
+ except IndexError:
+ 4
+ finally:
+ return 6
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (2, 'exception'),
+ (3, 'line'),
+ (6, 'line'),
+ (6, 'return')])
+
+ def test_break_to_continue1(self):
+
+ def func():
+ TRUE = 1
+ x = [1]
+ while x:
+ x.pop()
+ while TRUE:
+ break
+ continue
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (3, 'line'),
+ (4, 'line'),
+ (5, 'line'),
+ (6, 'line'),
+ (7, 'line'),
+ (3, 'line'),
+ (3, 'return')])
+
+ def test_break_to_continue2(self):
+
+ def func():
+ TRUE = 1
+ x = [1]
+ while x:
+ x.pop()
+ while TRUE:
+ break
+ else:
+ continue
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (3, 'line'),
+ (4, 'line'),
+ (5, 'line'),
+ (6, 'line'),
+ (3, 'line'),
+ (3, 'return')])
+
+ def test_break_to_break(self):
+
+ def func():
+ TRUE = 1
+ while TRUE:
+ while TRUE:
+ break
+ break
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (3, 'line'),
+ (4, 'line'),
+ (5, 'line'),
+ (5, 'return')])
+
class SkipLineEventsTraceTestCase(TraceTestCase):
"""Repeat the trace tests, but with per-line events skipped"""
@@ -766,7 +1021,7 @@ class JumpTracer:
if (self.firstLine is None and frame.f_code == self.code and
event == 'line'):
self.firstLine = frame.f_lineno - 1
- if (event == self.event and self.firstLine and
+ if (event == self.event and self.firstLine is not None and
frame.f_lineno == self.firstLine + self.jumpFrom):
f = frame
while f is not None and f.f_code != self.code:
@@ -980,7 +1235,7 @@ class JumpTestCase(unittest.TestCase):
pass
output.append(12)
- @jump_test(3, 4, [1], (ValueError, 'unreachable'))
+ @jump_test(3, 4, [1], (ValueError, 'after'))
def test_no_jump_infinite_while_loop(output):
output.append(1)
while True:
@@ -1540,7 +1795,7 @@ output.append(4)
""", "<fake module>", "exec")
class fake_function:
__code__ = code
- tracer = JumpTracer(fake_function, 2, 0)
+ tracer = JumpTracer(fake_function, 4, 1)
sys.settrace(tracer.trace)
namespace = {"output": []}
exec(code, namespace)
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index d07d28df60..e279957e26 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -18,6 +18,10 @@ from sysconfig import (get_paths, get_platform, get_config_vars,
get_scheme_names, get_config_var, _main)
import _osx_support
+
+HAS_USER_BASE = sysconfig._HAS_USER_BASE
+
+
class TestSysConfig(unittest.TestCase):
def setUp(self):
@@ -230,9 +234,10 @@ class TestSysConfig(unittest.TestCase):
self.assertTrue(os.path.isfile(config_h), config_h)
def test_get_scheme_names(self):
- wanted = ('nt', 'nt_user', 'osx_framework_user',
- 'posix_home', 'posix_prefix', 'posix_user')
- self.assertEqual(get_scheme_names(), wanted)
+ wanted = ['nt', 'posix_home', 'posix_prefix']
+ if HAS_USER_BASE:
+ wanted.extend(['nt_user', 'osx_framework_user', 'posix_user'])
+ self.assertEqual(get_scheme_names(), tuple(sorted(wanted)))
@skip_unless_symlink
def test_symlink(self): # Issue 7880
@@ -244,7 +249,8 @@ class TestSysConfig(unittest.TestCase):
# Issue #8759: make sure the posix scheme for the users
# is similar to the global posix_prefix one
base = get_config_var('base')
- user = get_config_var('userbase')
+ if HAS_USER_BASE:
+ user = get_config_var('userbase')
# the global scheme mirrors the distinction between prefix and
# exec-prefix but not the user scheme, so we have to adapt the paths
# before comparing (issue #9100)
@@ -259,8 +265,9 @@ class TestSysConfig(unittest.TestCase):
# before comparing
global_path = global_path.replace(sys.base_prefix, sys.prefix)
base = base.replace(sys.base_prefix, sys.prefix)
- user_path = get_path(name, 'posix_user')
- self.assertEqual(user_path, global_path.replace(base, user, 1))
+ if HAS_USER_BASE:
+ user_path = get_path(name, 'posix_user')
+ self.assertEqual(user_path, global_path.replace(base, user, 1))
def test_main(self):
# just making sure _main() runs and returns things in the stdout
@@ -360,10 +367,12 @@ class TestSysConfig(unittest.TestCase):
@unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
'EXT_SUFFIX required for this test')
- def test_SO_in_vars(self):
+ def test_EXT_SUFFIX_in_vars(self):
+ import _imp
vars = sysconfig.get_config_vars()
self.assertIsNotNone(vars['SO'])
self.assertEqual(vars['SO'], vars['EXT_SUFFIX'])
+ self.assertEqual(vars['EXT_SUFFIX'], _imp.extension_suffixes()[0])
@unittest.skipUnless(sys.platform == 'linux' and
hasattr(sys.implementation, '_multiarch'),
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 7b34d53d21..77ad8305c3 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -1347,10 +1347,10 @@ class WriteTest(WriteTestBase, unittest.TestCase):
f.write('something\n')
os.symlink(source_file, target_file)
with tarfile.open(temparchive, 'w') as tar:
- tar.add(source_file)
- tar.add(target_file)
+ tar.add(source_file, arcname="source")
+ tar.add(target_file, arcname="symlink")
# Let's extract it to the location which contains the symlink
- with tarfile.open(temparchive) as tar:
+ with tarfile.open(temparchive, errorlevel=2) as tar:
# this should not raise OSError: [Errno 17] File exists
try:
tar.extractall(path=tempdir)
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index cd2a30e533..5bc4f9bda1 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -1,4 +1,5 @@
import unittest
+import locale
import re
import subprocess
import sys
@@ -61,6 +62,10 @@ class TclTest(unittest.TestCase):
tcl = self.interp
self.assertEqual(tcl.eval('set a "a\\0b"'), 'a\x00b')
+ def test_eval_surrogates_in_result(self):
+ tcl = self.interp
+ self.assertIn(tcl.eval(r'set a "<\ud83d\udcbb>"'), '<\U0001f4bb>')
+
def testEvalException(self):
tcl = self.interp
self.assertRaises(TclError,tcl.eval,'set a')
@@ -133,10 +138,14 @@ class TclTest(unittest.TestCase):
def get_integers(self):
integers = (0, 1, -1, 2**31-1, -2**31, 2**31, -2**31-1, 2**63-1, -2**63)
- # bignum was added in Tcl 8.5, but its support is able only since 8.5.8
- if (get_tk_patchlevel() >= (8, 6, 0, 'final') or
- (8, 5, 8) <= get_tk_patchlevel() < (8, 6)):
- integers += (2**63, -2**63-1, 2**1000, -2**1000)
+ # bignum was added in Tcl 8.5, but its support is able only since 8.5.8.
+ # Actually it is determined at compile time, so using get_tk_patchlevel()
+ # is not reliable.
+ # TODO: expose full static version.
+ if tcl_version >= (8, 5):
+ v = get_tk_patchlevel()
+ if v >= (8, 6, 0, 'final') or (8, 5, 8) <= v < (8, 6):
+ integers += (2**63, -2**63-1, 2**1000, -2**1000)
return integers
def test_getint(self):
@@ -193,29 +202,48 @@ class TclTest(unittest.TestCase):
def testEvalFile(self):
tcl = self.interp
- with open(os_helper.TESTFN, 'w') as f:
- self.addCleanup(os_helper.unlink, os_helper.TESTFN)
+ filename = os_helper.TESTFN_ASCII
+ self.addCleanup(os_helper.unlink, filename)
+ with open(filename, 'w') as f:
f.write("""set a 1
set b 2
set c [ expr $a + $b ]
""")
- tcl.evalfile(os_helper.TESTFN)
+ tcl.evalfile(filename)
self.assertEqual(tcl.eval('set a'),'1')
self.assertEqual(tcl.eval('set b'),'2')
self.assertEqual(tcl.eval('set c'),'3')
def test_evalfile_null_in_result(self):
tcl = self.interp
- with open(os_helper.TESTFN, 'w') as f:
- self.addCleanup(os_helper.unlink, os_helper.TESTFN)
+ filename = os_helper.TESTFN_ASCII
+ self.addCleanup(os_helper.unlink, filename)
+ with open(filename, 'w') as f:
f.write("""
set a "a\0b"
set b "a\\0b"
""")
- tcl.evalfile(os_helper.TESTFN)
+ tcl.evalfile(filename)
self.assertEqual(tcl.eval('set a'), 'a\x00b')
self.assertEqual(tcl.eval('set b'), 'a\x00b')
+ def test_evalfile_surrogates_in_result(self):
+ tcl = self.interp
+ encoding = tcl.call('encoding', 'system')
+ self.addCleanup(tcl.call, 'encoding', 'system', encoding)
+ tcl.call('encoding', 'system', 'utf-8')
+
+ filename = os_helper.TESTFN_ASCII
+ self.addCleanup(os_helper.unlink, filename)
+ with open(filename, 'wb') as f:
+ f.write(b"""
+ set a "<\xed\xa0\xbd\xed\xb2\xbb>"
+ set b "<\\ud83d\\udcbb>"
+ """)
+ tcl.evalfile(filename)
+ self.assertEqual(tcl.eval('set a'), '<\U0001f4bb>')
+ self.assertEqual(tcl.eval('set b'), '<\U0001f4bb>')
+
def testEvalFileException(self):
tcl = self.interp
filename = "doesnotexists"
@@ -438,6 +466,11 @@ class TclTest(unittest.TestCase):
self.assertEqual(passValue('str\x00ing\u20ac'), 'str\x00ing\u20ac')
self.assertEqual(passValue('str\x00ing\U0001f4bb'),
'str\x00ing\U0001f4bb')
+ if sys.platform != 'win32':
+ self.assertEqual(passValue('<\udce2\udc82\udcac>'),
+ '<\u20ac>')
+ self.assertEqual(passValue('<\udced\udca0\udcbd\udced\udcb2\udcbb>'),
+ '<\U0001f4bb>')
self.assertEqual(passValue(b'str\x00ing'),
b'str\x00ing' if self.wantobjects else 'str\x00ing')
self.assertEqual(passValue(b'str\xc0\x80ing'),
@@ -497,6 +530,9 @@ class TclTest(unittest.TestCase):
check('string\xbd')
check('string\u20ac')
check('string\U0001f4bb')
+ if sys.platform != 'win32':
+ check('<\udce2\udc82\udcac>', '<\u20ac>')
+ check('<\udced\udca0\udcbd\udced\udcb2\udcbb>', '<\U0001f4bb>')
check('')
check(b'string', 'string')
check(b'string\xe2\x82\xac', 'string\xe2\x82\xac')
@@ -540,6 +576,8 @@ class TclTest(unittest.TestCase):
('a \u20ac', ('a', '\u20ac')),
('a \U0001f4bb', ('a', '\U0001f4bb')),
(b'a \xe2\x82\xac', ('a', '\u20ac')),
+ (b'a \xf0\x9f\x92\xbb', ('a', '\U0001f4bb')),
+ (b'a \xed\xa0\xbd\xed\xb2\xbb', ('a', '\U0001f4bb')),
(b'a\xc0\x80b c\xc0\x80d', ('a\x00b', 'c\x00d')),
('a {b c}', ('a', 'b c')),
(r'a b\ c', ('a', 'b c')),
diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py
index 7633901c96..8e36051cd0 100644
--- a/Lib/test/test_telnetlib.py
+++ b/Lib/test/test_telnetlib.py
@@ -16,7 +16,7 @@ def server(evt, serv):
try:
conn, addr = serv.accept()
conn.close()
- except socket.timeout:
+ except TimeoutError:
pass
finally:
serv.close()
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 2f0f3ae094..0a4372ec2d 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -469,6 +469,34 @@ class ThreadTests(BaseTestCase):
t = threading.Thread(daemon=True)
self.assertTrue(t.daemon)
+ @unittest.skipUnless(hasattr(os, 'fork'), 'needs os.fork()')
+ def test_fork_at_exit(self):
+ # bpo-42350: Calling os.fork() after threading._shutdown() must
+ # not log an error.
+ code = textwrap.dedent("""
+ import atexit
+ import os
+ import sys
+ from test.support import wait_process
+
+ # Import the threading module to register its "at fork" callback
+ import threading
+
+ def exit_handler():
+ pid = os.fork()
+ if not pid:
+ print("child process ok", file=sys.stderr, flush=True)
+ # child process
+ else:
+ wait_process(pid, exitcode=0)
+
+ # exit_handler() will be called after threading._shutdown()
+ atexit.register(exit_handler)
+ """)
+ _, out, err = assert_python_ok("-c", code)
+ self.assertEqual(out, b'')
+ self.assertEqual(err.rstrip(), b'child process ok')
+
@unittest.skipUnless(hasattr(os, 'fork'), 'test needs fork()')
def test_dummy_thread_after_fork(self):
# Issue #14308: a dummy thread in the active list doesn't mess up
@@ -765,6 +793,27 @@ class ThreadTests(BaseTestCase):
finally:
sys.settrace(old_trace)
+ def test_gettrace(self):
+ def noop_trace(frame, event, arg):
+ # no operation
+ return noop_trace
+ old_trace = threading.gettrace()
+ try:
+ threading.settrace(noop_trace)
+ trace_func = threading.gettrace()
+ self.assertEqual(noop_trace,trace_func)
+ finally:
+ threading.settrace(old_trace)
+
+ def test_getprofile(self):
+ def fn(*args): pass
+ old_profile = threading.getprofile()
+ try:
+ threading.setprofile(fn)
+ self.assertEqual(fn, threading.getprofile())
+ finally:
+ threading.setprofile(old_profile)
+
@cpython_only
def test_shutdown_locks(self):
for daemon in (False, True):
@@ -1331,6 +1380,27 @@ class ExceptHookTests(BaseTestCase):
'Exception in threading.excepthook:\n')
self.assertEqual(err_str, 'threading_hook failed')
+ def test_original_excepthook(self):
+ def run_thread():
+ with support.captured_output("stderr") as output:
+ thread = ThreadRunFail(name="excepthook thread")
+ thread.start()
+ thread.join()
+ return output.getvalue()
+
+ def threading_hook(args):
+ print("Running a thread failed", file=sys.stderr)
+
+ default_output = run_thread()
+ with support.swap_attr(threading, 'excepthook', threading_hook):
+ custom_hook_output = run_thread()
+ threading.excepthook = threading.__excepthook__
+ recovered_output = run_thread()
+
+ self.assertEqual(default_output, recovered_output)
+ self.assertNotEqual(default_output, custom_hook_output)
+ self.assertEqual(custom_hook_output, "Running a thread failed\n")
+
class TimerTests(BaseTestCase):
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index 6ced0470d0..3258298648 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -1041,6 +1041,36 @@ class TestOldPyTime(CPyTimeTestCase, unittest.TestCase):
with self.assertRaises(ValueError):
pytime_object_to_timespec(float('nan'), time_rnd)
+@unittest.skipUnless(sys.platform == "darwin", "test weak linking on macOS")
+class TestTimeWeaklinking(unittest.TestCase):
+ # These test cases verify that weak linking support on macOS works
+ # as expected. These cases only test new behaviour introduced by weak linking,
+ # regular behaviour is tested by the normal test cases.
+ #
+ # See the section on Weak Linking in Mac/README.txt for more information.
+ def test_clock_functions(self):
+ import sysconfig
+ import platform
+
+ config_vars = sysconfig.get_config_vars()
+ var_name = "HAVE_CLOCK_GETTIME"
+ if var_name not in config_vars or not config_vars[var_name]:
+ raise unittest.SkipTest(f"{var_name} is not available")
+
+ mac_ver = tuple(int(x) for x in platform.mac_ver()[0].split("."))
+
+ clock_names = [
+ "CLOCK_MONOTONIC", "clock_gettime", "clock_gettime_ns", "clock_settime",
+ "clock_settime_ns", "clock_getres"]
+
+ if mac_ver >= (10, 12):
+ for name in clock_names:
+ self.assertTrue(hasattr(time, name), f"time.{name} is not available")
+
+ else:
+ for name in clock_names:
+ self.assertFalse(hasattr(time, name), f"time.{name} is available")
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_timeout.py b/Lib/test/test_timeout.py
index ac803f5d63..823d5c3e17 100644
--- a/Lib/test/test_timeout.py
+++ b/Lib/test/test_timeout.py
@@ -122,7 +122,7 @@ class TimeoutTestCase(unittest.TestCase):
"""
Test the specified socket method.
- The method is run at most `count` times and must raise a socket.timeout
+ The method is run at most `count` times and must raise a TimeoutError
within `timeout` + self.fuzz seconds.
"""
self.sock.settimeout(timeout)
@@ -131,11 +131,11 @@ class TimeoutTestCase(unittest.TestCase):
t1 = time.monotonic()
try:
method(*args)
- except socket.timeout as e:
+ except TimeoutError as e:
delta = time.monotonic() - t1
break
else:
- self.fail('socket.timeout was not raised')
+ self.fail('TimeoutError was not raised')
# These checks should account for timing unprecision
self.assertLess(delta, timeout + self.fuzz)
self.assertGreater(delta, timeout - 1.0)
@@ -204,7 +204,7 @@ class TCPTimeoutTestCase(TimeoutTestCase):
sock.settimeout(timeout)
try:
sock.connect((whitehole))
- except socket.timeout:
+ except TimeoutError:
pass
except OSError as err:
if err.errno == errno.ECONNREFUSED:
diff --git a/Lib/test/test_tools/test_i18n.py b/Lib/test/test_tools/test_i18n.py
index 8da657907e..12f778dbf8 100644
--- a/Lib/test/test_tools/test_i18n.py
+++ b/Lib/test/test_tools/test_i18n.py
@@ -220,6 +220,76 @@ class Test_pygettext(unittest.TestCase):
'''))
self.assertIn('doc', msgids)
+ def test_calls_in_fstrings(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ f"{_('foo bar')}"
+ '''))
+ self.assertIn('foo bar', msgids)
+
+ def test_calls_in_fstrings_raw(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ rf"{_('foo bar')}"
+ '''))
+ self.assertIn('foo bar', msgids)
+
+ def test_calls_in_fstrings_nested(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ f"""{f'{_("foo bar")}'}"""
+ '''))
+ self.assertIn('foo bar', msgids)
+
+ def test_calls_in_fstrings_attribute(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ f"{obj._('foo bar')}"
+ '''))
+ self.assertIn('foo bar', msgids)
+
+ def test_calls_in_fstrings_with_call_on_call(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ f"{type(str)('foo bar')}"
+ '''))
+ self.assertNotIn('foo bar', msgids)
+
+ def test_calls_in_fstrings_with_format(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ f"{_('foo {bar}').format(bar='baz')}"
+ '''))
+ self.assertIn('foo {bar}', msgids)
+
+ def test_calls_in_fstrings_with_wrong_input_1(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ f"{_(f'foo {bar}')}"
+ '''))
+ self.assertFalse([msgid for msgid in msgids if 'foo {bar}' in msgid])
+
+ def test_calls_in_fstrings_with_wrong_input_2(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ f"{_(1)}"
+ '''))
+ self.assertNotIn(1, msgids)
+
+ def test_calls_in_fstring_with_multiple_args(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ f"{_('foo', 'bar')}"
+ '''))
+ self.assertNotIn('foo', msgids)
+ self.assertNotIn('bar', msgids)
+
+ def test_calls_in_fstring_with_keyword_args(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ f"{_('foo', bar='baz')}"
+ '''))
+ self.assertNotIn('foo', msgids)
+ self.assertNotIn('bar', msgids)
+ self.assertNotIn('baz', msgids)
+
+ def test_calls_in_fstring_with_partially_wrong_expression(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ f"{_(f'foo') + _('bar')}"
+ '''))
+ self.assertNotIn('foo', msgids)
+ self.assertIn('bar', msgids)
+
def test_files_list(self):
"""Make sure the directories are inspected for source files
bpo-31920
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 730596efd8..abb5762cd4 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -212,6 +212,26 @@ class TracebackCases(unittest.TestCase):
)
self.assertEqual(output.getvalue(), "Exception: projector\n")
+ def test_print_exception_exc(self):
+ output = StringIO()
+ traceback.print_exception(Exception("projector"), file=output)
+ self.assertEqual(output.getvalue(), "Exception: projector\n")
+
+ def test_format_exception_exc(self):
+ e = Exception("projector")
+ output = traceback.format_exception(e)
+ self.assertEqual(output, ["Exception: projector\n"])
+ with self.assertRaisesRegex(ValueError, 'Both or neither'):
+ traceback.format_exception(e.__class__, e)
+ with self.assertRaisesRegex(ValueError, 'Both or neither'):
+ traceback.format_exception(e.__class__, tb=e.__traceback__)
+ with self.assertRaisesRegex(TypeError, 'positional-only'):
+ traceback.format_exception(exc=e)
+
+ def test_format_exception_only_exc(self):
+ output = traceback.format_exception_only(Exception("projector"))
+ self.assertEqual(output, ["Exception: projector\n"])
+
class TracebackFormatTests(unittest.TestCase):
@@ -667,6 +687,31 @@ class BaseExceptionReportingTests:
msg = self.get_report(e).splitlines()
self.assertEqual(msg[-2], ' ^')
+ def test_syntax_error_no_lineno(self):
+ # See #34463.
+
+ # Without filename
+ e = SyntaxError('bad syntax')
+ msg = self.get_report(e).splitlines()
+ self.assertEqual(msg,
+ ['SyntaxError: bad syntax'])
+ e.lineno = 100
+ msg = self.get_report(e).splitlines()
+ self.assertEqual(msg,
+ [' File "<string>", line 100', 'SyntaxError: bad syntax'])
+
+ # With filename
+ e = SyntaxError('bad syntax')
+ e.filename = 'myfile.py'
+
+ msg = self.get_report(e).splitlines()
+ self.assertEqual(msg,
+ ['SyntaxError: bad syntax (myfile.py)'])
+ e.lineno = 100
+ msg = self.get_report(e).splitlines()
+ self.assertEqual(msg,
+ [' File "myfile.py", line 100', 'SyntaxError: bad syntax'])
+
def test_message_none(self):
# A message that looks like "None" should not be treated specially
err = self.get_report(Exception(None))
@@ -1103,7 +1148,19 @@ class TestTracebackException(unittest.TestCase):
self.assertEqual(exc_info[0], exc.exc_type)
self.assertEqual(str(exc_info[1]), str(exc))
- def test_comparison(self):
+ def test_no_refs_to_exception_and_traceback_objects(self):
+ try:
+ 1/0
+ except Exception:
+ exc_info = sys.exc_info()
+
+ refcnt1 = sys.getrefcount(exc_info[1])
+ refcnt2 = sys.getrefcount(exc_info[2])
+ exc = traceback.TracebackException(*exc_info)
+ self.assertEqual(sys.getrefcount(exc_info[1]), refcnt1)
+ self.assertEqual(sys.getrefcount(exc_info[2]), refcnt2)
+
+ def test_comparison_basic(self):
try:
1/0
except Exception:
@@ -1115,6 +1172,53 @@ class TestTracebackException(unittest.TestCase):
self.assertNotEqual(exc, object())
self.assertEqual(exc, ALWAYS_EQ)
+ def test_comparison_params_variations(self):
+ def raise_exc():
+ try:
+ raise ValueError('bad value')
+ except:
+ raise
+
+ def raise_with_locals():
+ x, y = 1, 2
+ raise_exc()
+
+ try:
+ raise_with_locals()
+ except Exception:
+ exc_info = sys.exc_info()
+
+ exc = traceback.TracebackException(*exc_info)
+ exc1 = traceback.TracebackException(*exc_info, limit=10)
+ exc2 = traceback.TracebackException(*exc_info, limit=2)
+
+ self.assertEqual(exc, exc1) # limit=10 gets all frames
+ self.assertNotEqual(exc, exc2) # limit=2 truncates the output
+
+ # locals change the output
+ exc3 = traceback.TracebackException(*exc_info, capture_locals=True)
+ self.assertNotEqual(exc, exc3)
+
+ # there are no locals in the innermost frame
+ exc4 = traceback.TracebackException(*exc_info, limit=-1)
+ exc5 = traceback.TracebackException(*exc_info, limit=-1, capture_locals=True)
+ self.assertEqual(exc4, exc5)
+
+ # there are locals in the next-to-innermost frame
+ exc6 = traceback.TracebackException(*exc_info, limit=-2)
+ exc7 = traceback.TracebackException(*exc_info, limit=-2, capture_locals=True)
+ self.assertNotEqual(exc6, exc7)
+
+ def test_comparison_equivalent_exceptions_are_equal(self):
+ excs = []
+ for _ in range(2):
+ try:
+ 1/0
+ except:
+ excs.append(traceback.TracebackException(*sys.exc_info()))
+ self.assertEqual(excs[0], excs[1])
+ self.assertEqual(list(excs[0].format()), list(excs[1].format()))
+
def test_unhashable(self):
class UnhashableException(Exception):
def __eq__(self, other):
@@ -1156,7 +1260,7 @@ class TestTracebackException(unittest.TestCase):
f = test_frame(c, None, None)
tb = test_tb(f, 6, None)
exc = traceback.TracebackException(Exception, e, tb, lookup_lines=False)
- self.assertEqual({}, linecache.cache)
+ self.assertEqual(linecache.cache, {})
linecache.updatecache('/foo.py', globals())
self.assertEqual(exc.stack[0].line, "import sys")
diff --git a/Lib/test/test_tracemalloc.py b/Lib/test/test_tracemalloc.py
index a0037f81b8..556656747b 100644
--- a/Lib/test/test_tracemalloc.py
+++ b/Lib/test/test_tracemalloc.py
@@ -85,6 +85,25 @@ def traceback_filename(filename):
return traceback_lineno(filename, 0)
+class TestTraceback(unittest.TestCase):
+ def test_repr(self):
+ def get_repr(*args) -> str:
+ return repr(tracemalloc.Traceback(*args))
+
+ self.assertEqual(get_repr(()), "<Traceback ()>")
+ self.assertEqual(get_repr((), 0), "<Traceback () total_nframe=0>")
+
+ frames = (("f1", 1), ("f2", 2))
+ exp_repr_frames = (
+ "(<Frame filename='f2' lineno=2>,"
+ " <Frame filename='f1' lineno=1>)"
+ )
+ self.assertEqual(get_repr(frames),
+ f"<Traceback {exp_repr_frames}>")
+ self.assertEqual(get_repr(frames, 2),
+ f"<Traceback {exp_repr_frames} total_nframe=2>")
+
+
class TestTracemallocEnabled(unittest.TestCase):
def setUp(self):
if tracemalloc.is_tracing():
@@ -1065,6 +1084,7 @@ class TestCAPI(unittest.TestCase):
def test_main():
support.run_unittest(
+ TestTraceback,
TestTracemallocEnabled,
TestSnapshot,
TestFilters,
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index 75c5eee42d..83196ad3c1 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -713,6 +713,30 @@ class TypesTests(unittest.TestCase):
assert repr(int | None) == "int | None"
assert repr(int | typing.GenericAlias(list, int)) == "int | list[int]"
+ def test_or_type_operator_with_genericalias(self):
+ a = list[int]
+ b = list[str]
+ c = dict[float, str]
+ class SubClass(types.GenericAlias): ...
+ d = SubClass(list, float)
+ # equivalence with typing.Union
+ self.assertEqual(a | b | c | d, typing.Union[a, b, c, d])
+ # de-duplicate
+ self.assertEqual(a | c | b | b | a | c | d | d, a | b | c | d)
+ # order shouldn't matter
+ self.assertEqual(a | b | d, b | a | d)
+ self.assertEqual(repr(a | b | c | d),
+ "list[int] | list[str] | dict[float, str] | list[float]")
+
+ class BadType(type):
+ def __eq__(self, other):
+ return 1 / 0
+
+ bt = BadType('bt', (), {})
+ # Comparison should fail and errors should propagate out for bad types.
+ with self.assertRaises(ZeroDivisionError):
+ list[int] | list[bt]
+
def test_ellipsis_type(self):
self.assertIsInstance(Ellipsis, types.EllipsisType)
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 2ab8be49b2..c340c8a898 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -25,6 +25,7 @@ from typing import IO, TextIO, BinaryIO
from typing import Pattern, Match
from typing import Annotated, ForwardRef
from typing import TypeAlias
+from typing import ParamSpec, Concatenate
import abc
import typing
import weakref
@@ -447,14 +448,6 @@ class CallableTests(BaseTestCase):
def test_callable_wrong_forms(self):
with self.assertRaises(TypeError):
- Callable[[...], int]
- with self.assertRaises(TypeError):
- Callable[(), int]
- with self.assertRaises(TypeError):
- Callable[[()], int]
- with self.assertRaises(TypeError):
- Callable[[int, 1], 2]
- with self.assertRaises(TypeError):
Callable[int]
def test_callable_instance_works(self):
@@ -528,6 +521,7 @@ class LiteralTests(BaseTestCase):
self.assertEqual(repr(Literal[int]), "typing.Literal[int]")
self.assertEqual(repr(Literal), "typing.Literal")
self.assertEqual(repr(Literal[None]), "typing.Literal[None]")
+ self.assertEqual(repr(Literal[1, 2, 3, 3]), "typing.Literal[1, 2, 3]")
def test_cannot_init(self):
with self.assertRaises(TypeError):
@@ -559,6 +553,35 @@ class LiteralTests(BaseTestCase):
with self.assertRaises(TypeError):
Literal[1][1]
+ def test_equal(self):
+ self.assertNotEqual(Literal[0], Literal[False])
+ self.assertNotEqual(Literal[True], Literal[1])
+ self.assertNotEqual(Literal[1], Literal[2])
+ self.assertNotEqual(Literal[1, True], Literal[1])
+ self.assertEqual(Literal[1], Literal[1])
+ self.assertEqual(Literal[1, 2], Literal[2, 1])
+ self.assertEqual(Literal[1, 2, 3], Literal[1, 2, 3, 3])
+
+ def test_hash(self):
+ self.assertEqual(hash(Literal[1]), hash(Literal[1]))
+ self.assertEqual(hash(Literal[1, 2]), hash(Literal[2, 1]))
+ self.assertEqual(hash(Literal[1, 2, 3]), hash(Literal[1, 2, 3, 3]))
+
+ def test_args(self):
+ self.assertEqual(Literal[1, 2, 3].__args__, (1, 2, 3))
+ self.assertEqual(Literal[1, 2, 3, 3].__args__, (1, 2, 3))
+ self.assertEqual(Literal[1, Literal[2], Literal[3, 4]].__args__, (1, 2, 3, 4))
+ # Mutable arguments will not be deduplicated
+ self.assertEqual(Literal[[], []].__args__, ([], []))
+
+ def test_flatten(self):
+ l1 = Literal[Literal[1], Literal[2], Literal[3]]
+ l2 = Literal[Literal[1, 2], 3]
+ l3 = Literal[Literal[1, 2, 3]]
+ for l in l1, l2, l3:
+ self.assertEqual(l, Literal[1, 2, 3])
+ self.assertEqual(l.__args__, (1, 2, 3))
+
XK = TypeVar('XK', str, bytes)
XV = TypeVar('XV')
@@ -1108,10 +1131,6 @@ class ProtocolTests(BaseTestCase):
PR[int]
with self.assertRaises(TypeError):
P[int, str]
- with self.assertRaises(TypeError):
- PR[int, 1]
- with self.assertRaises(TypeError):
- PR[int, ClassVar]
class C(PR[int, T]): pass
@@ -1133,8 +1152,6 @@ class ProtocolTests(BaseTestCase):
self.assertIsSubclass(P, PR)
with self.assertRaises(TypeError):
PR[int]
- with self.assertRaises(TypeError):
- PR[int, 1]
class P1(Protocol, Generic[T]):
def bar(self, x: T) -> str: ...
@@ -1153,8 +1170,6 @@ class ProtocolTests(BaseTestCase):
return x
self.assertIsInstance(Test(), PSub)
- with self.assertRaises(TypeError):
- PR[int, ClassVar]
def test_init_called(self):
T = TypeVar('T')
@@ -1724,8 +1739,6 @@ class GenericTests(BaseTestCase):
self.assertEqual(typing.Iterable[Tuple[T, T]][T], typing.Iterable[Tuple[T, T]])
with self.assertRaises(TypeError):
Tuple[T, int][()]
- with self.assertRaises(TypeError):
- Tuple[T, U][T, ...]
self.assertEqual(Union[T, int][int], int)
self.assertEqual(Union[T, U][int, Union[int, str]], Union[int, str])
@@ -1737,10 +1750,6 @@ class GenericTests(BaseTestCase):
self.assertEqual(Callable[[T], T][KT], Callable[[KT], KT])
self.assertEqual(Callable[..., List[T]][int], Callable[..., List[int]])
- with self.assertRaises(TypeError):
- Callable[[T], U][..., int]
- with self.assertRaises(TypeError):
- Callable[[T], U][[], int]
def test_extended_generic_rules_repr(self):
T = TypeVar('T')
@@ -1777,10 +1786,9 @@ class GenericTests(BaseTestCase):
def test_extended_generic_rules_subclassing(self):
class T1(Tuple[T, KT]): ...
class T2(Tuple[T, ...]): ...
- class C1(Callable[[T], T]): ...
- class C2(Callable[..., int]):
- def __call__(self):
- return None
+ class C1(typing.Container[T]):
+ def __contains__(self, item):
+ return False
self.assertEqual(T1.__parameters__, (T, KT))
self.assertEqual(T1[int, str].__args__, (int, str))
@@ -1794,10 +1802,9 @@ class GenericTests(BaseTestCase):
## T2[int, str]
self.assertEqual(repr(C1[int]).split('.')[-1], 'C1[int]')
- self.assertEqual(C2.__parameters__, ())
- self.assertIsInstance(C2(), collections.abc.Callable)
- self.assertIsSubclass(C2, collections.abc.Callable)
- self.assertIsSubclass(C1, collections.abc.Callable)
+ self.assertEqual(C1.__parameters__, (T,))
+ self.assertIsInstance(C1(), collections.abc.Container)
+ self.assertIsSubclass(C1, collections.abc.Container)
self.assertIsInstance(T1(), tuple)
self.assertIsSubclass(T2, tuple)
with self.assertRaises(TypeError):
@@ -1831,10 +1838,6 @@ class GenericTests(BaseTestCase):
class MyTup(Tuple[T, T]): ...
self.assertIs(MyTup[int]().__class__, MyTup)
self.assertEqual(MyTup[int]().__orig_class__, MyTup[int])
- class MyCall(Callable[..., T]):
- def __call__(self): return None
- self.assertIs(MyCall[T]().__class__, MyCall)
- self.assertEqual(MyCall[T]().__orig_class__, MyCall[T])
class MyDict(typing.Dict[T, T]): ...
self.assertIs(MyDict[int]().__class__, MyDict)
self.assertEqual(MyDict[int]().__orig_class__, MyDict[int])
@@ -3865,10 +3868,14 @@ class TypedDictTests(BaseTestCase):
self.assertEqual(D(), {})
self.assertEqual(D(x=1), {'x': 1})
self.assertEqual(D.__total__, False)
+ self.assertEqual(D.__required_keys__, frozenset())
+ self.assertEqual(D.__optional_keys__, {'x'})
self.assertEqual(Options(), {})
self.assertEqual(Options(log_level=2), {'log_level': 2})
self.assertEqual(Options.__total__, False)
+ self.assertEqual(Options.__required_keys__, frozenset())
+ self.assertEqual(Options.__optional_keys__, {'log_level', 'log_path'})
def test_optional_keys(self):
class Point2Dor3D(Point2D, total=False):
@@ -4223,6 +4230,111 @@ class TypeAliasTests(BaseTestCase):
TypeAlias[int]
+class ParamSpecTests(BaseTestCase):
+
+ def test_basic_plain(self):
+ P = ParamSpec('P')
+ self.assertEqual(P, P)
+ self.assertIsInstance(P, ParamSpec)
+
+ def test_valid_uses(self):
+ P = ParamSpec('P')
+ T = TypeVar('T')
+ C1 = Callable[P, int]
+ self.assertEqual(C1.__args__, (P, int))
+ self.assertEqual(C1.__parameters__, (P,))
+ C2 = Callable[P, T]
+ self.assertEqual(C2.__args__, (P, T))
+ self.assertEqual(C2.__parameters__, (P, T))
+ # Test collections.abc.Callable too.
+ C3 = collections.abc.Callable[P, int]
+ self.assertEqual(C3.__args__, (P, int))
+ self.assertEqual(C3.__parameters__, (P,))
+ C4 = collections.abc.Callable[P, T]
+ self.assertEqual(C4.__args__, (P, T))
+ self.assertEqual(C4.__parameters__, (P, T))
+
+ # ParamSpec instances should also have args and kwargs attributes.
+ self.assertIn('args', dir(P))
+ self.assertIn('kwargs', dir(P))
+ P.args
+ P.kwargs
+
+ def test_user_generics(self):
+ T = TypeVar("T")
+ P = ParamSpec("P")
+ P_2 = ParamSpec("P_2")
+
+ class X(Generic[T, P]):
+ f: Callable[P, int]
+ x: T
+ G1 = X[int, P_2]
+ self.assertEqual(G1.__args__, (int, P_2))
+ self.assertEqual(G1.__parameters__, (P_2,))
+
+ G2 = X[int, Concatenate[int, P_2]]
+ self.assertEqual(G2.__args__, (int, Concatenate[int, P_2]))
+ self.assertEqual(G2.__parameters__, (P_2,))
+
+ G3 = X[int, [int, bool]]
+ self.assertEqual(G3.__args__, (int, (int, bool)))
+ self.assertEqual(G3.__parameters__, ())
+
+ G4 = X[int, ...]
+ self.assertEqual(G4.__args__, (int, Ellipsis))
+ self.assertEqual(G4.__parameters__, ())
+
+ class Z(Generic[P]):
+ f: Callable[P, int]
+
+ G5 = Z[[int, str, bool]]
+ self.assertEqual(G5.__args__, ((int, str, bool),))
+ self.assertEqual(G5.__parameters__, ())
+
+ G6 = Z[int, str, bool]
+ self.assertEqual(G6.__args__, ((int, str, bool),))
+ self.assertEqual(G6.__parameters__, ())
+
+ # G5 and G6 should be equivalent according to the PEP
+ self.assertEqual(G5.__args__, G6.__args__)
+ self.assertEqual(G5.__origin__, G6.__origin__)
+ self.assertEqual(G5.__parameters__, G6.__parameters__)
+ self.assertEqual(G5, G6)
+
+ def test_var_substitution(self):
+ T = TypeVar("T")
+ P = ParamSpec("P")
+ C1 = Callable[P, T]
+ self.assertEqual(C1[int, str], Callable[[int], str])
+ self.assertEqual(C1[[int, str, dict], float], Callable[[int, str, dict], float])
+
+
+class ConcatenateTests(BaseTestCase):
+ def test_basics(self):
+ P = ParamSpec('P')
+ class MyClass: ...
+ c = Concatenate[MyClass, P]
+ self.assertNotEqual(c, Concatenate)
+
+ def test_valid_uses(self):
+ P = ParamSpec('P')
+ T = TypeVar('T')
+ C1 = Callable[Concatenate[int, P], int]
+ self.assertEqual(C1.__args__, (Concatenate[int, P], int))
+ self.assertEqual(C1.__parameters__, (P,))
+ C2 = Callable[Concatenate[int, T, P], T]
+ self.assertEqual(C2.__args__, (Concatenate[int, T, P], T))
+ self.assertEqual(C2.__parameters__, (T, P))
+
+ # Test collections.abc.Callable too.
+ C3 = collections.abc.Callable[Concatenate[int, P], int]
+ self.assertEqual(C3.__args__, (Concatenate[int, P], int))
+ self.assertEqual(C3.__parameters__, (P,))
+ C4 = collections.abc.Callable[Concatenate[int, T, P], T]
+ self.assertEqual(C4.__args__, (Concatenate[int, T, P], T))
+ self.assertEqual(C4.__parameters__, (T, P))
+
+
class AllTests(BaseTestCase):
"""Tests for __all__."""
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 90b0965582..4f5636e142 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -2516,11 +2516,13 @@ class CAPITest(unittest.TestCase):
def test_from_format(self):
import_helper.import_module('ctypes')
from ctypes import (
+ c_char_p,
pythonapi, py_object, sizeof,
c_int, c_long, c_longlong, c_ssize_t,
c_uint, c_ulong, c_ulonglong, c_size_t, c_void_p)
name = "PyUnicode_FromFormat"
_PyUnicode_FromFormat = getattr(pythonapi, name)
+ _PyUnicode_FromFormat.argtypes = (c_char_p,)
_PyUnicode_FromFormat.restype = py_object
def PyUnicode_FromFormat(format, *args):
diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py
index 532aa3a639..c7c8613ea2 100644
--- a/Lib/test/test_unparse.py
+++ b/Lib/test/test_unparse.py
@@ -152,6 +152,18 @@ class UnparseTestCase(ASTTestCase):
# See issue 25180
self.check_ast_roundtrip(r"""f'{f"{0}"*3}'""")
self.check_ast_roundtrip(r"""f'{f"{y}"*3}'""")
+ self.check_ast_roundtrip("""f''""")
+ self.check_ast_roundtrip('''f"""'end' "quote\\""""''')
+
+ def test_fstrings_complicated(self):
+ # See issue 28002
+ self.check_ast_roundtrip("""f'''{"'"}'''""")
+ self.check_ast_roundtrip('''f\'\'\'-{f"""*{f"+{f'.{x}.'}+"}*"""}-\'\'\'''')
+ self.check_ast_roundtrip('''f\'\'\'-{f"""*{f"+{f'.{x}.'}+"}*"""}-'single quote\\'\'\'\'''')
+ self.check_ast_roundtrip('f"""{\'\'\'\n\'\'\'}"""')
+ self.check_ast_roundtrip('f"""{g(\'\'\'\n\'\'\')}"""')
+ self.check_ast_roundtrip('''f"a\\r\\nb"''')
+ self.check_ast_roundtrip('''f"\\u2028{'x'}"''')
def test_strings(self):
self.check_ast_roundtrip("u'foo'")
@@ -311,6 +323,9 @@ class UnparseTestCase(ASTTestCase):
)
)
+ def test_invalid_fstring_backslash(self):
+ self.check_invalid(ast.FormattedValue(value=ast.Constant(value="\\\\")))
+
def test_invalid_set(self):
self.check_invalid(ast.Set(elts=[]))
@@ -330,8 +345,8 @@ class UnparseTestCase(ASTTestCase):
'\r\\r\t\\t\n\\n',
'""">>> content = \"\"\"blabla\"\"\" <<<"""',
r'foo\n\x00',
- '🐍⛎𩸽üéş^\N{LONG RIGHTWARDS SQUIGGLE ARROW}'
-
+ "' \\'\\'\\'\"\"\" \"\"\\'\\' \\'",
+ '🐍⛎𩸽üéş^\\\\X\\\\BB\N{LONG RIGHTWARDS SQUIGGLE ARROW}'
)
for docstring in docstrings:
# check as Module docstrings for easy testing
@@ -416,7 +431,6 @@ class CosmeticTestCase(ASTTestCase):
self.check_src_roundtrip("call((yield x))")
self.check_src_roundtrip("return x + (yield x)")
-
def test_class_bases_and_keywords(self):
self.check_src_roundtrip("class X:\n pass")
self.check_src_roundtrip("class X(A):\n pass")
@@ -429,6 +443,13 @@ class CosmeticTestCase(ASTTestCase):
self.check_src_roundtrip("class X(*args):\n pass")
self.check_src_roundtrip("class X(*args, **kwargs):\n pass")
+ def test_fstrings(self):
+ self.check_src_roundtrip('''f\'\'\'-{f"""*{f"+{f'.{x}.'}+"}*"""}-\'\'\'''')
+ self.check_src_roundtrip('''f"\\u2028{'x'}"''')
+ self.check_src_roundtrip(r"f'{x}\n'")
+ self.check_src_roundtrip('''f''\'{"""\n"""}\\n''\'''')
+ self.check_src_roundtrip('''f''\'{f"""{x}\n"""}\\n''\'''')
+
def test_docstrings(self):
docstrings = (
'"""simple doc string"""',
@@ -443,6 +464,10 @@ class CosmeticTestCase(ASTTestCase):
'""""""',
'"""\'\'\'"""',
'"""\'\'\'\'\'\'"""',
+ '"""🐍⛎𩸽üéş^\\\\X\\\\BB⟿"""',
+ '"""end in single \'quote\'"""',
+ "'''end in double \"quote\"'''",
+ '"""almost end in double "quote"."""',
)
for prefix in docstring_prefixes:
@@ -483,9 +508,8 @@ class DirectoryTestCase(ASTTestCase):
lib_dir = pathlib.Path(__file__).parent / ".."
test_directories = (lib_dir, lib_dir / "test")
- skip_files = {"test_fstring.py"}
run_always_files = {"test_grammar.py", "test_syntax.py", "test_compile.py",
- "test_ast.py", "test_asdl_parser.py"}
+ "test_ast.py", "test_asdl_parser.py", "test_fstring.py"}
_files_to_test = None
@@ -525,14 +549,6 @@ class DirectoryTestCase(ASTTestCase):
if test.support.verbose:
print(f"Testing {item.absolute()}")
- # Some f-strings are not correctly round-tripped by
- # Tools/parser/unparse.py. See issue 28002 for details.
- # We need to skip files that contain such f-strings.
- if item.name in self.skip_files:
- if test.support.verbose:
- print(f"Skipping {item.absolute()}: see issue 28002")
- continue
-
with self.subTest(filename=item):
source = read_pyfile(item)
self.check_ast_roundtrip(source)
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py
index c1d55ee8b2..4750ad9600 100644
--- a/Lib/test/test_urllib2net.py
+++ b/Lib/test/test_urllib2net.py
@@ -277,7 +277,7 @@ class OtherNetworkTests(unittest.TestCase):
ioerror_peer_reset:
buf = f.read()
debug("read %d bytes" % len(buf))
- except socket.timeout:
+ except TimeoutError:
print("<timeout: %s>" % url, file=sys.stderr)
f.close()
time.sleep(0.1)
diff --git a/Lib/test/test_utf8_mode.py b/Lib/test/test_utf8_mode.py
index bdb93457cf..8b6332ee22 100644
--- a/Lib/test/test_utf8_mode.py
+++ b/Lib/test/test_utf8_mode.py
@@ -3,11 +3,13 @@ Test the implementation of the PEP 540: the UTF-8 Mode.
"""
import locale
+import subprocess
import sys
import textwrap
import unittest
from test import support
from test.support.script_helper import assert_python_ok, assert_python_failure
+from test.support import os_helper
MS_WINDOWS = (sys.platform == 'win32')
@@ -250,6 +252,31 @@ class UTF8ModeTests(unittest.TestCase):
out = self.get_output('-X', 'utf8', '-E', '-c', code)
self.assertEqual(out, '1')
+ @unittest.skipIf(MS_WINDOWS,
+ "os.device_encoding() doesn't implement "
+ "the UTF-8 Mode on Windows")
+ def test_device_encoding(self):
+ # Use stdout as TTY
+ if not sys.stdout.isatty():
+ self.skipTest("sys.stdout is not a TTY")
+
+ filename = 'out.txt'
+ self.addCleanup(os_helper.unlink, filename)
+
+ code = (f'import os, sys; fd = sys.stdout.fileno(); '
+ f'out = open({filename!r}, "w", encoding="utf-8"); '
+ f'print(os.isatty(fd), os.device_encoding(fd), file=out); '
+ f'out.close()')
+ cmd = [sys.executable, '-X', 'utf8', '-c', code]
+ # The stdout TTY is inherited to the child process
+ proc = subprocess.run(cmd, text=True)
+ self.assertEqual(proc.returncode, 0, proc)
+
+ # In UTF-8 Mode, device_encoding(fd) returns "UTF-8" if fd is a TTY
+ with open(filename, encoding="utf8") as fp:
+ out = fp.read().rstrip()
+ self.assertEqual(out, 'True UTF-8')
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py
index 718113d6e1..d6a8333427 100644..100755
--- a/Lib/test/test_uuid.py
+++ b/Lib/test/test_uuid.py
@@ -639,7 +639,7 @@ class BaseTestUUID:
equal(u, self.uuid.UUID(v))
equal(str(u), v)
- @unittest.skipUnless(os.name == 'posix', 'requires Posix')
+ @unittest.skipUnless(hasattr(os, 'fork'), 'need os.fork')
def testIssue8621(self):
# On at least some versions of OSX self.uuid.uuid4 generates
# the same sequence of UUIDs in the parent and any
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
index 5bb62cdb37..098ba17af5 100644
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -446,7 +446,7 @@ class EnsurePipTest(BaseTest):
# pip's cross-version compatibility may trigger deprecation
# warnings in current versions of Python. Ensure related
# environment settings don't cause venv to fail.
- envvars["PYTHONWARNINGS"] = "e"
+ envvars["PYTHONWARNINGS"] = "ignore"
# ensurepip is different enough from a normal pip invocation
# that we want to ensure it ignores the normal pip environment
# variable settings. We set PIP_NO_INSTALL here specifically
@@ -485,7 +485,8 @@ class EnsurePipTest(BaseTest):
# Ensure pip is available in the virtual environment
envpy = os.path.join(os.path.realpath(self.env_dir), self.bindir, self.exe)
# Ignore DeprecationWarning since pip code is not part of Python
- out, err = check_output([envpy, '-W', 'ignore::DeprecationWarning', '-I',
+ out, err = check_output([envpy, '-W', 'ignore::DeprecationWarning',
+ '-W', 'ignore::ImportWarning', '-I',
'-m', 'pip', '--version'])
# We force everything to text, so unittest gives the detailed diff
# if we get unexpected results
@@ -501,8 +502,12 @@ class EnsurePipTest(BaseTest):
# Check the private uninstall command provided for the Windows
# installers works (at least in a virtual environment)
with EnvironmentVarGuard() as envvars:
+ # It seems ensurepip._uninstall calls subprocesses which do not
+ # inherit the interpreter settings.
+ envvars["PYTHONWARNINGS"] = "ignore"
out, err = check_output([envpy,
- '-W', 'ignore::DeprecationWarning', '-I',
+ '-W', 'ignore::DeprecationWarning',
+ '-W', 'ignore::ImportWarning', '-I',
'-m', 'ensurepip._uninstall'])
# We force everything to text, so unittest gives the detailed diff
# if we get unexpected results
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 3f1f3781e4..fd4a38527f 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -2852,8 +2852,12 @@ class ElementFindTest(unittest.TestCase):
['tag'] * 3)
self.assertEqual(summarize_list(e.findall('.//tag[@class="a"]')),
['tag'])
+ self.assertEqual(summarize_list(e.findall('.//tag[@class!="a"]')),
+ ['tag'] * 2)
self.assertEqual(summarize_list(e.findall('.//tag[@class="b"]')),
['tag'] * 2)
+ self.assertEqual(summarize_list(e.findall('.//tag[@class!="b"]')),
+ ['tag'])
self.assertEqual(summarize_list(e.findall('.//tag[@id]')),
['tag'])
self.assertEqual(summarize_list(e.findall('.//section[tag]')),
@@ -2875,6 +2879,19 @@ class ElementFindTest(unittest.TestCase):
self.assertEqual(summarize_list(e.findall(".//section[ tag = 'subtext' ]")),
['section'])
+ # Negations of above tests. They match nothing because the sole section
+ # tag has subtext.
+ self.assertEqual(summarize_list(e.findall(".//section[tag!='subtext']")),
+ [])
+ self.assertEqual(summarize_list(e.findall(".//section[tag !='subtext']")),
+ [])
+ self.assertEqual(summarize_list(e.findall(".//section[tag!= 'subtext']")),
+ [])
+ self.assertEqual(summarize_list(e.findall(".//section[tag != 'subtext']")),
+ [])
+ self.assertEqual(summarize_list(e.findall(".//section[ tag != 'subtext' ]")),
+ [])
+
self.assertEqual(summarize_list(e.findall(".//tag[.='subtext']")),
['tag'])
self.assertEqual(summarize_list(e.findall(".//tag[. ='subtext']")),
@@ -2890,6 +2907,24 @@ class ElementFindTest(unittest.TestCase):
self.assertEqual(summarize_list(e.findall(".//tag[.= ' subtext']")),
[])
+ # Negations of above tests.
+ # Matches everything but the tag containing subtext
+ self.assertEqual(summarize_list(e.findall(".//tag[.!='subtext']")),
+ ['tag'] * 3)
+ self.assertEqual(summarize_list(e.findall(".//tag[. !='subtext']")),
+ ['tag'] * 3)
+ self.assertEqual(summarize_list(e.findall('.//tag[.!= "subtext"]')),
+ ['tag'] * 3)
+ self.assertEqual(summarize_list(e.findall('.//tag[ . != "subtext" ]')),
+ ['tag'] * 3)
+ self.assertEqual(summarize_list(e.findall(".//tag[. != 'subtext']")),
+ ['tag'] * 3)
+ # Matches all tags.
+ self.assertEqual(summarize_list(e.findall(".//tag[. != 'subtext ']")),
+ ['tag'] * 4)
+ self.assertEqual(summarize_list(e.findall(".//tag[.!= ' subtext']")),
+ ['tag'] * 4)
+
# duplicate section => 2x tag matches
e[1] = e[2]
self.assertEqual(summarize_list(e.findall(".//section[tag = 'subtext']")),
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 3dfa84bf77..c54aeb1094 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -648,7 +648,7 @@ def http_server(evt, numrequests, requestHandler=None, encoding=None):
serv.handle_request()
numrequests -= 1
- except socket.timeout:
+ except TimeoutError:
pass
finally:
serv.socket.close()
@@ -713,7 +713,7 @@ def http_multi_server(evt, numrequests, requestHandler=None):
serv.handle_request()
numrequests -= 1
- except socket.timeout:
+ except TimeoutError:
pass
finally:
serv.socket.close()
diff --git a/Lib/test/test_xxlimited.py b/Lib/test/test_xxlimited.py
new file mode 100644
index 0000000000..e3f521d9b0
--- /dev/null
+++ b/Lib/test/test_xxlimited.py
@@ -0,0 +1,79 @@
+import unittest
+from test.support import import_helper
+import types
+
+xxlimited = import_helper.import_module('xxlimited')
+xxlimited_35 = import_helper.import_module('xxlimited_35')
+
+
+class CommonTests:
+ module: types.ModuleType
+
+ def test_xxo_new(self):
+ xxo = self.module.Xxo()
+
+ def test_xxo_attributes(self):
+ xxo = self.module.Xxo()
+ with self.assertRaises(AttributeError):
+ xxo.foo
+ with self.assertRaises(AttributeError):
+ del xxo.foo
+
+ xxo.foo = 1234
+ self.assertEqual(xxo.foo, 1234)
+
+ del xxo.foo
+ with self.assertRaises(AttributeError):
+ xxo.foo
+
+ def test_foo(self):
+ # the foo function adds 2 numbers
+ self.assertEqual(self.module.foo(1, 2), 3)
+
+ def test_str(self):
+ self.assertTrue(issubclass(self.module.Str, str))
+ self.assertIsNot(self.module.Str, str)
+
+ custom_string = self.module.Str("abcd")
+ self.assertEqual(custom_string, "abcd")
+ self.assertEqual(custom_string.upper(), "ABCD")
+
+ def test_new(self):
+ xxo = self.module.new()
+ self.assertEqual(xxo.demo("abc"), "abc")
+
+
+class TestXXLimited(CommonTests, unittest.TestCase):
+ module = xxlimited
+
+ def test_xxo_demo(self):
+ xxo = self.module.Xxo()
+ other = self.module.Xxo()
+ self.assertEqual(xxo.demo("abc"), "abc")
+ self.assertEqual(xxo.demo(xxo), xxo)
+ self.assertEqual(xxo.demo(other), other)
+ self.assertEqual(xxo.demo(0), None)
+
+ def test_error(self):
+ with self.assertRaises(self.module.Error):
+ raise self.module.Error
+
+
+class TestXXLimited35(CommonTests, unittest.TestCase):
+ module = xxlimited_35
+
+ def test_xxo_demo(self):
+ xxo = self.module.Xxo()
+ other = self.module.Xxo()
+ self.assertEqual(xxo.demo("abc"), "abc")
+ self.assertEqual(xxo.demo(0), None)
+
+ def test_roj(self):
+ # the roj function always fails
+ with self.assertRaises(SystemError):
+ self.module.roj(0)
+
+ def test_null(self):
+ null1 = self.module.Null()
+ null2 = self.module.Null()
+ self.assertNotEqual(null1, null2)
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index b3c24213f3..7c09e2f51b 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -2966,6 +2966,12 @@ class TestPath(unittest.TestCase):
assert e.read_text() == "content of e"
@pass_alpharep
+ def test_joinpath_multiple(self, alpharep):
+ root = zipfile.Path(alpharep)
+ e = root.joinpath("b", "d", "e.txt")
+ assert e.read_text() == "content of e"
+
+ @pass_alpharep
def test_traverse_truediv(self, alpharep):
root = zipfile.Path(alpharep)
a = root / "a.txt"
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index 8df7489f75..d59ef1ed6f 100644
--- a/Lib/test/test_zipimport.py
+++ b/Lib/test/test_zipimport.py
@@ -7,6 +7,7 @@ import struct
import time
import unittest
import unittest.mock
+import warnings
from test import support
from test.support import import_helper
@@ -241,10 +242,10 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
files = {TESTMOD + pyc_ext: (NOW, badmagic_pyc)}
try:
self.doTest(".py", files, TESTMOD)
- except ImportError:
- pass
- else:
- self.fail("expected ImportError; import from bad pyc")
+ self.fail("This should not be reached")
+ except zipimport.ZipImportError as exc:
+ self.assertIsInstance(exc.__cause__, ImportError)
+ self.assertIn("magic number", exc.__cause__.msg)
def testBadMTime(self):
badtime_pyc = bytearray(test_pyc)
@@ -450,37 +451,54 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
zi = zipimport.zipimporter(TEMP_ZIP)
self.assertEqual(zi.archive, TEMP_ZIP)
- self.assertEqual(zi.is_package(TESTPACK), True)
-
- find_mod = zi.find_module('spam')
- self.assertIsNotNone(find_mod)
- self.assertIsInstance(find_mod, zipimport.zipimporter)
- self.assertFalse(find_mod.is_package('spam'))
- load_mod = find_mod.load_module('spam')
- self.assertEqual(find_mod.get_filename('spam'), load_mod.__file__)
-
- mod = zi.load_module(TESTPACK)
+ self.assertTrue(zi.is_package(TESTPACK))
+
+ # PEP 302
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ find_mod = zi.find_module('spam')
+ self.assertIsNotNone(find_mod)
+ self.assertIsInstance(find_mod, zipimport.zipimporter)
+ self.assertFalse(find_mod.is_package('spam'))
+ load_mod = find_mod.load_module('spam')
+ self.assertEqual(find_mod.get_filename('spam'), load_mod.__file__)
+
+ mod = zi.load_module(TESTPACK)
+ self.assertEqual(zi.get_filename(TESTPACK), mod.__file__)
+
+ # PEP 451
+ spec = zi.find_spec('spam')
+ self.assertIsNotNone(spec)
+ self.assertIsInstance(spec.loader, zipimport.zipimporter)
+ self.assertFalse(spec.loader.is_package('spam'))
+ exec_mod = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(exec_mod)
+ self.assertEqual(spec.loader.get_filename('spam'), exec_mod.__file__)
+
+ spec = zi.find_spec(TESTPACK)
+ mod = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(mod)
self.assertEqual(zi.get_filename(TESTPACK), mod.__file__)
existing_pack_path = importlib.import_module(TESTPACK).__path__[0]
expected_path_path = os.path.join(TEMP_ZIP, TESTPACK)
self.assertEqual(existing_pack_path, expected_path_path)
- self.assertEqual(zi.is_package(packdir + '__init__'), False)
- self.assertEqual(zi.is_package(packdir + TESTPACK2), True)
- self.assertEqual(zi.is_package(packdir2 + TESTMOD), False)
+ self.assertFalse(zi.is_package(packdir + '__init__'))
+ self.assertTrue(zi.is_package(packdir + TESTPACK2))
+ self.assertFalse(zi.is_package(packdir2 + TESTMOD))
mod_path = packdir2 + TESTMOD
mod_name = module_path_to_dotted_name(mod_path)
mod = importlib.import_module(mod_name)
self.assertTrue(mod_name in sys.modules)
- self.assertEqual(zi.get_source(TESTPACK), None)
- self.assertEqual(zi.get_source(mod_path), None)
+ self.assertIsNone(zi.get_source(TESTPACK))
+ self.assertIsNone(zi.get_source(mod_path))
self.assertEqual(zi.get_filename(mod_path), mod.__file__)
# To pass in the module name instead of the path, we must use the
# right importer
- loader = mod.__loader__
- self.assertEqual(loader.get_source(mod_name), None)
+ loader = mod.__spec__.loader
+ self.assertIsNone(loader.get_source(mod_name))
self.assertEqual(loader.get_filename(mod_name), mod.__file__)
# test prefix and archivepath members
@@ -505,36 +523,55 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
zi = zipimport.zipimporter(TEMP_ZIP + os.sep + packdir)
self.assertEqual(zi.archive, TEMP_ZIP)
self.assertEqual(zi.prefix, packdir)
- self.assertEqual(zi.is_package(TESTPACK2), True)
- mod = zi.load_module(TESTPACK2)
- self.assertEqual(zi.get_filename(TESTPACK2), mod.__file__)
-
- self.assertEqual(
- zi.is_package(TESTPACK2 + os.sep + '__init__'), False)
- self.assertEqual(
- zi.is_package(TESTPACK2 + os.sep + TESTMOD), False)
+ self.assertTrue(zi.is_package(TESTPACK2))
+ # PEP 302
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ mod = zi.load_module(TESTPACK2)
+ self.assertEqual(zi.get_filename(TESTPACK2), mod.__file__)
+ # PEP 451
+ spec = zi.find_spec(TESTPACK2)
+ mod = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(mod)
+ self.assertEqual(spec.loader.get_filename(TESTPACK2), mod.__file__)
+
+ self.assertFalse(zi.is_package(TESTPACK2 + os.sep + '__init__'))
+ self.assertFalse(zi.is_package(TESTPACK2 + os.sep + TESTMOD))
pkg_path = TEMP_ZIP + os.sep + packdir + TESTPACK2
zi2 = zipimport.zipimporter(pkg_path)
- find_mod_dotted = zi2.find_module(TESTMOD)
- self.assertIsNotNone(find_mod_dotted)
- self.assertIsInstance(find_mod_dotted, zipimport.zipimporter)
- self.assertFalse(zi2.is_package(TESTMOD))
- load_mod = find_mod_dotted.load_module(TESTMOD)
+ # PEP 302
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ find_mod_dotted = zi2.find_module(TESTMOD)
+ self.assertIsNotNone(find_mod_dotted)
+ self.assertIsInstance(find_mod_dotted, zipimport.zipimporter)
+ self.assertFalse(zi2.is_package(TESTMOD))
+ load_mod = find_mod_dotted.load_module(TESTMOD)
+ self.assertEqual(
+ find_mod_dotted.get_filename(TESTMOD), load_mod.__file__)
+
+ # PEP 451
+ spec = zi2.find_spec(TESTMOD)
+ self.assertIsNotNone(spec)
+ self.assertIsInstance(spec.loader, zipimport.zipimporter)
+ self.assertFalse(spec.loader.is_package(TESTMOD))
+ load_mod = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(load_mod)
self.assertEqual(
- find_mod_dotted.get_filename(TESTMOD), load_mod.__file__)
+ spec.loader.get_filename(TESTMOD), load_mod.__file__)
mod_path = TESTPACK2 + os.sep + TESTMOD
mod_name = module_path_to_dotted_name(mod_path)
mod = importlib.import_module(mod_name)
self.assertTrue(mod_name in sys.modules)
- self.assertEqual(zi.get_source(TESTPACK2), None)
- self.assertEqual(zi.get_source(mod_path), None)
+ self.assertIsNone(zi.get_source(TESTPACK2))
+ self.assertIsNone(zi.get_source(mod_path))
self.assertEqual(zi.get_filename(mod_path), mod.__file__)
# To pass in the module name instead of the path, we must use the
# right importer.
loader = mod.__loader__
- self.assertEqual(loader.get_source(mod_name), None)
+ self.assertIsNone(loader.get_source(mod_name))
self.assertEqual(loader.get_filename(mod_name), mod.__file__)
def testGetData(self):
@@ -655,7 +692,9 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
zinfo = ZipInfo(TESTMOD + ".py", time.localtime(NOW))
zinfo.compress_type = self.compression
z.writestr(zinfo, test_src)
- zipimport.zipimporter(filename).load_module(TESTMOD)
+ spec = zipimport.zipimporter(filename).find_spec(TESTMOD)
+ mod = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(mod)
def testBytesPath(self):
filename = os_helper.TESTFN + ".zip"
@@ -746,17 +785,24 @@ class BadFileZipImportTestCase(unittest.TestCase):
z = zipimport.zipimporter(TESTMOD)
try:
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ self.assertRaises(TypeError, z.load_module, None)
self.assertRaises(TypeError, z.find_module, None)
- self.assertRaises(TypeError, z.load_module, None)
+ self.assertRaises(TypeError, z.find_spec, None)
+ self.assertRaises(TypeError, z.exec_module, None)
self.assertRaises(TypeError, z.is_package, None)
self.assertRaises(TypeError, z.get_code, None)
self.assertRaises(TypeError, z.get_data, None)
self.assertRaises(TypeError, z.get_source, None)
error = zipimport.ZipImportError
- self.assertEqual(z.find_module('abc'), None)
+ self.assertIsNone(z.find_module('abc'))
+ self.assertIsNone(z.find_spec('abc'))
- self.assertRaises(error, z.load_module, 'abc')
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ self.assertRaises(error, z.load_module, 'abc')
self.assertRaises(error, z.get_code, 'abc')
self.assertRaises(OSError, z.get_data, 'abc')
self.assertRaises(error, z.get_source, 'abc')
diff --git a/Lib/threading.py b/Lib/threading.py
index 06c77f70fe..7b3d63dd21 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -28,7 +28,7 @@ __all__ = ['get_ident', 'active_count', 'Condition', 'current_thread',
'Event', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread',
'Barrier', 'BrokenBarrierError', 'Timer', 'ThreadError',
'setprofile', 'settrace', 'local', 'stack_size',
- 'excepthook', 'ExceptHookArgs']
+ 'excepthook', 'ExceptHookArgs', 'gettrace', 'getprofile']
# Rename some stuff so "from threading import *" is safe
_start_new_thread = _thread.start_new_thread
@@ -65,6 +65,10 @@ def setprofile(func):
global _profile_hook
_profile_hook = func
+def getprofile():
+ """Get the profiler function as set by threading.setprofile()."""
+ return _profile_hook
+
def settrace(func):
"""Set a trace function for all threads started from the threading module.
@@ -75,6 +79,10 @@ def settrace(func):
global _trace_hook
_trace_hook = func
+def gettrace():
+ """Get the trace function as set by threading.settrace()."""
+ return _trace_hook
+
# Synchronization classes
Lock = _allocate_lock
@@ -836,8 +844,12 @@ class Thread:
# they may be in an invalid state leading to a deadlock or crash.
self._started._at_fork_reinit()
if is_alive:
- self._tstate_lock._at_fork_reinit()
- self._tstate_lock.acquire()
+ # bpo-42350: If the fork happens when the thread is already stopped
+ # (ex: after threading._shutdown() has been called), _tstate_lock
+ # is None. Do nothing in this case.
+ if self._tstate_lock is not None:
+ self._tstate_lock._at_fork_reinit()
+ self._tstate_lock.acquire()
else:
# The thread isn't alive after fork: it doesn't have a tstate
# anymore.
@@ -1192,6 +1204,10 @@ except ImportError:
stderr.flush()
+# Original value of threading.excepthook
+__excepthook__ = excepthook
+
+
def _make_invoke_excepthook():
# Create a local namespace to ensure that variables remain alive
# when _invoke_excepthook() is called, even if it is called late during
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
index 3bfeb7a017..fec56553e4 100644
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -270,7 +270,7 @@ class Event:
)
-_support_default_root = 1
+_support_default_root = True
_default_root = None
@@ -280,13 +280,51 @@ def NoDefaultRoot():
Call this function to inhibit that the first instance of
Tk is used for windows without an explicit parent window.
"""
- global _support_default_root
- _support_default_root = 0
- global _default_root
+ global _support_default_root, _default_root
+ _support_default_root = False
+ # Delete, so any use of _default_root will immediately raise an exception.
+ # Rebind before deletion, so repeated calls will not fail.
_default_root = None
del _default_root
+def _get_default_root(what=None):
+ if not _support_default_root:
+ raise RuntimeError("No master specified and tkinter is "
+ "configured to not support default root")
+ if _default_root is None:
+ if what:
+ raise RuntimeError(f"Too early to {what}: no default root window")
+ root = Tk()
+ assert _default_root is root
+ return _default_root
+
+
+def _get_temp_root():
+ global _support_default_root
+ if not _support_default_root:
+ raise RuntimeError("No master specified and tkinter is "
+ "configured to not support default root")
+ root = _default_root
+ if root is None:
+ assert _support_default_root
+ _support_default_root = False
+ root = Tk()
+ _support_default_root = True
+ assert _default_root is None
+ root.withdraw()
+ root._temporary = True
+ return root
+
+
+def _destroy_temp_root(master):
+ if getattr(master, '_temporary', False):
+ try:
+ master.destroy()
+ except TclError:
+ pass
+
+
def _tkerror(err):
"""Internal function."""
pass
@@ -329,8 +367,8 @@ class Variable:
if name is not None and not isinstance(name, str):
raise TypeError("name must be a string")
global _varnum
- if not master:
- master = _default_root
+ if master is None:
+ master = _get_default_root('create variable')
self._root = master._root()
self._tk = master.tk
if name:
@@ -591,7 +629,7 @@ class BooleanVar(Variable):
def mainloop(n=0):
"""Run the main loop of Tcl."""
- _default_root.tk.mainloop(n)
+ _get_default_root('run the main loop').tk.mainloop(n)
getint = int
@@ -600,9 +638,9 @@ getdouble = float
def getboolean(s):
- """Convert true and false to integer values 1 and 0."""
+ """Convert Tcl object to True or False."""
try:
- return _default_root.tk.getboolean(s)
+ return _get_default_root('use getboolean()').tk.getboolean(s)
except TclError:
raise ValueError("invalid literal for getboolean()")
@@ -795,7 +833,7 @@ class Misc:
function which shall be called. Additional parameters
are given as parameters to the function call. Return
identifier to cancel scheduling with after_cancel."""
- if not func:
+ if func is None:
# I'd rather use time.sleep(ms*0.001)
self.tk.call('after', ms)
return None
@@ -1529,7 +1567,7 @@ class Misc:
def _root(self):
"""Internal function."""
w = self
- while w.master: w = w.master
+ while w.master is not None: w = w.master
return w
_subst_format = ('%#', '%b', '%f', '%h', '%k',
'%s', '%t', '%w', '%x', '%y',
@@ -2248,7 +2286,7 @@ class Tk(Misc, Wm):
is the name of the widget class."""
self.master = None
self.children = {}
- self._tkloaded = 0
+ self._tkloaded = False
# to avoid recursions in the getattr code in case of failure, we
# ensure that self.tk is always _something_.
self.tk = None
@@ -2272,7 +2310,7 @@ class Tk(Misc, Wm):
self._loadtk()
def _loadtk(self):
- self._tkloaded = 1
+ self._tkloaded = True
global _default_root
# Version sanity checks
tk_version = self.tk.getvar('tk_version')
@@ -2293,7 +2331,7 @@ class Tk(Misc, Wm):
self.tk.createcommand('exit', _exit)
self._tclCommands.append('tkerror')
self._tclCommands.append('exit')
- if _support_default_root and not _default_root:
+ if _support_default_root and _default_root is None:
_default_root = self
self.protocol("WM_DELETE_WINDOW", self.destroy)
@@ -2521,12 +2559,8 @@ class BaseWidget(Misc):
def _setup(self, master, cnf):
"""Internal function. Sets up information about children."""
- if _support_default_root:
- global _default_root
- if not master:
- if not _default_root:
- _default_root = Tk()
- master = _default_root
+ if master is None:
+ master = _get_default_root()
self.master = master
self.tk = master.tk
name = None
@@ -3940,7 +3974,7 @@ class _setit:
def __call__(self, *args):
self.__var.set(self.__value)
- if self.__callback:
+ if self.__callback is not None:
self.__callback(self.__value, *args)
@@ -3989,10 +4023,8 @@ class Image:
def __init__(self, imgtype, name=None, cnf={}, master=None, **kw):
self.name = None
- if not master:
- master = _default_root
- if not master:
- raise RuntimeError('Too early to create image')
+ if master is None:
+ master = _get_default_root('create image')
self.tk = getattr(master, 'tk', master)
if not name:
Image._last_id += 1
@@ -4146,11 +4178,13 @@ class BitmapImage(Image):
def image_names():
- return _default_root.tk.splitlist(_default_root.tk.call('image', 'names'))
+ tk = _get_default_root('use image_names()').tk
+ return tk.splitlist(tk.call('image', 'names'))
def image_types():
- return _default_root.tk.splitlist(_default_root.tk.call('image', 'types'))
+ tk = _get_default_root('use image_types()').tk
+ return tk.splitlist(tk.call('image', 'types'))
class Spinbox(Widget, XView):
diff --git a/Lib/tkinter/commondialog.py b/Lib/tkinter/commondialog.py
index e56b5baf7d..e595c99def 100644
--- a/Lib/tkinter/commondialog.py
+++ b/Lib/tkinter/commondialog.py
@@ -10,7 +10,7 @@
__all__ = ["Dialog"]
-from tkinter import Frame
+from tkinter import Frame, _get_temp_root, _destroy_temp_root
class Dialog:
@@ -18,10 +18,10 @@ class Dialog:
command = None
def __init__(self, master=None, **options):
+ if master is None:
+ master = options.get('parent')
self.master = master
self.options = options
- if not master and options.get('parent'):
- self.master = options['parent']
def _fixoptions(self):
pass # hook
@@ -37,22 +37,17 @@ class Dialog:
self._fixoptions()
- # we need a dummy widget to properly process the options
- # (at least as long as we use Tkinter 1.63)
- w = Frame(self.master)
-
+ master = self.master
+ if master is None:
+ master = _get_temp_root()
try:
-
- s = w.tk.call(self.command, *w._options(self.options))
-
- s = self._fixresult(w, s)
-
+ self._test_callback(master) # The function below is replaced for some tests.
+ s = master.tk.call(self.command, *master._options(self.options))
+ s = self._fixresult(master, s)
finally:
-
- try:
- # get rid of the widget
- w.destroy()
- except:
- pass
+ _destroy_temp_root(master)
return s
+
+ def _test_callback(self, master):
+ pass
diff --git a/Lib/tkinter/dnd.py b/Lib/tkinter/dnd.py
index 3120ff342f..acec61ba71 100644
--- a/Lib/tkinter/dnd.py
+++ b/Lib/tkinter/dnd.py
@@ -108,7 +108,7 @@ __all__ = ["dnd_start", "DndHandler"]
def dnd_start(source, event):
h = DndHandler(source, event)
- if h.root:
+ if h.root is not None:
return h
else:
return None
@@ -143,7 +143,7 @@ class DndHandler:
def __del__(self):
root = self.root
self.root = None
- if root:
+ if root is not None:
try:
del root.__dnd
except AttributeError:
@@ -154,25 +154,25 @@ class DndHandler:
target_widget = self.initial_widget.winfo_containing(x, y)
source = self.source
new_target = None
- while target_widget:
+ while target_widget is not None:
try:
attr = target_widget.dnd_accept
except AttributeError:
pass
else:
new_target = attr(source, event)
- if new_target:
+ if new_target is not None:
break
target_widget = target_widget.master
old_target = self.target
if old_target is new_target:
- if old_target:
+ if old_target is not None:
old_target.dnd_motion(source, event)
else:
- if old_target:
+ if old_target is not None:
self.target = None
old_target.dnd_leave(source, event)
- if new_target:
+ if new_target is not None:
new_target.dnd_enter(source, event)
self.target = new_target
@@ -193,7 +193,7 @@ class DndHandler:
self.initial_widget.unbind("<Motion>")
widget['cursor'] = self.save_cursor
self.target = self.source = self.initial_widget = self.root = None
- if target:
+ if target is not None:
if commit:
target.dnd_commit(source, event)
else:
@@ -215,9 +215,9 @@ class Icon:
if canvas is self.canvas:
self.canvas.coords(self.id, x, y)
return
- if self.canvas:
+ if self.canvas is not None:
self.detach()
- if not canvas:
+ if canvas is None:
return
label = tkinter.Label(canvas, text=self.name,
borderwidth=2, relief="raised")
@@ -229,7 +229,7 @@ class Icon:
def detach(self):
canvas = self.canvas
- if not canvas:
+ if canvas is None:
return
id = self.id
label = self.label
diff --git a/Lib/tkinter/font.py b/Lib/tkinter/font.py
index a9f79d8e45..06ed01b99c 100644
--- a/Lib/tkinter/font.py
+++ b/Lib/tkinter/font.py
@@ -17,10 +17,10 @@ BOLD = "bold"
ITALIC = "italic"
-def nametofont(name):
+def nametofont(name, root=None):
"""Given the name of a tk named font, returns a Font representation.
"""
- return Font(name=name, exists=True)
+ return Font(name=name, exists=True, root=root)
class Font:
@@ -68,8 +68,8 @@ class Font:
def __init__(self, root=None, font=None, name=None, exists=False,
**options):
- if not root:
- root = tkinter._default_root
+ if root is None:
+ root = tkinter._get_default_root('use font')
tk = getattr(root, 'tk', root)
if font:
# get actual settings corresponding to the given font
@@ -183,8 +183,8 @@ class Font:
def families(root=None, displayof=None):
"Get font families (as a tuple)"
- if not root:
- root = tkinter._default_root
+ if root is None:
+ root = tkinter._get_default_root('use font.families()')
args = ()
if displayof:
args = ('-displayof', displayof)
@@ -193,8 +193,8 @@ def families(root=None, displayof=None):
def names(root=None):
"Get names of defined fonts (as a tuple)"
- if not root:
- root = tkinter._default_root
+ if root is None:
+ root = tkinter._get_default_root('use font.names()')
return root.tk.splitlist(root.tk.call("font", "names"))
diff --git a/Lib/tkinter/simpledialog.py b/Lib/tkinter/simpledialog.py
index 8524417111..a66fbd6cb9 100644
--- a/Lib/tkinter/simpledialog.py
+++ b/Lib/tkinter/simpledialog.py
@@ -24,10 +24,9 @@ askstring -- get a string from the user
"""
from tkinter import *
+from tkinter import _get_temp_root, _destroy_temp_root
from tkinter import messagebox
-import tkinter # used at _QueryDialog for tkinter._default_root
-
class SimpleDialog:
@@ -57,36 +56,8 @@ class SimpleDialog:
b.config(relief=RIDGE, borderwidth=8)
b.pack(side=LEFT, fill=BOTH, expand=1)
self.root.protocol('WM_DELETE_WINDOW', self.wm_delete_window)
- self._set_transient(master)
-
- def _set_transient(self, master, relx=0.5, rely=0.3):
- widget = self.root
- widget.withdraw() # Remain invisible while we figure out the geometry
- widget.transient(master)
- widget.update_idletasks() # Actualize geometry information
- if master.winfo_ismapped():
- m_width = master.winfo_width()
- m_height = master.winfo_height()
- m_x = master.winfo_rootx()
- m_y = master.winfo_rooty()
- else:
- m_width = master.winfo_screenwidth()
- m_height = master.winfo_screenheight()
- m_x = m_y = 0
- w_width = widget.winfo_reqwidth()
- w_height = widget.winfo_reqheight()
- x = m_x + (m_width - w_width) * relx
- y = m_y + (m_height - w_height) * rely
- if x+w_width > master.winfo_screenwidth():
- x = master.winfo_screenwidth() - w_width
- elif x < 0:
- x = 0
- if y+w_height > master.winfo_screenheight():
- y = master.winfo_screenheight() - w_height
- elif y < 0:
- y = 0
- widget.geometry("+%d+%d" % (x, y))
- widget.deiconify() # Become visible at the desired location
+ self.root.transient(master)
+ _place_window(self.root, master)
def go(self):
self.root.wait_visibility()
@@ -128,13 +99,17 @@ class Dialog(Toplevel):
title -- the dialog title
'''
- Toplevel.__init__(self, parent)
+ master = parent
+ if master is None:
+ master = _get_temp_root()
+
+ Toplevel.__init__(self, master)
self.withdraw() # remain invisible for now
- # If the master is not viewable, don't
+ # If the parent is not viewable, don't
# make the child transient, or else it
# would be opened withdrawn
- if parent.winfo_viewable():
+ if parent is not None and parent.winfo_viewable():
self.transient(parent)
if title:
@@ -150,16 +125,12 @@ class Dialog(Toplevel):
self.buttonbox()
- if not self.initial_focus:
+ if self.initial_focus is None:
self.initial_focus = self
self.protocol("WM_DELETE_WINDOW", self.cancel)
- if self.parent is not None:
- self.geometry("+%d+%d" % (parent.winfo_rootx()+50,
- parent.winfo_rooty()+50))
-
- self.deiconify() # become visible now
+ _place_window(self, parent)
self.initial_focus.focus_set()
@@ -172,6 +143,7 @@ class Dialog(Toplevel):
'''Destroy the window'''
self.initial_focus = None
Toplevel.destroy(self)
+ _destroy_temp_root(self.master)
#
# construction hooks
@@ -249,6 +221,37 @@ class Dialog(Toplevel):
pass # override
+# Place a toplevel window at the center of parent or screen
+# It is a Python implementation of ::tk::PlaceWindow.
+def _place_window(w, parent=None):
+ w.wm_withdraw() # Remain invisible while we figure out the geometry
+ w.update_idletasks() # Actualize geometry information
+
+ minwidth = w.winfo_reqwidth()
+ minheight = w.winfo_reqheight()
+ maxwidth = w.winfo_vrootwidth()
+ maxheight = w.winfo_vrootheight()
+ if parent is not None and parent.winfo_ismapped():
+ x = parent.winfo_rootx() + (parent.winfo_width() - minwidth) // 2
+ y = parent.winfo_rooty() + (parent.winfo_height() - minheight) // 2
+ vrootx = w.winfo_vrootx()
+ vrooty = w.winfo_vrooty()
+ x = min(x, vrootx + maxwidth - minwidth)
+ x = max(x, vrootx)
+ y = min(y, vrooty + maxheight - minheight)
+ y = max(y, vrooty)
+ if w._windowingsystem == 'aqua':
+ # Avoid the native menu bar which sits on top of everything.
+ y = max(y, 22)
+ else:
+ x = (w.winfo_screenwidth() - minwidth) // 2
+ y = (w.winfo_screenheight() - minheight) // 2
+
+ w.wm_maxsize(maxwidth, maxheight)
+ w.wm_geometry('+%d+%d' % (x, y))
+ w.wm_deiconify() # Become visible at the desired location
+
+
# --------------------------------------------------------------------
# convenience dialogues
@@ -259,9 +262,6 @@ class _QueryDialog(Dialog):
minvalue = None, maxvalue = None,
parent = None):
- if not parent:
- parent = tkinter._default_root
-
self.prompt = prompt
self.minvalue = minvalue
self.maxvalue = maxvalue
diff --git a/Lib/tkinter/test/support.py b/Lib/tkinter/test/support.py
index 467a0b66c2..dbc47a81e6 100644
--- a/Lib/tkinter/test/support.py
+++ b/Lib/tkinter/test/support.py
@@ -36,6 +36,33 @@ class AbstractTkTest:
w.destroy()
self.root.withdraw()
+
+class AbstractDefaultRootTest:
+
+ def setUp(self):
+ self._old_support_default_root = tkinter._support_default_root
+ destroy_default_root()
+ tkinter._support_default_root = True
+ self.wantobjects = tkinter.wantobjects
+
+ def tearDown(self):
+ destroy_default_root()
+ tkinter._default_root = None
+ tkinter._support_default_root = self._old_support_default_root
+
+ def _test_widget(self, constructor):
+ # no master passing
+ x = constructor()
+ self.assertIsNotNone(tkinter._default_root)
+ self.assertIs(x.master, tkinter._default_root)
+ self.assertIs(x.tk, tkinter._default_root.tk)
+ x.destroy()
+ destroy_default_root()
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, constructor)
+ self.assertFalse(hasattr(tkinter, '_default_root'))
+
+
def destroy_default_root():
if getattr(tkinter, '_default_root', None):
tkinter._default_root.update_idletasks()
diff --git a/Lib/tkinter/test/test_tkinter/test_colorchooser.py b/Lib/tkinter/test/test_tkinter/test_colorchooser.py
new file mode 100644
index 0000000000..600c8cde67
--- /dev/null
+++ b/Lib/tkinter/test/test_tkinter/test_colorchooser.py
@@ -0,0 +1,39 @@
+import unittest
+import tkinter
+from test.support import requires, run_unittest, swap_attr
+from tkinter.test.support import AbstractDefaultRootTest
+from tkinter.commondialog import Dialog
+from tkinter.colorchooser import askcolor
+
+requires('gui')
+
+
+class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
+
+ def test_askcolor(self):
+ def test_callback(dialog, master):
+ nonlocal ismapped
+ master.update()
+ ismapped = master.winfo_ismapped()
+ raise ZeroDivisionError
+
+ with swap_attr(Dialog, '_test_callback', test_callback):
+ ismapped = None
+ self.assertRaises(ZeroDivisionError, askcolor)
+ #askcolor()
+ self.assertEqual(ismapped, False)
+
+ root = tkinter.Tk()
+ ismapped = None
+ self.assertRaises(ZeroDivisionError, askcolor)
+ self.assertEqual(ismapped, True)
+ root.destroy()
+
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, askcolor)
+
+
+tests_gui = (DefaultRootTest,)
+
+if __name__ == "__main__":
+ run_unittest(*tests_gui)
diff --git a/Lib/tkinter/test/test_tkinter/test_font.py b/Lib/tkinter/test/test_tkinter/test_font.py
index 6d1eea44b4..0354c5f304 100644
--- a/Lib/tkinter/test/test_tkinter/test_font.py
+++ b/Lib/tkinter/test/test_tkinter/test_font.py
@@ -2,7 +2,7 @@ import unittest
import tkinter
from tkinter import font
from test.support import requires, run_unittest, gc_collect, ALWAYS_EQ
-from tkinter.test.support import AbstractTkTest
+from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest
requires('gui')
@@ -101,13 +101,58 @@ class FontTest(AbstractTkTest, unittest.TestCase):
self.assertTrue(name)
self.assertIn(fontname, names)
+ def test_nametofont(self):
+ testfont = font.nametofont(fontname, root=self.root)
+ self.assertIsInstance(testfont, font.Font)
+ self.assertEqual(testfont.name, fontname)
+
def test_repr(self):
self.assertEqual(
repr(self.font), f'<tkinter.font.Font object {fontname!r}>'
)
-tests_gui = (FontTest, )
+class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
+
+ def test_families(self):
+ self.assertRaises(RuntimeError, font.families)
+ root = tkinter.Tk()
+ families = font.families()
+ self.assertIsInstance(families, tuple)
+ self.assertTrue(families)
+ for family in families:
+ self.assertIsInstance(family, str)
+ self.assertTrue(family)
+ root.destroy()
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, font.families)
+
+ def test_names(self):
+ self.assertRaises(RuntimeError, font.names)
+ root = tkinter.Tk()
+ names = font.names()
+ self.assertIsInstance(names, tuple)
+ self.assertTrue(names)
+ for name in names:
+ self.assertIsInstance(name, str)
+ self.assertTrue(name)
+ self.assertIn(fontname, names)
+ root.destroy()
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, font.names)
+
+ def test_nametofont(self):
+ self.assertRaises(RuntimeError, font.nametofont, fontname)
+ root = tkinter.Tk()
+ testfont = font.nametofont(fontname)
+ self.assertIsInstance(testfont, font.Font)
+ self.assertEqual(testfont.name, fontname)
+ root.destroy()
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, font.nametofont, fontname)
+
+
+tests_gui = (FontTest, DefaultRootTest)
if __name__ == "__main__":
run_unittest(*tests_gui)
diff --git a/Lib/tkinter/test/test_tkinter/test_images.py b/Lib/tkinter/test/test_tkinter/test_images.py
index 6c6cb4e148..2526e92200 100644
--- a/Lib/tkinter/test/test_tkinter/test_images.py
+++ b/Lib/tkinter/test/test_tkinter/test_images.py
@@ -2,7 +2,7 @@ import unittest
import tkinter
from test import support
from test.support import os_helper
-from tkinter.test.support import AbstractTkTest, requires_tcl
+from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest, requires_tcl
support.requires('gui')
@@ -20,6 +20,47 @@ class MiscTest(AbstractTkTest, unittest.TestCase):
self.assertIsInstance(image_names, tuple)
+class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
+
+ def test_image_types(self):
+ self.assertRaises(RuntimeError, tkinter.image_types)
+ root = tkinter.Tk()
+ image_types = tkinter.image_types()
+ self.assertIsInstance(image_types, tuple)
+ self.assertIn('photo', image_types)
+ self.assertIn('bitmap', image_types)
+ root.destroy()
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, tkinter.image_types)
+
+ def test_image_names(self):
+ self.assertRaises(RuntimeError, tkinter.image_names)
+ root = tkinter.Tk()
+ image_names = tkinter.image_names()
+ self.assertIsInstance(image_names, tuple)
+ root.destroy()
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, tkinter.image_names)
+
+ def test_image_create_bitmap(self):
+ self.assertRaises(RuntimeError, tkinter.BitmapImage)
+ root = tkinter.Tk()
+ image = tkinter.BitmapImage()
+ self.assertIn(image.name, tkinter.image_names())
+ root.destroy()
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, tkinter.BitmapImage)
+
+ def test_image_create_photo(self):
+ self.assertRaises(RuntimeError, tkinter.PhotoImage)
+ root = tkinter.Tk()
+ image = tkinter.PhotoImage()
+ self.assertIn(image.name, tkinter.image_names())
+ root.destroy()
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, tkinter.PhotoImage)
+
+
class BitmapImageTest(AbstractTkTest, unittest.TestCase):
@classmethod
@@ -331,7 +372,7 @@ class PhotoImageTest(AbstractTkTest, unittest.TestCase):
self.assertEqual(image.transparency_get(4, 6), False)
-tests_gui = (MiscTest, BitmapImageTest, PhotoImageTest,)
+tests_gui = (MiscTest, DefaultRootTest, BitmapImageTest, PhotoImageTest,)
if __name__ == "__main__":
support.run_unittest(*tests_gui)
diff --git a/Lib/tkinter/test/test_tkinter/test_messagebox.py b/Lib/tkinter/test/test_tkinter/test_messagebox.py
new file mode 100644
index 0000000000..0dec08e904
--- /dev/null
+++ b/Lib/tkinter/test/test_tkinter/test_messagebox.py
@@ -0,0 +1,38 @@
+import unittest
+import tkinter
+from test.support import requires, run_unittest, swap_attr
+from tkinter.test.support import AbstractDefaultRootTest
+from tkinter.commondialog import Dialog
+from tkinter.messagebox import showinfo
+
+requires('gui')
+
+
+class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
+
+ def test_showinfo(self):
+ def test_callback(dialog, master):
+ nonlocal ismapped
+ master.update()
+ ismapped = master.winfo_ismapped()
+ raise ZeroDivisionError
+
+ with swap_attr(Dialog, '_test_callback', test_callback):
+ ismapped = None
+ self.assertRaises(ZeroDivisionError, showinfo, "Spam", "Egg Information")
+ self.assertEqual(ismapped, False)
+
+ root = tkinter.Tk()
+ ismapped = None
+ self.assertRaises(ZeroDivisionError, showinfo, "Spam", "Egg Information")
+ self.assertEqual(ismapped, True)
+ root.destroy()
+
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, showinfo, "Spam", "Egg Information")
+
+
+tests_gui = (DefaultRootTest,)
+
+if __name__ == "__main__":
+ run_unittest(*tests_gui)
diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py
index b8eea2544f..585d81ddf9 100644
--- a/Lib/tkinter/test/test_tkinter/test_misc.py
+++ b/Lib/tkinter/test/test_tkinter/test_misc.py
@@ -1,7 +1,7 @@
import unittest
import tkinter
from test import support
-from tkinter.test.support import AbstractTkTest
+from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest
support.requires('gui')
@@ -241,7 +241,85 @@ class MiscTest(AbstractTkTest, unittest.TestCase):
" num=3 delta=-1 focus=True"
" x=10 y=20 width=300 height=200>")
-tests_gui = (MiscTest, )
+ def test_getboolean(self):
+ for v in 'true', 'yes', 'on', '1', 't', 'y', 1, True:
+ self.assertIs(self.root.getboolean(v), True)
+ for v in 'false', 'no', 'off', '0', 'f', 'n', 0, False:
+ self.assertIs(self.root.getboolean(v), False)
+ self.assertRaises(ValueError, self.root.getboolean, 'yea')
+ self.assertRaises(ValueError, self.root.getboolean, '')
+ self.assertRaises(TypeError, self.root.getboolean, None)
+ self.assertRaises(TypeError, self.root.getboolean, ())
+
+ def test_mainloop(self):
+ log = []
+ def callback():
+ log.append(1)
+ self.root.after(100, self.root.quit)
+ self.root.after(100, callback)
+ self.root.mainloop(1)
+ self.assertEqual(log, [])
+ self.root.mainloop(0)
+ self.assertEqual(log, [1])
+ self.assertTrue(self.root.winfo_exists())
+
+
+class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
+
+ def test_default_root(self):
+ self.assertIs(tkinter._support_default_root, True)
+ self.assertIsNone(tkinter._default_root)
+ root = tkinter.Tk()
+ root2 = tkinter.Tk()
+ root3 = tkinter.Tk()
+ self.assertIs(tkinter._default_root, root)
+ root2.destroy()
+ self.assertIs(tkinter._default_root, root)
+ root.destroy()
+ self.assertIsNone(tkinter._default_root)
+ root3.destroy()
+ self.assertIsNone(tkinter._default_root)
+
+ def test_no_default_root(self):
+ self.assertIs(tkinter._support_default_root, True)
+ self.assertIsNone(tkinter._default_root)
+ root = tkinter.Tk()
+ self.assertIs(tkinter._default_root, root)
+ tkinter.NoDefaultRoot()
+ self.assertIs(tkinter._support_default_root, False)
+ self.assertFalse(hasattr(tkinter, '_default_root'))
+ # repeated call is no-op
+ tkinter.NoDefaultRoot()
+ self.assertIs(tkinter._support_default_root, False)
+ self.assertFalse(hasattr(tkinter, '_default_root'))
+ root.destroy()
+ self.assertIs(tkinter._support_default_root, False)
+ self.assertFalse(hasattr(tkinter, '_default_root'))
+ root = tkinter.Tk()
+ self.assertIs(tkinter._support_default_root, False)
+ self.assertFalse(hasattr(tkinter, '_default_root'))
+ root.destroy()
+
+ def test_getboolean(self):
+ self.assertRaises(RuntimeError, tkinter.getboolean, '1')
+ root = tkinter.Tk()
+ self.assertIs(tkinter.getboolean('1'), True)
+ self.assertRaises(ValueError, tkinter.getboolean, 'yea')
+ root.destroy()
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, tkinter.getboolean, '1')
+
+ def test_mainloop(self):
+ self.assertRaises(RuntimeError, tkinter.mainloop)
+ root = tkinter.Tk()
+ root.after_idle(root.quit)
+ tkinter.mainloop()
+ root.destroy()
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, tkinter.mainloop)
+
+
+tests_gui = (MiscTest, DefaultRootTest)
if __name__ == "__main__":
support.run_unittest(*tests_gui)
diff --git a/Lib/tkinter/test/test_tkinter/test_simpledialog.py b/Lib/tkinter/test/test_tkinter/test_simpledialog.py
new file mode 100644
index 0000000000..b64b854c4d
--- /dev/null
+++ b/Lib/tkinter/test/test_tkinter/test_simpledialog.py
@@ -0,0 +1,37 @@
+import unittest
+import tkinter
+from test.support import requires, run_unittest, swap_attr
+from tkinter.test.support import AbstractDefaultRootTest
+from tkinter.simpledialog import Dialog, askinteger
+
+requires('gui')
+
+
+class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
+
+ def test_askinteger(self):
+ @staticmethod
+ def mock_wait_window(w):
+ nonlocal ismapped
+ ismapped = w.master.winfo_ismapped()
+ w.destroy()
+
+ with swap_attr(Dialog, 'wait_window', mock_wait_window):
+ ismapped = None
+ askinteger("Go To Line", "Line number")
+ self.assertEqual(ismapped, False)
+
+ root = tkinter.Tk()
+ ismapped = None
+ askinteger("Go To Line", "Line number")
+ self.assertEqual(ismapped, True)
+ root.destroy()
+
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, askinteger, "Go To Line", "Line number")
+
+
+tests_gui = (DefaultRootTest,)
+
+if __name__ == "__main__":
+ run_unittest(*tests_gui)
diff --git a/Lib/tkinter/test/test_tkinter/test_variables.py b/Lib/tkinter/test/test_tkinter/test_variables.py
index 08b7dedcaf..63d7c21059 100644
--- a/Lib/tkinter/test/test_tkinter/test_variables.py
+++ b/Lib/tkinter/test/test_tkinter/test_variables.py
@@ -1,8 +1,10 @@
import unittest
import gc
+import tkinter
from tkinter import (Variable, StringVar, IntVar, DoubleVar, BooleanVar, Tcl,
TclError)
from test.support import ALWAYS_EQ
+from tkinter.test.support import AbstractDefaultRootTest
class Var(Variable):
@@ -308,8 +310,21 @@ class TestBooleanVar(TestBase):
v.get()
+class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
+
+ def test_variable(self):
+ self.assertRaises(RuntimeError, Variable)
+ root = tkinter.Tk()
+ v = Variable()
+ v.set("value")
+ self.assertEqual(v.get(), "value")
+ root.destroy()
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, Variable)
+
+
tests_gui = (TestVariable, TestStringVar, TestIntVar,
- TestDoubleVar, TestBooleanVar)
+ TestDoubleVar, TestBooleanVar, DefaultRootTest)
if __name__ == "__main__":
diff --git a/Lib/tkinter/test/test_tkinter/test_widgets.py b/Lib/tkinter/test/test_tkinter/test_widgets.py
index b6f792d6c2..39334de8cf 100644
--- a/Lib/tkinter/test/test_tkinter/test_widgets.py
+++ b/Lib/tkinter/test/test_tkinter/test_widgets.py
@@ -2,11 +2,11 @@ import unittest
import tkinter
from tkinter import TclError
import os
-import sys
from test.support import requires
from tkinter.test.support import (tcl_version, requires_tcl,
- get_tk_patchlevel, widget_eq)
+ get_tk_patchlevel, widget_eq,
+ AbstractDefaultRootTest)
from tkinter.test.widget_tests import (
add_standard_options, noconv, pixels_round,
AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests,
@@ -22,7 +22,7 @@ def float_round(x):
class AbstractToplevelTest(AbstractWidgetTest, PixelSizeTests):
_conv_pad_pixels = noconv
- def test_class(self):
+ def test_configure_class(self):
widget = self.create()
self.assertEqual(widget['class'],
widget.__class__.__name__.title())
@@ -31,7 +31,7 @@ class AbstractToplevelTest(AbstractWidgetTest, PixelSizeTests):
widget2 = self.create(class_='Foo')
self.assertEqual(widget2['class'], 'Foo')
- def test_colormap(self):
+ def test_configure_colormap(self):
widget = self.create()
self.assertEqual(widget['colormap'], '')
self.checkInvalidParam(widget, 'colormap', 'new',
@@ -39,7 +39,7 @@ class AbstractToplevelTest(AbstractWidgetTest, PixelSizeTests):
widget2 = self.create(colormap='new')
self.assertEqual(widget2['colormap'], 'new')
- def test_container(self):
+ def test_configure_container(self):
widget = self.create()
self.assertEqual(widget['container'], 0 if self.wantobjects else '0')
self.checkInvalidParam(widget, 'container', 1,
@@ -47,7 +47,7 @@ class AbstractToplevelTest(AbstractWidgetTest, PixelSizeTests):
widget2 = self.create(container=True)
self.assertEqual(widget2['container'], 1 if self.wantobjects else '1')
- def test_visual(self):
+ def test_configure_visual(self):
widget = self.create()
self.assertEqual(widget['visual'], '')
self.checkInvalidParam(widget, 'visual', 'default',
@@ -69,13 +69,13 @@ class ToplevelTest(AbstractToplevelTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Toplevel(self.root, **kwargs)
- def test_menu(self):
+ def test_configure_menu(self):
widget = self.create()
menu = tkinter.Menu(self.root)
self.checkParam(widget, 'menu', menu, eq=widget_eq)
self.checkParam(widget, 'menu', '')
- def test_screen(self):
+ def test_configure_screen(self):
widget = self.create()
self.assertEqual(widget['screen'], '')
try:
@@ -87,7 +87,7 @@ class ToplevelTest(AbstractToplevelTest, unittest.TestCase):
widget2 = self.create(screen=display)
self.assertEqual(widget2['screen'], display)
- def test_use(self):
+ def test_configure_use(self):
widget = self.create()
self.assertEqual(widget['use'], '')
parent = self.create(container=True)
@@ -124,14 +124,14 @@ class LabelFrameTest(AbstractToplevelTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.LabelFrame(self.root, **kwargs)
- def test_labelanchor(self):
+ def test_configure_labelanchor(self):
widget = self.create()
self.checkEnumParam(widget, 'labelanchor',
'e', 'en', 'es', 'n', 'ne', 'nw',
's', 'se', 'sw', 'w', 'wn', 'ws')
self.checkInvalidParam(widget, 'labelanchor', 'center')
- def test_labelwidget(self):
+ def test_configure_labelwidget(self):
widget = self.create()
label = tkinter.Label(self.root, text='Mupp', name='foo')
self.checkParam(widget, 'labelwidget', label, expected='.foo')
@@ -141,7 +141,7 @@ class LabelFrameTest(AbstractToplevelTest, unittest.TestCase):
class AbstractLabelTest(AbstractWidgetTest, IntegerSizeTests):
_conv_pixels = noconv
- def test_highlightthickness(self):
+ def test_configure_highlightthickness(self):
widget = self.create()
self.checkPixelsParam(widget, 'highlightthickness',
0, 1.3, 2.6, 6, -2, '10p')
@@ -179,7 +179,7 @@ class ButtonTest(AbstractLabelTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Button(self.root, **kwargs)
- def test_default(self):
+ def test_configure_default(self):
widget = self.create()
self.checkEnumParam(widget, 'default', 'active', 'disabled', 'normal')
@@ -204,11 +204,11 @@ class CheckbuttonTest(AbstractLabelTest, unittest.TestCase):
return tkinter.Checkbutton(self.root, **kwargs)
- def test_offvalue(self):
+ def test_configure_offvalue(self):
widget = self.create()
self.checkParams(widget, 'offvalue', 1, 2.3, '', 'any string')
- def test_onvalue(self):
+ def test_configure_onvalue(self):
widget = self.create()
self.checkParams(widget, 'onvalue', 1, 2.3, '', 'any string')
@@ -231,7 +231,7 @@ class RadiobuttonTest(AbstractLabelTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Radiobutton(self.root, **kwargs)
- def test_value(self):
+ def test_configure_value(self):
widget = self.create()
self.checkParams(widget, 'value', 1, 2.3, '', 'any string')
@@ -254,20 +254,19 @@ class MenubuttonTest(AbstractLabelTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Menubutton(self.root, **kwargs)
- def test_direction(self):
+ def test_configure_direction(self):
widget = self.create()
self.checkEnumParam(widget, 'direction',
'above', 'below', 'flush', 'left', 'right')
- def test_height(self):
+ def test_configure_height(self):
widget = self.create()
self.checkIntegerParam(widget, 'height', 100, -100, 0, conv=str)
- test_highlightthickness = StandardOptionsTests.test_highlightthickness
+ test_configure_highlightthickness = \
+ StandardOptionsTests.test_configure_highlightthickness
- @unittest.skipIf(sys.platform == 'darwin',
- 'crashes with Cocoa Tk (issue19733)')
- def test_image(self):
+ def test_configure_image(self):
widget = self.create()
image = tkinter.PhotoImage(master=self.root, name='image1')
self.checkParam(widget, 'image', image, conv=str)
@@ -281,23 +280,23 @@ class MenubuttonTest(AbstractLabelTest, unittest.TestCase):
if errmsg is not None:
self.assertEqual(str(cm.exception), errmsg)
- def test_menu(self):
+ def test_configure_menu(self):
widget = self.create()
menu = tkinter.Menu(widget, name='menu')
self.checkParam(widget, 'menu', menu, eq=widget_eq)
menu.destroy()
- def test_padx(self):
+ def test_configure_padx(self):
widget = self.create()
self.checkPixelsParam(widget, 'padx', 3, 4.4, 5.6, '12m')
self.checkParam(widget, 'padx', -2, expected=0)
- def test_pady(self):
+ def test_configure_pady(self):
widget = self.create()
self.checkPixelsParam(widget, 'pady', 3, 4.4, 5.6, '12m')
self.checkParam(widget, 'pady', -2, expected=0)
- def test_width(self):
+ def test_configure_width(self):
widget = self.create()
self.checkIntegerParam(widget, 'width', 402, -402, 0, conv=str)
@@ -330,18 +329,18 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Entry(self.root, **kwargs)
- def test_disabledbackground(self):
+ def test_configure_disabledbackground(self):
widget = self.create()
self.checkColorParam(widget, 'disabledbackground')
- def test_insertborderwidth(self):
+ def test_configure_insertborderwidth(self):
widget = self.create(insertwidth=100)
self.checkPixelsParam(widget, 'insertborderwidth',
0, 1.3, 2.6, 6, -2, '10p')
# insertborderwidth is bounded above by a half of insertwidth.
self.checkParam(widget, 'insertborderwidth', 60, expected=100//2)
- def test_insertwidth(self):
+ def test_configure_insertwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'insertwidth', 1.3, 3.6, '10p')
self.checkParam(widget, 'insertwidth', 0.1, expected=2)
@@ -351,32 +350,32 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
else:
self.checkParam(widget, 'insertwidth', 0.9, expected=1)
- def test_invalidcommand(self):
+ def test_configure_invalidcommand(self):
widget = self.create()
self.checkCommandParam(widget, 'invalidcommand')
self.checkCommandParam(widget, 'invcmd')
- def test_readonlybackground(self):
+ def test_configure_readonlybackground(self):
widget = self.create()
self.checkColorParam(widget, 'readonlybackground')
- def test_show(self):
+ def test_configure_show(self):
widget = self.create()
self.checkParam(widget, 'show', '*')
self.checkParam(widget, 'show', '')
self.checkParam(widget, 'show', ' ')
- def test_state(self):
+ def test_configure_state(self):
widget = self.create()
self.checkEnumParam(widget, 'state',
'disabled', 'normal', 'readonly')
- def test_validate(self):
+ def test_configure_validate(self):
widget = self.create()
self.checkEnumParam(widget, 'validate',
'all', 'key', 'focus', 'focusin', 'focusout', 'none')
- def test_validatecommand(self):
+ def test_configure_validatecommand(self):
widget = self.create()
self.checkCommandParam(widget, 'validatecommand')
self.checkCommandParam(widget, 'vcmd')
@@ -429,25 +428,25 @@ class SpinboxTest(EntryTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Spinbox(self.root, **kwargs)
- test_show = None
+ test_configure_show = None
- def test_buttonbackground(self):
+ def test_configure_buttonbackground(self):
widget = self.create()
self.checkColorParam(widget, 'buttonbackground')
- def test_buttoncursor(self):
+ def test_configure_buttoncursor(self):
widget = self.create()
self.checkCursorParam(widget, 'buttoncursor')
- def test_buttondownrelief(self):
+ def test_configure_buttondownrelief(self):
widget = self.create()
self.checkReliefParam(widget, 'buttondownrelief')
- def test_buttonuprelief(self):
+ def test_configure_buttonuprelief(self):
widget = self.create()
self.checkReliefParam(widget, 'buttonuprelief')
- def test_format(self):
+ def test_configure_format(self):
widget = self.create()
self.checkParam(widget, 'format', '%2f')
self.checkParam(widget, 'format', '%2.2f')
@@ -462,25 +461,25 @@ class SpinboxTest(EntryTest, unittest.TestCase):
self.checkParam(widget, 'format', '%09.200f')
self.checkInvalidParam(widget, 'format', '%d')
- def test_from(self):
+ def test_configure_from(self):
widget = self.create()
self.checkParam(widget, 'to', 100.0)
self.checkFloatParam(widget, 'from', -10, 10.2, 11.7)
self.checkInvalidParam(widget, 'from', 200,
errmsg='-to value must be greater than -from value')
- def test_increment(self):
+ def test_configure_increment(self):
widget = self.create()
self.checkFloatParam(widget, 'increment', -1, 1, 10.2, 12.8, 0)
- def test_to(self):
+ def test_configure_to(self):
widget = self.create()
self.checkParam(widget, 'from', -100.0)
self.checkFloatParam(widget, 'to', -10, 10.2, 11.7)
self.checkInvalidParam(widget, 'to', -200,
errmsg='-to value must be greater than -from value')
- def test_values(self):
+ def test_configure_values(self):
# XXX
widget = self.create()
self.assertEqual(widget['values'], '')
@@ -491,7 +490,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
expected='42 3.14 {} {any string}')
self.checkParam(widget, 'values', '')
- def test_wrap(self):
+ def test_configure_wrap(self):
widget = self.create()
self.checkBooleanParam(widget, 'wrap')
@@ -557,17 +556,17 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Text(self.root, **kwargs)
- def test_autoseparators(self):
+ def test_configure_autoseparators(self):
widget = self.create()
self.checkBooleanParam(widget, 'autoseparators')
@requires_tcl(8, 5)
- def test_blockcursor(self):
+ def test_configure_blockcursor(self):
widget = self.create()
self.checkBooleanParam(widget, 'blockcursor')
@requires_tcl(8, 5)
- def test_endline(self):
+ def test_configure_endline(self):
widget = self.create()
text = '\n'.join('Line %d' for i in range(100))
widget.insert('end', text)
@@ -580,50 +579,50 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
self.checkInvalidParam(widget, 'endline', 10,
errmsg='-startline must be less than or equal to -endline')
- def test_height(self):
+ def test_configure_height(self):
widget = self.create()
self.checkPixelsParam(widget, 'height', 100, 101.2, 102.6, '3c')
self.checkParam(widget, 'height', -100, expected=1)
self.checkParam(widget, 'height', 0, expected=1)
- def test_maxundo(self):
+ def test_configure_maxundo(self):
widget = self.create()
self.checkIntegerParam(widget, 'maxundo', 0, 5, -1)
@requires_tcl(8, 5)
- def test_inactiveselectbackground(self):
+ def test_configure_inactiveselectbackground(self):
widget = self.create()
self.checkColorParam(widget, 'inactiveselectbackground')
@requires_tcl(8, 6)
- def test_insertunfocussed(self):
+ def test_configure_insertunfocussed(self):
widget = self.create()
self.checkEnumParam(widget, 'insertunfocussed',
'hollow', 'none', 'solid')
- def test_selectborderwidth(self):
+ def test_configure_selectborderwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'selectborderwidth',
1.3, 2.6, -2, '10p', conv=noconv,
keep_orig=tcl_version >= (8, 5))
- def test_spacing1(self):
+ def test_configure_spacing1(self):
widget = self.create()
self.checkPixelsParam(widget, 'spacing1', 20, 21.4, 22.6, '0.5c')
self.checkParam(widget, 'spacing1', -5, expected=0)
- def test_spacing2(self):
+ def test_configure_spacing2(self):
widget = self.create()
self.checkPixelsParam(widget, 'spacing2', 5, 6.4, 7.6, '0.1c')
self.checkParam(widget, 'spacing2', -1, expected=0)
- def test_spacing3(self):
+ def test_configure_spacing3(self):
widget = self.create()
self.checkPixelsParam(widget, 'spacing3', 20, 21.4, 22.6, '0.5c')
self.checkParam(widget, 'spacing3', -10, expected=0)
@requires_tcl(8, 5)
- def test_startline(self):
+ def test_configure_startline(self):
widget = self.create()
text = '\n'.join('Line %d' for i in range(100))
widget.insert('end', text)
@@ -636,14 +635,14 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
self.checkInvalidParam(widget, 'startline', 70,
errmsg='-startline must be less than or equal to -endline')
- def test_state(self):
+ def test_configure_state(self):
widget = self.create()
if tcl_version < (8, 5):
self.checkParams(widget, 'state', 'disabled', 'normal')
else:
self.checkEnumParam(widget, 'state', 'disabled', 'normal')
- def test_tabs(self):
+ def test_configure_tabs(self):
widget = self.create()
if get_tk_patchlevel() < (8, 5, 11):
self.checkParam(widget, 'tabs', (10.2, 20.7, '1i', '2i'),
@@ -659,21 +658,21 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
keep_orig=tcl_version >= (8, 5))
@requires_tcl(8, 5)
- def test_tabstyle(self):
+ def test_configure_tabstyle(self):
widget = self.create()
self.checkEnumParam(widget, 'tabstyle', 'tabular', 'wordprocessor')
- def test_undo(self):
+ def test_configure_undo(self):
widget = self.create()
self.checkBooleanParam(widget, 'undo')
- def test_width(self):
+ def test_configure_width(self):
widget = self.create()
self.checkIntegerParam(widget, 'width', 402)
self.checkParam(widget, 'width', -402, expected=1)
self.checkParam(widget, 'width', 0, expected=1)
- def test_wrap(self):
+ def test_configure_wrap(self):
widget = self.create()
if tcl_version < (8, 5):
self.checkParams(widget, 'wrap', 'char', 'none', 'word')
@@ -711,16 +710,16 @@ class CanvasTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Canvas(self.root, **kwargs)
- def test_closeenough(self):
+ def test_configure_closeenough(self):
widget = self.create()
self.checkFloatParam(widget, 'closeenough', 24, 2.4, 3.6, -3,
conv=float)
- def test_confine(self):
+ def test_configure_confine(self):
widget = self.create()
self.checkBooleanParam(widget, 'confine')
- def test_offset(self):
+ def test_configure_offset(self):
widget = self.create()
self.assertEqual(widget['offset'], '0,0')
self.checkParams(widget, 'offset',
@@ -729,7 +728,7 @@ class CanvasTest(AbstractWidgetTest, unittest.TestCase):
self.checkParam(widget, 'offset', '#5,6')
self.checkInvalidParam(widget, 'offset', 'spam')
- def test_scrollregion(self):
+ def test_configure_scrollregion(self):
widget = self.create()
self.checkParam(widget, 'scrollregion', '0 0 200 150')
self.checkParam(widget, 'scrollregion', (0, 0, 200, 150),
@@ -741,17 +740,17 @@ class CanvasTest(AbstractWidgetTest, unittest.TestCase):
self.checkInvalidParam(widget, 'scrollregion', (0, 0, 200))
self.checkInvalidParam(widget, 'scrollregion', (0, 0, 200, 150, 0))
- def test_state(self):
+ def test_configure_state(self):
widget = self.create()
self.checkEnumParam(widget, 'state', 'disabled', 'normal',
errmsg='bad state value "{}": must be normal or disabled')
- def test_xscrollincrement(self):
+ def test_configure_xscrollincrement(self):
widget = self.create()
self.checkPixelsParam(widget, 'xscrollincrement',
40, 0, 41.2, 43.6, -40, '0.5i')
- def test_yscrollincrement(self):
+ def test_configure_yscrollincrement(self):
widget = self.create()
self.checkPixelsParam(widget, 'yscrollincrement',
10, 0, 11.2, 13.6, -10, '0.1i')
@@ -796,26 +795,26 @@ class ListboxTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Listbox(self.root, **kwargs)
- def test_activestyle(self):
+ def test_configure_activestyle(self):
widget = self.create()
self.checkEnumParam(widget, 'activestyle',
'dotbox', 'none', 'underline')
- test_justify = requires_tcl(8, 6, 5)(StandardOptionsTests.test_justify)
+ test_justify = requires_tcl(8, 6, 5)(StandardOptionsTests.test_configure_justify)
- def test_listvariable(self):
+ def test_configure_listvariable(self):
widget = self.create()
var = tkinter.DoubleVar(self.root)
self.checkVariableParam(widget, 'listvariable', var)
- def test_selectmode(self):
+ def test_configure_selectmode(self):
widget = self.create()
self.checkParam(widget, 'selectmode', 'single')
self.checkParam(widget, 'selectmode', 'browse')
self.checkParam(widget, 'selectmode', 'multiple')
self.checkParam(widget, 'selectmode', 'extended')
- def test_state(self):
+ def test_configure_state(self):
widget = self.create()
self.checkEnumParam(widget, 'state', 'disabled', 'normal')
@@ -930,53 +929,53 @@ class ScaleTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Scale(self.root, **kwargs)
- def test_bigincrement(self):
+ def test_configure_bigincrement(self):
widget = self.create()
self.checkFloatParam(widget, 'bigincrement', 12.4, 23.6, -5)
- def test_digits(self):
+ def test_configure_digits(self):
widget = self.create()
self.checkIntegerParam(widget, 'digits', 5, 0)
- def test_from(self):
+ def test_configure_from(self):
widget = self.create()
conv = False if get_tk_patchlevel() >= (8, 6, 10) else float_round
self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=conv)
- def test_label(self):
+ def test_configure_label(self):
widget = self.create()
self.checkParam(widget, 'label', 'any string')
self.checkParam(widget, 'label', '')
- def test_length(self):
+ def test_configure_length(self):
widget = self.create()
self.checkPixelsParam(widget, 'length', 130, 131.2, 135.6, '5i')
- def test_resolution(self):
+ def test_configure_resolution(self):
widget = self.create()
self.checkFloatParam(widget, 'resolution', 4.2, 0, 6.7, -2)
- def test_showvalue(self):
+ def test_configure_showvalue(self):
widget = self.create()
self.checkBooleanParam(widget, 'showvalue')
- def test_sliderlength(self):
+ def test_configure_sliderlength(self):
widget = self.create()
self.checkPixelsParam(widget, 'sliderlength',
10, 11.2, 15.6, -3, '3m')
- def test_sliderrelief(self):
+ def test_configure_sliderrelief(self):
widget = self.create()
self.checkReliefParam(widget, 'sliderrelief')
- def test_tickinterval(self):
+ def test_configure_tickinterval(self):
widget = self.create()
self.checkFloatParam(widget, 'tickinterval', 1, 4.3, 7.6, 0,
conv=float_round)
self.checkParam(widget, 'tickinterval', -2, expected=2,
conv=float_round)
- def test_to(self):
+ def test_configure_to(self):
widget = self.create()
self.checkFloatParam(widget, 'to', 300, 14.9, 15.1, -10,
conv=float_round)
@@ -1000,15 +999,15 @@ class ScrollbarTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Scrollbar(self.root, **kwargs)
- def test_activerelief(self):
+ def test_configure_activerelief(self):
widget = self.create()
self.checkReliefParam(widget, 'activerelief')
- def test_elementborderwidth(self):
+ def test_configure_elementborderwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'elementborderwidth', 4.3, 5.6, -2, '1m')
- def test_orient(self):
+ def test_configure_orient(self):
widget = self.create()
self.checkEnumParam(widget, 'orient', 'vertical', 'horizontal',
errmsg='bad orientation "{}": must be vertical or horizontal')
@@ -1049,63 +1048,63 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.PanedWindow(self.root, **kwargs)
- def test_handlepad(self):
+ def test_configure_handlepad(self):
widget = self.create()
self.checkPixelsParam(widget, 'handlepad', 5, 6.4, 7.6, -3, '1m')
- def test_handlesize(self):
+ def test_configure_handlesize(self):
widget = self.create()
self.checkPixelsParam(widget, 'handlesize', 8, 9.4, 10.6, -3, '2m',
conv=noconv)
- def test_height(self):
+ def test_configure_height(self):
widget = self.create()
self.checkPixelsParam(widget, 'height', 100, 101.2, 102.6, -100, 0, '1i',
conv=noconv)
- def test_opaqueresize(self):
+ def test_configure_opaqueresize(self):
widget = self.create()
self.checkBooleanParam(widget, 'opaqueresize')
@requires_tcl(8, 6, 5)
- def test_proxybackground(self):
+ def test_configure_proxybackground(self):
widget = self.create()
self.checkColorParam(widget, 'proxybackground')
@requires_tcl(8, 6, 5)
- def test_proxyborderwidth(self):
+ def test_configure_proxyborderwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'proxyborderwidth',
0, 1.3, 2.9, 6, -2, '10p',
conv=noconv)
@requires_tcl(8, 6, 5)
- def test_proxyrelief(self):
+ def test_configure_proxyrelief(self):
widget = self.create()
self.checkReliefParam(widget, 'proxyrelief')
- def test_sashcursor(self):
+ def test_configure_sashcursor(self):
widget = self.create()
self.checkCursorParam(widget, 'sashcursor')
- def test_sashpad(self):
+ def test_configure_sashpad(self):
widget = self.create()
self.checkPixelsParam(widget, 'sashpad', 8, 1.3, 2.6, -2, '2m')
- def test_sashrelief(self):
+ def test_configure_sashrelief(self):
widget = self.create()
self.checkReliefParam(widget, 'sashrelief')
- def test_sashwidth(self):
+ def test_configure_sashwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'sashwidth', 10, 11.1, 15.6, -3, '1m',
conv=noconv)
- def test_showhandle(self):
+ def test_configure_showhandle(self):
widget = self.create()
self.checkBooleanParam(widget, 'showhandle')
- def test_width(self):
+ def test_configure_width(self):
widget = self.create()
self.checkPixelsParam(widget, 'width', 402, 403.4, 404.6, -402, 0, '5i',
conv=noconv)
@@ -1224,23 +1223,23 @@ class MenuTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Menu(self.root, **kwargs)
- def test_postcommand(self):
+ def test_configure_postcommand(self):
widget = self.create()
self.checkCommandParam(widget, 'postcommand')
- def test_tearoff(self):
+ def test_configure_tearoff(self):
widget = self.create()
self.checkBooleanParam(widget, 'tearoff')
- def test_tearoffcommand(self):
+ def test_configure_tearoffcommand(self):
widget = self.create()
self.checkCommandParam(widget, 'tearoffcommand')
- def test_title(self):
+ def test_configure_title(self):
widget = self.create()
self.checkParam(widget, 'title', 'any string')
- def test_type(self):
+ def test_configure_type(self):
widget = self.create()
self.checkEnumParam(widget, 'type',
'normal', 'tearoff', 'menubar')
@@ -1293,17 +1292,26 @@ class MessageTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return tkinter.Message(self.root, **kwargs)
- def test_aspect(self):
+ def test_configure_aspect(self):
widget = self.create()
self.checkIntegerParam(widget, 'aspect', 250, 0, -300)
+class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
+
+ def test_frame(self):
+ self._test_widget(tkinter.Frame)
+
+ def test_label(self):
+ self._test_widget(tkinter.Label)
+
+
tests_gui = (
ButtonTest, CanvasTest, CheckbuttonTest, EntryTest,
FrameTest, LabelFrameTest,LabelTest, ListboxTest,
MenubuttonTest, MenuTest, MessageTest, OptionMenuTest,
PanedWindowTest, RadiobuttonTest, ScaleTest, ScrollbarTest,
- SpinboxTest, TextTest, ToplevelTest,
+ SpinboxTest, TextTest, ToplevelTest, DefaultRootTest,
)
if __name__ == '__main__':
diff --git a/Lib/tkinter/test/test_ttk/test_extensions.py b/Lib/tkinter/test/test_ttk/test_extensions.py
index a45f882bb0..1a70e0befe 100644
--- a/Lib/tkinter/test/test_ttk/test_extensions.py
+++ b/Lib/tkinter/test/test_ttk/test_extensions.py
@@ -2,8 +2,8 @@ import sys
import unittest
import tkinter
from tkinter import ttk
-from test.support import requires, run_unittest, swap_attr
-from tkinter.test.support import AbstractTkTest, destroy_default_root
+from test.support import requires, run_unittest
+from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest
requires('gui')
@@ -46,20 +46,6 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
if hasattr(sys, 'last_type'):
self.assertNotEqual(sys.last_type, tkinter.TclError)
-
- def test_initialization_no_master(self):
- # no master passing
- with swap_attr(tkinter, '_default_root', None), \
- swap_attr(tkinter, '_support_default_root', True):
- try:
- x = ttk.LabeledScale()
- self.assertIsNotNone(tkinter._default_root)
- self.assertEqual(x.master, tkinter._default_root)
- self.assertEqual(x.tk, tkinter._default_root.tk)
- x.destroy()
- finally:
- destroy_default_root()
-
def test_initialization(self):
# master passing
master = tkinter.Frame(self.root)
@@ -114,7 +100,6 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
def test_horizontal_range(self):
lscale = ttk.LabeledScale(self.root, from_=0, to=10)
lscale.pack()
- lscale.wait_visibility()
lscale.update()
linfo_1 = lscale.label.place_info()
@@ -144,7 +129,6 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
def test_variable_change(self):
x = ttk.LabeledScale(self.root)
x.pack()
- x.wait_visibility()
x.update()
curr_xcoord = x.scale.coords()[0]
@@ -187,7 +171,6 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
def test_resize(self):
x = ttk.LabeledScale(self.root)
x.pack(expand=True, fill='both')
- x.wait_visibility()
x.update()
width, height = x.master.winfo_width(), x.master.winfo_height()
@@ -268,7 +251,6 @@ class OptionMenuTest(AbstractTkTest, unittest.TestCase):
# check that variable is updated correctly
optmenu.pack()
- optmenu.wait_visibility()
optmenu['menu'].invoke(0)
self.assertEqual(optmenu._variable.get(), items[0])
@@ -299,9 +281,7 @@ class OptionMenuTest(AbstractTkTest, unittest.TestCase):
textvar2 = tkinter.StringVar(self.root)
optmenu2 = ttk.OptionMenu(self.root, textvar2, default, *items)
optmenu.pack()
- optmenu.wait_visibility()
optmenu2.pack()
- optmenu2.wait_visibility()
optmenu['menu'].invoke(1)
optmenu2['menu'].invoke(2)
optmenu_stringvar_name = optmenu['menu'].entrycget(0, 'variable')
@@ -317,7 +297,13 @@ class OptionMenuTest(AbstractTkTest, unittest.TestCase):
optmenu2.destroy()
-tests_gui = (LabeledScaleTest, OptionMenuTest)
+class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
+
+ def test_labeledscale(self):
+ self._test_widget(ttk.LabeledScale)
+
+
+tests_gui = (LabeledScaleTest, OptionMenuTest, DefaultRootTest)
if __name__ == "__main__":
run_unittest(*tests_gui)
diff --git a/Lib/tkinter/test/test_ttk/test_functions.py b/Lib/tkinter/test/test_ttk/test_functions.py
index f8e69a9f41..5c23d6fecf 100644
--- a/Lib/tkinter/test/test_ttk/test_functions.py
+++ b/Lib/tkinter/test/test_ttk/test_functions.py
@@ -137,6 +137,9 @@ class InternalFunctionsTest(unittest.TestCase):
result = ttk._format_mapdict(opts)
self.assertEqual(result, ('-üñíćódè', 'á vãl'))
+ self.assertEqual(ttk._format_mapdict({'opt': [('value',)]}),
+ ('-opt', '{} value'))
+
# empty states
valid = {'opt': [('', '', 'hi')]}
self.assertEqual(ttk._format_mapdict(valid), ('-opt', '{ } hi'))
@@ -159,10 +162,6 @@ class InternalFunctionsTest(unittest.TestCase):
opts = {'a': None}
self.assertRaises(TypeError, ttk._format_mapdict, opts)
- # items in the value must have size >= 2
- self.assertRaises(IndexError, ttk._format_mapdict,
- {'a': [('invalid', )]})
-
def test_format_elemcreate(self):
self.assertTrue(ttk._format_elemcreate(None), (None, ()))
diff --git a/Lib/tkinter/test/test_ttk/test_style.py b/Lib/tkinter/test/test_ttk/test_style.py
index 3537536d81..38d70d7a89 100644
--- a/Lib/tkinter/test/test_ttk/test_style.py
+++ b/Lib/tkinter/test/test_ttk/test_style.py
@@ -1,11 +1,23 @@
import unittest
+import sys
import tkinter
from tkinter import ttk
+from test import support
from test.support import requires, run_unittest
from tkinter.test.support import AbstractTkTest
requires('gui')
+CLASS_NAMES = [
+ '.', 'ComboboxPopdownFrame', 'Heading',
+ 'Horizontal.TProgressbar', 'Horizontal.TScale', 'Item', 'Sash',
+ 'TButton', 'TCheckbutton', 'TCombobox', 'TEntry',
+ 'TLabelframe', 'TLabelframe.Label', 'TMenubutton',
+ 'TNotebook', 'TNotebook.Tab', 'Toolbutton', 'TProgressbar',
+ 'TRadiobutton', 'Treeview', 'TScale', 'TScrollbar', 'TSpinbox',
+ 'Vertical.TProgressbar', 'Vertical.TScale'
+]
+
class StyleTest(AbstractTkTest, unittest.TestCase):
def setUp(self):
@@ -23,11 +35,36 @@ class StyleTest(AbstractTkTest, unittest.TestCase):
def test_map(self):
style = self.style
- style.map('TButton', background=[('active', 'background', 'blue')])
- self.assertEqual(style.map('TButton', 'background'),
- [('active', 'background', 'blue')] if self.wantobjects else
- [('active background', 'blue')])
- self.assertIsInstance(style.map('TButton'), dict)
+
+ # Single state
+ for states in ['active'], [('active',)]:
+ with self.subTest(states=states):
+ style.map('TButton', background=[(*states, 'white')])
+ expected = [('active', 'white')]
+ self.assertEqual(style.map('TButton', 'background'), expected)
+ m = style.map('TButton')
+ self.assertIsInstance(m, dict)
+ self.assertEqual(m['background'], expected)
+
+ # Multiple states
+ for states in ['pressed', '!disabled'], ['pressed !disabled'], [('pressed', '!disabled')]:
+ with self.subTest(states=states):
+ style.map('TButton', background=[(*states, 'black')])
+ expected = [('pressed', '!disabled', 'black')]
+ self.assertEqual(style.map('TButton', 'background'), expected)
+ m = style.map('TButton')
+ self.assertIsInstance(m, dict)
+ self.assertEqual(m['background'], expected)
+
+ # Default state
+ for states in [], [''], [()]:
+ with self.subTest(states=states):
+ style.map('TButton', background=[(*states, 'grey')])
+ expected = [('grey',)]
+ self.assertEqual(style.map('TButton', 'background'), expected)
+ m = style.map('TButton')
+ self.assertIsInstance(m, dict)
+ self.assertEqual(m['background'], expected)
def test_lookup(self):
@@ -86,6 +123,58 @@ class StyleTest(AbstractTkTest, unittest.TestCase):
self.style.theme_use(curr_theme)
+ def test_configure_custom_copy(self):
+ style = self.style
+
+ curr_theme = self.style.theme_use()
+ self.addCleanup(self.style.theme_use, curr_theme)
+ for theme in self.style.theme_names():
+ self.style.theme_use(theme)
+ for name in CLASS_NAMES:
+ default = style.configure(name)
+ if not default:
+ continue
+ with self.subTest(theme=theme, name=name):
+ if support.verbose >= 2:
+ print('configure', theme, name, default)
+ if (theme in ('vista', 'xpnative')
+ and sys.getwindowsversion()[:2] == (6, 1)):
+ # Fails on the Windows 7 buildbot
+ continue
+ newname = f'C.{name}'
+ self.assertEqual(style.configure(newname), None)
+ style.configure(newname, **default)
+ self.assertEqual(style.configure(newname), default)
+ for key, value in default.items():
+ self.assertEqual(style.configure(newname, key), value)
+
+
+ def test_map_custom_copy(self):
+ style = self.style
+
+ curr_theme = self.style.theme_use()
+ self.addCleanup(self.style.theme_use, curr_theme)
+ for theme in self.style.theme_names():
+ self.style.theme_use(theme)
+ for name in CLASS_NAMES:
+ default = style.map(name)
+ if not default:
+ continue
+ with self.subTest(theme=theme, name=name):
+ if support.verbose >= 2:
+ print('map', theme, name, default)
+ if (theme in ('vista', 'xpnative')
+ and sys.getwindowsversion()[:2] == (6, 1)):
+ # Fails on the Windows 7 buildbot
+ continue
+ newname = f'C.{name}'
+ self.assertEqual(style.map(newname), {})
+ style.map(newname, **default)
+ self.assertEqual(style.map(newname), default)
+ for key, value in default.items():
+ self.assertEqual(style.map(newname, key), value)
+
+
tests_gui = (StyleTest, )
if __name__ == "__main__":
diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py
index 2598bc6765..1fac83a004 100644
--- a/Lib/tkinter/test/test_ttk/test_widgets.py
+++ b/Lib/tkinter/test/test_ttk/test_widgets.py
@@ -6,7 +6,7 @@ import sys
from tkinter.test.test_ttk.test_functions import MockTclObj
from tkinter.test.support import (AbstractTkTest, tcl_version, get_tk_patchlevel,
- simulate_mouse_click)
+ simulate_mouse_click, AbstractDefaultRootTest)
from tkinter.test.widget_tests import (add_standard_options, noconv,
AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests,
setUpModule)
@@ -16,7 +16,7 @@ requires('gui')
class StandardTtkOptionsTests(StandardOptionsTests):
- def test_class(self):
+ def test_configure_class(self):
widget = self.create()
self.assertEqual(widget['class'], '')
errmsg='attempt to change read-only option'
@@ -26,7 +26,7 @@ class StandardTtkOptionsTests(StandardOptionsTests):
widget2 = self.create(class_='Foo')
self.assertEqual(widget2['class'], 'Foo')
- def test_padding(self):
+ def test_configure_padding(self):
widget = self.create()
self.checkParam(widget, 'padding', 0, expected=('0',))
self.checkParam(widget, 'padding', 5, expected=('5',))
@@ -38,7 +38,7 @@ class StandardTtkOptionsTests(StandardOptionsTests):
self.checkParam(widget, 'padding', ('5p', '6p', '7p', '8p'))
self.checkParam(widget, 'padding', (), expected='')
- def test_style(self):
+ def test_configure_style(self):
widget = self.create()
self.assertEqual(widget['style'], '')
errmsg = 'Layout Foo not found'
@@ -60,11 +60,10 @@ class WidgetTest(AbstractTkTest, unittest.TestCase):
super().setUp()
self.widget = ttk.Button(self.root, width=0, text="Text")
self.widget.pack()
- self.widget.wait_visibility()
def test_identify(self):
- self.widget.update_idletasks()
+ self.widget.update()
self.assertEqual(self.widget.identify(
int(self.widget.winfo_width() / 2),
int(self.widget.winfo_height() / 2)
@@ -140,14 +139,14 @@ class LabelFrameTest(AbstractToplevelTest, unittest.TestCase):
def create(self, **kwargs):
return ttk.LabelFrame(self.root, **kwargs)
- def test_labelanchor(self):
+ def test_configure_labelanchor(self):
widget = self.create()
self.checkEnumParam(widget, 'labelanchor',
'e', 'en', 'es', 'n', 'ne', 'nw', 's', 'se', 'sw', 'w', 'wn', 'ws',
errmsg='Bad label anchor specification {}')
self.checkInvalidParam(widget, 'labelanchor', 'center')
- def test_labelwidget(self):
+ def test_configure_labelwidget(self):
widget = self.create()
label = ttk.Label(self.root, text='Mupp', name='foo')
self.checkParam(widget, 'labelwidget', label, expected='.foo')
@@ -169,17 +168,17 @@ class AbstractLabelTest(AbstractWidgetTest):
self.checkInvalidParam(widget, name, 'spam',
errmsg='image "spam" doesn\'t exist')
- def test_compound(self):
+ def test_configure_compound(self):
widget = self.create()
self.checkEnumParam(widget, 'compound',
'none', 'text', 'image', 'center',
'top', 'bottom', 'left', 'right')
- def test_state(self):
+ def test_configure_state(self):
widget = self.create()
self.checkParams(widget, 'state', 'active', 'disabled', 'normal')
- def test_width(self):
+ def test_configure_width(self):
widget = self.create()
self.checkParams(widget, 'width', 402, -402, 0)
@@ -198,7 +197,7 @@ class LabelTest(AbstractLabelTest, unittest.TestCase):
def create(self, **kwargs):
return ttk.Label(self.root, **kwargs)
- def test_font(self):
+ def test_configure_font(self):
widget = self.create()
self.checkParam(widget, 'font',
'-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*')
@@ -216,7 +215,7 @@ class ButtonTest(AbstractLabelTest, unittest.TestCase):
def create(self, **kwargs):
return ttk.Button(self.root, **kwargs)
- def test_default(self):
+ def test_configure_default(self):
widget = self.create()
self.checkEnumParam(widget, 'default', 'normal', 'active', 'disabled')
@@ -241,11 +240,11 @@ class CheckbuttonTest(AbstractLabelTest, unittest.TestCase):
def create(self, **kwargs):
return ttk.Checkbutton(self.root, **kwargs)
- def test_offvalue(self):
+ def test_configure_offvalue(self):
widget = self.create()
self.checkParams(widget, 'offvalue', 1, 2.3, '', 'any string')
- def test_onvalue(self):
+ def test_configure_onvalue(self):
widget = self.create()
self.checkParams(widget, 'onvalue', 1, 2.3, '', 'any string')
@@ -293,27 +292,27 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return ttk.Entry(self.root, **kwargs)
- def test_invalidcommand(self):
+ def test_configure_invalidcommand(self):
widget = self.create()
self.checkCommandParam(widget, 'invalidcommand')
- def test_show(self):
+ def test_configure_show(self):
widget = self.create()
self.checkParam(widget, 'show', '*')
self.checkParam(widget, 'show', '')
self.checkParam(widget, 'show', ' ')
- def test_state(self):
+ def test_configure_state(self):
widget = self.create()
self.checkParams(widget, 'state',
'disabled', 'normal', 'readonly')
- def test_validate(self):
+ def test_configure_validate(self):
widget = self.create()
self.checkEnumParam(widget, 'validate',
'all', 'key', 'focus', 'focusin', 'focusout', 'none')
- def test_validatecommand(self):
+ def test_configure_validatecommand(self):
widget = self.create()
self.checkCommandParam(widget, 'validatecommand')
@@ -326,8 +325,7 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
def test_identify(self):
self.entry.pack()
- self.entry.wait_visibility()
- self.entry.update_idletasks()
+ self.entry.update()
# bpo-27313: macOS Cocoa widget differs from X, allow either
if sys.platform == 'darwin':
@@ -431,17 +429,18 @@ class ComboboxTest(EntryTest, unittest.TestCase):
def create(self, **kwargs):
return ttk.Combobox(self.root, **kwargs)
- def test_height(self):
+ def test_configure_height(self):
widget = self.create()
self.checkParams(widget, 'height', 100, 101.2, 102.6, -100, 0, '1i')
def _show_drop_down_listbox(self):
width = self.combo.winfo_width()
- self.combo.event_generate('<ButtonPress-1>', x=width - 5, y=5)
- self.combo.event_generate('<ButtonRelease-1>', x=width - 5, y=5)
+ x, y = width - 5, 5
+ self.assertRegex(self.combo.identify(x, y), r'.*downarrow\Z')
+ self.combo.event_generate('<ButtonPress-1>', x=x, y=y)
+ self.combo.event_generate('<ButtonRelease-1>', x=x, y=y)
self.combo.update_idletasks()
-
def test_virtual_event(self):
success = []
@@ -449,7 +448,7 @@ class ComboboxTest(EntryTest, unittest.TestCase):
self.combo.bind('<<ComboboxSelected>>',
lambda evt: success.append(True))
self.combo.pack()
- self.combo.wait_visibility()
+ self.combo.update()
height = self.combo.winfo_height()
self._show_drop_down_listbox()
@@ -460,12 +459,12 @@ class ComboboxTest(EntryTest, unittest.TestCase):
self.assertTrue(success)
- def test_postcommand(self):
+ def test_configure_postcommand(self):
success = []
self.combo['postcommand'] = lambda: success.append(True)
self.combo.pack()
- self.combo.wait_visibility()
+ self.combo.update()
self._show_drop_down_listbox()
self.assertTrue(success)
@@ -476,7 +475,7 @@ class ComboboxTest(EntryTest, unittest.TestCase):
self.assertEqual(len(success), 1)
- def test_values(self):
+ def test_configure_values(self):
def check_get_current(getval, currval):
self.assertEqual(self.combo.get(), getval)
self.assertEqual(self.combo.current(), currval)
@@ -552,7 +551,7 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return ttk.PanedWindow(self.root, **kwargs)
- def test_orient(self):
+ def test_configure_orient(self):
widget = self.create()
self.assertEqual(str(widget['orient']), 'vertical')
errmsg='attempt to change read-only option'
@@ -665,7 +664,6 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)
self.paned.pack(expand=True, fill='both')
- self.paned.wait_visibility()
curr_pos = self.paned.sashpos(0)
self.paned.sashpos(0, 1000)
@@ -686,11 +684,11 @@ class RadiobuttonTest(AbstractLabelTest, unittest.TestCase):
def create(self, **kwargs):
return ttk.Radiobutton(self.root, **kwargs)
- def test_value(self):
+ def test_configure_value(self):
widget = self.create()
self.checkParams(widget, 'value', 1, 2.3, '', 'any string')
- def test_invoke(self):
+ def test_configure_invoke(self):
success = []
def cb_test():
success.append(1)
@@ -741,7 +739,7 @@ class MenubuttonTest(AbstractLabelTest, unittest.TestCase):
self.checkEnumParam(widget, 'direction',
'above', 'below', 'left', 'right', 'flush')
- def test_menu(self):
+ def test_configure_menu(self):
widget = self.create()
menu = tkinter.Menu(widget, name='menu')
self.checkParam(widget, 'menu', menu, conv=str)
@@ -766,19 +764,19 @@ class ScaleTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return ttk.Scale(self.root, **kwargs)
- def test_from(self):
+ def test_configure_from(self):
widget = self.create()
self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=False)
- def test_length(self):
+ def test_configure_length(self):
widget = self.create()
self.checkPixelsParam(widget, 'length', 130, 131.2, 135.6, '5i')
- def test_to(self):
+ def test_configure_to(self):
widget = self.create()
self.checkFloatParam(widget, 'to', 300, 14.9, 15.1, -10, conv=False)
- def test_value(self):
+ def test_configure_value(self):
widget = self.create()
self.checkFloatParam(widget, 'value', 300, 14.9, 15.1, -10, conv=False)
@@ -868,23 +866,23 @@ class ProgressbarTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return ttk.Progressbar(self.root, **kwargs)
- def test_length(self):
+ def test_configure_length(self):
widget = self.create()
self.checkPixelsParam(widget, 'length', 100.1, 56.7, '2i')
- def test_maximum(self):
+ def test_configure_maximum(self):
widget = self.create()
self.checkFloatParam(widget, 'maximum', 150.2, 77.7, 0, -10, conv=False)
- def test_mode(self):
+ def test_configure_mode(self):
widget = self.create()
self.checkEnumParam(widget, 'mode', 'determinate', 'indeterminate')
- def test_phase(self):
+ def test_configure_phase(self):
# XXX
pass
- def test_value(self):
+ def test_configure_value(self):
widget = self.create()
self.checkFloatParam(widget, 'value', 150.2, 77.7, 0, -10,
conv=False)
@@ -933,7 +931,7 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
self.nb.add(self.child1, text='a')
self.nb.pack()
- self.nb.wait_visibility()
+ self.nb.update()
if sys.platform == 'darwin':
tb_idx = "@20,5"
else:
@@ -1041,7 +1039,7 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
def test_select(self):
self.nb.pack()
- self.nb.wait_visibility()
+ self.nb.update()
success = []
tab_changed = []
@@ -1073,7 +1071,7 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(self.nb.tab(self.child1, 'text'), 'abc')
- def test_tabs(self):
+ def test_configure_tabs(self):
self.assertEqual(len(self.nb.tabs()), 2)
self.nb.forget(self.child1)
@@ -1084,10 +1082,11 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
def test_traversal(self):
self.nb.pack()
- self.nb.wait_visibility()
+ self.nb.update()
self.nb.select(0)
+ self.assertEqual(self.nb.identify(5, 5), 'focus')
simulate_mouse_click(self.nb, 5, 5)
self.nb.focus_force()
self.nb.event_generate('<Control-Tab>')
@@ -1102,6 +1101,7 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
self.nb.tab(self.child1, text='a', underline=0)
self.nb.enable_traversal()
self.nb.focus_force()
+ self.assertEqual(self.nb.identify(5, 5), 'focus')
simulate_mouse_click(self.nb, 5, 5)
if sys.platform == 'darwin':
self.nb.event_generate('<Option-a>')
@@ -1132,6 +1132,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
height = self.spin.winfo_height()
x = width - 5
y = height//2 - 5
+ self.assertRegex(self.spin.identify(x, y), r'.*uparrow\Z')
self.spin.event_generate('<ButtonPress-1>', x=x, y=y)
self.spin.event_generate('<ButtonRelease-1>', x=x, y=y)
self.spin.update_idletasks()
@@ -1141,11 +1142,12 @@ class SpinboxTest(EntryTest, unittest.TestCase):
height = self.spin.winfo_height()
x = width - 5
y = height//2 + 4
+ self.assertRegex(self.spin.identify(x, y), r'.*downarrow\Z')
self.spin.event_generate('<ButtonPress-1>', x=x, y=y)
self.spin.event_generate('<ButtonRelease-1>', x=x, y=y)
self.spin.update_idletasks()
- def test_command(self):
+ def test_configure_command(self):
success = []
self.spin['command'] = lambda: success.append(True)
@@ -1165,7 +1167,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
self.spin.update()
self.assertEqual(len(success), 2)
- def test_to(self):
+ def test_configure_to(self):
self.spin['from'] = 0
self.spin['to'] = 5
self.spin.set(4)
@@ -1177,7 +1179,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
self._click_increment_arrow() # 5
self.assertEqual(self.spin.get(), '5')
- def test_from(self):
+ def test_configure_from(self):
self.spin['from'] = 1
self.spin['to'] = 10
self.spin.set(2)
@@ -1187,7 +1189,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
self._click_decrement_arrow() # 1
self.assertEqual(self.spin.get(), '1')
- def test_increment(self):
+ def test_configure_increment(self):
self.spin['from'] = 0
self.spin['to'] = 10
self.spin['increment'] = 4
@@ -1201,7 +1203,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
self._click_decrement_arrow() # 3
self.assertEqual(self.spin.get(), '3')
- def test_format(self):
+ def test_configure_format(self):
self.spin.set(1)
self.spin['format'] = '%10.3f'
self.spin.update()
@@ -1218,7 +1220,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
self.assertTrue('.' not in value)
self.assertEqual(len(value), 1)
- def test_wrap(self):
+ def test_configure_wrap(self):
self.spin['to'] = 10
self.spin['from'] = 1
self.spin.set(1)
@@ -1237,7 +1239,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
self._click_decrement_arrow()
self.assertEqual(self.spin.get(), '1')
- def test_values(self):
+ def test_configure_values(self):
self.assertEqual(self.spin['values'],
() if tcl_version < (8, 5) else '')
self.checkParam(self.spin, 'values', 'mon tue wed thur',
@@ -1297,14 +1299,14 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return ttk.Treeview(self.root, **kwargs)
- def test_columns(self):
+ def test_configure_columns(self):
widget = self.create()
self.checkParam(widget, 'columns', 'a b c',
expected=('a', 'b', 'c'))
self.checkParam(widget, 'columns', ('a', 'b', 'c'))
self.checkParam(widget, 'columns', '')
- def test_displaycolumns(self):
+ def test_configure_displaycolumns(self):
widget = self.create()
widget['columns'] = ('a', 'b', 'c')
self.checkParam(widget, 'displaycolumns', 'b a c',
@@ -1320,17 +1322,17 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
self.checkInvalidParam(widget, 'displaycolumns', (1, -2),
errmsg='Column index -2 out of bounds')
- def test_height(self):
+ def test_configure_height(self):
widget = self.create()
self.checkPixelsParam(widget, 'height', 100, -100, 0, '3c', conv=False)
self.checkPixelsParam(widget, 'height', 101.2, 102.6, conv=noconv)
- def test_selectmode(self):
+ def test_configure_selectmode(self):
widget = self.create()
self.checkEnumParam(widget, 'selectmode',
'none', 'browse', 'extended')
- def test_show(self):
+ def test_configure_show(self):
widget = self.create()
self.checkParam(widget, 'show', 'tree headings',
expected=('tree', 'headings'))
@@ -1342,7 +1344,6 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
def test_bbox(self):
self.tv.pack()
self.assertEqual(self.tv.bbox(''), '')
- self.tv.wait_visibility()
self.tv.update()
item_id = self.tv.insert('', 'end')
@@ -1530,13 +1531,15 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
def test_heading_callback(self):
def simulate_heading_click(x, y):
+ if tcl_version >= (8, 6):
+ self.assertEqual(self.tv.identify_column(x), '#0')
+ self.assertEqual(self.tv.identify_region(x, y), 'heading')
simulate_mouse_click(self.tv, x, y)
self.tv.update()
success = [] # no success for now
self.tv.pack()
- self.tv.wait_visibility()
self.tv.heading('#0', command=lambda: success.append(True))
self.tv.column('#0', width=100)
self.tv.update()
@@ -1784,7 +1787,6 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
lambda evt: events.append(2))
self.tv.pack()
- self.tv.wait_visibility()
self.tv.update()
pos_y = set()
@@ -1858,12 +1860,22 @@ class SizegripTest(AbstractWidgetTest, unittest.TestCase):
def create(self, **kwargs):
return ttk.Sizegrip(self.root, **kwargs)
+
+class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
+
+ def test_frame(self):
+ self._test_widget(ttk.Frame)
+
+ def test_label(self):
+ self._test_widget(ttk.Label)
+
+
tests_gui = (
ButtonTest, CheckbuttonTest, ComboboxTest, EntryTest,
FrameTest, LabelFrameTest, LabelTest, MenubuttonTest,
NotebookTest, PanedWindowTest, ProgressbarTest,
RadiobuttonTest, ScaleTest, ScrollbarTest, SeparatorTest,
- SizegripTest, SpinboxTest, TreeviewTest, WidgetTest,
+ SizegripTest, SpinboxTest, TreeviewTest, WidgetTest, DefaultRootTest,
)
if __name__ == "__main__":
diff --git a/Lib/tkinter/test/widget_tests.py b/Lib/tkinter/test/widget_tests.py
index b42ff52178..9702ff4530 100644
--- a/Lib/tkinter/test/widget_tests.py
+++ b/Lib/tkinter/test/widget_tests.py
@@ -1,7 +1,6 @@
# Common tests for test_tkinter/test_widgets.py and test_ttk/test_widgets.py
import unittest
-import sys
import tkinter
from tkinter.test.support import (AbstractTkTest, tcl_version, requires_tcl,
get_tk_patchlevel, pixels_conv, tcl_obj_eq)
@@ -243,31 +242,31 @@ class StandardOptionsTests:
'underline', 'wraplength', 'xscrollcommand', 'yscrollcommand',
)
- def test_activebackground(self):
+ def test_configure_activebackground(self):
widget = self.create()
self.checkColorParam(widget, 'activebackground')
- def test_activeborderwidth(self):
+ def test_configure_activeborderwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'activeborderwidth',
0, 1.3, 2.9, 6, -2, '10p')
- def test_activeforeground(self):
+ def test_configure_activeforeground(self):
widget = self.create()
self.checkColorParam(widget, 'activeforeground')
- def test_anchor(self):
+ def test_configure_anchor(self):
widget = self.create()
self.checkEnumParam(widget, 'anchor',
'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'center')
- def test_background(self):
+ def test_configure_background(self):
widget = self.create()
self.checkColorParam(widget, 'background')
if 'bg' in self.OPTIONS:
self.checkColorParam(widget, 'bg')
- def test_bitmap(self):
+ def test_configure_bitmap(self):
widget = self.create()
self.checkParam(widget, 'bitmap', 'questhead')
self.checkParam(widget, 'bitmap', 'gray50')
@@ -280,90 +279,88 @@ class StandardOptionsTests:
self.checkInvalidParam(widget, 'bitmap', 'spam',
errmsg='bitmap "spam" not defined')
- def test_borderwidth(self):
+ def test_configure_borderwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'borderwidth',
0, 1.3, 2.6, 6, -2, '10p')
if 'bd' in self.OPTIONS:
self.checkPixelsParam(widget, 'bd', 0, 1.3, 2.6, 6, -2, '10p')
- def test_compound(self):
+ def test_configure_compound(self):
widget = self.create()
self.checkEnumParam(widget, 'compound',
'bottom', 'center', 'left', 'none', 'right', 'top')
- def test_cursor(self):
+ def test_configure_cursor(self):
widget = self.create()
self.checkCursorParam(widget, 'cursor')
- def test_disabledforeground(self):
+ def test_configure_disabledforeground(self):
widget = self.create()
self.checkColorParam(widget, 'disabledforeground')
- def test_exportselection(self):
+ def test_configure_exportselection(self):
widget = self.create()
self.checkBooleanParam(widget, 'exportselection')
- def test_font(self):
+ def test_configure_font(self):
widget = self.create()
self.checkParam(widget, 'font',
'-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*')
self.checkInvalidParam(widget, 'font', '',
errmsg='font "" doesn\'t exist')
- def test_foreground(self):
+ def test_configure_foreground(self):
widget = self.create()
self.checkColorParam(widget, 'foreground')
if 'fg' in self.OPTIONS:
self.checkColorParam(widget, 'fg')
- def test_highlightbackground(self):
+ def test_configure_highlightbackground(self):
widget = self.create()
self.checkColorParam(widget, 'highlightbackground')
- def test_highlightcolor(self):
+ def test_configure_highlightcolor(self):
widget = self.create()
self.checkColorParam(widget, 'highlightcolor')
- def test_highlightthickness(self):
+ def test_configure_highlightthickness(self):
widget = self.create()
self.checkPixelsParam(widget, 'highlightthickness',
0, 1.3, 2.6, 6, '10p')
self.checkParam(widget, 'highlightthickness', -2, expected=0,
conv=self._conv_pixels)
- @unittest.skipIf(sys.platform == 'darwin',
- 'crashes with Cocoa Tk (issue19733)')
- def test_image(self):
+ def test_configure_image(self):
widget = self.create()
self.checkImageParam(widget, 'image')
- def test_insertbackground(self):
+ def test_configure_insertbackground(self):
widget = self.create()
self.checkColorParam(widget, 'insertbackground')
- def test_insertborderwidth(self):
+ def test_configure_insertborderwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'insertborderwidth',
0, 1.3, 2.6, 6, -2, '10p')
- def test_insertofftime(self):
+ def test_configure_insertofftime(self):
widget = self.create()
self.checkIntegerParam(widget, 'insertofftime', 100)
- def test_insertontime(self):
+ def test_configure_insertontime(self):
widget = self.create()
self.checkIntegerParam(widget, 'insertontime', 100)
- def test_insertwidth(self):
+ def test_configure_insertwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'insertwidth', 1.3, 2.6, -2, '10p')
- def test_jump(self):
+ def test_configure_jump(self):
widget = self.create()
self.checkBooleanParam(widget, 'jump')
- def test_justify(self):
+ def test_configure_justify(self):
widget = self.create()
self.checkEnumParam(widget, 'justify', 'left', 'right', 'center',
errmsg='bad justification "{}": must be '
@@ -372,154 +369,155 @@ class StandardOptionsTests:
errmsg='ambiguous justification "": must be '
'left, right, or center')
- def test_orient(self):
+ def test_configure_orient(self):
widget = self.create()
self.assertEqual(str(widget['orient']), self.default_orient)
self.checkEnumParam(widget, 'orient', 'horizontal', 'vertical')
- def test_padx(self):
+ def test_configure_padx(self):
widget = self.create()
self.checkPixelsParam(widget, 'padx', 3, 4.4, 5.6, -2, '12m',
conv=self._conv_pad_pixels)
- def test_pady(self):
+ def test_configure_pady(self):
widget = self.create()
self.checkPixelsParam(widget, 'pady', 3, 4.4, 5.6, -2, '12m',
conv=self._conv_pad_pixels)
- def test_relief(self):
+ def test_configure_relief(self):
widget = self.create()
self.checkReliefParam(widget, 'relief')
- def test_repeatdelay(self):
+ def test_configure_repeatdelay(self):
widget = self.create()
self.checkIntegerParam(widget, 'repeatdelay', -500, 500)
- def test_repeatinterval(self):
+ def test_configure_repeatinterval(self):
widget = self.create()
self.checkIntegerParam(widget, 'repeatinterval', -500, 500)
- def test_selectbackground(self):
+ def test_configure_selectbackground(self):
widget = self.create()
self.checkColorParam(widget, 'selectbackground')
- def test_selectborderwidth(self):
+ def test_configure_selectborderwidth(self):
widget = self.create()
self.checkPixelsParam(widget, 'selectborderwidth', 1.3, 2.6, -2, '10p')
- def test_selectforeground(self):
+ def test_configure_selectforeground(self):
widget = self.create()
self.checkColorParam(widget, 'selectforeground')
- def test_setgrid(self):
+ def test_configure_setgrid(self):
widget = self.create()
self.checkBooleanParam(widget, 'setgrid')
- def test_state(self):
+ def test_configure_state(self):
widget = self.create()
self.checkEnumParam(widget, 'state', 'active', 'disabled', 'normal')
- def test_takefocus(self):
+ def test_configure_takefocus(self):
widget = self.create()
self.checkParams(widget, 'takefocus', '0', '1', '')
- def test_text(self):
+ def test_configure_text(self):
widget = self.create()
self.checkParams(widget, 'text', '', 'any string')
- def test_textvariable(self):
+ def test_configure_textvariable(self):
widget = self.create()
var = tkinter.StringVar(self.root)
self.checkVariableParam(widget, 'textvariable', var)
- def test_troughcolor(self):
+ def test_configure_troughcolor(self):
widget = self.create()
self.checkColorParam(widget, 'troughcolor')
- def test_underline(self):
+ def test_configure_underline(self):
widget = self.create()
self.checkIntegerParam(widget, 'underline', 0, 1, 10)
- def test_wraplength(self):
+ def test_configure_wraplength(self):
widget = self.create()
self.checkPixelsParam(widget, 'wraplength', 100)
- def test_xscrollcommand(self):
+ def test_configure_xscrollcommand(self):
widget = self.create()
self.checkCommandParam(widget, 'xscrollcommand')
- def test_yscrollcommand(self):
+ def test_configure_yscrollcommand(self):
widget = self.create()
self.checkCommandParam(widget, 'yscrollcommand')
# non-standard but common options
- def test_command(self):
+ def test_configure_command(self):
widget = self.create()
self.checkCommandParam(widget, 'command')
- def test_indicatoron(self):
+ def test_configure_indicatoron(self):
widget = self.create()
self.checkBooleanParam(widget, 'indicatoron')
- def test_offrelief(self):
+ def test_configure_offrelief(self):
widget = self.create()
self.checkReliefParam(widget, 'offrelief')
- def test_overrelief(self):
+ def test_configure_overrelief(self):
widget = self.create()
self.checkReliefParam(widget, 'overrelief')
- def test_selectcolor(self):
+ def test_configure_selectcolor(self):
widget = self.create()
self.checkColorParam(widget, 'selectcolor')
- def test_selectimage(self):
+ def test_configure_selectimage(self):
widget = self.create()
self.checkImageParam(widget, 'selectimage')
@requires_tcl(8, 5)
- def test_tristateimage(self):
+ def test_configure_tristateimage(self):
widget = self.create()
self.checkImageParam(widget, 'tristateimage')
@requires_tcl(8, 5)
- def test_tristatevalue(self):
+ def test_configure_tristatevalue(self):
widget = self.create()
self.checkParam(widget, 'tristatevalue', 'unknowable')
- def test_variable(self):
+ def test_configure_variable(self):
widget = self.create()
var = tkinter.DoubleVar(self.root)
self.checkVariableParam(widget, 'variable', var)
class IntegerSizeTests:
- def test_height(self):
+ def test_configure_height(self):
widget = self.create()
self.checkIntegerParam(widget, 'height', 100, -100, 0)
- def test_width(self):
+ def test_configure_width(self):
widget = self.create()
self.checkIntegerParam(widget, 'width', 402, -402, 0)
class PixelSizeTests:
- def test_height(self):
+ def test_configure_height(self):
widget = self.create()
self.checkPixelsParam(widget, 'height', 100, 101.2, 102.6, -100, 0, '3c')
- def test_width(self):
+ def test_configure_width(self):
widget = self.create()
self.checkPixelsParam(widget, 'width', 402, 403.4, 404.6, -402, 0, '5i')
def add_standard_options(*source_classes):
- # This decorator adds test_xxx methods from source classes for every xxx
- # option in the OPTIONS class attribute if they are not defined explicitly.
+ # This decorator adds test_configure_xxx methods from source classes for
+ # every xxx option in the OPTIONS class attribute if they are not defined
+ # explicitly.
def decorator(cls):
for option in cls.OPTIONS:
- methodname = 'test_' + option
+ methodname = 'test_configure_' + option
if not hasattr(cls, methodname):
for source_class in source_classes:
if hasattr(source_class, methodname):
diff --git a/Lib/tkinter/tix.py b/Lib/tkinter/tix.py
index ac545502e4..7d24075403 100644
--- a/Lib/tkinter/tix.py
+++ b/Lib/tkinter/tix.py
@@ -386,10 +386,8 @@ class TixWidget(tkinter.Widget):
self.tk.call(name, 'configure', '-' + option, value)
# These are missing from Tkinter
def image_create(self, imgtype, cnf={}, master=None, **kw):
- if not master:
- master = tkinter._default_root
- if not master:
- raise RuntimeError('Too early to create image')
+ if master is None:
+ master = self
if kw and cnf: cnf = _cnfmerge((cnf, kw))
elif kw: cnf = kw
options = ()
@@ -469,16 +467,13 @@ class DisplayStyle:
(multiple) Display Items"""
def __init__(self, itemtype, cnf={}, *, master=None, **kw):
- if not master:
+ if master is None:
if 'refwindow' in kw:
master = kw['refwindow']
elif 'refwindow' in cnf:
master = cnf['refwindow']
else:
- master = tkinter._default_root
- if not master:
- raise RuntimeError("Too early to create display style: "
- "no root window")
+ master = tkinter._get_default_root('create display style')
self.tk = master.tk
self.stylename = self.tk.call('tixDisplayStyle', itemtype,
*self._options(cnf,kw) )
@@ -867,7 +862,7 @@ class HList(TixWidget, XView, YView):
return self.tk.call(self._w, 'add', entry, *self._options(cnf, kw))
def add_child(self, parent=None, cnf={}, **kw):
- if not parent:
+ if parent is None:
parent = ''
return self.tk.call(
self._w, 'addchild', parent, *self._options(cnf, kw))
diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py
index c7c71cd5a5..b854235a62 100644
--- a/Lib/tkinter/ttk.py
+++ b/Lib/tkinter/ttk.py
@@ -81,8 +81,6 @@ def _mapdict_values(items):
# ['active selected', 'grey', 'focus', [1, 2, 3, 4]]
opt_val = []
for *state, val in items:
- # hacks for backward compatibility
- state[0] # raise IndexError if empty
if len(state) == 1:
# if it is empty (something that evaluates to False), then
# format it to Tcl code to denote the "normal" state
@@ -243,19 +241,22 @@ def _script_from_settings(settings):
def _list_from_statespec(stuple):
"""Construct a list from the given statespec tuple according to the
accepted statespec accepted by _format_mapdict."""
- nval = []
- for val in stuple:
- typename = getattr(val, 'typename', None)
- if typename is None:
- nval.append(val)
- else: # this is a Tcl object
+ if isinstance(stuple, str):
+ return stuple
+ result = []
+ it = iter(stuple)
+ for state, val in zip(it, it):
+ if hasattr(state, 'typename'): # this is a Tcl object
+ state = str(state).split()
+ elif isinstance(state, str):
+ state = state.split()
+ elif not isinstance(state, (tuple, list)):
+ state = (state,)
+ if hasattr(val, 'typename'):
val = str(val)
- if typename == 'StateSpec':
- val = val.split()
- nval.append(val)
+ result.append((*state, val))
- it = iter(nval)
- return [_flatten(spec) for spec in zip(it, it)]
+ return result
def _list_from_layouttuple(tk, ltuple):
"""Construct a list from the tuple returned by ttk::layout, this is
@@ -348,12 +349,7 @@ def setup_master(master=None):
If it is not allowed to use the default root and master is None,
RuntimeError is raised."""
if master is None:
- if tkinter._support_default_root:
- master = tkinter._default_root or tkinter.Tk()
- else:
- raise RuntimeError(
- "No master specified and tkinter is "
- "configured to not support default root")
+ master = tkinter._get_default_root()
return master
@@ -395,13 +391,12 @@ class Style(object):
or something else of your preference. A statespec is compound of
one or more states and then a value."""
if query_opt is not None:
- return _list_from_statespec(self.tk.splitlist(
- self.tk.call(self._name, "map", style, '-%s' % query_opt)))
+ result = self.tk.call(self._name, "map", style, '-%s' % query_opt)
+ return _list_from_statespec(self.tk.splitlist(result))
- return _splitdict(
- self.tk,
- self.tk.call(self._name, "map", style, *_format_mapdict(kw)),
- conv=_tclobj_to_py)
+ result = self.tk.call(self._name, "map", style, *_format_mapdict(kw))
+ return {k: _list_from_statespec(self.tk.splitlist(v))
+ for k, v in _splitdict(self.tk, result).items()}
def lookup(self, style, option, state=None, default=None):
@@ -574,7 +569,7 @@ class Widget(tkinter.Widget):
matches statespec. statespec is expected to be a sequence."""
ret = self.tk.getboolean(
self.tk.call(self._w, "instate", ' '.join(statespec)))
- if ret and callback:
+ if ret and callback is not None:
return callback(*args, **kw)
return ret
@@ -1538,7 +1533,10 @@ class LabeledScale(Frame):
scale_side = 'bottom' if self._label_top else 'top'
label_side = 'top' if scale_side == 'bottom' else 'bottom'
self.scale.pack(side=scale_side, fill='x')
- tmp = Label(self).pack(side=label_side) # place holder
+ # Dummy required to make frame correct height
+ dummy = Label(self)
+ dummy.pack(side=label_side)
+ dummy.lower()
self.label.place(anchor='n' if label_side == 'top' else 's')
# update the label as scale or variable changes
diff --git a/Lib/traceback.py b/Lib/traceback.py
index a19e38718b..4e008bc0e0 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -84,7 +84,19 @@ _context_message = (
"another exception occurred:\n\n")
-def print_exception(etype, value, tb, limit=None, file=None, chain=True):
+_sentinel = object()
+
+
+def _parse_value_tb(exc, value, tb):
+ if (value is _sentinel) != (tb is _sentinel):
+ raise ValueError("Both or neither of value and tb must be given")
+ if value is tb is _sentinel:
+ return exc, exc.__traceback__
+ return value, tb
+
+
+def print_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None, \
+ file=None, chain=True):
"""Print exception up to 'limit' stack trace entries from 'tb' to 'file'.
This differs from print_tb() in the following ways: (1) if
@@ -95,9 +107,7 @@ def print_exception(etype, value, tb, limit=None, file=None, chain=True):
occurred with a caret on the next line indicating the approximate
position of the error.
"""
- # format_exception has ignored etype for some time, and code such as cgitb
- # passes in bogus values as a result. For compatibility with such code we
- # ignore it here (rather than in the new TracebackException API).
+ value, tb = _parse_value_tb(exc, value, tb)
if file is None:
file = sys.stderr
for line in TracebackException(
@@ -105,7 +115,8 @@ def print_exception(etype, value, tb, limit=None, file=None, chain=True):
print(line, file=file, end="")
-def format_exception(etype, value, tb, limit=None, chain=True):
+def format_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None, \
+ chain=True):
"""Format a stack trace and the exception information.
The arguments have the same meaning as the corresponding arguments
@@ -114,19 +125,15 @@ def format_exception(etype, value, tb, limit=None, chain=True):
these lines are concatenated and printed, exactly the same text is
printed as does print_exception().
"""
- # format_exception has ignored etype for some time, and code such as cgitb
- # passes in bogus values as a result. For compatibility with such code we
- # ignore it here (rather than in the new TracebackException API).
+ value, tb = _parse_value_tb(exc, value, tb)
return list(TracebackException(
type(value), value, tb, limit=limit).format(chain=chain))
-def format_exception_only(etype, value):
+def format_exception_only(exc, /, value=_sentinel):
"""Format the exception part of a traceback.
- The arguments are the exception type and value such as given by
- sys.last_type and sys.last_value. The return value is a list of
- strings, each ending in a newline.
+ The return value is a list of strings, each ending in a newline.
Normally, the list contains a single string; however, for
SyntaxError exceptions, it contains several lines that (when
@@ -137,7 +144,10 @@ def format_exception_only(etype, value):
string in the list.
"""
- return list(TracebackException(etype, value, None).format_exception_only())
+ if value is _sentinel:
+ value = exc
+ return list(TracebackException(
+ type(value), value, None).format_exception_only())
# -- not official API but folk probably use these two functions.
@@ -500,7 +510,6 @@ class TracebackException:
_seen=_seen)
else:
context = None
- self.exc_traceback = exc_traceback
self.__cause__ = cause
self.__context__ = context
self.__suppress_context__ = \
@@ -516,7 +525,8 @@ class TracebackException:
if exc_type and issubclass(exc_type, SyntaxError):
# Handle SyntaxError's specially
self.filename = exc_value.filename
- self.lineno = str(exc_value.lineno)
+ lno = exc_value.lineno
+ self.lineno = str(lno) if lno is not None else None
self.text = exc_value.text
self.offset = exc_value.offset
self.msg = exc_value.msg
@@ -575,9 +585,12 @@ class TracebackException:
def _format_syntax_error(self, stype):
"""Format SyntaxError exceptions (internal helper)."""
# Show exactly where the problem was found.
- filename = self.filename or "<string>"
- lineno = str(self.lineno) or '?'
- yield ' File "{}", line {}\n'.format(filename, lineno)
+ filename_suffix = ''
+ if self.lineno is not None:
+ yield ' File "{}", line {}\n'.format(
+ self.filename or "<string>", self.lineno)
+ elif self.filename is not None:
+ filename_suffix = ' ({})'.format(self.filename)
text = self.text
if text is not None:
@@ -595,7 +608,7 @@ class TracebackException:
caretspace = ((c if c.isspace() else ' ') for c in ltext[:caret])
yield ' {}^\n'.format(''.join(caretspace))
msg = self.msg or "<no detail available>"
- yield "{}: {}\n".format(stype, msg)
+ yield "{}: {}{}\n".format(stype, msg, filename_suffix)
def format(self, *, chain=True):
"""Format the exception.
@@ -617,7 +630,7 @@ class TracebackException:
not self.__suppress_context__):
yield from self.__context__.format(chain=chain)
yield _context_message
- if self.exc_traceback is not None:
+ if self.stack:
yield 'Traceback (most recent call last):\n'
- yield from self.stack.format()
+ yield from self.stack.format()
yield from self.format_exception_only()
diff --git a/Lib/tracemalloc.py b/Lib/tracemalloc.py
index 69b4170ec8..cec99c5970 100644
--- a/Lib/tracemalloc.py
+++ b/Lib/tracemalloc.py
@@ -226,7 +226,7 @@ class Traceback(Sequence):
return str(self[0])
def __repr__(self):
- s = "<Traceback %r" % tuple(self)
+ s = f"<Traceback {tuple(self)}"
if self._total_nframe is None:
s += ">"
else:
diff --git a/Lib/typing.py b/Lib/typing.py
index 3fa97a4a15..7b79876d4e 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -4,8 +4,10 @@ The typing module: Support for gradual typing as defined by PEP 484.
At large scale, the structure of the module is following:
* Imports and exports, all public names should be explicitly added to __all__.
* Internal helper functions: these should never be used in code outside this module.
-* _SpecialForm and its instances (special forms): Any, NoReturn, ClassVar, Union, Optional
-* Two classes whose instances can be type arguments in addition to types: ForwardRef and TypeVar
+* _SpecialForm and its instances (special forms):
+ Any, NoReturn, ClassVar, Union, Optional, Concatenate
+* Classes whose instances can be type arguments in addition to types:
+ ForwardRef, TypeVar and ParamSpec
* The core of internal generics API: _GenericAlias and _VariadicGenericAlias, the latter is
currently only used by Tuple and Callable. All subscripted types like X[int], Union[int, str],
etc., are instances of either of these classes.
@@ -36,11 +38,13 @@ __all__ = [
'Any',
'Callable',
'ClassVar',
+ 'Concatenate',
'Final',
'ForwardRef',
'Generic',
'Literal',
'Optional',
+ 'ParamSpec',
'Protocol',
'Tuple',
'Type',
@@ -120,6 +124,16 @@ __all__ = [
# namespace, but excluded from __all__ because they might stomp on
# legitimate imports of those modules.
+
+def _type_convert(arg):
+ """For converting None to type(None), and strings to ForwardRef."""
+ if arg is None:
+ return type(None)
+ if isinstance(arg, str):
+ return ForwardRef(arg)
+ return arg
+
+
def _type_check(arg, msg, is_argument=True):
"""Check that the argument is a type, and return it (internal helper).
@@ -136,10 +150,7 @@ def _type_check(arg, msg, is_argument=True):
if is_argument:
invalid_generic_forms = invalid_generic_forms + (ClassVar, Final)
- if arg is None:
- return type(None)
- if isinstance(arg, str):
- return ForwardRef(arg)
+ arg = _type_convert(arg)
if (isinstance(arg, _GenericAlias) and
arg.__origin__ in invalid_generic_forms):
raise TypeError(f"{arg} is not valid as type argument")
@@ -147,7 +158,7 @@ def _type_check(arg, msg, is_argument=True):
return arg
if isinstance(arg, _SpecialForm) or arg in (Generic, Protocol):
raise TypeError(f"Plain {arg} is not valid as type argument")
- if isinstance(arg, (type, TypeVar, ForwardRef, types.Union)):
+ if isinstance(arg, (type, TypeVar, ForwardRef, types.Union, ParamSpec)):
return arg
if not callable(arg):
raise TypeError(f"{msg} Got {arg!r:.100}.")
@@ -176,14 +187,14 @@ def _type_repr(obj):
def _collect_type_vars(types):
- """Collect all type variable contained in types in order of
- first appearance (lexicographic order). For example::
+ """Collect all type variable-like variables contained
+ in types in order of first appearance (lexicographic order). For example::
_collect_type_vars((T, List[S, T])) == (T, S)
"""
tvars = []
for t in types:
- if isinstance(t, TypeVar) and t not in tvars:
+ if isinstance(t, _TypeVarLike) and t not in tvars:
tvars.append(t)
if isinstance(t, (_GenericAlias, GenericAlias)):
tvars.extend([t for t in t.__parameters__ if t not in tvars])
@@ -201,6 +212,35 @@ def _check_generic(cls, parameters, elen):
raise TypeError(f"Too {'many' if alen > elen else 'few'} parameters for {cls};"
f" actual {alen}, expected {elen}")
+def _prepare_paramspec_params(cls, params):
+ """Prepares the parameters for a Generic containing ParamSpec
+ variables (internal helper).
+ """
+ # Special case where Z[[int, str, bool]] == Z[int, str, bool] in PEP 612.
+ if len(cls.__parameters__) == 1 and len(params) > 1:
+ return (params,)
+ else:
+ _params = []
+ # Convert lists to tuples to help other libraries cache the results.
+ for p, tvar in zip(params, cls.__parameters__):
+ if isinstance(tvar, ParamSpec) and isinstance(p, list):
+ p = tuple(p)
+ _params.append(p)
+ return tuple(_params)
+
+def _deduplicate(params):
+ # Weed out strict duplicates, preserving the first of each occurrence.
+ all_params = set(params)
+ if len(all_params) < len(params):
+ new_params = []
+ for t in params:
+ if t in all_params:
+ new_params.append(t)
+ all_params.remove(t)
+ params = new_params
+ assert not all_params, all_params
+ return params
+
def _remove_dups_flatten(parameters):
"""An internal helper for Union creation and substitution: flatten Unions
@@ -215,38 +255,45 @@ def _remove_dups_flatten(parameters):
params.extend(p[1:])
else:
params.append(p)
- # Weed out strict duplicates, preserving the first of each occurrence.
- all_params = set(params)
- if len(all_params) < len(params):
- new_params = []
- for t in params:
- if t in all_params:
- new_params.append(t)
- all_params.remove(t)
- params = new_params
- assert not all_params, all_params
+
+ return tuple(_deduplicate(params))
+
+
+def _flatten_literal_params(parameters):
+ """An internal helper for Literal creation: flatten Literals among parameters"""
+ params = []
+ for p in parameters:
+ if isinstance(p, _LiteralGenericAlias):
+ params.extend(p.__args__)
+ else:
+ params.append(p)
return tuple(params)
_cleanups = []
-def _tp_cache(func):
+def _tp_cache(func=None, /, *, typed=False):
"""Internal wrapper caching __getitem__ of generic types with a fallback to
original function for non-hashable arguments.
"""
- cached = functools.lru_cache()(func)
- _cleanups.append(cached.cache_clear)
+ def decorator(func):
+ cached = functools.lru_cache(typed=typed)(func)
+ _cleanups.append(cached.cache_clear)
- @functools.wraps(func)
- def inner(*args, **kwds):
- try:
- return cached(*args, **kwds)
- except TypeError:
- pass # All real errors (not unhashable args) are raised below.
- return func(*args, **kwds)
- return inner
+ @functools.wraps(func)
+ def inner(*args, **kwds):
+ try:
+ return cached(*args, **kwds)
+ except TypeError:
+ pass # All real errors (not unhashable args) are raised below.
+ return func(*args, **kwds)
+ return inner
+ if func is not None:
+ return decorator(func)
+
+ return decorator
def _eval_type(t, globalns, localns, recursive_guard=frozenset()):
"""Evaluate all forward references in the given type t.
@@ -319,6 +366,13 @@ class _SpecialForm(_Final, _root=True):
def __getitem__(self, parameters):
return self._getitem(self, parameters)
+
+class _LiteralSpecialForm(_SpecialForm, _root=True):
+ @_tp_cache(typed=True)
+ def __getitem__(self, parameters):
+ return self._getitem(self, parameters)
+
+
@_SpecialForm
def Any(self, parameters):
"""Special type indicating an unconstrained type.
@@ -436,7 +490,7 @@ def Optional(self, parameters):
arg = _type_check(parameters, f"{self} requires a single type.")
return Union[arg, type(None)]
-@_SpecialForm
+@_LiteralSpecialForm
def Literal(self, parameters):
"""Special typing form to define literal types (a.k.a. value types).
@@ -460,7 +514,17 @@ def Literal(self, parameters):
"""
# There is no '_type_check' call because arguments to Literal[...] are
# values, not types.
- return _GenericAlias(self, parameters)
+ if not isinstance(parameters, tuple):
+ parameters = (parameters,)
+
+ parameters = _flatten_literal_params(parameters)
+
+ try:
+ parameters = tuple(p for p, _ in _deduplicate(list(_value_and_type_iter(parameters))))
+ except TypeError: # unhashable parameters
+ pass
+
+ return _LiteralGenericAlias(self, parameters)
@_SpecialForm
@@ -478,6 +542,29 @@ def TypeAlias(self, parameters):
raise TypeError(f"{self} is not subscriptable")
+@_SpecialForm
+def Concatenate(self, parameters):
+ """Used in conjunction with ParamSpec and Callable to represent a higher
+ order function which adds, removes or transforms parameters of a Callable.
+
+ For example::
+
+ Callable[Concatenate[int, P], int]
+
+ See PEP 612 for detailed information.
+ """
+ if parameters == ():
+ raise TypeError("Cannot take a Concatenate of no types.")
+ if not isinstance(parameters, tuple):
+ parameters = (parameters,)
+ if not isinstance(parameters[-1], ParamSpec):
+ raise TypeError("The last parameter to Concatenate should be a "
+ "ParamSpec variable.")
+ msg = "Concatenate[arg, ...]: each arg must be a type."
+ parameters = tuple(_type_check(p, msg) for p in parameters)
+ return _ConcatenateGenericAlias(self, parameters)
+
+
class ForwardRef(_Final, _root=True):
"""Internal wrapper to hold a forward reference."""
@@ -540,8 +627,41 @@ class ForwardRef(_Final, _root=True):
def __repr__(self):
return f'ForwardRef({self.__forward_arg__!r})'
+class _TypeVarLike:
+ """Mixin for TypeVar-like types (TypeVar and ParamSpec)."""
+ def __init__(self, bound, covariant, contravariant):
+ """Used to setup TypeVars and ParamSpec's bound, covariant and
+ contravariant attributes.
+ """
+ if covariant and contravariant:
+ raise ValueError("Bivariant types are not supported.")
+ self.__covariant__ = bool(covariant)
+ self.__contravariant__ = bool(contravariant)
+ if bound:
+ self.__bound__ = _type_check(bound, "Bound must be a type.")
+ else:
+ self.__bound__ = None
+
+ def __or__(self, right):
+ return Union[self, right]
+
+ def __ror__(self, right):
+ return Union[self, right]
+
+ def __repr__(self):
+ if self.__covariant__:
+ prefix = '+'
+ elif self.__contravariant__:
+ prefix = '-'
+ else:
+ prefix = '~'
+ return prefix + self.__name__
+
+ def __reduce__(self):
+ return self.__name__
+
-class TypeVar(_Final, _Immutable, _root=True):
+class TypeVar( _Final, _Immutable, _TypeVarLike, _root=True):
"""Type variable.
Usage::
@@ -591,20 +711,13 @@ class TypeVar(_Final, _Immutable, _root=True):
def __init__(self, name, *constraints, bound=None,
covariant=False, contravariant=False):
self.__name__ = name
- if covariant and contravariant:
- raise ValueError("Bivariant types are not supported.")
- self.__covariant__ = bool(covariant)
- self.__contravariant__ = bool(contravariant)
+ super().__init__(bound, covariant, contravariant)
if constraints and bound is not None:
raise TypeError("Constraints cannot be combined with bound=...")
if constraints and len(constraints) == 1:
raise TypeError("A single constraint is not allowed")
msg = "TypeVar(name, constraint, ...): constraints must be types."
self.__constraints__ = tuple(_type_check(t, msg) for t in constraints)
- if bound:
- self.__bound__ = _type_check(bound, "Bound must be a type.")
- else:
- self.__bound__ = None
try:
def_mod = sys._getframe(1).f_globals.get('__name__', '__main__') # for pickling
except (AttributeError, ValueError):
@@ -612,23 +725,68 @@ class TypeVar(_Final, _Immutable, _root=True):
if def_mod != 'typing':
self.__module__ = def_mod
- def __or__(self, right):
- return Union[self, right]
- def __ror__(self, right):
- return Union[self, right]
+class ParamSpec(_Final, _Immutable, _TypeVarLike, _root=True):
+ """Parameter specification variable.
- def __repr__(self):
- if self.__covariant__:
- prefix = '+'
- elif self.__contravariant__:
- prefix = '-'
- else:
- prefix = '~'
- return prefix + self.__name__
+ Usage::
- def __reduce__(self):
- return self.__name__
+ P = ParamSpec('P')
+
+ Parameter specification variables exist primarily for the benefit of static
+ type checkers. They are used to forward the parameter types of one
+ Callable to another Callable, a pattern commonly found in higher order
+ functions and decorators. They are only valid when used in Concatenate, or
+ as the first argument to Callable, or as parameters for user-defined Generics.
+ See class Generic for more information on generic types. An example for
+ annotating a decorator::
+
+ T = TypeVar('T')
+ P = ParamSpec('P')
+
+ def add_logging(f: Callable[P, T]) -> Callable[P, T]:
+ '''A type-safe decorator to add logging to a function.'''
+ def inner(*args: P.args, **kwargs: P.kwargs) -> T:
+ logging.info(f'{f.__name__} was called')
+ return f(*args, **kwargs)
+ return inner
+
+ @add_logging
+ def add_two(x: float, y: float) -> float:
+ '''Add two numbers together.'''
+ return x + y
+
+ Parameter specification variables defined with covariant=True or
+ contravariant=True can be used to declare covariant or contravariant
+ generic types. These keyword arguments are valid, but their actual semantics
+ are yet to be decided. See PEP 612 for details.
+
+ Parameter specification variables can be introspected. e.g.:
+
+ P.__name__ == 'T'
+ P.__bound__ == None
+ P.__covariant__ == False
+ P.__contravariant__ == False
+
+ Note that only parameter specification variables defined in global scope can
+ be pickled.
+ """
+
+ __slots__ = ('__name__', '__bound__', '__covariant__', '__contravariant__',
+ '__dict__')
+
+ args = object()
+ kwargs = object()
+
+ def __init__(self, name, bound=None, covariant=False, contravariant=False):
+ self.__name__ = name
+ super().__init__(bound, covariant, contravariant)
+ try:
+ def_mod = sys._getframe(1).f_globals.get('__name__', '__main__')
+ except (AttributeError, ValueError):
+ def_mod = None
+ if def_mod != 'typing':
+ self.__module__ = def_mod
def _is_dunder(attr):
@@ -738,21 +896,26 @@ class _GenericAlias(_BaseGenericAlias, _root=True):
raise TypeError(f"Cannot subscript already-subscripted {self}")
if not isinstance(params, tuple):
params = (params,)
- msg = "Parameters to generic types must be types."
- params = tuple(_type_check(p, msg) for p in params)
+ params = tuple(_type_convert(p) for p in params)
+ if any(isinstance(t, ParamSpec) for t in self.__parameters__):
+ params = _prepare_paramspec_params(self, params)
_check_generic(self, params, len(self.__parameters__))
subst = dict(zip(self.__parameters__, params))
new_args = []
for arg in self.__args__:
- if isinstance(arg, TypeVar):
+ if isinstance(arg, _TypeVarLike):
arg = subst[arg]
elif isinstance(arg, (_GenericAlias, GenericAlias)):
subparams = arg.__parameters__
if subparams:
subargs = tuple(subst[x] for x in subparams)
arg = arg[subargs]
- new_args.append(arg)
+ # Required to flatten out the args for CallableGenericAlias
+ if self.__origin__ == collections.abc.Callable and isinstance(arg, tuple):
+ new_args.extend(arg)
+ else:
+ new_args.append(arg)
return self.copy_with(tuple(new_args))
def copy_with(self, params):
@@ -839,15 +1002,18 @@ class _SpecialGenericAlias(_BaseGenericAlias, _root=True):
class _CallableGenericAlias(_GenericAlias, _root=True):
def __repr__(self):
assert self._name == 'Callable'
- if len(self.__args__) == 2 and self.__args__[0] is Ellipsis:
+ args = self.__args__
+ if len(args) == 2 and (args[0] is Ellipsis
+ or isinstance(args[0], (ParamSpec, _ConcatenateGenericAlias))):
return super().__repr__()
return (f'typing.Callable'
- f'[[{", ".join([_type_repr(a) for a in self.__args__[:-1]])}], '
- f'{_type_repr(self.__args__[-1])}]')
+ f'[[{", ".join([_type_repr(a) for a in args[:-1]])}], '
+ f'{_type_repr(args[-1])}]')
def __reduce__(self):
args = self.__args__
- if not (len(args) == 2 and args[0] is ...):
+ if not (len(args) == 2 and (args[0] is Ellipsis
+ or isinstance(args[0], (ParamSpec, _ConcatenateGenericAlias)))):
args = list(args[:-1]), args[-1]
return operator.getitem, (Callable, args)
@@ -862,13 +1028,13 @@ class _CallableType(_SpecialGenericAlias, _root=True):
raise TypeError("Callable must be used as "
"Callable[[arg, ...], result].")
args, result = params
- if args is Ellipsis:
- params = (Ellipsis, result)
- else:
- if not isinstance(args, list):
- raise TypeError(f"Callable[args, result]: args must be a list."
- f" Got {args}")
+ # This relaxes what args can be on purpose to allow things like
+ # PEP 612 ParamSpec. Responsibility for whether a user is using
+ # Callable[...] properly is deferred to static type checkers.
+ if isinstance(args, list):
params = (tuple(args), result)
+ else:
+ params = (args, result)
return self.__getitem_inner__(params)
@_tp_cache
@@ -878,8 +1044,9 @@ class _CallableType(_SpecialGenericAlias, _root=True):
result = _type_check(result, msg)
if args is Ellipsis:
return self.copy_with((_TypingEllipsis, result))
- msg = "Callable[[arg, ...], result]: each arg must be a type."
- args = tuple(_type_check(arg, msg) for arg in args)
+ if not isinstance(args, tuple):
+ args = (args,)
+ args = tuple(_type_convert(arg) for arg in args)
params = args + (result,)
return self.copy_with(params)
@@ -930,6 +1097,25 @@ class _UnionGenericAlias(_GenericAlias, _root=True):
return True
+def _value_and_type_iter(parameters):
+ return ((p, type(p)) for p in parameters)
+
+
+class _LiteralGenericAlias(_GenericAlias, _root=True):
+
+ def __eq__(self, other):
+ if not isinstance(other, _LiteralGenericAlias):
+ return NotImplemented
+
+ return set(_value_and_type_iter(self.__args__)) == set(_value_and_type_iter(other.__args__))
+
+ def __hash__(self):
+ return hash(frozenset(_value_and_type_iter(self.__args__)))
+
+
+class _ConcatenateGenericAlias(_GenericAlias, _root=True):
+ pass
+
class Generic:
"""Abstract base class for generic types.
@@ -961,18 +1147,20 @@ class Generic:
if not params and cls is not Tuple:
raise TypeError(
f"Parameter list to {cls.__qualname__}[...] cannot be empty")
- msg = "Parameters to generic types must be types."
- params = tuple(_type_check(p, msg) for p in params)
+ params = tuple(_type_convert(p) for p in params)
if cls in (Generic, Protocol):
# Generic and Protocol can only be subscripted with unique type variables.
- if not all(isinstance(p, TypeVar) for p in params):
+ if not all(isinstance(p, _TypeVarLike) for p in params):
raise TypeError(
- f"Parameters to {cls.__name__}[...] must all be type variables")
+ f"Parameters to {cls.__name__}[...] must all be type variables "
+ f"or parameter specification variables.")
if len(set(params)) != len(params):
raise TypeError(
f"Parameters to {cls.__name__}[...] must all be unique")
else:
# Subscripting a regular Generic subclass.
+ if any(isinstance(t, ParamSpec) for t in cls.__parameters__):
+ params = _prepare_paramspec_params(cls, params)
_check_generic(cls, params, len(cls.__parameters__))
return _GenericAlias(cls, params)
@@ -1990,14 +2178,14 @@ def TypedDict(typename, fields=None, /, *, total=True, **kwargs):
raise TypeError("TypedDict takes either a dict or keyword arguments,"
" but not both")
- ns = {'__annotations__': dict(fields), '__total__': total}
+ ns = {'__annotations__': dict(fields)}
try:
# Setting correct module is necessary to make typed dict classes pickleable.
ns['__module__'] = sys._getframe(1).f_globals.get('__name__', '__main__')
except (AttributeError, ValueError):
pass
- return _TypedDictMeta(typename, (), ns)
+ return _TypedDictMeta(typename, (), ns, total=total)
_TypedDict = type.__new__(_TypedDictMeta, 'TypedDict', (), {})
TypedDict.__mro_entries__ = lambda bases: (_TypedDict,)
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index b495a5f6cc..720f682efb 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -406,7 +406,7 @@ class NonCallableMock(Base):
# Check if spec is an async object or function
bound_args = _MOCK_SIG.bind_partial(cls, *args, **kw).arguments
spec_arg = bound_args.get('spec_set', bound_args.get('spec'))
- if spec_arg and _is_async_obj(spec_arg):
+ if spec_arg is not None and _is_async_obj(spec_arg):
bases = (AsyncMockMixin, cls)
new = type(cls.__name__, bases, {'__doc__': cls.__doc__})
instance = _safe_super(NonCallableMock, cls).__new__(new)
@@ -631,9 +631,10 @@ class NonCallableMock(Base):
elif _is_magic(name):
raise AttributeError(name)
if not self._mock_unsafe:
- if name.startswith(('assert', 'assret')):
- raise AttributeError("Attributes cannot start with 'assert' "
- "or 'assret'")
+ if name.startswith(('assert', 'assret', 'asert', 'aseert', 'assrt')):
+ raise AttributeError(
+ f"{name!r} is not a valid assertion. Use a spec "
+ f"for the mock if {name!r} is meant to be an attribute.")
result = self._mock_children.get(name)
if result is _deleted:
@@ -1241,6 +1242,17 @@ def _importer(target):
return thing
+# _check_spec_arg_typos takes kwargs from commands like patch and checks that
+# they don't contain common misspellings of arguments related to autospeccing.
+def _check_spec_arg_typos(kwargs_to_check):
+ typos = ("autospect", "auto_spec", "set_spec")
+ for typo in typos:
+ if typo in kwargs_to_check:
+ raise RuntimeError(
+ f"{typo!r} might be a typo; use unsafe=True if this is intended"
+ )
+
+
class _patch(object):
attribute_name = None
@@ -1248,7 +1260,7 @@ class _patch(object):
def __init__(
self, getter, attribute, new, spec, create,
- spec_set, autospec, new_callable, kwargs
+ spec_set, autospec, new_callable, kwargs, *, unsafe=False
):
if new_callable is not None:
if new is not DEFAULT:
@@ -1259,6 +1271,8 @@ class _patch(object):
raise ValueError(
"Cannot use 'autospec' and 'new_callable' together"
)
+ if not unsafe:
+ _check_spec_arg_typos(kwargs)
self.getter = getter
self.attribute = attribute
@@ -1568,7 +1582,7 @@ def _get_target(target):
def _patch_object(
target, attribute, new=DEFAULT, spec=None,
create=False, spec_set=None, autospec=None,
- new_callable=None, **kwargs
+ new_callable=None, *, unsafe=False, **kwargs
):
"""
patch the named member (`attribute`) on an object (`target`) with a mock
@@ -1590,7 +1604,7 @@ def _patch_object(
getter = lambda: target
return _patch(
getter, attribute, new, spec, create,
- spec_set, autospec, new_callable, kwargs
+ spec_set, autospec, new_callable, kwargs, unsafe=unsafe
)
@@ -1645,7 +1659,7 @@ def _patch_multiple(target, spec=None, create=False, spec_set=None,
def patch(
target, new=DEFAULT, spec=None, create=False,
- spec_set=None, autospec=None, new_callable=None, **kwargs
+ spec_set=None, autospec=None, new_callable=None, *, unsafe=False, **kwargs
):
"""
`patch` acts as a function decorator, class decorator or a context
@@ -1707,6 +1721,10 @@ def patch(
use "as" then the patched object will be bound to the name after the
"as"; very useful if `patch` is creating a mock object for you.
+ Patch will raise a `RuntimeError` if passed some common misspellings of
+ the arguments autospec and spec_set. Pass the argument `unsafe` with the
+ value True to disable that check.
+
`patch` takes arbitrary keyword arguments. These will be passed to
`AsyncMock` if the patched object is asynchronous, to `MagicMock`
otherwise or to `new_callable` if specified.
@@ -1717,7 +1735,7 @@ def patch(
getter, attribute = _get_target(target)
return _patch(
getter, attribute, new, spec, create,
- spec_set, autospec, new_callable, kwargs
+ spec_set, autospec, new_callable, kwargs, unsafe=unsafe
)
@@ -2567,7 +2585,7 @@ call = _Call(from_kall=False)
def create_autospec(spec, spec_set=False, instance=False, _parent=None,
- _name=None, **kwargs):
+ _name=None, *, unsafe=False, **kwargs):
"""Create a mock object using another object as a spec. Attributes on the
mock will use the corresponding attribute on the `spec` object as their
spec.
@@ -2583,6 +2601,10 @@ def create_autospec(spec, spec_set=False, instance=False, _parent=None,
spec for an instance object by passing `instance=True`. The returned mock
will only be callable if instances of the mock are callable.
+ `create_autospec` will raise a `RuntimeError` if passed some common
+ misspellings of the arguments autospec and spec_set. Pass the argument
+ `unsafe` with the value True to disable that check.
+
`create_autospec` also takes arbitrary keyword arguments that are passed to
the constructor of the created mock."""
if _is_list(spec):
@@ -2600,6 +2622,8 @@ def create_autospec(spec, spec_set=False, instance=False, _parent=None,
_kwargs = {}
if _kwargs and instance:
_kwargs['_spec_as_instance'] = True
+ if not unsafe:
+ _check_spec_arg_typos(kwargs)
_kwargs.update(kwargs)
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
index ce674e713e..e38f41e1d2 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -38,6 +38,12 @@ class Something(object):
def smeth(a, b, c, d=None): pass
+class Typos():
+ autospect = None
+ auto_spec = None
+ set_spec = None
+
+
def something(a): pass
@@ -1598,14 +1604,23 @@ class MockTest(unittest.TestCase):
#Issue21238
def test_mock_unsafe(self):
m = Mock()
- msg = "Attributes cannot start with 'assert' or 'assret'"
+ msg = "is not a valid assertion. Use a spec for the mock"
with self.assertRaisesRegex(AttributeError, msg):
m.assert_foo_call()
with self.assertRaisesRegex(AttributeError, msg):
m.assret_foo_call()
+ with self.assertRaisesRegex(AttributeError, msg):
+ m.asert_foo_call()
+ with self.assertRaisesRegex(AttributeError, msg):
+ m.aseert_foo_call()
+ with self.assertRaisesRegex(AttributeError, msg):
+ m.assrt_foo_call()
m = Mock(unsafe=True)
m.assert_foo_call()
m.assret_foo_call()
+ m.asert_foo_call()
+ m.aseert_foo_call()
+ m.assrt_foo_call()
#Issue21262
def test_assert_not_called(self):
@@ -2156,6 +2171,62 @@ class MockTest(unittest.TestCase):
obj = mock(spec=Something)
self.assertIsInstance(obj, Something)
+ def test_bool_not_called_when_passing_spec_arg(self):
+ class Something:
+ def __init__(self):
+ self.obj_with_bool_func = unittest.mock.MagicMock()
+
+ obj = Something()
+ with unittest.mock.patch.object(obj, 'obj_with_bool_func', autospec=True): pass
+
+ self.assertEqual(obj.obj_with_bool_func.__bool__.call_count, 0)
+
+ def test_misspelled_arguments(self):
+ class Foo():
+ one = 'one'
+ # patch, patch.object and create_autospec need to check for misspelled
+ # arguments explicitly and throw a RuntimError if found.
+ with self.assertRaises(RuntimeError):
+ with patch(f'{__name__}.Something.meth', autospect=True): pass
+ with self.assertRaises(RuntimeError):
+ with patch.object(Foo, 'one', autospect=True): pass
+ with self.assertRaises(RuntimeError):
+ with patch(f'{__name__}.Something.meth', auto_spec=True): pass
+ with self.assertRaises(RuntimeError):
+ with patch.object(Foo, 'one', auto_spec=True): pass
+ with self.assertRaises(RuntimeError):
+ with patch(f'{__name__}.Something.meth', set_spec=True): pass
+ with self.assertRaises(RuntimeError):
+ with patch.object(Foo, 'one', set_spec=True): pass
+ with self.assertRaises(RuntimeError):
+ m = create_autospec(Foo, set_spec=True)
+ # patch.multiple, on the other hand, should flag misspelled arguments
+ # through an AttributeError, when trying to find the keys from kwargs
+ # as attributes on the target.
+ with self.assertRaises(AttributeError):
+ with patch.multiple(
+ f'{__name__}.Something', meth=DEFAULT, autospect=True): pass
+ with self.assertRaises(AttributeError):
+ with patch.multiple(
+ f'{__name__}.Something', meth=DEFAULT, auto_spec=True): pass
+ with self.assertRaises(AttributeError):
+ with patch.multiple(
+ f'{__name__}.Something', meth=DEFAULT, set_spec=True): pass
+
+ with patch(f'{__name__}.Something.meth', unsafe=True, autospect=True):
+ pass
+ with patch.object(Foo, 'one', unsafe=True, autospect=True): pass
+ with patch(f'{__name__}.Something.meth', unsafe=True, auto_spec=True):
+ pass
+ with patch.object(Foo, 'one', unsafe=True, auto_spec=True): pass
+ with patch(f'{__name__}.Something.meth', unsafe=True, set_spec=True):
+ pass
+ with patch.object(Foo, 'one', unsafe=True, set_spec=True): pass
+ m = create_autospec(Foo, set_spec=True, unsafe=True)
+ with patch.multiple(
+ f'{__name__}.Typos', autospect=True, set_spec=True, auto_spec=True):
+ pass
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index a8c870b977..39974d975e 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -202,6 +202,8 @@ def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH,
cafile=cafile,
capath=capath)
+ # send ALPN extension to indicate HTTP/1.1 protocol
+ context.set_alpn_protocols(['http/1.1'])
https_handler = HTTPSHandler(context=context)
opener = build_opener(https_handler)
elif context:
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index cea91308ce..6023c1e138 100755
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -550,7 +550,7 @@ def register_standard_browsers():
cmd = "xdg-settings get default-web-browser".split()
raw_result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
result = raw_result.decode().strip()
- except (FileNotFoundError, subprocess.CalledProcessError, PermissionError) :
+ except (FileNotFoundError, subprocess.CalledProcessError, PermissionError, NotADirectoryError) :
pass
else:
global _os_preferred_browser
diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py
index d318e65d84..1cbd8399d1 100644
--- a/Lib/xml/etree/ElementPath.py
+++ b/Lib/xml/etree/ElementPath.py
@@ -65,8 +65,9 @@ xpath_tokenizer_re = re.compile(
r"//?|"
r"\.\.|"
r"\(\)|"
+ r"!=|"
r"[/.*:\[\]\(\)@=])|"
- r"((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|"
+ r"((?:\{[^}]+\})?[^/\[\]\(\)@!=\s]+)|"
r"\s+"
)
@@ -253,15 +254,19 @@ def prepare_predicate(next, token):
if elem.get(key) is not None:
yield elem
return select
- if signature == "@-='":
- # [@attribute='value']
+ if signature == "@-='" or signature == "@-!='":
+ # [@attribute='value'] or [@attribute!='value']
key = predicate[1]
value = predicate[-1]
def select(context, result):
for elem in result:
if elem.get(key) == value:
yield elem
- return select
+ def select_negated(context, result):
+ for elem in result:
+ if (attr_value := elem.get(key)) is not None and attr_value != value:
+ yield elem
+ return select_negated if '!=' in signature else select
if signature == "-" and not re.match(r"\-?\d+$", predicate[0]):
# [tag]
tag = predicate[0]
@@ -270,8 +275,10 @@ def prepare_predicate(next, token):
if elem.find(tag) is not None:
yield elem
return select
- if signature == ".='" or (signature == "-='" and not re.match(r"\-?\d+$", predicate[0])):
- # [.='value'] or [tag='value']
+ if signature == ".='" or signature == ".!='" or (
+ (signature == "-='" or signature == "-!='")
+ and not re.match(r"\-?\d+$", predicate[0])):
+ # [.='value'] or [tag='value'] or [.!='value'] or [tag!='value']
tag = predicate[0]
value = predicate[-1]
if tag:
@@ -281,12 +288,22 @@ def prepare_predicate(next, token):
if "".join(e.itertext()) == value:
yield elem
break
+ def select_negated(context, result):
+ for elem in result:
+ for e in elem.iterfind(tag):
+ if "".join(e.itertext()) != value:
+ yield elem
+ break
else:
def select(context, result):
for elem in result:
if "".join(elem.itertext()) == value:
yield elem
- return select
+ def select_negated(context, result):
+ for elem in result:
+ if "".join(elem.itertext()) != value:
+ yield elem
+ return select_negated if '!=' in signature else select
if signature == "-" or signature == "-()" or signature == "-()-":
# [index] or [last()] or [last()-index]
if signature == "-":
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index e1a50a3eb5..0eed4ce9a6 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -2379,8 +2379,8 @@ class Path:
def __repr__(self):
return self.__repr.format(self=self)
- def joinpath(self, add):
- next = posixpath.join(self.at, add)
+ def joinpath(self, *other):
+ next = posixpath.join(self.at, *other)
return self._next(self.root.resolve_dir(next))
__truediv__ = joinpath
diff --git a/Lib/zipimport.py b/Lib/zipimport.py
index 080e0c4d98..ce3e00e24f 100644
--- a/Lib/zipimport.py
+++ b/Lib/zipimport.py
@@ -22,6 +22,7 @@ import _io # for open
import marshal # for loads
import sys # for modules
import time # for mktime
+import _warnings # For warn()
__all__ = ['ZipImportError', 'zipimporter']
@@ -42,7 +43,7 @@ END_CENTRAL_DIR_SIZE = 22
STRING_END_ARCHIVE = b'PK\x05\x06'
MAX_COMMENT_LEN = (1 << 16) - 1
-class zipimporter:
+class zipimporter(_bootstrap_external._LoaderBasics):
"""zipimporter(archivepath) -> zipimporter object
Create a new zipimporter instance. 'archivepath' must be a path to
@@ -115,6 +116,8 @@ class zipimporter:
full path name if it's possibly a portion of a namespace package,
or None otherwise. The optional 'path' argument is ignored -- it's
there for compatibility with the importer protocol.
+
+ Deprecated since Python 3.10. Use find_spec() instead.
"""
mi = _get_module_info(self, fullname)
if mi is not None:
@@ -146,15 +149,43 @@ class zipimporter:
instance itself if the module was found, or None if it wasn't.
The optional 'path' argument is ignored -- it's there for compatibility
with the importer protocol.
+
+ Deprecated since Python 3.10. Use find_spec() instead.
"""
return self.find_loader(fullname, path)[0]
+ def find_spec(self, fullname, target=None):
+ """Create a ModuleSpec for the specified module.
+
+ Returns None if the module cannot be found.
+ """
+ module_info = _get_module_info(self, fullname)
+ if module_info is not None:
+ return _bootstrap.spec_from_loader(fullname, self, is_package=module_info)
+ else:
+ # Not a module or regular package. See if this is a directory, and
+ # therefore possibly a portion of a namespace package.
+
+ # We're only interested in the last path component of fullname
+ # earlier components are recorded in self.prefix.
+ modpath = _get_module_path(self, fullname)
+ if _is_dir(self, modpath):
+ # This is possibly a portion of a namespace
+ # package. Return the string representing its path,
+ # without a trailing separator.
+ path = f'{self.archive}{path_sep}{modpath}'
+ spec = _bootstrap.ModuleSpec(name=fullname, loader=None,
+ is_package=True)
+ spec.submodule_search_locations.append(path)
+ return spec
+ else:
+ return None
def get_code(self, fullname):
"""get_code(fullname) -> code object.
Return the code object for the specified module. Raise ZipImportError
- if the module couldn't be found.
+ if the module couldn't be imported.
"""
code, ispackage, modpath = _get_module_code(self, fullname)
return code
@@ -184,7 +215,8 @@ class zipimporter:
def get_filename(self, fullname):
"""get_filename(fullname) -> filename string.
- Return the filename for the specified module.
+ Return the filename for the specified module or raise ZipImportError
+ if it couldn't be imported.
"""
# Deciding the filename requires working out where the code
# would come from if the module was actually loaded
@@ -236,8 +268,13 @@ class zipimporter:
Load the module specified by 'fullname'. 'fullname' must be the
fully qualified (dotted) module name. It returns the imported
- module, or raises ZipImportError if it wasn't found.
+ module, or raises ZipImportError if it could not be imported.
+
+ Deprecated since Python 3.10. Use exec_module() instead.
"""
+ msg = ("zipimport.zipimporter.load_module() is deprecated and slated for "
+ "removal in Python 3.12; use exec_module() instead")
+ _warnings.warn(msg, DeprecationWarning)
code, ispackage, modpath = _get_module_code(self, fullname)
mod = sys.modules.get(fullname)
if mod is None or not isinstance(mod, _module_type):
@@ -577,20 +614,15 @@ def _eq_mtime(t1, t2):
# Given the contents of a .py[co] file, unmarshal the data
-# and return the code object. Return None if it the magic word doesn't
-# match, or if the recorded .py[co] metadata does not match the source,
-# (we do this instead of raising an exception as we fall back
-# to .py if available and we don't want to mask other errors).
+# and return the code object. Raises ImportError it the magic word doesn't
+# match, or if the recorded .py[co] metadata does not match the source.
def _unmarshal_code(self, pathname, fullpath, fullname, data):
exc_details = {
'name': fullname,
'path': fullpath,
}
- try:
- flags = _bootstrap_external._classify_pyc(data, fullname, exc_details)
- except ImportError:
- return None
+ flags = _bootstrap_external._classify_pyc(data, fullname, exc_details)
hash_based = flags & 0b1 != 0
if hash_based:
@@ -604,11 +636,8 @@ def _unmarshal_code(self, pathname, fullpath, fullname, data):
source_bytes,
)
- try:
- _bootstrap_external._validate_hash_pyc(
- data, source_hash, fullname, exc_details)
- except ImportError:
- return None
+ _bootstrap_external._validate_hash_pyc(
+ data, source_hash, fullname, exc_details)
else:
source_mtime, source_size = \
_get_mtime_and_size_of_source(self, fullpath)
@@ -694,6 +723,7 @@ def _get_pyc_source(self, path):
# 'fullname'.
def _get_module_code(self, fullname):
path = _get_module_path(self, fullname)
+ import_error = None
for suffix, isbytecode, ispackage in _zip_searchorder:
fullpath = path + suffix
_bootstrap._verbose_message('trying {}{}{}', self.archive, path_sep, fullpath, verbosity=2)
@@ -704,8 +734,12 @@ def _get_module_code(self, fullname):
else:
modpath = toc_entry[0]
data = _get_data(self.archive, toc_entry)
+ code = None
if isbytecode:
- code = _unmarshal_code(self, modpath, fullpath, fullname, data)
+ try:
+ code = _unmarshal_code(self, modpath, fullpath, fullname, data)
+ except ImportError as exc:
+ import_error = exc
else:
code = _compile_source(modpath, data)
if code is None:
@@ -715,4 +749,8 @@ def _get_module_code(self, fullname):
modpath = toc_entry[0]
return code, ispackage, modpath
else:
- raise ZipImportError(f"can't find module {fullname!r}", name=fullname)
+ if import_error:
+ msg = f"module load failed: {import_error}"
+ raise ZipImportError(msg, name=fullname) from import_error
+ else:
+ raise ZipImportError(f"can't find module {fullname!r}", name=fullname)
diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py
index 2548b212d9..16816d1cf8 100755
--- a/Mac/BuildScript/build-installer.py
+++ b/Mac/BuildScript/build-installer.py
@@ -116,7 +116,8 @@ WORKDIR = "/tmp/_py"
DEPSRC = os.path.join(WORKDIR, 'third-party')
DEPSRC = os.path.expanduser('~/Universal/other-sources')
-universal_opts_map = { '32-bit': ('i386', 'ppc',),
+universal_opts_map = { 'universal2': ('arm64', 'x86_64'),
+ '32-bit': ('i386', 'ppc',),
'64-bit': ('x86_64', 'ppc64',),
'intel': ('i386', 'x86_64'),
'intel-32': ('i386',),
@@ -124,6 +125,7 @@ universal_opts_map = { '32-bit': ('i386', 'ppc',),
'3-way': ('ppc', 'i386', 'x86_64'),
'all': ('i386', 'ppc', 'x86_64', 'ppc64',) }
default_target_map = {
+ 'universal2': '10.9',
'64-bit': '10.5',
'3-way': '10.5',
'intel': '10.5',
@@ -151,6 +153,9 @@ DEPTARGET = '10.5'
def getDeptargetTuple():
return tuple([int(n) for n in DEPTARGET.split('.')[0:2]])
+def getBuildTuple():
+ return tuple([int(n) for n in platform.mac_ver()[0].split('.')[0:2]])
+
def getTargetCompilers():
target_cc_map = {
'10.4': ('gcc-4.0', 'g++-4.0'),
@@ -190,6 +195,34 @@ EXPECTED_SHARED_LIBS = {}
def internalTk():
return getDeptargetTuple() >= (10, 6)
+# Do we use 8.6.8 when building our own copy
+# of Tcl/Tk or a modern version.
+# We use the old version when buildin on
+# old versions of macOS due to build issues.
+def useOldTk():
+ return getBuildTuple() < (10, 15)
+
+
+def tweak_tcl_build(basedir, archList):
+ with open("Makefile", "r") as fp:
+ contents = fp.readlines()
+
+ # For reasons I don't understand the tcl configure script
+ # decides that some stdlib symbols aren't present, before
+ # deciding that strtod is broken.
+ new_contents = []
+ for line in contents:
+ if line.startswith("COMPAT_OBJS"):
+ # note: the space before strtod.o is intentional,
+ # the detection of a broken strtod results in
+ # "fixstrod.o" on this line.
+ for nm in ("strstr.o", "strtoul.o", " strtod.o"):
+ line = line.replace(nm, "")
+ new_contents.append(line)
+
+ with open("Makefile", "w") as fp:
+ fp.writelines(new_contents)
+
# List of names of third party software built with this installer.
# The names will be inserted into the rtf version of the License.
THIRD_PARTY_LIBS = []
@@ -215,15 +248,33 @@ def library_recipes():
buildrecipe=build_universal_openssl,
configure=None,
install=None,
+ patches=[
+ "openssl-mac-arm64.patch",
+ ],
),
])
if internalTk():
+ if useOldTk():
+ tcl_tk_ver='8.6.8'
+ tcl_checksum='81656d3367af032e0ae6157eff134f89'
+
+ tk_checksum='5e0faecba458ee1386078fb228d008ba'
+ tk_patches = ['tk868_on_10_8_10_9.patch']
+
+ else:
+ tcl_tk_ver='8.6.10'
+ tcl_checksum='97c55573f8520bcab74e21bfd8d0aadc'
+
+ tk_checksum='602a47ad9ecac7bf655ada729d140a94'
+ tk_patches = [ ]
+
+
result.extend([
dict(
- name="Tcl 8.6.8",
- url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tcl8.6.8-src.tar.gz",
- checksum='81656d3367af032e0ae6157eff134f89',
+ name="Tcl %s"%(tcl_tk_ver,),
+ url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tcl%s-src.tar.gz"%(tcl_tk_ver,),
+ checksum=tcl_checksum,
buildDir="unix",
configure_pre=[
'--enable-shared',
@@ -231,18 +282,17 @@ def library_recipes():
'--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib'%(getVersion(),),
],
useLDFlags=False,
+ buildrecipe=tweak_tcl_build,
install='make TCL_LIBRARY=%(TCL_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s DESTDIR=%(DESTDIR)s'%{
"DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')),
"TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.6'%(getVersion())),
},
),
dict(
- name="Tk 8.6.8",
- url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tk8.6.8-src.tar.gz",
- checksum='5e0faecba458ee1386078fb228d008ba',
- patches=[
- "tk868_on_10_8_10_9.patch",
- ],
+ name="Tk %s"%(tcl_tk_ver,),
+ url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tk%s-src.tar.gz"%(tcl_tk_ver,),
+ checksum=tk_checksum,
+ patches=tk_patches,
buildDir="unix",
configure_pre=[
'--enable-aqua',
@@ -537,8 +587,8 @@ def checkEnvironment():
Check that we're running on a supported system.
"""
- if sys.version_info[0:2] < (2, 5):
- fatal("This script must be run with Python 2.5 (or later)")
+ if sys.version_info[0:2] < (2, 7):
+ fatal("This script must be run with Python 2.7 (or later)")
if platform.system() != 'Darwin':
fatal("This script should be run on a macOS 10.5 (or later) system")
@@ -606,9 +656,6 @@ def checkEnvironment():
base_path = base_path + ':' + OLD_DEVELOPER_TOOLS
os.environ['PATH'] = base_path
print("Setting default PATH: %s"%(os.environ['PATH']))
- # Ensure we have access to sphinx-build.
- # You may have to create a link in /usr/bin for it.
- runCommand('sphinx-build --version')
def parseOptions(args=None):
"""
@@ -801,6 +848,7 @@ def build_universal_openssl(basedir, archList):
arch_opts = {
"i386": ["darwin-i386-cc"],
"x86_64": ["darwin64-x86_64-cc", "enable-ec_nistp_64_gcc_128"],
+ "arm64": ["darwin64-arm64-cc"],
"ppc": ["darwin-ppc-cc"],
"ppc64": ["darwin64-ppc-cc"],
}
@@ -1567,8 +1615,17 @@ def buildDMG():
if os.path.exists(outdir):
shutil.rmtree(outdir)
+ # We used to use the deployment target as the last characters of the
+ # installer file name. With the introduction of weaklinked installer
+ # variants, we may have two variants with the same file name, i.e.
+ # both ending in '10.9'. To avoid this, we now use the major/minor
+ # version numbers of the macOS version we are building on, i.e.
+ # '10.9' as before for 10.9+ variant, '11.0' for universal2 11.0-.
+ # it's not ideal but should cause the least disruption to packaging
+ # workflows.
+ build_system_version = '.'.join(platform.mac_ver()[0].split('.')[0:2])
imagepath = os.path.join(outdir,
- 'python-%s-macosx%s'%(getFullVersion(),DEPTARGET))
+ 'python-%s-macosx%s'%(getFullVersion(),build_system_version))
if INCLUDE_TIMESTAMP:
imagepath = imagepath + '-%04d-%02d-%02d'%(time.localtime()[:3])
imagepath = imagepath + '.dmg'
diff --git a/Mac/BuildScript/openssl-mac-arm64.patch b/Mac/BuildScript/openssl-mac-arm64.patch
new file mode 100644
index 0000000000..11267fb118
--- /dev/null
+++ b/Mac/BuildScript/openssl-mac-arm64.patch
@@ -0,0 +1,41 @@
+diff -ur openssl-1.1.1g-orig/Configurations/10-main.conf openssl-1.1.1g/Configurations/10-main.conf
+--- openssl-1.1.1g-orig/Configurations/10-main.conf 2020-04-21 14:22:39.000000000 +0200
++++ openssl-1.1.1g/Configurations/10-main.conf 2020-07-26 12:21:32.000000000 +0200
+@@ -1557,6 +1557,14 @@
+ bn_ops => "SIXTY_FOUR_BIT_LONG",
+ perlasm_scheme => "macosx",
+ },
++ "darwin64-arm64-cc" => {
++ inherit_from => [ "darwin-common", asm("aarch64_asm") ],
++ CFLAGS => add("-Wall"),
++ cflags => add("-arch arm64"),
++ lib_cppflags => add("-DL_ENDIAN"),
++ bn_ops => "SIXTY_FOUR_BIT_LONG",
++ perlasm_scheme => "ios64",
++ },
+
+ ##### GNU Hurd
+ "hurd-x86" => {
+diff -ur openssl-1.1.1g-orig/config openssl-1.1.1g/config
+--- openssl-1.1.1g-orig/config 2020-04-21 14:22:39.000000000 +0200
++++ openssl-1.1.1g/config 2020-07-26 12:21:59.000000000 +0200
+@@ -255,6 +255,9 @@
+ ;;
+ x86_64)
+ echo "x86_64-apple-darwin${VERSION}"
++ ;;
++ arm64)
++ echo "arm64-apple-darwin${VERSION}"
+ ;;
+ *)
+ echo "i686-apple-darwin${VERSION}"
+@@ -497,6 +500,9 @@
+ else
+ OUT="darwin64-x86_64-cc"
+ fi ;;
++ x86_64-apple-darwin*)
++ OUT="darwin64-arm64-cc"
++ ;;
+ armv6+7-*-iphoneos)
+ __CNF_CFLAGS="$__CNF_CFLAGS -arch armv6 -arch armv7"
+ __CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch armv6 -arch armv7"
diff --git a/Mac/BuildScript/resources/ReadMe.rtf b/Mac/BuildScript/resources/ReadMe.rtf
index a4dd8b5ee4..c82e4b6303 100644
--- a/Mac/BuildScript/resources/ReadMe.rtf
+++ b/Mac/BuildScript/resources/ReadMe.rtf
@@ -3,7 +3,7 @@
\f3\fmodern\fcharset0 CourierNewPSMT;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
-\margl1440\margr1440\vieww13380\viewh14600\viewkind0
+\margl1440\margr1440\vieww13380\viewh14580\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\f0\fs24 \cf0 This package will install Python $FULL_VERSION for macOS $MACOSX_DEPLOYMENT_TARGET for the following architecture(s): $ARCHITECTURES.\
@@ -56,7 +56,15 @@ Due to new security checks on macOS 10.15 Catalina, when launching IDLE macOS ma
\f0\b0 button to proceed.\
\
-\f1\b \ul Other changes\
+\f1\b \ul macOS 11.0 (Big Sur) and Apple Silicon Mac support [new in 3.10.0a3]\
+
+\f0\b0 \ulnone \
+As of 2020-11, macOS 11.0 (Big Sur) is the latest release of macOS and one of its major features is the support of new Apple Silicon Macs that are based on the ARM64 CPU architecture specification rather than the Intel 64 (x86_64) architecture used previously. There are other changes in Big Sur that affect Python operation regardless of CPU architecture.\
+\
+Beginning with 3.10.0a3, we provide a new "universal2" installer variant that provides universal binaries for both ARM64 and Intel 64 architectures and is also supported on all Macs that support macOS 10.9 or later. Some of the advantages of the new installer variant: native ARM64 code on Apple Silicon Macs should run significantly faster than Rosetta2-emulated code; some operating system functions and options introduced in macOS releases since 10.9 are now exposed when available (primarily in the os module); the new installer variant includes Tcl/Tk 8.6.10 rather than 8.6.8.\
+
+\f1\b \ul \
+Other changes\
\f0\b0 \ulnone \
For other changes in this release, see the
diff --git a/Mac/BuildScript/scripts/postflight.patch-profile b/Mac/BuildScript/scripts/postflight.patch-profile
index 0a62e327f5..68b8e4bb04 100755
--- a/Mac/BuildScript/scripts/postflight.patch-profile
+++ b/Mac/BuildScript/scripts/postflight.patch-profile
@@ -20,7 +20,7 @@ fi
# Make sure the directory ${PYTHON_ROOT}/bin is on the users PATH.
BSH="`basename "${theShell}"`"
case "${BSH}" in
-bash|ksh|sh|*csh|zsh)
+bash|ksh|sh|*csh|zsh|fish)
if [ `id -ur` = 0 ]; then
P=`su - ${USER} -c 'echo A-X-4-X@@$PATH@@X-4-X-A' | grep 'A-X-4-X@@.*@@X-4-X-A' | sed -e 's/^A-X-4-X@@//g' -e 's/@@X-4-X-A$//g'`
else
@@ -76,6 +76,22 @@ bash)
PR="${HOME}/.bash_profile"
fi
;;
+fish)
+ CONFIG_DIR="${HOME}/.config/fish"
+ RC="${CONFIG_DIR}/config.fish"
+ mkdir -p "$CONFIG_DIR"
+ if [ -f "${RC}" ]; then
+ cp -fp "${RC}" "${RC}.pysave"
+ fi
+ echo "" >> "${RC}"
+ echo "# Setting PATH for Python ${PYVER}" >> "${RC}"
+ echo "# The original version is saved in ${RC}.pysave" >> "${RC}"
+ echo "set -x PATH \"${PYTHON_ROOT}/bin\" \"\$PATH\"" >> "${RC}"
+ if [ `id -ur` = 0 ]; then
+ chown "${USER}" "${RC}"
+ fi
+ exit 0
+ ;;
zsh)
PR="${HOME}/.zprofile"
;;
diff --git a/Mac/README.rst b/Mac/README.rst
index ec7d873df2..f3638aa001 100644
--- a/Mac/README.rst
+++ b/Mac/README.rst
@@ -120,6 +120,8 @@ support ppc (Xcode 4 on 10.6 and later systems). The flavor can be specified
using the configure option ``--with-universal-archs=VALUE``. The following
values are available:
+ * ``universal2``: ``arm64``, ``x86_64``
+
* ``intel``: ``i386``, ``x86_64``
* ``intel-32``: ``i386``
@@ -155,6 +157,8 @@ following combinations of SDKs and universal-archs flavors are available:
* 10.15 and later SDKs support ``intel-64`` only
+ * 11.0 and later SDKs support ``universal2``
+
The makefile for a framework build will also install ``python3.x-32``
binaries when the universal architecture includes at least one 32-bit
architecture (that is, for all flavors but ``64-bit`` and ``intel-64``).
@@ -352,6 +356,39 @@ A framework install also installs some applications in ``/Applications/Python X.
And lastly a framework installation installs files in ``/usr/local/bin``, all of
them symbolic links to files in ``/Library/Frameworks/Python.framework/Versions/X.Y/bin``.
+Weak linking support
+====================
+
+The CPython sources support building with the latest SDK while targetting deployment
+to macOS 10.9. This is done through weak linking of symbols introduced in macOS
+10.10 or later and checking for their availability at runtime.
+
+This requires the use of Apple's compiler toolchain on macOS 10.13 or later.
+
+The basic implementation pattern is:
+
+* ``HAVE_<FUNCTION>`` is a macro defined (or not) by the configure script
+
+* ``HAVE_<FUNCTION>_RUNTIME`` is a macro defined in the relevant source
+ files. This expands to a call to ``__builtin_available`` when using
+ a new enough Apple compiler, and to a true value otherwise.
+
+* Use ``HAVE_<FUNCTION>_RUNTIME`` before calling ``<function>``. This macro
+ *must* be used a the sole expression in an if statement::
+
+ if (HAVE_<FUNCTION>_RUNTIME) {
+ /* <function> is available */
+ }
+
+ Or:
+
+ if (HAVE_<FUNCTION>_RUNTIME) {} else {
+ /* <function> is not available */
+ }
+
+ Using other patterns (such as ``!HAVE_<FUNCTION>_RUNTIME``) is not supported
+ by Apple's compilers.
+
Resources
=========
diff --git a/Mac/Tools/pythonw.c b/Mac/Tools/pythonw.c
index c8bd3ba8d6..78813e818e 100644
--- a/Mac/Tools/pythonw.c
+++ b/Mac/Tools/pythonw.c
@@ -95,9 +95,6 @@ setup_spawnattr(posix_spawnattr_t* spawnattr)
size_t count;
cpu_type_t cpu_types[1];
short flags = 0;
-#ifdef __LP64__
- int ch;
-#endif
if ((errno = posix_spawnattr_init(spawnattr)) != 0) {
err(2, "posix_spawnattr_int");
@@ -119,10 +116,16 @@ setup_spawnattr(posix_spawnattr_t* spawnattr)
#elif defined(__ppc__)
cpu_types[0] = CPU_TYPE_POWERPC;
+
#elif defined(__i386__)
cpu_types[0] = CPU_TYPE_X86;
+
+#elif defined(__arm64__)
+ cpu_types[0] = CPU_TYPE_ARM64;
+
#else
# error "Unknown CPU"
+
#endif
if (posix_spawnattr_setbinpref_np(spawnattr, count,
@@ -220,7 +223,8 @@ main(int argc, char **argv) {
/* We're weak-linking to posix-spawnv to ensure that
* an executable build on 10.5 can work on 10.4.
*/
- if (posix_spawn != NULL) {
+
+ if (&posix_spawn != NULL) {
posix_spawnattr_t spawnattr = NULL;
setup_spawnattr(&spawnattr);
diff --git a/Makefile.pre.in b/Makefile.pre.in
index a8912cd418..5c93b0b3fa 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -744,6 +744,13 @@ regen-importlib: Programs/_freeze_importlib
$(UPDATE_FILE) $(srcdir)/Python/importlib_zipimport.h $(srcdir)/Python/importlib_zipimport.h.new
+regen-limited-abi: all
+ @$(MKDIR_P) $(srcdir)/Doc/data/
+ $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/stable_abi.py generate $(srcdir)/Doc/data/stable_abi.dat.new
+ $(UPDATE_FILE) $(srcdir)/Doc/data/stable_abi.dat \
+ $(srcdir)/Doc/data/stable_abi.dat.new
+
+
############################################################################
# Regenerate all generated files
@@ -1095,6 +1102,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/cpython/pylifecycle.h \
$(srcdir)/Include/cpython/pymem.h \
$(srcdir)/Include/cpython/pystate.h \
+ $(srcdir)/Include/cpython/pythonrun.h \
$(srcdir)/Include/cpython/sysmodule.h \
$(srcdir)/Include/cpython/traceback.h \
$(srcdir)/Include/cpython/tupleobject.h \
@@ -1103,6 +1111,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_abstract.h \
$(srcdir)/Include/internal/pycore_accu.h \
$(srcdir)/Include/internal/pycore_atomic.h \
+ $(srcdir)/Include/internal/pycore_atomic_funcs.h \
$(srcdir)/Include/internal/pycore_bitutils.h \
$(srcdir)/Include/internal/pycore_bytes_methods.h \
$(srcdir)/Include/internal/pycore_call.h \
@@ -1112,6 +1121,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_context.h \
$(srcdir)/Include/internal/pycore_dtoa.h \
$(srcdir)/Include/internal/pycore_fileutils.h \
+ $(srcdir)/Include/internal/pycore_format.h \
$(srcdir)/Include/internal/pycore_getopt.h \
$(srcdir)/Include/internal/pycore_gil.h \
$(srcdir)/Include/internal/pycore_hamt.h \
@@ -1639,7 +1649,7 @@ libainstall: @DEF_MAKE_RULE@ python-config
$(INSTALL_SCRIPT) Modules/ld_so_aix \
$(DESTDIR)$(LIBPL)/ld_so_aix; \
echo "$(LIBPL)/ld_so_aix"; \
- echo; echo "See Misc/AIX-NOTES for details."; \
+ echo; echo "See Misc/README.AIX for details."; \
else true; \
fi
@@ -1899,6 +1909,9 @@ funny:
patchcheck: @DEF_MAKE_RULE@
$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
+check-limited-abi: all
+ $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/stable_abi.py check $(srcdir)/Doc/data/stable_abi.dat
+
# Dependencies
Python/thread.o: @THREADHEADERS@ $(srcdir)/Python/condvar.h
diff --git a/Misc/ACKS b/Misc/ACKS
index 5285693a6e..80e51f93e3 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -270,6 +270,7 @@ Daniel Calvelo
Tony Campbell
Giovanni Cappellotto
Brett Cannon
+Joshua Cannon
Tristan Carel
Mike Carlton
Pierre Carrier
@@ -367,6 +368,7 @@ Ryan Coyner
Christopher A. Craig
Jeremy Craven
Laura Creighton
+Nick Crews
Tyler Crompton
Simon Cross
Felipe Cruz
@@ -641,6 +643,7 @@ Grzegorz Grzywacz
Thomas Guettler
Yuyang Guo
Anuj Gupta
+Om Gupta
Michael Guravage
Lars Gustäbel
Thomas Güttler
@@ -861,6 +864,7 @@ Jan Kanis
Rafe Kaplan
Jacob Kaplan-Moss
Allison Kaptur
+Yurii Karabas
Janne Karila
Per Øyvind Karlsen
Anton Kasyanov
@@ -949,6 +953,7 @@ Ivan Krstić
Anselm Kruis
Steven Kryskalla
Andrew Kuchling
+Jakub Kuczys
Dave Kuhlman
Jon Kuhn
Ilya Kulakov
@@ -1279,6 +1284,7 @@ Michael Otteneder
Richard Oudkerk
Russel Owen
Joonas Paalasmaa
+Yaroslav Pankovych
Martin Packman
Elisha Paine
Shriphani Palakodety
@@ -1618,6 +1624,7 @@ Ville Skyttä
Michael Sloan
Nick Sloan
Václav Šmilauer
+Casper W. Smet
Allen W. Smith
Christopher Smith
Eric V. Smith
@@ -1842,6 +1849,7 @@ Zachary Ware
Barry Warsaw
Steve Waterbury
Bob Watson
+Colin Watson
David Watson
Aaron Watters
Henrik Weber
diff --git a/Misc/NEWS.d/3.10.0a2.rst b/Misc/NEWS.d/3.10.0a2.rst
new file mode 100644
index 0000000000..3cfef17160
--- /dev/null
+++ b/Misc/NEWS.d/3.10.0a2.rst
@@ -0,0 +1,912 @@
+.. bpo: 42103
+.. date: 2020-10-23-19-19-30
+.. nonce: cILT66
+.. release date: 2020-11-03
+.. section: Security
+
+Prevented potential DoS attack via CPU and RAM exhaustion when processing
+malformed Apple Property List files in binary format.
+
+..
+
+.. bpo: 42051
+.. date: 2020-10-19-10-56-27
+.. nonce: EU_B7u
+.. section: Security
+
+The :mod:`plistlib` module no longer accepts entity declarations in XML
+plist files to avoid XML vulnerabilities. This should not affect users as
+entity declarations are not used in regular plist files.
+
+..
+
+.. bpo: 42236
+.. date: 2020-11-01-21-21-38
+.. nonce: MPx-NK
+.. section: Core and Builtins
+
+If the ``nl_langinfo(CODESET)`` function returns an empty string, Python now
+uses UTF-8 as the filesystem encoding. Patch by Victor Stinner.
+
+..
+
+.. bpo: 42218
+.. date: 2020-10-31-17-50-23
+.. nonce: Dp_Z3v
+.. section: Core and Builtins
+
+Fixed a bug in the PEG parser that was causing crashes in debug mode. Now
+errors are checked in left-recursive rules to avoid cases where such errors
+do not get handled in time and appear as long-distance crashes in other
+places.
+
+..
+
+.. bpo: 42214
+.. date: 2020-10-30-22-16-30
+.. nonce: lXskM_
+.. section: Core and Builtins
+
+Fixed a possible crash in the PEG parser when checking for the '!=' token in
+the ``barry_as_flufl`` rule. Patch by Pablo Galindo.
+
+..
+
+.. bpo: 42206
+.. date: 2020-10-30-13-11-01
+.. nonce: xxssR8
+.. section: Core and Builtins
+
+Propagate and raise the errors caused by :c:func:`PyAST_Validate` in the
+parser.
+
+..
+
+.. bpo: 41796
+.. date: 2020-10-29-12-49-08
+.. nonce: tkGdHq
+.. section: Core and Builtins
+
+The :mod:`ast` module internal state is now per interpreter. Patch by Victor
+Stinner.
+
+..
+
+.. bpo: 42143
+.. date: 2020-10-27-21-34-05
+.. nonce: N6KXUO
+.. section: Core and Builtins
+
+Fix handling of errors during creation of ``PyFunctionObject``, which
+resulted in operations on uninitialized memory. Patch by Yonatan
+Goldschmidt.
+
+..
+
+.. bpo: 41659
+.. date: 2020-10-27-18-32-49
+.. nonce: d4a-8o
+.. section: Core and Builtins
+
+Fix a bug in the parser, where a curly brace following a `primary` didn't
+fail immediately. This led to invalid expressions like `a {b}` to throw a
+:exc:`SyntaxError` with a wrong offset, or invalid expressions ending with a
+curly brace like `a {` to not fail immediately in the REPL.
+
+..
+
+.. bpo: 42150
+.. date: 2020-10-25-21-14-18
+.. nonce: b70u_T
+.. section: Core and Builtins
+
+Fix possible buffer overflow in the new parser when checking for
+continuation lines. Patch by Pablo Galindo.
+
+..
+
+.. bpo: 42123
+.. date: 2020-10-23-02-43-24
+.. nonce: 64gJWC
+.. section: Core and Builtins
+
+Run the parser two times. On the first run, disable all the rules that only
+generate better error messages to gain performance. If there's a parse
+failure, run the parser a second time with those enabled.
+
+..
+
+.. bpo: 42093
+.. date: 2020-10-20-04-24-07
+.. nonce: ooZZNh
+.. section: Core and Builtins
+
+The ``LOAD_ATTR`` instruction now uses new "per opcode cache" mechanism and
+it is about 36% faster now. Patch by Pablo Galindo and Yury Selivanov.
+
+..
+
+.. bpo: 42030
+.. date: 2020-10-15-21-55-32
+.. nonce: PmU2CA
+.. section: Core and Builtins
+
+Support for the legacy AIX-specific shared library loading support has been
+removed. All versions of AIX since 4.3 have supported and defaulted to using
+the common Unix mechanism instead.
+
+..
+
+.. bpo: 41984
+.. date: 2020-10-14-16-19-43
+.. nonce: SEtKMr
+.. section: Core and Builtins
+
+The garbage collector now tracks all user-defined classes. Patch by Brandt
+Bucher.
+
+..
+
+.. bpo: 41993
+.. date: 2020-10-10-13-53-52
+.. nonce: YMzixQ
+.. section: Core and Builtins
+
+Fixed potential issues with removing not completely initialized module from
+``sys.modules`` when import fails.
+
+..
+
+.. bpo: 41979
+.. date: 2020-10-09-10-55-50
+.. nonce: ImXIk2
+.. section: Core and Builtins
+
+Star-unpacking is now allowed for with item's targets in the PEG parser.
+
+..
+
+.. bpo: 41974
+.. date: 2020-10-08-09-58-19
+.. nonce: 8B-q8O
+.. section: Core and Builtins
+
+Removed special methods ``__int__``, ``__float__``, ``__floordiv__``,
+``__mod__``, ``__divmod__``, ``__rfloordiv__``, ``__rmod__`` and
+``__rdivmod__`` of the :class:`complex` class. They always raised a
+:exc:`TypeError`.
+
+..
+
+.. bpo: 41902
+.. date: 2020-10-02-13-32-05
+.. nonce: ZKTxzW
+.. section: Core and Builtins
+
+Micro optimization when compute :c:member:`~PySequenceMethods.sq_item` and
+:c:member:`~PyMappingMethods.mp_subscript` of :class:`range`. Patch by
+Dong-hee Na.
+
+..
+
+.. bpo: 41894
+.. date: 2020-10-02-11-35-33
+.. nonce: ffmtOt
+.. section: Core and Builtins
+
+When loading a native module and a load failure occurs, prevent a possible
+UnicodeDecodeError when not running in a UTF-8 locale by decoding the load
+error message using the current locale's encoding.
+
+..
+
+.. bpo: 41902
+.. date: 2020-10-01-22-44-23
+.. nonce: iLoMVF
+.. section: Core and Builtins
+
+Micro optimization for range.index if step is 1. Patch by Dong-hee Na.
+
+..
+
+.. bpo: 41435
+.. date: 2020-08-07-13-42-48
+.. nonce: qPWjJA
+.. section: Core and Builtins
+
+Add `sys._current_exceptions()` function to retrieve a dictionary mapping
+each thread's identifier to the topmost exception currently active in that
+thread at the time the function is called.
+
+..
+
+.. bpo: 38605
+.. date: 2020-05-27-16-08-16
+.. nonce: rcs2uK
+.. section: Core and Builtins
+
+Enable ``from __future__ import annotations`` (:pep:`563`) by default. The
+values found in :attr:`__annotations__` dicts are now strings, e.g. ``{"x":
+"int"}`` instead of ``{"x": int}``.
+
+..
+
+.. bpo: 35455
+.. date: 2020-11-02-14-10-48
+.. nonce: Q1xTIo
+.. section: Library
+
+On Solaris, :func:`~time.thread_time` is now implemented with
+``gethrvtime()`` because ``clock_gettime(CLOCK_THREAD_CPUTIME_ID)`` is not
+always available. Patch by Jakub Kulik.
+
+..
+
+.. bpo: 42233
+.. date: 2020-11-02-01-31-15
+.. nonce: YxRj-h
+.. section: Library
+
+The :func:`repr` of :mod:`typing` types containing :ref:`Generic Alias Types
+<types-genericalias>` previously did not show the parameterized types in the
+``GenericAlias``. They have now been changed to do so.
+
+..
+
+.. bpo: 29566
+.. date: 2020-10-31-13-28-36
+.. nonce: 6aDbty
+.. section: Library
+
+``binhex.binhex()`` consisently writes macOS 9 line endings.
+
+..
+
+.. bpo: 26789
+.. date: 2020-10-31-01-16-49
+.. nonce: 9BdNAt
+.. section: Library
+
+The :class:`logging.FileHandler` class now keeps a reference to the builtin
+:func:`open` function to be able to open or reopen the file during Python
+finalization. Fix errors like: ``NameError: name 'open' is not defined``.
+Patch by Victor Stinner.
+
+..
+
+.. bpo: 42157
+.. date: 2020-10-26-23-29-16
+.. nonce: 4wuwTe
+.. section: Library
+
+Removed the ``unicodedata.ucnhash_CAPI`` attribute which was an internal
+PyCapsule object. The related private ``_PyUnicode_Name_CAPI`` structure was
+moved to the internal C API. Patch by Victor Stinner.
+
+..
+
+.. bpo: 42157
+.. date: 2020-10-26-19-08-07
+.. nonce: Bdpa04
+.. section: Library
+
+Convert the :mod:`unicodedata` extension module to the multiphase
+initialization API (:pep:`489`) and convert the ``unicodedata.UCD`` static
+type to a heap type. Patch by Mohamed Koubaa and Victor Stinner.
+
+..
+
+.. bpo: 42146
+.. date: 2020-10-25-19-25-02
+.. nonce: 6A8uvS
+.. section: Library
+
+Fix memory leak in :func:`subprocess.Popen` in case an uid (gid) specified
+in `user` (`group`, `extra_groups`) overflows `uid_t` (`gid_t`).
+
+..
+
+.. bpo: 42103
+.. date: 2020-10-23-19-20-14
+.. nonce: C5obK2
+.. section: Library
+
+:exc:`~plistlib.InvalidFileException` and :exc:`RecursionError` are now the
+only errors caused by loading malformed binary Plist file (previously
+ValueError and TypeError could be raised in some specific cases).
+
+..
+
+.. bpo: 41490
+.. date: 2020-10-23-08-54-47
+.. nonce: -Yk6OD
+.. section: Library
+
+In ``importlib.resources``, ``.path`` method is more aggressive about
+releasing handles to zipfile objects early, enabling use-cases like certifi
+to leave the context open but delete the underlying zip file.
+
+..
+
+.. bpo: 41052
+.. date: 2020-10-21-23-45-02
+.. nonce: 3N7J2J
+.. section: Library
+
+Pickling heap types implemented in C with protocols 0 and 1 raises now an
+error instead of producing incorrect data.
+
+..
+
+.. bpo: 42089
+.. date: 2020-10-19-16-53-19
+.. nonce: R1dthW
+.. section: Library
+
+In ``importlib.metadata.PackageNotFoundError``, make reference to the
+package metadata being missing to improve the user experience.
+
+..
+
+.. bpo: 41491
+.. date: 2020-10-19-14-02-09
+.. nonce: d1BUWH
+.. section: Library
+
+plistlib: fix parsing XML plists with hexadecimal integer values
+
+..
+
+.. bpo: 42065
+.. date: 2020-10-17-23-17-18
+.. nonce: 85BsRA
+.. section: Library
+
+Fix an incorrectly formatted error from :meth:`_codecs.charmap_decode` when
+called with a mapped value outside the range of valid Unicode code points.
+PR by Max Bernstein.
+
+..
+
+.. bpo: 41966
+.. date: 2020-10-17-07-52-53
+.. nonce: gwEQRZ
+.. section: Library
+
+Fix pickling pure Python :class:`datetime.time` subclasses. Patch by Dean
+Inwood.
+
+..
+
+.. bpo: 19270
+.. date: 2020-10-16-22-48-01
+.. nonce: jd_gkA
+.. section: Library
+
+:meth:`sched.scheduler.cancel()` will now cancel the correct event, if two
+events with same priority are scheduled for the same time. Patch by Bar
+Harel.
+
+..
+
+.. bpo: 28660
+.. date: 2020-10-16-16-08-04
+.. nonce: eX9pvD
+.. section: Library
+
+:func:`textwrap.wrap` now attempts to break long words after hyphens when
+``break_long_words=True`` and ``break_on_hyphens=True``.
+
+..
+
+.. bpo: 35823
+.. date: 2020-10-16-07-45-35
+.. nonce: SNQo56
+.. section: Library
+
+Use ``vfork()`` instead of ``fork()`` for :func:`subprocess.Popen` on Linux
+to improve performance in cases where it is deemed safe.
+
+..
+
+.. bpo: 42043
+.. date: 2020-10-15-17-20-37
+.. nonce: OS0p_v
+.. section: Library
+
+Add support for ``zipfile.Path`` inheritance. ``zipfile.Path.is_file()`` now
+returns False for non-existent names. ``zipfile.Path`` objects now expose a
+``.filename`` attribute and rely on that to resolve ``.name`` and
+``.parent`` when the ``Path`` object is at the root of the zipfile.
+
+..
+
+.. bpo: 42021
+.. date: 2020-10-12-21-21-24
+.. nonce: 8yv_8-
+.. section: Library
+
+Fix possible ref leaks in :mod:`sqlite3` module init.
+
+..
+
+.. bpo: 39101
+.. date: 2020-10-11-21-43-03
+.. nonce: -I49Pm
+.. section: Library
+
+Fixed tests using IsolatedAsyncioTestCase from hanging on BaseExceptions.
+
+..
+
+.. bpo: 41976
+.. date: 2020-10-08-18-22-28
+.. nonce: Svm0wb
+.. section: Library
+
+Fixed a bug that was causing :func:`ctypes.util.find_library` to return
+``None`` when triying to locate a library in an environment when gcc>=9 is
+available and ``ldconfig`` is not. Patch by Pablo Galindo
+
+..
+
+.. bpo: 41943
+.. date: 2020-10-07-18-36-03
+.. nonce: Pt55fT
+.. section: Library
+
+Fix bug where TestCase.assertLogs doesn't correctly filter messages by
+level.
+
+..
+
+.. bpo: 41923
+.. date: 2020-10-03-23-14-50
+.. nonce: Buonw9
+.. section: Library
+
+Implement :pep:`613`, introducing :data:`typing.TypeAlias` annotation.
+
+..
+
+.. bpo: 41905
+.. date: 2020-10-01-21-11-03
+.. nonce: _JpjR4
+.. section: Library
+
+A new function in abc: *update_abstractmethods* to re-calculate an abstract
+class's abstract status. In addition, *dataclass* has been changed to call
+this function.
+
+..
+
+.. bpo: 23706
+.. date: 2020-09-30-11-05-11
+.. nonce: dHTGjF
+.. section: Library
+
+Added *newline* parameter to ``pathlib.Path.write_text()``.
+
+..
+
+.. bpo: 41876
+.. date: 2020-09-29-16-23-54
+.. nonce: QicdDU
+.. section: Library
+
+Tkinter font class repr uses font name
+
+..
+
+.. bpo: 41831
+.. date: 2020-09-22-11-07-50
+.. nonce: k-Eop_
+.. section: Library
+
+``str()`` for the ``type`` attribute of the ``tkinter.Event`` object always
+returns now the numeric code returned by Tk instead of the name of the event
+type.
+
+..
+
+.. bpo: 39337
+.. date: 2020-09-13-02-02-18
+.. nonce: L3NXTt
+.. section: Library
+
+:func:`encodings.normalize_encoding` now ignores non-ASCII characters.
+
+..
+
+.. bpo: 41747
+.. date: 2020-09-08-23-41-29
+.. nonce: M6wLKv
+.. section: Library
+
+Ensure all methods that generated from :func:`dataclasses.dataclass` objects
+now have the proper ``__qualname__`` attribute referring to the class they
+belong to. Patch by Batuhan Taskaya.
+
+..
+
+.. bpo: 30681
+.. date: 2020-09-04-17-33-04
+.. nonce: LR4fnY
+.. section: Library
+
+Handle exceptions caused by unparseable date headers when using email
+"default" policy. Patch by Tim Bell, Georges Toth
+
+..
+
+.. bpo: 41586
+.. date: 2020-08-19-08-32-13
+.. nonce: IYjmjK
+.. section: Library
+
+Add F_SETPIPE_SZ and F_GETPIPE_SZ to fcntl module. Allow setting pipesize on
+subprocess.Popen.
+
+..
+
+.. bpo: 41229
+.. date: 2020-07-19-20-10-41
+.. nonce: p8rJa2
+.. section: Library
+
+Add ``contextlib.aclosing`` for deterministic cleanup of async generators
+which is analogous to ``contextlib.closing`` for non-async generators. Patch
+by Joongi Kim and John Belmonte.
+
+..
+
+.. bpo: 16396
+.. date: 2020-07-08-09-45-00
+.. nonce: z8o8Pn
+.. section: Library
+
+Allow ``ctypes.wintypes`` to be imported on non-Windows systems.
+
+..
+
+.. bpo: 4356
+.. date: 2020-05-31-10-48-47
+.. nonce: P8kXqp
+.. section: Library
+
+Add a key function to the bisect module.
+
+..
+
+.. bpo: 40592
+.. date: 2020-05-14-16-01-34
+.. nonce: Cmk855
+.. section: Library
+
+:func:`shutil.which` now ignores empty entries in :envvar:`PATHEXT` instead
+of treating them as a match.
+
+..
+
+.. bpo: 40492
+.. date: 2020-05-04-12-16-00
+.. nonce: ONk9Na
+.. section: Library
+
+Fix ``--outfile`` for :mod:`cProfile` / :mod:`profile` not writing the
+output file in the original directory when the program being profiled
+changes the working directory. PR by Anthony Sottile.
+
+..
+
+.. bpo: 34204
+.. date: 2020-04-21-17-18-33
+.. nonce: 9wXTtY
+.. section: Library
+
+The :mod:`shelve` module now uses :data:`pickle.DEFAULT_PROTOCOL` by default
+instead of :mod:`pickle` protocol ``3``.
+
+..
+
+.. bpo: 27321
+.. date: 2020-01-19-18-40-26
+.. nonce: 8e6SpM
+.. section: Library
+
+Fixed KeyError exception when flattening an email to a string attempts to
+replace a non-existent Content-Transfer-Encoding header.
+
+..
+
+.. bpo: 38976
+.. date: 2019-12-05-05-22-49
+.. nonce: 5MG7Uu
+.. section: Library
+
+The :mod:`http.cookiejar` module now supports the parsing of cookies in
+CURL-style cookiejar files through MozillaCookieJar on all platforms.
+Previously, such cookie entries would be silently ignored when loading a
+cookiejar with such entries.
+
+Additionally, the HTTP Only attribute is persisted in the object, and will
+be correctly written to file if the MozillaCookieJar object is subsequently
+dumped.
+
+..
+
+.. bpo: 42061
+.. date: 2020-10-28-21-39-45
+.. nonce: _x-0sg
+.. section: Documentation
+
+Document __format__ functionality for IP addresses.
+
+..
+
+.. bpo: 41910
+.. date: 2020-10-21-14-40-54
+.. nonce: CzBMit
+.. section: Documentation
+
+Document the default implementation of `object.__eq__`.
+
+..
+
+.. bpo: 42010
+.. date: 2020-10-21-02-21-14
+.. nonce: 76vJ0u
+.. section: Documentation
+
+Clarify that subscription expressions are also valid for certain
+:term:`classes <class>` and :term:`types <type>` in the standard library,
+and for user-defined classes and types if the classmethod
+:meth:`__class_getitem__` is provided.
+
+..
+
+.. bpo: 41805
+.. date: 2020-10-10-01-36-37
+.. nonce: l-CGv5
+.. section: Documentation
+
+Documented :ref:`generic alias type <types-genericalias>` and
+:data:`types.GenericAlias`. Also added an entry in glossary for
+:term:`generic types <generic type>`.
+
+..
+
+.. bpo: 39693
+.. date: 2020-02-24-09-02-05
+.. nonce: QXw0Fm
+.. section: Documentation
+
+Fix tarfile's extractfile documentation
+
+..
+
+.. bpo: 39416
+.. date: 2020-01-22-05-14-53
+.. nonce: uYjhEm
+.. section: Documentation
+
+Document some restrictions on the default string representations of numeric
+classes.
+
+..
+
+.. bpo: 41739
+.. date: 2020-10-12-00-11-47
+.. nonce: wSCc4K
+.. section: Tests
+
+Fix test_logging.test_race_between_set_target_and_flush(): the test now
+waits until all threads complete to avoid leaking running threads.
+
+..
+
+.. bpo: 41970
+.. date: 2020-10-08-14-00-17
+.. nonce: aZ8QFf
+.. section: Tests
+
+Avoid a test failure in ``test_lib2to3`` if the module has already imported
+at the time the test executes. Patch by Pablo Galindo.
+
+..
+
+.. bpo: 41944
+.. date: 2020-10-05-17-43-46
+.. nonce: rf1dYb
+.. section: Tests
+
+Tests for CJK codecs no longer call ``eval()`` on content received via HTTP.
+
+..
+
+.. bpo: 41306
+.. date: 2020-08-03-13-44-37
+.. nonce: VDoWXI
+.. section: Tests
+
+Fixed a failure in ``test_tk.test_widgets.ScaleTest`` happening when
+executing the test with Tk 8.6.10.
+
+..
+
+.. bpo: 38980
+.. date: 2020-10-21-18-31-54
+.. nonce: xz7BNd
+.. section: Build
+
+Add ``-fno-semantic-interposition`` to both the compile and link line when
+building with ``--enable-optimizations``. Patch by Victor Stinner and Pablo
+Galindo.
+
+..
+
+.. bpo: 38439
+.. date: 2020-10-20-13-19-42
+.. nonce: eMLi-t
+.. section: Windows
+
+Updates the icons for IDLE in the Windows Store package.
+
+..
+
+.. bpo: 38252
+.. date: 2020-10-18-18-43-45
+.. nonce: 7Nlepg
+.. section: Windows
+
+Use 8-byte step to detect ASCII sequence in 64-bit Windows build.
+
+..
+
+.. bpo: 39107
+.. date: 2020-09-24-23-09-40
+.. nonce: GbUZvD
+.. section: Windows
+
+Update Tcl and Tk to 8.6.10 in Windows installer.
+
+..
+
+.. bpo: 41557
+.. date: 2020-08-26-09-35-06
+.. nonce: vt00cQ
+.. section: Windows
+
+Update Windows installer to use SQLite 3.33.0.
+
+..
+
+.. bpo: 38324
+.. date: 2020-05-30-02-46-43
+.. nonce: 476M-5
+.. section: Windows
+
+Avoid Unicode errors when accessing certain locale data on Windows.
+
+..
+
+.. bpo: 41471
+.. date: 2020-10-19-12-25-19
+.. nonce: gwA7un
+.. section: macOS
+
+Ignore invalid prefix lengths in system proxy excludes.
+
+..
+
+.. bpo: 33987
+.. date: 2020-10-24-21-27-37
+.. nonce: fIh9JL
+.. section: IDLE
+
+Mostly finish using ttk widgets, mainly for editor, settings, and searches.
+Some patches by Mark Roseman.
+
+..
+
+.. bpo: 40511
+.. date: 2020-06-16-12-16-13
+.. nonce: XkihpM
+.. section: IDLE
+
+Typing opening and closing parentheses inside the parentheses of a function
+call will no longer cause unnecessary "flashing" off and on of an existing
+open call-tip, e.g. when typed in a string literal.
+
+..
+
+.. bpo: 38439
+.. date: 2020-04-22-09-37-40
+.. nonce: ieXL-c
+.. section: IDLE
+
+Add a 256×256 pixel IDLE icon to the Windows .ico file. Created by Andrew
+Clover. Remove the low-color gif variations from the .ico file.
+
+..
+
+.. bpo: 42157
+.. date: 2020-10-16-10-47-17
+.. nonce: e3BcPM
+.. section: C API
+
+The private ``_PyUnicode_Name_CAPI`` structure of the PyCapsule API
+``unicodedata.ucnhash_CAPI`` has been moved to the internal C API. Patch by
+Victor Stinner.
+
+..
+
+.. bpo: 42015
+.. date: 2020-10-12-20-13-58
+.. nonce: X4H2_V
+.. section: C API
+
+Fix potential crash in deallocating method objects when dynamically
+allocated `PyMethodDef`'s lifetime is managed through the ``self`` argument
+of a `PyCFunction`.
+
+..
+
+.. bpo: 40423
+.. date: 2020-10-11-19-17-44
+.. nonce: GsmgEj
+.. section: C API
+
+The :mod:`subprocess` module and ``os.closerange`` will now use the
+``close_range(low, high, flags)`` syscall when it is available for more
+efficient closing of ranges of descriptors.
+
+..
+
+.. bpo: 41845
+.. date: 2020-10-11-05-05-53
+.. nonce: ZFvuQM
+.. section: C API
+
+:c:func:`PyObject_GenericGetDict` is available again in the limited API when
+targeting 3.10 or later.
+
+..
+
+.. bpo: 40422
+.. date: 2020-10-10-14-05-24
+.. nonce: sh8IDY
+.. section: C API
+
+Add `_Py_closerange` function to provide performant closing of a range of
+file descriptors.
+
+..
+
+.. bpo: 41986
+.. date: 2020-10-09-22-50-46
+.. nonce: JUPE59
+.. section: C API
+
+:c:data:`Py_FileSystemDefaultEncodeErrors` and :c:data:`Py_UTF8Mode` are
+available again in limited API.
+
+..
+
+.. bpo: 41756
+.. date: 2020-09-28-14-31-07
+.. nonce: ZZ5wJG
+.. section: C API
+
+Add `PyIter_Send` function to allow sending value into
+generator/coroutine/iterator without raising StopIteration exception to
+signal return.
+
+..
+
+.. bpo: 41784
+.. date: 2020-09-14-10-17-00
+.. nonce: Yl4gI2
+.. section: C API
+
+Added ``PyUnicode_AsUTF8AndSize`` to the limited C API.
diff --git a/Misc/NEWS.d/3.10.0a3.rst b/Misc/NEWS.d/3.10.0a3.rst
new file mode 100644
index 0000000000..0b76367f94
--- /dev/null
+++ b/Misc/NEWS.d/3.10.0a3.rst
@@ -0,0 +1,1504 @@
+.. bpo: 40791
+.. date: 2020-05-28-06-06-47
+.. nonce: QGZClX
+.. release date: 2020-12-07
+.. section: Security
+
+Add ``volatile`` to the accumulator variable in ``hmac.compare_digest``,
+making constant-time-defeating optimizations less likely.
+
+..
+
+.. bpo: 42576
+.. date: 2020-12-05-22-34-47
+.. nonce: lEeEl7
+.. section: Core and Builtins
+
+``types.GenericAlias`` will now raise a ``TypeError`` when attempting to
+initialize with a keyword argument. Previously, this would cause the
+interpreter to crash if the interpreter was compiled with debug symbols.
+This does not affect interpreters compiled for release. Patch by Ken Jin.
+
+..
+
+.. bpo: 42536
+.. date: 2020-12-02-20-23-31
+.. nonce: Kx3ZOu
+.. section: Core and Builtins
+
+Several built-in and standard library types now ensure that their internal
+result tuples are always tracked by the :term:`garbage collector <garbage
+collection>`:
+
+- :meth:`collections.OrderedDict.items() <collections.OrderedDict>`
+
+- :meth:`dict.items`
+
+- :func:`enumerate`
+
+- :func:`functools.reduce`
+
+- :func:`itertools.combinations`
+
+- :func:`itertools.combinations_with_replacement`
+
+- :func:`itertools.permutations`
+
+- :func:`itertools.product`
+
+- :func:`itertools.zip_longest`
+
+- :func:`zip`
+
+Previously, they could have become untracked by a prior garbage collection.
+Patch by Brandt Bucher.
+
+..
+
+.. bpo: 42500
+.. date: 2020-11-30-14-27-29
+.. nonce: excVKU
+.. section: Core and Builtins
+
+Improve handling of exceptions near recursion limit. Converts a number of
+Fatal Errors in RecursionErrors.
+
+..
+
+.. bpo: 42246
+.. date: 2020-11-24-14-01-43
+.. nonce: c9k9hj
+.. section: Core and Builtins
+
+PEP 626: After a return, the f_lineno attribute of a frame is always the
+last line executed.
+
+..
+
+.. bpo: 42435
+.. date: 2020-11-22-14-34-55
+.. nonce: uwlB2W
+.. section: Core and Builtins
+
+Speed up comparison of bytes objects with non-bytes objects when option
+:option:`-b` is specified. Speed up comparison of bytarray objects with
+non-buffer object.
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-18-23-46-31
+.. nonce: GVOQ-m
+.. section: Core and Builtins
+
+Port the ``_warnings`` extension module to the multi-phase initialization
+API (:pep:`489`). Patch by Victor Stinner.
+
+..
+
+.. bpo: 41686
+.. date: 2020-11-17-16-25-50
+.. nonce: hX77kL
+.. section: Core and Builtins
+
+On Windows, the ``SIGINT`` event, ``_PyOS_SigintEvent()``, is now created
+even if Python is configured to not install signal handlers (if
+:c:member:`PyConfig.install_signal_handlers` equals to 0, or
+``Py_InitializeEx(0)``).
+
+..
+
+.. bpo: 42381
+.. date: 2020-11-16-23-45-56
+.. nonce: G4AWxL
+.. section: Core and Builtins
+
+Allow assignment expressions in set literals and set comprehensions as per
+PEP 572. Patch by Pablo Galindo.
+
+..
+
+.. bpo: 42202
+.. date: 2020-11-16-18-13-07
+.. nonce: ZxenYD
+.. section: Core and Builtins
+
+Change function parameters annotations internal representation to tuple of
+strings. Patch provided by Yurii Karabas.
+
+..
+
+.. bpo: 42374
+.. date: 2020-11-16-17-57-09
+.. nonce: t7np1E
+.. section: Core and Builtins
+
+Fix a regression introduced by the new parser, where an unparenthesized
+walrus operator was not allowed within generator expressions.
+
+..
+
+.. bpo: 42316
+.. date: 2020-11-16-17-30-03
+.. nonce: _DdmpQ
+.. section: Core and Builtins
+
+Allow an unparenthesized walrus in subscript indexes.
+
+..
+
+.. bpo: 42349
+.. date: 2020-11-13-17-25-44
+.. nonce: JdWxez
+.. section: Core and Builtins
+
+Make sure that the compiler front-end produces a well-formed control flow
+graph. Be be more aggressive in the compiler back-end, as it is now safe to
+do so.
+
+..
+
+.. bpo: 42296
+.. date: 2020-11-13-13-53-11
+.. nonce: DuGrLJ
+.. section: Core and Builtins
+
+On Windows, fix a regression in signal handling which prevented to interrupt
+a program using CTRL+C. The signal handler can be run in a thread different
+than the Python thread, in which case the test deciding if the thread can
+handle signals is wrong.
+
+..
+
+.. bpo: 42332
+.. date: 2020-11-12-23-16-14
+.. nonce: fEQIdk
+.. section: Core and Builtins
+
+:class:`types.GenericAlias` objects can now be the targets of weakrefs.
+
+..
+
+.. bpo: 42282
+.. date: 2020-11-07-21-02-05
+.. nonce: M1W4Wj
+.. section: Core and Builtins
+
+Optimise constant subexpressions that appear as part of named expressions
+(previously the AST optimiser did not descend into named expressions). Patch
+by Nick Coghlan.
+
+..
+
+.. bpo: 42266
+.. date: 2020-11-04-23-03-25
+.. nonce: G4hGDe
+.. section: Core and Builtins
+
+Fixed a bug with the LOAD_ATTR opcode cache that was not respecting
+monkey-patching a class-level attribute to make it a descriptor. Patch by
+Pablo Galindo.
+
+..
+
+.. bpo: 40077
+.. date: 2020-11-03-21-58-27
+.. nonce: a9qM1j
+.. section: Core and Builtins
+
+Convert :mod:`queue` to use heap types.
+
+..
+
+.. bpo: 42246
+.. date: 2020-11-02-15-48-17
+.. nonce: 3CNQEX
+.. section: Core and Builtins
+
+Improved accuracy of line tracing events and f_lineno attribute of Frame
+objects. See PEP 626 for details.
+
+..
+
+.. bpo: 40077
+.. date: 2020-11-02-14-39-48
+.. nonce: grY9TG
+.. section: Core and Builtins
+
+Convert :mod:`mmap` to use heap types.
+
+..
+
+.. bpo: 42233
+.. date: 2020-11-01-23-34-56
+.. nonce: zOSzja
+.. section: Core and Builtins
+
+Allow ``GenericAlias`` objects to use :ref:`union type expressions
+<types-union>`. This allows expressions like ``list[int] | dict[float,
+str]`` where previously a ``TypeError`` would have been thrown. This also
+fixes union type expressions not de-duplicating ``GenericAlias`` objects.
+(Contributed by Ken Jin in :issue:`42233`.)
+
+..
+
+.. bpo: 26131
+.. date: 2020-10-22-17-27-08
+.. nonce: B-Veg7
+.. section: Core and Builtins
+
+The import system triggers a `ImportWarning` when it falls back to using
+`load_module()`.
+
+..
+
+.. bpo: 5054
+.. date: 2020-12-04-03-51-12
+.. nonce: 53StYZ
+.. section: Library
+
+CGIHTTPRequestHandler.run_cgi() HTTP_ACCEPT improperly parsed. Replace the
+special purpose getallmatchingheaders with generic get_all method and add
+relevant tests.
+
+Original Patch by Martin Panter. Modified by Senthil Kumaran.
+
+..
+
+.. bpo: 42562
+.. date: 2020-12-03-22-42-03
+.. nonce: 2hPmhi
+.. section: Library
+
+Fix issue when dis failed to parse function that has no line numbers. Patch
+provided by Yurii Karabas.
+
+..
+
+.. bpo: 17735
+.. date: 2020-12-03-22-22-24
+.. nonce: Qsaaue
+.. section: Library
+
+:func:`inspect.findsource` now raises :exc:`OSError` instead of
+:exc:`IndexError` when :attr:`co_lineno` of a code object is greater than
+the file length. This can happen, for example, when a file is edited after
+it was imported. PR by Irit Katriel.
+
+..
+
+.. bpo: 42116
+.. date: 2020-12-03-15-42-32
+.. nonce: yIwroP
+.. section: Library
+
+Fix handling of trailing comments by :func:`inspect.getsource`.
+
+..
+
+.. bpo: 42532
+.. date: 2020-12-02-07-37-59
+.. nonce: ObNep_
+.. section: Library
+
+Remove unexpected call of ``__bool__`` when passing a ``spec_arg`` argument
+to a Mock.
+
+..
+
+.. bpo: 38200
+.. date: 2020-11-28-22-52-57
+.. nonce: DuWGlW
+.. section: Library
+
+Added itertools.pairwise()
+
+..
+
+.. bpo: 41818
+.. date: 2020-11-28-06-34-53
+.. nonce: mFSMc2
+.. section: Library
+
+Fix test_master_read() so that it succeeds on all platforms that either
+raise OSError or return b"" upon reading from master.
+
+..
+
+.. bpo: 42487
+.. date: 2020-11-28-04-31-20
+.. nonce: iqtC4L
+.. section: Library
+
+ChainMap.__iter__ no longer calls __getitem__ on underlying maps
+
+..
+
+.. bpo: 42482
+.. date: 2020-11-27-16-46-58
+.. nonce: EJC3sd
+.. section: Library
+
+:class:`~traceback.TracebackException` no longer holds a reference to the
+exception's traceback object. Consequently, instances of TracebackException
+for equivalent but non-equal exceptions now compare as equal.
+
+..
+
+.. bpo: 41818
+.. date: 2020-11-27-09-19-43
+.. nonce: KWYUbL
+.. section: Library
+
+Make test_openpty() avoid unexpected success due to number of rows and/or
+number of columns being == 0.
+
+..
+
+.. bpo: 42392
+.. date: 2020-11-26-12-40-16
+.. nonce: GbmdHE
+.. section: Library
+
+Remove loop parameter from ``asyncio.subprocess`` and ``asyncio.tasks``
+functions. Patch provided by Yurii Karabas.
+
+..
+
+.. bpo: 42392
+.. date: 2020-11-25-22-44-59
+.. nonce: T_DAEl
+.. section: Library
+
+Remove loop parameter from ``asyncio.open_connection`` and
+``asyncio.start_server`` functions. Patch provided by Yurii Karabas.
+
+..
+
+.. bpo: 28468
+.. date: 2020-11-24-13-18-05
+.. nonce: 8Gh2d4
+.. section: Library
+
+Add :func:`platform.freedesktop_os_release` function to parse
+freedesktop.org ``os-release`` files.
+
+..
+
+.. bpo: 42299
+.. date: 2020-11-23-23-42-08
+.. nonce: Fdn4Wf
+.. section: Library
+
+Removed the ``formatter`` module, which was deprecated in Python 3.4. It is
+somewhat obsolete, little used, and not tested. It was originally scheduled
+to be removed in Python 3.6, but such removals were delayed until after
+Python 2.7 EOL. Existing users should copy whatever classes they use into
+their code. Patch by Dong-hee Na and and Terry J. Reedy.
+
+..
+
+.. bpo: 26131
+.. date: 2020-11-22-12-30-26
+.. nonce: -HsFPG
+.. section: Library
+
+Deprecate zipimport.zipimporter.load_module() in favour of exec_module().
+
+..
+
+.. bpo: 41818
+.. date: 2020-11-20-14-44-07
+.. nonce: 33soAw
+.. section: Library
+
+Updated tests for the pty library. test_basic() has been changed to
+test_openpty(); this additionally checks if slave termios and slave winsize
+are being set properly by pty.openpty(). In order to add support for
+FreeBSD, NetBSD, OpenBSD, and Darwin, this also adds test_master_read(),
+which demonstrates that pty.spawn() should not depend on an OSError to exit
+from its copy loop.
+
+..
+
+.. bpo: 42392
+.. date: 2020-11-20-14-01-29
+.. nonce: -OUzvl
+.. section: Library
+
+Remove loop parameter from ``__init__`` in all ``asyncio.locks`` and
+``asyncio.Queue`` classes. Patch provided by Yurii Karabas.
+
+..
+
+.. bpo: 15450
+.. date: 2020-11-20-10-38-34
+.. nonce: E-y9PA
+.. section: Library
+
+Make :class:`filecmp.dircmp` respect subclassing. Now the
+:attr:`filecmp.dircmp.subdirs` behaves as expected when subclassing dircmp.
+
+..
+
+.. bpo: 42413
+.. date: 2020-11-19-20-27-51
+.. nonce: fjHrHx
+.. section: Library
+
+The exception :exc:`socket.timeout` is now an alias of :exc:`TimeoutError`.
+
+..
+
+.. bpo: 31904
+.. date: 2020-11-19-16-14-36
+.. nonce: 83kf9d
+.. section: Library
+
+Support signal module on VxWorks.
+
+..
+
+.. bpo: 42406
+.. date: 2020-11-19-10-44-41
+.. nonce: r9rNCj
+.. section: Library
+
+We fixed an issue in `pickle.whichmodule` in which importing
+`multiprocessing` could change the how pickle identifies which module an
+object belongs to, potentially breaking the unpickling of those objects.
+
+..
+
+.. bpo: 42403
+.. date: 2020-11-19-10-12-39
+.. nonce: t7q5AX
+.. section: Library
+
+Simplify the :mod:`importlib` external bootstrap code:
+``importlib._bootstrap_external`` now uses regular imports to import builtin
+modules. When it is imported, the builtin :func:`__import__()` function is
+already fully working and so can be used to import builtin modules like
+:mod:`sys`. Patch by Victor Stinner.
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-19-09-59-07
+.. nonce: 7cMypH
+.. section: Library
+
+Convert _sre module types to heap types (PEP 384). Patch by Erlend E.
+Aasland.
+
+..
+
+.. bpo: 42375
+.. date: 2020-11-19-04-13-53
+.. nonce: U8bp4s
+.. section: Library
+
+subprocess module update for DragonFlyBSD support.
+
+..
+
+.. bpo: 41713
+.. date: 2020-11-17-23-00-27
+.. nonce: -Us0tf
+.. section: Library
+
+Port the ``_signal`` extension module to the multi-phase initialization API
+(:pep:`489`). Patch by Victor Stinner and Mohamed Koubaa.
+
+..
+
+.. bpo: 37205
+.. date: 2020-11-16-15-08-12
+.. nonce: Wh5svI
+.. section: Library
+
+:func:`time.time()`, :func:`time.perf_counter()` and
+:func:`time.monotonic()` functions can no longer fail with a Python fatal
+error, instead raise a regular Python exception on failure.
+
+..
+
+.. bpo: 42328
+.. date: 2020-11-15-17-02-00
+.. nonce: bqpPlR
+.. section: Library
+
+Fixed :meth:`tkinter.ttk.Style.map`. The function accepts now the
+representation of the default state as empty sequence (as returned by
+``Style.map()``). The structure of the result is now the same on all
+platform and does not depend on the value of ``wantobjects``.
+
+..
+
+.. bpo: 42345
+.. date: 2020-11-15-15-23-34
+.. nonce: hiIR7x
+.. section: Library
+
+Fix various issues with ``typing.Literal`` parameter handling (flatten,
+deduplicate, use type to cache key). Patch provided by Yurii Karabas.
+
+..
+
+.. bpo: 37205
+.. date: 2020-11-14-14-34-32
+.. nonce: iDbHrw
+.. section: Library
+
+:func:`time.perf_counter()` on Windows and :func:`time.monotonic()` on macOS
+are now system-wide. Previously, they used an offset computed at startup to
+reduce the precision loss caused by the float type. Use
+:func:`time.perf_counter_ns()` and :func:`time.monotonic_ns()` added in
+Python 3.7 to avoid this precision loss.
+
+..
+
+.. bpo: 42318
+.. date: 2020-11-14-13-46-27
+.. nonce: wYAcBD
+.. section: Library
+
+Fixed support of non-BMP characters in :mod:`tkinter` on macOS.
+
+..
+
+.. bpo: 42350
+.. date: 2020-11-13-18-53-50
+.. nonce: rsql7V
+.. section: Library
+
+Fix the :class:`threading.Thread` class at fork: do nothing if the thread is
+already stopped (ex: fork called at Python exit). Previously, an error was
+logged in the child process.
+
+..
+
+.. bpo: 42333
+.. date: 2020-11-12-18-21-15
+.. nonce: J9vFmV
+.. section: Library
+
+Port _ssl extension module to heap types.
+
+..
+
+.. bpo: 42014
+.. date: 2020-11-10-15-40-56
+.. nonce: ShM37l
+.. section: Library
+
+The ``onerror`` callback from ``shutil.rmtree`` now receives correct
+function when ``os.open`` fails.
+
+..
+
+.. bpo: 42237
+.. date: 2020-11-10-14-27-49
+.. nonce: F363jO
+.. section: Library
+
+Fix `os.sendfile()` on illumos.
+
+..
+
+.. bpo: 42308
+.. date: 2020-11-10-12-09-13
+.. nonce: yaJHH9
+.. section: Library
+
+Add :data:`threading.__excepthook__` to allow retrieving the original value
+of :func:`threading.excepthook` in case it is set to a broken or a different
+value. Patch by Mario Corchero.
+
+..
+
+.. bpo: 42131
+.. date: 2020-11-06-18-20-47
+.. nonce: l2rjjG
+.. section: Library
+
+Implement PEP 451/spec methods on zipimport.zipimporter: find_spec(),
+create_module(), and exec_module().
+
+This also allows for the documented deprecation of find_loader(),
+find_module(), and load_module().
+
+..
+
+.. bpo: 41877
+.. date: 2020-11-05-16-00-03
+.. nonce: FHbngM
+.. section: Library
+
+Mock objects which are not unsafe will now raise an AttributeError if an
+attribute with the prefix asert, aseert, or assrt is accessed, in addition
+to this already happening for the prefixes assert or assret.
+
+..
+
+.. bpo: 42264
+.. date: 2020-11-05-13-32-41
+.. nonce: r4KYUU
+.. section: Library
+
+``sqlite3.OptimizedUnicode`` has been undocumented and obsolete since Python
+3.3, when it was made an alias to :class:`str`. It is now deprecated,
+scheduled for removal in Python 3.12.
+
+..
+
+.. bpo: 42251
+.. date: 2020-11-03-14-15-35
+.. nonce: 6TC32V
+.. section: Library
+
+Added :func:`threading.gettrace` and :func:`threading.getprofile` to
+retrieve the functions set by :func:`threading.settrace` and
+:func:`threading.setprofile` respectively. Patch by Mario Corchero.
+
+..
+
+.. bpo: 42249
+.. date: 2020-11-03-09-22-56
+.. nonce: vfNO2u
+.. section: Library
+
+Fixed writing binary Plist files larger than 4 GiB.
+
+..
+
+.. bpo: 42236
+.. date: 2020-11-02-23-05-17
+.. nonce: aJ6ZBR
+.. section: Library
+
+On Unix, the :func:`os.device_encoding` function now returns ``'UTF-8'``
+rather than the device encoding if the :ref:`Python UTF-8 Mode <utf8-mode>`
+is enabled.
+
+..
+
+.. bpo: 41754
+.. date: 2020-11-01-15-07-20
+.. nonce: DraSZh
+.. section: Library
+
+webbrowser: Ignore *NotADirectoryError* when calling ``xdg-settings``.
+
+..
+
+.. bpo: 42183
+.. date: 2020-10-29-11-17-35
+.. nonce: 50ZcIi
+.. section: Library
+
+Fix a stack overflow error for asyncio Task or Future repr().
+
+The overflow occurs under some circumstances when a Task or Future
+recursively returns itself.
+
+..
+
+.. bpo: 42140
+.. date: 2020-10-24-04-02-36
+.. nonce: miLqvb
+.. section: Library
+
+Improve asyncio.wait function to create the futures set just one time.
+
+..
+
+.. bpo: 42133
+.. date: 2020-10-23-15-47-47
+.. nonce: BzizYV
+.. section: Library
+
+Update various modules in the stdlib to fall back on `__spec__.loader` when
+`__loader__` isn't defined on a module.
+
+..
+
+.. bpo: 26131
+.. date: 2020-10-22-17-26-35
+.. nonce: CAsI3O
+.. section: Library
+
+The `load_module()` methods found in importlib now trigger a
+DeprecationWarning.
+
+..
+
+.. bpo: 39825
+.. date: 2020-10-20-08-28-26
+.. nonce: n6KnG0
+.. section: Library
+
+Windows: Change ``sysconfig.get_config_var('EXT_SUFFIX')`` to the expected
+full ``platform_tag.extension`` format. Previously it was hard-coded to
+``.pyd``, now it is compatible with ``distutils.sysconfig`` and will result
+in something like ``.cp38-win_amd64.pyd``. This brings windows into
+conformance with the other platforms.
+
+..
+
+.. bpo: 26389
+.. date: 2020-10-08-23-51-55
+.. nonce: uga44e
+.. section: Library
+
+The :func:`traceback.format_exception`,
+:func:`traceback.format_exception_only`, and
+:func:`traceback.print_exception` functions can now take an exception object
+as a positional-only argument.
+
+..
+
+.. bpo: 41889
+.. date: 2020-10-01-16-17-11
+.. nonce: qLkNh8
+.. section: Library
+
+Enum: fix regression involving inheriting a multiply-inherited enum
+
+..
+
+.. bpo: 41861
+.. date: 2020-10-01-15-44-52
+.. nonce: YTqJ7z
+.. section: Library
+
+Convert :mod:`sqlite3` to use heap types (PEP 384). Patch by Erlend E.
+Aasland.
+
+..
+
+.. bpo: 40624
+.. date: 2020-09-08-03-19-04
+.. nonce: 0-gYfx
+.. section: Library
+
+Added support for the XPath ``!=`` operator in xml.etree
+
+..
+
+.. bpo: 28850
+.. date: 2020-09-06-21-55-44
+.. nonce: HJNggD
+.. section: Library
+
+Fix :meth:`pprint.PrettyPrinter.format` overrides being ignored for contents
+of small containers. The :func:`pprint._safe_repr` function was removed.
+
+..
+
+.. bpo: 41625
+.. date: 2020-08-24-16-59-04
+.. nonce: Cc967V
+.. section: Library
+
+Expose the :c:func:`splice` as :func:`os.splice` in the :mod:`os` module.
+Patch by Pablo Galindo
+
+..
+
+.. bpo: 34215
+.. date: 2020-08-19-20-17-51
+.. nonce: _Cv8c-
+.. section: Library
+
+Clarify the error message for :exc:`asyncio.IncompleteReadError` when
+``expected`` is ``None``.
+
+..
+
+.. bpo: 41543
+.. date: 2020-08-14-00-39-04
+.. nonce: RpcRjb
+.. section: Library
+
+Add async context manager support for contextlib.nullcontext.
+
+..
+
+.. bpo: 21041
+.. date: 2020-08-10-15-06-55
+.. nonce: cYz1eL
+.. section: Library
+
+:attr:`pathlib.PurePath.parents` now supports negative indexing. Patch
+contributed by Yaroslav Pankovych.
+
+..
+
+.. bpo: 41332
+.. date: 2020-07-18-17-39-28
+.. nonce: QRGmA5
+.. section: Library
+
+Added missing connect_accepted_socket() method to
+``asyncio.AbstractEventLoop``.
+
+..
+
+.. bpo: 12800
+.. date: 2020-07-09-11-32-28
+.. nonce: fNgWwx
+.. section: Library
+
+Extracting a symlink from a tarball should succeed and overwrite the symlink
+if it already exists. The fix is to remove the existing file or symlink
+before extraction. Based on patch by Chris AtLee, Jeffrey Kintscher, and
+Senthil Kumaran.
+
+..
+
+.. bpo: 40968
+.. date: 2020-06-18-11-35-16
+.. nonce: R8Edbv
+.. section: Library
+
+:mod:`urllib.request` and :mod:`http.client` now send ``http/1.1`` ALPN
+extension during TLS handshake when no custom context is supplied.
+
+..
+
+.. bpo: 41001
+.. date: 2020-06-17-12-24-26
+.. nonce: 5mi7b0
+.. section: Library
+
+Add func:`os.eventfd` to provide a low level interface for Linux's event
+notification file descriptor.
+
+..
+
+.. bpo: 40816
+.. date: 2020-05-29-15-25-41
+.. nonce: w61Pob
+.. section: Library
+
+Add AsyncContextDecorator to contextlib to support async context manager as
+a decorator.
+
+..
+
+.. bpo: 40550
+.. date: 2020-05-08-21-30-54
+.. nonce: i7GWkb
+.. section: Library
+
+Fix time-of-check/time-of-action issue in subprocess.Popen.send_signal.
+
+..
+
+.. bpo: 39411
+.. date: 2020-01-21-16-38-25
+.. nonce: 9uHFqT
+.. section: Library
+
+Add an ``is_async`` identifier to :mod:`pyclbr`'s ``Function`` objects.
+Patch by Batuhan Taskaya
+
+..
+
+.. bpo: 35498
+.. date: 2018-12-14-13-29-17
+.. nonce: LEJHl7
+.. section: Library
+
+Add slice support to :attr:`pathlib.PurePath.parents`.
+
+..
+
+.. bpo: 42238
+.. date: 2020-11-24-22-54-49
+.. nonce: 62EOTu
+.. section: Documentation
+
+Tentative to deprecate ``make suspicious`` by first removing it from the CI
+and documentation builds, but keeping it around for manual uses.
+
+..
+
+.. bpo: 42153
+.. date: 2020-11-15-13-46-31
+.. nonce: KjBhx3
+.. section: Documentation
+
+Fix the URL for the IMAP protocol documents.
+
+..
+
+.. bpo: 41028
+.. date: 2020-06-18-23-37-03
+.. nonce: vM8bC8
+.. section: Documentation
+
+Language and version switchers, previously maintained in every cpython
+branches, are now handled by docsbuild-script.
+
+..
+
+.. bpo: 41473
+.. date: 2020-12-04-11-47-09
+.. nonce: W_updK
+.. section: Tests
+
+Reenable test_gdb on gdb 9.2 and newer:
+https://bugzilla.redhat.com/show_bug.cgi?id=1866884 bug is fixed in gdb
+10.1.
+
+..
+
+.. bpo: 42553
+.. date: 2020-12-03-13-32-44
+.. nonce: 2TRE2N
+.. section: Tests
+
+Fix ``test_asyncio.test_call_later()`` race condition: don't measure asyncio
+performance in the ``call_later()`` unit test. The test failed randomly on
+the CI.
+
+..
+
+.. bpo: 31904
+.. date: 2020-12-01-15-51-19
+.. nonce: iwetj4
+.. section: Tests
+
+Fix test_netrc on VxWorks: create temporary directories using temp_cwd().
+
+..
+
+.. bpo: 31904
+.. date: 2020-11-26-11-13-13
+.. nonce: ay4g89
+.. section: Tests
+
+skip test_getaddrinfo_ipv6_scopeid_symbolic and
+test_getnameinfo_ipv6_scopeid_symbolic on VxWorks
+
+..
+
+.. bpo: 31904
+.. date: 2020-11-25-17-00-53
+.. nonce: ue4hd9
+.. section: Tests
+
+skip test_test of test_mailcap on VxWorks
+
+..
+
+.. bpo: 31904
+.. date: 2020-11-24-17-26-41
+.. nonce: eug834
+.. section: Tests
+
+add shell requirement for test_pipes
+
+..
+
+.. bpo: 31904
+.. date: 2020-11-23-11-11-29
+.. nonce: V3sUZk
+.. section: Tests
+
+skip some tests related to fifo on VxWorks
+
+..
+
+.. bpo: 31904
+.. date: 2020-11-20-15-07-18
+.. nonce: EBJXjJ
+.. section: Tests
+
+Fix test_doctest.py failures for VxWorks.
+
+..
+
+.. bpo: 40754
+.. date: 2020-11-13-21-51-34
+.. nonce: Ekoxkg
+.. section: Tests
+
+Include ``_testinternalcapi`` module in Windows installer for test suite
+
+..
+
+.. bpo: 41561
+.. date: 2020-09-18-16-14-03
+.. nonce: uPnwrW
+.. section: Tests
+
+test_ssl: skip test_min_max_version_mismatch when TLS 1.0 is not available
+
+..
+
+.. bpo: 31904
+.. date: 2020-05-20-17-28-46
+.. nonce: yt83Ge
+.. section: Tests
+
+Fix os module failures for VxWorks RTOS.
+
+..
+
+.. bpo: 31904
+.. date: 2020-05-20-14-28-48
+.. nonce: yJik6k
+.. section: Tests
+
+Fix fifo test cases for VxWorks RTOS.
+
+..
+
+.. bpo: 31904
+.. date: 2020-11-19-17-01-50
+.. nonce: 894dk2
+.. section: Build
+
+remove libnet dependency from detect_socket() for VxWorks
+
+..
+
+.. bpo: 42398
+.. date: 2020-11-18-11-58-44
+.. nonce: Yt5wO8
+.. section: Build
+
+Fix a race condition in "make regen-all" when make -jN option is used to run
+jobs in parallel. The clinic.py script now only use atomic write to write
+files. Moveover, generated files are now left unchanged if the content does
+not change, to not change the file modification time.
+
+..
+
+.. bpo: 41617
+.. date: 2020-11-13-15-04-53
+.. nonce: 98_oaE
+.. section: Build
+
+Fix building ``pycore_bitutils.h`` internal header on old clang version
+without ``__builtin_bswap16()`` (ex: Xcode 4.6.3 on Mac OS X 10.7). Patch by
+Joshua Root and Victor Stinner.
+
+..
+
+.. bpo: 38823
+.. date: 2020-11-12-13-45-15
+.. nonce: C0z_Fe
+.. section: Build
+
+It is no longer possible to build the ``_ctypes`` extension module without
+:c:type:`wchar_t` type: remove ``CTYPES_UNICODE`` macro. Anyway, the
+:c:type:`wchar_t` type is required to build Python. Patch by Victor Stinner.
+
+..
+
+.. bpo: 42087
+.. date: 2020-10-19-15-41-05
+.. nonce: 2AhRFP
+.. section: Build
+
+Support was removed for AIX 5.3 and below. See :issue:`40680`.
+
+..
+
+.. bpo: 40998
+.. date: 2020-06-17-09-05-02
+.. nonce: sgqmg9
+.. section: Build
+
+Addressed three compiler warnings found by undefined behavior sanitizer
+(ubsan).
+
+..
+
+.. bpo: 42120
+.. date: 2020-11-16-22-41-02
+.. nonce: 9scgko
+.. section: Windows
+
+Remove macro definition of ``copysign`` (to ``_copysign``) in headers.
+
+..
+
+.. bpo: 38506
+.. date: 2020-11-15-23-01-14
+.. nonce: hhdnuP
+.. section: Windows
+
+The Windows launcher now properly handles Python 3.10 when listing installed
+Python versions.
+
+..
+
+.. bpo: 42504
+.. date: 2020-12-02-15-48-40
+.. nonce: RQmMOR
+.. section: macOS
+
+Fix build on macOS Big Sur when MACOSX_DEPLOYMENT_TARGET=11
+
+..
+
+.. bpo: 41116
+.. date: 2020-11-15-16-43-45
+.. nonce: oCkbrF
+.. section: macOS
+
+Ensure distutils.unixxcompiler.find_library_file can find system provided
+libraries on macOS 11.
+
+..
+
+.. bpo: 41100
+.. date: 2020-11-01-16-40-23
+.. nonce: BApztP
+.. section: macOS
+
+Add support for macOS 11 and Apple Silicon systems.
+
+It is now possible to build "Universal 2" binaries using
+"--enable-universalsdk --with-universal-archs=universal2".
+
+Binaries build on later macOS versions can be deployed back to older
+versions (tested up to macOS 10.9), when using the correct deployment
+target. This is tested using Xcode 11 and later.
+
+..
+
+.. bpo: 42232
+.. date: 2020-11-01-15-10-28
+.. nonce: 2zI1GN
+.. section: macOS
+
+Added Darwin specific madvise options to mmap module.
+
+..
+
+.. bpo: 38443
+.. date: 2020-10-23-10-26-53
+.. nonce: vu64tl
+.. section: macOS
+
+The ``--enable-universalsdk`` and ``--with-universal-archs`` options for the
+configure script now check that the specified architectures can be used.
+
+..
+
+.. bpo: 42508
+.. date: 2020-11-30-19-46-05
+.. nonce: fE7w4M
+.. section: IDLE
+
+Keep IDLE running on macOS. Remove obsolete workaround that prevented
+running files with shortcuts when using new universal2 installers built on
+macOS 11.
+
+..
+
+.. bpo: 42426
+.. date: 2020-11-21-17-21-21
+.. nonce: kNnPoC
+.. section: IDLE
+
+Fix reporting offset of the RE error in searchengine.
+
+..
+
+.. bpo: 42415
+.. date: 2020-11-20-01-30-27
+.. nonce: CyD-va
+.. section: IDLE
+
+Get docstrings for IDLE calltips more often by using inspect.getdoc.
+
+..
+
+.. bpo: 42212
+.. date: 2020-11-20-15-11-05
+.. nonce: sjzgOf
+.. section: Tools/Demos
+
+The smelly.py script now also checks the Python dynamic library and
+extension modules, not only the Python static library. Make also the script
+more verbose: explain what it does.
+
+..
+
+.. bpo: 36310
+.. date: 2020-05-03-01-30-46
+.. nonce: xDxxwY
+.. section: Tools/Demos
+
+Allow :file:`Tools/i18n/pygettext.py` to detect calls to ``gettext`` in
+f-strings.
+
+..
+
+.. bpo: 42423
+.. date: 2020-11-21-12-27-19
+.. nonce: ByJHhY
+.. section: C API
+
+The :c:func:`PyType_FromSpecWithBases` and
+:c:func:`PyType_FromModuleAndSpec` functions now accept a single class as
+the *bases* argument.
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-19-17-44-36
+.. nonce: qBZc3o
+.. section: C API
+
+Port :mod:`select` extension module to multiphase initialization
+(:pep:`489`).
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-19-16-54-16
+.. nonce: 9tVsZt
+.. section: C API
+
+Port _posixsubprocess extension module to multiphase initialization
+(:pep:`489`).
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-19-15-33-42
+.. nonce: 9tVsZt
+.. section: C API
+
+Port _posixshmem extension module to multiphase initialization (:pep:`489`)
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-19-12-06-43
+.. nonce: KEfZpn
+.. section: C API
+
+Port _struct extension module to multiphase initialization (:pep:`489`)
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-19-09-17-01
+.. nonce: 6F9o6L
+.. section: C API
+
+Port :mod:`spwd` extension module to multiphase initialization (:pep:`489`)
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-18-20-33-35
+.. nonce: B4ztSk
+.. section: C API
+
+Port :mod:`gc` extension module to multiphase initialization (:pep:`489`)
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-18-20-11-13
+.. nonce: fe3iRb
+.. section: C API
+
+Port _queue extension module to multiphase initialization (:pep:`489`)
+
+..
+
+.. bpo: 39573
+.. date: 2020-11-18-15-21-59
+.. nonce: VB3G2y
+.. section: C API
+
+Convert :c:func:`Py_TYPE` and :c:func:`Py_SIZE` back to macros to allow
+using them as an l-value. Many third party C extension modules rely on the
+ability of using Py_TYPE() and Py_SIZE() to set an object type and size:
+``Py_TYPE(obj) = type;`` and ``Py_SIZE(obj) = size;``.
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-18-10-52-38
+.. nonce: FrWAwJ
+.. section: C API
+
+Port :mod:`symtable` extension module to multiphase initialization
+(:pep:`489`)
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-18-09-46-35
+.. nonce: SH8OIT
+.. section: C API
+
+Port :mod:`grp` and :mod:`pwd` extension modules to multiphase
+initialization (:pep:`489`)
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-18-09-16-23
+.. nonce: gkoI7Y
+.. section: C API
+
+Port _random extension module to multiphase initialization (:pep:`489`)
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-18-08-45-36
+.. nonce: VLZfiY
+.. section: C API
+
+Port _hashlib extension module to multiphase initialization (:pep:`489`)
+
+..
+
+.. bpo: 41713
+.. date: 2020-11-17-15-39-10
+.. nonce: Rq99Vc
+.. section: C API
+
+Removed the undocumented ``PyOS_InitInterrupts()`` function. Initializing
+Python already implicitly installs signal handlers: see
+:c:member:`PyConfig.install_signal_handlers`. Patch by Victor Stinner.
+
+..
+
+.. bpo: 40170
+.. date: 2020-11-13-01-40-28
+.. nonce: uh8lEf
+.. section: C API
+
+The ``Py_TRASHCAN_BEGIN`` macro no longer accesses PyTypeObject attributes,
+but now can get the condition by calling the new private
+:c:func:`_PyTrash_cond()` function which hides implementation details.
+
+..
+
+.. bpo: 42260
+.. date: 2020-11-10-14-27-39
+.. nonce: -Br3Co
+.. section: C API
+
+:c:func:`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`,
+:c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome` and
+:c:func:`Py_GetProgramName` functions now return ``NULL`` if called before
+:c:func:`Py_Initialize` (before Python is initialized). Use the new
+:ref:`Python Initialization Configuration API <init-config>` to get the
+:ref:`Python Path Configuration. <init-path-config>`. Patch by Victor
+Stinner.
+
+..
+
+.. bpo: 42260
+.. date: 2020-11-05-18-02-07
+.. nonce: pAeaNR
+.. section: C API
+
+The :c:func:`PyConfig_Read` function now only parses
+:c:member:`PyConfig.argv` arguments once: :c:member:`PyConfig.parse_argv` is
+set to ``2`` after arguments are parsed. Since Python arguments are
+strippped from :c:member:`PyConfig.argv`, parsing arguments twice would
+parse the application options as Python options.
+
+..
+
+.. bpo: 42262
+.. date: 2020-11-04-17-22-36
+.. nonce: fCWzBb
+.. section: C API
+
+Added :c:func:`Py_NewRef` and :c:func:`Py_XNewRef` functions to increment
+the reference count of an object and return the object. Patch by Victor
+Stinner.
+
+..
+
+.. bpo: 42260
+.. date: 2020-11-04-16-31-55
+.. nonce: CmgHtF
+.. section: C API
+
+When :c:func:`Py_Initialize` is called twice, the second call now updates
+more :mod:`sys` attributes for the configuration, rather than only
+:data:`sys.argv`. Patch by Victor Stinner.
+
+..
+
+.. bpo: 41832
+.. date: 2020-11-03-19-47-06
+.. nonce: dL1VJJ
+.. section: C API
+
+The :c:func:`PyType_FromModuleAndSpec` function now accepts NULL ``tp_doc``
+slot.
+
+..
+
+.. bpo: 1635741
+.. date: 2020-11-03-11-52-27
+.. nonce: aDYJKB
+.. section: C API
+
+Added :c:func:`PyModule_AddObjectRef` function: similar to
+:c:func:`PyModule_AddObject` but don't steal a reference to the value on
+success. Patch by Victor Stinner.
+
+..
+
+.. bpo: 42171
+.. date: 2020-10-27-21-10-14
+.. nonce: S3FWTP
+.. section: C API
+
+The :c:data:`METH_FASTCALL` calling convention is added to the limited API.
+The functions :c:func:`PyModule_AddType`,
+:c:func:`PyType_FromModuleAndSpec`, :c:func:`PyType_GetModule` and
+:c:func:`PyType_GetModuleState` are added to the limited API on Windows.
+
+..
+
+.. bpo: 42085
+.. date: 2020-10-19-15-58-16
+.. nonce: NhEf3W
+.. section: C API
+
+Add dedicated entry to PyAsyncMethods for sending values
+
+..
+
+.. bpo: 41073
+.. date: 2020-07-08-21-01-49
+.. nonce: VqQZON
+.. section: C API
+
+:c:func:`PyType_GetSlot()` can now accept static types.
+
+..
+
+.. bpo: 30459
+.. date: 2020-05-06-23-54-57
+.. nonce: N9_Jai
+.. section: C API
+
+:c:func:`PyList_SET_ITEM`, :c:func:`PyTuple_SET_ITEM` and
+:c:func:`PyCell_SET` macros can no longer be used as l-value or r-value. For
+example, ``x = PyList_SET_ITEM(a, b, c)`` and ``PyList_SET_ITEM(a, b, c) =
+x`` now fail with a compiler error. It prevents bugs like ``if
+(PyList_SET_ITEM (a, b, c) < 0) ...`` test. Patch by Zackery Spytz and
+Victor Stinner.
diff --git a/Misc/NEWS.d/next/Build/2020-02-28-14-33-15.bpo-29076.Gtixi5.rst b/Misc/NEWS.d/next/Build/2020-02-28-14-33-15.bpo-29076.Gtixi5.rst
new file mode 100644
index 0000000000..b38beb0586
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2020-02-28-14-33-15.bpo-29076.Gtixi5.rst
@@ -0,0 +1 @@
+Add fish shell support to macOS installer.
diff --git a/Misc/NEWS.d/next/Build/2020-10-21-18-31-54.bpo-38980.xz7BNd.rst b/Misc/NEWS.d/next/Build/2020-10-21-18-31-54.bpo-38980.xz7BNd.rst
deleted file mode 100644
index c9d34cf12c..0000000000
--- a/Misc/NEWS.d/next/Build/2020-10-21-18-31-54.bpo-38980.xz7BNd.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Add ``-fno-semantic-interposition`` to both the compile and link line when
-building with ``--enable-optimizations``. Patch by Victor Stinner and Pablo
-Galindo.
diff --git a/Misc/NEWS.d/next/Build/2020-12-11-18-04-38.bpo-31904.j3j6d8.rst b/Misc/NEWS.d/next/Build/2020-12-11-18-04-38.bpo-31904.j3j6d8.rst
new file mode 100644
index 0000000000..d2da711448
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2020-12-11-18-04-38.bpo-31904.j3j6d8.rst
@@ -0,0 +1 @@
+Enable libpython3.so for VxWorks.
diff --git a/Misc/NEWS.d/next/Build/2020-12-13-14-43-10.bpo-42598.7ipr5H.rst b/Misc/NEWS.d/next/Build/2020-12-13-14-43-10.bpo-42598.7ipr5H.rst
new file mode 100644
index 0000000000..7dafc105c4
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2020-12-13-14-43-10.bpo-42598.7ipr5H.rst
@@ -0,0 +1,2 @@
+Fix implicit function declarations in configure which could have resulted in
+incorrect configuration checks. Patch contributed by Joshua Root.
diff --git a/Misc/NEWS.d/next/Build/2020-12-20-02-35-28.bpo-42604.gRd89w.rst b/Misc/NEWS.d/next/Build/2020-12-20-02-35-28.bpo-42604.gRd89w.rst
new file mode 100644
index 0000000000..caaada41cf
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2020-12-20-02-35-28.bpo-42604.gRd89w.rst
@@ -0,0 +1,4 @@
+Now all platforms use a value for the "EXT_SUFFIX" build variable derived
+from SOABI (for instance in freeBSD, "EXT_SUFFIX" is now ".cpython-310d.so"
+instead of ".so"). Previosuly only Linux, Mac and VxWorks were using a value
+for "EXT_SUFFIX" that included "SOABI".
diff --git a/Misc/NEWS.d/next/C API/2020-09-14-10-17-00.bpo-41784.Yl4gI2.rst b/Misc/NEWS.d/next/C API/2020-09-14-10-17-00.bpo-41784.Yl4gI2.rst
deleted file mode 100644
index f09e0879ad..0000000000
--- a/Misc/NEWS.d/next/C API/2020-09-14-10-17-00.bpo-41784.Yl4gI2.rst
+++ /dev/null
@@ -1 +0,0 @@
-Added ``PyUnicode_AsUTF8AndSize`` to the limited C API.
diff --git a/Misc/NEWS.d/next/C API/2020-09-28-14-31-07.bpo-41756.ZZ5wJG.rst b/Misc/NEWS.d/next/C API/2020-09-28-14-31-07.bpo-41756.ZZ5wJG.rst
deleted file mode 100644
index f7e27b4401..0000000000
--- a/Misc/NEWS.d/next/C API/2020-09-28-14-31-07.bpo-41756.ZZ5wJG.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Add `PyIter_Send` function to allow sending value into
-generator/coroutine/iterator without raising StopIteration exception to
-signal return.
diff --git a/Misc/NEWS.d/next/C API/2020-10-09-22-50-46.bpo-41986.JUPE59.rst b/Misc/NEWS.d/next/C API/2020-10-09-22-50-46.bpo-41986.JUPE59.rst
deleted file mode 100644
index d456ba66ba..0000000000
--- a/Misc/NEWS.d/next/C API/2020-10-09-22-50-46.bpo-41986.JUPE59.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-:c:data:`Py_FileSystemDefaultEncodeErrors` and :c:data:`Py_UTF8Mode` are
-available again in limited API.
diff --git a/Misc/NEWS.d/next/C API/2020-10-10-14-05-24.bpo-40422.sh8IDY.rst b/Misc/NEWS.d/next/C API/2020-10-10-14-05-24.bpo-40422.sh8IDY.rst
deleted file mode 100644
index 1b6d9e034b..0000000000
--- a/Misc/NEWS.d/next/C API/2020-10-10-14-05-24.bpo-40422.sh8IDY.rst
+++ /dev/null
@@ -1 +0,0 @@
-Add `_Py_closerange` function to provide performant closing of a range of file descriptors. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/C API/2020-10-11-05-05-53.bpo-41845.ZFvuQM.rst b/Misc/NEWS.d/next/C API/2020-10-11-05-05-53.bpo-41845.ZFvuQM.rst
deleted file mode 100644
index 31d3154c3c..0000000000
--- a/Misc/NEWS.d/next/C API/2020-10-11-05-05-53.bpo-41845.ZFvuQM.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-:c:func:`PyObject_GenericGetDict` is available again in the limited API
-when targeting 3.10 or later.
diff --git a/Misc/NEWS.d/next/C API/2020-10-11-19-17-44.bpo-40423.GsmgEj.rst b/Misc/NEWS.d/next/C API/2020-10-11-19-17-44.bpo-40423.GsmgEj.rst
deleted file mode 100644
index 44e571ebf8..0000000000
--- a/Misc/NEWS.d/next/C API/2020-10-11-19-17-44.bpo-40423.GsmgEj.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-The :mod:`subprocess` module and ``os.closerange`` will now use the
-``close_range(low, high, flags)`` syscall when it is available for more
-efficient closing of ranges of descriptors. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/C API/2020-10-12-20-13-58.bpo-42015.X4H2_V.rst b/Misc/NEWS.d/next/C API/2020-10-12-20-13-58.bpo-42015.X4H2_V.rst
deleted file mode 100644
index d77619f64b..0000000000
--- a/Misc/NEWS.d/next/C API/2020-10-12-20-13-58.bpo-42015.X4H2_V.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Fix potential crash in deallocating method objects when dynamically
-allocated `PyMethodDef`'s lifetime is managed through the ``self``
-argument of a `PyCFunction`.
diff --git a/Misc/NEWS.d/next/C API/2020-10-16-10-47-17.bpo-42157.e3BcPM.rst b/Misc/NEWS.d/next/C API/2020-10-16-10-47-17.bpo-42157.e3BcPM.rst
deleted file mode 100644
index 65a56188fa..0000000000
--- a/Misc/NEWS.d/next/C API/2020-10-16-10-47-17.bpo-42157.e3BcPM.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-The private ``_PyUnicode_Name_CAPI`` structure of the PyCapsule API
-``unicodedata.ucnhash_CAPI`` has been moved to the internal C API.
-Patch by Victor Stinner.
diff --git a/Misc/NEWS.d/next/C API/2020-10-21-18-43-06.bpo-42111.9pvtrc.rst b/Misc/NEWS.d/next/C API/2020-10-21-18-43-06.bpo-42111.9pvtrc.rst
new file mode 100644
index 0000000000..3fb718cc45
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2020-10-21-18-43-06.bpo-42111.9pvtrc.rst
@@ -0,0 +1,2 @@
+Update the ``xxlimited`` module to be a better example of how to use the
+limited C API.
diff --git a/Misc/NEWS.d/next/C API/2020-11-22-13-46-06.bpo-1635741.-fJLzA.rst b/Misc/NEWS.d/next/C API/2020-11-22-13-46-06.bpo-1635741.-fJLzA.rst
new file mode 100644
index 0000000000..da1e4cb9ef
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2020-11-22-13-46-06.bpo-1635741.-fJLzA.rst
@@ -0,0 +1 @@
+Port :mod:`resource` extension module to module state
diff --git a/Misc/NEWS.d/next/C API/2020-12-09-00-35-25.bpo-32381.Je08Ny.rst b/Misc/NEWS.d/next/C API/2020-12-09-00-35-25.bpo-32381.Je08Ny.rst
new file mode 100644
index 0000000000..ded75fa54a
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2020-12-09-00-35-25.bpo-32381.Je08Ny.rst
@@ -0,0 +1,3 @@
+Remove the private :c:func:`_Py_fopen` function which is no longer needed.
+Use :c:func:`_Py_wfopen` or :c:func:`_Py_fopen_obj` instead. Patch by Victor
+Stinner.
diff --git a/Misc/NEWS.d/next/C API/2020-12-10-10-43-03.bpo-42591.CXNY8G.rst b/Misc/NEWS.d/next/C API/2020-12-10-10-43-03.bpo-42591.CXNY8G.rst
new file mode 100644
index 0000000000..3519859f7b
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2020-12-10-10-43-03.bpo-42591.CXNY8G.rst
@@ -0,0 +1,3 @@
+Export the :c:func:`Py_FrozenMain` function: fix a Python 3.9.0 regression.
+Python 3.9 uses ``-fvisibility=hidden`` and the function was not exported
+explicitly and so not exported.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-05-13-18-50-27.bpo-39465.j7nl6A.rst b/Misc/NEWS.d/next/Core and Builtins/2020-05-13-18-50-27.bpo-39465.j7nl6A.rst
new file mode 100644
index 0000000000..c29b5e1757
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-05-13-18-50-27.bpo-39465.j7nl6A.rst
@@ -0,0 +1,3 @@
+Make :c:func:`_PyUnicode_FromId` function compatible with subinterpreters.
+Each interpreter now has an array of identifier objects (interned strings
+decoded from UTF-8). Patch by Victor Stinner.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-05-14-02-55-39.bpo-40521.dIlXsZ.rst b/Misc/NEWS.d/next/Core and Builtins/2020-05-14-02-55-39.bpo-40521.dIlXsZ.rst
new file mode 100644
index 0000000000..654757a5f9
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-05-14-02-55-39.bpo-40521.dIlXsZ.rst
@@ -0,0 +1,2 @@
+Make the Unicode dictionary of interned strings compatible with
+subinterpreters. Patch by Victor Stinner.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-05-27-16-08-16.bpo-38605.rcs2uK.rst b/Misc/NEWS.d/next/Core and Builtins/2020-05-27-16-08-16.bpo-38605.rcs2uK.rst
deleted file mode 100644
index cbfe6e2352..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-05-27-16-08-16.bpo-38605.rcs2uK.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Enable ``from __future__ import annotations`` (:pep:`563`) by default.
-The values found in :attr:`__annotations__` dicts are now strings, e.g.
-``{"x": "int"}`` instead of ``{"x": int}``.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-08-07-13-42-48.bpo-41435.qPWjJA.rst b/Misc/NEWS.d/next/Core and Builtins/2020-08-07-13-42-48.bpo-41435.qPWjJA.rst
deleted file mode 100644
index d2978f9b4e..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-08-07-13-42-48.bpo-41435.qPWjJA.rst
+++ /dev/null
@@ -1 +0,0 @@
-Add `sys._current_exceptions()` function to retrieve a dictionary mapping each thread's identifier to the topmost exception currently active in that thread at the time the function is called. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-01-22-44-23.bpo-41902.iLoMVF.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-01-22-44-23.bpo-41902.iLoMVF.rst
deleted file mode 100644
index 738ef5aec9..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-01-22-44-23.bpo-41902.iLoMVF.rst
+++ /dev/null
@@ -1 +0,0 @@
-Micro optimization for range.index if step is 1. Patch by Dong-hee Na.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-02-11-35-33.bpo-41894.ffmtOt.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-02-11-35-33.bpo-41894.ffmtOt.rst
deleted file mode 100644
index 571f5dae1a..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-02-11-35-33.bpo-41894.ffmtOt.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-When loading a native module and a load failure occurs, prevent a possible
-UnicodeDecodeError when not running in a UTF-8 locale by decoding the load
-error message using the current locale's encoding.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-02-13-32-05.bpo-41902.ZKTxzW.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-02-13-32-05.bpo-41902.ZKTxzW.rst
deleted file mode 100644
index b118a6a36f..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-02-13-32-05.bpo-41902.ZKTxzW.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Micro optimization when compute :c:member:`~PySequenceMethods.sq_item` and
-:c:member:`~PyMappingMethods.mp_subscript` of :class:`range`. Patch by
-Dong-hee Na.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-08-09-58-19.bpo-41974.8B-q8O.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-08-09-58-19.bpo-41974.8B-q8O.rst
deleted file mode 100644
index 034cfede84..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-08-09-58-19.bpo-41974.8B-q8O.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-Removed special methods ``__int__``, ``__float__``, ``__floordiv__``,
-``__mod__``, ``__divmod__``, ``__rfloordiv__``, ``__rmod__`` and
-``__rdivmod__`` of the :class:`complex` class. They always raised
-a :exc:`TypeError`.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-09-10-55-50.bpo-41979.ImXIk2.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-09-10-55-50.bpo-41979.ImXIk2.rst
deleted file mode 100644
index 3250309ca2..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-09-10-55-50.bpo-41979.ImXIk2.rst
+++ /dev/null
@@ -1 +0,0 @@
-Star-unpacking is now allowed for with item's targets in the PEG parser.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-10-13-53-52.bpo-41993.YMzixQ.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-10-13-53-52.bpo-41993.YMzixQ.rst
deleted file mode 100644
index 3669cf11ea..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-10-13-53-52.bpo-41993.YMzixQ.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fixed potential issues with removing not completely initialized module from
-``sys.modules`` when import fails.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-12-14-51-59.bpo-42008.ijWw2I.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-12-14-51-59.bpo-42008.ijWw2I.rst
new file mode 100644
index 0000000000..1b50a0ef3b
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-10-12-14-51-59.bpo-42008.ijWw2I.rst
@@ -0,0 +1 @@
+Fix _random.Random() seeding.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-14-16-19-43.bpo-41984.SEtKMr.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-14-16-19-43.bpo-41984.SEtKMr.rst
deleted file mode 100644
index e70d5dc2b8..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-14-16-19-43.bpo-41984.SEtKMr.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-The garbage collector now tracks all user-defined classes. Patch by Brandt
-Bucher.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-15-21-55-32.bpo-42030.PmU2CA.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-15-21-55-32.bpo-42030.PmU2CA.rst
deleted file mode 100644
index e8c691d809..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-15-21-55-32.bpo-42030.PmU2CA.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Support for the legacy AIX-specific shared library loading support has been
-removed. All versions of AIX since 4.3 have supported and defaulted to using
-the common Unix mechanism instead.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-20-04-24-07.bpo-42093.ooZZNh.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-20-04-24-07.bpo-42093.ooZZNh.rst
deleted file mode 100644
index 36a12c1c1c..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-20-04-24-07.bpo-42093.ooZZNh.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-The ``LOAD_ATTR`` instruction now uses new "per opcode cache" mechanism and
-it is about 36% faster now. Patch by Pablo Galindo and Yury Selivanov.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-21-14-40-54.bpo-41910.CzBMit.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-21-14-40-54.bpo-41910.CzBMit.rst
deleted file mode 100644
index a40e2519a6..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-21-14-40-54.bpo-41910.CzBMit.rst
+++ /dev/null
@@ -1 +0,0 @@
-Document the default implementation of `object.__eq__`.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-23-02-43-24.bpo-42123.64gJWC.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-23-02-43-24.bpo-42123.64gJWC.rst
deleted file mode 100644
index 6461efd76f..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-23-02-43-24.bpo-42123.64gJWC.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Run the parser two times. On the first run, disable all the rules that only
-generate better error messages to gain performance. If there's a parse
-failure, run the parser a second time with those enabled.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-25-21-14-18.bpo-42150.b70u_T.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-25-21-14-18.bpo-42150.b70u_T.rst
deleted file mode 100644
index 62fabb857a..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-25-21-14-18.bpo-42150.b70u_T.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fix possible buffer overflow in the new parser when checking for
-continuation lines. Patch by Pablo Galindo.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-27-18-32-49.bpo-41659.d4a-8o.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-27-18-32-49.bpo-41659.d4a-8o.rst
deleted file mode 100644
index 038749a7b1..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-27-18-32-49.bpo-41659.d4a-8o.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Fix a bug in the parser, where a curly brace following a `primary` didn't fail immediately.
-This led to invalid expressions like `a {b}` to throw a :exc:`SyntaxError` with a wrong offset,
-or invalid expressions ending with a curly brace like `a {` to not fail immediately in the REPL. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-27-21-34-05.bpo-42143.N6KXUO.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-27-21-34-05.bpo-42143.N6KXUO.rst
deleted file mode 100644
index 2b16e69da7..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-27-21-34-05.bpo-42143.N6KXUO.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fix handling of errors during creation of ``PyFunctionObject``, which resulted
-in operations on uninitialized memory. Patch by Yonatan Goldschmidt.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-29-12-49-08.bpo-41796.tkGdHq.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-29-12-49-08.bpo-41796.tkGdHq.rst
deleted file mode 100644
index b3ac08edd8..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-29-12-49-08.bpo-41796.tkGdHq.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-The :mod:`ast` module internal state is now per interpreter. Patch by Victor
-Stinner.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-30-13-11-01.bpo-42206.xxssR8.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-30-13-11-01.bpo-42206.xxssR8.rst
deleted file mode 100644
index b9eb135fec..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-30-13-11-01.bpo-42206.xxssR8.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Propagate and raise the errors caused by :c:func:`PyAST_Validate` in the
-parser.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-30-22-16-30.bpo-42214.lXskM_.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-30-22-16-30.bpo-42214.lXskM_.rst
deleted file mode 100644
index 3f85bbe839..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-30-22-16-30.bpo-42214.lXskM_.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fixed a possible crash in the PEG parser when checking for the '!=' token in
-the ``barry_as_flufl`` rule. Patch by Pablo Galindo.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-31-17-50-23.bpo-42218.Dp_Z3v.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-31-17-50-23.bpo-42218.Dp_Z3v.rst
deleted file mode 100644
index a38a310e4b..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-10-31-17-50-23.bpo-42218.Dp_Z3v.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Fixed a bug in the PEG parser that was causing crashes in debug mode. Now errors are checked
-in left-recursive rules to avoid cases where such errors do not get handled in time and appear
-as long-distance crashes in other places.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-11-01-21-21-38.bpo-42236.MPx-NK.rst b/Misc/NEWS.d/next/Core and Builtins/2020-11-01-21-21-38.bpo-42236.MPx-NK.rst
deleted file mode 100644
index 22e8c534ff..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-11-01-21-21-38.bpo-42236.MPx-NK.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-If the ``nl_langinfo(CODESET)`` function returns an empty string, Python now
-uses UTF-8 as the filesystem encoding. Patch by Victor Stinner.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-11-02-14-39-48.bpo-40077.grY9TG.rst b/Misc/NEWS.d/next/Core and Builtins/2020-11-02-14-39-48.bpo-40077.grY9TG.rst
deleted file mode 100644
index 48565a5a0d..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-11-02-14-39-48.bpo-40077.grY9TG.rst
+++ /dev/null
@@ -1 +0,0 @@
-Convert :mod:`mmap` to use heap types.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-11-20-00-57-47.bpo-42195.HeqcpS.rst b/Misc/NEWS.d/next/Core and Builtins/2020-11-20-00-57-47.bpo-42195.HeqcpS.rst
new file mode 100644
index 0000000000..87e8c0e89b
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-11-20-00-57-47.bpo-42195.HeqcpS.rst
@@ -0,0 +1,10 @@
+The ``__args__`` of the parameterized generics for :data:`typing.Callable`
+and :class:`collections.abc.Callable` are now consistent. The ``__args__``
+for :class:`collections.abc.Callable` are now flattened while
+:data:`typing.Callable`'s have not changed. To allow this change,
+:class:`types.GenericAlias` can now be subclassed and
+``collections.abc.Callable``'s ``__class_getitem__`` will now return a subclass
+of ``types.GenericAlias``. Tests for typing were also updated to not subclass
+things like ``Callable[..., T]`` as that is not a valid base class. Finally,
+both ``Callable``\ s no longer validate their ``argtypes``, in
+``Callable[[argtypes], resulttype]`` to prepare for :pep:`612`. Patch by Ken Jin.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-12-04-17-17-44.bpo-32381.NY5t2S.rst b/Misc/NEWS.d/next/Core and Builtins/2020-12-04-17-17-44.bpo-32381.NY5t2S.rst
new file mode 100644
index 0000000000..f4d84f9d84
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-12-04-17-17-44.bpo-32381.NY5t2S.rst
@@ -0,0 +1,3 @@
+Fix encoding name when running a ``.pyc`` file on Windows:
+:c:func:`PyRun_SimpleFileExFlags()` now uses the correct encoding to decode
+the filename.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-12-09-01-55-10.bpo-42639.5pI5HG.rst b/Misc/NEWS.d/next/Core and Builtins/2020-12-09-01-55-10.bpo-42639.5pI5HG.rst
new file mode 100644
index 0000000000..7999ee976f
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-12-09-01-55-10.bpo-42639.5pI5HG.rst
@@ -0,0 +1,3 @@
+Make the :mod:`atexit` module state per-interpreter. It is now safe have more
+than one :mod:`atexit` module instance.
+Patch by Dong-hee Na and Victor Stinner.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-12-10-17-06-52.bpo-42615.Je6Q-r.rst b/Misc/NEWS.d/next/Core and Builtins/2020-12-10-17-06-52.bpo-42615.Je6Q-r.rst
new file mode 100644
index 0000000000..2d919a8192
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-12-10-17-06-52.bpo-42615.Je6Q-r.rst
@@ -0,0 +1,2 @@
+Remove jump commands made redundant by the deletion of unreachable bytecode
+blocks
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-12-13-15-23-09.bpo-30858.-f9G4z.rst b/Misc/NEWS.d/next/Core and Builtins/2020-12-13-15-23-09.bpo-30858.-f9G4z.rst
new file mode 100644
index 0000000000..f2d06c3009
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-12-13-15-23-09.bpo-30858.-f9G4z.rst
@@ -0,0 +1,2 @@
+Improve error location in expressions that contain assignments. Patch by
+Pablo Galindo and Lysandros Nikolaou.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-12-15-18-43-43.bpo-32381.3tIofL.rst b/Misc/NEWS.d/next/Core and Builtins/2020-12-15-18-43-43.bpo-32381.3tIofL.rst
new file mode 100644
index 0000000000..fc8ea82fb0
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-12-15-18-43-43.bpo-32381.3tIofL.rst
@@ -0,0 +1,2 @@
+The coding cookie (ex: ``# coding: latin1``) is now ignored in the command
+passed to the :option:`-c` command line option. Patch by Victor Stinner.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-12-16-14-44-21.bpo-42246.RtIEY7.rst b/Misc/NEWS.d/next/Core and Builtins/2020-12-16-14-44-21.bpo-42246.RtIEY7.rst
new file mode 100644
index 0000000000..a3814b6419
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-12-16-14-44-21.bpo-42246.RtIEY7.rst
@@ -0,0 +1,3 @@
+Make sure that the ``f_lasti`` and ``f_lineno`` attributes of a frame are
+set correctly when an exception is raised or re-raised. Required for PEP
+626.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-12-22-20-30-11.bpo-42246.7BrPLg.rst b/Misc/NEWS.d/next/Core and Builtins/2020-12-22-20-30-11.bpo-42246.7BrPLg.rst
new file mode 100644
index 0000000000..33564f6b56
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-12-22-20-30-11.bpo-42246.7BrPLg.rst
@@ -0,0 +1 @@
+Jumps to jumps are not eliminated when it would break PEP 626.
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-12-25-23-30-58.bpo-42745.XsFoHS.rst b/Misc/NEWS.d/next/Core and Builtins/2020-12-25-23-30-58.bpo-42745.XsFoHS.rst
new file mode 100644
index 0000000000..fb7de9c215
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-12-25-23-30-58.bpo-42745.XsFoHS.rst
@@ -0,0 +1 @@
+Make the type attribute lookup cache per-interpreter. Patch by Victor Stinner.
diff --git a/Misc/NEWS.d/next/Documentation/2019-03-04-18-51-21.bpo-34398.YedUqW.rst b/Misc/NEWS.d/next/Documentation/2019-03-04-18-51-21.bpo-34398.YedUqW.rst
new file mode 100644
index 0000000000..4693cecdb7
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2019-03-04-18-51-21.bpo-34398.YedUqW.rst
@@ -0,0 +1,2 @@
+Prominently feature listings from the glossary in documentation search
+results. Patch by Ammar Askar.
diff --git a/Misc/NEWS.d/next/Documentation/2020-01-22-05-14-53.bpo-39416.uYjhEm.rst b/Misc/NEWS.d/next/Documentation/2020-01-22-05-14-53.bpo-39416.uYjhEm.rst
deleted file mode 100644
index 279a5f18ff..0000000000
--- a/Misc/NEWS.d/next/Documentation/2020-01-22-05-14-53.bpo-39416.uYjhEm.rst
+++ /dev/null
@@ -1 +0,0 @@
-Document some restrictions on the default string representations of numeric classes.
diff --git a/Misc/NEWS.d/next/Documentation/2020-02-24-09-02-05.bpo-39693.QXw0Fm.rst b/Misc/NEWS.d/next/Documentation/2020-02-24-09-02-05.bpo-39693.QXw0Fm.rst
deleted file mode 100644
index 86049c5368..0000000000
--- a/Misc/NEWS.d/next/Documentation/2020-02-24-09-02-05.bpo-39693.QXw0Fm.rst
+++ /dev/null
@@ -1 +0,0 @@
-Fix tarfile's extractfile documentation
diff --git a/Misc/NEWS.d/next/Documentation/2020-10-10-01-36-37.bpo-41805.l-CGv5.rst b/Misc/NEWS.d/next/Documentation/2020-10-10-01-36-37.bpo-41805.l-CGv5.rst
deleted file mode 100644
index 9c9134350a..0000000000
--- a/Misc/NEWS.d/next/Documentation/2020-10-10-01-36-37.bpo-41805.l-CGv5.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Documented :ref:`generic alias type <types-genericalias>` and
-:data:`types.GenericAlias`. Also added an entry in glossary for
-:term:`generic types <generic type>`.
diff --git a/Misc/NEWS.d/next/Documentation/2020-10-21-02-21-14.bpo-42010.76vJ0u.rst b/Misc/NEWS.d/next/Documentation/2020-10-21-02-21-14.bpo-42010.76vJ0u.rst
deleted file mode 100644
index 2a0cbf1075..0000000000
--- a/Misc/NEWS.d/next/Documentation/2020-10-21-02-21-14.bpo-42010.76vJ0u.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-Clarify that subscription expressions are also valid for certain
-:term:`classes <class>` and :term:`types <type>` in the standard library, and
-for user-defined classes and types if the classmethod
-:meth:`__class_getitem__` is provided.
diff --git a/Misc/NEWS.d/next/Documentation/2020-10-28-21-39-45.bpo-42061._x-0sg.rst b/Misc/NEWS.d/next/Documentation/2020-10-28-21-39-45.bpo-42061._x-0sg.rst
deleted file mode 100644
index b38bb84350..0000000000
--- a/Misc/NEWS.d/next/Documentation/2020-10-28-21-39-45.bpo-42061._x-0sg.rst
+++ /dev/null
@@ -1 +0,0 @@
-Document __format__ functionality for IP addresses. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Documentation/2020-12-16-21-06-16.bpo-17140.1leSEg.rst b/Misc/NEWS.d/next/Documentation/2020-12-16-21-06-16.bpo-17140.1leSEg.rst
new file mode 100644
index 0000000000..cb1fd23a56
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2020-12-16-21-06-16.bpo-17140.1leSEg.rst
@@ -0,0 +1 @@
+Add documentation for the :class:`multiprocessing.pool.ThreadPool` class.
diff --git a/Misc/NEWS.d/next/IDLE/2020-04-22-09-37-40.bpo-38439.ieXL-c.rst b/Misc/NEWS.d/next/IDLE/2020-04-22-09-37-40.bpo-38439.ieXL-c.rst
deleted file mode 100644
index d8d59015f2..0000000000
--- a/Misc/NEWS.d/next/IDLE/2020-04-22-09-37-40.bpo-38439.ieXL-c.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Add a 256×256 pixel IDLE icon to the Windows .ico file. Created by Andrew
-Clover. Remove the low-color gif variations from the .ico file.
diff --git a/Misc/NEWS.d/next/IDLE/2020-06-16-12-16-13.bpo-40511.XkihpM.rst b/Misc/NEWS.d/next/IDLE/2020-06-16-12-16-13.bpo-40511.XkihpM.rst
deleted file mode 100644
index cc96798138..0000000000
--- a/Misc/NEWS.d/next/IDLE/2020-06-16-12-16-13.bpo-40511.XkihpM.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Typing opening and closing parentheses inside the parentheses of a function
-call will no longer cause unnecessary "flashing" off and on of an existing
-open call-tip, e.g. when typed in a string literal.
diff --git a/Misc/NEWS.d/next/IDLE/2020-10-24-21-27-37.bpo-33987.fIh9JL.rst b/Misc/NEWS.d/next/IDLE/2020-10-24-21-27-37.bpo-33987.fIh9JL.rst
deleted file mode 100644
index 1e67edc03c..0000000000
--- a/Misc/NEWS.d/next/IDLE/2020-10-24-21-27-37.bpo-33987.fIh9JL.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Mostly finish using ttk widgets, mainly for editor, settings,
-and searches. Some patches by Mark Roseman.
-
diff --git a/Misc/NEWS.d/next/Library/2019-12-05-05-22-49.bpo-38976.5MG7Uu.rst b/Misc/NEWS.d/next/Library/2019-12-05-05-22-49.bpo-38976.5MG7Uu.rst
deleted file mode 100644
index 7a48943a6c..0000000000
--- a/Misc/NEWS.d/next/Library/2019-12-05-05-22-49.bpo-38976.5MG7Uu.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-The :mod:`http.cookiejar` module now supports the parsing of cookies in CURL-style cookiejar files through MozillaCookieJar
-on all platforms. Previously, such cookie entries would be silently ignored when loading a cookiejar with such entries.
-
-Additionally, the HTTP Only attribute is persisted in the object, and will be correctly written to file if the MozillaCookieJar object is subsequently dumped. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2020-01-19-18-40-26.bpo-27321.8e6SpM.rst b/Misc/NEWS.d/next/Library/2020-01-19-18-40-26.bpo-27321.8e6SpM.rst
deleted file mode 100644
index 28acf7f6ef..0000000000
--- a/Misc/NEWS.d/next/Library/2020-01-19-18-40-26.bpo-27321.8e6SpM.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fixed KeyError exception when flattening an email to a string attempts to
-replace a non-existent Content-Transfer-Encoding header.
diff --git a/Misc/NEWS.d/next/Library/2020-04-21-17-18-33.bpo-34204.9wXTtY.rst b/Misc/NEWS.d/next/Library/2020-04-21-17-18-33.bpo-34204.9wXTtY.rst
deleted file mode 100644
index bce6d39148..0000000000
--- a/Misc/NEWS.d/next/Library/2020-04-21-17-18-33.bpo-34204.9wXTtY.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-The :mod:`shelve` module now uses :data:`pickle.DEFAULT_PROTOCOL` by default
-instead of :mod:`pickle` protocol ``3``.
diff --git a/Misc/NEWS.d/next/Library/2020-05-04-12-16-00.bpo-40492.ONk9Na.rst b/Misc/NEWS.d/next/Library/2020-05-04-12-16-00.bpo-40492.ONk9Na.rst
deleted file mode 100644
index 86bc08c79e..0000000000
--- a/Misc/NEWS.d/next/Library/2020-05-04-12-16-00.bpo-40492.ONk9Na.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Fix ``--outfile`` for :mod:`cProfile` / :mod:`profile` not writing the output
-file in the original directory when the program being profiled changes the
-working directory. PR by Anthony Sottile.
diff --git a/Misc/NEWS.d/next/Library/2020-05-14-16-01-34.bpo-40592.Cmk855.rst b/Misc/NEWS.d/next/Library/2020-05-14-16-01-34.bpo-40592.Cmk855.rst
deleted file mode 100644
index 3211a1bc34..0000000000
--- a/Misc/NEWS.d/next/Library/2020-05-14-16-01-34.bpo-40592.Cmk855.rst
+++ /dev/null
@@ -1 +0,0 @@
-:func:`shutil.which` now ignores empty entries in :envvar:`PATHEXT` instead of treating them as a match.
diff --git a/Misc/NEWS.d/next/Library/2020-05-31-10-48-47.bpo-4356.P8kXqp.rst b/Misc/NEWS.d/next/Library/2020-05-31-10-48-47.bpo-4356.P8kXqp.rst
deleted file mode 100644
index f5211d8a76..0000000000
--- a/Misc/NEWS.d/next/Library/2020-05-31-10-48-47.bpo-4356.P8kXqp.rst
+++ /dev/null
@@ -1 +0,0 @@
-Add a key function to the bisect module.
diff --git a/Misc/NEWS.d/next/Library/2020-07-08-09-45-00.bpo-16936.z8o8Pn.rst b/Misc/NEWS.d/next/Library/2020-07-08-09-45-00.bpo-16936.z8o8Pn.rst
deleted file mode 100644
index c76db4eede..0000000000
--- a/Misc/NEWS.d/next/Library/2020-07-08-09-45-00.bpo-16936.z8o8Pn.rst
+++ /dev/null
@@ -1 +0,0 @@
-Allow ``ctypes.wintypes`` to be imported on non-Windows systems.
diff --git a/Misc/NEWS.d/next/Library/2020-07-13-19-43-11.bpo-40219.MUoJEP.rst b/Misc/NEWS.d/next/Library/2020-07-13-19-43-11.bpo-40219.MUoJEP.rst
new file mode 100644
index 0000000000..aedc5c49b4
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-07-13-19-43-11.bpo-40219.MUoJEP.rst
@@ -0,0 +1 @@
+Lowered :class:`tkinter.ttk.LabeledScale` dummy widget to prevent hiding part of the content label.
diff --git a/Misc/NEWS.d/next/Library/2020-07-19-20-10-41.bpo-41229.p8rJa2.rst b/Misc/NEWS.d/next/Library/2020-07-19-20-10-41.bpo-41229.p8rJa2.rst
deleted file mode 100644
index 926133221d..0000000000
--- a/Misc/NEWS.d/next/Library/2020-07-19-20-10-41.bpo-41229.p8rJa2.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Add ``contextlib.aclosing`` for deterministic cleanup of async generators
-which is analogous to ``contextlib.closing`` for non-async generators.
-Patch by Joongi Kim and John Belmonte.
diff --git a/Misc/NEWS.d/next/Library/2020-08-03-17-54-32.bpo-41462.ek38d_.rst b/Misc/NEWS.d/next/Library/2020-08-03-17-54-32.bpo-41462.ek38d_.rst
new file mode 100644
index 0000000000..ca5da1b17b
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-08-03-17-54-32.bpo-41462.ek38d_.rst
@@ -0,0 +1 @@
+Add :func:`os.set_blocking()` support for VxWorks RTOS.
diff --git a/Misc/NEWS.d/next/Library/2020-08-11-17-44-07.bpo-31904.cb13ea.rst b/Misc/NEWS.d/next/Library/2020-08-11-17-44-07.bpo-31904.cb13ea.rst
new file mode 100644
index 0000000000..a7164b7a5a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-08-11-17-44-07.bpo-31904.cb13ea.rst
@@ -0,0 +1 @@
+Fix site and sysconfig modules for VxWorks RTOS which has no home directories.
diff --git a/Misc/NEWS.d/next/Library/2020-08-19-08-32-13.bpo-41586.IYjmjK.rst b/Misc/NEWS.d/next/Library/2020-08-19-08-32-13.bpo-41586.IYjmjK.rst
deleted file mode 100644
index 40461679eb..0000000000
--- a/Misc/NEWS.d/next/Library/2020-08-19-08-32-13.bpo-41586.IYjmjK.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Add F_SETPIPE_SZ and F_GETPIPE_SZ to fcntl module. Allow setting pipesize on
-subprocess.Popen.
diff --git a/Misc/NEWS.d/next/Library/2020-09-04-17-33-04.bpo-30681.LR4fnY.rst b/Misc/NEWS.d/next/Library/2020-09-04-17-33-04.bpo-30681.LR4fnY.rst
deleted file mode 100644
index 83830e343d..0000000000
--- a/Misc/NEWS.d/next/Library/2020-09-04-17-33-04.bpo-30681.LR4fnY.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Handle exceptions caused by unparseable date headers when using email
-"default" policy. Patch by Tim Bell, Georges Toth
diff --git a/Misc/NEWS.d/next/Library/2020-09-08-23-41-29.bpo-41747.M6wLKv.rst b/Misc/NEWS.d/next/Library/2020-09-08-23-41-29.bpo-41747.M6wLKv.rst
deleted file mode 100644
index 0869462f5b..0000000000
--- a/Misc/NEWS.d/next/Library/2020-09-08-23-41-29.bpo-41747.M6wLKv.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Ensure all methods that generated from :func:`dataclasses.dataclass`
-objects now have the proper ``__qualname__`` attribute referring to
-the class they belong to. Patch by Batuhan Taskaya.
diff --git a/Misc/NEWS.d/next/Library/2020-09-11-16-07-00.bpo-24792.Z-ARra.rst b/Misc/NEWS.d/next/Library/2020-09-11-16-07-00.bpo-24792.Z-ARra.rst
new file mode 100644
index 0000000000..4f1f18a558
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-09-11-16-07-00.bpo-24792.Z-ARra.rst
@@ -0,0 +1 @@
+Fixed bug where :mod:`zipimporter` sometimes reports an incorrect cause of import errors. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2020-09-13-02-02-18.bpo-39337.L3NXTt.rst b/Misc/NEWS.d/next/Library/2020-09-13-02-02-18.bpo-39337.L3NXTt.rst
deleted file mode 100644
index c2b4dbe4d1..0000000000
--- a/Misc/NEWS.d/next/Library/2020-09-13-02-02-18.bpo-39337.L3NXTt.rst
+++ /dev/null
@@ -1 +0,0 @@
-:func:`encodings.normalize_encoding` now ignores non-ASCII characters.
diff --git a/Misc/NEWS.d/next/Library/2020-09-22-11-07-50.bpo-41831.k-Eop_.rst b/Misc/NEWS.d/next/Library/2020-09-22-11-07-50.bpo-41831.k-Eop_.rst
deleted file mode 100644
index 84a3f5253a..0000000000
--- a/Misc/NEWS.d/next/Library/2020-09-22-11-07-50.bpo-41831.k-Eop_.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-``str()`` for the ``type`` attribute of the ``tkinter.Event`` object always
-returns now the numeric code returned by Tk instead of the name of the event
-type.
diff --git a/Misc/NEWS.d/next/Library/2020-09-29-16-23-54.bpo-41876.QicdDU.rst b/Misc/NEWS.d/next/Library/2020-09-29-16-23-54.bpo-41876.QicdDU.rst
deleted file mode 100644
index d4f5f0a37b..0000000000
--- a/Misc/NEWS.d/next/Library/2020-09-29-16-23-54.bpo-41876.QicdDU.rst
+++ /dev/null
@@ -1 +0,0 @@
-Tkinter font class repr uses font name \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2020-09-30-11-05-11.bpo-23706.dHTGjF.rst b/Misc/NEWS.d/next/Library/2020-09-30-11-05-11.bpo-23706.dHTGjF.rst
deleted file mode 100644
index b9a69a55e6..0000000000
--- a/Misc/NEWS.d/next/Library/2020-09-30-11-05-11.bpo-23706.dHTGjF.rst
+++ /dev/null
@@ -1 +0,0 @@
-Added *newline* parameter to ``pathlib.Path.write_text()``.
diff --git a/Misc/NEWS.d/next/Library/2020-09-30-13-35-29.bpo-41891.pNAeYI.rst b/Misc/NEWS.d/next/Library/2020-09-30-13-35-29.bpo-41891.pNAeYI.rst
new file mode 100644
index 0000000000..75c2512780
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-09-30-13-35-29.bpo-41891.pNAeYI.rst
@@ -0,0 +1 @@
+Ensure asyncio.wait_for waits for task completion
diff --git a/Misc/NEWS.d/next/Library/2020-10-01-21-11-03.bpo-41905._JpjR4.rst b/Misc/NEWS.d/next/Library/2020-10-01-21-11-03.bpo-41905._JpjR4.rst
deleted file mode 100644
index 0d8c0ba6a6..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-01-21-11-03.bpo-41905._JpjR4.rst
+++ /dev/null
@@ -1 +0,0 @@
-A new function in abc: *update_abstractmethods* to re-calculate an abstract class's abstract status. In addition, *dataclass* has been changed to call this function. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2020-10-02-10-19-49.bpo-41907.wiIEsz.rst b/Misc/NEWS.d/next/Library/2020-10-02-10-19-49.bpo-41907.wiIEsz.rst
new file mode 100644
index 0000000000..2c7b70d589
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-10-02-10-19-49.bpo-41907.wiIEsz.rst
@@ -0,0 +1 @@
+fix ``format()`` behavior for ``IntFlag``
diff --git a/Misc/NEWS.d/next/Library/2020-10-03-23-14-50.bpo-41923.Buonw9.rst b/Misc/NEWS.d/next/Library/2020-10-03-23-14-50.bpo-41923.Buonw9.rst
deleted file mode 100644
index dd9a1f709f..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-03-23-14-50.bpo-41923.Buonw9.rst
+++ /dev/null
@@ -1 +0,0 @@
-Implement :pep:`613`, introducing :data:`typing.TypeAlias` annotation.
diff --git a/Misc/NEWS.d/next/Library/2020-10-06-23-59-20.bpo-41960.icQ7Xd.rst b/Misc/NEWS.d/next/Library/2020-10-06-23-59-20.bpo-41960.icQ7Xd.rst
new file mode 100644
index 0000000000..f7e71998da
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-10-06-23-59-20.bpo-41960.icQ7Xd.rst
@@ -0,0 +1,2 @@
+Add ``globalns`` and ``localns`` parameters to the :func:`inspect.signature`
+and :meth:`inspect.Signature.from_callable`.
diff --git a/Misc/NEWS.d/next/Library/2020-10-07-18-36-03.bpo-41943.Pt55fT.rst b/Misc/NEWS.d/next/Library/2020-10-07-18-36-03.bpo-41943.Pt55fT.rst
deleted file mode 100644
index 3a7874d25a..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-07-18-36-03.bpo-41943.Pt55fT.rst
+++ /dev/null
@@ -1 +0,0 @@
-Fix bug where TestCase.assertLogs doesn't correctly filter messages by level. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2020-10-08-18-22-28.bpo-41976.Svm0wb.rst b/Misc/NEWS.d/next/Library/2020-10-08-18-22-28.bpo-41976.Svm0wb.rst
deleted file mode 100644
index c8b3fc7718..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-08-18-22-28.bpo-41976.Svm0wb.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Fixed a bug that was causing :func:`ctypes.util.find_library` to return
-``None`` when triying to locate a library in an environment when gcc>=9 is
-available and ``ldconfig`` is not. Patch by Pablo Galindo
diff --git a/Misc/NEWS.d/next/Library/2020-10-11-21-43-03.bpo-39101.-I49Pm.rst b/Misc/NEWS.d/next/Library/2020-10-11-21-43-03.bpo-39101.-I49Pm.rst
deleted file mode 100644
index a571e8343c..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-11-21-43-03.bpo-39101.-I49Pm.rst
+++ /dev/null
@@ -1 +0,0 @@
-Fixed tests using IsolatedAsyncioTestCase from hanging on BaseExceptions. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2020-10-12-21-21-24.bpo-42021.8yv_8-.rst b/Misc/NEWS.d/next/Library/2020-10-12-21-21-24.bpo-42021.8yv_8-.rst
deleted file mode 100644
index 7d71e9a700..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-12-21-21-24.bpo-42021.8yv_8-.rst
+++ /dev/null
@@ -1 +0,0 @@
-Fix possible ref leaks in :mod:`sqlite3` module init.
diff --git a/Misc/NEWS.d/next/Library/2020-10-15-17-20-37.bpo-42043.OS0p_v.rst b/Misc/NEWS.d/next/Library/2020-10-15-17-20-37.bpo-42043.OS0p_v.rst
deleted file mode 100644
index b6b296956c..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-15-17-20-37.bpo-42043.OS0p_v.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-Add support for ``zipfile.Path`` inheritance. ``zipfile.Path.is_file()`` now
-returns False for non-existent names. ``zipfile.Path`` objects now expose a
-``.filename`` attribute and rely on that to resolve ``.name`` and
-``.parent`` when the ``Path`` object is at the root of the zipfile.
diff --git a/Misc/NEWS.d/next/Library/2020-10-16-07-45-35.bpo-35823.SNQo56.rst b/Misc/NEWS.d/next/Library/2020-10-16-07-45-35.bpo-35823.SNQo56.rst
deleted file mode 100644
index cd428d3696..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-16-07-45-35.bpo-35823.SNQo56.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Use ``vfork()`` instead of ``fork()`` for :func:`subprocess.Popen` on Linux
-to improve performance in cases where it is deemed safe.
diff --git a/Misc/NEWS.d/next/Library/2020-10-16-16-08-04.bpo-28660.eX9pvD.rst b/Misc/NEWS.d/next/Library/2020-10-16-16-08-04.bpo-28660.eX9pvD.rst
deleted file mode 100644
index d67993492f..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-16-16-08-04.bpo-28660.eX9pvD.rst
+++ /dev/null
@@ -1 +0,0 @@
-:func:`textwrap.wrap` now attempts to break long words after hyphens when ``break_long_words=True`` and ``break_on_hyphens=True``.
diff --git a/Misc/NEWS.d/next/Library/2020-10-16-22-48-01.bpo-19270.jd_gkA.rst b/Misc/NEWS.d/next/Library/2020-10-16-22-48-01.bpo-19270.jd_gkA.rst
deleted file mode 100644
index 6330a91a44..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-16-22-48-01.bpo-19270.jd_gkA.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-:meth:`sched.scheduler.cancel()` will now cancel the correct event, if two
-events with same priority are scheduled for the same time. Patch by Bar Harel.
diff --git a/Misc/NEWS.d/next/Library/2020-10-17-07-52-53.bpo-41966.gwEQRZ.rst b/Misc/NEWS.d/next/Library/2020-10-17-07-52-53.bpo-41966.gwEQRZ.rst
deleted file mode 100644
index 0e7fad4007..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-17-07-52-53.bpo-41966.gwEQRZ.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fix pickling pure Python :class:`datetime.time` subclasses. Patch by Dean
-Inwood.
diff --git a/Misc/NEWS.d/next/Library/2020-10-17-12-42-08.bpo-42059.ZGMZ3D.rst b/Misc/NEWS.d/next/Library/2020-10-17-12-42-08.bpo-42059.ZGMZ3D.rst
new file mode 100644
index 0000000000..3f18824fe6
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-10-17-12-42-08.bpo-42059.ZGMZ3D.rst
@@ -0,0 +1 @@
+:class:`typing.TypedDict` types created using the alternative call-style syntax now correctly respect the ``total`` keyword argument when setting their ``__required_keys__`` and ``__optional_keys__`` class attributes.
diff --git a/Misc/NEWS.d/next/Library/2020-10-17-23-17-18.bpo-42065.85BsRA.rst b/Misc/NEWS.d/next/Library/2020-10-17-23-17-18.bpo-42065.85BsRA.rst
deleted file mode 100644
index 83c86c0799..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-17-23-17-18.bpo-42065.85BsRA.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Fix an incorrectly formatted error from :meth:`_codecs.charmap_decode` when
-called with a mapped value outside the range of valid Unicode code points.
-PR by Max Bernstein.
diff --git a/Misc/NEWS.d/next/Library/2020-10-19-14-02-09.bpo-41491.d1BUWH.rst b/Misc/NEWS.d/next/Library/2020-10-19-14-02-09.bpo-41491.d1BUWH.rst
deleted file mode 100644
index 4f39c91b28..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-19-14-02-09.bpo-41491.d1BUWH.rst
+++ /dev/null
@@ -1 +0,0 @@
-plistlib: fix parsing XML plists with hexadecimal integer values
diff --git a/Misc/NEWS.d/next/Library/2020-10-19-16-53-19.bpo-42089.R1dthW.rst b/Misc/NEWS.d/next/Library/2020-10-19-16-53-19.bpo-42089.R1dthW.rst
deleted file mode 100644
index 3f3affd1a7..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-19-16-53-19.bpo-42089.R1dthW.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-In ``importlib.metadata.PackageNotFoundError``, make reference to the
-package metadata being missing to improve the user experience.
diff --git a/Misc/NEWS.d/next/Library/2020-10-20-23-28-55.bpo-1635741.Iyka3r.rst b/Misc/NEWS.d/next/Library/2020-10-20-23-28-55.bpo-1635741.Iyka3r.rst
new file mode 100644
index 0000000000..e14e9a12c2
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-10-20-23-28-55.bpo-1635741.Iyka3r.rst
@@ -0,0 +1 @@
+Port the _csv module to the multi-phase initialization API (:pep:`489`).
diff --git a/Misc/NEWS.d/next/Library/2020-10-21-23-45-02.bpo-41052.3N7J2J.rst b/Misc/NEWS.d/next/Library/2020-10-21-23-45-02.bpo-41052.3N7J2J.rst
deleted file mode 100644
index 528e90ed13..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-21-23-45-02.bpo-41052.3N7J2J.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Pickling heap types implemented in C with protocols 0 and 1 raises now an
-error instead of producing incorrect data.
diff --git a/Misc/NEWS.d/next/Library/2020-10-23-08-54-47.bpo-41490.-Yk6OD.rst b/Misc/NEWS.d/next/Library/2020-10-23-08-54-47.bpo-41490.-Yk6OD.rst
deleted file mode 100644
index 5ad6af3d14..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-23-08-54-47.bpo-41490.-Yk6OD.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-In ``importlib.resources``, ``.path`` method is more aggressive about
-releasing handles to zipfile objects early, enabling use-cases like certifi
-to leave the context open but delete the underlying zip file.
diff --git a/Misc/NEWS.d/next/Library/2020-10-23-19-20-14.bpo-42103.C5obK2.rst b/Misc/NEWS.d/next/Library/2020-10-23-19-20-14.bpo-42103.C5obK2.rst
deleted file mode 100644
index 4eb694c16a..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-23-19-20-14.bpo-42103.C5obK2.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-:exc:`~plistlib.InvalidFileException` and :exc:`RecursionError` are now
-the only errors caused by loading malformed binary Plist file (previously
-ValueError and TypeError could be raised in some specific cases).
diff --git a/Misc/NEWS.d/next/Library/2020-10-25-14-48-57.bpo-42090.Ubuc0j.rst b/Misc/NEWS.d/next/Library/2020-10-25-14-48-57.bpo-42090.Ubuc0j.rst
new file mode 100644
index 0000000000..72f6853b50
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-10-25-14-48-57.bpo-42090.Ubuc0j.rst
@@ -0,0 +1,2 @@
+``zipfile.Path.joinpath`` now accepts arbitrary arguments, same as
+``pathlib.Path.joinpath``.
diff --git a/Misc/NEWS.d/next/Library/2020-10-25-19-25-02.bpo-42146.6A8uvS.rst b/Misc/NEWS.d/next/Library/2020-10-25-19-25-02.bpo-42146.6A8uvS.rst
deleted file mode 100644
index 041809803d..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-25-19-25-02.bpo-42146.6A8uvS.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fix memory leak in :func:`subprocess.Popen` in case an uid (gid) specified in
-`user` (`group`, `extra_groups`) overflows `uid_t` (`gid_t`).
diff --git a/Misc/NEWS.d/next/Library/2020-10-26-19-08-07.bpo-42157.Bdpa04.rst b/Misc/NEWS.d/next/Library/2020-10-26-19-08-07.bpo-42157.Bdpa04.rst
deleted file mode 100644
index 68778906bb..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-26-19-08-07.bpo-42157.Bdpa04.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-Convert the :mod:`unicodedata` extension module to the multiphase
-initialization API (:pep:`489`) and convert the ``unicodedata.UCD``
-static type to a heap type.
-Patch by Mohamed Koubaa and Victor Stinner.
diff --git a/Misc/NEWS.d/next/Library/2020-10-26-23-29-16.bpo-42157.4wuwTe.rst b/Misc/NEWS.d/next/Library/2020-10-26-23-29-16.bpo-42157.4wuwTe.rst
deleted file mode 100644
index 39365677ec..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-26-23-29-16.bpo-42157.4wuwTe.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-Removed the ``unicodedata.ucnhash_CAPI`` attribute which was an internal
-PyCapsule object. The related private ``_PyUnicode_Name_CAPI`` structure was
-moved to the internal C API. Patch by Victor Stinner.
diff --git a/Misc/NEWS.d/next/Library/2020-10-31-01-16-49.bpo-26789.9BdNAt.rst b/Misc/NEWS.d/next/Library/2020-10-31-01-16-49.bpo-26789.9BdNAt.rst
deleted file mode 100644
index d8832401c9..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-31-01-16-49.bpo-26789.9BdNAt.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-The :class:`logging.FileHandler` class now keeps a reference to the builtin
-:func:`open` function to be able to open or reopen the file during Python
-finalization. Fix errors like: ``NameError: name 'open' is not defined``. Patch
-by Victor Stinner.
diff --git a/Misc/NEWS.d/next/Library/2020-10-31-13-28-36.bpo-29566.6aDbty.rst b/Misc/NEWS.d/next/Library/2020-10-31-13-28-36.bpo-29566.6aDbty.rst
deleted file mode 100644
index d54c714688..0000000000
--- a/Misc/NEWS.d/next/Library/2020-10-31-13-28-36.bpo-29566.6aDbty.rst
+++ /dev/null
@@ -1 +0,0 @@
-``binhex.binhex()`` consisently writes macOS 9 line endings.
diff --git a/Misc/NEWS.d/next/Library/2020-11-02-01-31-15.bpo-42233.YxRj-h.rst b/Misc/NEWS.d/next/Library/2020-11-02-01-31-15.bpo-42233.YxRj-h.rst
deleted file mode 100644
index aad4249fa1..0000000000
--- a/Misc/NEWS.d/next/Library/2020-11-02-01-31-15.bpo-42233.YxRj-h.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-The :func:`repr` of :mod:`typing` types containing
-:ref:`Generic Alias Types <types-genericalias>` previously did not show the
-parameterized types in the ``GenericAlias``. They have now been changed to do so.
diff --git a/Misc/NEWS.d/next/Library/2020-11-02-14-10-48.bpo-35455.Q1xTIo.rst b/Misc/NEWS.d/next/Library/2020-11-02-14-10-48.bpo-35455.Q1xTIo.rst
deleted file mode 100644
index e72c7d277a..0000000000
--- a/Misc/NEWS.d/next/Library/2020-11-02-14-10-48.bpo-35455.Q1xTIo.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-On Solaris, :func:`~time.thread_time` is now implemented with
-``gethrvtime()`` because ``clock_gettime(CLOCK_THREAD_CPUTIME_ID)`` is not
-always available. Patch by Jakub Kulik.
diff --git a/Misc/NEWS.d/next/Library/2020-11-20-19-00-27.bpo-34463.aJcm56.rst b/Misc/NEWS.d/next/Library/2020-11-20-19-00-27.bpo-34463.aJcm56.rst
new file mode 100644
index 0000000000..df18354823
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-11-20-19-00-27.bpo-34463.aJcm56.rst
@@ -0,0 +1 @@
+Fixed discrepancy between :mod:`traceback` and the interpreter in formatting of SyntaxError with lineno not set (:mod:`traceback` was changed to match interpreter).
diff --git a/Misc/NEWS.d/next/Library/2020-11-22-11-22-28.bpo-42388.LMgM6B.rst b/Misc/NEWS.d/next/Library/2020-11-22-11-22-28.bpo-42388.LMgM6B.rst
new file mode 100644
index 0000000000..1b19247e84
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-11-22-11-22-28.bpo-42388.LMgM6B.rst
@@ -0,0 +1,2 @@
+Fix subprocess.check_output(..., input=None) behavior when text=True to be
+consistent with that of the documentation and universal_newlines=True.
diff --git a/Misc/NEWS.d/next/Library/2020-11-27-18-09-59.bpo-31904.g8k43d.rst b/Misc/NEWS.d/next/Library/2020-11-27-18-09-59.bpo-31904.g8k43d.rst
new file mode 100644
index 0000000000..5a687d1eb3
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-11-27-18-09-59.bpo-31904.g8k43d.rst
@@ -0,0 +1,2 @@
+:func:`posixpath.expanduser` returns the input *path* unchanged if
+user home directory is None on VxWorks.
diff --git a/Misc/NEWS.d/next/Library/2020-12-06-12-00-00.bpo-42470.iqtC4L.rst b/Misc/NEWS.d/next/Library/2020-12-06-12-00-00.bpo-42470.iqtC4L.rst
new file mode 100644
index 0000000000..cd2edb65d7
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-06-12-00-00.bpo-42470.iqtC4L.rst
@@ -0,0 +1 @@
+:func:`random.sample` no longer warns on a sequence which is also a set.
diff --git a/Misc/NEWS.d/next/Library/2020-12-07-13-21-00.bpo-28964.UTQikc.rst b/Misc/NEWS.d/next/Library/2020-12-07-13-21-00.bpo-28964.UTQikc.rst
new file mode 100644
index 0000000000..b1be0de3b2
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-07-13-21-00.bpo-28964.UTQikc.rst
@@ -0,0 +1 @@
+:func:`ast.literal_eval` adds line number information (if available) in error message for malformed nodes. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2020-12-08-22-43-35.bpo-42678.ba9ktU.rst b/Misc/NEWS.d/next/Library/2020-12-08-22-43-35.bpo-42678.ba9ktU.rst
new file mode 100644
index 0000000000..4b2ced5c14
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-08-22-43-35.bpo-42678.ba9ktU.rst
@@ -0,0 +1 @@
+``Enum``: call ``__init_subclass__`` after members have been added
diff --git a/Misc/NEWS.d/next/Library/2020-12-09-10-59-16.bpo-42517.FKEVcZ.rst b/Misc/NEWS.d/next/Library/2020-12-09-10-59-16.bpo-42517.FKEVcZ.rst
new file mode 100644
index 0000000000..813139dfe5
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-09-10-59-16.bpo-42517.FKEVcZ.rst
@@ -0,0 +1,2 @@
+Enum: private names do not become members / do not generate errors -- they
+remain normal attributes
diff --git a/Misc/NEWS.d/next/Library/2020-12-09-14-15-48.bpo-34750.x8TASR.rst b/Misc/NEWS.d/next/Library/2020-12-09-14-15-48.bpo-34750.x8TASR.rst
new file mode 100644
index 0000000000..c98ba14797
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-09-14-15-48.bpo-34750.x8TASR.rst
@@ -0,0 +1 @@
+[Enum] `_EnumDict.update()` is now supported
diff --git a/Misc/NEWS.d/next/Library/2020-12-09-15-23-28.bpo-31904.g3k5k3.rst b/Misc/NEWS.d/next/Library/2020-12-09-15-23-28.bpo-31904.g3k5k3.rst
new file mode 100644
index 0000000000..7bca3ed845
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-09-15-23-28.bpo-31904.g3k5k3.rst
@@ -0,0 +1 @@
+Define THREAD_STACK_SIZE for VxWorks.
diff --git a/Misc/NEWS.d/next/Library/2020-12-09-19-45-32.bpo-42385.boGbjo.rst b/Misc/NEWS.d/next/Library/2020-12-09-19-45-32.bpo-42385.boGbjo.rst
new file mode 100644
index 0000000000..f95da859b0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-09-19-45-32.bpo-42385.boGbjo.rst
@@ -0,0 +1 @@
+StrEnum: fix _generate_next_value_ to return a str
diff --git a/Misc/NEWS.d/next/Library/2020-12-10-00-09-40.bpo-41559.1l4yjP.rst b/Misc/NEWS.d/next/Library/2020-12-10-00-09-40.bpo-41559.1l4yjP.rst
new file mode 100644
index 0000000000..539fdeccd1
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-10-00-09-40.bpo-41559.1l4yjP.rst
@@ -0,0 +1,2 @@
+Implemented :pep:`612`: added ``ParamSpec`` and ``Concatenate`` to
+:mod:`typing`. Patch by Ken Jin.
diff --git a/Misc/NEWS.d/next/Library/2020-12-10-09-24-44.bpo-41877.iJSCvM.rst b/Misc/NEWS.d/next/Library/2020-12-10-09-24-44.bpo-41877.iJSCvM.rst
new file mode 100644
index 0000000000..df43cc5d0c
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-10-09-24-44.bpo-41877.iJSCvM.rst
@@ -0,0 +1 @@
+AttributeError for suspected misspellings of assertions on mocks are now pointing out that the cause are misspelled assertions and also what to do if the misspelling is actually an intended attribute name. The unittest.mock document is also updated to reflect the current set of recognised misspellings. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2020-12-10-18-36-52.bpo-39717.sK2u0w.rst b/Misc/NEWS.d/next/Library/2020-12-10-18-36-52.bpo-39717.sK2u0w.rst
new file mode 100644
index 0000000000..6f3691f591
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-10-18-36-52.bpo-39717.sK2u0w.rst
@@ -0,0 +1 @@
+[tarfile] update nested exception raising to use ``from None`` or ``from e``
diff --git a/Misc/NEWS.d/next/Library/2020-12-10-19-49-52.bpo-41877.wiVlPc.rst b/Misc/NEWS.d/next/Library/2020-12-10-19-49-52.bpo-41877.wiVlPc.rst
new file mode 100644
index 0000000000..d42200ecd0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-10-19-49-52.bpo-41877.wiVlPc.rst
@@ -0,0 +1 @@
+A check is added against misspellings of autospect, auto_spec and set_spec being passed as arguments to patch, patch.object and create_autospec. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2020-12-14-08-23-57.bpo-36541.qdEtZv.rst b/Misc/NEWS.d/next/Library/2020-12-14-08-23-57.bpo-36541.qdEtZv.rst
new file mode 100644
index 0000000000..5678d8c595
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-14-08-23-57.bpo-36541.qdEtZv.rst
@@ -0,0 +1,2 @@
+Fixed lib2to3.pgen2 to be able to parse PEP-570 positional only argument
+syntax.
diff --git a/Misc/NEWS.d/next/Library/2020-12-14-22-31-22.bpo-42639.5Z3iWX.rst b/Misc/NEWS.d/next/Library/2020-12-14-22-31-22.bpo-42639.5Z3iWX.rst
new file mode 100644
index 0000000000..bdb2edd7ad
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-14-22-31-22.bpo-42639.5Z3iWX.rst
@@ -0,0 +1,3 @@
+At Python exit, if a callback registered with :func:`atexit.register` fails,
+its exception is now logged. Previously, only some exceptions were logged, and
+the last exception was always silently ignored.
diff --git a/Misc/NEWS.d/next/Library/2020-12-15-10-00-04.bpo-42644.XgLCNx.rst b/Misc/NEWS.d/next/Library/2020-12-15-10-00-04.bpo-42644.XgLCNx.rst
new file mode 100644
index 0000000000..ee4d111dc3
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-15-10-00-04.bpo-42644.XgLCNx.rst
@@ -0,0 +1,3 @@
+``logging.disable`` will now validate the types and value of its parameter. It
+also now accepts strings representing the levels (as does ``loging.setLevel``)
+instead of only the numerical values.
diff --git a/Misc/NEWS.d/next/Library/2020-12-15-15-14-29.bpo-42639.uJ3h8I.rst b/Misc/NEWS.d/next/Library/2020-12-15-15-14-29.bpo-42639.uJ3h8I.rst
new file mode 100644
index 0000000000..847c24112f
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-15-15-14-29.bpo-42639.uJ3h8I.rst
@@ -0,0 +1,3 @@
+:func:`atexit._run_exitfuncs` now logs callback exceptions using
+:data:`sys.unraisablehook`, rather than logging them directly into
+:data:`sys.stderr` and raise the last exception.
diff --git a/Misc/NEWS.d/next/Library/2020-12-15-17-51-27.bpo-42630.jf4jBl.rst b/Misc/NEWS.d/next/Library/2020-12-15-17-51-27.bpo-42630.jf4jBl.rst
new file mode 100644
index 0000000000..4b4a520931
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-15-17-51-27.bpo-42630.jf4jBl.rst
@@ -0,0 +1,4 @@
+:mod:`tkinter` functions and constructors which need a default root window
+raise now :exc:`RuntimeError` with descriptive message instead of obscure
+:exc:`AttributeError` or :exc:`NameError` if it is not created yet or cannot
+be created automatically.
diff --git a/Misc/NEWS.d/next/Library/2020-12-16-16-16-33.bpo-37961.jrESEq.rst b/Misc/NEWS.d/next/Library/2020-12-16-16-16-33.bpo-37961.jrESEq.rst
new file mode 100644
index 0000000000..5b363ad22d
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-16-16-16-33.bpo-37961.jrESEq.rst
@@ -0,0 +1 @@
+Fix crash in :func:`tracemalloc.Traceback.__repr__` (regressed in Python 3.9). \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Library/2020-12-16-23-28-52.bpo-1635741.Quy3zn.rst b/Misc/NEWS.d/next/Library/2020-12-16-23-28-52.bpo-1635741.Quy3zn.rst
new file mode 100644
index 0000000000..3412c204b0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-16-23-28-52.bpo-1635741.Quy3zn.rst
@@ -0,0 +1,2 @@
+Port the :mod:`_thread` extension module to the multiphase initialization
+API (:pep:`489`) and convert its static types to heap types.
diff --git a/Misc/NEWS.d/next/Library/2020-12-19-12-33-38.bpo-9694.CkKK9V.rst b/Misc/NEWS.d/next/Library/2020-12-19-12-33-38.bpo-9694.CkKK9V.rst
new file mode 100644
index 0000000000..723955270d
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-19-12-33-38.bpo-9694.CkKK9V.rst
@@ -0,0 +1,2 @@
+Argparse help no longer uses the confusing phrase, "optional arguments".
+It uses "options" instead.
diff --git a/Misc/NEWS.d/next/Library/2020-12-19-17-32-43.bpo-42685.kwZlwp.rst b/Misc/NEWS.d/next/Library/2020-12-19-17-32-43.bpo-42685.kwZlwp.rst
new file mode 100644
index 0000000000..068546a34c
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-19-17-32-43.bpo-42685.kwZlwp.rst
@@ -0,0 +1,4 @@
+Improved placing of simple query windows in Tkinter (such as
+:func:`tkinter.simpledialog.askinteger`). They are now centered at the
+center of the parent window if it is specified and shown, otherwise at the
+center of the screen.
diff --git a/Misc/NEWS.d/next/Library/2020-12-21-22-59-26.bpo-15303.zozVrq.rst b/Misc/NEWS.d/next/Library/2020-12-21-22-59-26.bpo-15303.zozVrq.rst
new file mode 100644
index 0000000000..5a7900aa90
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-21-22-59-26.bpo-15303.zozVrq.rst
@@ -0,0 +1 @@
+:mod:`tkinter` supports now widgets with boolean value False.
diff --git a/Misc/NEWS.d/next/Library/2020-12-21-23-34-57.bpo-35728.9m-azF.rst b/Misc/NEWS.d/next/Library/2020-12-21-23-34-57.bpo-35728.9m-azF.rst
new file mode 100644
index 0000000000..aa57e274ce
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-21-23-34-57.bpo-35728.9m-azF.rst
@@ -0,0 +1 @@
+Added a root parameter to :func:`tkinter.font.nametofont`.
diff --git a/Misc/NEWS.d/next/Library/2020-12-22-13-16-43.bpo-25246.GhhCTl.rst b/Misc/NEWS.d/next/Library/2020-12-22-13-16-43.bpo-25246.GhhCTl.rst
new file mode 100644
index 0000000000..258bb12ff8
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-22-13-16-43.bpo-25246.GhhCTl.rst
@@ -0,0 +1 @@
+Optimized :meth:`collections.deque.remove`.
diff --git a/Misc/NEWS.d/next/Library/2020-12-22-22-47-22.bpo-42721.I5Ai5L.rst b/Misc/NEWS.d/next/Library/2020-12-22-22-47-22.bpo-42721.I5Ai5L.rst
new file mode 100644
index 0000000000..58ab180d3b
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-22-22-47-22.bpo-42721.I5Ai5L.rst
@@ -0,0 +1,9 @@
+When simple query dialogs (:mod:`tkinter.simpledialog`), message boxes
+(:mod:`tkinter.messagebox`) or color choose dialog
+(:mod:`tkinter.colorchooser`) are created without arguments *master* and
+*parent*, and the default root window is not yet created, and
+:func:`~tkinter.NoDefaultRoot` was not called, a new temporal
+hidden root window will be created automatically. It will not be set as the
+default root window and will be destroyed right after closing the dialog
+window. It will help to use these simple dialog windows in programs which
+do not need other GUI.
diff --git a/Misc/NEWS.d/next/Library/2020-12-23-15-16-12.bpo-38308.lB4Sv0.rst b/Misc/NEWS.d/next/Library/2020-12-23-15-16-12.bpo-38308.lB4Sv0.rst
new file mode 100644
index 0000000000..cf3807d9dc
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-23-15-16-12.bpo-38308.lB4Sv0.rst
@@ -0,0 +1 @@
+Add optional *weights* to *statistics.harmonic_mean()*.
diff --git a/Misc/NEWS.d/next/Library/2020-12-23-19-43-06.bpo-42727.WH3ODh.rst b/Misc/NEWS.d/next/Library/2020-12-23-19-43-06.bpo-42727.WH3ODh.rst
new file mode 100644
index 0000000000..c2ef8eecb8
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-23-19-43-06.bpo-42727.WH3ODh.rst
@@ -0,0 +1,2 @@
+``EnumMeta.__prepare__`` now accepts ``**kwds`` to properly support
+``__init_subclass__``
diff --git a/Misc/NEWS.d/next/Security/2020-10-19-10-56-27.bpo-42051.EU_B7u.rst b/Misc/NEWS.d/next/Security/2020-10-19-10-56-27.bpo-42051.EU_B7u.rst
deleted file mode 100644
index e865ed12a0..0000000000
--- a/Misc/NEWS.d/next/Security/2020-10-19-10-56-27.bpo-42051.EU_B7u.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-The :mod:`plistlib` module no longer accepts entity declarations in XML
-plist files to avoid XML vulnerabilities. This should not affect users as
-entity declarations are not used in regular plist files.
diff --git a/Misc/NEWS.d/next/Security/2020-10-23-19-19-30.bpo-42103.cILT66.rst b/Misc/NEWS.d/next/Security/2020-10-23-19-19-30.bpo-42103.cILT66.rst
deleted file mode 100644
index 15d7b6549e..0000000000
--- a/Misc/NEWS.d/next/Security/2020-10-23-19-19-30.bpo-42103.cILT66.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Prevented potential DoS attack via CPU and RAM exhaustion when processing
-malformed Apple Property List files in binary format.
diff --git a/Misc/NEWS.d/next/Tests/2020-07-30-14-08-58.bpo-41439.yhteoi.rst b/Misc/NEWS.d/next/Tests/2020-07-30-14-08-58.bpo-41439.yhteoi.rst
new file mode 100644
index 0000000000..0451503a52
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2020-07-30-14-08-58.bpo-41439.yhteoi.rst
@@ -0,0 +1 @@
+Port test_ssl and test_uuid to VxWorks RTOS.
diff --git a/Misc/NEWS.d/next/Tests/2020-07-30-18-06-15.bpo-31904.y3d8dk.rst b/Misc/NEWS.d/next/Tests/2020-07-30-18-06-15.bpo-31904.y3d8dk.rst
new file mode 100644
index 0000000000..fa2974963b
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2020-07-30-18-06-15.bpo-31904.y3d8dk.rst
@@ -0,0 +1 @@
+Disable os.popen and impacted tests on VxWorks
diff --git a/Misc/NEWS.d/next/Tests/2020-07-30-18-43-05.bpo-41443.834gyg.rst b/Misc/NEWS.d/next/Tests/2020-07-30-18-43-05.bpo-41443.834gyg.rst
new file mode 100644
index 0000000000..439f3e3647
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2020-07-30-18-43-05.bpo-41443.834gyg.rst
@@ -0,0 +1 @@
+Add more attribute checking in test_posix.py
diff --git a/Misc/NEWS.d/next/Tests/2020-08-03-13-44-37.bpo-41306.VDoWXI.rst b/Misc/NEWS.d/next/Tests/2020-08-03-13-44-37.bpo-41306.VDoWXI.rst
deleted file mode 100644
index 5e9ba2d8a2..0000000000
--- a/Misc/NEWS.d/next/Tests/2020-08-03-13-44-37.bpo-41306.VDoWXI.rst
+++ /dev/null
@@ -1 +0,0 @@
-Fixed a failure in ``test_tk.test_widgets.ScaleTest`` happening when executing the test with Tk 8.6.10.
diff --git a/Misc/NEWS.d/next/Tests/2020-10-05-17-43-46.bpo-41944.rf1dYb.rst b/Misc/NEWS.d/next/Tests/2020-10-05-17-43-46.bpo-41944.rf1dYb.rst
deleted file mode 100644
index 4f9782f1c8..0000000000
--- a/Misc/NEWS.d/next/Tests/2020-10-05-17-43-46.bpo-41944.rf1dYb.rst
+++ /dev/null
@@ -1 +0,0 @@
-Tests for CJK codecs no longer call ``eval()`` on content received via HTTP.
diff --git a/Misc/NEWS.d/next/Tests/2020-10-08-14-00-17.bpo-41970.aZ8QFf.rst b/Misc/NEWS.d/next/Tests/2020-10-08-14-00-17.bpo-41970.aZ8QFf.rst
deleted file mode 100644
index 4cdca197fb..0000000000
--- a/Misc/NEWS.d/next/Tests/2020-10-08-14-00-17.bpo-41970.aZ8QFf.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Avoid a test failure in ``test_lib2to3`` if the module has already imported
-at the time the test executes. Patch by Pablo Galindo.
diff --git a/Misc/NEWS.d/next/Tests/2020-10-12-00-11-47.bpo-41739.wSCc4K.rst b/Misc/NEWS.d/next/Tests/2020-10-12-00-11-47.bpo-41739.wSCc4K.rst
deleted file mode 100644
index 7aee2b9444..0000000000
--- a/Misc/NEWS.d/next/Tests/2020-10-12-00-11-47.bpo-41739.wSCc4K.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fix test_logging.test_race_between_set_target_and_flush(): the test now
-waits until all threads complete to avoid leaking running threads.
diff --git a/Misc/NEWS.d/next/Tests/2020-10-29-21-26-46.bpo-42199.KksGCV.rst b/Misc/NEWS.d/next/Tests/2020-10-29-21-26-46.bpo-42199.KksGCV.rst
new file mode 100644
index 0000000000..4426f33636
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2020-10-29-21-26-46.bpo-42199.KksGCV.rst
@@ -0,0 +1 @@
+Fix bytecode helper assertNotInBytecode. \ No newline at end of file
diff --git a/Misc/NEWS.d/next/Tests/2020-12-09-15-23-28.bpo-31904.ghj38d.rst b/Misc/NEWS.d/next/Tests/2020-12-09-15-23-28.bpo-31904.ghj38d.rst
new file mode 100644
index 0000000000..654562bf40
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2020-12-09-15-23-28.bpo-31904.ghj38d.rst
@@ -0,0 +1 @@
+Skip some tests in _test_all_chown_common() on VxWorks.
diff --git a/Misc/NEWS.d/next/Tests/2020-12-15-17-38-04.bpo-42641.uzwlF_.rst b/Misc/NEWS.d/next/Tests/2020-12-15-17-38-04.bpo-42641.uzwlF_.rst
new file mode 100644
index 0000000000..bf890b73ee
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2020-12-15-17-38-04.bpo-42641.uzwlF_.rst
@@ -0,0 +1,2 @@
+Enhance ``test_select.test_select()``: it now takes 500 ms rather than 10
+seconds. Use Python rather than a shell to make the test more portable.
diff --git a/Misc/NEWS.d/next/Tests/2020-12-17-15-42-44.bpo-31904.d8g3l0d5.rst b/Misc/NEWS.d/next/Tests/2020-12-17-15-42-44.bpo-31904.d8g3l0d5.rst
new file mode 100644
index 0000000000..d74e466685
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2020-12-17-15-42-44.bpo-31904.d8g3l0d5.rst
@@ -0,0 +1 @@
+Skip some asyncio tests on VxWorks.
diff --git a/Misc/NEWS.d/next/Tools-Demos/2020-12-16-09-10-32.bpo-42613.J-jnm5.rst b/Misc/NEWS.d/next/Tools-Demos/2020-12-16-09-10-32.bpo-42613.J-jnm5.rst
new file mode 100644
index 0000000000..140ff8255b
--- /dev/null
+++ b/Misc/NEWS.d/next/Tools-Demos/2020-12-16-09-10-32.bpo-42613.J-jnm5.rst
@@ -0,0 +1,2 @@
+Fix ``freeze.py`` tool to use the prope config and library directories.
+Patch by Victor Stinner.
diff --git a/Misc/NEWS.d/next/Tools-Demos/2020-12-23-19-42-11.bpo-42726.a5EkTv.rst b/Misc/NEWS.d/next/Tools-Demos/2020-12-23-19-42-11.bpo-42726.a5EkTv.rst
new file mode 100644
index 0000000000..01a6e7fe55
--- /dev/null
+++ b/Misc/NEWS.d/next/Tools-Demos/2020-12-23-19-42-11.bpo-42726.a5EkTv.rst
@@ -0,0 +1,2 @@
+Fixed Python 3 compatibility issue with gdb/libpython.py handling of attribute
+dictionaries.
diff --git a/Misc/NEWS.d/next/Windows/2020-05-30-02-46-43.bpo-38324.476M-5.rst b/Misc/NEWS.d/next/Windows/2020-05-30-02-46-43.bpo-38324.476M-5.rst
deleted file mode 100644
index c45aa13091..0000000000
--- a/Misc/NEWS.d/next/Windows/2020-05-30-02-46-43.bpo-38324.476M-5.rst
+++ /dev/null
@@ -1 +0,0 @@
-Avoid Unicode errors when accessing certain locale data on Windows.
diff --git a/Misc/NEWS.d/next/Windows/2020-08-26-09-35-06.bpo-41557.vt00cQ.rst b/Misc/NEWS.d/next/Windows/2020-08-26-09-35-06.bpo-41557.vt00cQ.rst
deleted file mode 100644
index 9d85461f00..0000000000
--- a/Misc/NEWS.d/next/Windows/2020-08-26-09-35-06.bpo-41557.vt00cQ.rst
+++ /dev/null
@@ -1 +0,0 @@
-Update Windows installer to use SQLite 3.33.0.
diff --git a/Misc/NEWS.d/next/Windows/2020-09-24-23-09-40.bpo-39107.GbUZvD.rst b/Misc/NEWS.d/next/Windows/2020-09-24-23-09-40.bpo-39107.GbUZvD.rst
deleted file mode 100644
index 889ad48140..0000000000
--- a/Misc/NEWS.d/next/Windows/2020-09-24-23-09-40.bpo-39107.GbUZvD.rst
+++ /dev/null
@@ -1 +0,0 @@
-Update Tcl and Tk to 8.6.10 in Windows installer.
diff --git a/Misc/NEWS.d/next/Windows/2020-10-18-18-43-45.bpo-38252.7Nlepg.rst b/Misc/NEWS.d/next/Windows/2020-10-18-18-43-45.bpo-38252.7Nlepg.rst
deleted file mode 100644
index c103e6cfcc..0000000000
--- a/Misc/NEWS.d/next/Windows/2020-10-18-18-43-45.bpo-38252.7Nlepg.rst
+++ /dev/null
@@ -1 +0,0 @@
-Use 8-byte step to detect ASCII sequence in 64-bit Windows build.
diff --git a/Misc/NEWS.d/next/Windows/2020-10-20-13-19-42.bpo-38439.eMLi-t.rst b/Misc/NEWS.d/next/Windows/2020-10-20-13-19-42.bpo-38439.eMLi-t.rst
deleted file mode 100644
index acbc80c10f..0000000000
--- a/Misc/NEWS.d/next/Windows/2020-10-20-13-19-42.bpo-38439.eMLi-t.rst
+++ /dev/null
@@ -1 +0,0 @@
-Updates the icons for IDLE in the Windows Store package.
diff --git a/Misc/NEWS.d/next/macOS/2020-10-19-12-25-19.bpo-41471.gwA7un.rst b/Misc/NEWS.d/next/macOS/2020-10-19-12-25-19.bpo-41471.gwA7un.rst
deleted file mode 100644
index db5dd00b19..0000000000
--- a/Misc/NEWS.d/next/macOS/2020-10-19-12-25-19.bpo-41471.gwA7un.rst
+++ /dev/null
@@ -1 +0,0 @@
-Ignore invalid prefix lengths in system proxy excludes.
diff --git a/Misc/README.AIX b/Misc/README.AIX
index 92ad0293e6..6903a8146f 100644
--- a/Misc/README.AIX
+++ b/Misc/README.AIX
@@ -37,11 +37,6 @@ cd Python-3.2
CC=xlc_r OPT="-O2 -qmaxmem=70000" ./configure --without-computed-gotos --enable-shared
make
-Note:
-On AIX 5.3 and earlier, you will also need to specify the
-"--disable-ipv6" flag to configure. This has been corrected in AIX
-6.1.
-
======================================================================
Memory Limitations
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 90d288f739..01e36c656d 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -1479,7 +1479,8 @@ future_cls_getitem(PyObject *cls, PyObject *type)
static PyAsyncMethods FutureType_as_async = {
(unaryfunc)future_new_iter, /* am_await */
0, /* am_aiter */
- 0 /* am_anext */
+ 0, /* am_anext */
+ 0, /* am_send */
};
static PyMethodDef FutureType_methods[] = {
@@ -1597,37 +1598,61 @@ FutureIter_dealloc(futureiterobject *it)
}
}
-static PyObject *
-FutureIter_iternext(futureiterobject *it)
+static PySendResult
+FutureIter_am_send(futureiterobject *it,
+ PyObject *Py_UNUSED(arg),
+ PyObject **result)
{
+ /* arg is unused, see the comment on FutureIter_send for clarification */
+
PyObject *res;
FutureObj *fut = it->future;
+ *result = NULL;
if (fut == NULL) {
- return NULL;
+ return PYGEN_ERROR;
}
if (fut->fut_state == STATE_PENDING) {
if (!fut->fut_blocking) {
fut->fut_blocking = 1;
Py_INCREF(fut);
- return (PyObject *)fut;
+ *result = (PyObject *)fut;
+ return PYGEN_NEXT;
}
PyErr_SetString(PyExc_RuntimeError,
"await wasn't used with future");
- return NULL;
+ return PYGEN_ERROR;
}
it->future = NULL;
res = _asyncio_Future_result_impl(fut);
if (res != NULL) {
- /* The result of the Future is not an exception. */
- (void)_PyGen_SetStopIterationValue(res);
- Py_DECREF(res);
+ Py_DECREF(fut);
+ *result = res;
+ return PYGEN_RETURN;
}
Py_DECREF(fut);
- return NULL;
+ return PYGEN_ERROR;
+}
+
+static PyObject *
+FutureIter_iternext(futureiterobject *it)
+{
+ PyObject *result;
+ switch (FutureIter_am_send(it, Py_None, &result)) {
+ case PYGEN_RETURN:
+ (void)_PyGen_SetStopIterationValue(result);
+ Py_DECREF(result);
+ return NULL;
+ case PYGEN_NEXT:
+ return result;
+ case PYGEN_ERROR:
+ return NULL;
+ default:
+ Py_UNREACHABLE();
+ }
}
static PyObject *
@@ -1716,14 +1741,24 @@ static PyMethodDef FutureIter_methods[] = {
{NULL, NULL} /* Sentinel */
};
+static PyAsyncMethods FutureIterType_as_async = {
+ 0, /* am_await */
+ 0, /* am_aiter */
+ 0, /* am_anext */
+ (sendfunc)FutureIter_am_send, /* am_send */
+};
+
+
static PyTypeObject FutureIterType = {
PyVarObject_HEAD_INIT(NULL, 0)
"_asyncio.FutureIter",
.tp_basicsize = sizeof(futureiterobject),
.tp_itemsize = 0,
.tp_dealloc = (destructor)FutureIter_dealloc,
+ .tp_as_async = &FutureIterType_as_async,
.tp_getattro = PyObject_GenericGetAttr,
- .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
+ Py_TPFLAGS_HAVE_AM_SEND,
.tp_traverse = (traverseproc)FutureIter_traverse,
.tp_iter = PyObject_SelfIter,
.tp_iternext = (iternextfunc)FutureIter_iternext,
diff --git a/Modules/_blake2/blake2b_impl.c b/Modules/_blake2/blake2b_impl.c
index 8e1acce56b..5d108ed008 100644
--- a/Modules/_blake2/blake2b_impl.c
+++ b/Modules/_blake2/blake2b_impl.c
@@ -393,7 +393,7 @@ py_blake2b_dealloc(PyObject *self)
}
PyTypeObject *type = Py_TYPE(self);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(type);
}
diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c
index e1de5df37d..85c2d4edad 100644
--- a/Modules/_blake2/blake2s_impl.c
+++ b/Modules/_blake2/blake2s_impl.c
@@ -392,7 +392,7 @@ py_blake2s_dealloc(PyObject *self)
}
PyTypeObject *type = Py_TYPE(self);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(type);
}
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 1578750676..90bafb0ea8 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1128,38 +1128,6 @@ deque_insert(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
PyDoc_STRVAR(insert_doc,
"D.insert(index, object) -- insert object before index");
-static PyObject *
-deque_remove(dequeobject *deque, PyObject *value)
-{
- Py_ssize_t i, n=Py_SIZE(deque);
-
- for (i=0 ; i<n ; i++) {
- PyObject *item = deque->leftblock->data[deque->leftindex];
- int cmp = PyObject_RichCompareBool(item, value, Py_EQ);
-
- if (Py_SIZE(deque) != n) {
- PyErr_SetString(PyExc_IndexError,
- "deque mutated during remove().");
- return NULL;
- }
- if (cmp > 0) {
- PyObject *tgt = deque_popleft(deque, NULL);
- assert (tgt != NULL);
- if (_deque_rotate(deque, i))
- return NULL;
- Py_DECREF(tgt);
- Py_RETURN_NONE;
- }
- else if (cmp < 0) {
- _deque_rotate(deque, i);
- return NULL;
- }
- _deque_rotate(deque, -1);
- }
- PyErr_SetString(PyExc_ValueError, "deque.remove(x): x not in deque");
- return NULL;
-}
-
PyDoc_STRVAR(remove_doc,
"D.remove(value) -- remove first occurrence of value.");
@@ -1227,6 +1195,48 @@ deque_del_item(dequeobject *deque, Py_ssize_t i)
return rv;
}
+static PyObject *
+deque_remove(dequeobject *deque, PyObject *value)
+{
+ PyObject *item;
+ block *b = deque->leftblock;
+ Py_ssize_t i, n = Py_SIZE(deque), index = deque->leftindex;
+ size_t start_state = deque->state;
+ int cmp, rv;
+
+ for (i = 0 ; i < n; i++) {
+ item = b->data[index];
+ Py_INCREF(item);
+ cmp = PyObject_RichCompareBool(item, value, Py_EQ);
+ Py_DECREF(item);
+ if (cmp < 0) {
+ return NULL;
+ }
+ if (start_state != deque->state) {
+ PyErr_SetString(PyExc_IndexError,
+ "deque mutated during iteration");
+ return NULL;
+ }
+ if (cmp > 0) {
+ break;
+ }
+ index++;
+ if (index == BLOCKLEN) {
+ b = b->rightlink;
+ index = 0;
+ }
+ }
+ if (i == n) {
+ PyErr_Format(PyExc_ValueError, "%R is not in deque", value);
+ return NULL;
+ }
+ rv = deque_del_item(deque, i);
+ if (rv == -1) {
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
static int
deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v)
{
diff --git a/Modules/_contextvarsmodule.c b/Modules/_contextvarsmodule.c
index d6d7f375d1..d13b5962c1 100644
--- a/Modules/_contextvarsmodule.c
+++ b/Modules/_contextvarsmodule.c
@@ -30,30 +30,15 @@ static PyMethodDef _contextvars_methods[] = {
static int
_contextvars_exec(PyObject *m)
{
- Py_INCREF(&PyContext_Type);
- if (PyModule_AddObject(m, "Context",
- (PyObject *)&PyContext_Type) < 0)
- {
- Py_DECREF(&PyContext_Type);
+ if (PyModule_AddType(m, &PyContext_Type) < 0) {
return -1;
}
-
- Py_INCREF(&PyContextVar_Type);
- if (PyModule_AddObject(m, "ContextVar",
- (PyObject *)&PyContextVar_Type) < 0)
- {
- Py_DECREF(&PyContextVar_Type);
+ if (PyModule_AddType(m, &PyContextVar_Type) < 0) {
return -1;
}
-
- Py_INCREF(&PyContextToken_Type);
- if (PyModule_AddObject(m, "Token",
- (PyObject *)&PyContextToken_Type) < 0)
- {
- Py_DECREF(&PyContextToken_Type);
+ if (PyModule_AddType(m, &PyContextToken_Type) < 0) {
return -1;
}
-
return 0;
}
diff --git a/Modules/_csv.c b/Modules/_csv.c
index 594f6c1472..cade1ca9d4 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -18,9 +18,14 @@ module instead.
typedef struct {
PyObject *error_obj; /* CSV exception */
PyObject *dialects; /* Dialect registry */
+ PyTypeObject *dialect_type;
+ PyTypeObject *reader_type;
+ PyTypeObject *writer_type;
long field_limit; /* max parsed field size */
} _csvstate;
+static struct PyModuleDef _csvmodule;
+
static inline _csvstate*
get_csv_state(PyObject *module)
{
@@ -30,31 +35,35 @@ get_csv_state(PyObject *module)
}
static int
-_csv_clear(PyObject *m)
+_csv_clear(PyObject *module)
{
- Py_CLEAR(get_csv_state(m)->error_obj);
- Py_CLEAR(get_csv_state(m)->dialects);
+ _csvstate *module_state = PyModule_GetState(module);
+ Py_CLEAR(module_state->error_obj);
+ Py_CLEAR(module_state->dialects);
+ Py_CLEAR(module_state->dialect_type);
+ Py_CLEAR(module_state->reader_type);
+ Py_CLEAR(module_state->writer_type);
return 0;
}
static int
-_csv_traverse(PyObject *m, visitproc visit, void *arg)
+_csv_traverse(PyObject *module, visitproc visit, void *arg)
{
- Py_VISIT(get_csv_state(m)->error_obj);
- Py_VISIT(get_csv_state(m)->dialects);
+ _csvstate *module_state = PyModule_GetState(module);
+ Py_VISIT(module_state->error_obj);
+ Py_VISIT(module_state->dialects);
+ Py_VISIT(module_state->dialect_type);
+ Py_VISIT(module_state->reader_type);
+ Py_VISIT(module_state->writer_type);
return 0;
}
static void
-_csv_free(void *m)
+_csv_free(void *module)
{
- _csv_clear((PyObject *)m);
+ _csv_clear((PyObject *)module);
}
-static struct PyModuleDef _csvmodule;
-
-#define _csvstate_global ((_csvstate *)PyModule_GetState(PyState_FindModule(&_csvmodule)))
-
typedef enum {
START_RECORD, START_FIELD, ESCAPED_CHAR, IN_FIELD,
IN_QUOTED_FIELD, ESCAPE_IN_QUOTED_FIELD, QUOTE_IN_QUOTED_FIELD,
@@ -92,8 +101,6 @@ typedef struct {
} DialectObj;
-static PyTypeObject Dialect_Type;
-
typedef struct {
PyObject_HEAD
@@ -110,8 +117,6 @@ typedef struct {
unsigned long line_num; /* Source-file line number */
} ReaderObj;
-static PyTypeObject Reader_Type;
-
typedef struct {
PyObject_HEAD
@@ -123,26 +128,27 @@ typedef struct {
Py_ssize_t rec_size; /* size of allocated record */
Py_ssize_t rec_len; /* length of record */
int num_fields; /* number of fields in record */
-} WriterObj;
-static PyTypeObject Writer_Type;
+ PyObject *error_obj; /* cached error object */
+} WriterObj;
/*
* DIALECT class
*/
static PyObject *
-get_dialect_from_registry(PyObject * name_obj)
+get_dialect_from_registry(PyObject *name_obj, _csvstate *module_state)
{
PyObject *dialect_obj;
- dialect_obj = PyDict_GetItemWithError(_csvstate_global->dialects, name_obj);
+ dialect_obj = PyDict_GetItemWithError(module_state->dialects, name_obj);
if (dialect_obj == NULL) {
if (!PyErr_Occurred())
- PyErr_Format(_csvstate_global->error_obj, "unknown dialect");
+ PyErr_Format(module_state->error_obj, "unknown dialect");
}
else
Py_INCREF(dialect_obj);
+
return dialect_obj;
}
@@ -309,8 +315,16 @@ static PyGetSetDef Dialect_getsetlist[] = {
static void
Dialect_dealloc(DialectObj *self)
{
- Py_XDECREF(self->lineterminator);
- Py_TYPE(self)->tp_free((PyObject *)self);
+ PyTypeObject *tp = Py_TYPE(self);
+ Py_CLEAR(self->lineterminator);
+ tp->tp_free((PyObject *)self);
+ Py_DECREF(tp);
+}
+
+static void
+Dialect_finalize(DialectObj *self)
+{
+ Py_CLEAR(self->lineterminator);
}
static char *dialect_kws[] = {
@@ -326,6 +340,22 @@ static char *dialect_kws[] = {
NULL
};
+static _csvstate *
+_csv_state_from_type(PyTypeObject *type, const char *name)
+{
+ PyObject *module = _PyType_GetModuleByDef(type, &_csvmodule);
+ if (module == NULL) {
+ return NULL;
+ }
+ _csvstate *module_state = PyModule_GetState(module);
+ if (module_state == NULL) {
+ PyErr_Format(PyExc_SystemError,
+ "%s: No _csv module state found", name);
+ return NULL;
+ }
+ return module_state;
+}
+
static PyObject *
dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
@@ -354,16 +384,21 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
&strict))
return NULL;
+ _csvstate *module_state = _csv_state_from_type(type, "dialect_new");
+ if (module_state == NULL) {
+ return NULL;
+ }
+
if (dialect != NULL) {
if (PyUnicode_Check(dialect)) {
- dialect = get_dialect_from_registry(dialect);
+ dialect = get_dialect_from_registry(dialect, module_state);
if (dialect == NULL)
return NULL;
}
else
Py_INCREF(dialect);
/* Can we reuse this instance? */
- if (PyObject_TypeCheck(dialect, &Dialect_Type) &&
+ if (PyObject_TypeCheck(dialect, module_state->dialect_type) &&
delimiter == NULL &&
doublequote == NULL &&
escapechar == NULL &&
@@ -377,7 +412,7 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
self = (DialectObj *)type->tp_alloc(type, 0);
if (self == NULL) {
- Py_XDECREF(dialect);
+ Py_CLEAR(dialect);
return NULL;
}
self->lineterminator = NULL;
@@ -441,76 +476,69 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
ret = (PyObject *)self;
Py_INCREF(self);
err:
- Py_XDECREF(self);
- Py_XDECREF(dialect);
- Py_XDECREF(delimiter);
- Py_XDECREF(doublequote);
- Py_XDECREF(escapechar);
- Py_XDECREF(lineterminator);
- Py_XDECREF(quotechar);
- Py_XDECREF(quoting);
- Py_XDECREF(skipinitialspace);
- Py_XDECREF(strict);
+ Py_CLEAR(self);
+ Py_CLEAR(dialect);
+ Py_CLEAR(delimiter);
+ Py_CLEAR(doublequote);
+ Py_CLEAR(escapechar);
+ Py_CLEAR(lineterminator);
+ Py_CLEAR(quotechar);
+ Py_CLEAR(quoting);
+ Py_CLEAR(skipinitialspace);
+ Py_CLEAR(strict);
return ret;
}
+/* Since dialect is now a heap type, it inherits pickling method for
+ * protocol 0 and 1 from object, therefore it needs to be overriden */
+
+PyDoc_STRVAR(dialect_reduce_doc, "raises an exception to avoid pickling");
+
+static PyObject *
+Dialect_reduce(PyObject *self, PyObject *args) {
+ PyErr_Format(PyExc_TypeError,
+ "cannot pickle '%.100s' instances", _PyType_Name(Py_TYPE(self)));
+ return NULL;
+}
+
+static struct PyMethodDef dialect_methods[] = {
+ {"__reduce__", Dialect_reduce, METH_VARARGS, dialect_reduce_doc},
+ {"__reduce_ex__", Dialect_reduce, METH_VARARGS, dialect_reduce_doc},
+ {NULL, NULL}
+};
PyDoc_STRVAR(Dialect_Type_doc,
"CSV dialect\n"
"\n"
"The Dialect type records CSV parsing and generation options.\n");
-static PyTypeObject Dialect_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_csv.Dialect", /* tp_name */
- sizeof(DialectObj), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)Dialect_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
- (getattrfunc)0, /* tp_getattr */
- (setattrfunc)0, /* tp_setattr */
- 0, /* tp_as_async */
- (reprfunc)0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- (ternaryfunc)0, /* tp_call */
- (reprfunc)0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- Dialect_Type_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- Dialect_memberlist, /* tp_members */
- Dialect_getsetlist, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- dialect_new, /* tp_new */
- 0, /* tp_free */
+static PyType_Slot Dialect_Type_slots[] = {
+ {Py_tp_doc, (char*)Dialect_Type_doc},
+ {Py_tp_members, Dialect_memberlist},
+ {Py_tp_getset, Dialect_getsetlist},
+ {Py_tp_new, dialect_new},
+ {Py_tp_methods, dialect_methods},
+ {Py_tp_finalize, Dialect_finalize},
+ {Py_tp_dealloc, Dialect_dealloc},
+ {0, NULL}
};
+PyType_Spec Dialect_Type_spec = {
+ .name = "_csv.Dialect",
+ .basicsize = sizeof(DialectObj),
+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ .slots = Dialect_Type_slots,
+};
+
+
/*
* Return an instance of the dialect type, given a Python instance or kwarg
* description of the dialect
*/
static PyObject *
-_call_dialect(PyObject *dialect_inst, PyObject *kwargs)
+_call_dialect(_csvstate *module_state, PyObject *dialect_inst, PyObject *kwargs)
{
- PyObject *type = (PyObject *)&Dialect_Type;
+ PyObject *type = (PyObject *)module_state->dialect_type;
if (dialect_inst) {
return PyObject_VectorcallDict(type, &dialect_inst, 1, kwargs);
}
@@ -568,11 +596,12 @@ parse_grow_buff(ReaderObj *self)
}
static int
-parse_add_char(ReaderObj *self, Py_UCS4 c)
+parse_add_char(ReaderObj *self, _csvstate *module_state, Py_UCS4 c)
{
- if (self->field_len >= _csvstate_global->field_limit) {
- PyErr_Format(_csvstate_global->error_obj, "field larger than field limit (%ld)",
- _csvstate_global->field_limit);
+ if (self->field_len >= module_state->field_limit) {
+ PyErr_Format(module_state->error_obj,
+ "field larger than field limit (%ld)",
+ module_state->field_limit);
return -1;
}
if (self->field_len == self->field_size && !parse_grow_buff(self))
@@ -582,7 +611,7 @@ parse_add_char(ReaderObj *self, Py_UCS4 c)
}
static int
-parse_process_char(ReaderObj *self, Py_UCS4 c)
+parse_process_char(ReaderObj *self, _csvstate *module_state, Py_UCS4 c)
{
DialectObj *dialect = self->dialect;
@@ -628,7 +657,7 @@ parse_process_char(ReaderObj *self, Py_UCS4 c)
/* begin new unquoted field */
if (dialect->quoting == QUOTE_NONNUMERIC)
self->numeric_field = 1;
- if (parse_add_char(self, c) < 0)
+ if (parse_add_char(self, module_state, c) < 0)
return -1;
self->state = IN_FIELD;
}
@@ -636,14 +665,14 @@ parse_process_char(ReaderObj *self, Py_UCS4 c)
case ESCAPED_CHAR:
if (c == '\n' || c=='\r') {
- if (parse_add_char(self, c) < 0)
+ if (parse_add_char(self, module_state, c) < 0)
return -1;
self->state = AFTER_ESCAPED_CRNL;
break;
}
if (c == '\0')
c = '\n';
- if (parse_add_char(self, c) < 0)
+ if (parse_add_char(self, module_state, c) < 0)
return -1;
self->state = IN_FIELD;
break;
@@ -673,7 +702,7 @@ parse_process_char(ReaderObj *self, Py_UCS4 c)
}
else {
/* normal character - save in field */
- if (parse_add_char(self, c) < 0)
+ if (parse_add_char(self, module_state, c) < 0)
return -1;
}
break;
@@ -699,7 +728,7 @@ parse_process_char(ReaderObj *self, Py_UCS4 c)
}
else {
/* normal character - save in field */
- if (parse_add_char(self, c) < 0)
+ if (parse_add_char(self, module_state, c) < 0)
return -1;
}
break;
@@ -707,7 +736,7 @@ parse_process_char(ReaderObj *self, Py_UCS4 c)
case ESCAPE_IN_QUOTED_FIELD:
if (c == '\0')
c = '\n';
- if (parse_add_char(self, c) < 0)
+ if (parse_add_char(self, module_state, c) < 0)
return -1;
self->state = IN_QUOTED_FIELD;
break;
@@ -717,7 +746,7 @@ parse_process_char(ReaderObj *self, Py_UCS4 c)
if (dialect->quoting != QUOTE_NONE &&
c == dialect->quotechar) {
/* save "" as " */
- if (parse_add_char(self, c) < 0)
+ if (parse_add_char(self, module_state, c) < 0)
return -1;
self->state = IN_QUOTED_FIELD;
}
@@ -734,13 +763,13 @@ parse_process_char(ReaderObj *self, Py_UCS4 c)
self->state = (c == '\0' ? START_RECORD : EAT_CRNL);
}
else if (!dialect->strict) {
- if (parse_add_char(self, c) < 0)
+ if (parse_add_char(self, module_state, c) < 0)
return -1;
self->state = IN_FIELD;
}
else {
/* illegal */
- PyErr_Format(_csvstate_global->error_obj, "'%c' expected after '%c'",
+ PyErr_Format(module_state->error_obj, "'%c' expected after '%c'",
dialect->delimiter,
dialect->quotechar);
return -1;
@@ -753,7 +782,8 @@ parse_process_char(ReaderObj *self, Py_UCS4 c)
else if (c == '\0')
self->state = START_RECORD;
else {
- PyErr_Format(_csvstate_global->error_obj, "new-line character seen in unquoted field - do you need to open the file in universal-newline mode?");
+ PyErr_Format(module_state->error_obj,
+ "new-line character seen in unquoted field - do you need to open the file in universal-newline mode?");
return -1;
}
break;
@@ -784,6 +814,12 @@ Reader_iternext(ReaderObj *self)
const void *data;
PyObject *lineobj;
+ _csvstate *module_state = _csv_state_from_type(Py_TYPE(self),
+ "Reader.__next__");
+ if (module_state == NULL) {
+ return NULL;
+ }
+
if (parse_reset(self) < 0)
return NULL;
do {
@@ -793,7 +829,7 @@ Reader_iternext(ReaderObj *self)
if (!PyErr_Occurred() && (self->field_len != 0 ||
self->state == IN_QUOTED_FIELD)) {
if (self->dialect->strict)
- PyErr_SetString(_csvstate_global->error_obj,
+ PyErr_SetString(module_state->error_obj,
"unexpected end of data");
else if (parse_save_field(self) >= 0)
break;
@@ -801,7 +837,7 @@ Reader_iternext(ReaderObj *self)
return NULL;
}
if (!PyUnicode_Check(lineobj)) {
- PyErr_Format(_csvstate_global->error_obj,
+ PyErr_Format(module_state->error_obj,
"iterator should return strings, "
"not %.200s "
"(the file should be opened in text mode)",
@@ -823,18 +859,18 @@ Reader_iternext(ReaderObj *self)
c = PyUnicode_READ(kind, data, pos);
if (c == '\0') {
Py_DECREF(lineobj);
- PyErr_Format(_csvstate_global->error_obj,
+ PyErr_Format(module_state->error_obj,
"line contains NUL");
goto err;
}
- if (parse_process_char(self, c) < 0) {
+ if (parse_process_char(self, module_state, c) < 0) {
Py_DECREF(lineobj);
goto err;
}
pos++;
}
Py_DECREF(lineobj);
- if (parse_process_char(self, 0) < 0)
+ if (parse_process_char(self, module_state, 0) < 0)
goto err;
} while (self->state != START_RECORD);
@@ -847,13 +883,29 @@ err:
static void
Reader_dealloc(ReaderObj *self)
{
+ PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
- Py_XDECREF(self->dialect);
- Py_XDECREF(self->input_iter);
- Py_XDECREF(self->fields);
- if (self->field != NULL)
+ Py_CLEAR(self->dialect);
+ Py_CLEAR(self->input_iter);
+ Py_CLEAR(self->fields);
+ if (self->field != NULL) {
PyMem_Free(self->field);
+ self->field = NULL;
+ }
PyObject_GC_Del(self);
+ Py_DECREF(tp);
+}
+
+static void
+Reader_finalize(ReaderObj *self)
+{
+ Py_CLEAR(self->dialect);
+ Py_CLEAR(self->input_iter);
+ Py_CLEAR(self->fields);
+ if (self->field != NULL) {
+ PyMem_Free(self->field);
+ self->field = NULL;
+ }
}
static int
@@ -893,47 +945,35 @@ static struct PyMemberDef Reader_memberlist[] = {
};
-static PyTypeObject Reader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_csv.reader", /*tp_name*/
- sizeof(ReaderObj), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)Reader_dealloc, /*tp_dealloc*/
- 0, /*tp_vectorcall_offset*/
- (getattrfunc)0, /*tp_getattr*/
- (setattrfunc)0, /*tp_setattr*/
- 0, /*tp_as_async*/
- (reprfunc)0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- (hashfunc)0, /*tp_hash*/
- (ternaryfunc)0, /*tp_call*/
- (reprfunc)0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
- Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- Reader_Type_doc, /*tp_doc*/
- (traverseproc)Reader_traverse, /*tp_traverse*/
- (inquiry)Reader_clear, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- PyObject_SelfIter, /*tp_iter*/
- (getiterfunc)Reader_iternext, /*tp_iternext*/
- Reader_methods, /*tp_methods*/
- Reader_memberlist, /*tp_members*/
- 0, /*tp_getset*/
+static PyType_Slot Reader_Type_slots[] = {
+ {Py_tp_doc, (char*)Reader_Type_doc},
+ {Py_tp_traverse, Reader_traverse},
+ {Py_tp_clear, Reader_clear},
+ {Py_tp_iter, PyObject_SelfIter},
+ {Py_tp_iternext, Reader_iternext},
+ {Py_tp_methods, Reader_methods},
+ {Py_tp_members, Reader_memberlist},
+ {Py_tp_finalize, Reader_finalize},
+ {Py_tp_dealloc, Reader_dealloc},
+ {0, NULL}
+};
+PyType_Spec Reader_Type_spec = {
+ .name = "_csv.reader",
+ .basicsize = sizeof(ReaderObj),
+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
+ .slots = Reader_Type_slots
};
+
static PyObject *
csv_reader(PyObject *module, PyObject *args, PyObject *keyword_args)
{
PyObject * iterator, * dialect = NULL;
- ReaderObj * self = PyObject_GC_New(ReaderObj, &Reader_Type);
+ _csvstate *module_state = get_csv_state(module);
+ ReaderObj * self = PyObject_GC_New(
+ ReaderObj,
+ module_state->reader_type);
if (!self)
return NULL;
@@ -959,7 +999,8 @@ csv_reader(PyObject *module, PyObject *args, PyObject *keyword_args)
Py_DECREF(self);
return NULL;
}
- self->dialect = (DialectObj *)_call_dialect(dialect, keyword_args);
+ self->dialect = (DialectObj *)_call_dialect(module_state, dialect,
+ keyword_args);
if (self->dialect == NULL) {
Py_DECREF(self);
return NULL;
@@ -1048,7 +1089,7 @@ join_append_data(WriterObj *self, unsigned int field_kind, const void *field_dat
}
if (want_escape) {
if (!dialect->escapechar) {
- PyErr_Format(_csvstate_global->error_obj,
+ PyErr_Format(self->error_obj,
"need to escape, but no escapechar set");
return -1;
}
@@ -1166,7 +1207,7 @@ csv_writerow(WriterObj *self, PyObject *seq)
iter = PyObject_GetIter(seq);
if (iter == NULL) {
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
- PyErr_Format(_csvstate_global->error_obj,
+ PyErr_Format(self->error_obj,
"iterable expected, not %.200s",
Py_TYPE(seq)->tp_name);
}
@@ -1223,7 +1264,7 @@ csv_writerow(WriterObj *self, PyObject *seq)
if (self->num_fields > 0 && self->rec_len == 0) {
if (dialect->quoting == QUOTE_NONE) {
- PyErr_Format(_csvstate_global->error_obj,
+ PyErr_Format(self->error_obj,
"single empty field record must be quoted");
return NULL;
}
@@ -1292,22 +1333,12 @@ static struct PyMemberDef Writer_memberlist[] = {
{ NULL }
};
-static void
-Writer_dealloc(WriterObj *self)
-{
- PyObject_GC_UnTrack(self);
- Py_XDECREF(self->dialect);
- Py_XDECREF(self->write);
- if (self->rec != NULL)
- PyMem_Free(self->rec);
- PyObject_GC_Del(self);
-}
-
static int
Writer_traverse(WriterObj *self, visitproc visit, void *arg)
{
Py_VISIT(self->dialect);
Py_VISIT(self->write);
+ Py_VISIT(self->error_obj);
return 0;
}
@@ -1316,9 +1347,19 @@ Writer_clear(WriterObj *self)
{
Py_CLEAR(self->dialect);
Py_CLEAR(self->write);
+ Py_CLEAR(self->error_obj);
return 0;
}
+static void
+Writer_finalize(WriterObj *self)
+{
+ Writer_clear(self);
+ if (self->rec != NULL) {
+ PyMem_Free(self->rec);
+ }
+}
+
PyDoc_STRVAR(Writer_Type_doc,
"CSV writer\n"
"\n"
@@ -1326,46 +1367,30 @@ PyDoc_STRVAR(Writer_Type_doc,
"in CSV format from sequence input.\n"
);
-static PyTypeObject Writer_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_csv.writer", /*tp_name*/
- sizeof(WriterObj), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)Writer_dealloc, /*tp_dealloc*/
- 0, /*tp_vectorcall_offset*/
- (getattrfunc)0, /*tp_getattr*/
- (setattrfunc)0, /*tp_setattr*/
- 0, /*tp_as_async*/
- (reprfunc)0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- (hashfunc)0, /*tp_hash*/
- (ternaryfunc)0, /*tp_call*/
- (reprfunc)0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
- Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- Writer_Type_doc,
- (traverseproc)Writer_traverse, /*tp_traverse*/
- (inquiry)Writer_clear, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- (getiterfunc)0, /*tp_iter*/
- (getiterfunc)0, /*tp_iternext*/
- Writer_methods, /*tp_methods*/
- Writer_memberlist, /*tp_members*/
- 0, /*tp_getset*/
+static PyType_Slot Writer_Type_slots[] = {
+ {Py_tp_finalize, Writer_finalize},
+ {Py_tp_doc, (char*)Writer_Type_doc},
+ {Py_tp_traverse, Writer_traverse},
+ {Py_tp_clear, Writer_clear},
+ {Py_tp_methods, Writer_methods},
+ {Py_tp_members, Writer_memberlist},
+ {0, NULL}
+};
+
+PyType_Spec Writer_Type_spec = {
+ .name = "_csv.writer",
+ .basicsize = sizeof(WriterObj),
+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
+ .slots = Writer_Type_slots,
};
+
static PyObject *
csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args)
{
PyObject * output_file, * dialect = NULL;
- WriterObj * self = PyObject_GC_New(WriterObj, &Writer_Type);
+ _csvstate *module_state = get_csv_state(module);
+ WriterObj * self = PyObject_GC_New(WriterObj, module_state->writer_type);
_Py_IDENTIFIER(write);
if (!self)
@@ -1379,6 +1404,8 @@ csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args)
self->rec_len = 0;
self->num_fields = 0;
+ self->error_obj = Py_NewRef(module_state->error_obj);
+
if (!PyArg_UnpackTuple(args, "", 1, 2, &output_file, &dialect)) {
Py_DECREF(self);
return NULL;
@@ -1393,7 +1420,8 @@ csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args)
Py_DECREF(self);
return NULL;
}
- self->dialect = (DialectObj *)_call_dialect(dialect, keyword_args);
+ self->dialect = (DialectObj *)_call_dialect(module_state, dialect,
+ keyword_args);
if (self->dialect == NULL) {
Py_DECREF(self);
return NULL;
@@ -1408,13 +1436,14 @@ csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args)
static PyObject *
csv_list_dialects(PyObject *module, PyObject *args)
{
- return PyDict_Keys(_csvstate_global->dialects);
+ return PyDict_Keys(get_csv_state(module)->dialects);
}
static PyObject *
csv_register_dialect(PyObject *module, PyObject *args, PyObject *kwargs)
{
PyObject *name_obj, *dialect_obj = NULL;
+ _csvstate *module_state = get_csv_state(module);
PyObject *dialect;
if (!PyArg_UnpackTuple(args, "", 1, 2, &name_obj, &dialect_obj))
@@ -1426,10 +1455,10 @@ csv_register_dialect(PyObject *module, PyObject *args, PyObject *kwargs)
}
if (PyUnicode_READY(name_obj) == -1)
return NULL;
- dialect = _call_dialect(dialect_obj, kwargs);
+ dialect = _call_dialect(module_state, dialect_obj, kwargs);
if (dialect == NULL)
return NULL;
- if (PyDict_SetItem(_csvstate_global->dialects, name_obj, dialect) < 0) {
+ if (PyDict_SetItem(module_state->dialects, name_obj, dialect) < 0) {
Py_DECREF(dialect);
return NULL;
}
@@ -1440,9 +1469,10 @@ csv_register_dialect(PyObject *module, PyObject *args, PyObject *kwargs)
static PyObject *
csv_unregister_dialect(PyObject *module, PyObject *name_obj)
{
- if (PyDict_DelItem(_csvstate_global->dialects, name_obj) < 0) {
+ _csvstate *module_state = get_csv_state(module);
+ if (PyDict_DelItem(module_state->dialects, name_obj) < 0) {
if (PyErr_ExceptionMatches(PyExc_KeyError)) {
- PyErr_Format(_csvstate_global->error_obj, "unknown dialect");
+ PyErr_Format(module_state->error_obj, "unknown dialect");
}
return NULL;
}
@@ -1452,14 +1482,15 @@ csv_unregister_dialect(PyObject *module, PyObject *name_obj)
static PyObject *
csv_get_dialect(PyObject *module, PyObject *name_obj)
{
- return get_dialect_from_registry(name_obj);
+ return get_dialect_from_registry(name_obj, get_csv_state(module));
}
static PyObject *
csv_field_size_limit(PyObject *module, PyObject *args)
{
PyObject *new_limit = NULL;
- long old_limit = _csvstate_global->field_limit;
+ _csvstate *module_state = get_csv_state(module);
+ long old_limit = module_state->field_limit;
if (!PyArg_UnpackTuple(args, "field_size_limit", 0, 1, &new_limit))
return NULL;
@@ -1469,15 +1500,25 @@ csv_field_size_limit(PyObject *module, PyObject *args)
"limit must be an integer");
return NULL;
}
- _csvstate_global->field_limit = PyLong_AsLong(new_limit);
- if (_csvstate_global->field_limit == -1 && PyErr_Occurred()) {
- _csvstate_global->field_limit = old_limit;
+ module_state->field_limit = PyLong_AsLong(new_limit);
+ if (module_state->field_limit == -1 && PyErr_Occurred()) {
+ module_state->field_limit = old_limit;
return NULL;
}
}
return PyLong_FromLong(old_limit);
}
+static PyType_Slot error_slots[] = {
+ {0, NULL},
+};
+
+PyType_Spec error_spec = {
+ .name = "_csv.Error",
+ .flags = Py_TPFLAGS_DEFAULT,
+ .slots = error_slots,
+};
+
/*
* MODULE
*/
@@ -1610,68 +1651,89 @@ static struct PyMethodDef csv_methods[] = {
{ NULL, NULL }
};
-static struct PyModuleDef _csvmodule = {
- PyModuleDef_HEAD_INIT,
- "_csv",
- csv_module_doc,
- sizeof(_csvstate),
- csv_methods,
- NULL,
- _csv_traverse,
- _csv_clear,
- _csv_free
-};
-
-PyMODINIT_FUNC
-PyInit__csv(void)
-{
- PyObject *module;
+static int
+csv_exec(PyObject *module) {
const StyleDesc *style;
+ PyObject *temp;
+ _csvstate *module_state = get_csv_state(module);
- if (PyType_Ready(&Reader_Type) < 0)
- return NULL;
+ temp = PyType_FromModuleAndSpec(module, &Dialect_Type_spec, NULL);
+ module_state->dialect_type = (PyTypeObject *)temp;
+ if (PyModule_AddObjectRef(module, "Dialect", temp) < 0) {
+ return -1;
+ }
- if (PyType_Ready(&Writer_Type) < 0)
- return NULL;
+ temp = PyType_FromModuleAndSpec(module, &Reader_Type_spec, NULL);
+ module_state->reader_type = (PyTypeObject *)temp;
+ if (PyModule_AddObjectRef(module, "Reader", temp) < 0) {
+ return -1;
+ }
- /* Create the module and add the functions */
- module = PyModule_Create(&_csvmodule);
- if (module == NULL)
- return NULL;
+ temp = PyType_FromModuleAndSpec(module, &Writer_Type_spec, NULL);
+ module_state->writer_type = (PyTypeObject *)temp;
+ if (PyModule_AddObjectRef(module, "Writer", temp) < 0) {
+ return -1;
+ }
/* Add version to the module. */
if (PyModule_AddStringConstant(module, "__version__",
- MODULE_VERSION) == -1)
- return NULL;
+ MODULE_VERSION) == -1) {
+ return -1;
+ }
/* Set the field limit */
- get_csv_state(module)->field_limit = 128 * 1024;
- /* Do I still need to add this var to the Module Dict? */
+ module_state->field_limit = 128 * 1024;
/* Add _dialects dictionary */
- get_csv_state(module)->dialects = PyDict_New();
- if (get_csv_state(module)->dialects == NULL)
- return NULL;
- Py_INCREF(get_csv_state(module)->dialects);
- if (PyModule_AddObject(module, "_dialects", get_csv_state(module)->dialects))
- return NULL;
+ module_state->dialects = PyDict_New();
+ if (PyModule_AddObjectRef(module, "_dialects", module_state->dialects) < 0) {
+ return -1;
+ }
/* Add quote styles into dictionary */
for (style = quote_styles; style->name; style++) {
if (PyModule_AddIntConstant(module, style->name,
style->style) == -1)
- return NULL;
+ return -1;
}
- if (PyModule_AddType(module, &Dialect_Type)) {
- return NULL;
+ /* Add the CSV exception object to the module. */
+ PyObject *bases = PyTuple_Pack(1, PyExc_Exception);
+ if (bases == NULL) {
+ return -1;
+ }
+ module_state->error_obj = PyType_FromModuleAndSpec(module, &error_spec,
+ bases);
+ Py_DECREF(bases);
+ if (module_state->error_obj == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(module, (PyTypeObject *)module_state->error_obj) != 0) {
+ return -1;
}
- /* Add the CSV exception object to the module. */
- get_csv_state(module)->error_obj = PyErr_NewException("_csv.Error", NULL, NULL);
- if (get_csv_state(module)->error_obj == NULL)
- return NULL;
- Py_INCREF(get_csv_state(module)->error_obj);
- PyModule_AddObject(module, "Error", get_csv_state(module)->error_obj);
- return module;
+ return 0;
+}
+
+static PyModuleDef_Slot csv_slots[] = {
+ {Py_mod_exec, csv_exec},
+ {0, NULL}
+};
+
+static struct PyModuleDef _csvmodule = {
+ PyModuleDef_HEAD_INIT,
+ "_csv",
+ csv_module_doc,
+ sizeof(_csvstate),
+ csv_methods,
+ csv_slots,
+ _csv_traverse,
+ _csv_clear,
+ _csv_free
+};
+
+PyMODINIT_FUNC
+PyInit__csv(void)
+{
+ return PyModuleDef_Init(&_csvmodule);
}
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 8d5594c62c..5f8a723f63 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -125,9 +125,13 @@ PyObject *_ctypes_ptrtype_cache = NULL;
static PyTypeObject Simple_Type;
-/* a callable object used for unpickling */
+/* a callable object used for unpickling:
+ strong reference to _ctypes._unpickle() function */
static PyObject *_unpickle;
+#ifdef MS_WIN32
+PyObject *ComError; // Borrowed reference to: &PyComError_Type
+#endif
/****************************************************************/
@@ -1354,7 +1358,6 @@ static PyGetSetDef CharArray_getsets[] = {
{ NULL, NULL }
};
-#ifdef CTYPES_UNICODE
static PyObject *
WCharArray_get_value(CDataObject *self, void *Py_UNUSED(ignored))
{
@@ -1404,7 +1407,6 @@ static PyGetSetDef WCharArray_getsets[] = {
"string value"},
{ NULL, NULL }
};
-#endif
/*
The next three functions copied from Python's typeobject.c.
@@ -1611,11 +1613,10 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (itemdict->getfunc == _ctypes_get_fielddesc("c")->getfunc) {
if (-1 == add_getset(result, CharArray_getsets))
goto error;
-#ifdef CTYPES_UNICODE
- } else if (itemdict->getfunc == _ctypes_get_fielddesc("u")->getfunc) {
+ }
+ else if (itemdict->getfunc == _ctypes_get_fielddesc("u")->getfunc) {
if (-1 == add_getset(result, WCharArray_getsets))
goto error;
-#endif
}
return (PyObject *)result;
@@ -4307,7 +4308,7 @@ static PyNumberMethods PyCFuncPtr_as_number = {
PyTypeObject PyCFuncPtr_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
- "_ctypes.PyCFuncPtr",
+ "_ctypes.CFuncPtr",
sizeof(PyCFuncPtrObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)PyCFuncPtr_dealloc, /* tp_dealloc */
@@ -4650,7 +4651,6 @@ Array_subscript(PyObject *myself, PyObject *item)
PyMem_Free(dest);
return np;
}
-#ifdef CTYPES_UNICODE
if (itemdict->getfunc == _ctypes_get_fielddesc("u")->getfunc) {
wchar_t *ptr = (wchar_t *)self->b_ptr;
wchar_t *dest;
@@ -4677,7 +4677,6 @@ Array_subscript(PyObject *myself, PyObject *item)
PyMem_Free(dest);
return np;
}
-#endif
np = PyList_New(slicelen);
if (np == NULL)
@@ -5346,7 +5345,6 @@ Pointer_subscript(PyObject *myself, PyObject *item)
PyMem_Free(dest);
return np;
}
-#ifdef CTYPES_UNICODE
if (itemdict->getfunc == _ctypes_get_fielddesc("u")->getfunc) {
wchar_t *ptr = *(wchar_t **)self->b_ptr;
wchar_t *dest;
@@ -5367,7 +5365,6 @@ Pointer_subscript(PyObject *myself, PyObject *item)
PyMem_Free(dest);
return np;
}
-#endif
np = PyList_New(len);
if (np == NULL)
@@ -5555,20 +5552,7 @@ static PyTypeObject PyComError_Type = {
0, /* tp_alloc */
0, /* tp_new */
};
-
-
-static int
-create_comerror(void)
-{
- PyComError_Type.tp_base = (PyTypeObject*)PyExc_Exception;
- if (PyType_Ready(&PyComError_Type) < 0)
- return -1;
- Py_INCREF(&PyComError_Type);
- ComError = (PyObject*)&PyComError_Type;
- return 0;
-}
-
-#endif
+#endif // MS_WIN32
static PyObject *
string_at(const char *ptr, int size)
@@ -5662,7 +5646,7 @@ cast(void *ptr, PyObject *src, PyObject *ctype)
return NULL;
}
-#ifdef CTYPES_UNICODE
+
static PyObject *
wstring_at(const wchar_t *ptr, int size)
{
@@ -5674,133 +5658,74 @@ wstring_at(const wchar_t *ptr, int size)
ssize = wcslen(ptr);
return PyUnicode_FromWideChar(ptr, ssize);
}
-#endif
static struct PyModuleDef _ctypesmodule = {
PyModuleDef_HEAD_INIT,
- "_ctypes",
- module_docs,
- -1,
- _ctypes_module_methods,
- NULL,
- NULL,
- NULL,
- NULL
+ .m_name = "_ctypes",
+ .m_doc = module_docs,
+ .m_size = -1,
+ .m_methods = _ctypes_module_methods,
};
-PyMODINIT_FUNC
-PyInit__ctypes(void)
-{
- PyObject *m;
-
-/* Note:
- ob_type is the metatype (the 'type'), defaults to PyType_Type,
- tp_base is the base type, defaults to 'object' aka PyBaseObject_Type.
-*/
- m = PyModule_Create(&_ctypesmodule);
- if (!m)
- return NULL;
-
- _ctypes_ptrtype_cache = PyDict_New();
- if (_ctypes_ptrtype_cache == NULL)
- return NULL;
-
- PyModule_AddObject(m, "_pointer_type_cache", (PyObject *)_ctypes_ptrtype_cache);
-
- _unpickle = PyObject_GetAttrString(m, "_unpickle");
- if (_unpickle == NULL)
- return NULL;
-
- if (PyType_Ready(&PyCArg_Type) < 0)
- return NULL;
-
- if (PyType_Ready(&PyCThunk_Type) < 0)
- return NULL;
+static int
+_ctypes_add_types(PyObject *mod)
+{
+#define TYPE_READY(TYPE) \
+ if (PyType_Ready(TYPE) < 0) { \
+ return -1; \
+ }
+
+#define TYPE_READY_BASE(TYPE_EXPR, TP_BASE) \
+ do { \
+ PyTypeObject *type = (TYPE_EXPR); \
+ type->tp_base = (TP_BASE); \
+ TYPE_READY(type); \
+ } while (0)
+
+#define MOD_ADD_TYPE(TYPE_EXPR, TP_TYPE, TP_BASE) \
+ do { \
+ PyTypeObject *type = (TYPE_EXPR); \
+ Py_SET_TYPE(type, TP_TYPE); \
+ type->tp_base = TP_BASE; \
+ if (PyModule_AddType(mod, type) < 0) { \
+ return -1; \
+ } \
+ } while (0)
+
+ /* Note:
+ ob_type is the metatype (the 'type'), defaults to PyType_Type,
+ tp_base is the base type, defaults to 'object' aka PyBaseObject_Type.
+ */
+ TYPE_READY(&PyCArg_Type);
+ TYPE_READY(&PyCThunk_Type);
+ TYPE_READY(&PyCData_Type);
/* StgDict is derived from PyDict_Type */
- PyCStgDict_Type.tp_base = &PyDict_Type;
- if (PyType_Ready(&PyCStgDict_Type) < 0)
- return NULL;
+ TYPE_READY_BASE(&PyCStgDict_Type, &PyDict_Type);
/*************************************************
*
* Metaclasses
*/
-
- PyCStructType_Type.tp_base = &PyType_Type;
- if (PyType_Ready(&PyCStructType_Type) < 0)
- return NULL;
-
- UnionType_Type.tp_base = &PyType_Type;
- if (PyType_Ready(&UnionType_Type) < 0)
- return NULL;
-
- PyCPointerType_Type.tp_base = &PyType_Type;
- if (PyType_Ready(&PyCPointerType_Type) < 0)
- return NULL;
-
- PyCArrayType_Type.tp_base = &PyType_Type;
- if (PyType_Ready(&PyCArrayType_Type) < 0)
- return NULL;
-
- PyCSimpleType_Type.tp_base = &PyType_Type;
- if (PyType_Ready(&PyCSimpleType_Type) < 0)
- return NULL;
-
- PyCFuncPtrType_Type.tp_base = &PyType_Type;
- if (PyType_Ready(&PyCFuncPtrType_Type) < 0)
- return NULL;
+ TYPE_READY_BASE(&PyCStructType_Type, &PyType_Type);
+ TYPE_READY_BASE(&UnionType_Type, &PyType_Type);
+ TYPE_READY_BASE(&PyCPointerType_Type, &PyType_Type);
+ TYPE_READY_BASE(&PyCArrayType_Type, &PyType_Type);
+ TYPE_READY_BASE(&PyCSimpleType_Type, &PyType_Type);
+ TYPE_READY_BASE(&PyCFuncPtrType_Type, &PyType_Type);
/*************************************************
*
* Classes using a custom metaclass
*/
- if (PyType_Ready(&PyCData_Type) < 0)
- return NULL;
-
- Py_SET_TYPE(&Struct_Type, &PyCStructType_Type);
- Struct_Type.tp_base = &PyCData_Type;
- if (PyType_Ready(&Struct_Type) < 0)
- return NULL;
- Py_INCREF(&Struct_Type);
- PyModule_AddObject(m, "Structure", (PyObject *)&Struct_Type);
-
- Py_SET_TYPE(&Union_Type, &UnionType_Type);
- Union_Type.tp_base = &PyCData_Type;
- if (PyType_Ready(&Union_Type) < 0)
- return NULL;
- Py_INCREF(&Union_Type);
- PyModule_AddObject(m, "Union", (PyObject *)&Union_Type);
-
- Py_SET_TYPE(&PyCPointer_Type, &PyCPointerType_Type);
- PyCPointer_Type.tp_base = &PyCData_Type;
- if (PyType_Ready(&PyCPointer_Type) < 0)
- return NULL;
- Py_INCREF(&PyCPointer_Type);
- PyModule_AddObject(m, "_Pointer", (PyObject *)&PyCPointer_Type);
-
- Py_SET_TYPE(&PyCArray_Type, &PyCArrayType_Type);
- PyCArray_Type.tp_base = &PyCData_Type;
- if (PyType_Ready(&PyCArray_Type) < 0)
- return NULL;
- Py_INCREF(&PyCArray_Type);
- PyModule_AddObject(m, "Array", (PyObject *)&PyCArray_Type);
-
- Py_SET_TYPE(&Simple_Type, &PyCSimpleType_Type);
- Simple_Type.tp_base = &PyCData_Type;
- if (PyType_Ready(&Simple_Type) < 0)
- return NULL;
- Py_INCREF(&Simple_Type);
- PyModule_AddObject(m, "_SimpleCData", (PyObject *)&Simple_Type);
-
- Py_SET_TYPE(&PyCFuncPtr_Type, &PyCFuncPtrType_Type);
- PyCFuncPtr_Type.tp_base = &PyCData_Type;
- if (PyType_Ready(&PyCFuncPtr_Type) < 0)
- return NULL;
- Py_INCREF(&PyCFuncPtr_Type);
- PyModule_AddObject(m, "CFuncPtr", (PyObject *)&PyCFuncPtr_Type);
+ MOD_ADD_TYPE(&Struct_Type, &PyCStructType_Type, &PyCData_Type);
+ MOD_ADD_TYPE(&Union_Type, &UnionType_Type, &PyCData_Type);
+ MOD_ADD_TYPE(&PyCPointer_Type, &PyCPointerType_Type, &PyCData_Type);
+ MOD_ADD_TYPE(&PyCArray_Type, &PyCArrayType_Type, &PyCData_Type);
+ MOD_ADD_TYPE(&Simple_Type, &PyCSimpleType_Type, &PyCData_Type);
+ MOD_ADD_TYPE(&PyCFuncPtr_Type, &PyCFuncPtrType_Type, &PyCData_Type);
/*************************************************
*
@@ -5808,8 +5733,7 @@ PyInit__ctypes(void)
*/
/* PyCField_Type is derived from PyBaseObject_Type */
- if (PyType_Ready(&PyCField_Type) < 0)
- return NULL;
+ TYPE_READY(&PyCField_Type);
/*************************************************
*
@@ -5817,56 +5741,118 @@ PyInit__ctypes(void)
*/
DictRemover_Type.tp_new = PyType_GenericNew;
- if (PyType_Ready(&DictRemover_Type) < 0)
- return NULL;
-
- if (PyType_Ready(&StructParam_Type) < 0) {
- return NULL;
- }
+ TYPE_READY(&DictRemover_Type);
+ TYPE_READY(&StructParam_Type);
#ifdef MS_WIN32
- if (create_comerror() < 0)
- return NULL;
- PyModule_AddObject(m, "COMError", ComError);
-
- PyModule_AddObject(m, "FUNCFLAG_HRESULT", PyLong_FromLong(FUNCFLAG_HRESULT));
- PyModule_AddObject(m, "FUNCFLAG_STDCALL", PyLong_FromLong(FUNCFLAG_STDCALL));
+ TYPE_READY_BASE(&PyComError_Type, (PyTypeObject*)PyExc_Exception);
#endif
- PyModule_AddObject(m, "FUNCFLAG_CDECL", PyLong_FromLong(FUNCFLAG_CDECL));
- PyModule_AddObject(m, "FUNCFLAG_USE_ERRNO", PyLong_FromLong(FUNCFLAG_USE_ERRNO));
- PyModule_AddObject(m, "FUNCFLAG_USE_LASTERROR", PyLong_FromLong(FUNCFLAG_USE_LASTERROR));
- PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyLong_FromLong(FUNCFLAG_PYTHONAPI));
- PyModule_AddStringConstant(m, "__version__", "1.1.0");
-
- PyModule_AddObject(m, "_memmove_addr", PyLong_FromVoidPtr(memmove));
- PyModule_AddObject(m, "_memset_addr", PyLong_FromVoidPtr(memset));
- PyModule_AddObject(m, "_string_at_addr", PyLong_FromVoidPtr(string_at));
- PyModule_AddObject(m, "_cast_addr", PyLong_FromVoidPtr(cast));
-#ifdef CTYPES_UNICODE
- PyModule_AddObject(m, "_wstring_at_addr", PyLong_FromVoidPtr(wstring_at));
+
+#undef TYPE_READY
+#undef TYPE_READY_BASE
+#undef MOD_ADD_TYPE
+ return 0;
+}
+
+
+static int
+_ctypes_add_objects(PyObject *mod)
+{
+#define MOD_ADD(name, expr) \
+ do { \
+ PyObject *obj = (expr); \
+ if (obj == NULL) { \
+ return -1; \
+ } \
+ if (PyModule_AddObjectRef(mod, name, obj) < 0) { \
+ Py_DECREF(obj); \
+ return -1; \
+ } \
+ Py_DECREF(obj); \
+ } while (0)
+
+ MOD_ADD("_pointer_type_cache", Py_NewRef(_ctypes_ptrtype_cache));
+
+#ifdef MS_WIN32
+ MOD_ADD("COMError", Py_NewRef(ComError));
+ MOD_ADD("FUNCFLAG_HRESULT", PyLong_FromLong(FUNCFLAG_HRESULT));
+ MOD_ADD("FUNCFLAG_STDCALL", PyLong_FromLong(FUNCFLAG_STDCALL));
#endif
+ MOD_ADD("FUNCFLAG_CDECL", PyLong_FromLong(FUNCFLAG_CDECL));
+ MOD_ADD("FUNCFLAG_USE_ERRNO", PyLong_FromLong(FUNCFLAG_USE_ERRNO));
+ MOD_ADD("FUNCFLAG_USE_LASTERROR", PyLong_FromLong(FUNCFLAG_USE_LASTERROR));
+ MOD_ADD("FUNCFLAG_PYTHONAPI", PyLong_FromLong(FUNCFLAG_PYTHONAPI));
+ MOD_ADD("__version__", PyUnicode_FromString("1.1.0"));
+
+ MOD_ADD("_memmove_addr", PyLong_FromVoidPtr(memmove));
+ MOD_ADD("_memset_addr", PyLong_FromVoidPtr(memset));
+ MOD_ADD("_string_at_addr", PyLong_FromVoidPtr(string_at));
+ MOD_ADD("_cast_addr", PyLong_FromVoidPtr(cast));
+ MOD_ADD("_wstring_at_addr", PyLong_FromVoidPtr(wstring_at));
/* If RTLD_LOCAL is not defined (Windows!), set it to zero. */
#if !HAVE_DECL_RTLD_LOCAL
-#define RTLD_LOCAL 0
+# define RTLD_LOCAL 0
#endif
/* If RTLD_GLOBAL is not defined (cygwin), set it to the same value as
- RTLD_LOCAL.
-*/
+ RTLD_LOCAL. */
#if !HAVE_DECL_RTLD_GLOBAL
-#define RTLD_GLOBAL RTLD_LOCAL
+# define RTLD_GLOBAL RTLD_LOCAL
#endif
+ MOD_ADD("RTLD_LOCAL", PyLong_FromLong(RTLD_LOCAL));
+ MOD_ADD("RTLD_GLOBAL", PyLong_FromLong(RTLD_GLOBAL));
+ MOD_ADD("ArgumentError", Py_NewRef(PyExc_ArgError));
+ return 0;
+#undef MOD_ADD
+}
+
+
+static int
+_ctypes_mod_exec(PyObject *mod)
+{
+ _unpickle = PyObject_GetAttrString(mod, "_unpickle");
+ if (_unpickle == NULL) {
+ return -1;
+ }
- PyModule_AddObject(m, "RTLD_LOCAL", PyLong_FromLong(RTLD_LOCAL));
- PyModule_AddObject(m, "RTLD_GLOBAL", PyLong_FromLong(RTLD_GLOBAL));
+ _ctypes_ptrtype_cache = PyDict_New();
+ if (_ctypes_ptrtype_cache == NULL) {
+ return -1;
+ }
PyExc_ArgError = PyErr_NewException("ctypes.ArgumentError", NULL, NULL);
- if (PyExc_ArgError) {
- Py_INCREF(PyExc_ArgError);
- PyModule_AddObject(m, "ArgumentError", PyExc_ArgError);
+ if (!PyExc_ArgError) {
+ return -1;
+ }
+
+ if (_ctypes_add_types(mod) < 0) {
+ return -1;
+ }
+#ifdef MS_WIN32
+ ComError = (PyObject*)&PyComError_Type;
+#endif
+
+ if (_ctypes_add_objects(mod) < 0) {
+ return -1;
+ }
+ return 0;
+}
+
+
+PyMODINIT_FUNC
+PyInit__ctypes(void)
+{
+ PyObject *mod = PyModule_Create(&_ctypesmodule);
+ if (!mod) {
+ return NULL;
+ }
+
+ if (_ctypes_mod_exec(mod) < 0) {
+ Py_DECREF(mod);
+ return NULL;
}
- return m;
+ return mod;
}
/*
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 5cd8577248..654cb93dcf 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -1,6 +1,8 @@
#include "Python.h"
#include "frameobject.h"
+#include <stdbool.h>
+
#include <ffi.h>
#ifdef MS_WIN32
#include <windows.h>
@@ -18,7 +20,7 @@ CThunkObject_dealloc(PyObject *myself)
Py_XDECREF(self->callable);
Py_XDECREF(self->restype);
if (self->pcl_write)
- ffi_closure_free(self->pcl_write);
+ Py_ffi_closure_free(self->pcl_write);
PyObject_GC_Del(self);
}
@@ -362,8 +364,7 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable,
assert(CThunk_CheckExact((PyObject *)p));
- p->pcl_write = ffi_closure_alloc(sizeof(ffi_closure),
- &p->pcl_exec);
+ p->pcl_write = Py_ffi_closure_alloc(sizeof(ffi_closure), &p->pcl_exec);
if (p->pcl_write == NULL) {
PyErr_NoMemory();
goto error;
@@ -409,13 +410,42 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable,
"ffi_prep_cif failed with %d", result);
goto error;
}
-#if defined(X86_DARWIN) || defined(POWERPC_DARWIN)
- result = ffi_prep_closure(p->pcl_write, &p->cif, closure_fcn, p);
+#if HAVE_FFI_PREP_CLOSURE_LOC
+# if USING_APPLE_OS_LIBFFI
+# define HAVE_FFI_PREP_CLOSURE_LOC_RUNTIME __builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)
+# else
+# define HAVE_FFI_PREP_CLOSURE_LOC_RUNTIME 1
+# endif
+ if (HAVE_FFI_PREP_CLOSURE_LOC_RUNTIME) {
+ result = ffi_prep_closure_loc(p->pcl_write, &p->cif, closure_fcn,
+ p,
+ p->pcl_exec);
+ } else
+#endif
+ {
+#if USING_APPLE_OS_LIBFFI && defined(__arm64__)
+ PyErr_Format(PyExc_NotImplementedError, "ffi_prep_closure_loc() is missing");
+ goto error;
#else
- result = ffi_prep_closure_loc(p->pcl_write, &p->cif, closure_fcn,
- p,
- p->pcl_exec);
+#if defined(__clang__) || defined(MACOSX)
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
+#if defined(__GNUC__)
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
+ result = ffi_prep_closure(p->pcl_write, &p->cif, closure_fcn, p);
+
+#if defined(__clang__) || defined(MACOSX)
+ #pragma clang diagnostic pop
+#endif
+#if defined(__GNUC__)
+ #pragma GCC diagnostic pop
+#endif
+
+#endif
+ }
if (result != FFI_OK) {
PyErr_Format(PyExc_RuntimeError,
"ffi_prep_closure failed with %d", result);
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 261ae5ceb9..40a05a44ed 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -57,6 +57,8 @@
#include "Python.h"
#include "structmember.h" // PyMemberDef
+#include <stdbool.h>
+
#ifdef MS_WIN32
#include <windows.h>
#include <tchar.h>
@@ -64,6 +66,10 @@
#include "ctypes_dlfcn.h"
#endif
+#ifdef __APPLE__
+#include <mach-o/dyld.h>
+#endif
+
#ifdef MS_WIN32
#include <malloc.h>
#endif
@@ -248,8 +254,6 @@ set_last_error(PyObject *self, PyObject *args)
return set_error_internal(self, args, 1);
}
-PyObject *ComError;
-
static WCHAR *FormatError(DWORD code)
{
WCHAR *lpMsgBuf;
@@ -471,7 +475,7 @@ static void
PyCArg_dealloc(PyCArgObject *self)
{
Py_XDECREF(self->obj);
- PyObject_Del(self);
+ PyObject_Free(self);
}
static int
@@ -709,7 +713,6 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa)
return 0;
}
-#ifdef CTYPES_UNICODE
if (PyUnicode_Check(obj)) {
pa->ffi_type = &ffi_type_pointer;
pa->value.p = PyUnicode_AsWideCharString(obj, NULL);
@@ -722,7 +725,6 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa)
}
return 0;
}
-#endif
{
_Py_IDENTIFIER(_as_parameter_);
@@ -812,7 +814,8 @@ static int _call_function_pointer(int flags,
ffi_type **atypes,
ffi_type *restype,
void *resmem,
- int argcount)
+ int argcount,
+ int argtypecount)
{
PyThreadState *_save = NULL; /* For Py_BLOCK_THREADS and Py_UNBLOCK_THREADS */
PyObject *error_object = NULL;
@@ -835,14 +838,70 @@ static int _call_function_pointer(int flags,
if ((flags & FUNCFLAG_CDECL) == 0)
cc = FFI_STDCALL;
#endif
- if (FFI_OK != ffi_prep_cif(&cif,
- cc,
- argcount,
- restype,
- atypes)) {
- PyErr_SetString(PyExc_RuntimeError,
- "ffi_prep_cif failed");
- return -1;
+
+# if USING_APPLE_OS_LIBFFI
+# define HAVE_FFI_PREP_CIF_VAR_RUNTIME __builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)
+# elif HAVE_FFI_PREP_CIF_VAR
+# define HAVE_FFI_PREP_CIF_VAR_RUNTIME true
+# else
+# define HAVE_FFI_PREP_CIF_VAR_RUNTIME false
+# endif
+
+ /* Even on Apple-arm64 the calling convention for variadic functions conincides
+ * with the standard calling convention in the case that the function called
+ * only with its fixed arguments. Thus, we do not need a special flag to be
+ * set on variadic functions. We treat a function as variadic if it is called
+ * with a nonzero number of variadic arguments */
+ bool is_variadic = (argtypecount != 0 && argcount > argtypecount);
+ (void) is_variadic;
+
+#if defined(__APPLE__) && defined(__arm64__)
+ if (is_variadic) {
+ if (HAVE_FFI_PREP_CIF_VAR_RUNTIME) {
+ } else {
+ PyErr_SetString(PyExc_NotImplementedError, "ffi_prep_cif_var() is missing");
+ return -1;
+ }
+ }
+#endif
+
+#if HAVE_FFI_PREP_CIF_VAR
+ if (is_variadic) {
+ if (HAVE_FFI_PREP_CIF_VAR_RUNTIME) {
+ if (FFI_OK != ffi_prep_cif_var(&cif,
+ cc,
+ argtypecount,
+ argcount,
+ restype,
+ atypes)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "ffi_prep_cif_var failed");
+ return -1;
+ }
+ } else {
+ if (FFI_OK != ffi_prep_cif(&cif,
+ cc,
+ argcount,
+ restype,
+ atypes)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "ffi_prep_cif failed");
+ return -1;
+ }
+ }
+ } else
+#endif
+
+ {
+ if (FFI_OK != ffi_prep_cif(&cif,
+ cc,
+ argcount,
+ restype,
+ atypes)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "ffi_prep_cif failed");
+ return -1;
+ }
}
if (flags & (FUNCFLAG_USE_ERRNO | FUNCFLAG_USE_LASTERROR)) {
@@ -1212,9 +1271,8 @@ PyObject *_ctypes_callproc(PPROC pProc,
if (-1 == _call_function_pointer(flags, pProc, avalues, atypes,
rtype, resbuf,
- Py_SAFE_DOWNCAST(argcount,
- Py_ssize_t,
- int)))
+ Py_SAFE_DOWNCAST(argcount, Py_ssize_t, int),
+ Py_SAFE_DOWNCAST(argtype_count, Py_ssize_t, int)))
goto cleanup;
#ifdef WORDS_BIGENDIAN
@@ -1398,6 +1456,42 @@ copy_com_pointer(PyObject *self, PyObject *args)
}
#else
+#ifdef HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH
+static PyObject *py_dyld_shared_cache_contains_path(PyObject *self, PyObject *args)
+{
+ PyObject *name, *name2;
+ char *name_str;
+
+ if (__builtin_available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *)) {
+ int r;
+
+ if (!PyArg_ParseTuple(args, "O", &name))
+ return NULL;
+
+ if (name == Py_None)
+ Py_RETURN_FALSE;
+
+ if (PyUnicode_FSConverter(name, &name2) == 0)
+ return NULL;
+ name_str = PyBytes_AS_STRING(name2);
+
+ r = _dyld_shared_cache_contains_path(name_str);
+ Py_DECREF(name2);
+
+ if (r) {
+ Py_RETURN_TRUE;
+ } else {
+ Py_RETURN_FALSE;
+ }
+
+ } else {
+ PyErr_SetString(PyExc_NotImplementedError, "_dyld_shared_cache_contains_path symbol is missing");
+ return NULL;
+ }
+
+ }
+#endif
+
static PyObject *py_dl_open(PyObject *self, PyObject *args)
{
PyObject *name, *name2;
@@ -1887,6 +1981,8 @@ buffer_info(PyObject *self, PyObject *arg)
return Py_BuildValue("siN", dict->format, dict->ndim, shape);
}
+
+
PyMethodDef _ctypes_module_methods[] = {
{"get_errno", get_errno, METH_NOARGS},
{"set_errno", set_errno, METH_VARARGS},
@@ -1909,6 +2005,9 @@ PyMethodDef _ctypes_module_methods[] = {
{"dlclose", py_dl_close, METH_VARARGS, "dlclose a library"},
{"dlsym", py_dl_sym, METH_VARARGS, "find symbol in shared library"},
#endif
+#ifdef HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH
+ {"_dyld_shared_cache_contains_path", py_dyld_shared_cache_contains_path, METH_VARARGS, "check if path is in the shared cache"},
+#endif
{"alignment", align_func, METH_O, alignment_doc},
{"sizeof", sizeof_func, METH_O, sizeof_doc},
{"byref", byref, METH_VARARGS, byref_doc},
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index 98939290fb..5bd96f1eb8 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -125,13 +125,11 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
getfunc = fd->getfunc;
setfunc = fd->setfunc;
}
-#ifdef CTYPES_UNICODE
if (idict->getfunc == _ctypes_get_fielddesc("u")->getfunc) {
struct fielddesc *fd = _ctypes_get_fielddesc("U");
getfunc = fd->getfunc;
setfunc = fd->setfunc;
}
-#endif
}
}
@@ -1137,7 +1135,6 @@ c_get(void *ptr, Py_ssize_t size)
return PyBytes_FromStringAndSize((char *)ptr, 1);
}
-#ifdef CTYPES_UNICODE
/* u - a single wchar_t character */
static PyObject *
u_set(void *ptr, PyObject *value, Py_ssize_t size)
@@ -1232,7 +1229,6 @@ U_set(void *ptr, PyObject *value, Py_ssize_t length)
return value;
}
-#endif
static PyObject *
s_get(void *ptr, Py_ssize_t size)
@@ -1321,7 +1317,6 @@ z_get(void *ptr, Py_ssize_t size)
}
}
-#ifdef CTYPES_UNICODE
static PyObject *
Z_set(void *ptr, PyObject *value, Py_ssize_t size)
{
@@ -1373,7 +1368,7 @@ Z_get(void *ptr, Py_ssize_t size)
Py_RETURN_NONE;
}
}
-#endif
+
#ifdef MS_WIN32
static PyObject *
@@ -1507,11 +1502,9 @@ static struct fielddesc formattable[] = {
#endif
{ 'P', P_set, P_get, &ffi_type_pointer},
{ 'z', z_set, z_get, &ffi_type_pointer},
-#ifdef CTYPES_UNICODE
{ 'u', u_set, u_get, NULL}, /* ffi_type set later */
{ 'U', U_set, U_get, &ffi_type_pointer},
{ 'Z', Z_set, Z_get, &ffi_type_pointer},
-#endif
#ifdef MS_WIN32
{ 'X', BSTR_set, BSTR_get, &ffi_type_pointer},
#endif
@@ -1544,14 +1537,12 @@ _ctypes_get_fielddesc(const char *fmt)
if (!initialized) {
initialized = 1;
-#ifdef CTYPES_UNICODE
if (sizeof(wchar_t) == sizeof(short))
_ctypes_get_fielddesc("u")->pffi_type = &ffi_type_sshort;
else if (sizeof(wchar_t) == sizeof(int))
_ctypes_get_fielddesc("u")->pffi_type = &ffi_type_sint;
else if (sizeof(wchar_t) == sizeof(long))
_ctypes_get_fielddesc("u")->pffi_type = &ffi_type_slong;
-#endif
}
for (; table->code; ++table) {
diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h
index 1effccf9cc..6110027980 100644
--- a/Modules/_ctypes/ctypes.h
+++ b/Modules/_ctypes/ctypes.h
@@ -343,10 +343,6 @@ extern PyObject *PyExc_ArgError;
extern char *_ctypes_conversion_encoding;
extern char *_ctypes_conversion_errors;
-#if defined(HAVE_WCHAR_H)
-# define CTYPES_UNICODE
-#endif
-
extern void _ctypes_free_closure(void *);
extern void *_ctypes_alloc_closure(void);
@@ -366,6 +362,14 @@ PyObject *_ctypes_get_errobj(int **pspace);
extern PyObject *ComError;
#endif
+#if USING_MALLOC_CLOSURE_DOT_C
+void Py_ffi_closure_free(void *p);
+void *Py_ffi_closure_alloc(size_t size, void** codeloc);
+#else
+#define Py_ffi_closure_free ffi_closure_free
+#define Py_ffi_closure_alloc ffi_closure_alloc
+#endif
+
/*
Local Variables:
compile-command: "python setup.py -q build install --home ~"
diff --git a/Modules/_ctypes/malloc_closure.c b/Modules/_ctypes/malloc_closure.c
index f9cdb33695..788bae6a96 100644
--- a/Modules/_ctypes/malloc_closure.c
+++ b/Modules/_ctypes/malloc_closure.c
@@ -89,16 +89,35 @@ static void more_core(void)
/******************************************************************/
/* put the item back into the free list */
-void ffi_closure_free(void *p)
+void Py_ffi_closure_free(void *p)
{
+#if HAVE_FFI_CLOSURE_ALLOC
+#if USING_APPLE_OS_LIBFFI
+ if (__builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)) {
+#endif
+ ffi_closure_free(p);
+ return;
+#if USING_APPLE_OS_LIBFFI
+ }
+#endif
+#endif
ITEM *item = (ITEM *)p;
item->next = free_list;
free_list = item;
}
/* return one item from the free list, allocating more if needed */
-void *ffi_closure_alloc(size_t ignored, void** codeloc)
+void *Py_ffi_closure_alloc(size_t size, void** codeloc)
{
+#if HAVE_FFI_CLOSURE_ALLOC
+#if USING_APPLE_OS_LIBFFI
+ if (__builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *)) {
+#endif
+ return ffi_closure_alloc(size, codeloc);
+#if USING_APPLE_OS_LIBFFI
+ }
+#endif
+#endif
ITEM *item;
if (!free_list)
more_core();
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index 443951a6b0..747339dee3 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -538,9 +538,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
case FFI_TYPE_SINT16:
case FFI_TYPE_SINT32:
if (dict->getfunc != _ctypes_get_fielddesc("c")->getfunc
-#ifdef CTYPES_UNICODE
&& dict->getfunc != _ctypes_get_fielddesc("u")->getfunc
-#endif
)
break;
/* else fall through */
diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c
index 1a8f0b6368..d782ccd086 100644
--- a/Modules/_curses_panel.c
+++ b/Modules/_curses_panel.c
@@ -282,7 +282,7 @@ PyCursesPanel_Dealloc(PyCursesPanelObject *po)
Py_DECREF(po->wo);
remove_lop(po);
}
- PyObject_DEL(po);
+ PyObject_Free(po);
Py_DECREF(tp);
}
@@ -654,6 +654,7 @@ _curses_panel_exec(PyObject *mod)
if (state->PyCursesPanel_Type == NULL) {
return -1;
}
+ ((PyTypeObject *)state->PyCursesPanel_Type)->tp_new = NULL;
if (PyModule_AddType(mod, state->PyCursesPanel_Type) < 0) {
return -1;
@@ -715,4 +716,4 @@ PyMODINIT_FUNC
PyInit__curses_panel(void)
{
return PyModuleDef_Init(&_curses_panelmodule);
-} \ No newline at end of file
+}
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index a59858632e..1f4789baf7 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -689,7 +689,7 @@ PyCursesWindow_Dealloc(PyCursesWindowObject *wo)
if (wo->win != stdscr) delwin(wo->win);
if (wo->encoding != NULL)
PyMem_Free(wo->encoding);
- PyObject_DEL(wo);
+ PyObject_Free(wo);
}
/* Addch, Addstr, Addnstr */
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index e59f89b3d1..c3e0b52baa 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -6494,32 +6494,9 @@ static PyDateTime_CAPI CAPI = {
new_time_ex2
};
-
-
-static struct PyModuleDef datetimemodule = {
- PyModuleDef_HEAD_INIT,
- "_datetime",
- "Fast implementation of the datetime type.",
- -1,
- module_methods,
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-PyMODINIT_FUNC
-PyInit__datetime(void)
+static int
+_datetime_exec(PyObject *module)
{
- PyObject *m; /* a module object */
- PyObject *d; /* its dict */
- PyObject *x;
- PyObject *delta;
-
- m = PyModule_Create(&datetimemodule);
- if (m == NULL)
- return NULL;
-
// `&...` is not a constant expression according to a strict reading
// of C standards. Fill tp_base at run-time rather than statically.
// See https://bugs.python.org/issue40777
@@ -6537,98 +6514,72 @@ PyInit__datetime(void)
};
for (size_t i = 0; i < Py_ARRAY_LENGTH(types); i++) {
- if (PyModule_AddType(m, types[i]) < 0) {
- return NULL;
+ if (PyModule_AddType(module, types[i]) < 0) {
+ return -1;
}
}
if (PyType_Ready(&PyDateTime_IsoCalendarDateType) < 0) {
- return NULL;
+ return -1;
}
- Py_INCREF(&PyDateTime_IsoCalendarDateType);
-
- /* timedelta values */
- d = PyDateTime_DeltaType.tp_dict;
-
- x = new_delta(0, 0, 1, 0);
- if (x == NULL || PyDict_SetItemString(d, "resolution", x) < 0)
- return NULL;
- Py_DECREF(x);
- x = new_delta(-MAX_DELTA_DAYS, 0, 0, 0);
- if (x == NULL || PyDict_SetItemString(d, "min", x) < 0)
- return NULL;
- Py_DECREF(x);
+#define DATETIME_ADD_MACRO(dict, c, value_expr) \
+ do { \
+ PyObject *value = (value_expr); \
+ if (value == NULL) { \
+ return -1; \
+ } \
+ if (PyDict_SetItemString(dict, c, value) < 0) { \
+ Py_DECREF(value); \
+ return -1; \
+ } \
+ Py_DECREF(value); \
+ } while(0)
- x = new_delta(MAX_DELTA_DAYS, 24*3600-1, 1000000-1, 0);
- if (x == NULL || PyDict_SetItemString(d, "max", x) < 0)
- return NULL;
- Py_DECREF(x);
+ /* timedelta values */
+ PyObject *d = PyDateTime_DeltaType.tp_dict;
+ DATETIME_ADD_MACRO(d, "resolution", new_delta(0, 0, 1, 0));
+ DATETIME_ADD_MACRO(d, "min", new_delta(-MAX_DELTA_DAYS, 0, 0, 0));
+ DATETIME_ADD_MACRO(d, "max",
+ new_delta(MAX_DELTA_DAYS, 24*3600-1, 1000000-1, 0));
/* date values */
d = PyDateTime_DateType.tp_dict;
-
- x = new_date(1, 1, 1);
- if (x == NULL || PyDict_SetItemString(d, "min", x) < 0)
- return NULL;
- Py_DECREF(x);
-
- x = new_date(MAXYEAR, 12, 31);
- if (x == NULL || PyDict_SetItemString(d, "max", x) < 0)
- return NULL;
- Py_DECREF(x);
-
- x = new_delta(1, 0, 0, 0);
- if (x == NULL || PyDict_SetItemString(d, "resolution", x) < 0)
- return NULL;
- Py_DECREF(x);
+ DATETIME_ADD_MACRO(d, "min", new_date(1, 1, 1));
+ DATETIME_ADD_MACRO(d, "max", new_date(MAXYEAR, 12, 31));
+ DATETIME_ADD_MACRO(d, "resolution", new_delta(1, 0, 0, 0));
/* time values */
d = PyDateTime_TimeType.tp_dict;
-
- x = new_time(0, 0, 0, 0, Py_None, 0);
- if (x == NULL || PyDict_SetItemString(d, "min", x) < 0)
- return NULL;
- Py_DECREF(x);
-
- x = new_time(23, 59, 59, 999999, Py_None, 0);
- if (x == NULL || PyDict_SetItemString(d, "max", x) < 0)
- return NULL;
- Py_DECREF(x);
-
- x = new_delta(0, 0, 1, 0);
- if (x == NULL || PyDict_SetItemString(d, "resolution", x) < 0)
- return NULL;
- Py_DECREF(x);
+ DATETIME_ADD_MACRO(d, "min", new_time(0, 0, 0, 0, Py_None, 0));
+ DATETIME_ADD_MACRO(d, "max", new_time(23, 59, 59, 999999, Py_None, 0));
+ DATETIME_ADD_MACRO(d, "resolution", new_delta(0, 0, 1, 0));
/* datetime values */
d = PyDateTime_DateTimeType.tp_dict;
-
- x = new_datetime(1, 1, 1, 0, 0, 0, 0, Py_None, 0);
- if (x == NULL || PyDict_SetItemString(d, "min", x) < 0)
- return NULL;
- Py_DECREF(x);
-
- x = new_datetime(MAXYEAR, 12, 31, 23, 59, 59, 999999, Py_None, 0);
- if (x == NULL || PyDict_SetItemString(d, "max", x) < 0)
- return NULL;
- Py_DECREF(x);
-
- x = new_delta(0, 0, 1, 0);
- if (x == NULL || PyDict_SetItemString(d, "resolution", x) < 0)
- return NULL;
- Py_DECREF(x);
+ DATETIME_ADD_MACRO(d, "min",
+ new_datetime(1, 1, 1, 0, 0, 0, 0, Py_None, 0));
+ DATETIME_ADD_MACRO(d, "max", new_datetime(MAXYEAR, 12, 31, 23, 59, 59,
+ 999999, Py_None, 0));
+ DATETIME_ADD_MACRO(d, "resolution", new_delta(0, 0, 1, 0));
/* timezone values */
d = PyDateTime_TimeZoneType.tp_dict;
+ PyObject *delta = new_delta(0, 0, 0, 0);
+ if (delta == NULL) {
+ return -1;
+ }
- delta = new_delta(0, 0, 0, 0);
- if (delta == NULL)
- return NULL;
- x = create_timezone(delta, NULL);
+ PyObject *x = create_timezone(delta, NULL);
Py_DECREF(delta);
- if (x == NULL || PyDict_SetItemString(d, "utc", x) < 0)
- return NULL;
+ if (x == NULL) {
+ return -1;
+ }
+ if (PyDict_SetItemString(d, "utc", x) < 0) {
+ Py_DECREF(x);
+ return -1;
+ }
+
PyDateTime_TimeZone_UTC = x;
CAPI.TimeZone_UTC = PyDateTime_TimeZone_UTC;
@@ -6636,37 +6587,47 @@ PyInit__datetime(void)
* compatibility, even though the constructor will accept a wider range of
* values. This may change in the future.*/
delta = new_delta(-1, 60, 0, 1); /* -23:59 */
- if (delta == NULL)
- return NULL;
+ if (delta == NULL) {
+ return -1;
+ }
+
x = create_timezone(delta, NULL);
Py_DECREF(delta);
- if (x == NULL || PyDict_SetItemString(d, "min", x) < 0)
- return NULL;
- Py_DECREF(x);
+ DATETIME_ADD_MACRO(d, "min", x);
delta = new_delta(0, (23 * 60 + 59) * 60, 0, 0); /* +23:59 */
- if (delta == NULL)
- return NULL;
+ if (delta == NULL) {
+ return -1;
+ }
+
x = create_timezone(delta, NULL);
Py_DECREF(delta);
- if (x == NULL || PyDict_SetItemString(d, "max", x) < 0)
- return NULL;
- Py_DECREF(x);
+ DATETIME_ADD_MACRO(d, "max", x);
/* Epoch */
PyDateTime_Epoch = new_datetime(1970, 1, 1, 0, 0, 0, 0,
PyDateTime_TimeZone_UTC, 0);
- if (PyDateTime_Epoch == NULL)
- return NULL;
+ if (PyDateTime_Epoch == NULL) {
+ return -1;
+ }
/* module initialization */
- PyModule_AddIntMacro(m, MINYEAR);
- PyModule_AddIntMacro(m, MAXYEAR);
+ if (PyModule_AddIntMacro(module, MINYEAR) < 0) {
+ return -1;
+ }
+ if (PyModule_AddIntMacro(module, MAXYEAR) < 0) {
+ return -1;
+ }
x = PyCapsule_New(&CAPI, PyDateTime_CAPSULE_NAME, NULL);
- if (x == NULL)
- return NULL;
- PyModule_AddObject(m, "datetime_CAPI", x);
+ if (x == NULL) {
+ return -1;
+ }
+
+ if (PyModule_AddObject(module, "datetime_CAPI", x) < 0) {
+ Py_DECREF(x);
+ return -1;
+ }
/* A 4-year cycle has an extra leap day over what we'd get from
* pasting together 4 single years.
@@ -6691,8 +6652,9 @@ PyInit__datetime(void)
us_per_minute = PyLong_FromLong(60000000);
seconds_per_day = PyLong_FromLong(24 * 3600);
if (us_per_ms == NULL || us_per_second == NULL ||
- us_per_minute == NULL || seconds_per_day == NULL)
- return NULL;
+ us_per_minute == NULL || seconds_per_day == NULL) {
+ return -1;
+ }
/* The rest are too big for 32-bit ints, but even
* us_per_week fits in 40 bits, so doubles should be exact.
@@ -6700,9 +6662,33 @@ PyInit__datetime(void)
us_per_hour = PyLong_FromDouble(3600000000.0);
us_per_day = PyLong_FromDouble(86400000000.0);
us_per_week = PyLong_FromDouble(604800000000.0);
- if (us_per_hour == NULL || us_per_day == NULL || us_per_week == NULL)
+ if (us_per_hour == NULL || us_per_day == NULL || us_per_week == NULL) {
+ return -1;
+ }
+ return 0;
+}
+
+static struct PyModuleDef datetimemodule = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "_datetime",
+ .m_doc = "Fast implementation of the datetime type.",
+ .m_size = -1,
+ .m_methods = module_methods,
+};
+
+PyMODINIT_FUNC
+PyInit__datetime(void)
+{
+ PyObject *mod = PyModule_Create(&datetimemodule);
+ if (mod == NULL)
return NULL;
- return m;
+
+ if (_datetime_exec(mod) < 0) {
+ Py_DECREF(mod);
+ return NULL;
+ }
+
+ return mod;
}
/* ---------------------------------------------------------------------------
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index ea16c5a6cd..9c85d76c6b 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -1765,7 +1765,7 @@ ctxmanager_dealloc(PyDecContextManagerObject *self)
{
Py_XDECREF(self->local);
Py_XDECREF(self->global);
- PyObject_Del(self);
+ PyObject_Free(self);
}
static PyObject *
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index 9fad21fc33..621b721d01 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -1,5 +1,6 @@
#include "Python.h"
#include "pycore_long.h" // _PyLong_GetZero()
+#include "pycore_object.h" // _PyObject_GC_TRACK
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_tuple.h" // _PyTuple_ITEMS()
#include "structmember.h" // PyMemberDef
@@ -478,7 +479,7 @@ keyobject_dealloc(keyobject *ko)
{
Py_DECREF(ko->cmp);
Py_XDECREF(ko->object);
- PyObject_FREE(ko);
+ PyObject_Free(ko);
}
static int
@@ -673,6 +674,11 @@ functools_reduce(PyObject *self, PyObject *args)
if ((result = PyObject_Call(func, args, NULL)) == NULL) {
goto Fail;
}
+ // bpo-42536: The GC may have untracked this args tuple. Since we're
+ // recycling it, make sure it's tracked again:
+ if (!_PyObject_GC_IS_TRACKED(args)) {
+ _PyObject_GC_TRACK(args);
+ }
}
}
@@ -742,7 +748,7 @@ lru_list_elem_dealloc(lru_list_elem *link)
{
Py_XDECREF(link->key);
Py_XDECREF(link->result);
- PyObject_Del(link);
+ PyObject_Free(link);
}
static PyTypeObject lru_list_elem_type = {
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index adc8653773..d4295d7c36 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -341,7 +341,7 @@ EVP_dealloc(EVPobject *self)
if (self->lock != NULL)
PyThread_free_lock(self->lock);
EVP_MD_CTX_free(self->ctx);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(tp);
}
@@ -1453,7 +1453,7 @@ _hashlib_hmac_new_impl(PyObject *module, Py_buffer *key, PyObject *msg_obj,
error:
if (ctx) HMAC_CTX_free(ctx);
- if (self) PyObject_Del(self);
+ if (self) PyObject_Free(self);
return NULL;
}
@@ -1546,7 +1546,7 @@ _hmac_dealloc(HMACobject *self)
PyThread_free_lock(self->lock);
}
HMAC_CTX_free(self->ctx);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(tp);
}
@@ -2038,21 +2038,14 @@ hashlib_init_evpxoftype(PyObject *module)
{
#ifdef PY_OPENSSL_HAS_SHAKE
_hashlibstate *state = get_hashlib_state(module);
- PyObject *bases;
if (state->EVPtype == NULL) {
return -1;
}
- bases = PyTuple_Pack(1, state->EVPtype);
- if (bases == NULL) {
- return -1;
- }
-
state->EVPXOFtype = (PyTypeObject *)PyType_FromSpecWithBases(
- &EVPXOFtype_spec, bases
+ &EVPXOFtype_spec, (PyObject *)state->EVPtype
);
- Py_DECREF(bases);
if (state->EVPXOFtype == NULL) {
return -1;
}
@@ -2078,7 +2071,6 @@ hashlib_init_hmactype(PyObject *module)
return 0;
}
-#if 0
static PyModuleDef_Slot hashlib_slots[] = {
/* OpenSSL 1.0.2 and LibreSSL */
{Py_mod_exec, hashlib_openssl_legacy_init},
@@ -2088,7 +2080,6 @@ static PyModuleDef_Slot hashlib_slots[] = {
{Py_mod_exec, hashlib_md_meth_names},
{0, NULL}
};
-#endif
static struct PyModuleDef _hashlibmodule = {
PyModuleDef_HEAD_INIT,
@@ -2096,7 +2087,7 @@ static struct PyModuleDef _hashlibmodule = {
.m_doc = "OpenSSL interface for hashlib module",
.m_size = sizeof(_hashlibstate),
.m_methods = EVP_functions,
- .m_slots = NULL,
+ .m_slots = hashlib_slots,
.m_traverse = hashlib_traverse,
.m_clear = hashlib_clear,
.m_free = hashlib_free
@@ -2105,37 +2096,5 @@ static struct PyModuleDef _hashlibmodule = {
PyMODINIT_FUNC
PyInit__hashlib(void)
{
- PyObject *m = PyState_FindModule(&_hashlibmodule);
- if (m != NULL) {
- Py_INCREF(m);
- return m;
- }
-
- m = PyModule_Create(&_hashlibmodule);
- if (m == NULL) {
- return NULL;
- }
-
- if (hashlib_openssl_legacy_init(m) < 0) {
- Py_DECREF(m);
- return NULL;
- }
- if (hashlib_init_evptype(m) < 0) {
- Py_DECREF(m);
- return NULL;
- }
- if (hashlib_init_evpxoftype(m) < 0) {
- Py_DECREF(m);
- return NULL;
- }
- if (hashlib_init_hmactype(m) < 0) {
- Py_DECREF(m);
- return NULL;
- }
- if (hashlib_md_meth_names(m) == -1) {
- Py_DECREF(m);
- return NULL;
- }
-
- return m;
+ return PyModuleDef_Init(&_hashlibmodule);
}
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index 7b3597e060..564f5598ed 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -370,8 +370,8 @@ _locale_strcoll_impl(PyObject *module, PyObject *os1, PyObject *os2)
result = PyLong_FromLong(wcscoll(ws1, ws2));
done:
/* Deallocate everything. */
- if (ws1) PyMem_FREE(ws1);
- if (ws2) PyMem_FREE(ws2);
+ if (ws1) PyMem_Free(ws1);
+ if (ws2) PyMem_Free(ws2);
return result;
}
#endif
@@ -556,7 +556,6 @@ static struct langinfo_constant{
LANGINFO(PM_STR),
/* The following constants are available only with XPG4, but...
- AIX 3.2. only has CODESET.
OpenBSD doesn't have CODESET but has T_FMT_AMPM, and doesn't have
a few of the others.
Solution: ifdef-test them all. */
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 78d464d148..c32699cb8a 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -489,15 +489,15 @@ static PyStructSequence_Field profiler_subentry_fields[] = {
static PyStructSequence_Desc profiler_entry_desc = {
.name = "_lsprof.profiler_entry",
- .doc = "",
.fields = profiler_entry_fields,
+ .doc = NULL,
.n_in_sequence = 6
};
static PyStructSequence_Desc profiler_subentry_desc = {
.name = "_lsprof.profiler_subentry",
- .doc = "",
.fields = profiler_subentry_fields,
+ .doc = NULL,
.n_in_sequence = 5
};
diff --git a/Modules/_multiprocessing/posixshmem.c b/Modules/_multiprocessing/posixshmem.c
index 436ac6d6b3..d64ded4168 100644
--- a/Modules/_multiprocessing/posixshmem.c
+++ b/Modules/_multiprocessing/posixshmem.c
@@ -110,21 +110,17 @@ static PyMethodDef module_methods[ ] = {
};
-static struct PyModuleDef this_module = {
- PyModuleDef_HEAD_INIT, // m_base
- "_posixshmem", // m_name
- "POSIX shared memory module", // m_doc
- -1, // m_size (space allocated for module globals)
- module_methods, // m_methods
+static struct PyModuleDef _posixshmemmodule = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "_posixshmem",
+ .m_doc = "POSIX shared memory module",
+ .m_size = 0,
+ .m_methods = module_methods,
};
/* Module init function */
PyMODINIT_FUNC
-PyInit__posixshmem(void) {
- PyObject *module;
- module = PyModule_Create(&this_module);
- if (!module) {
- return NULL;
- }
- return module;
+PyInit__posixshmem(void)
+{
+ return PyModuleDef_Init(&_posixshmemmodule);
}
diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c
index 8732750e11..9a2d1f85c9 100644
--- a/Modules/_multiprocessing/semaphore.c
+++ b/Modules/_multiprocessing/semaphore.c
@@ -571,7 +571,7 @@ semlock_dealloc(SemLockObject* self)
if (self->handle != SEM_FAILED)
SEM_CLOSE(self->handle);
PyMem_Free(self->name);
- PyObject_Del(self);
+ PyObject_Free(self);
}
/*[clinic input]
diff --git a/Modules/_operator.c b/Modules/_operator.c
index c9d38aa342..da1e43158e 100644
--- a/Modules/_operator.c
+++ b/Modules/_operator.c
@@ -749,7 +749,7 @@ _tscmp(const unsigned char *a, const unsigned char *b,
volatile const unsigned char *left;
volatile const unsigned char *right;
Py_ssize_t i;
- unsigned char result;
+ volatile unsigned char result;
/* loop count depends on length of b */
length = len_b;
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index ed8afefe4c..5a8aad9de7 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -442,8 +442,8 @@ Pdata_dealloc(Pdata *self)
while (--i >= 0) {
Py_DECREF(self->data[i]);
}
- PyMem_FREE(self->data);
- PyObject_Del(self);
+ PyMem_Free(self->data);
+ PyObject_Free(self);
}
static PyTypeObject Pdata_Type = {
@@ -465,7 +465,7 @@ Pdata_New(void)
self->mark_set = 0;
self->fence = 0;
self->allocated = 8;
- self->data = PyMem_MALLOC(self->allocated * sizeof(PyObject *));
+ self->data = PyMem_Malloc(self->allocated * sizeof(PyObject *));
if (self->data)
return (PyObject *)self;
Py_DECREF(self);
@@ -726,7 +726,7 @@ static PyTypeObject Unpickler_Type;
static PyMemoTable *
PyMemoTable_New(void)
{
- PyMemoTable *memo = PyMem_MALLOC(sizeof(PyMemoTable));
+ PyMemoTable *memo = PyMem_Malloc(sizeof(PyMemoTable));
if (memo == NULL) {
PyErr_NoMemory();
return NULL;
@@ -735,9 +735,9 @@ PyMemoTable_New(void)
memo->mt_used = 0;
memo->mt_allocated = MT_MINSIZE;
memo->mt_mask = MT_MINSIZE - 1;
- memo->mt_table = PyMem_MALLOC(MT_MINSIZE * sizeof(PyMemoEntry));
+ memo->mt_table = PyMem_Malloc(MT_MINSIZE * sizeof(PyMemoEntry));
if (memo->mt_table == NULL) {
- PyMem_FREE(memo);
+ PyMem_Free(memo);
PyErr_NoMemory();
return NULL;
}
@@ -758,10 +758,10 @@ PyMemoTable_Copy(PyMemoTable *self)
new->mt_mask = self->mt_mask;
/* The table we get from _New() is probably smaller than we wanted.
Free it and allocate one that's the right size. */
- PyMem_FREE(new->mt_table);
+ PyMem_Free(new->mt_table);
new->mt_table = PyMem_NEW(PyMemoEntry, self->mt_allocated);
if (new->mt_table == NULL) {
- PyMem_FREE(new);
+ PyMem_Free(new);
PyErr_NoMemory();
return NULL;
}
@@ -800,8 +800,8 @@ PyMemoTable_Del(PyMemoTable *self)
return;
PyMemoTable_Clear(self);
- PyMem_FREE(self->mt_table);
- PyMem_FREE(self);
+ PyMem_Free(self->mt_table);
+ PyMem_Free(self);
}
/* Since entries cannot be deleted from this hashtable, _PyMemoTable_Lookup()
@@ -880,7 +880,7 @@ _PyMemoTable_ResizeTable(PyMemoTable *self, size_t min_size)
}
/* Deallocate the old table. */
- PyMem_FREE(oldtable);
+ PyMem_Free(oldtable);
return 0;
}
@@ -1582,7 +1582,7 @@ _Unpickler_MemoCleanup(UnpicklerObject *self)
while (--i >= 0) {
Py_XDECREF(memo[i]);
}
- PyMem_FREE(memo);
+ PyMem_Free(memo);
}
static UnpicklerObject *
@@ -7544,7 +7544,7 @@ Unpickler_set_memo(UnpicklerObject *self, PyObject *obj, void *Py_UNUSED(ignored
for (size_t i = new_memo_size - 1; i != SIZE_MAX; i--) {
Py_XDECREF(new_memo[i]);
}
- PyMem_FREE(new_memo);
+ PyMem_Free(new_memo);
}
return -1;
}
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index a00e13739a..46c41d3c20 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -55,7 +55,7 @@
# endif
#endif
-#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(__MACH__))
+#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__DragonFly__)
# define FD_DIR "/dev/fd"
#else
# define FD_DIR "/proc/self/fd"
@@ -85,11 +85,9 @@ get_posixsubprocess_state(PyObject *module)
return (_posixsubprocessstate *)state;
}
-#define _posixsubprocessstate_global get_posixsubprocess_state(PyState_FindModule(&_posixsubprocessmodule))
-
/* If gc was disabled, call gc.enable(). Ignore errors. */
static void
-_enable_gc(int need_to_reenable_gc, PyObject *gc_module)
+_enable_gc(int need_to_reenable_gc, PyObject *gc_module, _posixsubprocessstate *state)
{
PyObject *result;
PyObject *exctype, *val, *tb;
@@ -97,7 +95,7 @@ _enable_gc(int need_to_reenable_gc, PyObject *gc_module)
if (need_to_reenable_gc) {
PyErr_Fetch(&exctype, &val, &tb);
result = PyObject_CallMethodNoArgs(
- gc_module, _posixsubprocessstate_global->enable);
+ gc_module, state->enable);
if (result == NULL) {
/* We might have created a child process at this point, we
* we have no good way to handle a failure to reenable GC
@@ -127,9 +125,9 @@ _pos_int_from_ascii(const char *name)
}
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
/* When /dev/fd isn't mounted it is often a static directory populated
- * with 0 1 2 or entries for 0 .. 63 on FreeBSD, NetBSD and OpenBSD.
+ * with 0 1 2 or entries for 0 .. 63 on FreeBSD, NetBSD, OpenBSD and DragonFlyBSD.
* NetBSD and OpenBSD have a /proc fs available (though not necessarily
* mounted) and do not have fdescfs for /dev/fd. MacOS X has a devfs
* that properly supports /dev/fd.
@@ -377,7 +375,7 @@ _close_open_fds_maybe_unsafe(long start_fd, PyObject* py_fds_to_keep)
++start_fd;
#endif
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
if (!_is_fdescfs_mounted_on_dev_fd())
proc_fd_dir = NULL;
else
@@ -758,7 +756,7 @@ do_fork_exec(char *const exec_array[],
static PyObject *
-subprocess_fork_exec(PyObject* self, PyObject *args)
+subprocess_fork_exec(PyObject *module, PyObject *args)
{
PyObject *gc_module = NULL;
PyObject *executable_list, *py_fds_to_keep;
@@ -782,6 +780,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
Py_ssize_t arg_num, num_groups = 0;
int need_after_fork = 0;
int saved_errno = 0;
+ _posixsubprocessstate *state = get_posixsubprocess_state(module);
if (!PyArg_ParseTuple(
args, "OOpO!OOiiiiiiiiiiOOOiO:fork_exec",
@@ -827,7 +826,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
if (gc_module == NULL)
return NULL;
result = PyObject_CallMethodNoArgs(
- gc_module, _posixsubprocessstate_global->isenabled);
+ gc_module, state->isenabled);
if (result == NULL) {
Py_DECREF(gc_module);
return NULL;
@@ -839,7 +838,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
return NULL;
}
result = PyObject_CallMethodNoArgs(
- gc_module, _posixsubprocessstate_global->disable);
+ gc_module, state->disable);
if (result == NULL) {
Py_DECREF(gc_module);
return NULL;
@@ -1073,7 +1072,7 @@ cleanup:
if (exec_array)
_Py_FreeCharPArray(exec_array);
- _enable_gc(need_to_reenable_gc, gc_module);
+ _enable_gc(need_to_reenable_gc, gc_module, state);
Py_XDECREF(gc_module);
return pid == -1 ? NULL : PyLong_FromPid(pid);
@@ -1113,12 +1112,38 @@ Raises: Only on an error in the parent process.\n\
PyDoc_STRVAR(module_doc,
"A POSIX helper for the subprocess module.");
+static int
+_posixsubprocess_exec(PyObject *module)
+{
+ _posixsubprocessstate *state = get_posixsubprocess_state(module);
+
+ state->disable = PyUnicode_InternFromString("disable");
+ if (state->disable == NULL) {
+ return -1;
+ }
+
+ state->enable = PyUnicode_InternFromString("enable");
+ if (state->enable == NULL) {
+ return -1;
+ }
+
+ state->isenabled = PyUnicode_InternFromString("isenabled");
+ if (state->isenabled == NULL) {
+ return -1;
+ }
+
+ return 0;
+}
static PyMethodDef module_methods[] = {
{"fork_exec", subprocess_fork_exec, METH_VARARGS, subprocess_fork_exec_doc},
{NULL, NULL} /* sentinel */
};
+static PyModuleDef_Slot _posixsubprocess_slots[] = {
+ {Py_mod_exec, _posixsubprocess_exec},
+ {0, NULL}
+};
static int _posixsubprocess_traverse(PyObject *m, visitproc visit, void *arg) {
Py_VISIT(get_posixsubprocess_state(m)->disable);
@@ -1140,36 +1165,18 @@ static void _posixsubprocess_free(void *m) {
static struct PyModuleDef _posixsubprocessmodule = {
PyModuleDef_HEAD_INIT,
- "_posixsubprocess",
- module_doc,
- sizeof(_posixsubprocessstate),
- module_methods,
- NULL,
- _posixsubprocess_traverse,
- _posixsubprocess_clear,
- _posixsubprocess_free,
+ .m_name = "_posixsubprocess",
+ .m_doc = module_doc,
+ .m_size = sizeof(_posixsubprocessstate),
+ .m_methods = module_methods,
+ .m_slots = _posixsubprocess_slots,
+ .m_traverse = _posixsubprocess_traverse,
+ .m_clear = _posixsubprocess_clear,
+ .m_free = _posixsubprocess_free,
};
PyMODINIT_FUNC
PyInit__posixsubprocess(void)
{
- PyObject* m;
-
- m = PyState_FindModule(&_posixsubprocessmodule);
- if (m != NULL) {
- Py_INCREF(m);
- return m;
- }
-
- m = PyModule_Create(&_posixsubprocessmodule);
- if (m == NULL) {
- return NULL;
- }
-
- get_posixsubprocess_state(m)->disable = PyUnicode_InternFromString("disable");
- get_posixsubprocess_state(m)->enable = PyUnicode_InternFromString("enable");
- get_posixsubprocess_state(m)->isenabled = PyUnicode_InternFromString("isenabled");
-
- PyState_AddModule(m, &_posixsubprocessmodule);
- return m;
+ return PyModuleDef_Init(&_posixsubprocessmodule);
}
diff --git a/Modules/_queuemodule.c b/Modules/_queuemodule.c
index b155ea9423..a2b6ac87a7 100644
--- a/Modules/_queuemodule.c
+++ b/Modules/_queuemodule.c
@@ -1,16 +1,22 @@
#include "Python.h"
+#include "structmember.h" // PyMemberDef
#include <stddef.h> // offsetof()
-/*[clinic input]
-module _queue
-class _queue.SimpleQueue "simplequeueobject *" "&PySimpleQueueType"
-[clinic start generated code]*/
-/*[clinic end generated code: output=da39a3ee5e6b4b0d input=cf49af81bcbbbea6]*/
-
-static PyTypeObject PySimpleQueueType; /* forward decl */
-
-static PyObject *EmptyError;
+typedef struct {
+ PyTypeObject *SimpleQueueType;
+ PyObject *EmptyError;
+} simplequeue_state;
+static simplequeue_state *
+simplequeue_get_state(PyObject *module)
+{
+ simplequeue_state *state = PyModule_GetState(module);
+ assert(state);
+ return state;
+}
+static struct PyModuleDef queuemodule;
+#define simplequeue_get_state_by_type(tp) \
+ (simplequeue_get_state(_PyType_GetModuleByDef(type, &queuemodule)))
typedef struct {
PyObject_HEAD
@@ -21,10 +27,17 @@ typedef struct {
PyObject *weakreflist;
} simplequeueobject;
+/*[clinic input]
+module _queue
+class _queue.SimpleQueue "simplequeueobject *" "simplequeue_get_state_by_type(type)->SimpleQueueType"
+[clinic start generated code]*/
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=0a4023fe4d198c8d]*/
static void
simplequeue_dealloc(simplequeueobject *self)
{
+ PyTypeObject *tp = Py_TYPE(self);
+
PyObject_GC_UnTrack(self);
if (self->lock != NULL) {
/* Unlock the lock so it's safe to free it */
@@ -36,6 +49,7 @@ simplequeue_dealloc(simplequeueobject *self)
if (self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
Py_TYPE(self)->tp_free(self);
+ Py_DECREF(tp);
}
static int
@@ -155,6 +169,9 @@ simplequeue_pop_item(simplequeueobject *self)
/*[clinic input]
_queue.SimpleQueue.get
+
+ cls: defining_class
+ /
block: bool = True
timeout: object = None
@@ -171,9 +188,9 @@ in that case).
[clinic start generated code]*/
static PyObject *
-_queue_SimpleQueue_get_impl(simplequeueobject *self, int block,
- PyObject *timeout)
-/*[clinic end generated code: output=ec82a7157dcccd1a input=4bf691f9f01fa297]*/
+_queue_SimpleQueue_get_impl(simplequeueobject *self, PyTypeObject *cls,
+ int block, PyObject *timeout)
+/*[clinic end generated code: output=1969aefa7db63666 input=5fc4d56b9a54757e]*/
{
_PyTime_t endtime = 0;
_PyTime_t timeout_val;
@@ -225,8 +242,10 @@ _queue_SimpleQueue_get_impl(simplequeueobject *self, int block,
return NULL;
}
if (r == PY_LOCK_FAILURE) {
+ PyObject *module = PyType_GetModule(cls);
+ simplequeue_state *state = simplequeue_get_state(module);
/* Timed out */
- PyErr_SetNone(EmptyError);
+ PyErr_SetNone(state->EmptyError);
return NULL;
}
self->locked = 1;
@@ -251,6 +270,9 @@ _queue_SimpleQueue_get_impl(simplequeueobject *self, int block,
/*[clinic input]
_queue.SimpleQueue.get_nowait
+ cls: defining_class
+ /
+
Remove and return an item from the queue without blocking.
Only get an item if one is immediately available. Otherwise
@@ -258,10 +280,11 @@ raise the Empty exception.
[clinic start generated code]*/
static PyObject *
-_queue_SimpleQueue_get_nowait_impl(simplequeueobject *self)
-/*[clinic end generated code: output=a89731a75dbe4937 input=6fe5102db540a1b9]*/
+_queue_SimpleQueue_get_nowait_impl(simplequeueobject *self,
+ PyTypeObject *cls)
+/*[clinic end generated code: output=620c58e2750f8b8a input=842f732bf04216d3]*/
{
- return _queue_SimpleQueue_get_impl(self, 0, Py_None);
+ return _queue_SimpleQueue_get_impl(self, cls, 0, Py_None);
}
/*[clinic input]
@@ -290,6 +313,29 @@ _queue_SimpleQueue_qsize_impl(simplequeueobject *self)
return PyList_GET_SIZE(self->lst) - self->lst_pos;
}
+static int
+queue_traverse(PyObject *m, visitproc visit, void *arg)
+{
+ simplequeue_state *state = simplequeue_get_state(m);
+ Py_VISIT(state->SimpleQueueType);
+ Py_VISIT(state->EmptyError);
+ return 0;
+}
+
+static int
+queue_clear(PyObject *m)
+{
+ simplequeue_state *state = simplequeue_get_state(m);
+ Py_CLEAR(state->SimpleQueueType);
+ Py_CLEAR(state->EmptyError);
+ return 0;
+}
+
+static void
+queue_free(void *m)
+{
+ queue_clear((PyObject *)m);
+}
#include "clinic/_queuemodule.c.h"
@@ -306,48 +352,26 @@ static PyMethodDef simplequeue_methods[] = {
{NULL, NULL} /* sentinel */
};
+static struct PyMemberDef simplequeue_members[] = {
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(simplequeueobject, weakreflist), READONLY},
+ {NULL},
+};
+
+static PyType_Slot simplequeue_slots[] = {
+ {Py_tp_dealloc, simplequeue_dealloc},
+ {Py_tp_doc, (void *)simplequeue_new__doc__},
+ {Py_tp_traverse, simplequeue_traverse},
+ {Py_tp_members, simplequeue_members},
+ {Py_tp_methods, simplequeue_methods},
+ {Py_tp_new, simplequeue_new},
+ {0, NULL},
+};
-static PyTypeObject PySimpleQueueType = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_queue.SimpleQueue", /*tp_name*/
- sizeof(simplequeueobject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)simplequeue_dealloc, /*tp_dealloc*/
- 0, /*tp_vectorcall_offset*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_as_async*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
- | Py_TPFLAGS_HAVE_GC, /* tp_flags */
- simplequeue_new__doc__, /*tp_doc*/
- (traverseproc)simplequeue_traverse, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- offsetof(simplequeueobject, weakreflist), /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- simplequeue_methods, /*tp_methods*/
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- simplequeue_new /* tp_new */
+static PyType_Spec simplequeue_spec = {
+ .name = "_queue.SimpleQueue",
+ .basicsize = sizeof(simplequeueobject),
+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
+ .slots = simplequeue_slots,
};
@@ -357,43 +381,54 @@ PyDoc_STRVAR(queue_module_doc,
"C implementation of the Python queue module.\n\
This module is an implementation detail, please do not use it directly.");
-static struct PyModuleDef queuemodule = {
- PyModuleDef_HEAD_INIT,
- "_queue",
- queue_module_doc,
- -1,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-
-PyMODINIT_FUNC
-PyInit__queue(void)
+static int
+queuemodule_exec(PyObject *module)
{
- PyObject *m;
+ simplequeue_state *state = simplequeue_get_state(module);
- /* Create the module */
- m = PyModule_Create(&queuemodule);
- if (m == NULL)
- return NULL;
-
- EmptyError = PyErr_NewExceptionWithDoc(
+ state->EmptyError = PyErr_NewExceptionWithDoc(
"_queue.Empty",
"Exception raised by Queue.get(block=0)/get_nowait().",
NULL, NULL);
- if (EmptyError == NULL)
- return NULL;
-
- Py_INCREF(EmptyError);
- if (PyModule_AddObject(m, "Empty", EmptyError) < 0)
- return NULL;
+ if (state->EmptyError == NULL) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(module, "Empty", state->EmptyError) < 0) {
+ return -1;
+ }
- if (PyModule_AddType(m, &PySimpleQueueType) < 0) {
- return NULL;
+ state->SimpleQueueType = (PyTypeObject *)PyType_FromModuleAndSpec(
+ module, &simplequeue_spec, NULL);
+ if (state->SimpleQueueType == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(module, state->SimpleQueueType) < 0) {
+ return -1;
}
- return m;
+ return 0;
+}
+
+static PyModuleDef_Slot queuemodule_slots[] = {
+ {Py_mod_exec, queuemodule_exec},
+ {0, NULL}
+};
+
+
+static struct PyModuleDef queuemodule = {
+ .m_base = PyModuleDef_HEAD_INIT,
+ .m_name = "_queue",
+ .m_doc = queue_module_doc,
+ .m_size = sizeof(simplequeue_state),
+ .m_slots = queuemodule_slots,
+ .m_traverse = queue_traverse,
+ .m_clear = queue_clear,
+ .m_free = queue_free,
+};
+
+
+PyMODINIT_FUNC
+PyInit__queue(void)
+{
+ return PyModuleDef_Init(&queuemodule);
}
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c
index d338708086..99be69c065 100644
--- a/Modules/_randommodule.c
+++ b/Modules/_randommodule.c
@@ -93,7 +93,8 @@ get_random_state(PyObject *module)
static struct PyModuleDef _randommodule;
-#define _randomstate_global get_random_state(PyState_FindModule(&_randommodule))
+#define _randomstate_type(type) \
+ (get_random_state(_PyType_GetModuleByDef(type, &_randommodule)))
typedef struct {
PyObject_HEAD
@@ -106,9 +107,9 @@ typedef struct {
/*[clinic input]
module _random
-class _random.Random "RandomObject *" "&Random_Type"
+class _random.Random "RandomObject *" "_randomstate_type(type)->Random_Type"
[clinic start generated code]*/
-/*[clinic end generated code: output=da39a3ee5e6b4b0d input=f79898ae7847c321]*/
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=70a2c99619474983]*/
/* Random methods */
@@ -290,7 +291,8 @@ random_seed(RandomObject *self, PyObject *arg)
} else if (PyLong_Check(arg)) {
/* Calling int.__abs__() prevents calling arg.__abs__(), which might
return an invalid value. See issue #31478. */
- n = PyObject_CallOneArg(_randomstate_global->Long___abs__, arg);
+ _randomstate *state = _randomstate_type(Py_TYPE(self));
+ n = PyObject_CallOneArg(state->Long___abs__, arg);
}
else {
Py_hash_t hash = PyObject_Hash(arg);
@@ -517,8 +519,10 @@ random_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
RandomObject *self;
PyObject *tmp;
+ PyObject *arg = NULL;
+ _randomstate *state = _randomstate_type(type);
- if (type == (PyTypeObject*)_randomstate_global->Random_Type &&
+ if (type == (PyTypeObject*)state->Random_Type &&
!_PyArg_NoKeywords("Random()", kwds)) {
return NULL;
}
@@ -526,12 +530,22 @@ random_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self = (RandomObject *)PyType_GenericAlloc(type, 0);
if (self == NULL)
return NULL;
- tmp = random_seed(self, args);
+
+ if (PyTuple_GET_SIZE(args) > 1) {
+ PyErr_SetString(PyExc_TypeError, "Random() requires 0 or 1 argument");
+ return NULL;
+ }
+
+ if (PyTuple_GET_SIZE(args) == 1)
+ arg = PyTuple_GET_ITEM(args, 0);
+
+ tmp = random_seed(self, arg);
if (tmp == NULL) {
Py_DECREF(self);
return NULL;
}
Py_DECREF(tmp);
+
return (PyObject *)self;
}
@@ -568,6 +582,45 @@ PyDoc_STRVAR(module_doc,
"Module implements the Mersenne Twister random number generator.");
static int
+_random_exec(PyObject *module)
+{
+ _randomstate *state = get_random_state(module);
+
+ state->Random_Type = PyType_FromModuleAndSpec(
+ module, &Random_Type_spec, NULL);
+ if (state->Random_Type == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(module, (PyTypeObject *)state->Random_Type) < 0) {
+ return -1;
+ }
+
+ /* Look up and save int.__abs__, which is needed in random_seed(). */
+ PyObject *longval = longval = PyLong_FromLong(0);
+ if (longval == NULL) {
+ return -1;
+ }
+
+ PyObject *longtype = PyObject_Type(longval);
+ Py_DECREF(longval);
+ if (longtype == NULL) {
+ return -1;
+ }
+
+ state->Long___abs__ = PyObject_GetAttrString(longtype, "__abs__");
+ Py_DECREF(longtype);
+ if (state->Long___abs__ == NULL) {
+ return -1;
+ }
+ return 0;
+}
+
+static PyModuleDef_Slot _random_slots[] = {
+ {Py_mod_exec, _random_exec},
+ {0, NULL}
+};
+
+static int
_random_traverse(PyObject *module, visitproc visit, void *arg)
{
Py_VISIT(get_random_state(module)->Random_Type);
@@ -594,7 +647,7 @@ static struct PyModuleDef _randommodule = {
module_doc,
sizeof(_randomstate),
NULL,
- NULL,
+ _random_slots,
_random_traverse,
_random_clear,
_random_free,
@@ -603,43 +656,5 @@ static struct PyModuleDef _randommodule = {
PyMODINIT_FUNC
PyInit__random(void)
{
- PyObject *m;
-
- PyObject *Random_Type = PyType_FromSpec(&Random_Type_spec);
- if (Random_Type == NULL) {
- return NULL;
- }
-
- m = PyModule_Create(&_randommodule);
- if (m == NULL) {
- Py_DECREF(Random_Type);
- return NULL;
- }
- get_random_state(m)->Random_Type = Random_Type;
-
- Py_INCREF(Random_Type);
- PyModule_AddObject(m, "Random", Random_Type);
-
- /* Look up and save int.__abs__, which is needed in random_seed(). */
- PyObject *longval = NULL, *longtype = NULL;
- longval = PyLong_FromLong(0);
- if (longval == NULL) goto fail;
-
- longtype = PyObject_Type(longval);
- if (longtype == NULL) goto fail;
-
- PyObject *abs = PyObject_GetAttrString(longtype, "__abs__");
- if (abs == NULL) goto fail;
-
- Py_DECREF(longtype);
- Py_DECREF(longval);
- get_random_state(m)->Long___abs__ = abs;
-
- return m;
-
-fail:
- Py_XDECREF(longtype);
- Py_XDECREF(longval);
- Py_DECREF(m);
- return NULL;
+ return PyModuleDef_Init(&_randommodule);
}
diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c
index da6dde6812..cae10f99d5 100644
--- a/Modules/_sha3/sha3module.c
+++ b/Modules/_sha3/sha3module.c
@@ -274,7 +274,7 @@ SHA3_dealloc(SHA3object *self)
}
PyTypeObject *tp = Py_TYPE(self);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(tp);
}
diff --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c
index 0b02be4f0b..078a484b86 100644
--- a/Modules/_sqlite/cache.c
+++ b/Modules/_sqlite/cache.c
@@ -34,11 +34,8 @@ pysqlite_Node* pysqlite_new_node(PyObject* key, PyObject* data)
return NULL;
}
- Py_INCREF(key);
- node->key = key;
-
- Py_INCREF(data);
- node->data = data;
+ node->key = Py_NewRef(key);
+ node->data = Py_NewRef(data);
node->prev = NULL;
node->next = NULL;
@@ -81,8 +78,7 @@ int pysqlite_cache_init(pysqlite_Cache* self, PyObject* args, PyObject* kwargs)
return -1;
}
- Py_INCREF(factory);
- self->factory = factory;
+ self->factory = Py_NewRef(factory);
self->decref_factory = 1;
@@ -218,8 +214,7 @@ PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* key)
self->last = node;
}
- Py_INCREF(node->data);
- return node->data;
+ return Py_NewRef(node->data);
}
PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
@@ -258,17 +253,17 @@ PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
Py_RETURN_NONE;
}
-static PyType_Slot pysqlite_NodeType_slots[] = {
+static PyType_Slot node_slots[] = {
{Py_tp_dealloc, pysqlite_node_dealloc},
{Py_tp_new, PyType_GenericNew},
{0, NULL},
};
-static PyType_Spec pysqlite_NodeType_spec = {
+static PyType_Spec node_spec = {
.name = MODULE_NAME ".Node",
.basicsize = sizeof(pysqlite_Node),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- .slots = pysqlite_NodeType_slots,
+ .slots = node_slots,
};
PyTypeObject *pysqlite_NodeType = NULL;
@@ -280,7 +275,7 @@ static PyMethodDef cache_methods[] = {
{NULL, NULL}
};
-static PyType_Slot pysqlite_CacheType_slots[] = {
+static PyType_Slot cache_slots[] = {
{Py_tp_dealloc, pysqlite_cache_dealloc},
{Py_tp_methods, cache_methods},
{Py_tp_new, PyType_GenericNew},
@@ -288,22 +283,22 @@ static PyType_Slot pysqlite_CacheType_slots[] = {
{0, NULL},
};
-static PyType_Spec pysqlite_CacheType_spec = {
+static PyType_Spec cache_spec = {
.name = MODULE_NAME ".Cache",
.basicsize = sizeof(pysqlite_Cache),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- .slots = pysqlite_CacheType_slots,
+ .slots = cache_slots,
};
PyTypeObject *pysqlite_CacheType = NULL;
extern int pysqlite_cache_setup_types(PyObject *mod)
{
- pysqlite_NodeType = (PyTypeObject *)PyType_FromModuleAndSpec(mod, &pysqlite_NodeType_spec, NULL);
+ pysqlite_NodeType = (PyTypeObject *)PyType_FromModuleAndSpec(mod, &node_spec, NULL);
if (pysqlite_NodeType == NULL) {
return -1;
}
- pysqlite_CacheType = (PyTypeObject *)PyType_FromModuleAndSpec(mod, &pysqlite_CacheType_spec, NULL);
+ pysqlite_CacheType = (PyTypeObject *)PyType_FromModuleAndSpec(mod, &cache_spec, NULL);
if (pysqlite_CacheType == NULL) {
return -1;
}
diff --git a/Modules/_sqlite/clinic/connection.c.h b/Modules/_sqlite/clinic/connection.c.h
new file mode 100644
index 0000000000..01b8e37a95
--- /dev/null
+++ b/Modules/_sqlite/clinic/connection.c.h
@@ -0,0 +1,722 @@
+/*[clinic input]
+preserve
+[clinic start generated code]*/
+
+PyDoc_STRVAR(pysqlite_connection_cursor__doc__,
+"cursor($self, /, factory=<unrepresentable>)\n"
+"--\n"
+"\n"
+"Return a cursor for the connection.");
+
+#define PYSQLITE_CONNECTION_CURSOR_METHODDEF \
+ {"cursor", (PyCFunction)(void(*)(void))pysqlite_connection_cursor, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_cursor__doc__},
+
+static PyObject *
+pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyObject *factory);
+
+static PyObject *
+pysqlite_connection_cursor(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"factory", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "cursor", 0};
+ PyObject *argsbuf[1];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
+ PyObject *factory = NULL;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ factory = args[0];
+skip_optional_pos:
+ return_value = pysqlite_connection_cursor_impl(self, factory);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(pysqlite_connection_close__doc__,
+"close($self, /)\n"
+"--\n"
+"\n"
+"Closes the connection.");
+
+#define PYSQLITE_CONNECTION_CLOSE_METHODDEF \
+ {"close", (PyCFunction)pysqlite_connection_close, METH_NOARGS, pysqlite_connection_close__doc__},
+
+static PyObject *
+pysqlite_connection_close_impl(pysqlite_Connection *self);
+
+static PyObject *
+pysqlite_connection_close(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
+{
+ return pysqlite_connection_close_impl(self);
+}
+
+PyDoc_STRVAR(pysqlite_connection_commit__doc__,
+"commit($self, /)\n"
+"--\n"
+"\n"
+"Commit the current transaction.");
+
+#define PYSQLITE_CONNECTION_COMMIT_METHODDEF \
+ {"commit", (PyCFunction)pysqlite_connection_commit, METH_NOARGS, pysqlite_connection_commit__doc__},
+
+static PyObject *
+pysqlite_connection_commit_impl(pysqlite_Connection *self);
+
+static PyObject *
+pysqlite_connection_commit(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
+{
+ return pysqlite_connection_commit_impl(self);
+}
+
+PyDoc_STRVAR(pysqlite_connection_rollback__doc__,
+"rollback($self, /)\n"
+"--\n"
+"\n"
+"Roll back the current transaction.");
+
+#define PYSQLITE_CONNECTION_ROLLBACK_METHODDEF \
+ {"rollback", (PyCFunction)pysqlite_connection_rollback, METH_NOARGS, pysqlite_connection_rollback__doc__},
+
+static PyObject *
+pysqlite_connection_rollback_impl(pysqlite_Connection *self);
+
+static PyObject *
+pysqlite_connection_rollback(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
+{
+ return pysqlite_connection_rollback_impl(self);
+}
+
+PyDoc_STRVAR(pysqlite_connection_create_function__doc__,
+"create_function($self, /, name, narg, func, *, deterministic=False)\n"
+"--\n"
+"\n"
+"Creates a new function. Non-standard.");
+
+#define PYSQLITE_CONNECTION_CREATE_FUNCTION_METHODDEF \
+ {"create_function", (PyCFunction)(void(*)(void))pysqlite_connection_create_function, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_function__doc__},
+
+static PyObject *
+pysqlite_connection_create_function_impl(pysqlite_Connection *self,
+ const char *name, int narg,
+ PyObject *func, int deterministic);
+
+static PyObject *
+pysqlite_connection_create_function(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"name", "narg", "func", "deterministic", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "create_function", 0};
+ PyObject *argsbuf[4];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
+ const char *name;
+ int narg;
+ PyObject *func;
+ int deterministic = 0;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("create_function", "argument 'name'", "str", args[0]);
+ goto exit;
+ }
+ Py_ssize_t name_length;
+ name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
+ if (name == NULL) {
+ goto exit;
+ }
+ if (strlen(name) != (size_t)name_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ narg = _PyLong_AsInt(args[1]);
+ if (narg == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ func = args[2];
+ if (!noptargs) {
+ goto skip_optional_kwonly;
+ }
+ deterministic = PyObject_IsTrue(args[3]);
+ if (deterministic < 0) {
+ goto exit;
+ }
+skip_optional_kwonly:
+ return_value = pysqlite_connection_create_function_impl(self, name, narg, func, deterministic);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(pysqlite_connection_create_aggregate__doc__,
+"create_aggregate($self, /, name, n_arg, aggregate_class)\n"
+"--\n"
+"\n"
+"Creates a new aggregate. Non-standard.");
+
+#define PYSQLITE_CONNECTION_CREATE_AGGREGATE_METHODDEF \
+ {"create_aggregate", (PyCFunction)(void(*)(void))pysqlite_connection_create_aggregate, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_aggregate__doc__},
+
+static PyObject *
+pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,
+ const char *name, int n_arg,
+ PyObject *aggregate_class);
+
+static PyObject *
+pysqlite_connection_create_aggregate(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"name", "n_arg", "aggregate_class", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "create_aggregate", 0};
+ PyObject *argsbuf[3];
+ const char *name;
+ int n_arg;
+ PyObject *aggregate_class;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("create_aggregate", "argument 'name'", "str", args[0]);
+ goto exit;
+ }
+ Py_ssize_t name_length;
+ name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
+ if (name == NULL) {
+ goto exit;
+ }
+ if (strlen(name) != (size_t)name_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ n_arg = _PyLong_AsInt(args[1]);
+ if (n_arg == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ aggregate_class = args[2];
+ return_value = pysqlite_connection_create_aggregate_impl(self, name, n_arg, aggregate_class);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(pysqlite_connection_set_authorizer__doc__,
+"set_authorizer($self, /, authorizer_callback)\n"
+"--\n"
+"\n"
+"Sets authorizer callback. Non-standard.");
+
+#define PYSQLITE_CONNECTION_SET_AUTHORIZER_METHODDEF \
+ {"set_authorizer", (PyCFunction)(void(*)(void))pysqlite_connection_set_authorizer, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_authorizer__doc__},
+
+static PyObject *
+pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
+ PyObject *authorizer_cb);
+
+static PyObject *
+pysqlite_connection_set_authorizer(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"authorizer_callback", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "set_authorizer", 0};
+ PyObject *argsbuf[1];
+ PyObject *authorizer_cb;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ authorizer_cb = args[0];
+ return_value = pysqlite_connection_set_authorizer_impl(self, authorizer_cb);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(pysqlite_connection_set_progress_handler__doc__,
+"set_progress_handler($self, /, progress_handler, n)\n"
+"--\n"
+"\n"
+"Sets progress handler callback. Non-standard.");
+
+#define PYSQLITE_CONNECTION_SET_PROGRESS_HANDLER_METHODDEF \
+ {"set_progress_handler", (PyCFunction)(void(*)(void))pysqlite_connection_set_progress_handler, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_progress_handler__doc__},
+
+static PyObject *
+pysqlite_connection_set_progress_handler_impl(pysqlite_Connection *self,
+ PyObject *progress_handler,
+ int n);
+
+static PyObject *
+pysqlite_connection_set_progress_handler(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"progress_handler", "n", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "set_progress_handler", 0};
+ PyObject *argsbuf[2];
+ PyObject *progress_handler;
+ int n;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ progress_handler = args[0];
+ n = _PyLong_AsInt(args[1]);
+ if (n == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ return_value = pysqlite_connection_set_progress_handler_impl(self, progress_handler, n);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(pysqlite_connection_set_trace_callback__doc__,
+"set_trace_callback($self, /, trace_callback)\n"
+"--\n"
+"\n"
+"Sets a trace callback called for each SQL statement (passed as unicode).\n"
+"\n"
+"Non-standard.");
+
+#define PYSQLITE_CONNECTION_SET_TRACE_CALLBACK_METHODDEF \
+ {"set_trace_callback", (PyCFunction)(void(*)(void))pysqlite_connection_set_trace_callback, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_trace_callback__doc__},
+
+static PyObject *
+pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
+ PyObject *trace_callback);
+
+static PyObject *
+pysqlite_connection_set_trace_callback(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"trace_callback", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "set_trace_callback", 0};
+ PyObject *argsbuf[1];
+ PyObject *trace_callback;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ trace_callback = args[0];
+ return_value = pysqlite_connection_set_trace_callback_impl(self, trace_callback);
+
+exit:
+ return return_value;
+}
+
+#if !defined(SQLITE_OMIT_LOAD_EXTENSION)
+
+PyDoc_STRVAR(pysqlite_connection_enable_load_extension__doc__,
+"enable_load_extension($self, enable, /)\n"
+"--\n"
+"\n"
+"Enable dynamic loading of SQLite extension modules. Non-standard.");
+
+#define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF \
+ {"enable_load_extension", (PyCFunction)pysqlite_connection_enable_load_extension, METH_O, pysqlite_connection_enable_load_extension__doc__},
+
+static PyObject *
+pysqlite_connection_enable_load_extension_impl(pysqlite_Connection *self,
+ int onoff);
+
+static PyObject *
+pysqlite_connection_enable_load_extension(pysqlite_Connection *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ int onoff;
+
+ onoff = _PyLong_AsInt(arg);
+ if (onoff == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ return_value = pysqlite_connection_enable_load_extension_impl(self, onoff);
+
+exit:
+ return return_value;
+}
+
+#endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */
+
+#if !defined(SQLITE_OMIT_LOAD_EXTENSION)
+
+PyDoc_STRVAR(pysqlite_connection_load_extension__doc__,
+"load_extension($self, name, /)\n"
+"--\n"
+"\n"
+"Load SQLite extension module. Non-standard.");
+
+#define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF \
+ {"load_extension", (PyCFunction)pysqlite_connection_load_extension, METH_O, pysqlite_connection_load_extension__doc__},
+
+static PyObject *
+pysqlite_connection_load_extension_impl(pysqlite_Connection *self,
+ const char *extension_name);
+
+static PyObject *
+pysqlite_connection_load_extension(pysqlite_Connection *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ const char *extension_name;
+
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("load_extension", "argument", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t extension_name_length;
+ extension_name = PyUnicode_AsUTF8AndSize(arg, &extension_name_length);
+ if (extension_name == NULL) {
+ goto exit;
+ }
+ if (strlen(extension_name) != (size_t)extension_name_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ return_value = pysqlite_connection_load_extension_impl(self, extension_name);
+
+exit:
+ return return_value;
+}
+
+#endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */
+
+PyDoc_STRVAR(pysqlite_connection_execute__doc__,
+"execute($self, sql, parameters=<unrepresentable>, /)\n"
+"--\n"
+"\n"
+"Executes a SQL statement. Non-standard.");
+
+#define PYSQLITE_CONNECTION_EXECUTE_METHODDEF \
+ {"execute", (PyCFunction)(void(*)(void))pysqlite_connection_execute, METH_FASTCALL, pysqlite_connection_execute__doc__},
+
+static PyObject *
+pysqlite_connection_execute_impl(pysqlite_Connection *self, PyObject *sql,
+ PyObject *parameters);
+
+static PyObject *
+pysqlite_connection_execute(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *sql;
+ PyObject *parameters = NULL;
+
+ if (!_PyArg_CheckPositional("execute", nargs, 1, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("execute", "argument 1", "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ sql = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ parameters = args[1];
+skip_optional:
+ return_value = pysqlite_connection_execute_impl(self, sql, parameters);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(pysqlite_connection_executemany__doc__,
+"executemany($self, sql, parameters, /)\n"
+"--\n"
+"\n"
+"Repeatedly executes a SQL statement. Non-standard.");
+
+#define PYSQLITE_CONNECTION_EXECUTEMANY_METHODDEF \
+ {"executemany", (PyCFunction)(void(*)(void))pysqlite_connection_executemany, METH_FASTCALL, pysqlite_connection_executemany__doc__},
+
+static PyObject *
+pysqlite_connection_executemany_impl(pysqlite_Connection *self,
+ PyObject *sql, PyObject *parameters);
+
+static PyObject *
+pysqlite_connection_executemany(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *sql;
+ PyObject *parameters;
+
+ if (!_PyArg_CheckPositional("executemany", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("executemany", "argument 1", "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ sql = args[0];
+ parameters = args[1];
+ return_value = pysqlite_connection_executemany_impl(self, sql, parameters);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(pysqlite_connection_executescript__doc__,
+"executescript($self, sql_script, /)\n"
+"--\n"
+"\n"
+"Executes a multiple SQL statements at once. Non-standard.");
+
+#define PYSQLITE_CONNECTION_EXECUTESCRIPT_METHODDEF \
+ {"executescript", (PyCFunction)pysqlite_connection_executescript, METH_O, pysqlite_connection_executescript__doc__},
+
+PyDoc_STRVAR(pysqlite_connection_interrupt__doc__,
+"interrupt($self, /)\n"
+"--\n"
+"\n"
+"Abort any pending database operation. Non-standard.");
+
+#define PYSQLITE_CONNECTION_INTERRUPT_METHODDEF \
+ {"interrupt", (PyCFunction)pysqlite_connection_interrupt, METH_NOARGS, pysqlite_connection_interrupt__doc__},
+
+static PyObject *
+pysqlite_connection_interrupt_impl(pysqlite_Connection *self);
+
+static PyObject *
+pysqlite_connection_interrupt(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
+{
+ return pysqlite_connection_interrupt_impl(self);
+}
+
+PyDoc_STRVAR(pysqlite_connection_iterdump__doc__,
+"iterdump($self, /)\n"
+"--\n"
+"\n"
+"Returns iterator to the dump of the database in an SQL text format.\n"
+"\n"
+"Non-standard.");
+
+#define PYSQLITE_CONNECTION_ITERDUMP_METHODDEF \
+ {"iterdump", (PyCFunction)pysqlite_connection_iterdump, METH_NOARGS, pysqlite_connection_iterdump__doc__},
+
+static PyObject *
+pysqlite_connection_iterdump_impl(pysqlite_Connection *self);
+
+static PyObject *
+pysqlite_connection_iterdump(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
+{
+ return pysqlite_connection_iterdump_impl(self);
+}
+
+PyDoc_STRVAR(pysqlite_connection_backup__doc__,
+"backup($self, /, target=<unrepresentable>, *, pages=-1, progress=None,\n"
+" name=\'main\', sleep=0.25)\n"
+"--\n"
+"\n"
+"Makes a backup of the database. Non-standard.");
+
+#define PYSQLITE_CONNECTION_BACKUP_METHODDEF \
+ {"backup", (PyCFunction)(void(*)(void))pysqlite_connection_backup, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_backup__doc__},
+
+static PyObject *
+pysqlite_connection_backup_impl(pysqlite_Connection *self,
+ pysqlite_Connection *target, int pages,
+ PyObject *progress, const char *name,
+ double sleep);
+
+static PyObject *
+pysqlite_connection_backup(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"target", "pages", "progress", "name", "sleep", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "backup", 0};
+ PyObject *argsbuf[5];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
+ pysqlite_Connection *target = NULL;
+ int pages = -1;
+ PyObject *progress = Py_None;
+ const char *name = "main";
+ double sleep = 0.25;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[0]) {
+ if (!PyObject_TypeCheck(args[0], pysqlite_ConnectionType)) {
+ _PyArg_BadArgument("backup", "argument 'target'", (pysqlite_ConnectionType)->tp_name, args[0]);
+ goto exit;
+ }
+ target = (pysqlite_Connection *)args[0];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+skip_optional_pos:
+ if (!noptargs) {
+ goto skip_optional_kwonly;
+ }
+ if (args[1]) {
+ pages = _PyLong_AsInt(args[1]);
+ if (pages == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (!--noptargs) {
+ goto skip_optional_kwonly;
+ }
+ }
+ if (args[2]) {
+ progress = args[2];
+ if (!--noptargs) {
+ goto skip_optional_kwonly;
+ }
+ }
+ if (args[3]) {
+ if (!PyUnicode_Check(args[3])) {
+ _PyArg_BadArgument("backup", "argument 'name'", "str", args[3]);
+ goto exit;
+ }
+ Py_ssize_t name_length;
+ name = PyUnicode_AsUTF8AndSize(args[3], &name_length);
+ if (name == NULL) {
+ goto exit;
+ }
+ if (strlen(name) != (size_t)name_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ if (!--noptargs) {
+ goto skip_optional_kwonly;
+ }
+ }
+ if (PyFloat_CheckExact(args[4])) {
+ sleep = PyFloat_AS_DOUBLE(args[4]);
+ }
+ else
+ {
+ sleep = PyFloat_AsDouble(args[4]);
+ if (sleep == -1.0 && PyErr_Occurred()) {
+ goto exit;
+ }
+ }
+skip_optional_kwonly:
+ return_value = pysqlite_connection_backup_impl(self, target, pages, progress, name, sleep);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(pysqlite_connection_create_collation__doc__,
+"create_collation($self, name, callback, /)\n"
+"--\n"
+"\n"
+"Creates a collation function. Non-standard.");
+
+#define PYSQLITE_CONNECTION_CREATE_COLLATION_METHODDEF \
+ {"create_collation", (PyCFunction)(void(*)(void))pysqlite_connection_create_collation, METH_FASTCALL, pysqlite_connection_create_collation__doc__},
+
+static PyObject *
+pysqlite_connection_create_collation_impl(pysqlite_Connection *self,
+ PyObject *name, PyObject *callable);
+
+static PyObject *
+pysqlite_connection_create_collation(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *name;
+ PyObject *callable;
+
+ if (!_PyArg_CheckPositional("create_collation", nargs, 2, 2)) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("create_collation", "argument 1", "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ name = args[0];
+ callable = args[1];
+ return_value = pysqlite_connection_create_collation_impl(self, name, callable);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(pysqlite_connection_enter__doc__,
+"__enter__($self, /)\n"
+"--\n"
+"\n"
+"Called when the connection is used as a context manager.\n"
+"\n"
+"Returns itself as a convenience to the caller.");
+
+#define PYSQLITE_CONNECTION_ENTER_METHODDEF \
+ {"__enter__", (PyCFunction)pysqlite_connection_enter, METH_NOARGS, pysqlite_connection_enter__doc__},
+
+static PyObject *
+pysqlite_connection_enter_impl(pysqlite_Connection *self);
+
+static PyObject *
+pysqlite_connection_enter(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
+{
+ return pysqlite_connection_enter_impl(self);
+}
+
+PyDoc_STRVAR(pysqlite_connection_exit__doc__,
+"__exit__($self, type, value, traceback, /)\n"
+"--\n"
+"\n"
+"Called when the connection is used as a context manager.\n"
+"\n"
+"If there was any exception, a rollback takes place; otherwise we commit.");
+
+#define PYSQLITE_CONNECTION_EXIT_METHODDEF \
+ {"__exit__", (PyCFunction)(void(*)(void))pysqlite_connection_exit, METH_FASTCALL, pysqlite_connection_exit__doc__},
+
+static PyObject *
+pysqlite_connection_exit_impl(pysqlite_Connection *self, PyObject *exc_type,
+ PyObject *exc_value, PyObject *exc_tb);
+
+static PyObject *
+pysqlite_connection_exit(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *exc_type;
+ PyObject *exc_value;
+ PyObject *exc_tb;
+
+ if (!_PyArg_CheckPositional("__exit__", nargs, 3, 3)) {
+ goto exit;
+ }
+ exc_type = args[0];
+ exc_value = args[1];
+ exc_tb = args[2];
+ return_value = pysqlite_connection_exit_impl(self, exc_type, exc_value, exc_tb);
+
+exit:
+ return return_value;
+}
+
+#ifndef PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
+ #define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
+#endif /* !defined(PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF) */
+
+#ifndef PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
+ #define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
+#endif /* !defined(PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF) */
+/*[clinic end generated code: output=7cb13d491a5970aa input=a9049054013a1b77]*/
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 69203f85e0..46717acf7c 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -37,6 +37,13 @@
#define HAVE_TRACE_V2
#endif
+#include "clinic/connection.c.h"
+/*[clinic input]
+module _sqlite3
+class _sqlite3.Connection "pysqlite_Connection *" "pysqlite_ConnectionType"
+[clinic start generated code]*/
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=aa796073bd8f69db]*/
+
_Py_IDENTIFIER(cursor);
static const char * const begin_statements[] = {
@@ -269,17 +276,20 @@ error:
return 0;
}
-PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
+/*[clinic input]
+_sqlite3.Connection.cursor as pysqlite_connection_cursor
+
+ factory: object = NULL
+
+Return a cursor for the connection.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyObject *factory)
+/*[clinic end generated code: output=562432a9e6af2aa1 input=4127345aa091b650]*/
{
- static char *kwlist[] = {"factory", NULL};
- PyObject* factory = NULL;
PyObject* cursor;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", kwlist,
- &factory)) {
- return NULL;
- }
-
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
}
@@ -309,7 +319,15 @@ PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args,
return cursor;
}
-PyObject* pysqlite_connection_close(pysqlite_Connection* self, PyObject* args)
+/*[clinic input]
+_sqlite3.Connection.close as pysqlite_connection_close
+
+Closes the connection.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_close_impl(pysqlite_Connection *self)
+/*[clinic end generated code: output=a546a0da212c9b97 input=3d58064bbffaa3d3]*/
{
int rc;
@@ -389,7 +407,15 @@ error:
}
}
-PyObject* pysqlite_connection_commit(pysqlite_Connection* self, PyObject* args)
+/*[clinic input]
+_sqlite3.Connection.commit as pysqlite_connection_commit
+
+Commit the current transaction.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_commit_impl(pysqlite_Connection *self)
+/*[clinic end generated code: output=3da45579e89407f2 input=39c12c04dda276a8]*/
{
int rc;
const char* tail;
@@ -431,7 +457,15 @@ error:
}
}
-PyObject* pysqlite_connection_rollback(pysqlite_Connection* self, PyObject* args)
+/*[clinic input]
+_sqlite3.Connection.rollback as pysqlite_connection_rollback
+
+Roll back the current transaction.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_rollback_impl(pysqlite_Connection *self)
+/*[clinic end generated code: output=b66fa0d43e7ef305 input=12d4e8d068942830]*/
{
int rc;
const char* tail;
@@ -541,8 +575,7 @@ PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_
/* TODO: have a way to show errors here */
if (!cur_py_value) {
PyErr_Clear();
- Py_INCREF(Py_None);
- cur_py_value = Py_None;
+ cur_py_value = Py_NewRef(Py_None);
}
break;
case SQLITE_BLOB:
@@ -552,8 +585,7 @@ PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_
break;
case SQLITE_NULL:
default:
- Py_INCREF(Py_None);
- cur_py_value = Py_None;
+ cur_py_value = Py_NewRef(Py_None);
}
if (!cur_py_value) {
@@ -780,27 +812,31 @@ static void _destructor(void* args)
Py_DECREF((PyObject*)args);
}
-PyObject* pysqlite_connection_create_function(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
-{
- static char *kwlist[] = {"name", "narg", "func", "deterministic", NULL};
+/*[clinic input]
+_sqlite3.Connection.create_function as pysqlite_connection_create_function
+
+ name: str
+ narg: int
+ func: object
+ *
+ deterministic: bool = False
- PyObject* func;
- char* name;
- int narg;
+Creates a new function. Non-standard.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_create_function_impl(pysqlite_Connection *self,
+ const char *name, int narg,
+ PyObject *func, int deterministic)
+/*[clinic end generated code: output=07d1877dd98c0308 input=f2edcf073e815beb]*/
+{
int rc;
- int deterministic = 0;
int flags = SQLITE_UTF8;
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
}
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO|$p", kwlist,
- &name, &narg, &func, &deterministic))
- {
- return NULL;
- }
-
if (deterministic) {
#if SQLITE_VERSION_NUMBER < 3008003
PyErr_SetString(pysqlite_NotSupportedError,
@@ -815,12 +851,11 @@ PyObject* pysqlite_connection_create_function(pysqlite_Connection* self, PyObjec
flags |= SQLITE_DETERMINISTIC;
#endif
}
- Py_INCREF(func);
rc = sqlite3_create_function_v2(self->db,
name,
narg,
flags,
- (void*)func,
+ (void*)Py_NewRef(func),
_pysqlite_func_callback,
NULL,
NULL,
@@ -834,29 +869,34 @@ PyObject* pysqlite_connection_create_function(pysqlite_Connection* self, PyObjec
Py_RETURN_NONE;
}
-PyObject* pysqlite_connection_create_aggregate(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
-{
- PyObject* aggregate_class;
+/*[clinic input]
+_sqlite3.Connection.create_aggregate as pysqlite_connection_create_aggregate
+
+ name: str
+ n_arg: int
+ aggregate_class: object
- int n_arg;
- char* name;
- static char *kwlist[] = { "name", "n_arg", "aggregate_class", NULL };
+Creates a new aggregate. Non-standard.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,
+ const char *name, int n_arg,
+ PyObject *aggregate_class)
+/*[clinic end generated code: output=fbb2f858cfa4d8db input=c2e13bbf234500a5]*/
+{
int rc;
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
}
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO:create_aggregate",
- kwlist, &name, &n_arg, &aggregate_class)) {
- return NULL;
- }
Py_INCREF(aggregate_class);
rc = sqlite3_create_function_v2(self->db,
name,
n_arg,
SQLITE_UTF8,
- (void*)aggregate_class,
+ (void*)Py_NewRef(aggregate_class),
0,
&_pysqlite_step_callback,
&_pysqlite_final_callback,
@@ -982,22 +1022,25 @@ static void _trace_callback(void* user_arg, const char* statement_string)
#endif
}
-static PyObject* pysqlite_connection_set_authorizer(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
-{
- PyObject* authorizer_cb;
+/*[clinic input]
+_sqlite3.Connection.set_authorizer as pysqlite_connection_set_authorizer
+
+ authorizer_callback as authorizer_cb: object
- static char *kwlist[] = { "authorizer_callback", NULL };
+Sets authorizer callback. Non-standard.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
+ PyObject *authorizer_cb)
+/*[clinic end generated code: output=f18ba575d788b35c input=df079724c020d2f2]*/
+{
int rc;
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
}
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:set_authorizer",
- kwlist, &authorizer_cb)) {
- return NULL;
- }
-
rc = sqlite3_set_authorizer(self->db, _authorizer_callback, (void*)authorizer_cb);
if (rc != SQLITE_OK) {
PyErr_SetString(pysqlite_OperationalError, "Error setting authorizer callback");
@@ -1010,19 +1053,22 @@ static PyObject* pysqlite_connection_set_authorizer(pysqlite_Connection* self, P
Py_RETURN_NONE;
}
-static PyObject* pysqlite_connection_set_progress_handler(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
-{
- PyObject* progress_handler;
- int n;
+/*[clinic input]
+_sqlite3.Connection.set_progress_handler as pysqlite_connection_set_progress_handler
- static char *kwlist[] = { "progress_handler", "n", NULL };
+ progress_handler: object
+ n: int
- if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
- return NULL;
- }
+Sets progress handler callback. Non-standard.
+[clinic start generated code]*/
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi:set_progress_handler",
- kwlist, &progress_handler, &n)) {
+static PyObject *
+pysqlite_connection_set_progress_handler_impl(pysqlite_Connection *self,
+ PyObject *progress_handler,
+ int n)
+/*[clinic end generated code: output=35a7c10364cb1b04 input=857696c25f964c64]*/
+{
+ if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
}
@@ -1038,28 +1084,33 @@ static PyObject* pysqlite_connection_set_progress_handler(pysqlite_Connection* s
Py_RETURN_NONE;
}
-/*
- * Ref.
- * - https://sqlite.org/c3ref/c_trace.html
- * - https://sqlite.org/c3ref/trace_v2.html
- */
-static PyObject* pysqlite_connection_set_trace_callback(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
-{
- PyObject* trace_callback;
+/*[clinic input]
+_sqlite3.Connection.set_trace_callback as pysqlite_connection_set_trace_callback
- static char *kwlist[] = { "trace_callback", NULL };
+ trace_callback: object
- if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
- return NULL;
- }
+Sets a trace callback called for each SQL statement (passed as unicode).
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:set_trace_callback",
- kwlist, &trace_callback)) {
+Non-standard.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
+ PyObject *trace_callback)
+/*[clinic end generated code: output=fb0e307b9924d454 input=56d60fd38d763679]*/
+{
+ if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
}
if (trace_callback == Py_None) {
- /* None clears the trace callback previously set */
+ /*
+ * None clears the trace callback previously set
+ *
+ * Ref.
+ * - https://sqlite.org/c3ref/c_trace.html
+ * - https://sqlite.org/c3ref/trace_v2.html
+ */
#ifdef HAVE_TRACE_V2
sqlite3_trace_v2(self->db, SQLITE_TRACE_STMT, 0, 0);
#else
@@ -1080,19 +1131,26 @@ static PyObject* pysqlite_connection_set_trace_callback(pysqlite_Connection* sel
}
#ifndef SQLITE_OMIT_LOAD_EXTENSION
-static PyObject* pysqlite_enable_load_extension(pysqlite_Connection* self, PyObject* args)
+/*[clinic input]
+_sqlite3.Connection.enable_load_extension as pysqlite_connection_enable_load_extension
+
+ enable as onoff: bool(accept={int})
+ /
+
+Enable dynamic loading of SQLite extension modules. Non-standard.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_enable_load_extension_impl(pysqlite_Connection *self,
+ int onoff)
+/*[clinic end generated code: output=9cac37190d388baf input=5c0da5b121121cbc]*/
{
int rc;
- int onoff;
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
}
- if (!PyArg_ParseTuple(args, "i", &onoff)) {
- return NULL;
- }
-
rc = sqlite3_enable_load_extension(self->db, onoff);
if (rc != SQLITE_OK) {
@@ -1103,20 +1161,27 @@ static PyObject* pysqlite_enable_load_extension(pysqlite_Connection* self, PyObj
}
}
-static PyObject* pysqlite_load_extension(pysqlite_Connection* self, PyObject* args)
+/*[clinic input]
+_sqlite3.Connection.load_extension as pysqlite_connection_load_extension
+
+ name as extension_name: str
+ /
+
+Load SQLite extension module. Non-standard.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_load_extension_impl(pysqlite_Connection *self,
+ const char *extension_name)
+/*[clinic end generated code: output=47eb1d7312bc97a7 input=0b711574560db9fc]*/
{
int rc;
- char* extension_name;
char* errmsg;
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
}
- if (!PyArg_ParseTuple(args, "s", &extension_name)) {
- return NULL;
- }
-
rc = sqlite3_load_extension(self->db, extension_name, 0, &errmsg);
if (rc != 0) {
PyErr_SetString(pysqlite_OperationalError, errmsg);
@@ -1144,8 +1209,7 @@ int pysqlite_check_thread(pysqlite_Connection* self)
static PyObject* pysqlite_connection_get_isolation_level(pysqlite_Connection* self, void* unused)
{
- Py_INCREF(self->isolation_level);
- return self->isolation_level;
+ return Py_NewRef(self->isolation_level);
}
static PyObject* pysqlite_connection_get_total_changes(pysqlite_Connection* self, void* unused)
@@ -1279,89 +1343,108 @@ error:
return NULL;
}
-PyObject* pysqlite_connection_execute(pysqlite_Connection* self, PyObject* args)
+/*[clinic input]
+_sqlite3.Connection.execute as pysqlite_connection_execute
+
+ sql: unicode
+ parameters: object = NULL
+ /
+
+Executes a SQL statement. Non-standard.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_execute_impl(pysqlite_Connection *self, PyObject *sql,
+ PyObject *parameters)
+/*[clinic end generated code: output=5be05ae01ee17ee4 input=fbd17c75c7140271]*/
{
+ _Py_IDENTIFIER(execute);
PyObject* cursor = 0;
PyObject* result = 0;
- PyObject* method = 0;
cursor = _PyObject_CallMethodIdNoArgs((PyObject*)self, &PyId_cursor);
if (!cursor) {
goto error;
}
- method = PyObject_GetAttrString(cursor, "execute");
- if (!method) {
- Py_CLEAR(cursor);
- goto error;
- }
-
- result = PyObject_CallObject(method, args);
+ result = _PyObject_CallMethodIdObjArgs(cursor, &PyId_execute, sql, parameters, NULL);
if (!result) {
Py_CLEAR(cursor);
}
error:
Py_XDECREF(result);
- Py_XDECREF(method);
return cursor;
}
-PyObject* pysqlite_connection_executemany(pysqlite_Connection* self, PyObject* args)
+/*[clinic input]
+_sqlite3.Connection.executemany as pysqlite_connection_executemany
+
+ sql: unicode
+ parameters: object
+ /
+
+Repeatedly executes a SQL statement. Non-standard.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_executemany_impl(pysqlite_Connection *self,
+ PyObject *sql, PyObject *parameters)
+/*[clinic end generated code: output=776cd2fd20bfe71f input=4feab80659ffc82b]*/
{
+ _Py_IDENTIFIER(executemany);
PyObject* cursor = 0;
PyObject* result = 0;
- PyObject* method = 0;
cursor = _PyObject_CallMethodIdNoArgs((PyObject*)self, &PyId_cursor);
if (!cursor) {
goto error;
}
- method = PyObject_GetAttrString(cursor, "executemany");
- if (!method) {
- Py_CLEAR(cursor);
- goto error;
- }
-
- result = PyObject_CallObject(method, args);
+ result = _PyObject_CallMethodIdObjArgs(cursor, &PyId_executemany, sql,
+ parameters, NULL);
if (!result) {
Py_CLEAR(cursor);
}
error:
Py_XDECREF(result);
- Py_XDECREF(method);
return cursor;
}
-PyObject* pysqlite_connection_executescript(pysqlite_Connection* self, PyObject* args)
+/*[clinic input]
+_sqlite3.Connection.executescript as pysqlite_connection_executescript
+
+ sql_script as script_obj: object
+ /
+
+Executes a multiple SQL statements at once. Non-standard.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_connection_executescript(pysqlite_Connection *self,
+ PyObject *script_obj)
+/*[clinic end generated code: output=4c4f9d77aa0ae37d input=c0b14695aa6c81d9]*/
{
+ _Py_IDENTIFIER(executescript);
PyObject* cursor = 0;
PyObject* result = 0;
- PyObject* method = 0;
cursor = _PyObject_CallMethodIdNoArgs((PyObject*)self, &PyId_cursor);
if (!cursor) {
goto error;
}
- method = PyObject_GetAttrString(cursor, "executescript");
- if (!method) {
- Py_CLEAR(cursor);
- goto error;
- }
-
- result = PyObject_CallObject(method, args);
+ result = _PyObject_CallMethodIdObjArgs(cursor, &PyId_executescript,
+ script_obj, NULL);
if (!result) {
Py_CLEAR(cursor);
}
error:
Py_XDECREF(result);
- Py_XDECREF(method);
return cursor;
}
@@ -1421,8 +1504,15 @@ finally:
return result;
}
+/*[clinic input]
+_sqlite3.Connection.interrupt as pysqlite_connection_interrupt
+
+Abort any pending database operation. Non-standard.
+[clinic start generated code]*/
+
static PyObject *
-pysqlite_connection_interrupt(pysqlite_Connection* self, PyObject* args)
+pysqlite_connection_interrupt_impl(pysqlite_Connection *self)
+/*[clinic end generated code: output=f193204bc9e70b47 input=4bd0ad083cf93aa7]*/
{
PyObject* retval = NULL;
@@ -1432,8 +1522,7 @@ pysqlite_connection_interrupt(pysqlite_Connection* self, PyObject* args)
sqlite3_interrupt(self->db);
- Py_INCREF(Py_None);
- retval = Py_None;
+ retval = Py_NewRef(Py_None);
finally:
return retval;
@@ -1443,8 +1532,17 @@ finally:
* Class method of Connection to call the Python function _iterdump
* of the sqlite3 module.
*/
+/*[clinic input]
+_sqlite3.Connection.iterdump as pysqlite_connection_iterdump
+
+Returns iterator to the dump of the database in an SQL text format.
+
+Non-standard.
+[clinic start generated code]*/
+
static PyObject *
-pysqlite_connection_iterdump(pysqlite_Connection* self, PyObject* args)
+pysqlite_connection_iterdump_impl(pysqlite_Connection *self)
+/*[clinic end generated code: output=586997aaf9808768 input=53bc907cb5eedb85]*/
{
_Py_IDENTIFIER(_iterdump);
PyObject* retval = NULL;
@@ -1482,51 +1580,41 @@ finally:
return retval;
}
+/*[clinic input]
+_sqlite3.Connection.backup as pysqlite_connection_backup
+
+ target: object(type='pysqlite_Connection *', subclass_of='pysqlite_ConnectionType') = NULL
+ *
+ pages: int = -1
+ progress: object = None
+ name: str = "main"
+ sleep: double = 0.250
+
+Makes a backup of the database. Non-standard.
+[clinic start generated code]*/
+
static PyObject *
-pysqlite_connection_backup(pysqlite_Connection *self, PyObject *args, PyObject *kwds)
+pysqlite_connection_backup_impl(pysqlite_Connection *self,
+ pysqlite_Connection *target, int pages,
+ PyObject *progress, const char *name,
+ double sleep)
+/*[clinic end generated code: output=306a3e6a38c36334 input=2f3497ea530144b1]*/
{
- PyObject *target = NULL;
- int pages = -1;
- PyObject *progress = Py_None;
- const char *name = "main";
int rc;
int callback_error = 0;
- PyObject *sleep_obj = NULL;
- int sleep_ms = 250;
+ int sleep_ms = sleep * 1000.0;
sqlite3 *bck_conn;
sqlite3_backup *bck_handle;
- static char *keywords[] = {"target", "pages", "progress", "name", "sleep", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|$iOsO:backup", keywords,
- pysqlite_ConnectionType, &target,
- &pages, &progress, &name, &sleep_obj)) {
- return NULL;
- }
-
- if (sleep_obj != NULL) {
- _PyTime_t sleep_secs;
- if (_PyTime_FromSecondsObject(&sleep_secs, sleep_obj,
- _PyTime_ROUND_TIMEOUT)) {
- return NULL;
- }
- _PyTime_t ms = _PyTime_AsMilliseconds(sleep_secs,
- _PyTime_ROUND_TIMEOUT);
- if (ms < INT_MIN || ms > INT_MAX) {
- PyErr_SetString(PyExc_OverflowError, "sleep is too large");
- return NULL;
- }
- sleep_ms = (int)ms;
- }
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
}
- if (!pysqlite_check_connection((pysqlite_Connection *)target)) {
+ if (!pysqlite_check_connection(target)) {
return NULL;
}
- if ((pysqlite_Connection *)target == self) {
+ if (target == self) {
PyErr_SetString(PyExc_ValueError, "target cannot be the same connection instance");
return NULL;
}
@@ -1534,7 +1622,7 @@ pysqlite_connection_backup(pysqlite_Connection *self, PyObject *args, PyObject *
#if SQLITE_VERSION_NUMBER < 3008008
/* Since 3.8.8 this is already done, per commit
https://www.sqlite.org/src/info/169b5505498c0a7e */
- if (!sqlite3_get_autocommit(((pysqlite_Connection *)target)->db)) {
+ if (!sqlite3_get_autocommit(target->db)) {
PyErr_SetString(pysqlite_OperationalError, "target is in transaction");
return NULL;
}
@@ -1549,7 +1637,7 @@ pysqlite_connection_backup(pysqlite_Connection *self, PyObject *args, PyObject *
pages = -1;
}
- bck_conn = ((pysqlite_Connection *)target)->db;
+ bck_conn = target->db;
Py_BEGIN_ALLOW_THREADS
bck_handle = sqlite3_backup_init(bck_conn, "main", self->db, name);
@@ -1637,13 +1725,22 @@ pysqlite_connection_backup(pysqlite_Connection *self, PyObject *args, PyObject *
}
}
+/*[clinic input]
+_sqlite3.Connection.create_collation as pysqlite_connection_create_collation
+
+ name: unicode
+ callback as callable: object
+ /
+
+Creates a collation function. Non-standard.
+[clinic start generated code]*/
+
static PyObject *
-pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
+pysqlite_connection_create_collation_impl(pysqlite_Connection *self,
+ PyObject *name, PyObject *callable)
+/*[clinic end generated code: output=0f63b8995565ae22 input=5c3898813a776cf2]*/
{
- PyObject* callable;
PyObject* uppercase_name = 0;
- PyObject* name;
- PyObject* retval;
Py_ssize_t i, len;
_Py_IDENTIFIER(upper);
const char *uppercase_name_str;
@@ -1655,11 +1752,6 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
goto finally;
}
- if (!PyArg_ParseTuple(args, "UO:create_collation(name, callback)",
- &name, &callable)) {
- goto finally;
- }
-
uppercase_name = _PyObject_CallMethodIdOneArg((PyObject *)&PyUnicode_Type,
&PyId_upper, name);
if (!uppercase_name) {
@@ -1716,37 +1808,47 @@ finally:
Py_XDECREF(uppercase_name);
if (PyErr_Occurred()) {
- retval = NULL;
- } else {
- Py_INCREF(Py_None);
- retval = Py_None;
+ return NULL;
}
-
- return retval;
+ return Py_NewRef(Py_None);
}
-/* Called when the connection is used as a context manager. Returns itself as a
- * convenience to the caller. */
+/*[clinic input]
+_sqlite3.Connection.__enter__ as pysqlite_connection_enter
+
+Called when the connection is used as a context manager.
+
+Returns itself as a convenience to the caller.
+[clinic start generated code]*/
+
static PyObject *
-pysqlite_connection_enter(pysqlite_Connection* self, PyObject* args)
+pysqlite_connection_enter_impl(pysqlite_Connection *self)
+/*[clinic end generated code: output=457b09726d3e9dcd input=127d7a4f17e86d8f]*/
{
- Py_INCREF(self);
- return (PyObject*)self;
+ return Py_NewRef((PyObject *)self);
}
-/** Called when the connection is used as a context manager. If there was any
- * exception, a rollback takes place; otherwise we commit. */
+/*[clinic input]
+_sqlite3.Connection.__exit__ as pysqlite_connection_exit
+
+ type as exc_type: object
+ value as exc_value: object
+ traceback as exc_tb: object
+ /
+
+Called when the connection is used as a context manager.
+
+If there was any exception, a rollback takes place; otherwise we commit.
+[clinic start generated code]*/
+
static PyObject *
-pysqlite_connection_exit(pysqlite_Connection* self, PyObject* args)
+pysqlite_connection_exit_impl(pysqlite_Connection *self, PyObject *exc_type,
+ PyObject *exc_value, PyObject *exc_tb)
+/*[clinic end generated code: output=0705200e9321202a input=bd66f1532c9c54a7]*/
{
- PyObject* exc_type, *exc_value, *exc_tb;
const char* method_name;
PyObject* result;
- if (!PyArg_ParseTuple(args, "OOO", &exc_type, &exc_value, &exc_tb)) {
- return NULL;
- }
-
if (exc_type == Py_None && exc_value == Py_None && exc_tb == Py_None) {
method_name = "commit";
} else {
@@ -1773,48 +1875,26 @@ static PyGetSetDef connection_getset[] = {
};
static PyMethodDef connection_methods[] = {
- {"cursor", (PyCFunction)(void(*)(void))pysqlite_connection_cursor, METH_VARARGS|METH_KEYWORDS,
- PyDoc_STR("Return a cursor for the connection.")},
- {"close", (PyCFunction)pysqlite_connection_close, METH_NOARGS,
- PyDoc_STR("Closes the connection.")},
- {"commit", (PyCFunction)pysqlite_connection_commit, METH_NOARGS,
- PyDoc_STR("Commit the current transaction.")},
- {"rollback", (PyCFunction)pysqlite_connection_rollback, METH_NOARGS,
- PyDoc_STR("Roll back the current transaction.")},
- {"create_function", (PyCFunction)(void(*)(void))pysqlite_connection_create_function, METH_VARARGS|METH_KEYWORDS,
- PyDoc_STR("Creates a new function. Non-standard.")},
- {"create_aggregate", (PyCFunction)(void(*)(void))pysqlite_connection_create_aggregate, METH_VARARGS|METH_KEYWORDS,
- PyDoc_STR("Creates a new aggregate. Non-standard.")},
- {"set_authorizer", (PyCFunction)(void(*)(void))pysqlite_connection_set_authorizer, METH_VARARGS|METH_KEYWORDS,
- PyDoc_STR("Sets authorizer callback. Non-standard.")},
- #ifndef SQLITE_OMIT_LOAD_EXTENSION
- {"enable_load_extension", (PyCFunction)pysqlite_enable_load_extension, METH_VARARGS,
- PyDoc_STR("Enable dynamic loading of SQLite extension modules. Non-standard.")},
- {"load_extension", (PyCFunction)pysqlite_load_extension, METH_VARARGS,
- PyDoc_STR("Load SQLite extension module. Non-standard.")},
- #endif
- {"set_progress_handler", (PyCFunction)(void(*)(void))pysqlite_connection_set_progress_handler, METH_VARARGS|METH_KEYWORDS,
- PyDoc_STR("Sets progress handler callback. Non-standard.")},
- {"set_trace_callback", (PyCFunction)(void(*)(void))pysqlite_connection_set_trace_callback, METH_VARARGS|METH_KEYWORDS,
- PyDoc_STR("Sets a trace callback called for each SQL statement (passed as unicode). Non-standard.")},
- {"execute", (PyCFunction)pysqlite_connection_execute, METH_VARARGS,
- PyDoc_STR("Executes a SQL statement. Non-standard.")},
- {"executemany", (PyCFunction)pysqlite_connection_executemany, METH_VARARGS,
- PyDoc_STR("Repeatedly executes a SQL statement. Non-standard.")},
- {"executescript", (PyCFunction)pysqlite_connection_executescript, METH_VARARGS,
- PyDoc_STR("Executes a multiple SQL statements at once. Non-standard.")},
- {"create_collation", (PyCFunction)pysqlite_connection_create_collation, METH_VARARGS,
- PyDoc_STR("Creates a collation function. Non-standard.")},
- {"interrupt", (PyCFunction)pysqlite_connection_interrupt, METH_NOARGS,
- PyDoc_STR("Abort any pending database operation. Non-standard.")},
- {"iterdump", (PyCFunction)pysqlite_connection_iterdump, METH_NOARGS,
- PyDoc_STR("Returns iterator to the dump of the database in an SQL text format. Non-standard.")},
- {"backup", (PyCFunction)(void(*)(void))pysqlite_connection_backup, METH_VARARGS | METH_KEYWORDS,
- PyDoc_STR("Makes a backup of the database. Non-standard.")},
- {"__enter__", (PyCFunction)pysqlite_connection_enter, METH_NOARGS,
- PyDoc_STR("For context manager. Non-standard.")},
- {"__exit__", (PyCFunction)pysqlite_connection_exit, METH_VARARGS,
- PyDoc_STR("For context manager. Non-standard.")},
+ PYSQLITE_CONNECTION_BACKUP_METHODDEF
+ PYSQLITE_CONNECTION_CLOSE_METHODDEF
+ PYSQLITE_CONNECTION_COMMIT_METHODDEF
+ PYSQLITE_CONNECTION_CREATE_AGGREGATE_METHODDEF
+ PYSQLITE_CONNECTION_CREATE_COLLATION_METHODDEF
+ PYSQLITE_CONNECTION_CREATE_FUNCTION_METHODDEF
+ PYSQLITE_CONNECTION_CURSOR_METHODDEF
+ PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
+ PYSQLITE_CONNECTION_ENTER_METHODDEF
+ PYSQLITE_CONNECTION_EXECUTEMANY_METHODDEF
+ PYSQLITE_CONNECTION_EXECUTESCRIPT_METHODDEF
+ PYSQLITE_CONNECTION_EXECUTE_METHODDEF
+ PYSQLITE_CONNECTION_EXIT_METHODDEF
+ PYSQLITE_CONNECTION_INTERRUPT_METHODDEF
+ PYSQLITE_CONNECTION_ITERDUMP_METHODDEF
+ PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
+ PYSQLITE_CONNECTION_ROLLBACK_METHODDEF
+ PYSQLITE_CONNECTION_SET_AUTHORIZER_METHODDEF
+ PYSQLITE_CONNECTION_SET_PROGRESS_HANDLER_METHODDEF
+ PYSQLITE_CONNECTION_SET_TRACE_CALLBACK_METHODDEF
{NULL, NULL}
};
diff --git a/Modules/_sqlite/connection.h b/Modules/_sqlite/connection.h
index aadf439034..1d1a8ad5ae 100644
--- a/Modules/_sqlite/connection.h
+++ b/Modules/_sqlite/connection.h
@@ -110,11 +110,7 @@ extern PyTypeObject *pysqlite_ConnectionType;
PyObject* pysqlite_connection_alloc(PyTypeObject* type, int aware);
void pysqlite_connection_dealloc(pysqlite_Connection* self);
-PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, PyObject* kwargs);
-PyObject* pysqlite_connection_close(pysqlite_Connection* self, PyObject* args);
PyObject* _pysqlite_connection_begin(pysqlite_Connection* self);
-PyObject* pysqlite_connection_commit(pysqlite_Connection* self, PyObject* args);
-PyObject* pysqlite_connection_rollback(pysqlite_Connection* self, PyObject* args);
PyObject* pysqlite_connection_new(PyTypeObject* type, PyObject* args, PyObject* kw);
int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject* kwargs);
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 3c09c1c6b7..13385f6d50 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -271,8 +271,7 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self)
nbytes = sqlite3_column_bytes(self->statement->st, i);
val_str = (const char*)sqlite3_column_blob(self->statement->st, i);
if (!val_str) {
- Py_INCREF(Py_None);
- converted = Py_None;
+ converted = Py_NewRef(Py_None);
} else {
item = PyBytes_FromStringAndSize(val_str, nbytes);
if (!item)
@@ -285,8 +284,7 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self)
coltype = sqlite3_column_type(self->statement->st, i);
Py_END_ALLOW_THREADS
if (coltype == SQLITE_NULL) {
- Py_INCREF(Py_None);
- converted = Py_None;
+ converted = Py_NewRef(Py_None);
} else if (coltype == SQLITE_INTEGER) {
converted = PyLong_FromLongLong(sqlite3_column_int64(self->statement->st, i));
} else if (coltype == SQLITE_FLOAT) {
@@ -402,8 +400,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* args)
if (PyIter_Check(second_argument)) {
/* iterator */
- Py_INCREF(second_argument);
- parameters_iter = second_argument;
+ parameters_iter = Py_NewRef(second_argument);
} else {
/* sequence */
parameters_iter = PyObject_GetIter(second_argument);
@@ -456,8 +453,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* args)
if (!func_args) {
goto error;
}
- Py_INCREF(operation);
- if (PyTuple_SetItem(func_args, 0, operation) != 0) {
+ if (PyTuple_SetItem(func_args, 0, Py_NewRef(operation)) != 0) {
goto error;
}
@@ -555,12 +551,12 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* args)
goto error;
}
PyTuple_SetItem(descriptor, 0, column_name);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 1, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 2, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 3, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 4, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 5, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 6, Py_None);
+ PyTuple_SetItem(descriptor, 1, Py_NewRef(Py_None));
+ PyTuple_SetItem(descriptor, 2, Py_NewRef(Py_None));
+ PyTuple_SetItem(descriptor, 3, Py_NewRef(Py_None));
+ PyTuple_SetItem(descriptor, 4, Py_NewRef(Py_None));
+ PyTuple_SetItem(descriptor, 5, Py_NewRef(Py_None));
+ PyTuple_SetItem(descriptor, 6, Py_NewRef(Py_None));
PyTuple_SetItem(self->description, i, descriptor);
}
}
@@ -610,8 +606,7 @@ error:
self->rowcount = -1L;
return NULL;
} else {
- Py_INCREF(self);
- return (PyObject*)self;
+ return Py_NewRef((PyObject *)self);
}
}
@@ -628,6 +623,7 @@ PyObject* pysqlite_cursor_executemany(pysqlite_Cursor* self, PyObject* args)
static PyObject *
pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args)
{
+ _Py_IDENTIFIER(commit);
PyObject* script_obj;
const char* script_cstr;
sqlite3_stmt* statement;
@@ -655,7 +651,7 @@ pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args)
}
/* commit first */
- result = pysqlite_connection_commit(self->connection, NULL);
+ result = _PyObject_CallMethodIdNoArgs((PyObject *)self->connection, &PyId_commit);
if (!result) {
goto error;
}
@@ -705,8 +701,7 @@ error:
if (PyErr_Occurred()) {
return NULL;
} else {
- Py_INCREF(self);
- return (PyObject*)self;
+ return Py_NewRef((PyObject *)self);
}
}
diff --git a/Modules/_sqlite/microprotocols.c b/Modules/_sqlite/microprotocols.c
index cf1fefd671..e219a7239f 100644
--- a/Modules/_sqlite/microprotocols.c
+++ b/Modules/_sqlite/microprotocols.c
@@ -43,12 +43,10 @@ pysqlite_microprotocols_init(PyObject *module)
return -1;
}
- if (PyModule_AddObject(module, "adapters", psyco_adapters) < 0) {
- Py_DECREF(psyco_adapters);
- return -1;
- }
+ int res = PyModule_AddObjectRef(module, "adapters", psyco_adapters);
+ Py_DECREF(psyco_adapters);
- return 0;
+ return res;
}
@@ -142,8 +140,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
}
if (alt) {
- Py_INCREF(alt);
- return alt;
+ return Py_NewRef(alt);
}
/* else set the right exception and return NULL */
PyErr_SetString(pysqlite_ProgrammingError, "can't adapt");
diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c
index 3332440238..cd2eb576c7 100644
--- a/Modules/_sqlite/module.c
+++ b/Modules/_sqlite/module.c
@@ -120,17 +120,11 @@ static PyObject *
pysqlite_complete_statement_impl(PyObject *module, const char *statement)
/*[clinic end generated code: output=e55f1ff1952df558 input=f6b24996b31c5c33]*/
{
- PyObject* result;
-
if (sqlite3_complete(statement)) {
- result = Py_True;
+ return Py_NewRef(Py_True);
} else {
- result = Py_False;
+ return Py_NewRef(Py_False);
}
-
- Py_INCREF(result);
-
- return result;
}
/*[clinic input]
@@ -219,8 +213,7 @@ pysqlite_register_converter_impl(PyObject *module, PyObject *orig_name,
goto error;
}
- Py_INCREF(Py_None);
- retval = Py_None;
+ retval = Py_NewRef(Py_None);
error:
Py_XDECREF(name);
return retval;
@@ -263,17 +256,17 @@ pysqlite_adapt_impl(PyObject *module, PyObject *obj, PyObject *proto,
return pysqlite_microprotocols_adapt(obj, proto, alt);
}
-static void converters_init(PyObject* module)
+static int converters_init(PyObject* module)
{
_pysqlite_converters = PyDict_New();
if (!_pysqlite_converters) {
- return;
+ return -1;
}
- if (PyModule_AddObject(module, "converters", _pysqlite_converters) < 0) {
- Py_DECREF(_pysqlite_converters);
- }
- return;
+ int res = PyModule_AddObjectRef(module, "converters", _pysqlite_converters);
+ Py_DECREF(_pysqlite_converters);
+
+ return res;
}
static PyMethodDef module_methods[] = {
@@ -361,8 +354,9 @@ do { \
if (!exc) { \
goto error; \
} \
- if (PyModule_AddObject(module, name, exc) < 0) { \
- Py_DECREF(exc); \
+ int res = PyModule_AddObjectRef(module, name, exc); \
+ Py_DECREF(exc); \
+ if (res < 0) { \
goto error; \
} \
} while (0)
@@ -411,17 +405,6 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
ADD_EXCEPTION(module, "DataError", pysqlite_DataError, pysqlite_DatabaseError);
ADD_EXCEPTION(module, "NotSupportedError", pysqlite_NotSupportedError, pysqlite_DatabaseError);
- /* In Python 2.x, setting Connection.text_factory to
- OptimizedUnicode caused Unicode objects to be returned for
- non-ASCII data and bytestrings to be returned for ASCII data.
- Now OptimizedUnicode is an alias for str, so it has no
- effect. */
- Py_INCREF((PyObject*)&PyUnicode_Type);
- if (PyModule_AddObject(module, "OptimizedUnicode", (PyObject*)&PyUnicode_Type) < 0) {
- Py_DECREF((PyObject*)&PyUnicode_Type);
- goto error;
- }
-
/* Set integer constants */
if (add_integer_constants(module) < 0) {
goto error;
@@ -441,7 +424,9 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
}
/* initialize the default converters */
- converters_init(module);
+ if (converters_init(module) < 0) {
+ goto error;
+ }
error:
if (PyErr_Occurred())
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c
index 76b6f04f0c..9086c19af7 100644
--- a/Modules/_sqlite/row.c
+++ b/Modules/_sqlite/row.c
@@ -63,20 +63,16 @@ pysqlite_row_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
if (self == NULL)
return NULL;
- Py_INCREF(data);
- self->data = data;
-
- Py_INCREF(cursor->description);
- self->description = cursor->description;
+ self->data = Py_NewRef(data);
+ self->description = Py_NewRef(cursor->description);
return (PyObject *) self;
}
PyObject* pysqlite_row_item(pysqlite_Row* self, Py_ssize_t idx)
{
- PyObject* item = PyTuple_GetItem(self->data, idx);
- Py_XINCREF(item);
- return item;
+ PyObject *item = PyTuple_GetItem(self->data, idx);
+ return Py_XNewRef(item);
}
static int
@@ -111,7 +107,6 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
{
Py_ssize_t _idx;
Py_ssize_t nitems, i;
- PyObject* item;
if (PyLong_Check(idx)) {
_idx = PyNumber_AsSsize_t(idx, PyExc_IndexError);
@@ -119,9 +114,9 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
return NULL;
if (_idx < 0)
_idx += PyTuple_GET_SIZE(self->data);
- item = PyTuple_GetItem(self->data, _idx);
- Py_XINCREF(item);
- return item;
+
+ PyObject *item = PyTuple_GetItem(self->data, _idx);
+ return Py_XNewRef(item);
} else if (PyUnicode_Check(idx)) {
nitems = PyTuple_Size(self->description);
@@ -135,9 +130,8 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
}
if (eq) {
/* found item */
- item = PyTuple_GetItem(self->data, i);
- Py_INCREF(item);
- return item;
+ PyObject *item = PyTuple_GetItem(self->data, i);
+ return Py_XNewRef(item);
}
}
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index 4682d286c5..b62de58109 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -72,8 +72,7 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
}
self->in_weakreflist = NULL;
- Py_INCREF(sql);
- self->sql = sql;
+ self->sql = Py_NewRef(sql);
/* Determine if the statement is a DML statement.
SELECT is the only exception. See #9924. */
@@ -240,11 +239,11 @@ void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* para
}
for (i = 0; i < num_params; i++) {
if (PyTuple_CheckExact(parameters)) {
- current_param = PyTuple_GET_ITEM(parameters, i);
- Py_INCREF(current_param);
+ PyObject *item = PyTuple_GET_ITEM(parameters, i);
+ current_param = Py_NewRef(item);
} else if (PyList_CheckExact(parameters)) {
- current_param = PyList_GetItem(parameters, i);
- Py_XINCREF(current_param);
+ PyObject *item = PyList_GetItem(parameters, i);
+ current_param = Py_XNewRef(item);
} else {
current_param = PySequence_GetItem(parameters, i);
}
@@ -290,8 +289,8 @@ void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* para
return;
}
if (PyDict_CheckExact(parameters)) {
- current_param = PyDict_GetItemWithError(parameters, binding_name_obj);
- Py_XINCREF(current_param);
+ PyObject *item = PyDict_GetItemWithError(parameters, binding_name_obj);
+ current_param = Py_XNewRef(item);
} else {
current_param = PyObject_GetItem(parameters, binding_name_obj);
}
diff --git a/Modules/_sre.c b/Modules/_sre.c
index fbabeb7c9f..57faf7bdaa 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -197,7 +197,7 @@ static void
data_stack_dealloc(SRE_STATE* state)
{
if (state->data_stack) {
- PyMem_FREE(state->data_stack);
+ PyMem_Free(state->data_stack);
state->data_stack = NULL;
}
state->data_stack_size = state->data_stack_base = 0;
@@ -213,7 +213,7 @@ data_stack_grow(SRE_STATE* state, Py_ssize_t size)
void* stack;
cursize = minsize+minsize/4+1024;
TRACE(("allocate/grow stack %zd\n", cursize));
- stack = PyMem_REALLOC(state->data_stack, cursize);
+ stack = PyMem_Realloc(state->data_stack, cursize);
if (!stack) {
data_stack_dealloc(state);
return SRE_ERROR_MEMORY;
@@ -248,22 +248,36 @@ data_stack_grow(SRE_STATE* state, Py_ssize_t size)
/* -------------------------------------------------------------------- */
/* factories and destructors */
-/* see sre.h for object declarations */
-static PyObject*pattern_new_match(PatternObject*, SRE_STATE*, Py_ssize_t);
-static PyObject *pattern_scanner(PatternObject *, PyObject *, Py_ssize_t, Py_ssize_t);
+/* module state */
+typedef struct {
+ PyTypeObject *Pattern_Type;
+ PyTypeObject *Match_Type;
+ PyTypeObject *Scanner_Type;
+} _sremodulestate;
+
+static _sremodulestate *
+get_sre_module_state(PyObject *m)
+{
+ _sremodulestate *state = (_sremodulestate *)PyModule_GetState(m);
+ assert(state);
+ return state;
+}
+static struct PyModuleDef sremodule;
+#define get_sre_module_state_by_class(cls) \
+ (get_sre_module_state(PyType_GetModule(cls)))
+
+/* see sre.h for object declarations */
+static PyObject*pattern_new_match(_sremodulestate *, PatternObject*, SRE_STATE*, Py_ssize_t);
+static PyObject *pattern_scanner(_sremodulestate *, PatternObject *, PyObject *, Py_ssize_t, Py_ssize_t);
/*[clinic input]
module _sre
-class _sre.SRE_Pattern "PatternObject *" "&Pattern_Type"
-class _sre.SRE_Match "MatchObject *" "&Match_Type"
-class _sre.SRE_Scanner "ScannerObject *" "&Scanner_Type"
+class _sre.SRE_Pattern "PatternObject *" "get_sre_module_state_by_class(tp)->Pattern_Type"
+class _sre.SRE_Match "MatchObject *" "get_sre_module_state_by_class(tp)->Match_Type"
+class _sre.SRE_Scanner "ScannerObject *" "get_sre_module_state_by_class(tp)->Scanner_Type"
[clinic start generated code]*/
-/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b0230ec19a0deac8]*/
-
-static PyTypeObject Pattern_Type;
-static PyTypeObject Match_Type;
-static PyTypeObject Scanner_Type;
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=fe2966e32b66a231]*/
/*[clinic input]
_sre.getcodesize -> int
@@ -458,7 +472,7 @@ state_init(SRE_STATE* state, PatternObject* pattern, PyObject* string,
/* We add an explicit cast here because MSVC has a bug when
compiling C code where it believes that `const void**` cannot be
safely casted to `void*`, see bpo-39943 for details. */
- PyMem_Del((void*) state->mark);
+ PyMem_Free((void*) state->mark);
state->mark = NULL;
if (state->buffer.buf)
PyBuffer_Release(&state->buffer);
@@ -473,7 +487,7 @@ state_fini(SRE_STATE* state)
Py_XDECREF(state->string);
data_stack_dealloc(state);
/* See above PyMem_Del for why we explicitly cast here. */
- PyMem_Del((void*) state->mark);
+ PyMem_Free((void*) state->mark);
state->mark = NULL;
}
@@ -550,12 +564,15 @@ pattern_error(Py_ssize_t status)
static void
pattern_dealloc(PatternObject* self)
{
+ PyTypeObject *tp = Py_TYPE(self);
+
if (self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
Py_XDECREF(self->pattern);
Py_XDECREF(self->groupindex);
Py_XDECREF(self->indexgroup);
- PyObject_DEL(self);
+ PyObject_Free(self);
+ Py_DECREF(tp);
}
LOCAL(Py_ssize_t)
@@ -583,6 +600,8 @@ sre_search(SRE_STATE* state, SRE_CODE* pattern)
/*[clinic input]
_sre.SRE_Pattern.match
+ cls: defining_class
+ /
string: object
pos: Py_ssize_t = 0
endpos: Py_ssize_t(c_default="PY_SSIZE_T_MAX") = sys.maxsize
@@ -591,10 +610,12 @@ Matches zero or more characters at the beginning of the string.
[clinic start generated code]*/
static PyObject *
-_sre_SRE_Pattern_match_impl(PatternObject *self, PyObject *string,
- Py_ssize_t pos, Py_ssize_t endpos)
-/*[clinic end generated code: output=ea2d838888510661 input=a2ba191647abebe5]*/
+_sre_SRE_Pattern_match_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *string, Py_ssize_t pos,
+ Py_ssize_t endpos)
+/*[clinic end generated code: output=ec6208ea58a0cca0 input=4bdb9c3e564d13ac]*/
{
+ _sremodulestate *module_state = get_sre_module_state_by_class(cls);
SRE_STATE state;
Py_ssize_t status;
PyObject *match;
@@ -614,7 +635,7 @@ _sre_SRE_Pattern_match_impl(PatternObject *self, PyObject *string,
return NULL;
}
- match = pattern_new_match(self, &state, status);
+ match = pattern_new_match(module_state, self, &state, status);
state_fini(&state);
return match;
}
@@ -622,6 +643,8 @@ _sre_SRE_Pattern_match_impl(PatternObject *self, PyObject *string,
/*[clinic input]
_sre.SRE_Pattern.fullmatch
+ cls: defining_class
+ /
string: object
pos: Py_ssize_t = 0
endpos: Py_ssize_t(c_default="PY_SSIZE_T_MAX") = sys.maxsize
@@ -630,10 +653,12 @@ Matches against all of the string.
[clinic start generated code]*/
static PyObject *
-_sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyObject *string,
- Py_ssize_t pos, Py_ssize_t endpos)
-/*[clinic end generated code: output=5833c47782a35f4a input=d9fb03a7625b5828]*/
+_sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *string, Py_ssize_t pos,
+ Py_ssize_t endpos)
+/*[clinic end generated code: output=625b75b027ef94da input=50981172ab0fcfdd]*/
{
+ _sremodulestate *module_state = get_sre_module_state_by_class(cls);
SRE_STATE state;
Py_ssize_t status;
PyObject *match;
@@ -654,7 +679,7 @@ _sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyObject *string,
return NULL;
}
- match = pattern_new_match(self, &state, status);
+ match = pattern_new_match(module_state, self, &state, status);
state_fini(&state);
return match;
}
@@ -662,6 +687,8 @@ _sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyObject *string,
/*[clinic input]
_sre.SRE_Pattern.search
+ cls: defining_class
+ /
string: object
pos: Py_ssize_t = 0
endpos: Py_ssize_t(c_default="PY_SSIZE_T_MAX") = sys.maxsize
@@ -672,10 +699,12 @@ Return None if no position in the string matches.
[clinic start generated code]*/
static PyObject *
-_sre_SRE_Pattern_search_impl(PatternObject *self, PyObject *string,
- Py_ssize_t pos, Py_ssize_t endpos)
-/*[clinic end generated code: output=25f302a644e951e8 input=4ae5cb7dc38fed1b]*/
+_sre_SRE_Pattern_search_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *string, Py_ssize_t pos,
+ Py_ssize_t endpos)
+/*[clinic end generated code: output=bd7f2d9d583e1463 input=afa9afb66a74a4b3]*/
{
+ _sremodulestate *module_state = get_sre_module_state_by_class(cls);
SRE_STATE state;
Py_ssize_t status;
PyObject *match;
@@ -694,7 +723,7 @@ _sre_SRE_Pattern_search_impl(PatternObject *self, PyObject *string,
return NULL;
}
- match = pattern_new_match(self, &state, status);
+ match = pattern_new_match(module_state, self, &state, status);
state_fini(&state);
return match;
}
@@ -826,6 +855,8 @@ error:
/*[clinic input]
_sre.SRE_Pattern.finditer
+ cls: defining_class
+ /
string: object
pos: Py_ssize_t = 0
endpos: Py_ssize_t(c_default="PY_SSIZE_T_MAX") = sys.maxsize
@@ -836,15 +867,17 @@ For each match, the iterator returns a match object.
[clinic start generated code]*/
static PyObject *
-_sre_SRE_Pattern_finditer_impl(PatternObject *self, PyObject *string,
- Py_ssize_t pos, Py_ssize_t endpos)
-/*[clinic end generated code: output=0bbb1a0aeb38bb14 input=612aab69e9fe08e4]*/
+_sre_SRE_Pattern_finditer_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *string, Py_ssize_t pos,
+ Py_ssize_t endpos)
+/*[clinic end generated code: output=1791dbf3618ade56 input=812e332a4848cbaf]*/
{
+ _sremodulestate *module_state = get_sre_module_state_by_class(cls);
PyObject* scanner;
PyObject* search;
PyObject* iterator;
- scanner = pattern_scanner(self, string, pos, endpos);
+ scanner = pattern_scanner(module_state, self, string, pos, endpos);
if (!scanner)
return NULL;
@@ -862,6 +895,8 @@ _sre_SRE_Pattern_finditer_impl(PatternObject *self, PyObject *string,
/*[clinic input]
_sre.SRE_Pattern.scanner
+ cls: defining_class
+ /
string: object
pos: Py_ssize_t = 0
endpos: Py_ssize_t(c_default="PY_SSIZE_T_MAX") = sys.maxsize
@@ -869,11 +904,14 @@ _sre.SRE_Pattern.scanner
[clinic start generated code]*/
static PyObject *
-_sre_SRE_Pattern_scanner_impl(PatternObject *self, PyObject *string,
- Py_ssize_t pos, Py_ssize_t endpos)
-/*[clinic end generated code: output=54ea548aed33890b input=3aacdbde77a3a637]*/
+_sre_SRE_Pattern_scanner_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *string, Py_ssize_t pos,
+ Py_ssize_t endpos)
+/*[clinic end generated code: output=f70cd506112f1bd9 input=2e487e5151bcee4c]*/
{
- return pattern_scanner(self, string, pos, endpos);
+ _sremodulestate *module_state = get_sre_module_state_by_class(cls);
+
+ return pattern_scanner(module_state, self, string, pos, endpos);
}
/*[clinic input]
@@ -980,8 +1018,12 @@ error:
}
static PyObject*
-pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string,
- Py_ssize_t count, Py_ssize_t subn)
+pattern_subx(_sremodulestate* module_state,
+ PatternObject* self,
+ PyObject* ptemplate,
+ PyObject* string,
+ Py_ssize_t count,
+ Py_ssize_t subn)
{
SRE_STATE state;
PyObject* list;
@@ -1083,7 +1125,7 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string,
if (filter_is_callable) {
/* pass match object through filter */
- match = pattern_new_match(self, &state, 1);
+ match = pattern_new_match(module_state, self, &state, 1);
if (!match)
goto error;
item = PyObject_CallOneArg(filter, match);
@@ -1163,6 +1205,8 @@ error:
/*[clinic input]
_sre.SRE_Pattern.sub
+ cls: defining_class
+ /
repl: object
string: object
count: Py_ssize_t = 0
@@ -1171,16 +1215,20 @@ Return the string obtained by replacing the leftmost non-overlapping occurrences
[clinic start generated code]*/
static PyObject *
-_sre_SRE_Pattern_sub_impl(PatternObject *self, PyObject *repl,
- PyObject *string, Py_ssize_t count)
-/*[clinic end generated code: output=1dbf2ec3479cba00 input=c53d70be0b3caf86]*/
+_sre_SRE_Pattern_sub_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *repl, PyObject *string, Py_ssize_t count)
+/*[clinic end generated code: output=4be141ab04bca60d input=d8d1d4ac2311a07c]*/
{
- return pattern_subx(self, repl, string, count, 0);
+ _sremodulestate *module_state = get_sre_module_state_by_class(cls);
+
+ return pattern_subx(module_state, self, repl, string, count, 0);
}
/*[clinic input]
_sre.SRE_Pattern.subn
+ cls: defining_class
+ /
repl: object
string: object
count: Py_ssize_t = 0
@@ -1189,11 +1237,14 @@ Return the tuple (new_string, number_of_subs_made) found by replacing the leftmo
[clinic start generated code]*/
static PyObject *
-_sre_SRE_Pattern_subn_impl(PatternObject *self, PyObject *repl,
- PyObject *string, Py_ssize_t count)
-/*[clinic end generated code: output=0d9522cd529e9728 input=e7342d7ce6083577]*/
+_sre_SRE_Pattern_subn_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *repl, PyObject *string,
+ Py_ssize_t count)
+/*[clinic end generated code: output=da02fd85258b1e1f input=8b78a65b8302e58d]*/
{
- return pattern_subx(self, repl, string, count, 1);
+ _sremodulestate *module_state = get_sre_module_state_by_class(cls);
+
+ return pattern_subx(module_state, self, repl, string, count, 1);
}
/*[clinic input]
@@ -1338,12 +1389,13 @@ _sre_compile_impl(PyObject *module, PyObject *pattern, int flags,
{
/* "compile" pattern descriptor to pattern object */
+ _sremodulestate *module_state = get_sre_module_state(module);
PatternObject* self;
Py_ssize_t i, n;
n = PyList_GET_SIZE(code);
/* coverity[ampersand_in_size] */
- self = PyObject_NewVar(PatternObject, &Pattern_Type, n);
+ self = PyObject_NewVar(PatternObject, module_state->Pattern_Type, n);
if (!self)
return NULL;
self->weakreflist = NULL;
@@ -1887,10 +1939,13 @@ _validate(PatternObject *self)
static void
match_dealloc(MatchObject* self)
{
+ PyTypeObject *tp = Py_TYPE(self);
+
Py_XDECREF(self->regs);
Py_XDECREF(self->string);
Py_DECREF(self->pattern);
- PyObject_DEL(self);
+ PyObject_Free(self);
+ Py_DECREF(tp);
}
static PyObject*
@@ -2319,7 +2374,10 @@ match_repr(MatchObject *self)
static PyObject*
-pattern_new_match(PatternObject* pattern, SRE_STATE* state, Py_ssize_t status)
+pattern_new_match(_sremodulestate* module_state,
+ PatternObject* pattern,
+ SRE_STATE* state,
+ Py_ssize_t status)
{
/* create match object (from state object) */
@@ -2332,7 +2390,8 @@ pattern_new_match(PatternObject* pattern, SRE_STATE* state, Py_ssize_t status)
/* create match object (with room for extra group marks) */
/* coverity[ampersand_in_size] */
- match = PyObject_NewVar(MatchObject, &Match_Type,
+ match = PyObject_NewVar(MatchObject,
+ module_state->Match_Type,
2*(pattern->groups+1));
if (!match)
return NULL;
@@ -2387,20 +2446,27 @@ pattern_new_match(PatternObject* pattern, SRE_STATE* state, Py_ssize_t status)
static void
scanner_dealloc(ScannerObject* self)
{
+ PyTypeObject *tp = Py_TYPE(self);
+
state_fini(&self->state);
Py_XDECREF(self->pattern);
- PyObject_DEL(self);
+ PyObject_Free(self);
+ Py_DECREF(tp);
}
/*[clinic input]
_sre.SRE_Scanner.match
+ cls: defining_class
+ /
+
[clinic start generated code]*/
static PyObject *
-_sre_SRE_Scanner_match_impl(ScannerObject *self)
-/*[clinic end generated code: output=936b30c63d4b81eb input=881a0154f8c13d9a]*/
+_sre_SRE_Scanner_match_impl(ScannerObject *self, PyTypeObject *cls)
+/*[clinic end generated code: output=6e22c149dc0f0325 input=b5146e1f30278cb7]*/
{
+ _sremodulestate *module_state = get_sre_module_state_by_class(cls);
SRE_STATE* state = &self->state;
PyObject* match;
Py_ssize_t status;
@@ -2416,8 +2482,8 @@ _sre_SRE_Scanner_match_impl(ScannerObject *self)
if (PyErr_Occurred())
return NULL;
- match = pattern_new_match((PatternObject*) self->pattern,
- state, status);
+ match = pattern_new_match(module_state, (PatternObject*) self->pattern,
+ state, status);
if (status == 0)
state->start = NULL;
@@ -2433,12 +2499,16 @@ _sre_SRE_Scanner_match_impl(ScannerObject *self)
/*[clinic input]
_sre.SRE_Scanner.search
+ cls: defining_class
+ /
+
[clinic start generated code]*/
static PyObject *
-_sre_SRE_Scanner_search_impl(ScannerObject *self)
-/*[clinic end generated code: output=7dc211986088f025 input=161223ee92ef9270]*/
+_sre_SRE_Scanner_search_impl(ScannerObject *self, PyTypeObject *cls)
+/*[clinic end generated code: output=23e8fc78013f9161 input=056c2d37171d0bf2]*/
{
+ _sremodulestate *module_state = get_sre_module_state_by_class(cls);
SRE_STATE* state = &self->state;
PyObject* match;
Py_ssize_t status;
@@ -2454,8 +2524,8 @@ _sre_SRE_Scanner_search_impl(ScannerObject *self)
if (PyErr_Occurred())
return NULL;
- match = pattern_new_match((PatternObject*) self->pattern,
- state, status);
+ match = pattern_new_match(module_state, (PatternObject*) self->pattern,
+ state, status);
if (status == 0)
state->start = NULL;
@@ -2468,12 +2538,16 @@ _sre_SRE_Scanner_search_impl(ScannerObject *self)
}
static PyObject *
-pattern_scanner(PatternObject *self, PyObject *string, Py_ssize_t pos, Py_ssize_t endpos)
+pattern_scanner(_sremodulestate *module_state,
+ PatternObject *self,
+ PyObject *string,
+ Py_ssize_t pos,
+ Py_ssize_t endpos)
{
ScannerObject* scanner;
/* create scanner object */
- scanner = PyObject_New(ScannerObject, &Scanner_Type);
+ scanner = PyObject_New(ScannerObject, module_state->Scanner_Type);
if (!scanner)
return NULL;
scanner->pattern = NULL;
@@ -2516,6 +2590,8 @@ pattern_hash(PatternObject *self)
static PyObject*
pattern_richcompare(PyObject *lefto, PyObject *righto, int op)
{
+ PyTypeObject *tp = Py_TYPE(lefto);
+ _sremodulestate *module_state = get_sre_module_state_by_class(tp);
PatternObject *left, *right;
int cmp;
@@ -2523,7 +2599,8 @@ pattern_richcompare(PyObject *lefto, PyObject *righto, int op)
Py_RETURN_NOTIMPLEMENTED;
}
- if (!Py_IS_TYPE(lefto, &Pattern_Type) || !Py_IS_TYPE(righto, &Pattern_Type)) {
+ if (!Py_IS_TYPE(righto, module_state->Pattern_Type))
+ {
Py_RETURN_NOTIMPLEMENTED;
}
@@ -2592,47 +2669,28 @@ static PyMemberDef pattern_members[] = {
"The regex matching flags."},
{"groups", T_PYSSIZET, PAT_OFF(groups), READONLY,
"The number of capturing groups in the pattern."},
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(PatternObject, weakreflist), READONLY},
{NULL} /* Sentinel */
};
-static PyTypeObject Pattern_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "re.Pattern",
- sizeof(PatternObject), sizeof(SRE_CODE),
- (destructor)pattern_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_as_async */
- (reprfunc)pattern_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)pattern_hash, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- pattern_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- pattern_richcompare, /* tp_richcompare */
- offsetof(PatternObject, weakreflist), /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- pattern_methods, /* tp_methods */
- pattern_members, /* tp_members */
- pattern_getset, /* tp_getset */
+static PyType_Slot pattern_slots[] = {
+ {Py_tp_dealloc, (destructor)pattern_dealloc},
+ {Py_tp_repr, (reprfunc)pattern_repr},
+ {Py_tp_hash, (hashfunc)pattern_hash},
+ {Py_tp_doc, (void *)pattern_doc},
+ {Py_tp_richcompare, pattern_richcompare},
+ {Py_tp_methods, pattern_methods},
+ {Py_tp_members, pattern_members},
+ {Py_tp_getset, pattern_getset},
+ {0, NULL},
};
-/* Match objects do not support length or assignment, but do support
- __getitem__. */
-static PyMappingMethods match_as_mapping = {
- NULL,
- (binaryfunc)match_getitem,
- NULL
+static PyType_Spec pattern_spec = {
+ .name = "re.Pattern",
+ .basicsize = sizeof(PatternObject),
+ .itemsize = sizeof(SRE_CODE),
+ .flags = Py_TPFLAGS_DEFAULT,
+ .slots = pattern_slots,
};
static PyMethodDef match_methods[] = {
@@ -2674,37 +2732,30 @@ static PyMemberDef match_members[] = {
/* FIXME: implement setattr("string", None) as a special case (to
detach the associated string, if any */
+static PyType_Slot match_slots[] = {
+ {Py_tp_dealloc, match_dealloc},
+ {Py_tp_repr, match_repr},
+ {Py_tp_doc, (void *)match_doc},
+ {Py_tp_methods, match_methods},
+ {Py_tp_members, match_members},
+ {Py_tp_getset, match_getset},
+
+ /* As mapping.
+ *
+ * Match objects do not support length or assignment, but do support
+ * __getitem__.
+ */
+ {Py_mp_subscript, match_getitem},
+
+ {0, NULL},
+};
-static PyTypeObject Match_Type = {
- PyVarObject_HEAD_INIT(NULL,0)
- "re.Match",
- sizeof(MatchObject), sizeof(Py_ssize_t),
- (destructor)match_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_as_async */
- (reprfunc)match_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- &match_as_mapping, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- match_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- match_methods, /* tp_methods */
- match_members, /* tp_members */
- match_getset, /* tp_getset */
+static PyType_Spec match_spec = {
+ .name = "re.Match",
+ .basicsize = sizeof(MatchObject),
+ .itemsize = sizeof(Py_ssize_t),
+ .flags = Py_TPFLAGS_DEFAULT,
+ .slots = match_slots,
};
static PyMethodDef scanner_methods[] = {
@@ -2719,36 +2770,18 @@ static PyMemberDef scanner_members[] = {
{NULL} /* Sentinel */
};
-static PyTypeObject Scanner_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_" SRE_MODULE ".SRE_Scanner",
- sizeof(ScannerObject), 0,
- (destructor)scanner_dealloc,/* tp_dealloc */
- 0, /* tp_vectorcall_offset */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_as_async */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- 0, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- scanner_methods, /* tp_methods */
- scanner_members, /* tp_members */
- 0, /* tp_getset */
+static PyType_Slot scanner_slots[] = {
+ {Py_tp_dealloc, scanner_dealloc},
+ {Py_tp_methods, scanner_methods},
+ {Py_tp_members, scanner_members},
+ {0, NULL},
+};
+
+static PyType_Spec scanner_spec = {
+ .name = "_" SRE_MODULE ".SRE_Scanner",
+ .basicsize = sizeof(ScannerObject),
+ .flags = Py_TPFLAGS_DEFAULT,
+ .slots = scanner_slots,
};
static PyMethodDef _functions[] = {
@@ -2761,64 +2794,108 @@ static PyMethodDef _functions[] = {
{NULL, NULL}
};
-static struct PyModuleDef sremodule = {
- PyModuleDef_HEAD_INIT,
- "_" SRE_MODULE,
- NULL,
- -1,
- _functions,
- NULL,
- NULL,
- NULL,
- NULL
-};
+static int
+sre_traverse(PyObject *module, visitproc visit, void *arg)
+{
+ _sremodulestate *state = get_sre_module_state(module);
+
+ Py_VISIT(state->Pattern_Type);
+ Py_VISIT(state->Match_Type);
+ Py_VISIT(state->Scanner_Type);
+
+ return 0;
+}
-PyMODINIT_FUNC PyInit__sre(void)
+static int
+sre_clear(PyObject *module)
{
- PyObject* m;
- PyObject* d;
- PyObject* x;
+ _sremodulestate *state = get_sre_module_state(module);
- /* Patch object types */
- if (PyType_Ready(&Pattern_Type) || PyType_Ready(&Match_Type) ||
- PyType_Ready(&Scanner_Type))
- return NULL;
+ Py_CLEAR(state->Pattern_Type);
+ Py_CLEAR(state->Match_Type);
+ Py_CLEAR(state->Scanner_Type);
- m = PyModule_Create(&sremodule);
- if (m == NULL)
- return NULL;
- d = PyModule_GetDict(m);
+ return 0;
+}
- x = PyLong_FromLong(SRE_MAGIC);
- if (x) {
- PyDict_SetItemString(d, "MAGIC", x);
- Py_DECREF(x);
- }
+static void
+sre_free(void *module)
+{
+ sre_clear((PyObject *)module);
+}
+
+#define CREATE_TYPE(m, type, spec) \
+do { \
+ type = (PyTypeObject *)PyType_FromModuleAndSpec(m, spec, NULL); \
+ if (type == NULL) { \
+ goto error; \
+ } \
+} while (0)
+
+#define ADD_ULONG_CONSTANT(module, name, value) \
+ do { \
+ PyObject *o = PyLong_FromUnsignedLong(value); \
+ if (!o) \
+ goto error; \
+ int res = PyModule_AddObjectRef(module, name, o); \
+ Py_DECREF(o); \
+ if (res < 0) { \
+ goto error; \
+ } \
+} while (0)
- x = PyLong_FromLong(sizeof(SRE_CODE));
- if (x) {
- PyDict_SetItemString(d, "CODESIZE", x);
- Py_DECREF(x);
- }
+static int
+sre_exec(PyObject *m)
+{
+ _sremodulestate *state;
+
+ /* Create heap types */
+ state = get_sre_module_state(m);
+ CREATE_TYPE(m, state->Pattern_Type, &pattern_spec);
+ CREATE_TYPE(m, state->Match_Type, &match_spec);
+ CREATE_TYPE(m, state->Scanner_Type, &scanner_spec);
- x = PyLong_FromUnsignedLong(SRE_MAXREPEAT);
- if (x) {
- PyDict_SetItemString(d, "MAXREPEAT", x);
- Py_DECREF(x);
+ if (PyModule_AddIntConstant(m, "MAGIC", SRE_MAGIC) < 0) {
+ goto error;
}
- x = PyLong_FromUnsignedLong(SRE_MAXGROUPS);
- if (x) {
- PyDict_SetItemString(d, "MAXGROUPS", x);
- Py_DECREF(x);
+ if (PyModule_AddIntConstant(m, "CODESIZE", sizeof(SRE_CODE)) < 0) {
+ goto error;
}
- x = PyUnicode_FromString(copyright);
- if (x) {
- PyDict_SetItemString(d, "copyright", x);
- Py_DECREF(x);
+ ADD_ULONG_CONSTANT(m, "MAXREPEAT", SRE_MAXREPEAT);
+ ADD_ULONG_CONSTANT(m, "MAXGROUPS", SRE_MAXGROUPS);
+
+ if (PyModule_AddStringConstant(m, "copyright", copyright) < 0) {
+ goto error;
}
- return m;
+
+ return 0;
+
+error:
+ return -1;
+}
+
+static PyModuleDef_Slot sre_slots[] = {
+ {Py_mod_exec, sre_exec},
+ {0, NULL},
+};
+
+static struct PyModuleDef sremodule = {
+ .m_base = PyModuleDef_HEAD_INIT,
+ .m_name = "_" SRE_MODULE,
+ .m_size = sizeof(_sremodulestate),
+ .m_methods = _functions,
+ .m_slots = sre_slots,
+ .m_traverse = sre_traverse,
+ .m_free = sre_free,
+ .m_clear = sre_clear,
+};
+
+PyMODINIT_FUNC
+PyInit__sre(void)
+{
+ return PyModuleDef_Init(&sremodule);
}
/* vim:ts=4:sw=4:et
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 54c365b88e..96d2796fcf 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -487,10 +487,10 @@ typedef struct {
PySSLContext *ctx;
} PySSLSession;
-static PyTypeObject PySSLContext_Type;
-static PyTypeObject PySSLSocket_Type;
-static PyTypeObject PySSLMemoryBIO_Type;
-static PyTypeObject PySSLSession_Type;
+static PyTypeObject *PySSLContext_Type;
+static PyTypeObject *PySSLSocket_Type;
+static PyTypeObject *PySSLMemoryBIO_Type;
+static PyTypeObject *PySSLSession_Type;
static inline _PySSLError _PySSL_errno(int failed, const SSL *ssl, int retcode)
{
@@ -508,12 +508,12 @@ static inline _PySSLError _PySSL_errno(int failed, const SSL *ssl, int retcode)
/*[clinic input]
module _ssl
-class _ssl._SSLContext "PySSLContext *" "&PySSLContext_Type"
-class _ssl._SSLSocket "PySSLSocket *" "&PySSLSocket_Type"
-class _ssl.MemoryBIO "PySSLMemoryBIO *" "&PySSLMemoryBIO_Type"
-class _ssl.SSLSession "PySSLSession *" "&PySSLSession_Type"
+class _ssl._SSLContext "PySSLContext *" "PySSLContext_Type"
+class _ssl._SSLSocket "PySSLSocket *" "PySSLSocket_Type"
+class _ssl.MemoryBIO "PySSLMemoryBIO *" "PySSLMemoryBIO_Type"
+class _ssl.SSLSession "PySSLSession *" "PySSLSession_Type"
[clinic start generated code]*/
-/*[clinic end generated code: output=da39a3ee5e6b4b0d input=bdc67fafeeaa8109]*/
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=cc4883756da17954]*/
#include "clinic/_ssl.c.h"
@@ -521,9 +521,9 @@ static int PySSL_select(PySocketSockObject *s, int writing, _PyTime_t timeout);
static int PySSL_set_owner(PySSLSocket *, PyObject *, void *);
static int PySSL_set_session(PySSLSocket *, PyObject *, void *);
-#define PySSLSocket_Check(v) Py_IS_TYPE(v, &PySSLSocket_Type)
-#define PySSLMemoryBIO_Check(v) Py_IS_TYPE(v, &PySSLMemoryBIO_Type)
-#define PySSLSession_Check(v) Py_IS_TYPE(v, &PySSLSession_Type)
+#define PySSLSocket_Check(v) Py_IS_TYPE(v, PySSLSocket_Type)
+#define PySSLMemoryBIO_Check(v) Py_IS_TYPE(v, PySSLMemoryBIO_Type)
+#define PySSLSession_Check(v) Py_IS_TYPE(v, PySSLSession_Type)
typedef enum {
SOCKET_IS_NONBLOCKING,
@@ -587,7 +587,6 @@ SSLError_str(PyOSErrorObject *self)
}
static PyType_Slot sslerror_type_slots[] = {
- {Py_tp_base, NULL}, /* Filled out in module init as it's not a constant */
{Py_tp_doc, (void*)SSLError_doc},
{Py_tp_str, SSLError_str},
{0, 0},
@@ -937,7 +936,7 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
SSL_CTX *ctx = sslctx->ctx;
_PySSLError err = { 0 };
- self = PyObject_New(PySSLSocket, &PySSLSocket_Type);
+ self = PyObject_New(PySSLSocket, PySSLSocket_Type);
if (self == NULL)
return NULL;
@@ -1102,7 +1101,7 @@ _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self)
}
if (sockstate == SOCKET_HAS_TIMED_OUT) {
- PyErr_SetString(PySocketModule.timeout_error,
+ PyErr_SetString(PyExc_TimeoutError,
ERRSTR("The handshake operation timed out"));
goto error;
} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
@@ -2194,7 +2193,7 @@ static PySSLContext *PySSL_get_context(PySSLSocket *self, void *closure) {
static int PySSL_set_context(PySSLSocket *self, PyObject *value,
void *closure) {
- if (PyObject_TypeCheck(value, &PySSLContext_Type)) {
+ if (PyObject_TypeCheck(value, PySSLContext_Type)) {
#if !HAVE_SNI
PyErr_SetString(PyExc_NotImplementedError, "setting a socket's "
"context is not supported by your OpenSSL library");
@@ -2289,13 +2288,15 @@ PySSL_clear(PySSLSocket *self)
static void
PySSL_dealloc(PySSLSocket *self)
{
+ PyTypeObject *tp = Py_TYPE(self);
if (self->ssl)
SSL_free(self->ssl);
Py_XDECREF(self->Socket);
Py_XDECREF(self->ctx);
Py_XDECREF(self->server_hostname);
Py_XDECREF(self->owner);
- PyObject_Del(self);
+ PyObject_Free(self);
+ Py_DECREF(tp);
}
/* If the socket has a timeout, do a select()/poll() on the socket.
@@ -2419,7 +2420,7 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b)
sockstate = PySSL_select(sock, 1, timeout);
if (sockstate == SOCKET_HAS_TIMED_OUT) {
- PyErr_SetString(PySocketModule.timeout_error,
+ PyErr_SetString(PyExc_TimeoutError,
"The write operation timed out");
goto error;
} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
@@ -2454,7 +2455,7 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b)
}
if (sockstate == SOCKET_HAS_TIMED_OUT) {
- PyErr_SetString(PySocketModule.timeout_error,
+ PyErr_SetString(PyExc_TimeoutError,
"The write operation timed out");
goto error;
} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
@@ -2609,7 +2610,7 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, int len, int group_right_1,
sockstate = SOCKET_OPERATION_OK;
if (sockstate == SOCKET_HAS_TIMED_OUT) {
- PyErr_SetString(PySocketModule.timeout_error,
+ PyErr_SetString(PyExc_TimeoutError,
"The read operation timed out");
goto error;
} else if (sockstate == SOCKET_IS_NONBLOCKING) {
@@ -2724,10 +2725,10 @@ _ssl__SSLSocket_shutdown_impl(PySSLSocket *self)
if (sockstate == SOCKET_HAS_TIMED_OUT) {
if (err.ssl == SSL_ERROR_WANT_READ)
- PyErr_SetString(PySocketModule.timeout_error,
+ PyErr_SetString(PyExc_TimeoutError,
"The read operation timed out");
else
- PyErr_SetString(PySocketModule.timeout_error,
+ PyErr_SetString(PyExc_TimeoutError,
"The write operation timed out");
goto error;
}
@@ -2895,7 +2896,7 @@ PySSL_get_session(PySSLSocket *self, void *closure) {
Py_RETURN_NONE;
}
#endif
- pysess = PyObject_GC_New(PySSLSession, &PySSLSession_Type);
+ pysess = PyObject_GC_New(PySSLSession, PySSLSession_Type);
if (pysess == NULL) {
SSL_SESSION_free(session);
return NULL;
@@ -3008,38 +3009,21 @@ static PyMethodDef PySSLMethods[] = {
{NULL, NULL}
};
-static PyTypeObject PySSLSocket_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_ssl._SSLSocket", /*tp_name*/
- sizeof(PySSLSocket), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)PySSL_dealloc, /*tp_dealloc*/
- 0, /*tp_vectorcall_offset*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_as_async*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- (traverseproc) PySSL_traverse, /*tp_traverse*/
- (inquiry) PySSL_clear, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- PySSLMethods, /*tp_methods*/
- 0, /*tp_members*/
- ssl_getsetlist, /*tp_getset*/
+static PyType_Slot PySSLSocket_slots[] = {
+ {Py_tp_methods, PySSLMethods},
+ {Py_tp_getset, ssl_getsetlist},
+ {Py_tp_dealloc, PySSL_dealloc},
+ {Py_tp_traverse, PySSL_traverse},
+ {Py_tp_clear, PySSL_clear},
+ {0, 0},
+};
+
+static PyType_Spec PySSLSocket_spec = {
+ "_ssl._SSLSocket",
+ sizeof(PySSLSocket),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySSLSocket_slots,
};
@@ -3316,17 +3300,19 @@ context_clear(PySSLContext *self)
static void
context_dealloc(PySSLContext *self)
{
+ PyTypeObject *tp = Py_TYPE(self);
/* bpo-31095: UnTrack is needed before calling any callbacks */
PyObject_GC_UnTrack(self);
context_clear(self);
SSL_CTX_free(self->ctx);
#if HAVE_NPN
- PyMem_FREE(self->npn_protocols);
+ PyMem_Free(self->npn_protocols);
#endif
#if HAVE_ALPN
- PyMem_FREE(self->alpn_protocols);
+ PyMem_Free(self->alpn_protocols);
#endif
Py_TYPE(self)->tp_free(self);
+ Py_DECREF(tp);
}
/*[clinic input]
@@ -3524,7 +3510,7 @@ _ssl__SSLContext__set_alpn_protocols_impl(PySSLContext *self,
return NULL;
}
- PyMem_FREE(self->alpn_protocols);
+ PyMem_Free(self->alpn_protocols);
self->alpn_protocols = PyMem_Malloc(protos->len);
if (!self->alpn_protocols)
return PyErr_NoMemory();
@@ -4366,8 +4352,8 @@ _ssl__SSLContext__wrap_socket_impl(PySSLContext *self, PyObject *sock,
/*[clinic input]
_ssl._SSLContext._wrap_bio
- incoming: object(subclass_of="&PySSLMemoryBIO_Type", type="PySSLMemoryBIO *")
- outgoing: object(subclass_of="&PySSLMemoryBIO_Type", type="PySSLMemoryBIO *")
+ incoming: object(subclass_of="PySSLMemoryBIO_Type", type="PySSLMemoryBIO *")
+ outgoing: object(subclass_of="PySSLMemoryBIO_Type", type="PySSLMemoryBIO *")
server_side: int
server_hostname as hostname_obj: object = None
*
@@ -4381,7 +4367,7 @@ _ssl__SSLContext__wrap_bio_impl(PySSLContext *self, PySSLMemoryBIO *incoming,
PySSLMemoryBIO *outgoing, int server_side,
PyObject *hostname_obj, PyObject *owner,
PyObject *session)
-/*[clinic end generated code: output=5c5d6d9b41f99332 input=8cf22f4d586ac56a]*/
+/*[clinic end generated code: output=5c5d6d9b41f99332 input=63867b8f3e1a1aa3]*/
{
char *hostname = NULL;
PyObject *res;
@@ -4829,45 +4815,22 @@ static struct PyMethodDef context_methods[] = {
{NULL, NULL} /* sentinel */
};
-static PyTypeObject PySSLContext_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_ssl._SSLContext", /*tp_name*/
- sizeof(PySSLContext), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)context_dealloc, /*tp_dealloc*/
- 0, /*tp_vectorcall_offset*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_as_async*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- (traverseproc) context_traverse, /*tp_traverse*/
- (inquiry) context_clear, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- context_methods, /*tp_methods*/
- 0, /*tp_members*/
- context_getsetlist, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- _ssl__SSLContext, /*tp_new*/
+static PyType_Slot PySSLContext_slots[] = {
+ {Py_tp_methods, context_methods},
+ {Py_tp_getset, context_getsetlist},
+ {Py_tp_new, _ssl__SSLContext},
+ {Py_tp_dealloc, context_dealloc},
+ {Py_tp_traverse, context_traverse},
+ {Py_tp_clear, context_clear},
+ {0, 0},
+};
+
+static PyType_Spec PySSLContext_spec = {
+ "_ssl._SSLContext",
+ sizeof(PySSLContext),
+ 0,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
+ PySSLContext_slots,
};
@@ -4915,8 +4878,10 @@ _ssl_MemoryBIO_impl(PyTypeObject *type)
static void
memory_bio_dealloc(PySSLMemoryBIO *self)
{
+ PyTypeObject *tp = Py_TYPE(self);
BIO_free(self->bio);
Py_TYPE(self)->tp_free(self);
+ Py_DECREF(tp);
}
static PyObject *
@@ -5054,47 +5019,21 @@ static struct PyMethodDef memory_bio_methods[] = {
{NULL, NULL} /* sentinel */
};
-static PyTypeObject PySSLMemoryBIO_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_ssl.MemoryBIO", /*tp_name*/
- sizeof(PySSLMemoryBIO), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)memory_bio_dealloc, /*tp_dealloc*/
- 0, /*tp_vectorcall_offset*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_as_async*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- memory_bio_methods, /*tp_methods*/
- 0, /*tp_members*/
- memory_bio_getsetlist, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- _ssl_MemoryBIO, /*tp_new*/
+static PyType_Slot PySSLMemoryBIO_slots[] = {
+ {Py_tp_methods, memory_bio_methods},
+ {Py_tp_getset, memory_bio_getsetlist},
+ {Py_tp_new, _ssl_MemoryBIO},
+ {Py_tp_dealloc, memory_bio_dealloc},
+ {0, 0},
};
+static PyType_Spec PySSLMemoryBIO_spec = {
+ "_ssl.MemoryBIO",
+ sizeof(PySSLMemoryBIO),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySSLMemoryBIO_slots,
+};
/*
* SSL Session object
@@ -5103,6 +5042,7 @@ static PyTypeObject PySSLMemoryBIO_Type = {
static void
PySSLSession_dealloc(PySSLSession *self)
{
+ PyTypeObject *tp = Py_TYPE(self);
/* bpo-31095: UnTrack is needed before calling any callbacks */
PyObject_GC_UnTrack(self);
Py_XDECREF(self->ctx);
@@ -5110,6 +5050,7 @@ PySSLSession_dealloc(PySSLSession *self)
SSL_SESSION_free(self->session);
}
PyObject_GC_Del(self);
+ Py_DECREF(tp);
}
static PyObject *
@@ -5251,37 +5192,21 @@ static PyGetSetDef PySSLSession_getsetlist[] = {
{NULL}, /* sentinel */
};
-static PyTypeObject PySSLSession_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "_ssl.Session", /*tp_name*/
- sizeof(PySSLSession), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)PySSLSession_dealloc, /*tp_dealloc*/
- 0, /*tp_vectorcall_offset*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_as_async*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- (traverseproc)PySSLSession_traverse, /*tp_traverse*/
- (inquiry)PySSLSession_clear, /*tp_clear*/
- PySSLSession_richcompare, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- 0, /*tp_methods*/
- 0, /*tp_members*/
- PySSLSession_getsetlist, /*tp_getset*/
+static PyType_Slot PySSLSession_slots[] = {
+ {Py_tp_getset,PySSLSession_getsetlist},
+ {Py_tp_richcompare, PySSLSession_richcompare},
+ {Py_tp_dealloc, PySSLSession_dealloc},
+ {Py_tp_traverse, PySSLSession_traverse},
+ {Py_tp_clear, PySSLSession_clear},
+ {0, 0},
+};
+
+static PyType_Spec PySSLSession_spec = {
+ "_ssl.SSLSession",
+ sizeof(PySSLSession),
+ 0,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
+ PySSLSession_slots,
};
@@ -5979,23 +5904,190 @@ static int _setup_ssl_threads(void) {
#endif /* HAVE_OPENSSL_CRYPTO_LOCK for OpenSSL < 1.1.0 */
-PyDoc_STRVAR(module_doc,
-"Implementation module for SSL socket operations. See the socket module\n\
-for documentation.");
+static int
+sslmodule_init_types(PyObject *module)
+{
+ PySSLContext_Type = (PyTypeObject *)PyType_FromModuleAndSpec(
+ module, &PySSLContext_spec, NULL
+ );
+ if (PySSLContext_Type == NULL)
+ return -1;
+ PySSLSocket_Type = (PyTypeObject *)PyType_FromModuleAndSpec(
+ module, &PySSLSocket_spec, NULL
+ );
+ if (PySSLSocket_Type == NULL)
+ return -1;
-static struct PyModuleDef _sslmodule = {
- PyModuleDef_HEAD_INIT,
- "_ssl",
- module_doc,
- -1,
- PySSL_methods,
- NULL,
- NULL,
- NULL,
- NULL
-};
+ PySSLMemoryBIO_Type = (PyTypeObject *)PyType_FromModuleAndSpec(
+ module, &PySSLMemoryBIO_spec, NULL
+ );
+ if (PySSLMemoryBIO_Type == NULL)
+ return -1;
+
+ PySSLSession_Type = (PyTypeObject *)PyType_FromModuleAndSpec(
+ module, &PySSLSession_spec, NULL
+ );
+ if (PySSLSession_Type == NULL)
+ return -1;
+
+ if (PyModule_AddType(module, PySSLContext_Type))
+ return -1;
+ if (PyModule_AddType(module, PySSLSocket_Type))
+ return -1;
+ if (PyModule_AddType(module, PySSLMemoryBIO_Type))
+ return -1;
+ if (PyModule_AddType(module, PySSLSession_Type))
+ return -1;
+
+ return 0;
+}
+
+static int
+sslmodule_init_exceptions(PyObject *module)
+{
+ PyObject *bases = NULL;
+
+#define add_exception(exc, name, doc, base) \
+do { \
+ (exc) = PyErr_NewExceptionWithDoc("ssl." name, (doc), (base), NULL); \
+ if ((exc) == NULL) goto error; \
+ if (PyModule_AddObjectRef(module, name, exc) < 0) goto error; \
+} while(0)
+
+ PySSLErrorObject = PyType_FromSpecWithBases(&sslerror_type_spec, PyExc_OSError);
+ if (PySSLErrorObject == NULL) {
+ goto error;
+ }
+ if (PyModule_AddObjectRef(module, "SSLError", PySSLErrorObject) < 0) {
+ goto error;
+ }
+
+ /* ssl.CertificateError used to be a subclass of ValueError */
+ bases = PyTuple_Pack(2, PySSLErrorObject, PyExc_ValueError);
+ if (bases == NULL) {
+ goto error;
+ }
+ add_exception(
+ PySSLCertVerificationErrorObject,
+ "SSLCertVerificationError",
+ SSLCertVerificationError_doc,
+ bases
+ );
+ Py_CLEAR(bases);
+
+ add_exception(
+ PySSLZeroReturnErrorObject,
+ "SSLZeroReturnError",
+ SSLZeroReturnError_doc,
+ PySSLErrorObject
+ );
+
+ add_exception(
+ PySSLWantWriteErrorObject,
+ "SSLWantWriteError",
+ SSLWantWriteError_doc,
+ PySSLErrorObject
+ );
+
+ add_exception(
+ PySSLWantReadErrorObject,
+ "SSLWantReadError",
+ SSLWantReadError_doc,
+ PySSLErrorObject
+ );
+
+ add_exception(
+ PySSLSyscallErrorObject,
+ "SSLSyscallError",
+ SSLSyscallError_doc,
+ PySSLErrorObject
+ );
+
+ add_exception(
+ PySSLEOFErrorObject,
+ "SSLEOFError",
+ SSLEOFError_doc,
+ PySSLErrorObject
+ );
+#undef add_exception
+
+ return 0;
+ error:
+ Py_XDECREF(bases);
+ return -1;
+}
+
+static int
+sslmodule_init_socketapi(PyObject *module)
+{
+ PySocketModule_APIObject *socket_api;
+
+ /* Load _socket module and its C API */
+ socket_api = PySocketModule_ImportModuleAndAPI();
+ if (socket_api == NULL)
+ return -1;
+ PySocketModule = *socket_api;
+
+ return 0;
+}
+static int
+sslmodule_init_errorcodes(PyObject *module)
+{
+ struct py_ssl_error_code *errcode;
+ struct py_ssl_library_code *libcode;
+
+ /* Mappings for error codes */
+ err_codes_to_names = PyDict_New();
+ if (err_codes_to_names == NULL)
+ return -1;
+ err_names_to_codes = PyDict_New();
+ if (err_names_to_codes == NULL)
+ return -1;
+ lib_codes_to_names = PyDict_New();
+ if (lib_codes_to_names == NULL)
+ return -1;
+
+ errcode = error_codes;
+ while (errcode->mnemonic != NULL) {
+ PyObject *mnemo, *key;
+ mnemo = PyUnicode_FromString(errcode->mnemonic);
+ key = Py_BuildValue("ii", errcode->library, errcode->reason);
+ if (mnemo == NULL || key == NULL)
+ return -1;
+ if (PyDict_SetItem(err_codes_to_names, key, mnemo))
+ return -1;
+ if (PyDict_SetItem(err_names_to_codes, mnemo, key))
+ return -1;
+ Py_DECREF(key);
+ Py_DECREF(mnemo);
+ errcode++;
+ }
+
+ libcode = library_codes;
+ while (libcode->library != NULL) {
+ PyObject *mnemo, *key;
+ key = PyLong_FromLong(libcode->code);
+ mnemo = PyUnicode_FromString(libcode->library);
+ if (key == NULL || mnemo == NULL)
+ return -1;
+ if (PyDict_SetItem(lib_codes_to_names, key, mnemo))
+ return -1;
+ Py_DECREF(key);
+ Py_DECREF(mnemo);
+ libcode++;
+ }
+
+ if (PyModule_AddObject(module, "err_codes_to_names", err_codes_to_names))
+ return -1;
+ if (PyModule_AddObject(module, "err_names_to_codes", err_names_to_codes))
+ return -1;
+ if (PyModule_AddObject(module, "lib_codes_to_names", lib_codes_to_names))
+ return -1;
+
+ return 0;
+}
static void
parse_openssl_version(unsigned long libver,
@@ -6014,113 +6106,43 @@ parse_openssl_version(unsigned long libver,
*major = libver & 0xFF;
}
-PyMODINIT_FUNC
-PyInit__ssl(void)
+static int
+sslmodule_init_versioninfo(PyObject *m)
{
- PyObject *m, *d, *r, *bases;
+ PyObject *r;
unsigned long libver;
unsigned int major, minor, fix, patch, status;
- PySocketModule_APIObject *socket_api;
- struct py_ssl_error_code *errcode;
- struct py_ssl_library_code *libcode;
-
- if (PyType_Ready(&PySSLContext_Type) < 0)
- return NULL;
- if (PyType_Ready(&PySSLSocket_Type) < 0)
- return NULL;
- if (PyType_Ready(&PySSLMemoryBIO_Type) < 0)
- return NULL;
- if (PyType_Ready(&PySSLSession_Type) < 0)
- return NULL;
-
- m = PyModule_Create(&_sslmodule);
- if (m == NULL)
- return NULL;
- d = PyModule_GetDict(m);
-
- /* Load _socket module and its C API */
- socket_api = PySocketModule_ImportModuleAndAPI();
- if (!socket_api)
- return NULL;
- PySocketModule = *socket_api;
+ /* OpenSSL version */
+ /* SSLeay() gives us the version of the library linked against,
+ which could be different from the headers version.
+ */
+ libver = OpenSSL_version_num();
+ r = PyLong_FromUnsignedLong(libver);
+ if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION_NUMBER", r))
+ return -1;
-#ifndef OPENSSL_VERSION_1_1
- /* Load all algorithms and initialize cpuid */
- OPENSSL_add_all_algorithms_noconf();
- /* Init OpenSSL */
- SSL_load_error_strings();
- SSL_library_init();
-#endif
+ parse_openssl_version(libver, &major, &minor, &fix, &patch, &status);
+ r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
+ if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION_INFO", r))
+ return -1;
-#ifdef HAVE_OPENSSL_CRYPTO_LOCK
- /* note that this will start threading if not already started */
- if (!_setup_ssl_threads()) {
- return NULL;
- }
-#elif OPENSSL_VERSION_1_1
- /* OpenSSL 1.1.0 builtin thread support is enabled */
- _ssl_locks_count++;
-#endif
+ r = PyUnicode_FromString(OpenSSL_version(OPENSSL_VERSION));
+ if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION", r))
+ return -1;
- /* Add symbols to module dict */
- sslerror_type_slots[0].pfunc = PyExc_OSError;
- PySSLErrorObject = PyType_FromSpec(&sslerror_type_spec);
- if (PySSLErrorObject == NULL)
- return NULL;
+ libver = OPENSSL_VERSION_NUMBER;
+ parse_openssl_version(libver, &major, &minor, &fix, &patch, &status);
+ r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
+ if (r == NULL || PyModule_AddObject(m, "_OPENSSL_API_VERSION", r))
+ return -1;
- /* ssl.CertificateError used to be a subclass of ValueError */
- bases = Py_BuildValue("OO", PySSLErrorObject, PyExc_ValueError);
- if (bases == NULL)
- return NULL;
- PySSLCertVerificationErrorObject = PyErr_NewExceptionWithDoc(
- "ssl.SSLCertVerificationError", SSLCertVerificationError_doc,
- bases, NULL);
- Py_DECREF(bases);
- PySSLZeroReturnErrorObject = PyErr_NewExceptionWithDoc(
- "ssl.SSLZeroReturnError", SSLZeroReturnError_doc,
- PySSLErrorObject, NULL);
- PySSLWantReadErrorObject = PyErr_NewExceptionWithDoc(
- "ssl.SSLWantReadError", SSLWantReadError_doc,
- PySSLErrorObject, NULL);
- PySSLWantWriteErrorObject = PyErr_NewExceptionWithDoc(
- "ssl.SSLWantWriteError", SSLWantWriteError_doc,
- PySSLErrorObject, NULL);
- PySSLSyscallErrorObject = PyErr_NewExceptionWithDoc(
- "ssl.SSLSyscallError", SSLSyscallError_doc,
- PySSLErrorObject, NULL);
- PySSLEOFErrorObject = PyErr_NewExceptionWithDoc(
- "ssl.SSLEOFError", SSLEOFError_doc,
- PySSLErrorObject, NULL);
- if (PySSLCertVerificationErrorObject == NULL
- || PySSLZeroReturnErrorObject == NULL
- || PySSLWantReadErrorObject == NULL
- || PySSLWantWriteErrorObject == NULL
- || PySSLSyscallErrorObject == NULL
- || PySSLEOFErrorObject == NULL)
- return NULL;
- if (PyDict_SetItemString(d, "SSLError", PySSLErrorObject) != 0
- || PyDict_SetItemString(d, "SSLCertVerificationError",
- PySSLCertVerificationErrorObject) != 0
- || PyDict_SetItemString(d, "SSLZeroReturnError", PySSLZeroReturnErrorObject) != 0
- || PyDict_SetItemString(d, "SSLWantReadError", PySSLWantReadErrorObject) != 0
- || PyDict_SetItemString(d, "SSLWantWriteError", PySSLWantWriteErrorObject) != 0
- || PyDict_SetItemString(d, "SSLSyscallError", PySSLSyscallErrorObject) != 0
- || PyDict_SetItemString(d, "SSLEOFError", PySSLEOFErrorObject) != 0)
- return NULL;
- if (PyDict_SetItemString(d, "_SSLContext",
- (PyObject *)&PySSLContext_Type) != 0)
- return NULL;
- if (PyDict_SetItemString(d, "_SSLSocket",
- (PyObject *)&PySSLSocket_Type) != 0)
- return NULL;
- if (PyDict_SetItemString(d, "MemoryBIO",
- (PyObject *)&PySSLMemoryBIO_Type) != 0)
- return NULL;
- if (PyDict_SetItemString(d, "SSLSession",
- (PyObject *)&PySSLSession_Type) != 0)
- return NULL;
+ return 0;
+}
+static int
+sslmodule_init_constants(PyObject *m)
+{
PyModule_AddStringConstant(m, "_DEFAULT_CIPHERS",
PY_SSL_DEFAULT_CIPHER_STRING);
@@ -6377,72 +6399,71 @@ PyInit__ssl(void)
addbool(m, "HAS_TLSv1_3", 0);
#endif
- /* Mappings for error codes */
- err_codes_to_names = PyDict_New();
- err_names_to_codes = PyDict_New();
- if (err_codes_to_names == NULL || err_names_to_codes == NULL)
- return NULL;
- errcode = error_codes;
- while (errcode->mnemonic != NULL) {
- PyObject *mnemo, *key;
- mnemo = PyUnicode_FromString(errcode->mnemonic);
- key = Py_BuildValue("ii", errcode->library, errcode->reason);
- if (mnemo == NULL || key == NULL)
- return NULL;
- if (PyDict_SetItem(err_codes_to_names, key, mnemo))
- return NULL;
- if (PyDict_SetItem(err_names_to_codes, mnemo, key))
- return NULL;
- Py_DECREF(key);
- Py_DECREF(mnemo);
- errcode++;
+ return 0;
+}
+
+static int
+sslmodule_legacy(PyObject *module)
+{
+#ifndef OPENSSL_VERSION_1_1
+ /* Load all algorithms and initialize cpuid */
+ OPENSSL_add_all_algorithms_noconf();
+ /* Init OpenSSL */
+ SSL_load_error_strings();
+ SSL_library_init();
+#endif
+
+#ifdef HAVE_OPENSSL_CRYPTO_LOCK
+ /* note that this will start threading if not already started */
+ if (!_setup_ssl_threads()) {
+ return 0;
}
- if (PyModule_AddObject(m, "err_codes_to_names", err_codes_to_names))
- return NULL;
- if (PyModule_AddObject(m, "err_names_to_codes", err_names_to_codes))
+#elif OPENSSL_VERSION_1_1
+ /* OpenSSL 1.1.0 builtin thread support is enabled */
+ _ssl_locks_count++;
+#endif
+ return 0;
+}
+
+PyDoc_STRVAR(module_doc,
+"Implementation module for SSL socket operations. See the socket module\n\
+for documentation.");
+
+
+static struct PyModuleDef _sslmodule = {
+ PyModuleDef_HEAD_INIT,
+ "_ssl",
+ module_doc,
+ -1,
+ PySSL_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyMODINIT_FUNC
+PyInit__ssl(void)
+{
+ PyObject *m;
+
+ m = PyModule_Create(&_sslmodule);
+ if (m == NULL)
return NULL;
- lib_codes_to_names = PyDict_New();
- if (lib_codes_to_names == NULL)
+ if (sslmodule_init_types(m) != 0)
return NULL;
- libcode = library_codes;
- while (libcode->library != NULL) {
- PyObject *mnemo, *key;
- key = PyLong_FromLong(libcode->code);
- mnemo = PyUnicode_FromString(libcode->library);
- if (key == NULL || mnemo == NULL)
- return NULL;
- if (PyDict_SetItem(lib_codes_to_names, key, mnemo))
- return NULL;
- Py_DECREF(key);
- Py_DECREF(mnemo);
- libcode++;
- }
- if (PyModule_AddObject(m, "lib_codes_to_names", lib_codes_to_names))
+ if (sslmodule_init_exceptions(m) != 0)
return NULL;
-
- /* OpenSSL version */
- /* SSLeay() gives us the version of the library linked against,
- which could be different from the headers version.
- */
- libver = OpenSSL_version_num();
- r = PyLong_FromUnsignedLong(libver);
- if (r == NULL)
+ if (sslmodule_init_socketapi(m) != 0)
return NULL;
- if (PyModule_AddObject(m, "OPENSSL_VERSION_NUMBER", r))
+ if (sslmodule_init_errorcodes(m) != 0)
return NULL;
- parse_openssl_version(libver, &major, &minor, &fix, &patch, &status);
- r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
- if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION_INFO", r))
+ if (sslmodule_init_constants(m) != 0)
return NULL;
- r = PyUnicode_FromString(OpenSSL_version(OPENSSL_VERSION));
- if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION", r))
+ if (sslmodule_init_versioninfo(m) != 0)
return NULL;
-
- libver = OPENSSL_VERSION_NUMBER;
- parse_openssl_version(libver, &major, &minor, &fix, &patch, &status);
- r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
- if (r == NULL || PyModule_AddObject(m, "_OPENSSL_API_VERSION", r))
+ if (sslmodule_legacy(m) != 0)
return NULL;
return m;
diff --git a/Modules/_struct.c b/Modules/_struct.c
index 81cdbb9b81..c95c76f8ae 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -15,6 +15,7 @@ class Struct "PyStructObject *" "&PyStructType"
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=9b032058a83ed7c3]*/
typedef struct {
+ PyObject *cache;
PyObject *PyStructType;
PyObject *unpackiter_type;
PyObject *StructError;
@@ -30,16 +31,19 @@ get_struct_state(PyObject *module)
static struct PyModuleDef _structmodule;
-#define _structmodulestate_global get_struct_state(PyState_FindModule(&_structmodule))
+#define get_struct_state_structinst(self) \
+ (get_struct_state(_PyType_GetModuleByDef(Py_TYPE(self), &_structmodule)))
+#define get_struct_state_iterinst(self) \
+ (get_struct_state(PyType_GetModule(Py_TYPE(self))))
/* The translation function for each format character is table driven */
typedef struct _formatdef {
char format;
Py_ssize_t size;
Py_ssize_t alignment;
- PyObject* (*unpack)(const char *,
+ PyObject* (*unpack)(_structmodulestate *, const char *,
const struct _formatdef *);
- int (*pack)(char *, PyObject *,
+ int (*pack)(_structmodulestate *, char *, PyObject *,
const struct _formatdef *);
} formatdef;
@@ -61,10 +65,7 @@ typedef struct {
PyObject *weakreflist; /* List of weak references */
} PyStructObject;
-
-#define PyStruct_Check(op) PyObject_TypeCheck(op, (PyTypeObject *)_structmodulestate_global->PyStructType)
-#define PyStruct_CheckExact(op) Py_IS_TYPE(op, (PyTypeObject *)_structmodulestate_global->PyStructType)
-
+#define PyStruct_Check(op, state) PyObject_TypeCheck(op, (PyTypeObject *)(state)->PyStructType)
/* Define various structs to figure out the alignments of types */
@@ -102,12 +103,20 @@ class cache_struct_converter(CConverter):
converter = 'cache_struct_converter'
c_default = "NULL"
+ def parse_arg(self, argname, displayname):
+ return """
+ if (!{converter}(module, {argname}, &{paramname})) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name,
+ converter=self.converter)
+
def cleanup(self):
return "Py_XDECREF(%s);\n" % self.name
[python start generated code]*/
-/*[python end generated code: output=da39a3ee5e6b4b0d input=49957cca130ffb63]*/
+/*[python end generated code: output=da39a3ee5e6b4b0d input=d6746621c2fb1a7d]*/
-static int cache_struct_converter(PyObject *, PyStructObject **);
+static int cache_struct_converter(PyObject *, PyObject *, PyStructObject **);
#include "clinic/_struct.c.h"
@@ -115,7 +124,7 @@ static int cache_struct_converter(PyObject *, PyStructObject **);
PyLongObject if possible, otherwise fails. Caller should decref. */
static PyObject *
-get_pylong(PyObject *v)
+get_pylong(_structmodulestate *state, PyObject *v)
{
assert(v != NULL);
if (!PyLong_Check(v)) {
@@ -126,7 +135,7 @@ get_pylong(PyObject *v)
return NULL;
}
else {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"required argument is not an integer");
return NULL;
}
@@ -142,11 +151,11 @@ get_pylong(PyObject *v)
one */
static int
-get_long(PyObject *v, long *p)
+get_long(_structmodulestate *state, PyObject *v, long *p)
{
long x;
- v = get_pylong(v);
+ v = get_pylong(state, v);
if (v == NULL)
return -1;
assert(PyLong_Check(v));
@@ -154,7 +163,7 @@ get_long(PyObject *v, long *p)
Py_DECREF(v);
if (x == (long)-1 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError))
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"argument out of range");
return -1;
}
@@ -166,11 +175,11 @@ get_long(PyObject *v, long *p)
/* Same, but handling unsigned long */
static int
-get_ulong(PyObject *v, unsigned long *p)
+get_ulong(_structmodulestate *state, PyObject *v, unsigned long *p)
{
unsigned long x;
- v = get_pylong(v);
+ v = get_pylong(state, v);
if (v == NULL)
return -1;
assert(PyLong_Check(v));
@@ -178,7 +187,7 @@ get_ulong(PyObject *v, unsigned long *p)
Py_DECREF(v);
if (x == (unsigned long)-1 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError))
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"argument out of range");
return -1;
}
@@ -189,11 +198,11 @@ get_ulong(PyObject *v, unsigned long *p)
/* Same, but handling native long long. */
static int
-get_longlong(PyObject *v, long long *p)
+get_longlong(_structmodulestate *state, PyObject *v, long long *p)
{
long long x;
- v = get_pylong(v);
+ v = get_pylong(state, v);
if (v == NULL)
return -1;
assert(PyLong_Check(v));
@@ -201,7 +210,7 @@ get_longlong(PyObject *v, long long *p)
Py_DECREF(v);
if (x == (long long)-1 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError))
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"argument out of range");
return -1;
}
@@ -212,11 +221,11 @@ get_longlong(PyObject *v, long long *p)
/* Same, but handling native unsigned long long. */
static int
-get_ulonglong(PyObject *v, unsigned long long *p)
+get_ulonglong(_structmodulestate *state, PyObject *v, unsigned long long *p)
{
unsigned long long x;
- v = get_pylong(v);
+ v = get_pylong(state, v);
if (v == NULL)
return -1;
assert(PyLong_Check(v));
@@ -224,7 +233,7 @@ get_ulonglong(PyObject *v, unsigned long long *p)
Py_DECREF(v);
if (x == (unsigned long long)-1 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError))
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"argument out of range");
return -1;
}
@@ -235,11 +244,11 @@ get_ulonglong(PyObject *v, unsigned long long *p)
/* Same, but handling Py_ssize_t */
static int
-get_ssize_t(PyObject *v, Py_ssize_t *p)
+get_ssize_t(_structmodulestate *state, PyObject *v, Py_ssize_t *p)
{
Py_ssize_t x;
- v = get_pylong(v);
+ v = get_pylong(state, v);
if (v == NULL)
return -1;
assert(PyLong_Check(v));
@@ -247,7 +256,7 @@ get_ssize_t(PyObject *v, Py_ssize_t *p)
Py_DECREF(v);
if (x == (Py_ssize_t)-1 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError))
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"argument out of range");
return -1;
}
@@ -258,11 +267,11 @@ get_ssize_t(PyObject *v, Py_ssize_t *p)
/* Same, but handling size_t */
static int
-get_size_t(PyObject *v, size_t *p)
+get_size_t(_structmodulestate *state, PyObject *v, size_t *p)
{
size_t x;
- v = get_pylong(v);
+ v = get_pylong(state, v);
if (v == NULL)
return -1;
assert(PyLong_Check(v));
@@ -270,7 +279,7 @@ get_size_t(PyObject *v, size_t *p)
Py_DECREF(v);
if (x == (size_t)-1 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError))
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"argument out of range");
return -1;
}
@@ -279,7 +288,7 @@ get_size_t(PyObject *v, size_t *p)
}
-#define RANGE_ERROR(x, f, flag, mask) return _range_error(f, flag)
+#define RANGE_ERROR(state, x, f, flag, mask) return _range_error(state, f, flag)
/* Floating point helpers */
@@ -298,13 +307,14 @@ unpack_halffloat(const char *p, /* start of 2-byte string */
}
static int
-pack_halffloat(char *p, /* start of 2-byte string */
+pack_halffloat(_structmodulestate *state,
+ char *p, /* start of 2-byte string */
PyObject *v, /* value to pack */
int le) /* true for little-endian, false for big-endian */
{
double x = PyFloat_AsDouble(v);
if (x == -1.0 && PyErr_Occurred()) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"required argument is not a float");
return -1;
}
@@ -337,7 +347,7 @@ unpack_double(const char *p, /* start of 8-byte string */
/* Helper to format the range error exceptions */
static int
-_range_error(const formatdef *f, int is_unsigned)
+_range_error(_structmodulestate *state, const formatdef *f, int is_unsigned)
{
/* ulargest is the largest unsigned value with f->size bytes.
* Note that the simpler:
@@ -350,13 +360,13 @@ _range_error(const formatdef *f, int is_unsigned)
const size_t ulargest = (size_t)-1 >> ((SIZEOF_SIZE_T - f->size)*8);
assert(f->size >= 1 && f->size <= SIZEOF_SIZE_T);
if (is_unsigned)
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"'%c' format requires 0 <= number <= %zu",
f->format,
ulargest);
else {
const Py_ssize_t largest = (Py_ssize_t)(ulargest >> 1);
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"'%c' format requires %zd <= number <= %zd",
f->format,
~ largest,
@@ -388,25 +398,25 @@ _range_error(const formatdef *f, int is_unsigned)
does this). */
static PyObject *
-nu_char(const char *p, const formatdef *f)
+nu_char(_structmodulestate *state, const char *p, const formatdef *f)
{
return PyBytes_FromStringAndSize(p, 1);
}
static PyObject *
-nu_byte(const char *p, const formatdef *f)
+nu_byte(_structmodulestate *state, const char *p, const formatdef *f)
{
return PyLong_FromLong((long) *(signed char *)p);
}
static PyObject *
-nu_ubyte(const char *p, const formatdef *f)
+nu_ubyte(_structmodulestate *state, const char *p, const formatdef *f)
{
return PyLong_FromLong((long) *(unsigned char *)p);
}
static PyObject *
-nu_short(const char *p, const formatdef *f)
+nu_short(_structmodulestate *state, const char *p, const formatdef *f)
{
short x;
memcpy((char *)&x, p, sizeof x);
@@ -414,7 +424,7 @@ nu_short(const char *p, const formatdef *f)
}
static PyObject *
-nu_ushort(const char *p, const formatdef *f)
+nu_ushort(_structmodulestate *state, const char *p, const formatdef *f)
{
unsigned short x;
memcpy((char *)&x, p, sizeof x);
@@ -422,7 +432,7 @@ nu_ushort(const char *p, const formatdef *f)
}
static PyObject *
-nu_int(const char *p, const formatdef *f)
+nu_int(_structmodulestate *state, const char *p, const formatdef *f)
{
int x;
memcpy((char *)&x, p, sizeof x);
@@ -430,7 +440,7 @@ nu_int(const char *p, const formatdef *f)
}
static PyObject *
-nu_uint(const char *p, const formatdef *f)
+nu_uint(_structmodulestate *state, const char *p, const formatdef *f)
{
unsigned int x;
memcpy((char *)&x, p, sizeof x);
@@ -438,7 +448,7 @@ nu_uint(const char *p, const formatdef *f)
}
static PyObject *
-nu_long(const char *p, const formatdef *f)
+nu_long(_structmodulestate *state, const char *p, const formatdef *f)
{
long x;
memcpy((char *)&x, p, sizeof x);
@@ -446,7 +456,7 @@ nu_long(const char *p, const formatdef *f)
}
static PyObject *
-nu_ulong(const char *p, const formatdef *f)
+nu_ulong(_structmodulestate *state, const char *p, const formatdef *f)
{
unsigned long x;
memcpy((char *)&x, p, sizeof x);
@@ -454,7 +464,7 @@ nu_ulong(const char *p, const formatdef *f)
}
static PyObject *
-nu_ssize_t(const char *p, const formatdef *f)
+nu_ssize_t(_structmodulestate *state, const char *p, const formatdef *f)
{
Py_ssize_t x;
memcpy((char *)&x, p, sizeof x);
@@ -462,7 +472,7 @@ nu_ssize_t(const char *p, const formatdef *f)
}
static PyObject *
-nu_size_t(const char *p, const formatdef *f)
+nu_size_t(_structmodulestate *state, const char *p, const formatdef *f)
{
size_t x;
memcpy((char *)&x, p, sizeof x);
@@ -470,7 +480,7 @@ nu_size_t(const char *p, const formatdef *f)
}
static PyObject *
-nu_longlong(const char *p, const formatdef *f)
+nu_longlong(_structmodulestate *state, const char *p, const formatdef *f)
{
long long x;
memcpy((char *)&x, p, sizeof x);
@@ -478,7 +488,7 @@ nu_longlong(const char *p, const formatdef *f)
}
static PyObject *
-nu_ulonglong(const char *p, const formatdef *f)
+nu_ulonglong(_structmodulestate *state, const char *p, const formatdef *f)
{
unsigned long long x;
memcpy((char *)&x, p, sizeof x);
@@ -486,7 +496,7 @@ nu_ulonglong(const char *p, const formatdef *f)
}
static PyObject *
-nu_bool(const char *p, const formatdef *f)
+nu_bool(_structmodulestate *state, const char *p, const formatdef *f)
{
_Bool x;
memcpy((char *)&x, p, sizeof x);
@@ -495,7 +505,7 @@ nu_bool(const char *p, const formatdef *f)
static PyObject *
-nu_halffloat(const char *p, const formatdef *f)
+nu_halffloat(_structmodulestate *state, const char *p, const formatdef *f)
{
#if PY_LITTLE_ENDIAN
return unpack_halffloat(p, 1);
@@ -505,7 +515,7 @@ nu_halffloat(const char *p, const formatdef *f)
}
static PyObject *
-nu_float(const char *p, const formatdef *f)
+nu_float(_structmodulestate *state, const char *p, const formatdef *f)
{
float x;
memcpy((char *)&x, p, sizeof x);
@@ -513,7 +523,7 @@ nu_float(const char *p, const formatdef *f)
}
static PyObject *
-nu_double(const char *p, const formatdef *f)
+nu_double(_structmodulestate *state, const char *p, const formatdef *f)
{
double x;
memcpy((char *)&x, p, sizeof x);
@@ -521,7 +531,7 @@ nu_double(const char *p, const formatdef *f)
}
static PyObject *
-nu_void_p(const char *p, const formatdef *f)
+nu_void_p(_structmodulestate *state, const char *p, const formatdef *f)
{
void *x;
memcpy((char *)&x, p, sizeof x);
@@ -529,13 +539,13 @@ nu_void_p(const char *p, const formatdef *f)
}
static int
-np_byte(char *p, PyObject *v, const formatdef *f)
+np_byte(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
long x;
- if (get_long(v, &x) < 0)
+ if (get_long(state, v, &x) < 0)
return -1;
if (x < -128 || x > 127) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"byte format requires -128 <= number <= 127");
return -1;
}
@@ -544,13 +554,13 @@ np_byte(char *p, PyObject *v, const formatdef *f)
}
static int
-np_ubyte(char *p, PyObject *v, const formatdef *f)
+np_ubyte(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
long x;
- if (get_long(v, &x) < 0)
+ if (get_long(state, v, &x) < 0)
return -1;
if (x < 0 || x > 255) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"ubyte format requires 0 <= number <= 255");
return -1;
}
@@ -559,10 +569,10 @@ np_ubyte(char *p, PyObject *v, const formatdef *f)
}
static int
-np_char(char *p, PyObject *v, const formatdef *f)
+np_char(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
if (!PyBytes_Check(v) || PyBytes_Size(v) != 1) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"char format requires a bytes object of length 1");
return -1;
}
@@ -571,14 +581,14 @@ np_char(char *p, PyObject *v, const formatdef *f)
}
static int
-np_short(char *p, PyObject *v, const formatdef *f)
+np_short(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
long x;
short y;
- if (get_long(v, &x) < 0)
+ if (get_long(state, v, &x) < 0)
return -1;
if (x < SHRT_MIN || x > SHRT_MAX) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"short format requires " Py_STRINGIFY(SHRT_MIN)
" <= number <= " Py_STRINGIFY(SHRT_MAX));
return -1;
@@ -589,14 +599,14 @@ np_short(char *p, PyObject *v, const formatdef *f)
}
static int
-np_ushort(char *p, PyObject *v, const formatdef *f)
+np_ushort(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
long x;
unsigned short y;
- if (get_long(v, &x) < 0)
+ if (get_long(state, v, &x) < 0)
return -1;
if (x < 0 || x > USHRT_MAX) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"ushort format requires 0 <= number <= "
Py_STRINGIFY(USHRT_MAX));
return -1;
@@ -607,15 +617,15 @@ np_ushort(char *p, PyObject *v, const formatdef *f)
}
static int
-np_int(char *p, PyObject *v, const formatdef *f)
+np_int(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
long x;
int y;
- if (get_long(v, &x) < 0)
+ if (get_long(state, v, &x) < 0)
return -1;
#if (SIZEOF_LONG > SIZEOF_INT)
if ((x < ((long)INT_MIN)) || (x > ((long)INT_MAX)))
- RANGE_ERROR(x, f, 0, -1);
+ RANGE_ERROR(state, x, f, 0, -1);
#endif
y = (int)x;
memcpy(p, (char *)&y, sizeof y);
@@ -623,76 +633,76 @@ np_int(char *p, PyObject *v, const formatdef *f)
}
static int
-np_uint(char *p, PyObject *v, const formatdef *f)
+np_uint(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
unsigned long x;
unsigned int y;
- if (get_ulong(v, &x) < 0)
+ if (get_ulong(state, v, &x) < 0)
return -1;
y = (unsigned int)x;
#if (SIZEOF_LONG > SIZEOF_INT)
if (x > ((unsigned long)UINT_MAX))
- RANGE_ERROR(y, f, 1, -1);
+ RANGE_ERROR(state, y, f, 1, -1);
#endif
memcpy(p, (char *)&y, sizeof y);
return 0;
}
static int
-np_long(char *p, PyObject *v, const formatdef *f)
+np_long(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
long x;
- if (get_long(v, &x) < 0)
+ if (get_long(state, v, &x) < 0)
return -1;
memcpy(p, (char *)&x, sizeof x);
return 0;
}
static int
-np_ulong(char *p, PyObject *v, const formatdef *f)
+np_ulong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
unsigned long x;
- if (get_ulong(v, &x) < 0)
+ if (get_ulong(state, v, &x) < 0)
return -1;
memcpy(p, (char *)&x, sizeof x);
return 0;
}
static int
-np_ssize_t(char *p, PyObject *v, const formatdef *f)
+np_ssize_t(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
Py_ssize_t x;
- if (get_ssize_t(v, &x) < 0)
+ if (get_ssize_t(state, v, &x) < 0)
return -1;
memcpy(p, (char *)&x, sizeof x);
return 0;
}
static int
-np_size_t(char *p, PyObject *v, const formatdef *f)
+np_size_t(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
size_t x;
- if (get_size_t(v, &x) < 0)
+ if (get_size_t(state, v, &x) < 0)
return -1;
memcpy(p, (char *)&x, sizeof x);
return 0;
}
static int
-np_longlong(char *p, PyObject *v, const formatdef *f)
+np_longlong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
long long x;
- if (get_longlong(v, &x) < 0)
+ if (get_longlong(state, v, &x) < 0)
return -1;
memcpy(p, (char *)&x, sizeof x);
return 0;
}
static int
-np_ulonglong(char *p, PyObject *v, const formatdef *f)
+np_ulonglong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
unsigned long long x;
- if (get_ulonglong(v, &x) < 0)
+ if (get_ulonglong(state, v, &x) < 0)
return -1;
memcpy(p, (char *)&x, sizeof x);
return 0;
@@ -700,7 +710,7 @@ np_ulonglong(char *p, PyObject *v, const formatdef *f)
static int
-np_bool(char *p, PyObject *v, const formatdef *f)
+np_bool(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
int y;
_Bool x;
@@ -713,21 +723,21 @@ np_bool(char *p, PyObject *v, const formatdef *f)
}
static int
-np_halffloat(char *p, PyObject *v, const formatdef *f)
+np_halffloat(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
#if PY_LITTLE_ENDIAN
- return pack_halffloat(p, v, 1);
+ return pack_halffloat(state, p, v, 1);
#else
- return pack_halffloat(p, v, 0);
+ return pack_halffloat(state, p, v, 0);
#endif
}
static int
-np_float(char *p, PyObject *v, const formatdef *f)
+np_float(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
float x = (float)PyFloat_AsDouble(v);
if (x == -1 && PyErr_Occurred()) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"required argument is not a float");
return -1;
}
@@ -736,11 +746,11 @@ np_float(char *p, PyObject *v, const formatdef *f)
}
static int
-np_double(char *p, PyObject *v, const formatdef *f)
+np_double(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
double x = PyFloat_AsDouble(v);
if (x == -1 && PyErr_Occurred()) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"required argument is not a float");
return -1;
}
@@ -749,11 +759,11 @@ np_double(char *p, PyObject *v, const formatdef *f)
}
static int
-np_void_p(char *p, PyObject *v, const formatdef *f)
+np_void_p(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
void *x;
- v = get_pylong(v);
+ v = get_pylong(state, v);
if (v == NULL)
return -1;
assert(PyLong_Check(v));
@@ -793,7 +803,7 @@ static const formatdef native_table[] = {
/* Big-endian routines. *****************************************************/
static PyObject *
-bu_int(const char *p, const formatdef *f)
+bu_int(_structmodulestate *state, const char *p, const formatdef *f)
{
long x = 0;
Py_ssize_t i = f->size;
@@ -808,7 +818,7 @@ bu_int(const char *p, const formatdef *f)
}
static PyObject *
-bu_uint(const char *p, const formatdef *f)
+bu_uint(_structmodulestate *state, const char *p, const formatdef *f)
{
unsigned long x = 0;
Py_ssize_t i = f->size;
@@ -820,7 +830,7 @@ bu_uint(const char *p, const formatdef *f)
}
static PyObject *
-bu_longlong(const char *p, const formatdef *f)
+bu_longlong(_structmodulestate *state, const char *p, const formatdef *f)
{
long long x = 0;
Py_ssize_t i = f->size;
@@ -835,7 +845,7 @@ bu_longlong(const char *p, const formatdef *f)
}
static PyObject *
-bu_ulonglong(const char *p, const formatdef *f)
+bu_ulonglong(_structmodulestate *state, const char *p, const formatdef *f)
{
unsigned long long x = 0;
Py_ssize_t i = f->size;
@@ -847,44 +857,44 @@ bu_ulonglong(const char *p, const formatdef *f)
}
static PyObject *
-bu_halffloat(const char *p, const formatdef *f)
+bu_halffloat(_structmodulestate *state, const char *p, const formatdef *f)
{
return unpack_halffloat(p, 0);
}
static PyObject *
-bu_float(const char *p, const formatdef *f)
+bu_float(_structmodulestate *state, const char *p, const formatdef *f)
{
return unpack_float(p, 0);
}
static PyObject *
-bu_double(const char *p, const formatdef *f)
+bu_double(_structmodulestate *state, const char *p, const formatdef *f)
{
return unpack_double(p, 0);
}
static PyObject *
-bu_bool(const char *p, const formatdef *f)
+bu_bool(_structmodulestate *state, const char *p, const formatdef *f)
{
return PyBool_FromLong(*p != 0);
}
static int
-bp_int(char *p, PyObject *v, const formatdef *f)
+bp_int(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
long x;
Py_ssize_t i;
unsigned char *q = (unsigned char *)p;
- if (get_long(v, &x) < 0)
+ if (get_long(state, v, &x) < 0)
return -1;
i = f->size;
if (i != SIZEOF_LONG) {
if ((i == 2) && (x < -32768 || x > 32767))
- RANGE_ERROR(x, f, 0, 0xffffL);
+ RANGE_ERROR(state, x, f, 0, 0xffffL);
#if (SIZEOF_LONG != 4)
else if ((i == 4) && (x < -2147483648L || x > 2147483647L))
- RANGE_ERROR(x, f, 0, 0xffffffffL);
+ RANGE_ERROR(state, x, f, 0, 0xffffffffL);
#endif
}
do {
@@ -895,19 +905,19 @@ bp_int(char *p, PyObject *v, const formatdef *f)
}
static int
-bp_uint(char *p, PyObject *v, const formatdef *f)
+bp_uint(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
unsigned long x;
Py_ssize_t i;
unsigned char *q = (unsigned char *)p;
- if (get_ulong(v, &x) < 0)
+ if (get_ulong(state, v, &x) < 0)
return -1;
i = f->size;
if (i != SIZEOF_LONG) {
unsigned long maxint = 1;
maxint <<= (unsigned long)(i * 8);
if (x >= maxint)
- RANGE_ERROR(x, f, 1, maxint - 1);
+ RANGE_ERROR(state, x, f, 1, maxint - 1);
}
do {
q[--i] = (unsigned char)(x & 0xffUL);
@@ -917,10 +927,10 @@ bp_uint(char *p, PyObject *v, const formatdef *f)
}
static int
-bp_longlong(char *p, PyObject *v, const formatdef *f)
+bp_longlong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
int res;
- v = get_pylong(v);
+ v = get_pylong(state, v);
if (v == NULL)
return -1;
res = _PyLong_AsByteArray((PyLongObject *)v,
@@ -933,10 +943,10 @@ bp_longlong(char *p, PyObject *v, const formatdef *f)
}
static int
-bp_ulonglong(char *p, PyObject *v, const formatdef *f)
+bp_ulonglong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
int res;
- v = get_pylong(v);
+ v = get_pylong(state, v);
if (v == NULL)
return -1;
res = _PyLong_AsByteArray((PyLongObject *)v,
@@ -949,17 +959,17 @@ bp_ulonglong(char *p, PyObject *v, const formatdef *f)
}
static int
-bp_halffloat(char *p, PyObject *v, const formatdef *f)
+bp_halffloat(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
- return pack_halffloat(p, v, 0);
+ return pack_halffloat(state, p, v, 0);
}
static int
-bp_float(char *p, PyObject *v, const formatdef *f)
+bp_float(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
double x = PyFloat_AsDouble(v);
if (x == -1 && PyErr_Occurred()) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"required argument is not a float");
return -1;
}
@@ -967,11 +977,11 @@ bp_float(char *p, PyObject *v, const formatdef *f)
}
static int
-bp_double(char *p, PyObject *v, const formatdef *f)
+bp_double(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
double x = PyFloat_AsDouble(v);
if (x == -1 && PyErr_Occurred()) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"required argument is not a float");
return -1;
}
@@ -979,7 +989,7 @@ bp_double(char *p, PyObject *v, const formatdef *f)
}
static int
-bp_bool(char *p, PyObject *v, const formatdef *f)
+bp_bool(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
int y;
y = PyObject_IsTrue(v);
@@ -1014,7 +1024,7 @@ static formatdef bigendian_table[] = {
/* Little-endian routines. *****************************************************/
static PyObject *
-lu_int(const char *p, const formatdef *f)
+lu_int(_structmodulestate *state, const char *p, const formatdef *f)
{
long x = 0;
Py_ssize_t i = f->size;
@@ -1029,7 +1039,7 @@ lu_int(const char *p, const formatdef *f)
}
static PyObject *
-lu_uint(const char *p, const formatdef *f)
+lu_uint(_structmodulestate *state, const char *p, const formatdef *f)
{
unsigned long x = 0;
Py_ssize_t i = f->size;
@@ -1041,7 +1051,7 @@ lu_uint(const char *p, const formatdef *f)
}
static PyObject *
-lu_longlong(const char *p, const formatdef *f)
+lu_longlong(_structmodulestate *state, const char *p, const formatdef *f)
{
long long x = 0;
Py_ssize_t i = f->size;
@@ -1056,7 +1066,7 @@ lu_longlong(const char *p, const formatdef *f)
}
static PyObject *
-lu_ulonglong(const char *p, const formatdef *f)
+lu_ulonglong(_structmodulestate *state, const char *p, const formatdef *f)
{
unsigned long long x = 0;
Py_ssize_t i = f->size;
@@ -1068,38 +1078,38 @@ lu_ulonglong(const char *p, const formatdef *f)
}
static PyObject *
-lu_halffloat(const char *p, const formatdef *f)
+lu_halffloat(_structmodulestate *state, const char *p, const formatdef *f)
{
return unpack_halffloat(p, 1);
}
static PyObject *
-lu_float(const char *p, const formatdef *f)
+lu_float(_structmodulestate *state, const char *p, const formatdef *f)
{
return unpack_float(p, 1);
}
static PyObject *
-lu_double(const char *p, const formatdef *f)
+lu_double(_structmodulestate *state, const char *p, const formatdef *f)
{
return unpack_double(p, 1);
}
static int
-lp_int(char *p, PyObject *v, const formatdef *f)
+lp_int(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
long x;
Py_ssize_t i;
unsigned char *q = (unsigned char *)p;
- if (get_long(v, &x) < 0)
+ if (get_long(state, v, &x) < 0)
return -1;
i = f->size;
if (i != SIZEOF_LONG) {
if ((i == 2) && (x < -32768 || x > 32767))
- RANGE_ERROR(x, f, 0, 0xffffL);
+ RANGE_ERROR(state, x, f, 0, 0xffffL);
#if (SIZEOF_LONG != 4)
else if ((i == 4) && (x < -2147483648L || x > 2147483647L))
- RANGE_ERROR(x, f, 0, 0xffffffffL);
+ RANGE_ERROR(state, x, f, 0, 0xffffffffL);
#endif
}
do {
@@ -1110,19 +1120,19 @@ lp_int(char *p, PyObject *v, const formatdef *f)
}
static int
-lp_uint(char *p, PyObject *v, const formatdef *f)
+lp_uint(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
unsigned long x;
Py_ssize_t i;
unsigned char *q = (unsigned char *)p;
- if (get_ulong(v, &x) < 0)
+ if (get_ulong(state, v, &x) < 0)
return -1;
i = f->size;
if (i != SIZEOF_LONG) {
unsigned long maxint = 1;
maxint <<= (unsigned long)(i * 8);
if (x >= maxint)
- RANGE_ERROR(x, f, 1, maxint - 1);
+ RANGE_ERROR(state, x, f, 1, maxint - 1);
}
do {
*q++ = (unsigned char)(x & 0xffUL);
@@ -1132,10 +1142,10 @@ lp_uint(char *p, PyObject *v, const formatdef *f)
}
static int
-lp_longlong(char *p, PyObject *v, const formatdef *f)
+lp_longlong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
int res;
- v = get_pylong(v);
+ v = get_pylong(state, v);
if (v == NULL)
return -1;
res = _PyLong_AsByteArray((PyLongObject*)v,
@@ -1148,10 +1158,10 @@ lp_longlong(char *p, PyObject *v, const formatdef *f)
}
static int
-lp_ulonglong(char *p, PyObject *v, const formatdef *f)
+lp_ulonglong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
int res;
- v = get_pylong(v);
+ v = get_pylong(state, v);
if (v == NULL)
return -1;
res = _PyLong_AsByteArray((PyLongObject*)v,
@@ -1164,17 +1174,17 @@ lp_ulonglong(char *p, PyObject *v, const formatdef *f)
}
static int
-lp_halffloat(char *p, PyObject *v, const formatdef *f)
+lp_halffloat(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
- return pack_halffloat(p, v, 1);
+ return pack_halffloat(state, p, v, 1);
}
static int
-lp_float(char *p, PyObject *v, const formatdef *f)
+lp_float(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
double x = PyFloat_AsDouble(v);
if (x == -1 && PyErr_Occurred()) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"required argument is not a float");
return -1;
}
@@ -1182,11 +1192,11 @@ lp_float(char *p, PyObject *v, const formatdef *f)
}
static int
-lp_double(char *p, PyObject *v, const formatdef *f)
+lp_double(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
{
double x = PyFloat_AsDouble(v);
if (x == -1 && PyErr_Occurred()) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"required argument is not a float");
return -1;
}
@@ -1246,14 +1256,14 @@ whichtable(const char **pfmt)
/* Get the table entry for a format code */
static const formatdef *
-getentry(int c, const formatdef *f)
+getentry(_structmodulestate *state, int c, const formatdef *f)
{
for (; f->format != '\0'; f++) {
if (f->format == c) {
return f;
}
}
- PyErr_SetString(_structmodulestate_global->StructError, "bad char in struct format");
+ PyErr_SetString(state->StructError, "bad char in struct format");
return NULL;
}
@@ -1295,9 +1305,11 @@ prepare_s(PyStructObject *self)
Py_ssize_t size, len, num, itemsize;
size_t ncodes;
+ _structmodulestate *state = get_struct_state_structinst(self);
+
fmt = PyBytes_AS_STRING(self->s_format);
if (strlen(fmt) != (size_t)PyBytes_GET_SIZE(self->s_format)) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"embedded null character");
return -1;
}
@@ -1323,7 +1335,7 @@ prepare_s(PyStructObject *self)
num = num*10 + (c - '0');
}
if (c == '\0') {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"repeat count given without format specifier");
return -1;
}
@@ -1331,7 +1343,7 @@ prepare_s(PyStructObject *self)
else
num = 1;
- e = getentry(c, f);
+ e = getentry(state, c, f);
if (e == NULL)
return -1;
@@ -1361,14 +1373,14 @@ prepare_s(PyStructObject *self)
self->s_size = size;
self->s_len = len;
- codes = PyMem_MALLOC((ncodes + 1) * sizeof(formatcode));
+ codes = PyMem_Malloc((ncodes + 1) * sizeof(formatcode));
if (codes == NULL) {
PyErr_NoMemory();
return -1;
}
/* Free any s_codes value left over from a previous initialization. */
if (self->s_codes != NULL)
- PyMem_FREE(self->s_codes);
+ PyMem_Free(self->s_codes);
self->s_codes = codes;
s = fmt;
@@ -1384,7 +1396,7 @@ prepare_s(PyStructObject *self)
else
num = 1;
- e = getentry(c, f);
+ e = getentry(state, c, f);
size = align(size, c, e);
if (c == 's' || c == 'p') {
@@ -1413,7 +1425,7 @@ prepare_s(PyStructObject *self)
return 0;
overflow:
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"total struct size too long");
return -1;
}
@@ -1490,7 +1502,7 @@ s_dealloc(PyStructObject *s)
if (s->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *)s);
if (s->s_codes != NULL) {
- PyMem_FREE(s->s_codes);
+ PyMem_Free(s->s_codes);
}
Py_XDECREF(s->s_format);
freefunc free_func = PyType_GetSlot(Py_TYPE(s), Py_tp_free);
@@ -1499,7 +1511,8 @@ s_dealloc(PyStructObject *s)
}
static PyObject *
-s_unpack_internal(PyStructObject *soself, const char *startfrom) {
+s_unpack_internal(PyStructObject *soself, const char *startfrom,
+ _structmodulestate *state) {
formatcode *code;
Py_ssize_t i = 0;
PyObject *result = PyTuple_New(soself->s_len);
@@ -1520,7 +1533,7 @@ s_unpack_internal(PyStructObject *soself, const char *startfrom) {
n = code->size - 1;
v = PyBytes_FromStringAndSize(res + 1, n);
} else {
- v = e->unpack(res, e);
+ v = e->unpack(state, res, e);
}
if (v == NULL)
goto fail;
@@ -1554,14 +1567,15 @@ static PyObject *
Struct_unpack_impl(PyStructObject *self, Py_buffer *buffer)
/*[clinic end generated code: output=873a24faf02e848a input=3113f8e7038b2f6c]*/
{
+ _structmodulestate *state = get_struct_state_structinst(self);
assert(self->s_codes != NULL);
if (buffer->len != self->s_size) {
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"unpack requires a buffer of %zd bytes",
self->s_size);
return NULL;
}
- return s_unpack_internal(self, buffer->buf);
+ return s_unpack_internal(self, buffer->buf, state);
}
/*[clinic input]
@@ -1585,11 +1599,12 @@ Struct_unpack_from_impl(PyStructObject *self, Py_buffer *buffer,
Py_ssize_t offset)
/*[clinic end generated code: output=57fac875e0977316 input=cafd4851d473c894]*/
{
+ _structmodulestate *state = get_struct_state_structinst(self);
assert(self->s_codes != NULL);
if (offset < 0) {
if (offset + self->s_size > 0) {
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"not enough data to unpack %zd bytes at offset %zd",
self->s_size,
offset);
@@ -1597,7 +1612,7 @@ Struct_unpack_from_impl(PyStructObject *self, Py_buffer *buffer,
}
if (offset + buffer->len < 0) {
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"offset %zd out of range for %zd-byte buffer",
offset,
buffer->len);
@@ -1607,7 +1622,7 @@ Struct_unpack_from_impl(PyStructObject *self, Py_buffer *buffer,
}
if ((buffer->len - offset) < self->s_size) {
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"unpack_from requires a buffer of at least %zu bytes for "
"unpacking %zd bytes at offset %zd "
"(actual buffer size is %zd)",
@@ -1617,7 +1632,7 @@ Struct_unpack_from_impl(PyStructObject *self, Py_buffer *buffer,
buffer->len);
return NULL;
}
- return s_unpack_internal(self, (char*)buffer->buf + offset);
+ return s_unpack_internal(self, (char*)buffer->buf + offset, state);
}
@@ -1671,6 +1686,7 @@ static PyMethodDef unpackiter_methods[] = {
static PyObject *
unpackiter_iternext(unpackiterobject *self)
{
+ _structmodulestate *state = get_struct_state_iterinst(self);
PyObject *result;
if (self->so == NULL)
return NULL;
@@ -1682,7 +1698,8 @@ unpackiter_iternext(unpackiterobject *self)
}
assert(self->index + self->so->s_size <= self->buf.len);
result = s_unpack_internal(self->so,
- (char*) self->buf.buf + self->index);
+ (char*) self->buf.buf + self->index,
+ state);
self->index += self->so->s_size;
return result;
}
@@ -1729,17 +1746,18 @@ static PyObject *
Struct_iter_unpack(PyStructObject *self, PyObject *buffer)
/*[clinic end generated code: output=172d83d0cd15dbab input=6d65b3f3107dbc99]*/
{
+ _structmodulestate *state = get_struct_state_structinst(self);
unpackiterobject *iter;
assert(self->s_codes != NULL);
if (self->s_size == 0) {
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"cannot iteratively unpack with a struct of length 0");
return NULL;
}
- iter = (unpackiterobject *) PyType_GenericAlloc((PyTypeObject *)_structmodulestate_global->unpackiter_type, 0);
+ iter = (unpackiterobject *) PyType_GenericAlloc((PyTypeObject *)state->unpackiter_type, 0);
if (iter == NULL)
return NULL;
@@ -1748,7 +1766,7 @@ Struct_iter_unpack(PyStructObject *self, PyObject *buffer)
return NULL;
}
if (iter->buf.len % self->s_size != 0) {
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"iterative unpacking requires a buffer of "
"a multiple of %zd bytes",
self->s_size);
@@ -1773,7 +1791,8 @@ Struct_iter_unpack(PyStructObject *self, PyObject *buffer)
*
*/
static int
-s_pack_internal(PyStructObject *soself, PyObject *const *args, int offset, char* buf)
+s_pack_internal(PyStructObject *soself, PyObject *const *args, int offset,
+ char* buf, _structmodulestate *state)
{
formatcode *code;
/* XXX(nnorwitz): why does i need to be a local? can we use
@@ -1794,7 +1813,7 @@ s_pack_internal(PyStructObject *soself, PyObject *const *args, int offset, char*
const void *p;
isstring = PyBytes_Check(v);
if (!isstring && !PyByteArray_Check(v)) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"argument for 's' must be a bytes object");
return -1;
}
@@ -1816,7 +1835,7 @@ s_pack_internal(PyStructObject *soself, PyObject *const *args, int offset, char*
const void *p;
isstring = PyBytes_Check(v);
if (!isstring && !PyByteArray_Check(v)) {
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"argument for 'p' must be a bytes object");
return -1;
}
@@ -1836,9 +1855,9 @@ s_pack_internal(PyStructObject *soself, PyObject *const *args, int offset, char*
n = 255;
*res = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char);
} else {
- if (e->pack(res, v, e) < 0) {
+ if (e->pack(state, res, v, e) < 0) {
if (PyLong_Check(v) && PyErr_ExceptionMatches(PyExc_OverflowError))
- PyErr_SetString(_structmodulestate_global->StructError,
+ PyErr_SetString(state->StructError,
"int too large to convert");
return -1;
}
@@ -1864,14 +1883,15 @@ s_pack(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
{
char *buf;
PyStructObject *soself;
+ _structmodulestate *state = get_struct_state_structinst(self);
/* Validate arguments. */
soself = (PyStructObject *)self;
- assert(PyStruct_Check(self));
+ assert(PyStruct_Check(self, state));
assert(soself->s_codes != NULL);
if (nargs != soself->s_len)
{
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"pack expected %zd items for packing (got %zd)", soself->s_len, nargs);
return NULL;
}
@@ -1886,7 +1906,7 @@ s_pack(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
}
/* Call the guts */
- if ( s_pack_internal(soself, args, 0, buf) != 0 ) {
+ if ( s_pack_internal(soself, args, 0, buf, state) != 0 ) {
_PyBytesWriter_Dealloc(&writer);
return NULL;
}
@@ -1908,23 +1928,24 @@ s_pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
PyStructObject *soself;
Py_buffer buffer;
Py_ssize_t offset;
+ _structmodulestate *state = get_struct_state_structinst(self);
/* Validate arguments. +1 is for the first arg as buffer. */
soself = (PyStructObject *)self;
- assert(PyStruct_Check(self));
+ assert(PyStruct_Check(self, state));
assert(soself->s_codes != NULL);
if (nargs != (soself->s_len + 2))
{
if (nargs == 0) {
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"pack_into expected buffer argument");
}
else if (nargs == 1) {
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"pack_into expected offset argument");
}
else {
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"pack_into expected %zd items for packing (got %zd)",
soself->s_len, (nargs - 2));
}
@@ -1947,7 +1968,7 @@ s_pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
if (offset < 0) {
/* Check that negative offset is low enough to fit data */
if (offset + soself->s_size > 0) {
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"no space to pack %zd bytes at offset %zd",
soself->s_size,
offset);
@@ -1957,7 +1978,7 @@ s_pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
/* Check that negative offset is not crossing buffer boundary */
if (offset + buffer.len < 0) {
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"offset %zd out of range for %zd-byte buffer",
offset,
buffer.len);
@@ -1973,7 +1994,7 @@ s_pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
assert(offset >= 0);
assert(soself->s_size >= 0);
- PyErr_Format(_structmodulestate_global->StructError,
+ PyErr_Format(state->StructError,
"pack_into requires a buffer of at least %zu bytes for "
"packing %zd bytes at offset %zd "
"(actual buffer size is %zd)",
@@ -1986,7 +2007,7 @@ s_pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
}
/* Call the guts */
- if (s_pack_internal(soself, args, 2, (char*)buffer.buf + offset) != 0) {
+ if (s_pack_internal(soself, args, 2, (char*)buffer.buf + offset, state) != 0) {
PyBuffer_Release(&buffer);
return NULL;
}
@@ -2080,12 +2101,12 @@ static PyType_Spec PyStructType_spec = {
/* ---- Standalone functions ---- */
#define MAXCACHE 100
-static PyObject *cache = NULL;
static int
-cache_struct_converter(PyObject *fmt, PyStructObject **ptr)
+cache_struct_converter(PyObject *module, PyObject *fmt, PyStructObject **ptr)
{
PyObject * s_object;
+ _structmodulestate *state = get_struct_state(module);
if (fmt == NULL) {
Py_DECREF(*ptr);
@@ -2093,13 +2114,13 @@ cache_struct_converter(PyObject *fmt, PyStructObject **ptr)
return 1;
}
- if (cache == NULL) {
- cache = PyDict_New();
- if (cache == NULL)
+ if (state->cache == NULL) {
+ state->cache = PyDict_New();
+ if (state->cache == NULL)
return 0;
}
- s_object = PyDict_GetItemWithError(cache, fmt);
+ s_object = PyDict_GetItemWithError(state->cache, fmt);
if (s_object != NULL) {
Py_INCREF(s_object);
*ptr = (PyStructObject *)s_object;
@@ -2109,12 +2130,12 @@ cache_struct_converter(PyObject *fmt, PyStructObject **ptr)
return 0;
}
- s_object = PyObject_CallOneArg(_structmodulestate_global->PyStructType, fmt);
+ s_object = PyObject_CallOneArg(state->PyStructType, fmt);
if (s_object != NULL) {
- if (PyDict_GET_SIZE(cache) >= MAXCACHE)
- PyDict_Clear(cache);
+ if (PyDict_GET_SIZE(state->cache) >= MAXCACHE)
+ PyDict_Clear(state->cache);
/* Attempt to cache the result */
- if (PyDict_SetItem(cache, fmt, s_object) == -1)
+ if (PyDict_SetItem(state->cache, fmt, s_object) == -1)
PyErr_Clear();
*ptr = (PyStructObject *)s_object;
return Py_CLEANUP_SUPPORTED;
@@ -2132,7 +2153,7 @@ static PyObject *
_clearcache_impl(PyObject *module)
/*[clinic end generated code: output=ce4fb8a7bf7cb523 input=463eaae04bab3211]*/
{
- Py_CLEAR(cache);
+ Py_CLEAR(get_struct_state(module)->cache);
Py_RETURN_NONE;
}
@@ -2160,7 +2181,7 @@ Return a bytes object containing the values v1, v2, ... packed according\n\
to the format string. See help(struct) for more on format strings.");
static PyObject *
-pack(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
+pack(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *s_object = NULL;
PyObject *format, *result;
@@ -2171,7 +2192,7 @@ pack(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
}
format = args[0];
- if (!cache_struct_converter(format, (PyStructObject **)&s_object)) {
+ if (!cache_struct_converter(module, format, (PyStructObject **)&s_object)) {
return NULL;
}
result = s_pack(s_object, args + 1, nargs - 1);
@@ -2188,7 +2209,7 @@ that the offset is a required argument. See help(struct) for more\n\
on format strings.");
static PyObject *
-pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
+pack_into(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *s_object = NULL;
PyObject *format, *result;
@@ -2199,7 +2220,7 @@ pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
}
format = args[0];
- if (!cache_struct_converter(format, (PyStructObject **)&s_object)) {
+ if (!cache_struct_converter(module, format, (PyStructObject **)&s_object)) {
return NULL;
}
result = s_pack_into(s_object, args + 1, nargs - 1);
@@ -2322,8 +2343,9 @@ The variable struct.error is an exception raised on errors.\n");
static int
_structmodule_traverse(PyObject *module, visitproc visit, void *arg)
{
- _structmodulestate *state = (_structmodulestate *)PyModule_GetState(module);
+ _structmodulestate *state = get_struct_state(module);
if (state) {
+ Py_VISIT(state->cache);
Py_VISIT(state->PyStructType);
Py_VISIT(state->unpackiter_type);
Py_VISIT(state->StructError);
@@ -2334,8 +2356,9 @@ _structmodule_traverse(PyObject *module, visitproc visit, void *arg)
static int
_structmodule_clear(PyObject *module)
{
- _structmodulestate *state = (_structmodulestate *)PyModule_GetState(module);
+ _structmodulestate *state = get_struct_state(module);
if (state) {
+ Py_CLEAR(state->cache);
Py_CLEAR(state->PyStructType);
Py_CLEAR(state->unpackiter_type);
Py_CLEAR(state->StructError);
@@ -2349,40 +2372,25 @@ _structmodule_free(void *module)
_structmodule_clear((PyObject *)module);
}
-static struct PyModuleDef _structmodule = {
- PyModuleDef_HEAD_INIT,
- "_struct",
- module_doc,
- sizeof(_structmodulestate),
- module_functions,
- NULL,
- _structmodule_traverse,
- _structmodule_clear,
- _structmodule_free,
-};
-
-PyMODINIT_FUNC
-PyInit__struct(void)
+static int
+_structmodule_exec(PyObject *m)
{
- PyObject *m;
+ _structmodulestate *state = get_struct_state(m);
- m = PyModule_Create(&_structmodule);
- if (m == NULL)
- return NULL;
-
- PyObject *PyStructType = PyType_FromSpec(&PyStructType_spec);
- if (PyStructType == NULL) {
- return NULL;
+ state->PyStructType = PyType_FromModuleAndSpec(
+ m, &PyStructType_spec, NULL);
+ if (state->PyStructType == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(m, (PyTypeObject *)state->PyStructType) < 0) {
+ return -1;
}
- Py_INCREF(PyStructType);
- PyModule_AddObject(m, "Struct", PyStructType);
- get_struct_state(m)->PyStructType = PyStructType;
- PyObject *unpackiter_type = PyType_FromSpec(&unpackiter_type_spec);
- if (unpackiter_type == NULL) {
- return NULL;
+ state->unpackiter_type = PyType_FromModuleAndSpec(
+ m, &unpackiter_type_spec, NULL);
+ if (state->unpackiter_type == NULL) {
+ return -1;
}
- get_struct_state(m)->unpackiter_type = unpackiter_type;
/* Check endian and swap in faster functions */
{
@@ -2427,12 +2435,36 @@ PyInit__struct(void)
}
/* Add some symbolic constants to the module */
- PyObject *StructError = PyErr_NewException("struct.error", NULL, NULL);
- if (StructError == NULL)
- return NULL;
- Py_INCREF(StructError);
- PyModule_AddObject(m, "error", StructError);
- get_struct_state(m)->StructError = StructError;
+ state->StructError = PyErr_NewException("struct.error", NULL, NULL);
+ if (state->StructError == NULL) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "error", state->StructError) < 0) {
+ return -1;
+ }
+
+ return 0;
+}
- return m;
+static PyModuleDef_Slot _structmodule_slots[] = {
+ {Py_mod_exec, _structmodule_exec},
+ {0, NULL}
+};
+
+static struct PyModuleDef _structmodule = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "_struct",
+ .m_doc = module_doc,
+ .m_size = sizeof(_structmodulestate),
+ .m_methods = module_functions,
+ .m_slots = _structmodule_slots,
+ .m_traverse = _structmodule_traverse,
+ .m_clear = _structmodule_clear,
+ .m_free = _structmodule_free,
+};
+
+PyMODINIT_FUNC
+PyInit__struct(void)
+{
+ return PyModuleDef_Init(&_structmodule);
}
diff --git a/Modules/_testbuffer.c b/Modules/_testbuffer.c
index d8321768bc..1b4fb09fb8 100644
--- a/Modules/_testbuffer.c
+++ b/Modules/_testbuffer.c
@@ -236,7 +236,7 @@ ndarray_dealloc(NDArrayObject *self)
ndbuf_pop(self);
}
}
- PyObject_Del(self);
+ PyObject_Free(self);
}
static int
@@ -2734,7 +2734,7 @@ staticarray_init(PyObject *self, PyObject *args, PyObject *kwds)
static void
staticarray_dealloc(StaticArrayObject *self)
{
- PyObject_Del(self);
+ PyObject_Free(self);
}
/* Return a buffer for a PyBUF_FULL_RO request. Flags are not checked,
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 28d2c124d5..4f97927fa2 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -1019,6 +1019,62 @@ test_buildvalue_N(PyObject *self, PyObject *Py_UNUSED(ignored))
static PyObject *
+test_get_statictype_slots(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ newfunc tp_new = PyType_GetSlot(&PyLong_Type, Py_tp_new);
+ if (PyLong_Type.tp_new != tp_new) {
+ PyErr_SetString(PyExc_AssertionError, "mismatch: tp_new of long");
+ return NULL;
+ }
+
+ reprfunc tp_repr = PyType_GetSlot(&PyLong_Type, Py_tp_repr);
+ if (PyLong_Type.tp_repr != tp_repr) {
+ PyErr_SetString(PyExc_AssertionError, "mismatch: tp_repr of long");
+ return NULL;
+ }
+
+ ternaryfunc tp_call = PyType_GetSlot(&PyLong_Type, Py_tp_call);
+ if (tp_call != NULL) {
+ PyErr_SetString(PyExc_AssertionError, "mismatch: tp_call of long");
+ return NULL;
+ }
+
+ binaryfunc nb_add = PyType_GetSlot(&PyLong_Type, Py_nb_add);
+ if (PyLong_Type.tp_as_number->nb_add != nb_add) {
+ PyErr_SetString(PyExc_AssertionError, "mismatch: nb_add of long");
+ return NULL;
+ }
+
+ lenfunc mp_length = PyType_GetSlot(&PyLong_Type, Py_mp_length);
+ if (mp_length != NULL) {
+ PyErr_SetString(PyExc_AssertionError, "mismatch: mp_length of long");
+ return NULL;
+ }
+
+ void *over_value = PyType_GetSlot(&PyLong_Type, Py_bf_releasebuffer + 1);
+ if (over_value != NULL) {
+ PyErr_SetString(PyExc_AssertionError, "mismatch: max+1 of long");
+ return NULL;
+ }
+
+ tp_new = PyType_GetSlot(&PyLong_Type, 0);
+ if (tp_new != NULL) {
+ PyErr_SetString(PyExc_AssertionError, "mismatch: slot 0 of long");
+ return NULL;
+ }
+ if (PyErr_ExceptionMatches(PyExc_SystemError)) {
+ // This is the right exception
+ PyErr_Clear();
+ }
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+
+static PyObject *
get_args(PyObject *self, PyObject *args)
{
if (args == NULL) {
@@ -1932,12 +1988,12 @@ unicode_asucs4(PyObject *self, PyObject *args)
buffer[str_len] = 0xffffU;
if (!PyUnicode_AsUCS4(unicode, buffer, buf_len, copy_null)) {
- PyMem_FREE(buffer);
+ PyMem_Free(buffer);
return NULL;
}
result = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buffer, buf_len);
- PyMem_FREE(buffer);
+ PyMem_Free(buffer);
return result;
}
@@ -5556,6 +5612,59 @@ pynumber_tobase(PyObject *module, PyObject *args)
static PyObject *test_buildvalue_issue38913(PyObject *, PyObject *);
+
+static PyObject*
+test_set_type_size(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ PyObject *obj = PyList_New(0);
+ if (obj == NULL) {
+ return NULL;
+ }
+
+ // Ensure that following tests don't modify the object,
+ // to ensure that Py_DECREF() will not crash.
+ assert(Py_TYPE(obj) == &PyList_Type);
+ assert(Py_SIZE(obj) == 0);
+
+ // bpo-39573: Check that Py_TYPE() and Py_SIZE() can be used
+ // as l-values to set an object type and size.
+ Py_TYPE(obj) = &PyList_Type;
+ Py_SIZE(obj) = 0;
+
+ Py_DECREF(obj);
+ Py_RETURN_NONE;
+}
+
+
+// Test Py_NewRef() and Py_XNewRef() functions
+static PyObject*
+test_refcount(PyObject *self, PyObject *Py_UNUSED(ignored))
+{
+ PyObject *obj = PyList_New(0);
+ if (obj == NULL) {
+ return NULL;
+ }
+ assert(Py_REFCNT(obj) == 1);
+
+ // Test Py_NewRef()
+ PyObject *ref = Py_NewRef(obj);
+ assert(ref == obj);
+ assert(Py_REFCNT(obj) == 2);
+ Py_DECREF(ref);
+
+ // Test Py_XNewRef()
+ PyObject *xref = Py_XNewRef(obj);
+ assert(xref == obj);
+ assert(Py_REFCNT(obj) == 2);
+ Py_DECREF(xref);
+
+ assert(Py_XNewRef(NULL) == NULL);
+
+ Py_DECREF(obj);
+ Py_RETURN_NONE;
+}
+
+
static PyMethodDef TestMethods[] = {
{"raise_exception", raise_exception, METH_VARARGS},
{"raise_memoryerror", raise_memoryerror, METH_NOARGS},
@@ -5627,8 +5736,10 @@ static PyMethodDef TestMethods[] = {
{"PyBuffer_SizeFromFormat", test_PyBuffer_SizeFromFormat, METH_VARARGS},
{"test_buildvalue_N", test_buildvalue_N, METH_NOARGS},
{"test_buildvalue_issue38913", test_buildvalue_issue38913, METH_NOARGS},
- {"get_args", get_args, METH_VARARGS},
- {"get_kwargs", (PyCFunction)(void(*)(void))get_kwargs, METH_VARARGS|METH_KEYWORDS},
+ {"get_args", get_args, METH_VARARGS},
+ {"test_get_statictype_slots", test_get_statictype_slots, METH_NOARGS},
+ {"get_kwargs", (PyCFunction)(void(*)(void))get_kwargs,
+ METH_VARARGS|METH_KEYWORDS},
{"getargs_tuple", getargs_tuple, METH_VARARGS},
{"getargs_keywords", (PyCFunction)(void(*)(void))getargs_keywords,
METH_VARARGS|METH_KEYWORDS},
@@ -5825,6 +5936,8 @@ static PyMethodDef TestMethods[] = {
{"meth_fastcall_keywords", (PyCFunction)(void(*)(void))meth_fastcall_keywords, METH_FASTCALL|METH_KEYWORDS},
{"pynumber_tobase", pynumber_tobase, METH_VARARGS},
{"without_gc", without_gc, METH_O},
+ {"test_set_type_size", test_set_type_size, METH_NOARGS},
+ {"test_refcount", test_refcount, METH_NOARGS},
{NULL, NULL} /* sentinel */
};
@@ -5927,7 +6040,7 @@ test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
static void
test_structmembers_free(PyObject *ob)
{
- PyObject_FREE(ob);
+ PyObject_Free(ob);
}
static PyTypeObject test_structmembersType = {
@@ -6142,7 +6255,8 @@ awaitObject_await(awaitObject *ao)
static PyAsyncMethods awaitType_as_async = {
(unaryfunc)awaitObject_await, /* am_await */
0, /* am_aiter */
- 0 /* am_anext */
+ 0, /* am_anext */
+ 0, /* am_send */
};
@@ -6508,6 +6622,23 @@ static PyType_Spec HeapDocCType_spec = {
HeapDocCType_slots
};
+typedef struct {
+ PyObject_HEAD
+} NullTpDocTypeObject;
+
+static PyType_Slot NullTpDocType_slots[] = {
+ {Py_tp_doc, NULL},
+ {0, 0},
+};
+
+static PyType_Spec NullTpDocType_spec = {
+ "_testcapi.NullTpDocType",
+ sizeof(NullTpDocTypeObject),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ NullTpDocType_slots
+};
+
PyDoc_STRVAR(heapgctype__doc__,
"A heap type with GC, and with overridden dealloc.\n\n"
@@ -6563,7 +6694,7 @@ static void
heapctype_dealloc(HeapCTypeObject *self)
{
PyTypeObject *tp = Py_TYPE(self);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(tp);
}
@@ -6753,7 +6884,7 @@ heapctypewithdict_dealloc(HeapCTypeWithDictObject* self)
PyTypeObject *tp = Py_TYPE(self);
Py_XDECREF(self->dict);
- PyObject_DEL(self);
+ PyObject_Free(self);
Py_DECREF(tp);
}
@@ -6824,7 +6955,7 @@ heapctypewithweakref_dealloc(HeapCTypeWithWeakrefObject* self)
if (self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
Py_XDECREF(self->weakreflist);
- PyObject_DEL(self);
+ PyObject_Free(self);
Py_DECREF(tp);
}
@@ -6867,7 +6998,7 @@ static void
heapctypesetattr_dealloc(HeapCTypeSetattrObject *self)
{
PyTypeObject *tp = Py_TYPE(self);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(tp);
}
@@ -7183,6 +7314,14 @@ PyInit__testcapi(void)
}
PyModule_AddObject(m, "HeapDocCType", HeapDocCType);
+ /* bpo-41832: Add a new type to test PyType_FromSpec()
+ now can accept a NULL tp_doc slot. */
+ PyObject *NullTpDocType = PyType_FromSpec(&NullTpDocType_spec);
+ if (NullTpDocType == NULL) {
+ return NULL;
+ }
+ PyModule_AddObject(m, "NullTpDocType", NullTpDocType);
+
PyObject *HeapGcCType = PyType_FromSpec(&HeapGcCType_spec);
if (HeapGcCType == NULL) {
return NULL;
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index ad74af8363..ab6c5965d1 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -12,10 +12,12 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
+#include "pycore_atomic_funcs.h" // _Py_atomic_int_get()
#include "pycore_bitutils.h" // _Py_bswap32()
-#include "pycore_initconfig.h" // _Py_GetConfigsAsDict()
-#include "pycore_hashtable.h" // _Py_hashtable_new()
#include "pycore_gc.h" // PyGC_Head
+#include "pycore_hashtable.h" // _Py_hashtable_new()
+#include "pycore_initconfig.h" // _Py_GetConfigsAsDict()
+#include "pycore_interp.h" // _PyInterpreterState_GetConfigCopy()
static PyObject *
@@ -231,6 +233,52 @@ test_hashtable(PyObject *self, PyObject *Py_UNUSED(args))
}
+static PyObject *
+test_get_config(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
+{
+ PyConfig config;
+ PyConfig_InitIsolatedConfig(&config);
+ if (_PyInterpreterState_GetConfigCopy(&config) < 0) {
+ PyConfig_Clear(&config);
+ return NULL;
+ }
+ PyObject *dict = _PyConfig_AsDict(&config);
+ PyConfig_Clear(&config);
+ return dict;
+}
+
+
+static PyObject *
+test_set_config(PyObject *Py_UNUSED(self), PyObject *dict)
+{
+ PyConfig config;
+ PyConfig_InitIsolatedConfig(&config);
+ if (_PyConfig_FromDict(&config, dict) < 0) {
+ goto error;
+ }
+ if (_PyInterpreterState_SetConfig(&config) < 0) {
+ goto error;
+ }
+ PyConfig_Clear(&config);
+ Py_RETURN_NONE;
+
+error:
+ PyConfig_Clear(&config);
+ return NULL;
+}
+
+
+static PyObject*
+test_atomic_funcs(PyObject *self, PyObject *Py_UNUSED(args))
+{
+ // Test _Py_atomic_size_get() and _Py_atomic_size_set()
+ Py_ssize_t var = 1;
+ _Py_atomic_size_set(&var, 2);
+ assert(_Py_atomic_size_get(&var) == 2);
+ Py_RETURN_NONE;
+}
+
+
static PyMethodDef TestMethods[] = {
{"get_configs", get_configs, METH_NOARGS},
{"get_recursion_depth", get_recursion_depth, METH_NOARGS},
@@ -238,6 +286,9 @@ static PyMethodDef TestMethods[] = {
{"test_popcount", test_popcount, METH_NOARGS},
{"test_bit_length", test_bit_length, METH_NOARGS},
{"test_hashtable", test_hashtable, METH_NOARGS},
+ {"get_config", test_get_config, METH_NOARGS},
+ {"set_config", test_set_config, METH_O},
+ {"test_atomic_funcs", test_atomic_funcs, METH_NOARGS},
{NULL, NULL} /* sentinel */
};
diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c
index 8bba077be9..ad60f32f7e 100644
--- a/Modules/_testmultiphase.c
+++ b/Modules/_testmultiphase.c
@@ -121,24 +121,30 @@ static PyType_Spec Example_Type_spec = {
};
+static PyModuleDef def_meth_state_access;
+
/*[clinic input]
_testmultiphase.StateAccessType.get_defining_module
cls: defining_class
Return the module of the defining class.
+
+Also tests that result of _PyType_GetModuleByDef matches defining_class's
+module.
[clinic start generated code]*/
static PyObject *
_testmultiphase_StateAccessType_get_defining_module_impl(StateAccessTypeObject *self,
PyTypeObject *cls)
-/*[clinic end generated code: output=ba2a14284a5d0921 input=946149f91cf72c0d]*/
+/*[clinic end generated code: output=ba2a14284a5d0921 input=356f999fc16e0933]*/
{
PyObject *retval;
retval = PyType_GetModule(cls);
if (retval == NULL) {
return NULL;
}
+ assert(_PyType_GetModuleByDef(Py_TYPE(self), &def_meth_state_access) == retval);
Py_INCREF(retval);
return retval;
}
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index 56ed8a2e2d..9b8757715a 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -7,13 +7,36 @@
#include "pycore_interp.h" // _PyInterpreterState.num_threads
#include "pycore_pystate.h" // _PyThreadState_Init()
#include <stddef.h> // offsetof()
+#include "structmember.h" // PyMemberDef
-static PyObject *ThreadError;
-static PyObject *str_dict;
+// ThreadError is just an alias to PyExc_RuntimeError
+#define ThreadError PyExc_RuntimeError
+
+_Py_IDENTIFIER(__dict__);
_Py_IDENTIFIER(stderr);
_Py_IDENTIFIER(flush);
+
+// Forward declarations
+static struct PyModuleDef thread_module;
+
+
+typedef struct {
+ PyTypeObject *lock_type;
+ PyTypeObject *local_type;
+ PyTypeObject *local_dummy_type;
+} thread_module_state;
+
+static inline thread_module_state*
+get_thread_state(PyObject *module)
+{
+ void *state = PyModule_GetState(module);
+ assert(state != NULL);
+ return (thread_module_state *)state;
+}
+
+
/* Lock objects */
typedef struct {
@@ -23,18 +46,28 @@ typedef struct {
char locked; /* for sanity checking */
} lockobject;
+static int
+lock_traverse(lockobject *self, visitproc visit, void *arg)
+{
+ Py_VISIT(Py_TYPE(self));
+ return 0;
+}
+
static void
lock_dealloc(lockobject *self)
{
- if (self->in_weakreflist != NULL)
+ if (self->in_weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject *) self);
+ }
if (self->lock_lock != NULL) {
/* Unlock the lock so it's safe to free it */
if (self->locked)
PyThread_release_lock(self->lock_lock);
PyThread_free_lock(self->lock_lock);
}
- PyObject_Del(self);
+ PyTypeObject *tp = Py_TYPE(self);
+ tp->tp_free((PyObject*)self);
+ Py_DECREF(tp);
}
/* Helper to acquire an interruptible lock with a timeout. If the lock acquire
@@ -48,12 +81,13 @@ acquire_timed(PyThread_type_lock lock, _PyTime_t timeout)
{
PyLockStatus r;
_PyTime_t endtime = 0;
- _PyTime_t microseconds;
- if (timeout > 0)
+ if (timeout > 0) {
endtime = _PyTime_GetMonotonicClock() + timeout;
+ }
do {
+ _PyTime_t microseconds;
microseconds = _PyTime_AsMicroseconds(timeout, _PyTime_ROUND_CEILING);
/* first a simple non-blocking try without releasing the GIL */
@@ -138,12 +172,10 @@ static PyObject *
lock_PyThread_acquire_lock(lockobject *self, PyObject *args, PyObject *kwds)
{
_PyTime_t timeout;
- PyLockStatus r;
-
if (lock_acquire_parse_args(args, kwds, &timeout) < 0)
return NULL;
- r = acquire_timed(self->lock_lock, timeout);
+ PyLockStatus r = acquire_timed(self->lock_lock, timeout);
if (r == PY_LOCK_INTR) {
return NULL;
}
@@ -245,36 +277,38 @@ static PyMethodDef lock_methods[] = {
{NULL, NULL} /* sentinel */
};
-static PyTypeObject Locktype = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "_thread.lock", /*tp_name*/
- sizeof(lockobject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)lock_dealloc, /*tp_dealloc*/
- 0, /*tp_vectorcall_offset*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_as_async*/
- (reprfunc)lock_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- offsetof(lockobject, in_weakreflist), /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- lock_methods, /*tp_methods*/
+PyDoc_STRVAR(lock_doc,
+"A lock object is a synchronization primitive. To create a lock,\n\
+call threading.Lock(). Methods are:\n\
+\n\
+acquire() -- lock the lock, possibly blocking until it can be obtained\n\
+release() -- unlock of the lock\n\
+locked() -- test whether the lock is currently locked\n\
+\n\
+A lock is not owned by the thread that locked it; another thread may\n\
+unlock it. A thread attempting to lock a lock that it has already locked\n\
+will block until another thread unlocks it. Deadlocks may ensue.");
+
+static PyMemberDef lock_type_members[] = {
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(lockobject, in_weakreflist), READONLY},
+ {NULL},
+};
+
+static PyType_Slot lock_type_slots[] = {
+ {Py_tp_dealloc, (destructor)lock_dealloc},
+ {Py_tp_repr, (reprfunc)lock_repr},
+ {Py_tp_doc, (void *)lock_doc},
+ {Py_tp_methods, lock_methods},
+ {Py_tp_traverse, lock_traverse},
+ {Py_tp_members, lock_type_members},
+ {0, 0}
+};
+
+static PyType_Spec lock_type_spec = {
+ .name = "_thread.lock",
+ .basicsize = sizeof(lockobject),
+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
+ .slots = lock_type_slots,
};
/* Recursive lock objects */
@@ -301,7 +335,9 @@ rlock_dealloc(rlockobject *self)
PyThread_free_lock(self->rlock_lock);
}
- Py_TYPE(self)->tp_free(self);
+ PyTypeObject *tp = Py_TYPE(self);
+ tp->tp_free(self);
+ Py_DECREF(tp);
}
static PyObject *
@@ -525,58 +561,43 @@ static PyMethodDef rlock_methods[] = {
};
-static PyTypeObject RLocktype = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "_thread.RLock", /*tp_name*/
- sizeof(rlockobject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)rlock_dealloc, /*tp_dealloc*/
- 0, /*tp_vectorcall_offset*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_as_async*/
- (reprfunc)rlock_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- offsetof(rlockobject, in_weakreflist), /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- rlock_methods, /*tp_methods*/
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- PyType_GenericAlloc, /* tp_alloc */
- rlock_new /* tp_new */
+static PyMemberDef rlock_type_members[] = {
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(rlockobject, in_weakreflist), READONLY},
+ {NULL},
+};
+
+static PyType_Slot rlock_type_slots[] = {
+ {Py_tp_dealloc, (destructor)rlock_dealloc},
+ {Py_tp_repr, (reprfunc)rlock_repr},
+ {Py_tp_methods, rlock_methods},
+ {Py_tp_alloc, PyType_GenericAlloc},
+ {Py_tp_new, rlock_new},
+ {Py_tp_members, rlock_type_members},
+ {0, 0},
+};
+
+static PyType_Spec rlock_type_spec = {
+ .name = "_thread.RLock",
+ .basicsize = sizeof(rlockobject),
+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ .slots = rlock_type_slots,
};
static lockobject *
-newlockobject(void)
+newlockobject(PyObject *module)
{
- lockobject *self;
- self = PyObject_New(lockobject, &Locktype);
- if (self == NULL)
+ thread_module_state *state = get_thread_state(module);
+
+ PyTypeObject *type = state->lock_type;
+ lockobject *self = (lockobject *)type->tp_alloc(type, 0);
+ if (self == NULL) {
return NULL;
+ }
+
self->lock_lock = PyThread_allocate_lock();
self->locked = 0;
self->in_weakreflist = NULL;
+
if (self->lock_lock == NULL) {
Py_DECREF(self);
PyErr_SetString(ThreadError, "can't allocate lock");
@@ -637,35 +658,28 @@ localdummy_dealloc(localdummyobject *self)
{
if (self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
- Py_TYPE(self)->tp_free((PyObject*)self);
+ PyTypeObject *tp = Py_TYPE(self);
+ tp->tp_free((PyObject*)self);
+ Py_DECREF(tp);
}
-static PyTypeObject localdummytype = {
- PyVarObject_HEAD_INIT(NULL, 0)
- /* tp_name */ "_thread._localdummy",
- /* tp_basicsize */ sizeof(localdummyobject),
- /* tp_itemsize */ 0,
- /* tp_dealloc */ (destructor)localdummy_dealloc,
- /* tp_vectorcall_offset */ 0,
- /* tp_getattr */ 0,
- /* tp_setattr */ 0,
- /* tp_as_async */ 0,
- /* tp_repr */ 0,
- /* tp_as_number */ 0,
- /* tp_as_sequence */ 0,
- /* tp_as_mapping */ 0,
- /* tp_hash */ 0,
- /* tp_call */ 0,
- /* tp_str */ 0,
- /* tp_getattro */ 0,
- /* tp_setattro */ 0,
- /* tp_as_buffer */ 0,
- /* tp_flags */ Py_TPFLAGS_DEFAULT,
- /* tp_doc */ "Thread-local dummy",
- /* tp_traverse */ 0,
- /* tp_clear */ 0,
- /* tp_richcompare */ 0,
- /* tp_weaklistoffset */ offsetof(localdummyobject, weakreflist)
+static PyMemberDef local_dummy_type_members[] = {
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(localdummyobject, weakreflist), READONLY},
+ {NULL},
+};
+
+static PyType_Slot local_dummy_type_slots[] = {
+ {Py_tp_dealloc, (destructor)localdummy_dealloc},
+ {Py_tp_doc, "Thread-local dummy"},
+ {Py_tp_members, local_dummy_type_members},
+ {0, 0}
+};
+
+static PyType_Spec local_dummy_type_spec = {
+ .name = "_thread._localdummy",
+ .basicsize = sizeof(localdummyobject),
+ .flags = Py_TPFLAGS_DEFAULT,
+ .slots = local_dummy_type_slots,
};
@@ -682,19 +696,19 @@ typedef struct {
} localobject;
/* Forward declaration */
-static PyObject *_ldict(localobject *self);
+static PyObject *_ldict(localobject *self, thread_module_state *state);
static PyObject *_localdummy_destroyed(PyObject *meth_self, PyObject *dummyweakref);
/* Create and register the dummy for the current thread.
Returns a borrowed reference of the corresponding local dict */
static PyObject *
-_local_create_dummy(localobject *self)
+_local_create_dummy(localobject *self, thread_module_state *state)
{
- PyObject *tdict, *ldict = NULL, *wr = NULL;
+ PyObject *ldict = NULL, *wr = NULL;
localdummyobject *dummy = NULL;
- int r;
+ PyTypeObject *type = state->local_dummy_type;
- tdict = PyThreadState_GetDict();
+ PyObject *tdict = PyThreadState_GetDict();
if (tdict == NULL) {
PyErr_SetString(PyExc_SystemError,
"Couldn't get thread-state dictionary");
@@ -702,25 +716,30 @@ _local_create_dummy(localobject *self)
}
ldict = PyDict_New();
- if (ldict == NULL)
+ if (ldict == NULL) {
goto err;
- dummy = (localdummyobject *) localdummytype.tp_alloc(&localdummytype, 0);
- if (dummy == NULL)
+ }
+ dummy = (localdummyobject *) type->tp_alloc(type, 0);
+ if (dummy == NULL) {
goto err;
+ }
dummy->localdict = ldict;
wr = PyWeakref_NewRef((PyObject *) dummy, self->wr_callback);
- if (wr == NULL)
+ if (wr == NULL) {
goto err;
+ }
/* As a side-effect, this will cache the weakref's hash before the
dummy gets deleted */
- r = PyDict_SetItem(self->dummies, wr, ldict);
- if (r < 0)
+ int r = PyDict_SetItem(self->dummies, wr, ldict);
+ if (r < 0) {
goto err;
+ }
Py_CLEAR(wr);
r = PyDict_SetItem(tdict, self->key, (PyObject *) dummy);
- if (r < 0)
+ if (r < 0) {
goto err;
+ }
Py_CLEAR(dummy);
Py_DECREF(ldict);
@@ -736,8 +755,6 @@ err:
static PyObject *
local_new(PyTypeObject *type, PyObject *args, PyObject *kw)
{
- localobject *self;
- PyObject *wr;
static PyMethodDef wr_callback_def = {
"_localdummy_destroyed", (PyCFunction) _localdummy_destroyed, METH_O
};
@@ -749,42 +766,48 @@ local_new(PyTypeObject *type, PyObject *args, PyObject *kw)
if (rc == 0 && kw != NULL)
rc = PyObject_IsTrue(kw);
if (rc != 0) {
- if (rc > 0)
+ if (rc > 0) {
PyErr_SetString(PyExc_TypeError,
"Initialization arguments are not supported");
+ }
return NULL;
}
}
- self = (localobject *)type->tp_alloc(type, 0);
- if (self == NULL)
+ PyObject *module = _PyType_GetModuleByDef(type, &thread_module);
+ thread_module_state *state = get_thread_state(module);
+
+ localobject *self = (localobject *)type->tp_alloc(type, 0);
+ if (self == NULL) {
return NULL;
+ }
- Py_XINCREF(args);
- self->args = args;
- Py_XINCREF(kw);
- self->kw = kw;
+ self->args = Py_XNewRef(args);
+ self->kw = Py_XNewRef(kw);
self->key = PyUnicode_FromFormat("thread.local.%p", self);
- if (self->key == NULL)
+ if (self->key == NULL) {
goto err;
+ }
self->dummies = PyDict_New();
- if (self->dummies == NULL)
+ if (self->dummies == NULL) {
goto err;
+ }
/* We use a weak reference to self in the callback closure
in order to avoid spurious reference cycles */
- wr = PyWeakref_NewRef((PyObject *) self, NULL);
- if (wr == NULL)
+ PyObject *wr = PyWeakref_NewRef((PyObject *) self, NULL);
+ if (wr == NULL) {
goto err;
+ }
self->wr_callback = PyCFunction_NewEx(&wr_callback_def, wr, NULL);
Py_DECREF(wr);
- if (self->wr_callback == NULL)
+ if (self->wr_callback == NULL) {
goto err;
-
- if (_local_create_dummy(self) == NULL)
+ }
+ if (_local_create_dummy(self, state) == NULL) {
goto err;
-
+ }
return (PyObject *)self;
err:
@@ -795,6 +818,7 @@ local_new(PyTypeObject *type, PyObject *args, PyObject *kw)
static int
local_traverse(localobject *self, visitproc visit, void *arg)
{
+ Py_VISIT(Py_TYPE(self));
Py_VISIT(self->args);
Py_VISIT(self->kw);
Py_VISIT(self->dummies);
@@ -834,35 +858,38 @@ local_dealloc(localobject *self)
{
/* Weakrefs must be invalidated right now, otherwise they can be used
from code called below, which is very dangerous since Py_REFCNT(self) == 0 */
- if (self->weakreflist != NULL)
+ if (self->weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject *) self);
+ }
PyObject_GC_UnTrack(self);
local_clear(self);
Py_XDECREF(self->key);
- Py_TYPE(self)->tp_free((PyObject*)self);
+
+ PyTypeObject *tp = Py_TYPE(self);
+ tp->tp_free((PyObject*)self);
+ Py_DECREF(tp);
}
/* Returns a borrowed reference to the local dict, creating it if necessary */
static PyObject *
-_ldict(localobject *self)
+_ldict(localobject *self, thread_module_state *state)
{
- PyObject *tdict, *ldict, *dummy;
-
- tdict = PyThreadState_GetDict();
+ PyObject *tdict = PyThreadState_GetDict();
if (tdict == NULL) {
PyErr_SetString(PyExc_SystemError,
"Couldn't get thread-state dictionary");
return NULL;
}
- dummy = PyDict_GetItemWithError(tdict, self->key);
+ PyObject *ldict;
+ PyObject *dummy = PyDict_GetItemWithError(tdict, self->key);
if (dummy == NULL) {
if (PyErr_Occurred()) {
return NULL;
}
- ldict = _local_create_dummy(self);
+ ldict = _local_create_dummy(self, state);
if (ldict == NULL)
return NULL;
@@ -877,7 +904,7 @@ _ldict(localobject *self)
}
}
else {
- assert(Py_IS_TYPE(dummy, &localdummytype));
+ assert(Py_IS_TYPE(dummy, state->local_dummy_type));
ldict = ((localdummyobject *) dummy)->localdict;
}
@@ -887,104 +914,97 @@ _ldict(localobject *self)
static int
local_setattro(localobject *self, PyObject *name, PyObject *v)
{
- PyObject *ldict;
- int r;
+ PyObject *module = _PyType_GetModuleByDef(Py_TYPE(self), &thread_module);
+ thread_module_state *state = get_thread_state(module);
- ldict = _ldict(self);
- if (ldict == NULL)
+ PyObject *ldict = _ldict(self, state);
+ if (ldict == NULL) {
+ return -1;
+ }
+
+ PyObject *str_dict = _PyUnicode_FromId(&PyId___dict__); // borrowed ref
+ if (str_dict == NULL) {
return -1;
+ }
- r = PyObject_RichCompareBool(name, str_dict, Py_EQ);
+ int r = PyObject_RichCompareBool(name, str_dict, Py_EQ);
+ if (r == -1) {
+ return -1;
+ }
if (r == 1) {
PyErr_Format(PyExc_AttributeError,
"'%.50s' object attribute '%U' is read-only",
Py_TYPE(self)->tp_name, name);
return -1;
}
- if (r == -1)
- return -1;
return _PyObject_GenericSetAttrWithDict((PyObject *)self, name, v, ldict);
}
static PyObject *local_getattro(localobject *, PyObject *);
-static PyTypeObject localtype = {
- PyVarObject_HEAD_INIT(NULL, 0)
- /* tp_name */ "_thread._local",
- /* tp_basicsize */ sizeof(localobject),
- /* tp_itemsize */ 0,
- /* tp_dealloc */ (destructor)local_dealloc,
- /* tp_vectorcall_offset */ 0,
- /* tp_getattr */ 0,
- /* tp_setattr */ 0,
- /* tp_as_async */ 0,
- /* tp_repr */ 0,
- /* tp_as_number */ 0,
- /* tp_as_sequence */ 0,
- /* tp_as_mapping */ 0,
- /* tp_hash */ 0,
- /* tp_call */ 0,
- /* tp_str */ 0,
- /* tp_getattro */ (getattrofunc)local_getattro,
- /* tp_setattro */ (setattrofunc)local_setattro,
- /* tp_as_buffer */ 0,
- /* tp_flags */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
- | Py_TPFLAGS_HAVE_GC,
- /* tp_doc */ "Thread-local data",
- /* tp_traverse */ (traverseproc)local_traverse,
- /* tp_clear */ (inquiry)local_clear,
- /* tp_richcompare */ 0,
- /* tp_weaklistoffset */ offsetof(localobject, weakreflist),
- /* tp_iter */ 0,
- /* tp_iternext */ 0,
- /* tp_methods */ 0,
- /* tp_members */ 0,
- /* tp_getset */ 0,
- /* tp_base */ 0,
- /* tp_dict */ 0, /* internal use */
- /* tp_descr_get */ 0,
- /* tp_descr_set */ 0,
- /* tp_dictoffset */ 0,
- /* tp_init */ 0,
- /* tp_alloc */ 0,
- /* tp_new */ local_new,
- /* tp_free */ 0, /* Low-level free-mem routine */
- /* tp_is_gc */ 0, /* For PyObject_IS_GC */
+static PyMemberDef local_type_members[] = {
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(localobject, weakreflist), READONLY},
+ {NULL},
+};
+
+static PyType_Slot local_type_slots[] = {
+ {Py_tp_dealloc, (destructor)local_dealloc},
+ {Py_tp_getattro, (getattrofunc)local_getattro},
+ {Py_tp_setattro, (setattrofunc)local_setattro},
+ {Py_tp_doc, "Thread-local data"},
+ {Py_tp_traverse, (traverseproc)local_traverse},
+ {Py_tp_clear, (inquiry)local_clear},
+ {Py_tp_new, local_new},
+ {Py_tp_members, local_type_members},
+ {0, 0}
+};
+
+static PyType_Spec local_type_spec = {
+ .name = "_thread._local",
+ .basicsize = sizeof(localobject),
+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
+ .slots = local_type_slots,
};
static PyObject *
local_getattro(localobject *self, PyObject *name)
{
- PyObject *ldict, *value;
- int r;
+ PyObject *module = _PyType_GetModuleByDef(Py_TYPE(self), &thread_module);
+ thread_module_state *state = get_thread_state(module);
- ldict = _ldict(self);
+ PyObject *ldict = _ldict(self, state);
if (ldict == NULL)
return NULL;
- r = PyObject_RichCompareBool(name, str_dict, Py_EQ);
+ PyObject *str_dict = _PyUnicode_FromId(&PyId___dict__); // borrowed ref
+ if (str_dict == NULL) {
+ return NULL;
+ }
+
+ int r = PyObject_RichCompareBool(name, str_dict, Py_EQ);
if (r == 1) {
- Py_INCREF(ldict);
- return ldict;
+ return Py_NewRef(ldict);
}
- if (r == -1)
+ if (r == -1) {
return NULL;
+ }
- if (!Py_IS_TYPE(self, &localtype))
+ if (!Py_IS_TYPE(self, state->local_type)) {
/* use generic lookup for subtypes */
- return _PyObject_GenericGetAttrWithDict(
- (PyObject *)self, name, ldict, 0);
+ return _PyObject_GenericGetAttrWithDict((PyObject *)self, name,
+ ldict, 0);
+ }
/* Optimization: just look in dict ourselves */
- value = PyDict_GetItemWithError(ldict, name);
+ PyObject *value = PyDict_GetItemWithError(ldict, name);
if (value != NULL) {
- Py_INCREF(value);
- return value;
+ return Py_NewRef(value);
}
- else if (PyErr_Occurred()) {
+ if (PyErr_Occurred()) {
return NULL;
}
+
/* Fall back on generic to get __class__ and __dict__ */
return _PyObject_GenericGetAttrWithDict(
(PyObject *)self, name, ldict, 0);
@@ -994,17 +1014,15 @@ local_getattro(localobject *self, PyObject *name)
static PyObject *
_localdummy_destroyed(PyObject *localweakref, PyObject *dummyweakref)
{
- PyObject *obj;
- localobject *self;
assert(PyWeakref_CheckRef(localweakref));
- obj = PyWeakref_GET_OBJECT(localweakref);
- if (obj == Py_None)
+ PyObject *obj = PyWeakref_GET_OBJECT(localweakref);
+ if (obj == Py_None) {
Py_RETURN_NONE;
- Py_INCREF(obj);
- assert(PyObject_TypeCheck(obj, &localtype));
+ }
+
/* If the thread-local object is still alive and not being cleared,
remove the corresponding local dict */
- self = (localobject *) obj;
+ localobject *self = (localobject *)Py_NewRef(obj);
if (self->dummies != NULL) {
PyObject *ldict;
ldict = PyDict_GetItemWithError(self->dummies, dummyweakref);
@@ -1024,24 +1042,35 @@ struct bootstate {
PyInterpreterState *interp;
PyObject *func;
PyObject *args;
- PyObject *keyw;
+ PyObject *kwargs;
PyThreadState *tstate;
_PyRuntimeState *runtime;
};
+
static void
-t_bootstrap(void *boot_raw)
+thread_bootstate_free(struct bootstate *boot)
+{
+ Py_DECREF(boot->func);
+ Py_DECREF(boot->args);
+ Py_XDECREF(boot->kwargs);
+ PyMem_Free(boot);
+}
+
+
+static void
+thread_run(void *boot_raw)
{
struct bootstate *boot = (struct bootstate *) boot_raw;
PyThreadState *tstate;
- PyObject *res;
tstate = boot->tstate;
tstate->thread_id = PyThread_get_thread_ident();
_PyThreadState_Init(tstate);
PyEval_AcquireThread(tstate);
tstate->interp->num_threads++;
- res = PyObject_Call(boot->func, boot->args, boot->keyw);
+
+ PyObject *res = PyObject_Call(boot->func, boot->args, boot->kwargs);
if (res == NULL) {
if (PyErr_ExceptionMatches(PyExc_SystemExit))
/* SystemExit is ignored silently */
@@ -1053,13 +1082,12 @@ t_bootstrap(void *boot_raw)
else {
Py_DECREF(res);
}
- Py_DECREF(boot->func);
- Py_DECREF(boot->args);
- Py_XDECREF(boot->keyw);
- PyMem_DEL(boot_raw);
+
+ thread_bootstate_free(boot);
tstate->interp->num_threads--;
PyThreadState_Clear(tstate);
_PyThreadState_DeleteCurrent(tstate);
+
PyThread_exit_thread();
}
@@ -1067,12 +1095,10 @@ static PyObject *
thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
{
_PyRuntimeState *runtime = &_PyRuntime;
- PyObject *func, *args, *keyw = NULL;
- struct bootstate *boot;
- unsigned long ident;
+ PyObject *func, *args, *kwargs = NULL;
if (!PyArg_UnpackTuple(fargs, "start_new_thread", 2, 3,
- &func, &args, &keyw))
+ &func, &args, &kwargs))
return NULL;
if (!PyCallable_Check(func)) {
PyErr_SetString(PyExc_TypeError,
@@ -1084,7 +1110,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
"2nd arg must be a tuple");
return NULL;
}
- if (keyw != NULL && !PyDict_Check(keyw)) {
+ if (kwargs != NULL && !PyDict_Check(kwargs)) {
PyErr_SetString(PyExc_TypeError,
"optional 3rd arg must be a dictionary");
return NULL;
@@ -1097,31 +1123,26 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
return NULL;
}
- boot = PyMem_NEW(struct bootstate, 1);
- if (boot == NULL)
+ struct bootstate *boot = PyMem_NEW(struct bootstate, 1);
+ if (boot == NULL) {
return PyErr_NoMemory();
+ }
boot->interp = _PyInterpreterState_GET();
- boot->func = func;
- boot->args = args;
- boot->keyw = keyw;
boot->tstate = _PyThreadState_Prealloc(boot->interp);
- boot->runtime = runtime;
if (boot->tstate == NULL) {
- PyMem_DEL(boot);
+ PyMem_Free(boot);
return PyErr_NoMemory();
}
- Py_INCREF(func);
- Py_INCREF(args);
- Py_XINCREF(keyw);
+ boot->runtime = runtime;
+ boot->func = Py_NewRef(func);
+ boot->args = Py_NewRef(args);
+ boot->kwargs = Py_XNewRef(kwargs);
- ident = PyThread_start_new_thread(t_bootstrap, (void*) boot);
+ unsigned long ident = PyThread_start_new_thread(thread_run, (void*) boot);
if (ident == PYTHREAD_INVALID_THREAD_ID) {
PyErr_SetString(ThreadError, "can't start new thread");
- Py_DECREF(func);
- Py_DECREF(args);
- Py_XDECREF(keyw);
PyThreadState_Clear(boot->tstate);
- PyMem_DEL(boot);
+ thread_bootstate_free(boot);
return NULL;
}
return PyLong_FromUnsignedLong(ident);
@@ -1166,12 +1187,12 @@ Raise a KeyboardInterrupt in the main thread.\n\
A subthread can use this function to interrupt the main thread."
);
-static lockobject *newlockobject(void);
+static lockobject *newlockobject(PyObject *module);
static PyObject *
-thread_PyThread_allocate_lock(PyObject *self, PyObject *Py_UNUSED(ignored))
+thread_PyThread_allocate_lock(PyObject *module, PyObject *Py_UNUSED(ignored))
{
- return (PyObject *) newlockobject();
+ return (PyObject *) newlockobject(module);
}
PyDoc_STRVAR(allocate_doc,
@@ -1248,7 +1269,6 @@ release_sentinel(void *wr_raw)
PyObject *obj = PyWeakref_GET_OBJECT(wr);
lockobject *lock;
if (obj != Py_None) {
- assert(Py_IS_TYPE(obj, &Locktype));
lock = (lockobject *) obj;
if (lock->locked) {
PyThread_release_lock(lock->lock_lock);
@@ -1261,7 +1281,7 @@ release_sentinel(void *wr_raw)
}
static PyObject *
-thread__set_sentinel(PyObject *self, PyObject *Py_UNUSED(ignored))
+thread__set_sentinel(PyObject *module, PyObject *Py_UNUSED(ignored))
{
PyObject *wr;
PyThreadState *tstate = PyThreadState_Get();
@@ -1276,7 +1296,7 @@ thread__set_sentinel(PyObject *self, PyObject *Py_UNUSED(ignored))
tstate->on_delete_data = NULL;
Py_DECREF(wr);
}
- lock = newlockobject();
+ lock = newlockobject(module);
if (lock == NULL)
return NULL;
/* The lock is owned by whoever called _set_sentinel(), but the weakref
@@ -1429,7 +1449,7 @@ static PyStructSequence_Field ExceptHookArgs_fields[] = {
};
static PyStructSequence_Desc ExceptHookArgs_desc = {
- .name = "_thread.ExceptHookArgs",
+ .name = "_thread._ExceptHookArgs",
.doc = ExceptHookArgs__doc__,
.fields = ExceptHookArgs_fields,
.n_in_sequence = 4
@@ -1530,106 +1550,132 @@ static PyMethodDef thread_methods[] = {
/* Initialization function */
-PyDoc_STRVAR(thread_doc,
-"This module provides primitive operations to write multi-threaded programs.\n\
-The 'threading' module provides a more convenient interface.");
+static int
+thread_module_exec(PyObject *module)
+{
+ thread_module_state *state = get_thread_state(module);
+ PyObject *d = PyModule_GetDict(module);
-PyDoc_STRVAR(lock_doc,
-"A lock object is a synchronization primitive. To create a lock,\n\
-call threading.Lock(). Methods are:\n\
-\n\
-acquire() -- lock the lock, possibly blocking until it can be obtained\n\
-release() -- unlock of the lock\n\
-locked() -- test whether the lock is currently locked\n\
-\n\
-A lock is not owned by the thread that locked it; another thread may\n\
-unlock it. A thread attempting to lock a lock that it has already locked\n\
-will block until another thread unlocks it. Deadlocks may ensue.");
+ // Initialize the C thread library
+ PyThread_init_thread();
-static struct PyModuleDef threadmodule = {
- PyModuleDef_HEAD_INIT,
- "_thread",
- thread_doc,
- -1,
- thread_methods,
- NULL,
- NULL,
- NULL,
- NULL
-};
+ // Lock
+ state->lock_type = (PyTypeObject *)PyType_FromSpec(&lock_type_spec);
+ if (state->lock_type == NULL) {
+ return -1;
+ }
+ if (PyDict_SetItemString(d, "LockType", (PyObject *)state->lock_type) < 0) {
+ return -1;
+ }
+ // RLock
+ PyTypeObject *rlock_type = (PyTypeObject *)PyType_FromSpec(&rlock_type_spec);
+ if (rlock_type == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(module, rlock_type) < 0) {
+ Py_DECREF(rlock_type);
+ return -1;
+ }
+ Py_DECREF(rlock_type);
-PyMODINIT_FUNC
-PyInit__thread(void)
-{
- PyObject *m, *d, *v;
- double time_max;
- double timeout_max;
- PyInterpreterState *interp = _PyInterpreterState_GET();
+ // Local dummy
+ state->local_dummy_type = (PyTypeObject *)PyType_FromSpec(&local_dummy_type_spec);
+ if (state->local_dummy_type == NULL) {
+ return -1;
+ }
+
+ // Local
+ state->local_type = (PyTypeObject *)PyType_FromModuleAndSpec(module, &local_type_spec, NULL);
+ if (state->local_type == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(module, state->local_type) < 0) {
+ return -1;
+ }
- /* Initialize types: */
- if (PyType_Ready(&localdummytype) < 0)
- return NULL;
- if (PyType_Ready(&localtype) < 0)
- return NULL;
- if (PyType_Ready(&Locktype) < 0)
- return NULL;
- if (PyType_Ready(&RLocktype) < 0)
- return NULL;
if (ExceptHookArgsType.tp_name == NULL) {
if (PyStructSequence_InitType2(&ExceptHookArgsType,
&ExceptHookArgs_desc) < 0) {
- return NULL;
+ return -1;
}
}
- /* Create the module and add the functions */
- m = PyModule_Create(&threadmodule);
- if (m == NULL)
- return NULL;
+ // Add module attributes
+ if (PyDict_SetItemString(d, "error", ThreadError) < 0) {
+ return -1;
+ }
+ if (PyModule_AddType(module, &ExceptHookArgsType) < 0) {
+ return -1;
+ }
- timeout_max = (_PyTime_t)PY_TIMEOUT_MAX * 1e-6;
- time_max = _PyTime_AsSecondsDouble(_PyTime_MAX);
+ // TIMEOUT_MAX
+ double timeout_max = (_PyTime_t)PY_TIMEOUT_MAX * 1e-6;
+ double time_max = _PyTime_AsSecondsDouble(_PyTime_MAX);
timeout_max = Py_MIN(timeout_max, time_max);
- /* Round towards minus infinity */
+ // Round towards minus infinity
timeout_max = floor(timeout_max);
- v = PyFloat_FromDouble(timeout_max);
- if (!v)
- return NULL;
- if (PyModule_AddObject(m, "TIMEOUT_MAX", v) < 0)
- return NULL;
+ if (PyModule_AddObject(module, "TIMEOUT_MAX",
+ PyFloat_FromDouble(timeout_max)) < 0) {
+ return -1;
+ }
- /* Add a symbolic constant */
- d = PyModule_GetDict(m);
- ThreadError = PyExc_RuntimeError;
- Py_INCREF(ThreadError);
+ return 0;
+}
- PyDict_SetItemString(d, "error", ThreadError);
- Locktype.tp_doc = lock_doc;
- Py_INCREF(&Locktype);
- PyDict_SetItemString(d, "LockType", (PyObject *)&Locktype);
- Py_INCREF(&RLocktype);
- if (PyModule_AddObject(m, "RLock", (PyObject *)&RLocktype) < 0)
- return NULL;
+static int
+thread_module_traverse(PyObject *module, visitproc visit, void *arg)
+{
+ thread_module_state *state = get_thread_state(module);
+ Py_VISIT(state->lock_type);
+ Py_VISIT(state->local_type);
+ Py_VISIT(state->local_dummy_type);
+ return 0;
+}
- Py_INCREF(&localtype);
- if (PyModule_AddObject(m, "_local", (PyObject *)&localtype) < 0)
- return NULL;
+static int
+thread_module_clear(PyObject *module)
+{
+ thread_module_state *state = get_thread_state(module);
+ Py_CLEAR(state->lock_type);
+ Py_CLEAR(state->local_type);
+ Py_CLEAR(state->local_dummy_type);
+ return 0;
+}
- Py_INCREF(&ExceptHookArgsType);
- if (PyModule_AddObject(m, "_ExceptHookArgs",
- (PyObject *)&ExceptHookArgsType) < 0)
- return NULL;
+static void
+thread_module_free(void *module)
+{
+ thread_module_clear((PyObject *)module);
+}
- interp->num_threads = 0;
- str_dict = PyUnicode_InternFromString("__dict__");
- if (str_dict == NULL)
- return NULL;
- /* Initialize the C thread library */
- PyThread_init_thread();
- return m;
+PyDoc_STRVAR(thread_doc,
+"This module provides primitive operations to write multi-threaded programs.\n\
+The 'threading' module provides a more convenient interface.");
+
+static PyModuleDef_Slot thread_module_slots[] = {
+ {Py_mod_exec, thread_module_exec},
+ {0, NULL}
+};
+
+static struct PyModuleDef thread_module = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "_thread",
+ .m_doc = thread_doc,
+ .m_size = sizeof(thread_module_state),
+ .m_methods = thread_methods,
+ .m_traverse = thread_module_traverse,
+ .m_clear = thread_module_clear,
+ .m_free = thread_module_free,
+ .m_slots = thread_module_slots,
+};
+
+PyMODINIT_FUNC
+PyInit__thread(void)
+{
+ return PyModuleDef_Init(&thread_module);
}
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 793c5e7154..46d6a6e095 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -395,7 +395,8 @@ unicodeFromTclStringAndSize(const char *s, Py_ssize_t size)
char *buf = NULL;
PyErr_Clear();
- /* Tcl encodes null character as \xc0\x80 */
+ /* Tcl encodes null character as \xc0\x80.
+ https://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8 */
if (memchr(s, '\xc0', size)) {
char *q;
const char *e = s + size;
@@ -419,6 +420,57 @@ unicodeFromTclStringAndSize(const char *s, Py_ssize_t size)
if (buf != NULL) {
PyMem_Free(buf);
}
+ if (r == NULL || PyUnicode_KIND(r) == PyUnicode_1BYTE_KIND) {
+ return r;
+ }
+
+ /* In CESU-8 non-BMP characters are represented as a surrogate pair,
+ like in UTF-16, and then each surrogate code point is encoded in UTF-8.
+ https://en.wikipedia.org/wiki/CESU-8 */
+ Py_ssize_t len = PyUnicode_GET_LENGTH(r);
+ Py_ssize_t i, j;
+ /* All encoded surrogate characters start with \xED. */
+ i = PyUnicode_FindChar(r, 0xdcED, 0, len, 1);
+ if (i == -2) {
+ Py_DECREF(r);
+ return NULL;
+ }
+ if (i == -1) {
+ return r;
+ }
+ Py_UCS4 *u = PyUnicode_AsUCS4Copy(r);
+ Py_DECREF(r);
+ if (u == NULL) {
+ return NULL;
+ }
+ Py_UCS4 ch;
+ for (j = i; i < len; i++, u[j++] = ch) {
+ Py_UCS4 ch1, ch2, ch3, high, low;
+ /* Low surrogates U+D800 - U+DBFF are encoded as
+ \xED\xA0\x80 - \xED\xAF\xBF. */
+ ch1 = ch = u[i];
+ if (ch1 != 0xdcED) continue;
+ ch2 = u[i + 1];
+ if (!(0xdcA0 <= ch2 && ch2 <= 0xdcAF)) continue;
+ ch3 = u[i + 2];
+ if (!(0xdc80 <= ch3 && ch3 <= 0xdcBF)) continue;
+ high = 0xD000 | ((ch2 & 0x3F) << 6) | (ch3 & 0x3F);
+ assert(Py_UNICODE_IS_HIGH_SURROGATE(high));
+ /* High surrogates U+DC00 - U+DFFF are encoded as
+ \xED\xB0\x80 - \xED\xBF\xBF. */
+ ch1 = u[i + 3];
+ if (ch1 != 0xdcED) continue;
+ ch2 = u[i + 4];
+ if (!(0xdcB0 <= ch2 && ch2 <= 0xdcBF)) continue;
+ ch3 = u[i + 5];
+ if (!(0xdc80 <= ch3 && ch3 <= 0xdcBF)) continue;
+ low = 0xD000 | ((ch2 & 0x3F) << 6) | (ch3 & 0x3F);
+ assert(Py_UNICODE_IS_HIGH_SURROGATE(high));
+ ch = Py_UNICODE_JOIN_SURROGATES(high, low);
+ i += 5;
+ }
+ r = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, u, j);
+ PyMem_Free(u);
return r;
}
@@ -852,7 +904,7 @@ PyTclObject_dealloc(PyTclObject *self)
PyObject *tp = (PyObject *) Py_TYPE(self);
Tcl_DecrRefCount(self->value);
Py_XDECREF(self->string);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(tp);
}
@@ -2420,7 +2472,7 @@ PythonCmdDelete(ClientData clientData)
ENTER_PYTHON
Py_XDECREF(data->self);
Py_XDECREF(data->func);
- PyMem_DEL(data);
+ PyMem_Free(data);
LEAVE_PYTHON
}
@@ -2493,7 +2545,7 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
CommandEvent *ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent));
if (ev == NULL) {
PyErr_NoMemory();
- PyMem_DEL(data);
+ PyMem_Free(data);
return NULL;
}
ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
@@ -2516,7 +2568,7 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
}
if (err) {
PyErr_SetString(Tkinter_TclError, "can't create Tcl command");
- PyMem_DEL(data);
+ PyMem_Free(data);
return NULL;
}
@@ -2614,7 +2666,7 @@ DeleteFHCD(int id)
*pp = p->next;
Py_XDECREF(p->func);
Py_XDECREF(p->file);
- PyMem_DEL(p);
+ PyMem_Free(p);
}
else
pp = &p->next;
@@ -2771,7 +2823,7 @@ Tktt_Dealloc(PyObject *self)
Py_XDECREF(func);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(tp);
}
@@ -3044,7 +3096,7 @@ Tkapp_Dealloc(PyObject *self)
ENTER_TCL
Tcl_DeleteInterp(Tkapp_Interp(self));
LEAVE_TCL
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(tp);
DisableEventHook();
}
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c
index 7888cf86de..bb32b14966 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -172,7 +172,7 @@ static void
update_strong_cache(const PyTypeObject *const type, PyObject *key,
PyObject *zone);
static PyObject *
-zone_from_strong_cache(const PyTypeObject *const type, PyObject *key);
+zone_from_strong_cache(const PyTypeObject *const type, PyObject *const key);
static PyObject *
zoneinfo_new_instance(PyTypeObject *type, PyObject *key)
@@ -1214,15 +1214,9 @@ calendarrule_new(uint8_t month, uint8_t week, uint8_t day, int8_t hour,
return -1;
}
- // day is an unsigned integer, so day < 0 should always return false, but
- // if day's type changes to a signed integer *without* changing this value,
- // it may create a bug. Considering that the compiler should be able to
- // optimize out the first comparison if day is an unsigned integer anyway,
- // we will leave this comparison in place and disable the compiler warning.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wtype-limits"
- if (day < 0 || day > 6) {
-#pragma GCC diagnostic pop
+ // If the 'day' parameter type is changed to a signed type,
+ // "day < 0" check must be added.
+ if (/* day < 0 || */ day > 6) {
PyErr_Format(PyExc_ValueError, "Day must be in [0, 6]");
return -1;
}
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 2ba2ff43aa..6583e66611 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -133,7 +133,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
}
if (newsize == 0) {
- PyMem_FREE(self->ob_item);
+ PyMem_Free(self->ob_item);
self->ob_item = NULL;
Py_SET_SIZE(self, 0);
self->allocated = 0;
@@ -652,7 +652,7 @@ array_dealloc(arrayobject *op)
if (op->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) op);
if (op->ob_item != NULL)
- PyMem_DEL(op->ob_item);
+ PyMem_Free(op->ob_item);
Py_TYPE(op)->tp_free((PyObject *)op);
}
diff --git a/Modules/atexitmodule.c b/Modules/atexitmodule.c
index fd47ddd773..49e2a75137 100644
--- a/Modules/atexitmodule.c
+++ b/Modules/atexitmodule.c
@@ -7,117 +7,119 @@
*/
#include "Python.h"
-
-/* Forward declaration (for atexit_cleanup) */
-static PyObject *atexit_clear(PyObject*, PyObject*);
-/* Forward declaration of module object */
-static struct PyModuleDef atexitmodule;
+#include "pycore_initconfig.h" // _PyStatus_NO_MEMORY
+#include "pycore_interp.h" // PyInterpreterState.atexit
+#include "pycore_pystate.h" // _PyInterpreterState_GET
/* ===================================================================== */
/* Callback machinery. */
-typedef struct {
- PyObject *func;
- PyObject *args;
- PyObject *kwargs;
-} atexit_callback;
-
-typedef struct {
- atexit_callback **atexit_callbacks;
- int ncallbacks;
- int callback_len;
-} atexitmodule_state;
-
-static inline atexitmodule_state*
-get_atexit_state(PyObject *module)
+static inline struct atexit_state*
+get_atexit_state(void)
{
- void *state = PyModule_GetState(module);
- assert(state != NULL);
- return (atexitmodule_state *)state;
+ PyInterpreterState *interp = _PyInterpreterState_GET();
+ return &interp->atexit;
}
static void
-atexit_delete_cb(atexitmodule_state *modstate, int i)
+atexit_delete_cb(struct atexit_state *state, int i)
{
- atexit_callback *cb;
+ atexit_callback *cb = state->callbacks[i];
+ state->callbacks[i] = NULL;
- cb = modstate->atexit_callbacks[i];
- modstate->atexit_callbacks[i] = NULL;
Py_DECREF(cb->func);
Py_DECREF(cb->args);
Py_XDECREF(cb->kwargs);
PyMem_Free(cb);
}
+
/* Clear all callbacks without calling them */
static void
-atexit_cleanup(atexitmodule_state *modstate)
+atexit_cleanup(struct atexit_state *state)
{
atexit_callback *cb;
- int i;
- for (i = 0; i < modstate->ncallbacks; i++) {
- cb = modstate->atexit_callbacks[i];
+ for (int i = 0; i < state->ncallbacks; i++) {
+ cb = state->callbacks[i];
if (cb == NULL)
continue;
- atexit_delete_cb(modstate, i);
+ atexit_delete_cb(state, i);
}
- modstate->ncallbacks = 0;
+ state->ncallbacks = 0;
}
-/* Installed into pylifecycle.c's atexit mechanism */
-static void
-atexit_callfuncs(PyObject *module)
+PyStatus
+_PyAtExit_Init(PyThreadState *tstate)
{
- PyObject *exc_type = NULL, *exc_value, *exc_tb, *r;
- atexit_callback *cb;
- atexitmodule_state *modstate;
- int i;
+ struct atexit_state *state = &tstate->interp->atexit;
+ // _PyAtExit_Init() must only be called once
+ assert(state->callbacks == NULL);
+
+ state->callback_len = 32;
+ state->ncallbacks = 0;
+ state->callbacks = PyMem_New(atexit_callback*, state->callback_len);
+ if (state->callbacks == NULL) {
+ return _PyStatus_NO_MEMORY();
+ }
+ return _PyStatus_OK();
+}
- if (module == NULL)
- return;
- modstate = get_atexit_state(module);
- if (modstate->ncallbacks == 0)
- return;
+void
+_PyAtExit_Fini(PyInterpreterState *interp)
+{
+ struct atexit_state *state = &interp->atexit;
+ atexit_cleanup(state);
+ PyMem_Free(state->callbacks);
+ state->callbacks = NULL;
+}
- for (i = modstate->ncallbacks - 1; i >= 0; i--)
- {
- cb = modstate->atexit_callbacks[i];
- if (cb == NULL)
+static void
+atexit_callfuncs(struct atexit_state *state)
+{
+ assert(!PyErr_Occurred());
+
+ if (state->ncallbacks == 0) {
+ return;
+ }
+
+ for (int i = state->ncallbacks - 1; i >= 0; i--) {
+ atexit_callback *cb = state->callbacks[i];
+ if (cb == NULL) {
continue;
+ }
- r = PyObject_Call(cb->func, cb->args, cb->kwargs);
- Py_XDECREF(r);
- if (r == NULL) {
- /* Maintain the last exception, but don't leak if there are
- multiple exceptions. */
- if (exc_type) {
- Py_DECREF(exc_type);
- Py_XDECREF(exc_value);
- Py_XDECREF(exc_tb);
- }
- PyErr_Fetch(&exc_type, &exc_value, &exc_tb);
- if (!PyErr_GivenExceptionMatches(exc_type, PyExc_SystemExit)) {
- PySys_WriteStderr("Error in atexit._run_exitfuncs:\n");
- PyErr_NormalizeException(&exc_type, &exc_value, &exc_tb);
- PyErr_Display(exc_type, exc_value, exc_tb);
- }
+ PyObject *res = PyObject_Call(cb->func, cb->args, cb->kwargs);
+ if (res == NULL) {
+ _PyErr_WriteUnraisableMsg("in atexit callback", cb->func);
+ }
+ else {
+ Py_DECREF(res);
}
}
- atexit_cleanup(modstate);
+ atexit_cleanup(state);
+
+ assert(!PyErr_Occurred());
+}
+
- if (exc_type)
- PyErr_Restore(exc_type, exc_value, exc_tb);
+void
+_PyAtExit_Call(PyThreadState *tstate)
+{
+ struct atexit_state *state = &tstate->interp->atexit;
+ atexit_callfuncs(state);
}
+
/* ===================================================================== */
/* Module methods. */
+
PyDoc_STRVAR(atexit_register__doc__,
"register(func, *args, **kwargs) -> func\n\
\n\
@@ -130,68 +132,63 @@ Register a function to be executed upon normal program termination\n\
func is returned to facilitate usage as a decorator.");
static PyObject *
-atexit_register(PyObject *self, PyObject *args, PyObject *kwargs)
+atexit_register(PyObject *module, PyObject *args, PyObject *kwargs)
{
- atexitmodule_state *modstate;
- atexit_callback *new_callback;
- PyObject *func = NULL;
-
- modstate = get_atexit_state(self);
-
- if (modstate->ncallbacks >= modstate->callback_len) {
- atexit_callback **r;
- modstate->callback_len += 16;
- r = (atexit_callback**)PyMem_Realloc(modstate->atexit_callbacks,
- sizeof(atexit_callback*) * modstate->callback_len);
- if (r == NULL)
- return PyErr_NoMemory();
- modstate->atexit_callbacks = r;
- }
-
if (PyTuple_GET_SIZE(args) == 0) {
PyErr_SetString(PyExc_TypeError,
"register() takes at least 1 argument (0 given)");
return NULL;
}
- func = PyTuple_GET_ITEM(args, 0);
+ PyObject *func = PyTuple_GET_ITEM(args, 0);
if (!PyCallable_Check(func)) {
PyErr_SetString(PyExc_TypeError,
"the first argument must be callable");
return NULL;
}
- new_callback = PyMem_Malloc(sizeof(atexit_callback));
- if (new_callback == NULL)
+ struct atexit_state *state = get_atexit_state();
+ if (state->ncallbacks >= state->callback_len) {
+ atexit_callback **r;
+ state->callback_len += 16;
+ size_t size = sizeof(atexit_callback*) * (size_t)state->callback_len;
+ r = (atexit_callback**)PyMem_Realloc(state->callbacks, size);
+ if (r == NULL) {
+ return PyErr_NoMemory();
+ }
+ state->callbacks = r;
+ }
+
+ atexit_callback *callback = PyMem_Malloc(sizeof(atexit_callback));
+ if (callback == NULL) {
return PyErr_NoMemory();
+ }
- new_callback->args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args));
- if (new_callback->args == NULL) {
- PyMem_Free(new_callback);
+ callback->args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args));
+ if (callback->args == NULL) {
+ PyMem_Free(callback);
return NULL;
}
- new_callback->func = func;
- new_callback->kwargs = kwargs;
- Py_INCREF(func);
- Py_XINCREF(kwargs);
+ callback->func = Py_NewRef(func);
+ callback->kwargs = Py_XNewRef(kwargs);
- modstate->atexit_callbacks[modstate->ncallbacks++] = new_callback;
+ state->callbacks[state->ncallbacks++] = callback;
- Py_INCREF(func);
- return func;
+ return Py_NewRef(func);
}
PyDoc_STRVAR(atexit_run_exitfuncs__doc__,
"_run_exitfuncs() -> None\n\
\n\
-Run all registered exit functions.");
+Run all registered exit functions.\n\
+\n\
+If a callaback raises an exception, it is logged with sys.unraisablehook.");
static PyObject *
-atexit_run_exitfuncs(PyObject *self, PyObject *unused)
+atexit_run_exitfuncs(PyObject *module, PyObject *unused)
{
- atexit_callfuncs(self);
- if (PyErr_Occurred())
- return NULL;
+ struct atexit_state *state = get_atexit_state();
+ atexit_callfuncs(state);
Py_RETURN_NONE;
}
@@ -201,9 +198,9 @@ PyDoc_STRVAR(atexit_clear__doc__,
Clear the list of previously registered exit functions.");
static PyObject *
-atexit_clear(PyObject *self, PyObject *unused)
+atexit_clear(PyObject *module, PyObject *unused)
{
- atexit_cleanup(get_atexit_state(self));
+ atexit_cleanup(get_atexit_state());
Py_RETURN_NONE;
}
@@ -213,50 +210,10 @@ PyDoc_STRVAR(atexit_ncallbacks__doc__,
Return the number of registered exit functions.");
static PyObject *
-atexit_ncallbacks(PyObject *self, PyObject *unused)
-{
- atexitmodule_state *modstate;
-
- modstate = get_atexit_state(self);
-
- return PyLong_FromSsize_t(modstate->ncallbacks);
-}
-
-static int
-atexit_m_traverse(PyObject *self, visitproc visit, void *arg)
-{
- int i;
- atexitmodule_state *modstate;
-
- modstate = (atexitmodule_state *)PyModule_GetState(self);
-
- for (i = 0; i < modstate->ncallbacks; i++) {
- atexit_callback *cb = modstate->atexit_callbacks[i];
- if (cb == NULL)
- continue;
- Py_VISIT(cb->func);
- Py_VISIT(cb->args);
- Py_VISIT(cb->kwargs);
- }
- return 0;
-}
-
-static int
-atexit_m_clear(PyObject *self)
+atexit_ncallbacks(PyObject *module, PyObject *unused)
{
- atexitmodule_state *modstate;
- modstate = (atexitmodule_state *)PyModule_GetState(self);
- atexit_cleanup(modstate);
- return 0;
-}
-
-static void
-atexit_free(PyObject *m)
-{
- atexitmodule_state *modstate;
- modstate = (atexitmodule_state *)PyModule_GetState(m);
- atexit_cleanup(modstate);
- PyMem_Free(modstate->atexit_callbacks);
+ struct atexit_state *state = get_atexit_state();
+ return PyLong_FromSsize_t(state->ncallbacks);
}
PyDoc_STRVAR(atexit_unregister__doc__,
@@ -268,29 +225,28 @@ atexit.register\n\
func - function to be unregistered");
static PyObject *
-atexit_unregister(PyObject *self, PyObject *func)
+atexit_unregister(PyObject *module, PyObject *func)
{
- atexitmodule_state *modstate;
- atexit_callback *cb;
- int i, eq;
-
- modstate = get_atexit_state(self);
-
- for (i = 0; i < modstate->ncallbacks; i++)
+ struct atexit_state *state = get_atexit_state();
+ for (int i = 0; i < state->ncallbacks; i++)
{
- cb = modstate->atexit_callbacks[i];
- if (cb == NULL)
+ atexit_callback *cb = state->callbacks[i];
+ if (cb == NULL) {
continue;
+ }
- eq = PyObject_RichCompareBool(cb->func, func, Py_EQ);
- if (eq < 0)
+ int eq = PyObject_RichCompareBool(cb->func, func, Py_EQ);
+ if (eq < 0) {
return NULL;
- if (eq)
- atexit_delete_cb(modstate, i);
+ }
+ if (eq) {
+ atexit_delete_cb(state, i);
+ }
}
Py_RETURN_NONE;
}
+
static PyMethodDef atexit_methods[] = {
{"register", (PyCFunction)(void(*)(void)) atexit_register, METH_VARARGS|METH_KEYWORDS,
atexit_register__doc__},
@@ -305,6 +261,7 @@ static PyMethodDef atexit_methods[] = {
{NULL, NULL} /* sentinel */
};
+
/* ===================================================================== */
/* Initialization function. */
@@ -315,37 +272,12 @@ upon normal program termination.\n\
Two public functions, register and unregister, are defined.\n\
");
-static int
-atexit_exec(PyObject *m) {
- atexitmodule_state *modstate;
-
- modstate = get_atexit_state(m);
- modstate->callback_len = 32;
- modstate->ncallbacks = 0;
- modstate->atexit_callbacks = PyMem_New(atexit_callback*,
- modstate->callback_len);
- if (modstate->atexit_callbacks == NULL)
- return -1;
-
- _Py_PyAtExit(atexit_callfuncs, m);
- return 0;
-}
-
-static PyModuleDef_Slot atexit_slots[] = {
- {Py_mod_exec, atexit_exec},
- {0, NULL}
-};
-
static struct PyModuleDef atexitmodule = {
PyModuleDef_HEAD_INIT,
- "atexit",
- atexit__doc__,
- sizeof(atexitmodule_state),
- atexit_methods,
- atexit_slots,
- atexit_m_traverse,
- atexit_m_clear,
- (freefunc)atexit_free
+ .m_name = "atexit",
+ .m_doc = atexit__doc__,
+ .m_size = 0,
+ .m_methods = atexit_methods,
};
PyMODINIT_FUNC
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index 86402768b6..9208b86b0c 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -691,7 +691,7 @@ static struct PyMethodDef multibytecodec_methods[] = {
static void
multibytecodec_dealloc(MultibyteCodecObject *self)
{
- PyObject_Del(self);
+ PyObject_Free(self);
}
static PyTypeObject MultibyteCodec_Type = {
@@ -1191,13 +1191,13 @@ _multibytecodec_MultibyteIncrementalDecoder_decode_impl(MultibyteIncrementalDeco
goto errorexit;
if (wdata != data)
- PyMem_Del(wdata);
+ PyMem_Free(wdata);
Py_XDECREF(buf.excobj);
return res;
errorexit:
if (wdata != NULL && wdata != data)
- PyMem_Del(wdata);
+ PyMem_Free(wdata);
Py_XDECREF(buf.excobj);
_PyUnicodeWriter_Dealloc(&buf.writer);
return NULL;
diff --git a/Modules/clinic/_queuemodule.c.h b/Modules/clinic/_queuemodule.c.h
index c25eacf08b..8741f7d9af 100644
--- a/Modules/clinic/_queuemodule.c.h
+++ b/Modules/clinic/_queuemodule.c.h
@@ -16,11 +16,11 @@ simplequeue_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
- if ((type == &PySimpleQueueType) &&
+ if ((type == simplequeue_get_state_by_type(type)->SimpleQueueType) &&
!_PyArg_NoPositional("SimpleQueue", args)) {
goto exit;
}
- if ((type == &PySimpleQueueType) &&
+ if ((type == simplequeue_get_state_by_type(type)->SimpleQueueType) &&
!_PyArg_NoKeywords("SimpleQueue", kwargs)) {
goto exit;
}
@@ -133,42 +133,26 @@ PyDoc_STRVAR(_queue_SimpleQueue_get__doc__,
"in that case).");
#define _QUEUE_SIMPLEQUEUE_GET_METHODDEF \
- {"get", (PyCFunction)(void(*)(void))_queue_SimpleQueue_get, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_get__doc__},
+ {"get", (PyCFunction)(void(*)(void))_queue_SimpleQueue_get, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_get__doc__},
static PyObject *
-_queue_SimpleQueue_get_impl(simplequeueobject *self, int block,
- PyObject *timeout);
+_queue_SimpleQueue_get_impl(simplequeueobject *self, PyTypeObject *cls,
+ int block, PyObject *timeout);
static PyObject *
-_queue_SimpleQueue_get(simplequeueobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+_queue_SimpleQueue_get(simplequeueobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"block", "timeout", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "get", 0};
- PyObject *argsbuf[2];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
+ static _PyArg_Parser _parser = {"|pO:get", _keywords, 0};
int block = 1;
PyObject *timeout = Py_None;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf);
- if (!args) {
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &block, &timeout)) {
goto exit;
}
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[0]) {
- block = PyObject_IsTrue(args[0]);
- if (block < 0) {
- goto exit;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- timeout = args[1];
-skip_optional_pos:
- return_value = _queue_SimpleQueue_get_impl(self, block, timeout);
+ return_value = _queue_SimpleQueue_get_impl(self, cls, block, timeout);
exit:
return return_value;
@@ -184,15 +168,27 @@ PyDoc_STRVAR(_queue_SimpleQueue_get_nowait__doc__,
"raise the Empty exception.");
#define _QUEUE_SIMPLEQUEUE_GET_NOWAIT_METHODDEF \
- {"get_nowait", (PyCFunction)_queue_SimpleQueue_get_nowait, METH_NOARGS, _queue_SimpleQueue_get_nowait__doc__},
+ {"get_nowait", (PyCFunction)(void(*)(void))_queue_SimpleQueue_get_nowait, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_get_nowait__doc__},
static PyObject *
-_queue_SimpleQueue_get_nowait_impl(simplequeueobject *self);
+_queue_SimpleQueue_get_nowait_impl(simplequeueobject *self,
+ PyTypeObject *cls);
static PyObject *
-_queue_SimpleQueue_get_nowait(simplequeueobject *self, PyObject *Py_UNUSED(ignored))
+_queue_SimpleQueue_get_nowait(simplequeueobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- return _queue_SimpleQueue_get_nowait_impl(self);
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = { NULL};
+ static _PyArg_Parser _parser = {":get_nowait", _keywords, 0};
+
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
+ )) {
+ goto exit;
+ }
+ return_value = _queue_SimpleQueue_get_nowait_impl(self, cls);
+
+exit:
+ return return_value;
}
PyDoc_STRVAR(_queue_SimpleQueue_empty__doc__,
@@ -250,4 +246,4 @@ _queue_SimpleQueue_qsize(simplequeueobject *self, PyObject *Py_UNUSED(ignored))
exit:
return return_value;
}
-/*[clinic end generated code: output=b4717e2974cbc909 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ce56b46fac150909 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_sre.c.h b/Modules/clinic/_sre.c.h
index 2314114a1b..72d772c289 100644
--- a/Modules/clinic/_sre.c.h
+++ b/Modules/clinic/_sre.c.h
@@ -164,63 +164,28 @@ PyDoc_STRVAR(_sre_SRE_Pattern_match__doc__,
"Matches zero or more characters at the beginning of the string.");
#define _SRE_SRE_PATTERN_MATCH_METHODDEF \
- {"match", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_match, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_match__doc__},
+ {"match", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_match, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_match__doc__},
static PyObject *
-_sre_SRE_Pattern_match_impl(PatternObject *self, PyObject *string,
- Py_ssize_t pos, Py_ssize_t endpos);
+_sre_SRE_Pattern_match_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *string, Py_ssize_t pos,
+ Py_ssize_t endpos);
static PyObject *
-_sre_SRE_Pattern_match(PatternObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+_sre_SRE_Pattern_match(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "match", 0};
- PyObject *argsbuf[3];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
+ static _PyArg_Parser _parser = {"O|nn:match", _keywords, 0};
PyObject *string;
Py_ssize_t pos = 0;
Py_ssize_t endpos = PY_SSIZE_T_MAX;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
- if (!args) {
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &string, &pos, &endpos)) {
goto exit;
}
- string = args[0];
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[1]) {
- {
- Py_ssize_t ival = -1;
- PyObject *iobj = _PyNumber_Index(args[1]);
- if (iobj != NULL) {
- ival = PyLong_AsSsize_t(iobj);
- Py_DECREF(iobj);
- }
- if (ival == -1 && PyErr_Occurred()) {
- goto exit;
- }
- pos = ival;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- {
- Py_ssize_t ival = -1;
- PyObject *iobj = _PyNumber_Index(args[2]);
- if (iobj != NULL) {
- ival = PyLong_AsSsize_t(iobj);
- Py_DECREF(iobj);
- }
- if (ival == -1 && PyErr_Occurred()) {
- goto exit;
- }
- endpos = ival;
- }
-skip_optional_pos:
- return_value = _sre_SRE_Pattern_match_impl(self, string, pos, endpos);
+ return_value = _sre_SRE_Pattern_match_impl(self, cls, string, pos, endpos);
exit:
return return_value;
@@ -233,63 +198,28 @@ PyDoc_STRVAR(_sre_SRE_Pattern_fullmatch__doc__,
"Matches against all of the string.");
#define _SRE_SRE_PATTERN_FULLMATCH_METHODDEF \
- {"fullmatch", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_fullmatch, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_fullmatch__doc__},
+ {"fullmatch", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_fullmatch, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_fullmatch__doc__},
static PyObject *
-_sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyObject *string,
- Py_ssize_t pos, Py_ssize_t endpos);
+_sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *string, Py_ssize_t pos,
+ Py_ssize_t endpos);
static PyObject *
-_sre_SRE_Pattern_fullmatch(PatternObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+_sre_SRE_Pattern_fullmatch(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "fullmatch", 0};
- PyObject *argsbuf[3];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
+ static _PyArg_Parser _parser = {"O|nn:fullmatch", _keywords, 0};
PyObject *string;
Py_ssize_t pos = 0;
Py_ssize_t endpos = PY_SSIZE_T_MAX;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
- if (!args) {
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &string, &pos, &endpos)) {
goto exit;
}
- string = args[0];
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[1]) {
- {
- Py_ssize_t ival = -1;
- PyObject *iobj = _PyNumber_Index(args[1]);
- if (iobj != NULL) {
- ival = PyLong_AsSsize_t(iobj);
- Py_DECREF(iobj);
- }
- if (ival == -1 && PyErr_Occurred()) {
- goto exit;
- }
- pos = ival;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- {
- Py_ssize_t ival = -1;
- PyObject *iobj = _PyNumber_Index(args[2]);
- if (iobj != NULL) {
- ival = PyLong_AsSsize_t(iobj);
- Py_DECREF(iobj);
- }
- if (ival == -1 && PyErr_Occurred()) {
- goto exit;
- }
- endpos = ival;
- }
-skip_optional_pos:
- return_value = _sre_SRE_Pattern_fullmatch_impl(self, string, pos, endpos);
+ return_value = _sre_SRE_Pattern_fullmatch_impl(self, cls, string, pos, endpos);
exit:
return return_value;
@@ -304,63 +234,28 @@ PyDoc_STRVAR(_sre_SRE_Pattern_search__doc__,
"Return None if no position in the string matches.");
#define _SRE_SRE_PATTERN_SEARCH_METHODDEF \
- {"search", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_search, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_search__doc__},
+ {"search", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_search, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_search__doc__},
static PyObject *
-_sre_SRE_Pattern_search_impl(PatternObject *self, PyObject *string,
- Py_ssize_t pos, Py_ssize_t endpos);
+_sre_SRE_Pattern_search_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *string, Py_ssize_t pos,
+ Py_ssize_t endpos);
static PyObject *
-_sre_SRE_Pattern_search(PatternObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+_sre_SRE_Pattern_search(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "search", 0};
- PyObject *argsbuf[3];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
+ static _PyArg_Parser _parser = {"O|nn:search", _keywords, 0};
PyObject *string;
Py_ssize_t pos = 0;
Py_ssize_t endpos = PY_SSIZE_T_MAX;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
- if (!args) {
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &string, &pos, &endpos)) {
goto exit;
}
- string = args[0];
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[1]) {
- {
- Py_ssize_t ival = -1;
- PyObject *iobj = _PyNumber_Index(args[1]);
- if (iobj != NULL) {
- ival = PyLong_AsSsize_t(iobj);
- Py_DECREF(iobj);
- }
- if (ival == -1 && PyErr_Occurred()) {
- goto exit;
- }
- pos = ival;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- {
- Py_ssize_t ival = -1;
- PyObject *iobj = _PyNumber_Index(args[2]);
- if (iobj != NULL) {
- ival = PyLong_AsSsize_t(iobj);
- Py_DECREF(iobj);
- }
- if (ival == -1 && PyErr_Occurred()) {
- goto exit;
- }
- endpos = ival;
- }
-skip_optional_pos:
- return_value = _sre_SRE_Pattern_search_impl(self, string, pos, endpos);
+ return_value = _sre_SRE_Pattern_search_impl(self, cls, string, pos, endpos);
exit:
return return_value;
@@ -444,63 +339,28 @@ PyDoc_STRVAR(_sre_SRE_Pattern_finditer__doc__,
"For each match, the iterator returns a match object.");
#define _SRE_SRE_PATTERN_FINDITER_METHODDEF \
- {"finditer", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_finditer, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_finditer__doc__},
+ {"finditer", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_finditer, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_finditer__doc__},
static PyObject *
-_sre_SRE_Pattern_finditer_impl(PatternObject *self, PyObject *string,
- Py_ssize_t pos, Py_ssize_t endpos);
+_sre_SRE_Pattern_finditer_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *string, Py_ssize_t pos,
+ Py_ssize_t endpos);
static PyObject *
-_sre_SRE_Pattern_finditer(PatternObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+_sre_SRE_Pattern_finditer(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "finditer", 0};
- PyObject *argsbuf[3];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
+ static _PyArg_Parser _parser = {"O|nn:finditer", _keywords, 0};
PyObject *string;
Py_ssize_t pos = 0;
Py_ssize_t endpos = PY_SSIZE_T_MAX;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
- if (!args) {
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &string, &pos, &endpos)) {
goto exit;
}
- string = args[0];
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[1]) {
- {
- Py_ssize_t ival = -1;
- PyObject *iobj = _PyNumber_Index(args[1]);
- if (iobj != NULL) {
- ival = PyLong_AsSsize_t(iobj);
- Py_DECREF(iobj);
- }
- if (ival == -1 && PyErr_Occurred()) {
- goto exit;
- }
- pos = ival;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- {
- Py_ssize_t ival = -1;
- PyObject *iobj = _PyNumber_Index(args[2]);
- if (iobj != NULL) {
- ival = PyLong_AsSsize_t(iobj);
- Py_DECREF(iobj);
- }
- if (ival == -1 && PyErr_Occurred()) {
- goto exit;
- }
- endpos = ival;
- }
-skip_optional_pos:
- return_value = _sre_SRE_Pattern_finditer_impl(self, string, pos, endpos);
+ return_value = _sre_SRE_Pattern_finditer_impl(self, cls, string, pos, endpos);
exit:
return return_value;
@@ -512,63 +372,28 @@ PyDoc_STRVAR(_sre_SRE_Pattern_scanner__doc__,
"\n");
#define _SRE_SRE_PATTERN_SCANNER_METHODDEF \
- {"scanner", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_scanner, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_scanner__doc__},
+ {"scanner", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_scanner, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_scanner__doc__},
static PyObject *
-_sre_SRE_Pattern_scanner_impl(PatternObject *self, PyObject *string,
- Py_ssize_t pos, Py_ssize_t endpos);
+_sre_SRE_Pattern_scanner_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *string, Py_ssize_t pos,
+ Py_ssize_t endpos);
static PyObject *
-_sre_SRE_Pattern_scanner(PatternObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+_sre_SRE_Pattern_scanner(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "scanner", 0};
- PyObject *argsbuf[3];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
+ static _PyArg_Parser _parser = {"O|nn:scanner", _keywords, 0};
PyObject *string;
Py_ssize_t pos = 0;
Py_ssize_t endpos = PY_SSIZE_T_MAX;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
- if (!args) {
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &string, &pos, &endpos)) {
goto exit;
}
- string = args[0];
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[1]) {
- {
- Py_ssize_t ival = -1;
- PyObject *iobj = _PyNumber_Index(args[1]);
- if (iobj != NULL) {
- ival = PyLong_AsSsize_t(iobj);
- Py_DECREF(iobj);
- }
- if (ival == -1 && PyErr_Occurred()) {
- goto exit;
- }
- pos = ival;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- {
- Py_ssize_t ival = -1;
- PyObject *iobj = _PyNumber_Index(args[2]);
- if (iobj != NULL) {
- ival = PyLong_AsSsize_t(iobj);
- Py_DECREF(iobj);
- }
- if (ival == -1 && PyErr_Occurred()) {
- goto exit;
- }
- endpos = ival;
- }
-skip_optional_pos:
- return_value = _sre_SRE_Pattern_scanner_impl(self, string, pos, endpos);
+ return_value = _sre_SRE_Pattern_scanner_impl(self, cls, string, pos, endpos);
exit:
return return_value;
@@ -632,47 +457,27 @@ PyDoc_STRVAR(_sre_SRE_Pattern_sub__doc__,
"Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl.");
#define _SRE_SRE_PATTERN_SUB_METHODDEF \
- {"sub", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_sub, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_sub__doc__},
+ {"sub", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_sub, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_sub__doc__},
static PyObject *
-_sre_SRE_Pattern_sub_impl(PatternObject *self, PyObject *repl,
- PyObject *string, Py_ssize_t count);
+_sre_SRE_Pattern_sub_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *repl, PyObject *string, Py_ssize_t count);
static PyObject *
-_sre_SRE_Pattern_sub(PatternObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+_sre_SRE_Pattern_sub(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"repl", "string", "count", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "sub", 0};
- PyObject *argsbuf[3];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
+ static _PyArg_Parser _parser = {"OO|n:sub", _keywords, 0};
PyObject *repl;
PyObject *string;
Py_ssize_t count = 0;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf);
- if (!args) {
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &repl, &string, &count)) {
goto exit;
}
- repl = args[0];
- string = args[1];
- if (!noptargs) {
- goto skip_optional_pos;
- }
- {
- Py_ssize_t ival = -1;
- PyObject *iobj = _PyNumber_Index(args[2]);
- if (iobj != NULL) {
- ival = PyLong_AsSsize_t(iobj);
- Py_DECREF(iobj);
- }
- if (ival == -1 && PyErr_Occurred()) {
- goto exit;
- }
- count = ival;
- }
-skip_optional_pos:
- return_value = _sre_SRE_Pattern_sub_impl(self, repl, string, count);
+ return_value = _sre_SRE_Pattern_sub_impl(self, cls, repl, string, count);
exit:
return return_value;
@@ -685,47 +490,28 @@ PyDoc_STRVAR(_sre_SRE_Pattern_subn__doc__,
"Return the tuple (new_string, number_of_subs_made) found by replacing the leftmost non-overlapping occurrences of pattern with the replacement repl.");
#define _SRE_SRE_PATTERN_SUBN_METHODDEF \
- {"subn", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_subn, METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_subn__doc__},
+ {"subn", (PyCFunction)(void(*)(void))_sre_SRE_Pattern_subn, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_subn__doc__},
static PyObject *
-_sre_SRE_Pattern_subn_impl(PatternObject *self, PyObject *repl,
- PyObject *string, Py_ssize_t count);
+_sre_SRE_Pattern_subn_impl(PatternObject *self, PyTypeObject *cls,
+ PyObject *repl, PyObject *string,
+ Py_ssize_t count);
static PyObject *
-_sre_SRE_Pattern_subn(PatternObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+_sre_SRE_Pattern_subn(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"repl", "string", "count", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "subn", 0};
- PyObject *argsbuf[3];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
+ static _PyArg_Parser _parser = {"OO|n:subn", _keywords, 0};
PyObject *repl;
PyObject *string;
Py_ssize_t count = 0;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf);
- if (!args) {
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &repl, &string, &count)) {
goto exit;
}
- repl = args[0];
- string = args[1];
- if (!noptargs) {
- goto skip_optional_pos;
- }
- {
- Py_ssize_t ival = -1;
- PyObject *iobj = _PyNumber_Index(args[2]);
- if (iobj != NULL) {
- ival = PyLong_AsSsize_t(iobj);
- Py_DECREF(iobj);
- }
- if (ival == -1 && PyErr_Occurred()) {
- goto exit;
- }
- count = ival;
- }
-skip_optional_pos:
- return_value = _sre_SRE_Pattern_subn_impl(self, repl, string, count);
+ return_value = _sre_SRE_Pattern_subn_impl(self, cls, repl, string, count);
exit:
return return_value;
@@ -1075,15 +861,26 @@ PyDoc_STRVAR(_sre_SRE_Scanner_match__doc__,
"\n");
#define _SRE_SRE_SCANNER_MATCH_METHODDEF \
- {"match", (PyCFunction)_sre_SRE_Scanner_match, METH_NOARGS, _sre_SRE_Scanner_match__doc__},
+ {"match", (PyCFunction)(void(*)(void))_sre_SRE_Scanner_match, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Scanner_match__doc__},
static PyObject *
-_sre_SRE_Scanner_match_impl(ScannerObject *self);
+_sre_SRE_Scanner_match_impl(ScannerObject *self, PyTypeObject *cls);
static PyObject *
-_sre_SRE_Scanner_match(ScannerObject *self, PyObject *Py_UNUSED(ignored))
+_sre_SRE_Scanner_match(ScannerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- return _sre_SRE_Scanner_match_impl(self);
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = { NULL};
+ static _PyArg_Parser _parser = {":match", _keywords, 0};
+
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
+ )) {
+ goto exit;
+ }
+ return_value = _sre_SRE_Scanner_match_impl(self, cls);
+
+exit:
+ return return_value;
}
PyDoc_STRVAR(_sre_SRE_Scanner_search__doc__,
@@ -1092,14 +889,25 @@ PyDoc_STRVAR(_sre_SRE_Scanner_search__doc__,
"\n");
#define _SRE_SRE_SCANNER_SEARCH_METHODDEF \
- {"search", (PyCFunction)_sre_SRE_Scanner_search, METH_NOARGS, _sre_SRE_Scanner_search__doc__},
+ {"search", (PyCFunction)(void(*)(void))_sre_SRE_Scanner_search, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Scanner_search__doc__},
static PyObject *
-_sre_SRE_Scanner_search_impl(ScannerObject *self);
+_sre_SRE_Scanner_search_impl(ScannerObject *self, PyTypeObject *cls);
static PyObject *
-_sre_SRE_Scanner_search(ScannerObject *self, PyObject *Py_UNUSED(ignored))
+_sre_SRE_Scanner_search(ScannerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- return _sre_SRE_Scanner_search_impl(self);
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = { NULL};
+ static _PyArg_Parser _parser = {":search", _keywords, 0};
+
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
+ )) {
+ goto exit;
+ }
+ return_value = _sre_SRE_Scanner_search_impl(self, cls);
+
+exit:
+ return return_value;
}
-/*[clinic end generated code: output=0e27915b1eb7c0e4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=518f7bb775c1184f input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_ssl.c.h b/Modules/clinic/_ssl.c.h
index 2375f83b32..43469d3c35 100644
--- a/Modules/clinic/_ssl.c.h
+++ b/Modules/clinic/_ssl.c.h
@@ -399,7 +399,7 @@ _ssl__SSLContext(PyTypeObject *type, PyObject *args, PyObject *kwargs)
PyObject *return_value = NULL;
int proto_version;
- if ((type == &PySSLContext_Type) &&
+ if ((type == PySSLContext_Type) &&
!_PyArg_NoKeywords("_SSLContext", kwargs)) {
goto exit;
}
@@ -754,13 +754,13 @@ _ssl__SSLContext__wrap_bio(PySSLContext *self, PyObject *const *args, Py_ssize_t
if (!args) {
goto exit;
}
- if (!PyObject_TypeCheck(args[0], &PySSLMemoryBIO_Type)) {
- _PyArg_BadArgument("_wrap_bio", "argument 'incoming'", (&PySSLMemoryBIO_Type)->tp_name, args[0]);
+ if (!PyObject_TypeCheck(args[0], PySSLMemoryBIO_Type)) {
+ _PyArg_BadArgument("_wrap_bio", "argument 'incoming'", (PySSLMemoryBIO_Type)->tp_name, args[0]);
goto exit;
}
incoming = (PySSLMemoryBIO *)args[0];
- if (!PyObject_TypeCheck(args[1], &PySSLMemoryBIO_Type)) {
- _PyArg_BadArgument("_wrap_bio", "argument 'outgoing'", (&PySSLMemoryBIO_Type)->tp_name, args[1]);
+ if (!PyObject_TypeCheck(args[1], PySSLMemoryBIO_Type)) {
+ _PyArg_BadArgument("_wrap_bio", "argument 'outgoing'", (PySSLMemoryBIO_Type)->tp_name, args[1]);
goto exit;
}
outgoing = (PySSLMemoryBIO *)args[1];
@@ -919,11 +919,11 @@ _ssl_MemoryBIO(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
- if ((type == &PySSLMemoryBIO_Type) &&
+ if ((type == PySSLMemoryBIO_Type) &&
!_PyArg_NoPositional("MemoryBIO", args)) {
goto exit;
}
- if ((type == &PySSLMemoryBIO_Type) &&
+ if ((type == PySSLMemoryBIO_Type) &&
!_PyArg_NoKeywords("MemoryBIO", kwargs)) {
goto exit;
}
@@ -1447,4 +1447,4 @@ exit:
#ifndef _SSL_ENUM_CRLS_METHODDEF
#define _SSL_ENUM_CRLS_METHODDEF
#endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
-/*[clinic end generated code: output=d4e4f9cdd08819f4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=2bb53a80040c9b35 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_struct.c.h b/Modules/clinic/_struct.c.h
index 1cfaef3b71..b0c1eb4587 100644
--- a/Modules/clinic/_struct.c.h
+++ b/Modules/clinic/_struct.c.h
@@ -199,7 +199,7 @@ calcsize(PyObject *module, PyObject *arg)
PyStructObject *s_object = NULL;
Py_ssize_t _return_value;
- if (!cache_struct_converter(arg, &s_object)) {
+ if (!cache_struct_converter(module, arg, &s_object)) {
goto exit;
}
_return_value = calcsize_impl(module, s_object);
@@ -241,7 +241,7 @@ unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (!_PyArg_CheckPositional("unpack", nargs, 2, 2)) {
goto exit;
}
- if (!cache_struct_converter(args[0], &s_object)) {
+ if (!cache_struct_converter(module, args[0], &s_object)) {
goto exit;
}
if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) {
@@ -297,7 +297,7 @@ unpack_from(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
if (!args) {
goto exit;
}
- if (!cache_struct_converter(args[0], &s_object)) {
+ if (!cache_struct_converter(module, args[0], &s_object)) {
goto exit;
}
if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) {
@@ -364,7 +364,7 @@ iter_unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (!_PyArg_CheckPositional("iter_unpack", nargs, 2, 2)) {
goto exit;
}
- if (!cache_struct_converter(args[0], &s_object)) {
+ if (!cache_struct_converter(module, args[0], &s_object)) {
goto exit;
}
buffer = args[1];
@@ -376,4 +376,4 @@ exit:
return return_value;
}
-/*[clinic end generated code: output=8089792d8ed0c1be input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a3d3cd900091cb1c input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_testmultiphase.c.h b/Modules/clinic/_testmultiphase.c.h
index 0d38c230f7..55f934be8c 100644
--- a/Modules/clinic/_testmultiphase.c.h
+++ b/Modules/clinic/_testmultiphase.c.h
@@ -6,7 +6,10 @@ PyDoc_STRVAR(_testmultiphase_StateAccessType_get_defining_module__doc__,
"get_defining_module($self, /)\n"
"--\n"
"\n"
-"Return the module of the defining class.");
+"Return the module of the defining class.\n"
+"\n"
+"Also tests that result of _PyType_GetModuleByDef matches defining_class\'s\n"
+"module.");
#define _TESTMULTIPHASE_STATEACCESSTYPE_GET_DEFINING_MODULE_METHODDEF \
{"get_defining_module", (PyCFunction)(void(*)(void))_testmultiphase_StateAccessType_get_defining_module, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testmultiphase_StateAccessType_get_defining_module__doc__},
@@ -98,4 +101,4 @@ _testmultiphase_StateAccessType_get_count(StateAccessTypeObject *self, PyTypeObj
exit:
return return_value;
}
-/*[clinic end generated code: output=39eea487e94e7f5d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f01137bb3b373e14 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/itertoolsmodule.c.h b/Modules/clinic/itertoolsmodule.c.h
index c1192bbcb0..82729eeb56 100644
--- a/Modules/clinic/itertoolsmodule.c.h
+++ b/Modules/clinic/itertoolsmodule.c.h
@@ -2,6 +2,37 @@
preserve
[clinic start generated code]*/
+PyDoc_STRVAR(pairwise_new__doc__,
+"pairwise(iterable, /)\n"
+"--\n"
+"\n"
+"Return an iterator of overlapping pairs taken from the input iterator.\n"
+"\n"
+" s -> (s0,s1), (s1,s2), (s2, s3), ...");
+
+static PyObject *
+pairwise_new_impl(PyTypeObject *type, PyObject *iterable);
+
+static PyObject *
+pairwise_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *iterable;
+
+ if ((type == &pairwise_type) &&
+ !_PyArg_NoKeywords("pairwise", kwargs)) {
+ goto exit;
+ }
+ if (!_PyArg_CheckPositional("pairwise", PyTuple_GET_SIZE(args), 1, 1)) {
+ goto exit;
+ }
+ iterable = PyTuple_GET_ITEM(args, 0);
+ return_value = pairwise_new_impl(type, iterable);
+
+exit:
+ return return_value;
+}
+
PyDoc_STRVAR(itertools_groupby__doc__,
"groupby(iterable, key=None)\n"
"--\n"
@@ -627,4 +658,4 @@ skip_optional_pos:
exit:
return return_value;
}
-/*[clinic end generated code: output=d7f58dc477814b45 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=889c4afc3b13574f input=a9049054013a1b77]*/
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index df680d5738..4a72ea0dd5 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -5674,6 +5674,106 @@ exit:
#endif /* defined(HAVE_COPY_FILE_RANGE) */
+#if ((defined(HAVE_SPLICE) && !defined(_AIX)))
+
+PyDoc_STRVAR(os_splice__doc__,
+"splice($module, /, src, dst, count, offset_src=None, offset_dst=None,\n"
+" flags=0)\n"
+"--\n"
+"\n"
+"Transfer count bytes from one pipe to a descriptor or vice versa.\n"
+"\n"
+" src\n"
+" Source file descriptor.\n"
+" dst\n"
+" Destination file descriptor.\n"
+" count\n"
+" Number of bytes to copy.\n"
+" offset_src\n"
+" Starting offset in src.\n"
+" offset_dst\n"
+" Starting offset in dst.\n"
+" flags\n"
+" Flags to modify the semantics of the call.\n"
+"\n"
+"If offset_src is None, then src is read from the current position;\n"
+"respectively for offset_dst. The offset associated to the file\n"
+"descriptor that refers to a pipe must be None.");
+
+#define OS_SPLICE_METHODDEF \
+ {"splice", (PyCFunction)(void(*)(void))os_splice, METH_FASTCALL|METH_KEYWORDS, os_splice__doc__},
+
+static PyObject *
+os_splice_impl(PyObject *module, int src, int dst, Py_ssize_t count,
+ PyObject *offset_src, PyObject *offset_dst,
+ unsigned int flags);
+
+static PyObject *
+os_splice(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"src", "dst", "count", "offset_src", "offset_dst", "flags", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "splice", 0};
+ PyObject *argsbuf[6];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
+ int src;
+ int dst;
+ Py_ssize_t count;
+ PyObject *offset_src = Py_None;
+ PyObject *offset_dst = Py_None;
+ unsigned int flags = 0;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 6, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ src = _PyLong_AsInt(args[0]);
+ if (src == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ dst = _PyLong_AsInt(args[1]);
+ if (dst == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[2]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ count = ival;
+ }
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[3]) {
+ offset_src = args[3];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ if (args[4]) {
+ offset_dst = args[4];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ if (!_PyLong_UnsignedInt_Converter(args[5], &flags)) {
+ goto exit;
+ }
+skip_optional_pos:
+ return_value = os_splice_impl(module, src, dst, count, offset_src, offset_dst, flags);
+
+exit:
+ return return_value;
+}
+
+#endif /* ((defined(HAVE_SPLICE) && !defined(_AIX))) */
+
#if defined(HAVE_MKFIFO)
PyDoc_STRVAR(os_mkfifo__doc__,
@@ -7620,6 +7720,134 @@ exit:
#endif /* defined(HAVE_MEMFD_CREATE) */
+#if defined(HAVE_EVENTFD)
+
+PyDoc_STRVAR(os_eventfd__doc__,
+"eventfd($module, /, initval, flags=EFD_CLOEXEC)\n"
+"--\n"
+"\n"
+"Creates and returns an event notification file descriptor.");
+
+#define OS_EVENTFD_METHODDEF \
+ {"eventfd", (PyCFunction)(void(*)(void))os_eventfd, METH_FASTCALL|METH_KEYWORDS, os_eventfd__doc__},
+
+static PyObject *
+os_eventfd_impl(PyObject *module, unsigned int initval, int flags);
+
+static PyObject *
+os_eventfd(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"initval", "flags", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "eventfd", 0};
+ PyObject *argsbuf[2];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
+ unsigned int initval;
+ int flags = EFD_CLOEXEC;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!_PyLong_UnsignedInt_Converter(args[0], &initval)) {
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ flags = _PyLong_AsInt(args[1]);
+ if (flags == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional_pos:
+ return_value = os_eventfd_impl(module, initval, flags);
+
+exit:
+ return return_value;
+}
+
+#endif /* defined(HAVE_EVENTFD) */
+
+#if defined(HAVE_EVENTFD)
+
+PyDoc_STRVAR(os_eventfd_read__doc__,
+"eventfd_read($module, /, fd)\n"
+"--\n"
+"\n"
+"Read eventfd value");
+
+#define OS_EVENTFD_READ_METHODDEF \
+ {"eventfd_read", (PyCFunction)(void(*)(void))os_eventfd_read, METH_FASTCALL|METH_KEYWORDS, os_eventfd_read__doc__},
+
+static PyObject *
+os_eventfd_read_impl(PyObject *module, int fd);
+
+static PyObject *
+os_eventfd_read(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"fd", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "eventfd_read", 0};
+ PyObject *argsbuf[1];
+ int fd;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
+ goto exit;
+ }
+ return_value = os_eventfd_read_impl(module, fd);
+
+exit:
+ return return_value;
+}
+
+#endif /* defined(HAVE_EVENTFD) */
+
+#if defined(HAVE_EVENTFD)
+
+PyDoc_STRVAR(os_eventfd_write__doc__,
+"eventfd_write($module, /, fd, value)\n"
+"--\n"
+"\n"
+"Write eventfd value.");
+
+#define OS_EVENTFD_WRITE_METHODDEF \
+ {"eventfd_write", (PyCFunction)(void(*)(void))os_eventfd_write, METH_FASTCALL|METH_KEYWORDS, os_eventfd_write__doc__},
+
+static PyObject *
+os_eventfd_write_impl(PyObject *module, int fd, unsigned long long value);
+
+static PyObject *
+os_eventfd_write(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"fd", "value", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "eventfd_write", 0};
+ PyObject *argsbuf[2];
+ int fd;
+ unsigned long long value;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
+ goto exit;
+ }
+ if (!_PyLong_UnsignedLongLong_Converter(args[1], &value)) {
+ goto exit;
+ }
+ return_value = os_eventfd_write_impl(module, fd, value);
+
+exit:
+ return return_value;
+}
+
+#endif /* defined(HAVE_EVENTFD) */
+
#if (defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL))
PyDoc_STRVAR(os_get_terminal_size__doc__,
@@ -8736,6 +8964,10 @@ exit:
#define OS_COPY_FILE_RANGE_METHODDEF
#endif /* !defined(OS_COPY_FILE_RANGE_METHODDEF) */
+#ifndef OS_SPLICE_METHODDEF
+ #define OS_SPLICE_METHODDEF
+#endif /* !defined(OS_SPLICE_METHODDEF) */
+
#ifndef OS_MKFIFO_METHODDEF
#define OS_MKFIFO_METHODDEF
#endif /* !defined(OS_MKFIFO_METHODDEF) */
@@ -8884,6 +9116,18 @@ exit:
#define OS_MEMFD_CREATE_METHODDEF
#endif /* !defined(OS_MEMFD_CREATE_METHODDEF) */
+#ifndef OS_EVENTFD_METHODDEF
+ #define OS_EVENTFD_METHODDEF
+#endif /* !defined(OS_EVENTFD_METHODDEF) */
+
+#ifndef OS_EVENTFD_READ_METHODDEF
+ #define OS_EVENTFD_READ_METHODDEF
+#endif /* !defined(OS_EVENTFD_READ_METHODDEF) */
+
+#ifndef OS_EVENTFD_WRITE_METHODDEF
+ #define OS_EVENTFD_WRITE_METHODDEF
+#endif /* !defined(OS_EVENTFD_WRITE_METHODDEF) */
+
#ifndef OS_GET_TERMINAL_SIZE_METHODDEF
#define OS_GET_TERMINAL_SIZE_METHODDEF
#endif /* !defined(OS_GET_TERMINAL_SIZE_METHODDEF) */
@@ -8919,4 +9163,4 @@ exit:
#ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF
#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF
#endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */
-/*[clinic end generated code: output=936f33448cd66ccb input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f3ec08afcd6cd8f8 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/selectmodule.c.h b/Modules/clinic/selectmodule.c.h
index 00a78c4847..d7095dfb00 100644
--- a/Modules/clinic/selectmodule.c.h
+++ b/Modules/clinic/selectmodule.c.h
@@ -933,11 +933,11 @@ select_kqueue(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
- if ((type == _selectstate_global->kqueue_queue_Type) &&
+ if ((type == _selectstate_by_type(type)->kqueue_queue_Type) &&
!_PyArg_NoPositional("kqueue", args)) {
goto exit;
}
- if ((type == _selectstate_global->kqueue_queue_Type) &&
+ if ((type == _selectstate_by_type(type)->kqueue_queue_Type) &&
!_PyArg_NoKeywords("kqueue", kwargs)) {
goto exit;
}
@@ -1179,4 +1179,4 @@ exit:
#ifndef SELECT_KQUEUE_CONTROL_METHODDEF
#define SELECT_KQUEUE_CONTROL_METHODDEF
#endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */
-/*[clinic end generated code: output=162f4f4efa850416 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=cd2062a787e13b35 input=a9049054013a1b77]*/
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index e6ad0f2dd4..fdbba6a7af 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -165,12 +165,17 @@ PyStatus
_PyGC_Init(PyThreadState *tstate)
{
GCState *gcstate = &tstate->interp->gc;
+
+ gcstate->garbage = PyList_New(0);
if (gcstate->garbage == NULL) {
- gcstate->garbage = PyList_New(0);
- if (gcstate->garbage == NULL) {
- return _PyStatus_NO_MEMORY();
- }
+ return _PyStatus_NO_MEMORY();
+ }
+
+ gcstate->callbacks = PyList_New(0);
+ if (gcstate->callbacks == NULL) {
+ return _PyStatus_NO_MEMORY();
}
+
return _PyStatus_OK();
}
@@ -1992,59 +1997,50 @@ static PyMethodDef GcMethods[] = {
{NULL, NULL} /* Sentinel */
};
-static struct PyModuleDef gcmodule = {
- PyModuleDef_HEAD_INIT,
- "gc", /* m_name */
- gc__doc__, /* m_doc */
- -1, /* m_size */
- GcMethods, /* m_methods */
- NULL, /* m_reload */
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-
-PyMODINIT_FUNC
-PyInit_gc(void)
+static int
+gcmodule_exec(PyObject *module)
{
GCState *gcstate = get_gc_state();
- PyObject *m = PyModule_Create(&gcmodule);
-
- if (m == NULL) {
- return NULL;
- }
-
- if (gcstate->garbage == NULL) {
- gcstate->garbage = PyList_New(0);
- if (gcstate->garbage == NULL) {
- return NULL;
- }
- }
- Py_INCREF(gcstate->garbage);
- if (PyModule_AddObject(m, "garbage", gcstate->garbage) < 0) {
- return NULL;
- }
-
- if (gcstate->callbacks == NULL) {
- gcstate->callbacks = PyList_New(0);
- if (gcstate->callbacks == NULL) {
- return NULL;
- }
+ /* garbage and callbacks are initialized by _PyGC_Init() early in
+ * interpreter lifecycle. */
+ assert(gcstate->garbage != NULL);
+ if (PyModule_AddObjectRef(module, "garbage", gcstate->garbage) < 0) {
+ return -1;
}
- Py_INCREF(gcstate->callbacks);
- if (PyModule_AddObject(m, "callbacks", gcstate->callbacks) < 0) {
- return NULL;
+ assert(gcstate->callbacks != NULL);
+ if (PyModule_AddObjectRef(module, "callbacks", gcstate->callbacks) < 0) {
+ return -1;
}
-#define ADD_INT(NAME) if (PyModule_AddIntConstant(m, #NAME, NAME) < 0) { return NULL; }
+#define ADD_INT(NAME) if (PyModule_AddIntConstant(module, #NAME, NAME) < 0) { return -1; }
ADD_INT(DEBUG_STATS);
ADD_INT(DEBUG_COLLECTABLE);
ADD_INT(DEBUG_UNCOLLECTABLE);
ADD_INT(DEBUG_SAVEALL);
ADD_INT(DEBUG_LEAK);
#undef ADD_INT
- return m;
+ return 0;
+}
+
+static PyModuleDef_Slot gcmodule_slots[] = {
+ {Py_mod_exec, gcmodule_exec},
+ {0, NULL}
+};
+
+static struct PyModuleDef gcmodule = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "gc",
+ .m_doc = gc__doc__,
+ .m_size = 0, // per interpreter state, see: get_gc_state()
+ .m_methods = GcMethods,
+ .m_slots = gcmodule_slots
+};
+
+PyMODINIT_FUNC
+PyInit_gc(void)
+{
+ return PyModuleDef_Init(&gcmodule);
}
/* Public API to invoke gc.collect() from C */
@@ -2294,7 +2290,7 @@ _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems)
}
PyGC_Head *g = AS_GC(op);
- g = (PyGC_Head *)PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize);
+ g = (PyGC_Head *)PyObject_Realloc(g, sizeof(PyGC_Head) + basicsize);
if (g == NULL)
return (PyVarObject *)PyErr_NoMemory();
op = (PyVarObject *) FROM_GC(g);
@@ -2313,7 +2309,7 @@ PyObject_GC_Del(void *op)
if (gcstate->generations[0].count > 0) {
gcstate->generations[0].count--;
}
- PyObject_FREE(g);
+ PyObject_Free(g);
}
int
diff --git a/Modules/getpath.c b/Modules/getpath.c
index f7a6dd4044..44453f29df 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -923,11 +923,7 @@ static PyStatus
calculate_program_macos(wchar_t **abs_path_p)
{
char execpath[MAXPATHLEN + 1];
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
uint32_t nsexeclength = Py_ARRAY_LENGTH(execpath) - 1;
-#else
- unsigned long nsexeclength = Py_ARRAY_LENGTH(execpath) - 1;
-#endif
/* On Mac OS X, if a script uses an interpreter of the form
"#!/opt/python2.3/bin/python", the kernel only passes "python"
diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c
index c4d16819e4..f6298ca0ee 100644
--- a/Modules/grpmodule.c
+++ b/Modules/grpmodule.c
@@ -46,20 +46,19 @@ get_grp_state(PyObject *module)
return (grpmodulestate *)state;
}
-#define modulestate_global get_grp_state(PyState_FindModule(&grpmodule))
-
static struct PyModuleDef grpmodule;
#define DEFAULT_BUFFER_SIZE 1024
static PyObject *
-mkgrent(struct group *p)
+mkgrent(PyObject *module, struct group *p)
{
int setIndex = 0;
PyObject *v, *w;
char **member;
- if ((v = PyStructSequence_New(modulestate_global->StructGrpType)) == NULL)
+ v = PyStructSequence_New(get_grp_state(module)->StructGrpType);
+ if (v == NULL)
return NULL;
if ((w = PyList_New(0)) == NULL) {
@@ -170,7 +169,7 @@ grp_getgrgid_impl(PyObject *module, PyObject *id)
Py_DECREF(gid_obj);
return NULL;
}
- retval = mkgrent(p);
+ retval = mkgrent(module, p);
#ifdef HAVE_GETGRGID_R
PyMem_RawFree(buf);
#endif
@@ -248,7 +247,7 @@ grp_getgrnam_impl(PyObject *module, PyObject *name)
}
goto out;
}
- retval = mkgrent(p);
+ retval = mkgrent(module, p);
out:
PyMem_RawFree(buf);
Py_DECREF(bytes);
@@ -275,7 +274,7 @@ grp_getgrall_impl(PyObject *module)
return NULL;
setgrent();
while ((p = getgrent()) != NULL) {
- PyObject *v = mkgrent(p);
+ PyObject *v = mkgrent(module, p);
if (v == NULL || PyList_Append(d, v) != 0) {
Py_XDECREF(v);
Py_DECREF(d);
@@ -311,6 +310,26 @@ users are not explicitly listed as members of the groups they are in\n\
according to the password database. Check both databases to get\n\
complete membership information.)");
+static int
+grpmodule_exec(PyObject *module)
+{
+ grpmodulestate *state = get_grp_state(module);
+
+ state->StructGrpType = PyStructSequence_NewType(&struct_group_type_desc);
+ if (state->StructGrpType == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(module, state->StructGrpType) < 0) {
+ return -1;
+ }
+ return 0;
+}
+
+static PyModuleDef_Slot grpmodule_slots[] = {
+ {Py_mod_exec, grpmodule_exec},
+ {0, NULL}
+};
+
static int grpmodule_traverse(PyObject *m, visitproc visit, void *arg) {
Py_VISIT(get_grp_state(m)->StructGrpType);
return 0;
@@ -326,37 +345,19 @@ static void grpmodule_free(void *m) {
}
static struct PyModuleDef grpmodule = {
- PyModuleDef_HEAD_INIT,
- "grp",
- grp__doc__,
- sizeof(grpmodulestate),
- grp_methods,
- NULL,
- grpmodule_traverse,
- grpmodule_clear,
- grpmodule_free,
+ PyModuleDef_HEAD_INIT,
+ .m_name = "grp",
+ .m_doc = grp__doc__,
+ .m_size = sizeof(grpmodulestate),
+ .m_methods = grp_methods,
+ .m_slots = grpmodule_slots,
+ .m_traverse = grpmodule_traverse,
+ .m_clear = grpmodule_clear,
+ .m_free = grpmodule_free,
};
PyMODINIT_FUNC
PyInit_grp(void)
{
- PyObject *m;
- if ((m = PyState_FindModule(&grpmodule)) != NULL) {
- Py_INCREF(m);
- return m;
- }
-
- if ((m = PyModule_Create(&grpmodule)) == NULL) {
- return NULL;
- }
-
- grpmodulestate *state = PyModule_GetState(m);
- state->StructGrpType = PyStructSequence_NewType(&struct_group_type_desc);
- if (state->StructGrpType == NULL) {
- return NULL;
- }
-
- Py_INCREF(state->StructGrpType);
- PyModule_AddObject(m, "struct_group", (PyObject *) state->StructGrpType);
- return m;
+ return PyModuleDef_Init(&grpmodule);
}
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index ce8b4347ef..293735a886 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -1,7 +1,9 @@
+
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycore_long.h" // _PyLong_GetZero()
+#include "pycore_object.h" // _PyObject_GC_TRACK()
#include "pycore_tuple.h" // _PyTuple_ITEMS()
#include <stddef.h> // offsetof()
@@ -27,8 +29,9 @@ class itertools.accumulate "accumulateobject *" "&accumulate_type"
class itertools.compress "compressobject *" "&compress_type"
class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
class itertools.count "countobject *" "&count_type"
+class itertools.pairwise "pairwiseobject *" "&pairwise_type"
[clinic start generated code]*/
-/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ea05c93c6d94726a]*/
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=6498ed21fbe1bf94]*/
static PyTypeObject groupby_type;
static PyTypeObject _grouper_type;
@@ -45,9 +48,140 @@ static PyTypeObject accumulate_type;
static PyTypeObject compress_type;
static PyTypeObject filterfalse_type;
static PyTypeObject count_type;
+static PyTypeObject pairwise_type;
#include "clinic/itertoolsmodule.c.h"
+/* pairwise object ***********************************************************/
+
+typedef struct {
+ PyObject_HEAD
+ PyObject *it;
+ PyObject *old;
+} pairwiseobject;
+
+/*[clinic input]
+@classmethod
+itertools.pairwise.__new__ as pairwise_new
+ iterable: object
+ /
+Return an iterator of overlapping pairs taken from the input iterator.
+
+ s -> (s0,s1), (s1,s2), (s2, s3), ...
+
+[clinic start generated code]*/
+
+static PyObject *
+pairwise_new_impl(PyTypeObject *type, PyObject *iterable)
+/*[clinic end generated code: output=9f0267062d384456 input=6e7c3cddb431a8d6]*/
+{
+ PyObject *it;
+ pairwiseobject *po;
+
+ it = PyObject_GetIter(iterable);
+ if (it == NULL) {
+ return NULL;
+ }
+ po = (pairwiseobject *)type->tp_alloc(type, 0);
+ if (po == NULL) {
+ Py_DECREF(it);
+ return NULL;
+ }
+ po->it = it;
+ po->old = NULL;
+ return (PyObject *)po;
+}
+
+static void
+pairwise_dealloc(pairwiseobject *po)
+{
+ PyObject_GC_UnTrack(po);
+ Py_XDECREF(po->it);
+ Py_XDECREF(po->old);
+ Py_TYPE(po)->tp_free(po);
+}
+
+static int
+pairwise_traverse(pairwiseobject *po, visitproc visit, void *arg)
+{
+ Py_VISIT(po->it);
+ Py_VISIT(po->old);
+ return 0;
+}
+
+static PyObject *
+pairwise_next(pairwiseobject *po)
+{
+ PyObject *it = po->it;
+ PyObject *old = po->old;
+ PyObject *new, *result;
+
+ if (it == NULL) {
+ return NULL;
+ }
+ if (old == NULL) {
+ po->old = old = (*Py_TYPE(it)->tp_iternext)(it);
+ if (old == NULL) {
+ Py_CLEAR(po->it);
+ return NULL;
+ }
+ }
+ new = (*Py_TYPE(it)->tp_iternext)(it);
+ if (new == NULL) {
+ Py_CLEAR(po->it);
+ Py_CLEAR(po->old);
+ return NULL;
+ }
+ /* Future optimization: Reuse the result tuple as we do in enumerate() */
+ result = PyTuple_Pack(2, old, new);
+ Py_SETREF(po->old, new);
+ return result;
+}
+
+static PyTypeObject pairwise_type = {
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ "itertools.pairwise", /* tp_name */
+ sizeof(pairwiseobject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)pairwise_dealloc, /* tp_dealloc */
+ 0, /* tp_vectorcall_offset */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_as_async */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
+ Py_TPFLAGS_BASETYPE, /* tp_flags */
+ pairwise_new__doc__, /* tp_doc */
+ (traverseproc)pairwise_traverse, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ PyObject_SelfIter, /* tp_iter */
+ (iternextfunc)pairwise_next, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ PyType_GenericAlloc, /* tp_alloc */
+ pairwise_new, /* tp_new */
+ PyObject_GC_Del, /* tp_free */
+};
+
/* groupby object ************************************************************/
@@ -2245,6 +2379,11 @@ product_next(productobject *lz)
lz->result = result;
Py_DECREF(old_result);
}
+ // bpo-42536: The GC may have untracked this result tuple. Since we're
+ // recycling it, make sure it's tracked again:
+ else if (!_PyObject_GC_IS_TRACKED(result)) {
+ _PyObject_GC_TRACK(result);
+ }
/* Now, we've got the only copy so we can update it in-place */
assert (npools==0 || Py_REFCNT(result) == 1);
@@ -2568,6 +2707,11 @@ combinations_next(combinationsobject *co)
co->result = result;
Py_DECREF(old_result);
}
+ // bpo-42536: The GC may have untracked this result tuple. Since we're
+ // recycling it, make sure it's tracked again:
+ else if (!_PyObject_GC_IS_TRACKED(result)) {
+ _PyObject_GC_TRACK(result);
+ }
/* Now, we've got the only copy so we can update it in-place
* CPython's empty tuple is a singleton and cached in
* PyTuple's freelist.
@@ -2902,6 +3046,11 @@ cwr_next(cwrobject *co)
co->result = result;
Py_DECREF(old_result);
}
+ // bpo-42536: The GC may have untracked this result tuple. Since we're
+ // recycling it, make sure it's tracked again:
+ else if (!_PyObject_GC_IS_TRACKED(result)) {
+ _PyObject_GC_TRACK(result);
+ }
/* Now, we've got the only copy so we can update it in-place CPython's
empty tuple is a singleton and cached in PyTuple's freelist. */
assert(r == 0 || Py_REFCNT(result) == 1);
@@ -3246,6 +3395,11 @@ permutations_next(permutationsobject *po)
po->result = result;
Py_DECREF(old_result);
}
+ // bpo-42536: The GC may have untracked this result tuple. Since we're
+ // recycling it, make sure it's tracked again:
+ else if (!_PyObject_GC_IS_TRACKED(result)) {
+ _PyObject_GC_TRACK(result);
+ }
/* Now, we've got the only copy so we can update it in-place */
assert(r == 0 || Py_REFCNT(result) == 1);
@@ -4516,6 +4670,11 @@ zip_longest_next(ziplongestobject *lz)
PyTuple_SET_ITEM(result, i, item);
Py_DECREF(olditem);
}
+ // bpo-42536: The GC may have untracked this result tuple. Since we're
+ // recycling it, make sure it's tracked again:
+ if (!_PyObject_GC_IS_TRACKED(result)) {
+ _PyObject_GC_TRACK(result);
+ }
} else {
result = PyTuple_New(tuplesize);
if (result == NULL)
@@ -4666,6 +4825,7 @@ groupby(iterable[, keyfunc]) --> sub-iterators grouped by value of keyfunc(v)\n\
filterfalse(pred, seq) --> elements of seq where pred(elem) is False\n\
islice(seq, [start,] stop [, step]) --> elements from\n\
seq[start:stop:step]\n\
+pairwise(s) --> (s[0],s[1]), (s[1],s[2]), (s[2], s[3]), ...\n\
starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...\n\
tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n\n\
takewhile(pred, seq) --> seq[0], seq[1], until pred fails\n\
@@ -4695,6 +4855,7 @@ itertoolsmodule_exec(PyObject *m)
&filterfalse_type,
&count_type,
&ziplongest_type,
+ &pairwise_type,
&permutations_type,
&product_type,
&repeat_type,
diff --git a/Modules/main.c b/Modules/main.c
index 2cc891f61a..ccf096352e 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -223,7 +223,7 @@ pymain_import_readline(const PyConfig *config)
static int
-pymain_run_command(wchar_t *command, PyCompilerFlags *cf)
+pymain_run_command(wchar_t *command)
{
PyObject *unicode, *bytes;
int ret;
@@ -243,7 +243,9 @@ pymain_run_command(wchar_t *command, PyCompilerFlags *cf)
goto error;
}
- ret = PyRun_SimpleStringFlags(PyBytes_AsString(bytes), cf);
+ PyCompilerFlags cf = _PyCompilerFlags_INIT;
+ cf.cf_flags |= PyCF_IGNORE_COOKIE;
+ ret = PyRun_SimpleStringFlags(PyBytes_AsString(bytes), &cf);
Py_DECREF(bytes);
return (ret != 0);
@@ -305,29 +307,23 @@ pymain_run_module(const wchar_t *modname, int set_argv0)
static int
-pymain_run_file(const PyConfig *config, PyCompilerFlags *cf)
+pymain_run_file_obj(PyObject *program_name, PyObject *filename,
+ int skip_source_first_line)
{
- const wchar_t *filename = config->run_filename;
- if (PySys_Audit("cpython.run_file", "u", filename) < 0) {
+ if (PySys_Audit("cpython.run_file", "O", filename) < 0) {
return pymain_exit_err_print();
}
- FILE *fp = _Py_wfopen(filename, L"rb");
+
+ FILE *fp = _Py_fopen_obj(filename, "rb");
if (fp == NULL) {
- char *cfilename_buffer;
- const char *cfilename;
- int err = errno;
- cfilename_buffer = _Py_EncodeLocaleRaw(filename, NULL);
- if (cfilename_buffer != NULL)
- cfilename = cfilename_buffer;
- else
- cfilename = "<unprintable file name>";
- fprintf(stderr, "%ls: can't open file '%s': [Errno %d] %s\n",
- config->program_name, cfilename, err, strerror(err));
- PyMem_RawFree(cfilename_buffer);
+ // Ignore the OSError
+ PyErr_Clear();
+ PySys_FormatStderr("%S: can't open file %R: [Errno %d] %s\n",
+ program_name, filename, errno, strerror(errno));
return 2;
}
- if (config->skip_source_first_line) {
+ if (skip_source_first_line) {
int ch;
/* Push back first newline so line numbers remain the same */
while ((ch = getc(fp)) != EOF) {
@@ -340,104 +336,97 @@ pymain_run_file(const PyConfig *config, PyCompilerFlags *cf)
struct _Py_stat_struct sb;
if (_Py_fstat_noraise(fileno(fp), &sb) == 0 && S_ISDIR(sb.st_mode)) {
- fprintf(stderr,
- "%ls: '%ls' is a directory, cannot continue\n",
- config->program_name, filename);
+ PySys_FormatStderr("%S: %R is a directory, cannot continue\n",
+ program_name, filename);
fclose(fp);
return 1;
}
- /* call pending calls like signal handlers (SIGINT) */
+ // Call pending calls like signal handlers (SIGINT)
if (Py_MakePendingCalls() == -1) {
fclose(fp);
return pymain_exit_err_print();
}
- PyObject *unicode, *bytes = NULL;
- const char *filename_str;
+ /* PyRun_AnyFileExFlags(closeit=1) calls fclose(fp) before running code */
+ PyCompilerFlags cf = _PyCompilerFlags_INIT;
+ int run = _PyRun_AnyFileObject(fp, filename, 1, &cf);
+ return (run != 0);
+}
- unicode = PyUnicode_FromWideChar(filename, wcslen(filename));
- if (unicode != NULL) {
- bytes = PyUnicode_EncodeFSDefault(unicode);
- Py_DECREF(unicode);
- }
- if (bytes != NULL) {
- filename_str = PyBytes_AsString(bytes);
+static int
+pymain_run_file(const PyConfig *config)
+{
+ PyObject *filename = PyUnicode_FromWideChar(config->run_filename, -1);
+ if (filename == NULL) {
+ PyErr_Print();
+ return -1;
}
- else {
- PyErr_Clear();
- filename_str = "<filename encoding error>";
+ PyObject *program_name = PyUnicode_FromWideChar(config->program_name, -1);
+ if (program_name == NULL) {
+ Py_DECREF(filename);
+ PyErr_Print();
+ return -1;
}
- /* PyRun_AnyFileExFlags(closeit=1) calls fclose(fp) before running code */
- int run = PyRun_AnyFileExFlags(fp, filename_str, 1, cf);
- Py_XDECREF(bytes);
- return (run != 0);
+ int res = pymain_run_file_obj(program_name, filename,
+ config->skip_source_first_line);
+ Py_DECREF(filename);
+ Py_DECREF(program_name);
+ return res;
}
static int
-pymain_run_startup(PyConfig *config, PyCompilerFlags *cf, int *exitcode)
+pymain_run_startup(PyConfig *config, int *exitcode)
{
int ret;
- PyObject *startup_obj = NULL;
if (!config->use_environment) {
return 0;
}
+ PyObject *startup = NULL;
#ifdef MS_WINDOWS
- const wchar_t *wstartup = _wgetenv(L"PYTHONSTARTUP");
- if (wstartup == NULL || wstartup[0] == L'\0') {
+ const wchar_t *env = _wgetenv(L"PYTHONSTARTUP");
+ if (env == NULL || env[0] == L'\0') {
return 0;
}
- PyObject *startup_bytes = NULL;
- startup_obj = PyUnicode_FromWideChar(wstartup, wcslen(wstartup));
- if (startup_obj == NULL) {
- goto error;
- }
- startup_bytes = PyUnicode_EncodeFSDefault(startup_obj);
- if (startup_bytes == NULL) {
+ startup = PyUnicode_FromWideChar(env, wcslen(env));
+ if (startup == NULL) {
goto error;
}
- const char *startup = PyBytes_AS_STRING(startup_bytes);
#else
- const char *startup = _Py_GetEnv(config->use_environment, "PYTHONSTARTUP");
- if (startup == NULL) {
+ const char *env = _Py_GetEnv(config->use_environment, "PYTHONSTARTUP");
+ if (env == NULL) {
return 0;
}
- startup_obj = PyUnicode_DecodeFSDefault(startup);
- if (startup_obj == NULL) {
+ startup = PyUnicode_DecodeFSDefault(env);
+ if (startup == NULL) {
goto error;
}
#endif
- if (PySys_Audit("cpython.run_startup", "O", startup_obj) < 0) {
+ if (PySys_Audit("cpython.run_startup", "O", startup) < 0) {
goto error;
}
-#ifdef MS_WINDOWS
- FILE *fp = _Py_wfopen(wstartup, L"r");
-#else
- FILE *fp = _Py_fopen(startup, "r");
-#endif
+ FILE *fp = _Py_fopen_obj(startup, "r");
if (fp == NULL) {
int save_errno = errno;
PyErr_Clear();
PySys_WriteStderr("Could not open PYTHONSTARTUP\n");
errno = save_errno;
- PyErr_SetFromErrnoWithFilenameObjects(PyExc_OSError, startup_obj, NULL);
+ PyErr_SetFromErrnoWithFilenameObjects(PyExc_OSError, startup, NULL);
goto error;
}
- (void) PyRun_SimpleFileExFlags(fp, startup, 0, cf);
+ PyCompilerFlags cf = _PyCompilerFlags_INIT;
+ (void) _PyRun_SimpleFileObject(fp, startup, 0, &cf);
PyErr_Clear();
fclose(fp);
ret = 0;
done:
-#ifdef MS_WINDOWS
- Py_XDECREF(startup_bytes);
-#endif
- Py_XDECREF(startup_obj);
+ Py_XDECREF(startup);
return ret;
error:
@@ -484,14 +473,14 @@ error:
static int
-pymain_run_stdin(PyConfig *config, PyCompilerFlags *cf)
+pymain_run_stdin(PyConfig *config)
{
if (stdin_is_interactive(config)) {
config->inspect = 0;
Py_InspectFlag = 0; /* do exit on SystemExit */
int exitcode;
- if (pymain_run_startup(config, cf, &exitcode)) {
+ if (pymain_run_startup(config, &exitcode)) {
return exitcode;
}
@@ -509,13 +498,14 @@ pymain_run_stdin(PyConfig *config, PyCompilerFlags *cf)
return pymain_exit_err_print();
}
- int run = PyRun_AnyFileExFlags(stdin, "<stdin>", 0, cf);
+ PyCompilerFlags cf = _PyCompilerFlags_INIT;
+ int run = PyRun_AnyFileExFlags(stdin, "<stdin>", 0, &cf);
return (run != 0);
}
static void
-pymain_repl(PyConfig *config, PyCompilerFlags *cf, int *exitcode)
+pymain_repl(PyConfig *config, int *exitcode)
{
/* Check this environment variable at the end, to give programs the
opportunity to set it from Python. */
@@ -534,7 +524,8 @@ pymain_repl(PyConfig *config, PyCompilerFlags *cf, int *exitcode)
return;
}
- int res = PyRun_AnyFileFlags(stdin, "<stdin>", cf);
+ PyCompilerFlags cf = _PyCompilerFlags_INIT;
+ int res = PyRun_AnyFileFlags(stdin, "<stdin>", &cf);
*exitcode = (res != 0);
}
@@ -580,13 +571,11 @@ pymain_run_python(int *exitcode)
}
}
- PyCompilerFlags cf = _PyCompilerFlags_INIT;
-
pymain_header(config);
pymain_import_readline(config);
if (config->run_command) {
- *exitcode = pymain_run_command(config->run_command, &cf);
+ *exitcode = pymain_run_command(config->run_command);
}
else if (config->run_module) {
*exitcode = pymain_run_module(config->run_module, 1);
@@ -595,13 +584,13 @@ pymain_run_python(int *exitcode)
*exitcode = pymain_run_module(L"__main__", 0);
}
else if (config->run_filename != NULL) {
- *exitcode = pymain_run_file(config, &cf);
+ *exitcode = pymain_run_file(config);
}
else {
- *exitcode = pymain_run_stdin(config, &cf);
+ *exitcode = pymain_run_stdin(config);
}
- pymain_repl(config, &cf, exitcode);
+ pymain_repl(config, exitcode);
goto done;
error:
diff --git a/Modules/makexp_aix b/Modules/makexp_aix
index cb349c2875..b39d93b682 100755
--- a/Modules/makexp_aix
+++ b/Modules/makexp_aix
@@ -3,7 +3,7 @@
# ===========================================================================
# FILE: makexp_aix
# TYPE: standalone executable
-# SYSTEM: AIX 3.2.5 and AIX 4
+# SYSTEM: AIX
#
# DESCRIPTION: This script creates an export list of ALL global symbols
# from a list of object or archive files.
@@ -48,34 +48,24 @@ echo "*" >> $expFileName
echo "* $notemsg" >> $expFileName
echo "*" >> $expFileName
-# Extract the symbol list using 'nm' which produces quite
-# different output under AIX 4 than under AIX 3.2.5.
-# The following handles both versions by using a common flagset.
+# Extract the symbol list using 'nm'
# Here are some hidden tricks:
-# 1. Use /usr/ccs/bin/nm. Relevant to AIX 3.2.5 which has
-# another version under /usr/ucb/bin/nm.
-# 2. Use the -B flag to have a standard BSD representation
-# of the symbol list on both AIX 3.2.5 and AIX 4. The "-B"
-# flag is missing in the AIX 3.2.5 online usage help of 'nm'.
-# 3. Use the -x flag to have a hex representation of the symbol
-# values. This fills the leading whitespaces on AIX 4,
-# thus simplifying the sed statement.
-# 4. Eliminate all entries except those with either "B", "D"
-# or "T" key letters. We are interested only in the global
-# (extern) BSS, DATA and TEXT symbols. With the same statement
-# we eliminate object member lines relevant to AIX 4.
-# 5. Eliminate entries containing a dot. We can have a dot only
-# as a symbol prefix, but such symbols are undefined externs.
-# 6. Eliminate everything including the key letter, so that we're
-# left with just the symbol name.
-# 7. Eliminate all entries containing two colons, like Class::method
+# - Use the -B flag to have a standard BSD representation
+# of the symbol list.
+# - Use the -x flag to have a hex representation of the symbol
+# values. This fills the leading whitespaces, thus simplifying
+# the sed statement.
+# - Eliminate all entries except those with either "B", "D"
+# or "T" key letters. We are interested only in the global
+# (extern) BSS, DATA and TEXT symbols. With the same statement
+# we eliminate object member lines relevant to AIX 4.
+# - Eliminate entries containing a dot. We can have a dot only
+# as a symbol prefix, but such symbols are undefined externs.
+# - Eliminate everything including the key letter, so that we're
+# left with just the symbol name.
+# - Eliminate all entries containing two colons, like Class::method
#
-# Use -X32_64 if it appears to be implemented in this version of 'nm'.
-NM=/usr/ccs/bin/nm
-xopt=-X32_64
-$NM -e $xopt $1 >/dev/null 2>&1 || xopt=""
-
-$NM -Bex $xopt $inputFiles \
+/usr/ccs/bin/nm -Bex -X32_64 $inputFiles \
| sed -e '/ [^BDT] /d' -e '/\./d' -e 's/.* [BDT] //' -e '/::/d' \
| sort | uniq >> $expFileName
diff --git a/Modules/md5module.c b/Modules/md5module.c
index 9bd2bd17e4..1c401e8843 100644
--- a/Modules/md5module.c
+++ b/Modules/md5module.c
@@ -342,7 +342,7 @@ static void
MD5_dealloc(PyObject *ptr)
{
PyTypeObject *tp = Py_TYPE(ptr);
- PyObject_Del(ptr);
+ PyObject_Free(ptr);
Py_DECREF(tp);
}
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 1e9684970f..1e66962d37 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -1667,6 +1667,14 @@ mmap_exec(PyObject *module)
#ifdef MADV_PROTECT
ADD_INT_MACRO(module, MADV_PROTECT);
#endif
+
+ // Darwin-specific
+#ifdef MADV_FREE_REUSABLE // (As MADV_FREE but reclaims more faithful for task_info/Activity Monitor...)
+ ADD_INT_MACRO(module, MADV_FREE_REUSABLE);
+#endif
+#ifdef MADV_FREE_REUSE // (Reuse pages previously tagged as reusable)
+ ADD_INT_MACRO(module, MADV_FREE_REUSE);
+#endif
#endif // HAVE_MADVISE
return 0;
}
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c
index 2a1ac10814..4f2d9cb8b7 100644
--- a/Modules/ossaudiodev.c
+++ b/Modules/ossaudiodev.c
@@ -154,7 +154,7 @@ oss_dealloc(oss_audio_t *self)
/* if already closed, don't reclose it */
if (self->fd != -1)
close(self->fd);
- PyObject_Del(self);
+ PyObject_Free(self);
}
@@ -199,7 +199,7 @@ oss_mixer_dealloc(oss_mixer_t *self)
/* if already closed, don't reclose it */
if (self->fd != -1)
close(self->fd);
- PyObject_Del(self);
+ PyObject_Free(self);
}
diff --git a/Modules/overlapped.c b/Modules/overlapped.c
index 3829932070..38dd98f084 100644
--- a/Modules/overlapped.c
+++ b/Modules/overlapped.c
@@ -722,7 +722,7 @@ Overlapped_dealloc(OverlappedObject *self)
SetLastError(olderr);
PyTypeObject *tp = Py_TYPE(self);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(tp);
}
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 203f98515d..d9eb62f20e 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7,18 +7,6 @@
of the compiler used. Different compilers define their own feature
test macro, e.g. '_MSC_VER'. */
-#ifdef __APPLE__
- /*
- * Step 1 of support for weak-linking a number of symbols existing on
- * OSX 10.4 and later, see the comment in the #ifdef __APPLE__ block
- * at the end of this file for more information.
- */
-# pragma weak lchown
-# pragma weak statvfs
-# pragma weak fstatvfs
-
-#endif /* __APPLE__ */
-
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -55,6 +43,127 @@
#include <stdio.h> /* needed for ctermid() */
+/*
+ * A number of APIs are available on macOS from a certain macOS version.
+ * To support building with a new SDK while deploying to older versions
+ * the availability test is split into two:
+ * - HAVE_<FUNCTION>: The configure check for compile time availability
+ * - HAVE_<FUNCTION>_RUNTIME: Runtime check for availability
+ *
+ * The latter is always true when not on macOS, or when using a compiler
+ * that does not support __has_builtin (older versions of Xcode).
+ *
+ * Due to compiler restrictions there is one valid use of HAVE_<FUNCTION>_RUNTIME:
+ * if (HAVE_<FUNCTION>_RUNTIME) { ... }
+ *
+ * In mixing the test with other tests or using negations will result in compile
+ * errors.
+ */
+#if defined(__APPLE__)
+
+#if defined(__has_builtin) && __has_builtin(__builtin_available)
+# define HAVE_FSTATAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
+# define HAVE_FACCESSAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
+# define HAVE_FCHMODAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
+# define HAVE_FCHOWNAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
+# define HAVE_LINKAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
+# define HAVE_FDOPENDIR_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
+# define HAVE_MKDIRAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
+# define HAVE_RENAMEAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
+# define HAVE_UNLINKAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
+# define HAVE_OPENAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
+# define HAVE_READLINKAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
+# define HAVE_SYMLINKAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
+# define HAVE_FUTIMENS_RUNTIME __builtin_available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *)
+# define HAVE_UTIMENSAT_RUNTIME __builtin_available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *)
+# define HAVE_PWRITEV_RUNTIME __builtin_available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *)
+
+# define HAVE_POSIX_SPAWN_SETSID_RUNTIME __builtin_available(macOS 10.15, *)
+
+#else /* Xcode 8 or earlier */
+
+ /* __builtin_available is not present in these compilers, but
+ * some of the symbols might be weak linked (10.10 SDK or later
+ * deploying on 10.9.
+ *
+ * Fall back to the older style of availability checking for
+ * symbols introduced in macOS 10.10.
+ */
+
+# ifdef HAVE_FSTATAT
+# define HAVE_FSTATAT_RUNTIME (fstatat != NULL)
+# endif
+
+# ifdef HAVE_FACCESSAT
+# define HAVE_FACCESSAT_RUNTIME (faccessat != NULL)
+# endif
+
+# ifdef HAVE_FCHMODAT
+# define HAVE_FCHMODAT_RUNTIME (fchmodat != NULL)
+# endif
+
+# ifdef HAVE_FCHOWNAT
+# define HAVE_FCHOWNAT_RUNTIME (fchownat != NULL)
+# endif
+
+# ifdef HAVE_LINKAT
+# define HAVE_LINKAT_RUNTIME (linkat != NULL)
+# endif
+
+# ifdef HAVE_FDOPENDIR
+# define HAVE_FDOPENDIR_RUNTIME (fdopendir != NULL)
+# endif
+
+# ifdef HAVE_MKDIRAT
+# define HAVE_MKDIRAT_RUNTIME (mkdirat != NULL)
+# endif
+
+# ifdef HAVE_RENAMEAT
+# define HAVE_RENAMEAT_RUNTIME (renameat != NULL)
+# endif
+
+# ifdef HAVE_UNLINKAT
+# define HAVE_UNLINKAT_RUNTIME (unlinkat != NULL)
+# endif
+
+# ifdef HAVE_OPENAT
+# define HAVE_OPENAT_RUNTIME (openat != NULL)
+# endif
+
+# ifdef HAVE_READLINKAT
+# define HAVE_READLINKAT_RUNTIME (readlinkat != NULL)
+# endif
+
+# ifdef HAVE_SYMLINKAT
+# define HAVE_SYMLINKAT_RUNTIME (symlinkat != NULL)
+# endif
+
+#endif
+
+#ifdef HAVE_FUTIMESAT
+/* Some of the logic for weak linking depends on this assertion */
+# error "HAVE_FUTIMESAT unexpectedly defined"
+#endif
+
+#else
+# define HAVE_FSTATAT_RUNTIME 1
+# define HAVE_FACCESSAT_RUNTIME 1
+# define HAVE_FCHMODAT_RUNTIME 1
+# define HAVE_FCHOWNAT_RUNTIME 1
+# define HAVE_LINKAT_RUNTIME 1
+# define HAVE_FDOPENDIR_RUNTIME 1
+# define HAVE_MKDIRAT_RUNTIME 1
+# define HAVE_RENAMEAT_RUNTIME 1
+# define HAVE_UNLINKAT_RUNTIME 1
+# define HAVE_OPENAT_RUNTIME 1
+# define HAVE_READLINKAT_RUNTIME 1
+# define HAVE_SYMLINKAT_RUNTIME 1
+# define HAVE_FUTIMENS_RUNTIME 1
+# define HAVE_UTIMENSAT_RUNTIME 1
+# define HAVE_PWRITEV_RUNTIME 1
+#endif
+
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -409,6 +518,11 @@ extern char *ctermid_r(char *);
# include <linux/memfd.h>
#endif
+/* eventfd() */
+#ifdef HAVE_SYS_EVENTFD_H
+# include <sys/eventfd.h>
+#endif
+
#ifdef _Py_MEMORY_SANITIZER
# include <sanitizer/msan_interface.h>
#endif
@@ -2360,6 +2474,10 @@ posix_do_stat(PyObject *module, const char *function_name, path_t *path,
STRUCT_STAT st;
int result;
+#ifdef HAVE_FSTATAT
+ int fstatat_unavailable = 0;
+#endif
+
#if !defined(MS_WINDOWS) && !defined(HAVE_FSTATAT) && !defined(HAVE_LSTAT)
if (follow_symlinks_specified(function_name, follow_symlinks))
return NULL;
@@ -2386,15 +2504,27 @@ posix_do_stat(PyObject *module, const char *function_name, path_t *path,
else
#endif /* HAVE_LSTAT */
#ifdef HAVE_FSTATAT
- if ((dir_fd != DEFAULT_DIR_FD) || !follow_symlinks)
- result = fstatat(dir_fd, path->narrow, &st,
+ if ((dir_fd != DEFAULT_DIR_FD) || !follow_symlinks) {
+ if (HAVE_FSTATAT_RUNTIME) {
+ result = fstatat(dir_fd, path->narrow, &st,
follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW);
- else
+
+ } else {
+ fstatat_unavailable = 1;
+ }
+ } else
#endif /* HAVE_FSTATAT */
result = STAT(path->narrow, &st);
#endif /* MS_WINDOWS */
Py_END_ALLOW_THREADS
+#ifdef HAVE_FSTATAT
+ if (fstatat_unavailable) {
+ argument_unavailable_error("stat", "dir_fd");
+ return NULL;
+ }
+#endif
+
if (result != 0) {
return path_error(path);
}
@@ -2808,6 +2938,10 @@ os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd,
int result;
#endif
+#ifdef HAVE_FACCESSAT
+ int faccessat_unavailable = 0;
+#endif
+
#ifndef HAVE_FACCESSAT
if (follow_symlinks_specified("access", follow_symlinks))
return -1;
@@ -2842,17 +2976,40 @@ os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd,
if ((dir_fd != DEFAULT_DIR_FD) ||
effective_ids ||
!follow_symlinks) {
- int flags = 0;
- if (!follow_symlinks)
- flags |= AT_SYMLINK_NOFOLLOW;
- if (effective_ids)
- flags |= AT_EACCESS;
- result = faccessat(dir_fd, path->narrow, mode, flags);
+
+ if (HAVE_FACCESSAT_RUNTIME) {
+ int flags = 0;
+ if (!follow_symlinks)
+ flags |= AT_SYMLINK_NOFOLLOW;
+ if (effective_ids)
+ flags |= AT_EACCESS;
+ result = faccessat(dir_fd, path->narrow, mode, flags);
+ } else {
+ faccessat_unavailable = 1;
+ }
}
else
#endif
result = access(path->narrow, mode);
Py_END_ALLOW_THREADS
+
+#ifdef HAVE_FACCESSAT
+ if (faccessat_unavailable) {
+ if (dir_fd != DEFAULT_DIR_FD) {
+ argument_unavailable_error("access", "dir_fd");
+ return -1;
+ }
+ if (follow_symlinks_specified("access", follow_symlinks))
+ return -1;
+
+ if (effective_ids) {
+ argument_unavailable_error("access", "effective_ids");
+ return -1;
+ }
+ /* should be unreachable */
+ return -1;
+ }
+#endif
return_value = !result;
#endif
@@ -3050,6 +3207,7 @@ os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
#ifdef HAVE_FCHMODAT
int fchmodat_nofollow_unsupported = 0;
+ int fchmodat_unsupported = 0;
#endif
#if !(defined(HAVE_FCHMODAT) || defined(HAVE_LCHMOD))
@@ -3085,42 +3243,56 @@ os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
if (path->fd != -1)
result = fchmod(path->fd, mode);
else
-#endif
+#endif /* HAVE_CHMOD */
#ifdef HAVE_LCHMOD
if ((!follow_symlinks) && (dir_fd == DEFAULT_DIR_FD))
result = lchmod(path->narrow, mode);
else
-#endif
+#endif /* HAVE_LCHMOD */
#ifdef HAVE_FCHMODAT
if ((dir_fd != DEFAULT_DIR_FD) || !follow_symlinks) {
- /*
- * fchmodat() doesn't currently support AT_SYMLINK_NOFOLLOW!
- * The documentation specifically shows how to use it,
- * and then says it isn't implemented yet.
- * (true on linux with glibc 2.15, and openindiana 3.x)
- *
- * Once it is supported, os.chmod will automatically
- * support dir_fd and follow_symlinks=False. (Hopefully.)
- * Until then, we need to be careful what exception we raise.
- */
- result = fchmodat(dir_fd, path->narrow, mode,
- follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW);
- /*
- * But wait! We can't throw the exception without allowing threads,
- * and we can't do that in this nested scope. (Macro trickery, sigh.)
- */
- fchmodat_nofollow_unsupported =
- result &&
- ((errno == ENOTSUP) || (errno == EOPNOTSUPP)) &&
- !follow_symlinks;
+ if (HAVE_FCHMODAT_RUNTIME) {
+ /*
+ * fchmodat() doesn't currently support AT_SYMLINK_NOFOLLOW!
+ * The documentation specifically shows how to use it,
+ * and then says it isn't implemented yet.
+ * (true on linux with glibc 2.15, and openindiana 3.x)
+ *
+ * Once it is supported, os.chmod will automatically
+ * support dir_fd and follow_symlinks=False. (Hopefully.)
+ * Until then, we need to be careful what exception we raise.
+ */
+ result = fchmodat(dir_fd, path->narrow, mode,
+ follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW);
+ /*
+ * But wait! We can't throw the exception without allowing threads,
+ * and we can't do that in this nested scope. (Macro trickery, sigh.)
+ */
+ fchmodat_nofollow_unsupported =
+ result &&
+ ((errno == ENOTSUP) || (errno == EOPNOTSUPP)) &&
+ !follow_symlinks;
+ } else {
+ fchmodat_unsupported = 1;
+ fchmodat_nofollow_unsupported = 1;
+
+ result = -1;
+ }
}
else
-#endif
+#endif /* HAVE_FHCMODAT */
result = chmod(path->narrow, mode);
Py_END_ALLOW_THREADS
if (result) {
#ifdef HAVE_FCHMODAT
+ if (fchmodat_unsupported) {
+ if (dir_fd != DEFAULT_DIR_FD) {
+ argument_unavailable_error("chmod", "dir_fd");
+ return NULL;
+ }
+ }
+
if (fchmodat_nofollow_unsupported) {
if (dir_fd != DEFAULT_DIR_FD)
dir_fd_and_follow_symlinks_invalid("chmod",
@@ -3130,10 +3302,10 @@ os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
return NULL;
}
else
-#endif
+#endif /* HAVE_FCHMODAT */
return path_error(path);
}
-#endif
+#endif /* MS_WINDOWS */
Py_RETURN_NONE;
}
@@ -3421,6 +3593,10 @@ os_chown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid,
{
int result;
+#if defined(HAVE_FCHOWNAT)
+ int fchownat_unsupported = 0;
+#endif
+
#if !(defined(HAVE_LCHOWN) || defined(HAVE_FCHOWNAT))
if (follow_symlinks_specified("chown", follow_symlinks))
return NULL;
@@ -3429,19 +3605,6 @@ os_chown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid,
fd_and_follow_symlinks_invalid("chown", path->fd, follow_symlinks))
return NULL;
-#ifdef __APPLE__
- /*
- * This is for Mac OS X 10.3, which doesn't have lchown.
- * (But we still have an lchown symbol because of weak-linking.)
- * It doesn't have fchownat either. So there's no possibility
- * of a graceful failover.
- */
- if ((!follow_symlinks) && (lchown == NULL)) {
- follow_symlinks_specified("chown", follow_symlinks);
- return NULL;
- }
-#endif
-
if (PySys_Audit("os.chown", "OIIi", path->object, uid, gid,
dir_fd == DEFAULT_DIR_FD ? -1 : dir_fd) < 0) {
return NULL;
@@ -3459,14 +3622,28 @@ os_chown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid,
else
#endif
#ifdef HAVE_FCHOWNAT
- if ((dir_fd != DEFAULT_DIR_FD) || (!follow_symlinks))
+ if ((dir_fd != DEFAULT_DIR_FD) || (!follow_symlinks)) {
+ if (HAVE_FCHOWNAT_RUNTIME) {
result = fchownat(dir_fd, path->narrow, uid, gid,
follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW);
- else
+ } else {
+ fchownat_unsupported = 1;
+ }
+ } else
#endif
result = chown(path->narrow, uid, gid);
Py_END_ALLOW_THREADS
+#ifdef HAVE_FCHOWNAT
+ if (fchownat_unsupported) {
+ /* This would be incorrect if the current platform
+ * doesn't support lchown.
+ */
+ argument_unavailable_error(NULL, "dir_fd");
+ return NULL;
+ }
+#endif
+
if (result)
return path_error(path);
@@ -3712,6 +3889,9 @@ os_link_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd,
#else
int result;
#endif
+#if defined(HAVE_LINKAT)
+ int linkat_unavailable = 0;
+#endif
#ifndef HAVE_LINKAT
if ((src_dir_fd != DEFAULT_DIR_FD) || (dst_dir_fd != DEFAULT_DIR_FD)) {
@@ -3746,15 +3926,43 @@ os_link_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd,
#ifdef HAVE_LINKAT
if ((src_dir_fd != DEFAULT_DIR_FD) ||
(dst_dir_fd != DEFAULT_DIR_FD) ||
- (!follow_symlinks))
- result = linkat(src_dir_fd, src->narrow,
- dst_dir_fd, dst->narrow,
- follow_symlinks ? AT_SYMLINK_FOLLOW : 0);
+ (!follow_symlinks)) {
+
+ if (HAVE_LINKAT_RUNTIME) {
+
+ result = linkat(src_dir_fd, src->narrow,
+ dst_dir_fd, dst->narrow,
+ follow_symlinks ? AT_SYMLINK_FOLLOW : 0);
+
+ }
+#ifdef __APPLE__
+ else {
+ if (src_dir_fd == DEFAULT_DIR_FD && dst_dir_fd == DEFAULT_DIR_FD) {
+ /* See issue 41355: This matches the behaviour of !HAVE_LINKAT */
+ result = link(src->narrow, dst->narrow);
+ } else {
+ linkat_unavailable = 1;
+ }
+ }
+#endif
+ }
else
#endif /* HAVE_LINKAT */
result = link(src->narrow, dst->narrow);
Py_END_ALLOW_THREADS
+#ifdef HAVE_LINKAT
+ if (linkat_unavailable) {
+ /* Either or both dir_fd arguments were specified */
+ if (src_dir_fd != DEFAULT_DIR_FD) {
+ argument_unavailable_error("link", "src_dir_fd");
+ } else {
+ argument_unavailable_error("link", "dst_dir_fd");
+ }
+ return NULL;
+ }
+#endif
+
if (result)
return path_error2(src, dst);
#endif /* MS_WINDOWS */
@@ -3877,6 +4085,7 @@ _posix_listdir(path_t *path, PyObject *list)
errno = 0;
#ifdef HAVE_FDOPENDIR
if (path->fd != -1) {
+ if (HAVE_FDOPENDIR_RUNTIME) {
/* closedir() closes the FD, so we duplicate it */
fd = _Py_dup(path->fd);
if (fd == -1)
@@ -3887,6 +4096,11 @@ _posix_listdir(path_t *path, PyObject *list)
Py_BEGIN_ALLOW_THREADS
dirp = fdopendir(fd);
Py_END_ALLOW_THREADS
+ } else {
+ PyErr_SetString(PyExc_TypeError,
+ "listdir: path should be string, bytes, os.PathLike or None, not int");
+ return NULL;
+ }
}
else
#endif
@@ -4200,6 +4414,9 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd)
/*[clinic end generated code: output=a70446903abe821f input=e965f68377e9b1ce]*/
{
int result;
+#ifdef HAVE_MKDIRAT
+ int mkdirat_unavailable = 0;
+#endif
if (PySys_Audit("os.mkdir", "Oii", path->object, mode,
dir_fd == DEFAULT_DIR_FD ? -1 : dir_fd) < 0) {
@@ -4216,9 +4433,14 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd)
#else
Py_BEGIN_ALLOW_THREADS
#if HAVE_MKDIRAT
- if (dir_fd != DEFAULT_DIR_FD)
+ if (dir_fd != DEFAULT_DIR_FD) {
+ if (HAVE_MKDIRAT_RUNTIME) {
result = mkdirat(dir_fd, path->narrow, mode);
- else
+
+ } else {
+ mkdirat_unavailable = 1;
+ }
+ } else
#endif
#if defined(__WATCOMC__) && !defined(__QNX__)
result = mkdir(path->narrow);
@@ -4226,6 +4448,14 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd)
result = mkdir(path->narrow, mode);
#endif
Py_END_ALLOW_THREADS
+
+#if HAVE_MKDIRAT
+ if (mkdirat_unavailable) {
+ argument_unavailable_error(NULL, "dir_fd");
+ return NULL;
+ }
+#endif
+
if (result < 0)
return path_error(path);
#endif /* MS_WINDOWS */
@@ -4335,6 +4565,10 @@ internal_rename(path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd, int is
const char *function_name = is_replace ? "replace" : "rename";
int dir_fd_specified;
+#ifdef HAVE_RENAMEAT
+ int renameat_unavailable = 0;
+#endif
+
#ifdef MS_WINDOWS
BOOL result;
int flags = is_replace ? MOVEFILE_REPLACE_EXISTING : 0;
@@ -4374,13 +4608,25 @@ internal_rename(path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd, int is
Py_BEGIN_ALLOW_THREADS
#ifdef HAVE_RENAMEAT
- if (dir_fd_specified)
- result = renameat(src_dir_fd, src->narrow, dst_dir_fd, dst->narrow);
- else
+ if (dir_fd_specified) {
+ if (HAVE_RENAMEAT_RUNTIME) {
+ result = renameat(src_dir_fd, src->narrow, dst_dir_fd, dst->narrow);
+ } else {
+ renameat_unavailable = 1;
+ }
+ } else
#endif
result = rename(src->narrow, dst->narrow);
Py_END_ALLOW_THREADS
+
+#ifdef HAVE_RENAMEAT
+ if (renameat_unavailable) {
+ argument_unavailable_error(function_name, "src_dir_fd and dst_dir_fd");
+ return NULL;
+ }
+#endif
+
if (result)
return path_error2(src, dst);
#endif
@@ -4456,6 +4702,9 @@ os_rmdir_impl(PyObject *module, path_t *path, int dir_fd)
/*[clinic end generated code: output=080eb54f506e8301 input=38c8b375ca34a7e2]*/
{
int result;
+#ifdef HAVE_UNLINKAT
+ int unlinkat_unavailable = 0;
+#endif
if (PySys_Audit("os.rmdir", "Oi", path->object,
dir_fd == DEFAULT_DIR_FD ? -1 : dir_fd) < 0) {
@@ -4468,14 +4717,26 @@ os_rmdir_impl(PyObject *module, path_t *path, int dir_fd)
result = !RemoveDirectoryW(path->wide);
#else
#ifdef HAVE_UNLINKAT
- if (dir_fd != DEFAULT_DIR_FD)
+ if (dir_fd != DEFAULT_DIR_FD) {
+ if (HAVE_UNLINKAT_RUNTIME) {
result = unlinkat(dir_fd, path->narrow, AT_REMOVEDIR);
- else
+ } else {
+ unlinkat_unavailable = 1;
+ result = -1;
+ }
+ } else
#endif
result = rmdir(path->narrow);
#endif
Py_END_ALLOW_THREADS
+#ifdef HAVE_UNLINKAT
+ if (unlinkat_unavailable) {
+ argument_unavailable_error("rmdir", "dir_fd");
+ return NULL;
+ }
+#endif
+
if (result)
return path_error(path);
@@ -4619,6 +4880,9 @@ os_unlink_impl(PyObject *module, path_t *path, int dir_fd)
/*[clinic end generated code: output=621797807b9963b1 input=d7bcde2b1b2a2552]*/
{
int result;
+#ifdef HAVE_UNLINKAT
+ int unlinkat_unavailable = 0;
+#endif
if (PySys_Audit("os.remove", "Oi", path->object,
dir_fd == DEFAULT_DIR_FD ? -1 : dir_fd) < 0) {
@@ -4632,15 +4896,27 @@ os_unlink_impl(PyObject *module, path_t *path, int dir_fd)
result = !Py_DeleteFileW(path->wide);
#else
#ifdef HAVE_UNLINKAT
- if (dir_fd != DEFAULT_DIR_FD)
+ if (dir_fd != DEFAULT_DIR_FD) {
+ if (HAVE_UNLINKAT_RUNTIME) {
+
result = unlinkat(dir_fd, path->narrow, 0);
- else
+ } else {
+ unlinkat_unavailable = 1;
+ }
+ } else
#endif /* HAVE_UNLINKAT */
result = unlink(path->narrow);
#endif
_Py_END_SUPPRESS_IPH
Py_END_ALLOW_THREADS
+#ifdef HAVE_UNLINKAT
+ if (unlinkat_unavailable) {
+ argument_unavailable_error(NULL, "dir_fd");
+ return NULL;
+ }
+#endif
+
if (result)
return path_error(path);
@@ -4811,7 +5087,16 @@ typedef struct {
static int
utime_dir_fd(utime_t *ut, int dir_fd, const char *path, int follow_symlinks)
{
-#ifdef HAVE_UTIMENSAT
+#if defined(__APPLE__) && defined(HAVE_UTIMENSAT)
+ if (HAVE_UTIMENSAT_RUNTIME) {
+ int flags = follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW;
+ UTIME_TO_TIMESPEC;
+ return utimensat(dir_fd, path, time, flags);
+ } else {
+ errno = ENOSYS;
+ return -1;
+ }
+#elif defined(HAVE_UTIMENSAT)
int flags = follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW;
UTIME_TO_TIMESPEC;
return utimensat(dir_fd, path, time, flags);
@@ -4838,11 +5123,30 @@ static int
utime_fd(utime_t *ut, int fd)
{
#ifdef HAVE_FUTIMENS
+
+ if (HAVE_FUTIMENS_RUNTIME) {
+
UTIME_TO_TIMESPEC;
return futimens(fd, time);
-#else
+
+ } else
+#ifndef HAVE_FUTIMES
+ {
+ /* Not sure if this can happen */
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "neither futimens nor futimes are supported"
+ " on this system");
+ return -1;
+ }
+#endif
+
+#endif
+#ifdef HAVE_FUTIMES
+ {
UTIME_TO_TIMEVAL;
return futimes(fd, time);
+ }
#endif
}
@@ -4861,11 +5165,27 @@ static int
utime_nofollow_symlinks(utime_t *ut, const char *path)
{
#ifdef HAVE_UTIMENSAT
- UTIME_TO_TIMESPEC;
- return utimensat(DEFAULT_DIR_FD, path, time, AT_SYMLINK_NOFOLLOW);
-#else
+ if (HAVE_UTIMENSAT_RUNTIME) {
+ UTIME_TO_TIMESPEC;
+ return utimensat(DEFAULT_DIR_FD, path, time, AT_SYMLINK_NOFOLLOW);
+ } else
+#ifndef HAVE_LUTIMES
+ {
+ /* Not sure if this can happen */
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "neither utimensat nor lutimes are supported"
+ " on this system");
+ return -1;
+ }
+#endif
+#endif
+
+#ifdef HAVE_LUTIMES
+ {
UTIME_TO_TIMEVAL;
return lutimes(path, time);
+ }
#endif
}
@@ -4876,7 +5196,15 @@ utime_nofollow_symlinks(utime_t *ut, const char *path)
static int
utime_default(utime_t *ut, const char *path)
{
-#ifdef HAVE_UTIMENSAT
+#if defined(__APPLE__) && defined(HAVE_UTIMENSAT)
+ if (HAVE_UTIMENSAT_RUNTIME) {
+ UTIME_TO_TIMESPEC;
+ return utimensat(DEFAULT_DIR_FD, path, time, 0);
+ } else {
+ UTIME_TO_TIMEVAL;
+ return utimes(path, time);
+ }
+#elif defined(HAVE_UTIMENSAT)
UTIME_TO_TIMESPEC;
return utimensat(DEFAULT_DIR_FD, path, time, 0);
#elif defined(HAVE_UTIMES)
@@ -5085,9 +5413,10 @@ os_utime_impl(PyObject *module, path_t *path, PyObject *times, PyObject *ns,
#endif
#if defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMENSAT)
- if ((dir_fd != DEFAULT_DIR_FD) || (!follow_symlinks))
+ if ((dir_fd != DEFAULT_DIR_FD) || (!follow_symlinks)) {
result = utime_dir_fd(&utime, dir_fd, path->narrow, follow_symlinks);
- else
+
+ } else
#endif
#if defined(HAVE_FUTIMES) || defined(HAVE_FUTIMENS)
@@ -5100,6 +5429,14 @@ os_utime_impl(PyObject *module, path_t *path, PyObject *times, PyObject *ns,
Py_END_ALLOW_THREADS
+#if defined(__APPLE__) && defined(HAVE_UTIMENSAT)
+ /* See utime_dir_fd implementation */
+ if (result == -1 && errno == ENOSYS) {
+ argument_unavailable_error(NULL, "dir_fd");
+ return NULL;
+ }
+#endif
+
if (result < 0) {
/* see previous comment about not putting filename in error here */
posix_error();
@@ -5143,7 +5480,7 @@ free_string_array(EXECV_CHAR **array, Py_ssize_t count)
Py_ssize_t i;
for (i = 0; i < count; i++)
PyMem_Free(array[i]);
- PyMem_DEL(array);
+ PyMem_Free(array);
}
static int
@@ -5498,6 +5835,9 @@ parse_posix_spawn_flags(PyObject *module, const char *func_name, PyObject *setpg
}
if (setsid) {
+#ifdef HAVE_POSIX_SPAWN_SETSID_RUNTIME
+ if (HAVE_POSIX_SPAWN_SETSID_RUNTIME) {
+#endif
#ifdef POSIX_SPAWN_SETSID
all_flags |= POSIX_SPAWN_SETSID;
#elif defined(POSIX_SPAWN_SETSID_NP)
@@ -5506,6 +5846,14 @@ parse_posix_spawn_flags(PyObject *module, const char *func_name, PyObject *setpg
argument_unavailable_error(func_name, "setsid");
return -1;
#endif
+
+#ifdef HAVE_POSIX_SPAWN_SETSID_RUNTIME
+ } else {
+ argument_unavailable_error(func_name, "setsid");
+ return -1;
+ }
+#endif /* HAVE_POSIX_SPAWN_SETSID_RUNTIME */
+
}
if (setsigmask) {
@@ -6162,9 +6510,10 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
res = Py_BuildValue(_Py_PARSE_INTPTR, spawnval);
fail_2:
- while (--envc >= 0)
- PyMem_DEL(envlist[envc]);
- PyMem_DEL(envlist);
+ while (--envc >= 0) {
+ PyMem_Free(envlist[envc]);
+ }
+ PyMem_Free(envlist);
fail_1:
free_string_array(argvlist, lastarg);
fail_0:
@@ -6173,7 +6522,6 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
#endif /* HAVE_SPAWNV */
-
#ifdef HAVE_FORK
/* Helper function to validate arguments.
@@ -7097,7 +7445,7 @@ os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid)
list = PyList_New(ngroups);
if (list == NULL) {
- PyMem_Del(groups);
+ PyMem_Free(groups);
return NULL;
}
@@ -7109,13 +7457,13 @@ os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid)
#endif
if (o == NULL) {
Py_DECREF(list);
- PyMem_Del(groups);
+ PyMem_Free(groups);
return NULL;
}
PyList_SET_ITEM(list, i, o);
}
- PyMem_Del(groups);
+ PyMem_Free(groups);
return list;
}
@@ -8115,16 +8463,30 @@ os_readlink_impl(PyObject *module, path_t *path, int dir_fd)
#if defined(HAVE_READLINK)
char buffer[MAXPATHLEN+1];
ssize_t length;
+#ifdef HAVE_READLINKAT
+ int readlinkat_unavailable = 0;
+#endif
Py_BEGIN_ALLOW_THREADS
#ifdef HAVE_READLINKAT
- if (dir_fd != DEFAULT_DIR_FD)
- length = readlinkat(dir_fd, path->narrow, buffer, MAXPATHLEN);
- else
+ if (dir_fd != DEFAULT_DIR_FD) {
+ if (HAVE_READLINKAT_RUNTIME) {
+ length = readlinkat(dir_fd, path->narrow, buffer, MAXPATHLEN);
+ } else {
+ readlinkat_unavailable = 1;
+ }
+ } else
#endif
length = readlink(path->narrow, buffer, MAXPATHLEN);
Py_END_ALLOW_THREADS
+#ifdef HAVE_READLINKAT
+ if (readlinkat_unavailable) {
+ argument_unavailable_error(NULL, "dir_fd");
+ return NULL;
+ }
+#endif
+
if (length < 0) {
return path_error(path);
}
@@ -8320,6 +8682,9 @@ os_symlink_impl(PyObject *module, path_t *src, path_t *dst,
static int windows_has_symlink_unprivileged_flag = TRUE;
#else
int result;
+#ifdef HAVE_SYMLINKAT
+ int symlinkat_unavailable = 0;
+#endif
#endif
if (PySys_Audit("os.symlink", "OOi", src->object, dst->object,
@@ -8382,14 +8747,25 @@ os_symlink_impl(PyObject *module, path_t *src, path_t *dst,
}
Py_BEGIN_ALLOW_THREADS
-#if HAVE_SYMLINKAT
- if (dir_fd != DEFAULT_DIR_FD)
- result = symlinkat(src->narrow, dir_fd, dst->narrow);
- else
+#ifdef HAVE_SYMLINKAT
+ if (dir_fd != DEFAULT_DIR_FD) {
+ if (HAVE_SYMLINKAT_RUNTIME) {
+ result = symlinkat(src->narrow, dir_fd, dst->narrow);
+ } else {
+ symlinkat_unavailable = 1;
+ }
+ } else
#endif
result = symlink(src->narrow, dst->narrow);
Py_END_ALLOW_THREADS
+#ifdef HAVE_SYMLINKAT
+ if (symlinkat_unavailable) {
+ argument_unavailable_error(NULL, "dir_fd");
+ return NULL;
+ }
+#endif
+
if (result)
return path_error2(src, dst);
#endif
@@ -8660,6 +9036,9 @@ os_open_impl(PyObject *module, path_t *path, int flags, int mode, int dir_fd)
{
int fd;
int async_err = 0;
+#ifdef HAVE_OPENAT
+ int openat_unavailable = 0;
+#endif
#ifdef O_CLOEXEC
int *atomic_flag_works = &_Py_open_cloexec_works;
@@ -8684,9 +9063,15 @@ os_open_impl(PyObject *module, path_t *path, int flags, int mode, int dir_fd)
fd = _wopen(path->wide, flags, mode);
#else
#ifdef HAVE_OPENAT
- if (dir_fd != DEFAULT_DIR_FD)
- fd = openat(dir_fd, path->narrow, flags, mode);
- else
+ if (dir_fd != DEFAULT_DIR_FD) {
+ if (HAVE_OPENAT_RUNTIME) {
+ fd = openat(dir_fd, path->narrow, flags, mode);
+
+ } else {
+ openat_unavailable = 1;
+ fd = -1;
+ }
+ } else
#endif /* HAVE_OPENAT */
fd = open(path->narrow, flags, mode);
#endif /* !MS_WINDOWS */
@@ -8694,6 +9079,13 @@ os_open_impl(PyObject *module, path_t *path, int flags, int mode, int dir_fd)
} while (fd < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
_Py_END_SUPPRESS_IPH
+#ifdef HAVE_OPENAT
+ if (openat_unavailable) {
+ argument_unavailable_error(NULL, "dir_fd");
+ return -1;
+ }
+#endif
+
if (fd < 0) {
if (!async_err)
PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, path->object);
@@ -9016,7 +9408,7 @@ iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, Py_ssize_t cnt, in
*buf = PyMem_New(Py_buffer, cnt);
if (*buf == NULL) {
- PyMem_Del(*iov);
+ PyMem_Free(*iov);
PyErr_NoMemory();
return -1;
}
@@ -9036,11 +9428,11 @@ iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, Py_ssize_t cnt, in
return 0;
fail:
- PyMem_Del(*iov);
+ PyMem_Free(*iov);
for (j = 0; j < i; j++) {
PyBuffer_Release(&(*buf)[j]);
}
- PyMem_Del(*buf);
+ PyMem_Free(*buf);
return -1;
}
@@ -9048,11 +9440,11 @@ static void
iov_cleanup(struct iovec *iov, Py_buffer *buf, int cnt)
{
int i;
- PyMem_Del(iov);
+ PyMem_Free(iov);
for (i = 0; i < cnt; i++) {
PyBuffer_Release(&buf[i]);
}
- PyMem_Del(buf);
+ PyMem_Free(buf);
}
#endif
@@ -9233,12 +9625,25 @@ os_preadv_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset,
} while (n < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
#else
do {
+#ifdef __APPLE__
+/* This entire function will be removed from the module dict when the API
+ * is not available.
+ */
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunguarded-availability"
+#pragma clang diagnostic ignored "-Wunguarded-availability-new"
+#endif
Py_BEGIN_ALLOW_THREADS
_Py_BEGIN_SUPPRESS_IPH
n = preadv(fd, iov, cnt, offset);
_Py_END_SUPPRESS_IPH
Py_END_ALLOW_THREADS
} while (n < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
+
+#ifdef __APPLE__
+#pragma clang diagnostic pop
+#endif
+
#endif
iov_cleanup(iov, buf, cnt);
@@ -9473,11 +9878,26 @@ done:
if (offset >= st.st_size) {
return Py_BuildValue("i", 0);
}
+
+ // On illumos specifically sendfile() may perform a partial write but
+ // return -1/an error (in one confirmed case the destination socket
+ // had a 5 second timeout set and errno was EAGAIN) and it's on the client
+ // code to check if the offset parameter was modified by sendfile().
+ //
+ // We need this variable to track said change.
+ off_t original_offset = offset;
#endif
do {
Py_BEGIN_ALLOW_THREADS
ret = sendfile(out_fd, in_fd, &offset, count);
+#if defined(__sun) && defined(__SVR4)
+ // This handles illumos-specific sendfile() partial write behavior,
+ // see a comment above for more details.
+ if (ret < 0 && offset != original_offset) {
+ ret = offset - original_offset;
+ }
+#endif
Py_END_ALLOW_THREADS
} while (ret < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
if (ret < 0)
@@ -9846,6 +10266,15 @@ os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset,
Py_END_ALLOW_THREADS
} while (result < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
#else
+
+#ifdef __APPLE__
+/* This entire function will be removed from the module dict when the API
+ * is not available.
+ */
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunguarded-availability"
+#pragma clang diagnostic ignored "-Wunguarded-availability-new"
+#endif
do {
Py_BEGIN_ALLOW_THREADS
_Py_BEGIN_SUPPRESS_IPH
@@ -9853,6 +10282,11 @@ os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset,
_Py_END_SUPPRESS_IPH
Py_END_ALLOW_THREADS
} while (result < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
+
+#ifdef __APPLE__
+#pragma clang diagnostic pop
+#endif
+
#endif
iov_cleanup(iov, buf, cnt);
@@ -9936,6 +10370,75 @@ os_copy_file_range_impl(PyObject *module, int src, int dst, Py_ssize_t count,
}
#endif /* HAVE_COPY_FILE_RANGE*/
+#if (defined(HAVE_SPLICE) && !defined(_AIX))
+/*[clinic input]
+
+os.splice
+ src: int
+ Source file descriptor.
+ dst: int
+ Destination file descriptor.
+ count: Py_ssize_t
+ Number of bytes to copy.
+ offset_src: object = None
+ Starting offset in src.
+ offset_dst: object = None
+ Starting offset in dst.
+ flags: unsigned_int = 0
+ Flags to modify the semantics of the call.
+
+Transfer count bytes from one pipe to a descriptor or vice versa.
+
+If offset_src is None, then src is read from the current position;
+respectively for offset_dst. The offset associated to the file
+descriptor that refers to a pipe must be None.
+[clinic start generated code]*/
+
+static PyObject *
+os_splice_impl(PyObject *module, int src, int dst, Py_ssize_t count,
+ PyObject *offset_src, PyObject *offset_dst,
+ unsigned int flags)
+/*[clinic end generated code: output=d0386f25a8519dc5 input=047527c66c6d2e0a]*/
+{
+ off_t offset_src_val, offset_dst_val;
+ off_t *p_offset_src = NULL;
+ off_t *p_offset_dst = NULL;
+ Py_ssize_t ret;
+ int async_err = 0;
+
+ if (count < 0) {
+ PyErr_SetString(PyExc_ValueError, "negative value for 'count' not allowed");
+ return NULL;
+ }
+
+ if (offset_src != Py_None) {
+ if (!Py_off_t_converter(offset_src, &offset_src_val)) {
+ return NULL;
+ }
+ p_offset_src = &offset_src_val;
+ }
+
+ if (offset_dst != Py_None) {
+ if (!Py_off_t_converter(offset_dst, &offset_dst_val)) {
+ return NULL;
+ }
+ p_offset_dst = &offset_dst_val;
+ }
+
+ do {
+ Py_BEGIN_ALLOW_THREADS
+ ret = splice(src, p_offset_src, dst, p_offset_dst, count, flags);
+ Py_END_ALLOW_THREADS
+ } while (ret < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
+
+ if (ret < 0) {
+ return (!async_err) ? posix_error() : NULL;
+ }
+
+ return PyLong_FromSsize_t(ret);
+}
+#endif /* HAVE_SPLICE*/
+
#ifdef HAVE_MKFIFO
/*[clinic input]
os.mkfifo
@@ -10742,13 +11245,6 @@ os_statvfs_impl(PyObject *module, path_t *path)
Py_BEGIN_ALLOW_THREADS
#ifdef HAVE_FSTATVFS
if (path->fd != -1) {
-#ifdef __APPLE__
- /* handle weak-linking on Mac OS X 10.3 */
- if (fstatvfs == NULL) {
- fd_specified("statvfs", path->fd);
- return NULL;
- }
-#endif
result = fstatvfs(path->fd, &st);
}
else
@@ -12320,7 +12816,7 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
path_error(path);
break;
}
- buffer = PyMem_MALLOC(buffer_size);
+ buffer = PyMem_Malloc(buffer_size);
if (!buffer) {
PyErr_NoMemory();
break;
@@ -12337,7 +12833,7 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
if (length < 0) {
if (errno == ERANGE) {
- PyMem_FREE(buffer);
+ PyMem_Free(buffer);
buffer = NULL;
continue;
}
@@ -12375,7 +12871,7 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
}
exit:
if (buffer)
- PyMem_FREE(buffer);
+ PyMem_Free(buffer);
return result;
}
#endif /* USE_XATTRS */
@@ -12437,6 +12933,79 @@ os_memfd_create_impl(PyObject *module, PyObject *name, unsigned int flags)
}
#endif
+#ifdef HAVE_EVENTFD
+/*[clinic input]
+os.eventfd
+
+ initval: unsigned_int
+ flags: int(c_default="EFD_CLOEXEC") = EFD_CLOEXEC
+
+Creates and returns an event notification file descriptor.
+[clinic start generated code]*/
+
+static PyObject *
+os_eventfd_impl(PyObject *module, unsigned int initval, int flags)
+/*[clinic end generated code: output=ce9c9bbd1446f2de input=66203e3c50c4028b]*/
+
+{
+ /* initval is limited to uint32_t, internal counter is uint64_t */
+ int fd;
+ Py_BEGIN_ALLOW_THREADS
+ fd = eventfd(initval, flags);
+ Py_END_ALLOW_THREADS
+ if (fd == -1) {
+ return PyErr_SetFromErrno(PyExc_OSError);
+ }
+ return PyLong_FromLong(fd);
+}
+
+/*[clinic input]
+os.eventfd_read
+
+ fd: fildes
+
+Read eventfd value
+[clinic start generated code]*/
+
+static PyObject *
+os_eventfd_read_impl(PyObject *module, int fd)
+/*[clinic end generated code: output=8f2c7b59a3521fd1 input=110f8b57fa596afe]*/
+{
+ eventfd_t value;
+ int result;
+ Py_BEGIN_ALLOW_THREADS
+ result = eventfd_read(fd, &value);
+ Py_END_ALLOW_THREADS
+ if (result == -1) {
+ return PyErr_SetFromErrno(PyExc_OSError);
+ }
+ return PyLong_FromUnsignedLongLong(value);
+}
+
+/*[clinic input]
+os.eventfd_write
+
+ fd: fildes
+ value: unsigned_long_long
+
+Write eventfd value.
+[clinic start generated code]*/
+
+static PyObject *
+os_eventfd_write_impl(PyObject *module, int fd, unsigned long long value)
+/*[clinic end generated code: output=bebd9040bbf987f5 input=156de8555be5a949]*/
+{
+ int result;
+ Py_BEGIN_ALLOW_THREADS
+ result = eventfd_write(fd, value);
+ Py_END_ALLOW_THREADS
+ if (result == -1) {
+ return PyErr_SetFromErrno(PyExc_OSError);
+ }
+ Py_RETURN_NONE;
+}
+#endif /* HAVE_EVENTFD */
+
/* Terminal size querying */
PyDoc_STRVAR(TerminalSize_docstring,
@@ -12832,13 +13401,17 @@ _Py_COMP_DIAG_POP
const char *path = PyBytes_AS_STRING(ub);
if (self->dir_fd != DEFAULT_DIR_FD) {
#ifdef HAVE_FSTATAT
+ if (HAVE_FSTATAT_RUNTIME) {
result = fstatat(self->dir_fd, path, &st,
follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW);
-#else
+ } else
+
+#endif /* HAVE_FSTATAT */
+ {
Py_DECREF(ub);
PyErr_SetString(PyExc_NotImplementedError, "can't fetch stat");
return NULL;
-#endif /* HAVE_FSTATAT */
+ }
}
else
#endif
@@ -13637,6 +14210,7 @@ os_scandir_impl(PyObject *module, path_t *path)
errno = 0;
#ifdef HAVE_FDOPENDIR
if (iterator->path.fd != -1) {
+ if (HAVE_FDOPENDIR_RUNTIME) {
/* closedir() closes the FD, so we duplicate it */
fd = _Py_dup(iterator->path.fd);
if (fd == -1)
@@ -13645,6 +14219,11 @@ os_scandir_impl(PyObject *module, path_t *path)
Py_BEGIN_ALLOW_THREADS
iterator->dirp = fdopendir(fd);
Py_END_ALLOW_THREADS
+ } else {
+ PyErr_SetString(PyExc_TypeError,
+ "scandir: path should be string, bytes, os.PathLike or None, not int");
+ return NULL;
+ }
}
else
#endif
@@ -13923,7 +14502,7 @@ os__remove_dll_directory_impl(PyObject *module, PyObject *cookie)
os.waitstatus_to_exitcode() is implemented in C and not in Python, so
subprocess can safely call it during late Python finalization without
- risking that used os attributes were set to None by _PyImport_Cleanup(). */
+ risking that used os attributes were set to None by finalize_modules(). */
#if defined(WIFEXITED) || defined(MS_WINDOWS)
/*[clinic input]
os.waitstatus_to_exitcode
@@ -14040,6 +14619,7 @@ static PyMethodDef posix_methods[] = {
OS_POSIX_SPAWNP_METHODDEF
OS_READLINK_METHODDEF
OS_COPY_FILE_RANGE_METHODDEF
+ OS_SPLICE_METHODDEF
OS_RENAME_METHODDEF
OS_REPLACE_METHODDEF
OS_RMDIR_METHODDEF
@@ -14187,6 +14767,9 @@ static PyMethodDef posix_methods[] = {
OS_FSPATH_METHODDEF
OS_GETRANDOM_METHODDEF
OS_MEMFD_CREATE_METHODDEF
+ OS_EVENTFD_METHODDEF
+ OS_EVENTFD_READ_METHODDEF
+ OS_EVENTFD_WRITE_METHODDEF
OS__ADD_DLL_DIRECTORY_METHODDEF
OS__REMOVE_DLL_DIRECTORY_METHODDEF
OS_WAITSTATUS_TO_EXITCODE_METHODDEF
@@ -14559,6 +15142,13 @@ all_ins(PyObject *m)
if (PyModule_AddIntConstant(m, "RWF_APPEND", RWF_APPEND)) return -1;
#endif
+/* constants for splice */
+#if defined(HAVE_SPLICE) && defined(__linux__)
+ if (PyModule_AddIntConstant(m, "SPLICE_F_MOVE", SPLICE_F_MOVE)) return -1;
+ if (PyModule_AddIntConstant(m, "SPLICE_F_NONBLOCK", SPLICE_F_NONBLOCK)) return -1;
+ if (PyModule_AddIntConstant(m, "SPLICE_F_MORE", SPLICE_F_MORE)) return -1;
+#endif
+
/* constants for posix_spawn */
#ifdef HAVE_POSIX_SPAWN
if (PyModule_AddIntConstant(m, "POSIX_SPAWN_OPEN", POSIX_SPAWN_OPEN)) return -1;
@@ -14695,6 +15285,12 @@ all_ins(PyObject *m)
#ifdef MFD_HUGE_16GB
if (PyModule_AddIntMacro(m, MFD_HUGE_16GB)) return -1;
#endif
+#endif /* HAVE_MEMFD_CREATE */
+
+#ifdef HAVE_EVENTFD
+ if (PyModule_AddIntMacro(m, EFD_CLOEXEC)) return -1;
+ if (PyModule_AddIntMacro(m, EFD_NONBLOCK)) return -1;
+ if (PyModule_AddIntMacro(m, EFD_SEMAPHORE)) return -1;
#endif
#if defined(__APPLE__)
@@ -14713,137 +15309,214 @@ all_ins(PyObject *m)
}
-static const char * const have_functions[] = {
+
+#define PROBE(name, test) \
+ static int name(void) \
+ { \
+ if (test) { \
+ return 1; \
+ } else { \
+ return 0; \
+ } \
+ }
+
+#ifdef HAVE_FSTATAT
+PROBE(probe_fstatat, HAVE_FSTATAT_RUNTIME)
+#endif
#ifdef HAVE_FACCESSAT
- "HAVE_FACCESSAT",
+PROBE(probe_faccessat, HAVE_FACCESSAT_RUNTIME)
+#endif
+
+#ifdef HAVE_FCHMODAT
+PROBE(probe_fchmodat, HAVE_FCHMODAT_RUNTIME)
+#endif
+
+#ifdef HAVE_FCHOWNAT
+PROBE(probe_fchownat, HAVE_FCHOWNAT_RUNTIME)
+#endif
+
+#ifdef HAVE_LINKAT
+PROBE(probe_linkat, HAVE_LINKAT_RUNTIME)
+#endif
+
+#ifdef HAVE_FDOPENDIR
+PROBE(probe_fdopendir, HAVE_FDOPENDIR_RUNTIME)
+#endif
+
+#ifdef HAVE_MKDIRAT
+PROBE(probe_mkdirat, HAVE_MKDIRAT_RUNTIME)
+#endif
+
+#ifdef HAVE_RENAMEAT
+PROBE(probe_renameat, HAVE_RENAMEAT_RUNTIME)
+#endif
+
+#ifdef HAVE_UNLINKAT
+PROBE(probe_unlinkat, HAVE_UNLINKAT_RUNTIME)
+#endif
+
+#ifdef HAVE_OPENAT
+PROBE(probe_openat, HAVE_OPENAT_RUNTIME)
+#endif
+
+#ifdef HAVE_READLINKAT
+PROBE(probe_readlinkat, HAVE_READLINKAT_RUNTIME)
+#endif
+
+#ifdef HAVE_SYMLINKAT
+PROBE(probe_symlinkat, HAVE_SYMLINKAT_RUNTIME)
+#endif
+
+#ifdef HAVE_FUTIMENS
+PROBE(probe_futimens, HAVE_FUTIMENS_RUNTIME)
+#endif
+
+#ifdef HAVE_UTIMENSAT
+PROBE(probe_utimensat, HAVE_UTIMENSAT_RUNTIME)
+#endif
+
+
+
+
+static const struct have_function {
+ const char * const label;
+ int (*probe)(void);
+} have_functions[] = {
+
+#ifdef HAVE_EVENTFD
+ {"HAVE_EVENTFD", NULL},
+#endif
+
+#ifdef HAVE_FACCESSAT
+ { "HAVE_FACCESSAT", probe_faccessat },
#endif
#ifdef HAVE_FCHDIR
- "HAVE_FCHDIR",
+ { "HAVE_FCHDIR", NULL },
#endif
#ifdef HAVE_FCHMOD
- "HAVE_FCHMOD",
+ { "HAVE_FCHMOD", NULL },
#endif
#ifdef HAVE_FCHMODAT
- "HAVE_FCHMODAT",
+ { "HAVE_FCHMODAT", probe_fchmodat },
#endif
#ifdef HAVE_FCHOWN
- "HAVE_FCHOWN",
+ { "HAVE_FCHOWN", NULL },
#endif
#ifdef HAVE_FCHOWNAT
- "HAVE_FCHOWNAT",
+ { "HAVE_FCHOWNAT", probe_fchownat },
#endif
#ifdef HAVE_FEXECVE
- "HAVE_FEXECVE",
+ { "HAVE_FEXECVE", NULL },
#endif
#ifdef HAVE_FDOPENDIR
- "HAVE_FDOPENDIR",
+ { "HAVE_FDOPENDIR", probe_fdopendir },
#endif
#ifdef HAVE_FPATHCONF
- "HAVE_FPATHCONF",
+ { "HAVE_FPATHCONF", NULL },
#endif
#ifdef HAVE_FSTATAT
- "HAVE_FSTATAT",
+ { "HAVE_FSTATAT", probe_fstatat },
#endif
#ifdef HAVE_FSTATVFS
- "HAVE_FSTATVFS",
+ { "HAVE_FSTATVFS", NULL },
#endif
#if defined HAVE_FTRUNCATE || defined MS_WINDOWS
- "HAVE_FTRUNCATE",
+ { "HAVE_FTRUNCATE", NULL },
#endif
#ifdef HAVE_FUTIMENS
- "HAVE_FUTIMENS",
+ { "HAVE_FUTIMENS", probe_futimens },
#endif
#ifdef HAVE_FUTIMES
- "HAVE_FUTIMES",
+ { "HAVE_FUTIMES", NULL },
#endif
#ifdef HAVE_FUTIMESAT
- "HAVE_FUTIMESAT",
+ { "HAVE_FUTIMESAT", NULL },
#endif
#ifdef HAVE_LINKAT
- "HAVE_LINKAT",
+ { "HAVE_LINKAT", probe_linkat },
#endif
#ifdef HAVE_LCHFLAGS
- "HAVE_LCHFLAGS",
+ { "HAVE_LCHFLAGS", NULL },
#endif
#ifdef HAVE_LCHMOD
- "HAVE_LCHMOD",
+ { "HAVE_LCHMOD", NULL },
#endif
#ifdef HAVE_LCHOWN
- "HAVE_LCHOWN",
+ { "HAVE_LCHOWN", NULL },
#endif
#ifdef HAVE_LSTAT
- "HAVE_LSTAT",
+ { "HAVE_LSTAT", NULL },
#endif
#ifdef HAVE_LUTIMES
- "HAVE_LUTIMES",
+ { "HAVE_LUTIMES", NULL },
#endif
#ifdef HAVE_MEMFD_CREATE
- "HAVE_MEMFD_CREATE",
+ { "HAVE_MEMFD_CREATE", NULL },
#endif
#ifdef HAVE_MKDIRAT
- "HAVE_MKDIRAT",
+ { "HAVE_MKDIRAT", probe_mkdirat },
#endif
#ifdef HAVE_MKFIFOAT
- "HAVE_MKFIFOAT",
+ { "HAVE_MKFIFOAT", NULL },
#endif
#ifdef HAVE_MKNODAT
- "HAVE_MKNODAT",
+ { "HAVE_MKNODAT", NULL },
#endif
#ifdef HAVE_OPENAT
- "HAVE_OPENAT",
+ { "HAVE_OPENAT", probe_openat },
#endif
#ifdef HAVE_READLINKAT
- "HAVE_READLINKAT",
+ { "HAVE_READLINKAT", probe_readlinkat },
#endif
#ifdef HAVE_RENAMEAT
- "HAVE_RENAMEAT",
+ { "HAVE_RENAMEAT", probe_renameat },
#endif
#ifdef HAVE_SYMLINKAT
- "HAVE_SYMLINKAT",
+ { "HAVE_SYMLINKAT", probe_symlinkat },
#endif
#ifdef HAVE_UNLINKAT
- "HAVE_UNLINKAT",
+ { "HAVE_UNLINKAT", probe_unlinkat },
#endif
#ifdef HAVE_UTIMENSAT
- "HAVE_UTIMENSAT",
+ { "HAVE_UTIMENSAT", probe_utimensat },
#endif
#ifdef MS_WINDOWS
- "MS_WINDOWS",
+ { "MS_WINDOWS", NULL },
#endif
- NULL
+ { NULL, NULL }
};
@@ -14852,6 +15525,23 @@ posixmodule_exec(PyObject *m)
{
_posixstate *state = get_posix_state(m);
+#if defined(HAVE_PWRITEV)
+ if (HAVE_PWRITEV_RUNTIME) {} else {
+ PyObject* dct = PyModule_GetDict(m);
+
+ if (dct == NULL) {
+ return -1;
+ }
+
+ if (PyDict_DelItemString(dct, "pwritev") == -1) {
+ PyErr_Clear();
+ }
+ if (PyDict_DelItemString(dct, "preadv") == -1) {
+ PyErr_Clear();
+ }
+ }
+#endif
+
/* Initialize environ dictionary */
PyObject *v = convertenviron();
Py_XINCREF(v);
@@ -14964,44 +15654,6 @@ posixmodule_exec(PyObject *m)
PyModule_AddObject(m, "uname_result", (PyObject *)UnameResultType);
state->UnameResultType = (PyObject *)UnameResultType;
-#ifdef __APPLE__
- /*
- * Step 2 of weak-linking support on Mac OS X.
- *
- * The code below removes functions that are not available on the
- * currently active platform.
- *
- * This block allow one to use a python binary that was build on
- * OSX 10.4 on OSX 10.3, without losing access to new APIs on
- * OSX 10.4.
- */
-#ifdef HAVE_FSTATVFS
- if (fstatvfs == NULL) {
- if (PyObject_DelAttrString(m, "fstatvfs") == -1) {
- return -1;
- }
- }
-#endif /* HAVE_FSTATVFS */
-
-#ifdef HAVE_STATVFS
- if (statvfs == NULL) {
- if (PyObject_DelAttrString(m, "statvfs") == -1) {
- return -1;
- }
- }
-#endif /* HAVE_STATVFS */
-
-# ifdef HAVE_LCHOWN
- if (lchown == NULL) {
- if (PyObject_DelAttrString(m, "lchown") == -1) {
- return -1;
- }
- }
-#endif /* HAVE_LCHOWN */
-
-
-#endif /* __APPLE__ */
-
if ((state->billion = PyLong_FromLong(1000000000)) == NULL)
return -1;
#if defined(HAVE_WAIT3) || defined(HAVE_WAIT4)
@@ -15031,14 +15683,17 @@ posixmodule_exec(PyObject *m)
if (!list) {
return -1;
}
- for (const char * const *trace = have_functions; *trace; trace++) {
- PyObject *unicode = PyUnicode_DecodeASCII(*trace, strlen(*trace), NULL);
+ for (const struct have_function *trace = have_functions; trace->label; trace++) {
+ PyObject *unicode;
+ if (trace->probe && !trace->probe()) continue;
+ unicode = PyUnicode_DecodeASCII(trace->label, strlen(trace->label), NULL);
if (!unicode)
return -1;
if (PyList_Append(list, unicode))
return -1;
Py_DECREF(unicode);
}
+
PyModule_AddObject(m, "_have_functions", list);
return 0;
diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c
index 901a3ed9a2..14d3f9dcb1 100644
--- a/Modules/pwdmodule.c
+++ b/Modules/pwdmodule.c
@@ -59,8 +59,6 @@ get_pwd_state(PyObject *module)
return (pwdmodulestate *)state;
}
-#define modulestate_global get_pwd_state(PyState_FindModule(&pwdmodule))
-
static struct PyModuleDef pwdmodule;
#define DEFAULT_BUFFER_SIZE 1024
@@ -79,10 +77,10 @@ sets(PyObject *v, int i, const char* val)
}
static PyObject *
-mkpwent(struct passwd *p)
+mkpwent(PyObject *module, struct passwd *p)
{
int setIndex = 0;
- PyObject *v = PyStructSequence_New(modulestate_global->StructPwdType);
+ PyObject *v = PyStructSequence_New(get_pwd_state(module)->StructPwdType);
if (v == NULL)
return NULL;
@@ -194,7 +192,7 @@ pwd_getpwuid(PyObject *module, PyObject *uidobj)
Py_DECREF(uid_obj);
return NULL;
}
- retval = mkpwent(p);
+ retval = mkpwent(module, p);
#ifdef HAVE_GETPWUID_R
PyMem_RawFree(buf);
#endif
@@ -274,7 +272,7 @@ pwd_getpwnam_impl(PyObject *module, PyObject *name)
}
goto out;
}
- retval = mkpwent(p);
+ retval = mkpwent(module, p);
out:
PyMem_RawFree(buf);
Py_DECREF(bytes);
@@ -300,7 +298,7 @@ pwd_getpwall_impl(PyObject *module)
return NULL;
setpwent();
while ((p = getpwent()) != NULL) {
- PyObject *v = mkpwent(p);
+ PyObject *v = mkpwent(module, p);
if (v == NULL || PyList_Append(d, v) != 0) {
Py_XDECREF(v);
Py_DECREF(d);
@@ -323,6 +321,26 @@ static PyMethodDef pwd_methods[] = {
{NULL, NULL} /* sentinel */
};
+static int
+pwdmodule_exec(PyObject *module)
+{
+ pwdmodulestate *state = get_pwd_state(module);
+
+ state->StructPwdType = PyStructSequence_NewType(&struct_pwd_type_desc);
+ if (state->StructPwdType == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(module, state->StructPwdType) < 0) {
+ return -1;
+ }
+ return 0;
+}
+
+static PyModuleDef_Slot pwdmodule_slots[] = {
+ {Py_mod_exec, pwdmodule_exec},
+ {0, NULL}
+};
+
static int pwdmodule_traverse(PyObject *m, visitproc visit, void *arg) {
Py_VISIT(get_pwd_state(m)->StructPwdType);
return 0;
@@ -337,34 +355,19 @@ static void pwdmodule_free(void *m) {
static struct PyModuleDef pwdmodule = {
PyModuleDef_HEAD_INIT,
- "pwd",
- pwd__doc__,
- sizeof(pwdmodulestate),
- pwd_methods,
- NULL,
- pwdmodule_traverse,
- pwdmodule_clear,
- pwdmodule_free,
+ .m_name = "pwd",
+ .m_doc = pwd__doc__,
+ .m_size = sizeof(pwdmodulestate),
+ .m_methods = pwd_methods,
+ .m_slots = pwdmodule_slots,
+ .m_traverse = pwdmodule_traverse,
+ .m_clear = pwdmodule_clear,
+ .m_free = pwdmodule_free,
};
PyMODINIT_FUNC
PyInit_pwd(void)
{
- PyObject *m;
- if ((m = PyState_FindModule(&pwdmodule)) != NULL) {
- Py_INCREF(m);
- return m;
- }
- if ((m = PyModule_Create(&pwdmodule)) == NULL)
- return NULL;
-
- pwdmodulestate *state = PyModule_GetState(m);
- state->StructPwdType = PyStructSequence_NewType(&struct_pwd_type_desc);
- if (state->StructPwdType == NULL) {
- return NULL;
- }
- Py_INCREF(state->StructPwdType);
- PyModule_AddObject(m, "struct_passwd", (PyObject *) state->StructPwdType);
- return m;
+ return PyModuleDef_Init(&pwdmodule);
}
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index 73ea51385e..7d7da56897 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1587,18 +1587,6 @@ PyDoc_STRVAR(pyexpat_module_documentation,
#define MODULE_INITFUNC PyInit_pyexpat
#endif
-static struct PyModuleDef pyexpatmodule = {
- PyModuleDef_HEAD_INIT,
- MODULE_NAME,
- pyexpat_module_documentation,
- -1,
- pyexpat_methods,
- NULL,
- NULL,
- NULL,
- NULL
-};
-
static int init_handler_descrs(void)
{
int i;
@@ -1623,210 +1611,182 @@ static int init_handler_descrs(void)
return 0;
}
-PyMODINIT_FUNC
-MODULE_INITFUNC(void)
+static PyObject *
+add_submodule(PyObject *mod, const char *fullname)
{
- PyObject *m, *d;
- PyObject *errmod_name = PyUnicode_FromString(MODULE_NAME ".errors");
- PyObject *errors_module;
- PyObject *modelmod_name;
- PyObject *model_module;
- PyObject *tmpnum, *tmpstr;
- PyObject *codes_dict;
- PyObject *rev_codes_dict;
- int res;
- static struct PyExpat_CAPI capi;
- PyObject *capi_object;
+ const char *name = strrchr(fullname, '.') + 1;
- if (errmod_name == NULL)
- return NULL;
- modelmod_name = PyUnicode_FromString(MODULE_NAME ".model");
- if (modelmod_name == NULL)
+ PyObject *submodule = PyModule_New(fullname);
+ if (submodule == NULL) {
return NULL;
+ }
- if (PyType_Ready(&Xmlparsetype) < 0 || init_handler_descrs() < 0)
+ PyObject *mod_name = PyUnicode_FromString(fullname);
+ if (mod_name == NULL) {
+ Py_DECREF(submodule);
return NULL;
+ }
- /* Create the module and add the functions */
- m = PyModule_Create(&pyexpatmodule);
- if (m == NULL)
+ if (_PyImport_SetModule(mod_name, submodule) < 0) {
+ Py_DECREF(submodule);
+ Py_DECREF(mod_name);
return NULL;
+ }
+ Py_DECREF(mod_name);
- /* Add some symbolic constants to the module */
- if (ErrorObject == NULL) {
- ErrorObject = PyErr_NewException("xml.parsers.expat.ExpatError",
- NULL, NULL);
- if (ErrorObject == NULL)
- return NULL;
+ /* gives away the reference to the submodule */
+ if (PyModule_AddObject(mod, name, submodule) < 0) {
+ Py_DECREF(submodule);
+ return NULL;
}
- Py_INCREF(ErrorObject);
- PyModule_AddObject(m, "error", ErrorObject);
- Py_INCREF(ErrorObject);
- PyModule_AddObject(m, "ExpatError", ErrorObject);
- Py_INCREF(&Xmlparsetype);
- PyModule_AddObject(m, "XMLParserType", (PyObject *) &Xmlparsetype);
- PyModule_AddStringConstant(m, "EXPAT_VERSION",
- XML_ExpatVersion());
- {
- XML_Expat_Version info = XML_ExpatVersionInfo();
- PyModule_AddObject(m, "version_info",
- Py_BuildValue("(iii)", info.major,
- info.minor, info.micro));
+ return submodule;
+}
+
+static int
+add_error(PyObject *errors_module, PyObject *codes_dict,
+ PyObject *rev_codes_dict, const char *name, int value)
+{
+ const char *error_string = XML_ErrorString(value);
+ if (PyModule_AddStringConstant(errors_module, name, error_string) < 0) {
+ return -1;
}
- /* XXX When Expat supports some way of figuring out how it was
- compiled, this should check and set native_encoding
- appropriately.
- */
- PyModule_AddStringConstant(m, "native_encoding", "UTF-8");
- d = PyModule_GetDict(m);
- if (d == NULL) {
- Py_DECREF(m);
- return NULL;
+ PyObject *num = PyLong_FromLong(value);
+ if (num == NULL) {
+ return -1;
}
- errors_module = PyDict_GetItemWithError(d, errmod_name);
- if (errors_module == NULL && !PyErr_Occurred()) {
- errors_module = PyModule_New(MODULE_NAME ".errors");
- if (errors_module != NULL) {
- _PyImport_SetModule(errmod_name, errors_module);
- /* gives away the reference to errors_module */
- PyModule_AddObject(m, "errors", errors_module);
- }
+
+ if (PyDict_SetItemString(codes_dict, error_string, num) < 0) {
+ Py_DECREF(num);
+ return -1;
}
- Py_DECREF(errmod_name);
- model_module = PyDict_GetItemWithError(d, modelmod_name);
- if (model_module == NULL && !PyErr_Occurred()) {
- model_module = PyModule_New(MODULE_NAME ".model");
- if (model_module != NULL) {
- _PyImport_SetModule(modelmod_name, model_module);
- /* gives away the reference to model_module */
- PyModule_AddObject(m, "model", model_module);
- }
+
+ PyObject *str = PyUnicode_FromString(error_string);
+ if (str == NULL) {
+ Py_DECREF(num);
+ return -1;
}
- Py_DECREF(modelmod_name);
- if (errors_module == NULL || model_module == NULL) {
- /* Don't core dump later! */
- Py_DECREF(m);
- return NULL;
+
+ int res = PyDict_SetItem(rev_codes_dict, num, str);
+ Py_DECREF(str);
+ Py_DECREF(num);
+ if (res < 0) {
+ return -1;
}
-#if XML_COMBINED_VERSION > 19505
- {
- const XML_Feature *features = XML_GetFeatureList();
- PyObject *list = PyList_New(0);
- if (list == NULL)
- /* just ignore it */
- PyErr_Clear();
- else {
- int i = 0;
- for (; features[i].feature != XML_FEATURE_END; ++i) {
- int ok;
- PyObject *item = Py_BuildValue("si", features[i].name,
- features[i].value);
- if (item == NULL) {
- Py_DECREF(list);
- list = NULL;
- break;
- }
- ok = PyList_Append(list, item);
- Py_DECREF(item);
- if (ok < 0) {
- PyErr_Clear();
- break;
- }
- }
- if (list != NULL)
- PyModule_AddObject(m, "features", list);
- }
+ return 0;
+}
+
+static int
+add_errors_module(PyObject *mod)
+{
+ PyObject *errors_module = add_submodule(mod, MODULE_NAME ".errors");
+ if (errors_module == NULL) {
+ return -1;
}
-#endif
- codes_dict = PyDict_New();
- rev_codes_dict = PyDict_New();
+ PyObject *codes_dict = PyDict_New();
+ PyObject *rev_codes_dict = PyDict_New();
if (codes_dict == NULL || rev_codes_dict == NULL) {
- Py_XDECREF(codes_dict);
- Py_XDECREF(rev_codes_dict);
- return NULL;
+ goto error;
}
-#define MYCONST(name) \
- if (PyModule_AddStringConstant(errors_module, #name, \
- XML_ErrorString(name)) < 0) \
- return NULL; \
- tmpnum = PyLong_FromLong(name); \
- if (tmpnum == NULL) return NULL; \
- res = PyDict_SetItemString(codes_dict, \
- XML_ErrorString(name), tmpnum); \
- if (res < 0) return NULL; \
- tmpstr = PyUnicode_FromString(XML_ErrorString(name)); \
- if (tmpstr == NULL) return NULL; \
- res = PyDict_SetItem(rev_codes_dict, tmpnum, tmpstr); \
- Py_DECREF(tmpstr); \
- Py_DECREF(tmpnum); \
- if (res < 0) return NULL; \
-
- MYCONST(XML_ERROR_NO_MEMORY);
- MYCONST(XML_ERROR_SYNTAX);
- MYCONST(XML_ERROR_NO_ELEMENTS);
- MYCONST(XML_ERROR_INVALID_TOKEN);
- MYCONST(XML_ERROR_UNCLOSED_TOKEN);
- MYCONST(XML_ERROR_PARTIAL_CHAR);
- MYCONST(XML_ERROR_TAG_MISMATCH);
- MYCONST(XML_ERROR_DUPLICATE_ATTRIBUTE);
- MYCONST(XML_ERROR_JUNK_AFTER_DOC_ELEMENT);
- MYCONST(XML_ERROR_PARAM_ENTITY_REF);
- MYCONST(XML_ERROR_UNDEFINED_ENTITY);
- MYCONST(XML_ERROR_RECURSIVE_ENTITY_REF);
- MYCONST(XML_ERROR_ASYNC_ENTITY);
- MYCONST(XML_ERROR_BAD_CHAR_REF);
- MYCONST(XML_ERROR_BINARY_ENTITY_REF);
- MYCONST(XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF);
- MYCONST(XML_ERROR_MISPLACED_XML_PI);
- MYCONST(XML_ERROR_UNKNOWN_ENCODING);
- MYCONST(XML_ERROR_INCORRECT_ENCODING);
- MYCONST(XML_ERROR_UNCLOSED_CDATA_SECTION);
- MYCONST(XML_ERROR_EXTERNAL_ENTITY_HANDLING);
- MYCONST(XML_ERROR_NOT_STANDALONE);
- MYCONST(XML_ERROR_UNEXPECTED_STATE);
- MYCONST(XML_ERROR_ENTITY_DECLARED_IN_PE);
- MYCONST(XML_ERROR_FEATURE_REQUIRES_XML_DTD);
- MYCONST(XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING);
+#define ADD_CONST(name) do { \
+ if (add_error(errors_module, codes_dict, rev_codes_dict, \
+ #name, name) < 0) { \
+ goto error; \
+ } \
+ } while(0)
+
+ ADD_CONST(XML_ERROR_NO_MEMORY);
+ ADD_CONST(XML_ERROR_SYNTAX);
+ ADD_CONST(XML_ERROR_NO_ELEMENTS);
+ ADD_CONST(XML_ERROR_INVALID_TOKEN);
+ ADD_CONST(XML_ERROR_UNCLOSED_TOKEN);
+ ADD_CONST(XML_ERROR_PARTIAL_CHAR);
+ ADD_CONST(XML_ERROR_TAG_MISMATCH);
+ ADD_CONST(XML_ERROR_DUPLICATE_ATTRIBUTE);
+ ADD_CONST(XML_ERROR_JUNK_AFTER_DOC_ELEMENT);
+ ADD_CONST(XML_ERROR_PARAM_ENTITY_REF);
+ ADD_CONST(XML_ERROR_UNDEFINED_ENTITY);
+ ADD_CONST(XML_ERROR_RECURSIVE_ENTITY_REF);
+ ADD_CONST(XML_ERROR_ASYNC_ENTITY);
+ ADD_CONST(XML_ERROR_BAD_CHAR_REF);
+ ADD_CONST(XML_ERROR_BINARY_ENTITY_REF);
+ ADD_CONST(XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF);
+ ADD_CONST(XML_ERROR_MISPLACED_XML_PI);
+ ADD_CONST(XML_ERROR_UNKNOWN_ENCODING);
+ ADD_CONST(XML_ERROR_INCORRECT_ENCODING);
+ ADD_CONST(XML_ERROR_UNCLOSED_CDATA_SECTION);
+ ADD_CONST(XML_ERROR_EXTERNAL_ENTITY_HANDLING);
+ ADD_CONST(XML_ERROR_NOT_STANDALONE);
+ ADD_CONST(XML_ERROR_UNEXPECTED_STATE);
+ ADD_CONST(XML_ERROR_ENTITY_DECLARED_IN_PE);
+ ADD_CONST(XML_ERROR_FEATURE_REQUIRES_XML_DTD);
+ ADD_CONST(XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING);
/* Added in Expat 1.95.7. */
- MYCONST(XML_ERROR_UNBOUND_PREFIX);
+ ADD_CONST(XML_ERROR_UNBOUND_PREFIX);
/* Added in Expat 1.95.8. */
- MYCONST(XML_ERROR_UNDECLARING_PREFIX);
- MYCONST(XML_ERROR_INCOMPLETE_PE);
- MYCONST(XML_ERROR_XML_DECL);
- MYCONST(XML_ERROR_TEXT_DECL);
- MYCONST(XML_ERROR_PUBLICID);
- MYCONST(XML_ERROR_SUSPENDED);
- MYCONST(XML_ERROR_NOT_SUSPENDED);
- MYCONST(XML_ERROR_ABORTED);
- MYCONST(XML_ERROR_FINISHED);
- MYCONST(XML_ERROR_SUSPEND_PE);
+ ADD_CONST(XML_ERROR_UNDECLARING_PREFIX);
+ ADD_CONST(XML_ERROR_INCOMPLETE_PE);
+ ADD_CONST(XML_ERROR_XML_DECL);
+ ADD_CONST(XML_ERROR_TEXT_DECL);
+ ADD_CONST(XML_ERROR_PUBLICID);
+ ADD_CONST(XML_ERROR_SUSPENDED);
+ ADD_CONST(XML_ERROR_NOT_SUSPENDED);
+ ADD_CONST(XML_ERROR_ABORTED);
+ ADD_CONST(XML_ERROR_FINISHED);
+ ADD_CONST(XML_ERROR_SUSPEND_PE);
+#undef ADD_CONST
if (PyModule_AddStringConstant(errors_module, "__doc__",
"Constants used to describe "
- "error conditions.") < 0)
- return NULL;
+ "error conditions.") < 0) {
+ goto error;
+ }
- if (PyModule_AddObject(errors_module, "codes", codes_dict) < 0)
- return NULL;
- if (PyModule_AddObject(errors_module, "messages", rev_codes_dict) < 0)
- return NULL;
+ Py_INCREF(codes_dict);
+ if (PyModule_AddObject(errors_module, "codes", codes_dict) < 0) {
+ Py_DECREF(codes_dict);
+ goto error;
+ }
+ Py_CLEAR(codes_dict);
-#undef MYCONST
+ Py_INCREF(rev_codes_dict);
+ if (PyModule_AddObject(errors_module, "messages", rev_codes_dict) < 0) {
+ Py_DECREF(rev_codes_dict);
+ goto error;
+ }
+ Py_CLEAR(rev_codes_dict);
-#define MYCONST(c) PyModule_AddIntConstant(m, #c, c)
- MYCONST(XML_PARAM_ENTITY_PARSING_NEVER);
- MYCONST(XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE);
- MYCONST(XML_PARAM_ENTITY_PARSING_ALWAYS);
-#undef MYCONST
+ return 0;
+
+error:
+ Py_XDECREF(codes_dict);
+ Py_XDECREF(rev_codes_dict);
+ return -1;
+}
+
+static int
+add_model_module(PyObject *mod)
+{
+ PyObject *model_module = add_submodule(mod, MODULE_NAME ".model");
+ if (model_module == NULL) {
+ return -1;
+ }
+
+#define MYCONST(c) do { \
+ if (PyModule_AddIntConstant(model_module, #c, c) < 0) { \
+ return -1; \
+ } \
+ } while(0)
-#define MYCONST(c) PyModule_AddIntConstant(model_module, #c, c)
- PyModule_AddStringConstant(model_module, "__doc__",
- "Constants used to interpret content model information.");
+ if (PyModule_AddStringConstant(
+ model_module, "__doc__",
+ "Constants used to interpret content model information.") < 0) {
+ return -1;
+ }
MYCONST(XML_CTYPE_EMPTY);
MYCONST(XML_CTYPE_ANY);
@@ -1840,7 +1800,128 @@ MODULE_INITFUNC(void)
MYCONST(XML_CQUANT_REP);
MYCONST(XML_CQUANT_PLUS);
#undef MYCONST
+ return 0;
+}
+#if XML_COMBINED_VERSION > 19505
+static int
+add_features(PyObject *mod)
+{
+ PyObject *list = PyList_New(0);
+ if (list == NULL) {
+ return -1;
+ }
+
+ const XML_Feature *features = XML_GetFeatureList();
+ for (size_t i = 0; features[i].feature != XML_FEATURE_END; ++i) {
+ PyObject *item = Py_BuildValue("si", features[i].name,
+ features[i].value);
+ if (item == NULL) {
+ goto error;
+ }
+ int ok = PyList_Append(list, item);
+ Py_DECREF(item);
+ if (ok < 0) {
+ goto error;
+ }
+ }
+ if (PyModule_AddObject(mod, "features", list) < 0) {
+ goto error;
+ }
+ return 0;
+
+error:
+ Py_DECREF(list);
+ return -1;
+}
+#endif
+
+static int
+pyexpat_exec(PyObject *mod)
+{
+ if (PyType_Ready(&Xmlparsetype) < 0) {
+ return -1;
+ }
+
+ if (init_handler_descrs() < 0) {
+ return -1;
+ }
+
+ /* Add some symbolic constants to the module */
+ if (ErrorObject == NULL) {
+ ErrorObject = PyErr_NewException("xml.parsers.expat.ExpatError",
+ NULL, NULL);
+ }
+ if (ErrorObject == NULL) {
+ return -1;
+ }
+
+ Py_INCREF(ErrorObject);
+ if (PyModule_AddObject(mod, "error", ErrorObject) < 0) {
+ Py_DECREF(ErrorObject);
+ return -1;
+ }
+ Py_INCREF(ErrorObject);
+ if (PyModule_AddObject(mod, "ExpatError", ErrorObject) < 0) {
+ Py_DECREF(ErrorObject);
+ return -1;
+ }
+ Py_INCREF(&Xmlparsetype);
+ if (PyModule_AddObject(mod, "XMLParserType",
+ (PyObject *) &Xmlparsetype) < 0) {
+ Py_DECREF(&Xmlparsetype);
+ return -1;
+ }
+
+ if (PyModule_AddStringConstant(mod, "EXPAT_VERSION",
+ XML_ExpatVersion()) < 0) {
+ return -1;
+ }
+ {
+ XML_Expat_Version info = XML_ExpatVersionInfo();
+ PyObject *versionInfo = Py_BuildValue("(iii)",
+ info.major,
+ info.minor,
+ info.micro);
+ if (PyModule_AddObject(mod, "version_info", versionInfo) < 0) {
+ Py_DECREF(versionInfo);
+ return -1;
+ }
+ }
+ /* XXX When Expat supports some way of figuring out how it was
+ compiled, this should check and set native_encoding
+ appropriately.
+ */
+ if (PyModule_AddStringConstant(mod, "native_encoding", "UTF-8") < 0) {
+ return -1;
+ }
+
+ if (add_errors_module(mod) < 0) {
+ return -1;
+ }
+
+ if (add_model_module(mod) < 0) {
+ return -1;
+ }
+
+#if XML_COMBINED_VERSION > 19505
+ if (add_features(mod) < 0) {
+ return -1;
+ }
+#endif
+
+#define MYCONST(c) do { \
+ if (PyModule_AddIntConstant(mod, #c, c) < 0) { \
+ return -1; \
+ } \
+ } while(0)
+
+ MYCONST(XML_PARAM_ENTITY_PARSING_NEVER);
+ MYCONST(XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE);
+ MYCONST(XML_PARAM_ENTITY_PARSING_ALWAYS);
+#undef MYCONST
+
+ static struct PyExpat_CAPI capi;
/* initialize pyexpat dispatch table */
capi.size = sizeof(capi);
capi.magic = PyExpat_CAPI_MAGIC;
@@ -1872,10 +1953,39 @@ MODULE_INITFUNC(void)
#endif
/* export using capsule */
- capi_object = PyCapsule_New(&capi, PyExpat_CAPSULE_NAME, NULL);
- if (capi_object)
- PyModule_AddObject(m, "expat_CAPI", capi_object);
- return m;
+ PyObject *capi_object = PyCapsule_New(&capi, PyExpat_CAPSULE_NAME, NULL);
+ if (capi_object == NULL) {
+ return -1;
+ }
+
+ if (PyModule_AddObject(mod, "expat_CAPI", capi_object) < 0) {
+ Py_DECREF(capi_object);
+ return -1;
+ }
+
+ return 0;
+}
+
+static struct PyModuleDef pyexpatmodule = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = MODULE_NAME,
+ .m_doc = pyexpat_module_documentation,
+ .m_size = -1,
+ .m_methods = pyexpat_methods,
+};
+
+PyMODINIT_FUNC
+PyInit_pyexpat(void)
+{
+ PyObject *mod = PyModule_Create(&pyexpatmodule);
+ if (mod == NULL)
+ return NULL;
+
+ if (pyexpat_exec(mod) < 0) {
+ Py_DECREF(mod);
+ return NULL;
+ }
+ return mod;
}
static void
diff --git a/Modules/resource.c b/Modules/resource.c
index 4f5dcf8438..f10a80f477 100644
--- a/Modules/resource.c
+++ b/Modules/resource.c
@@ -63,8 +63,20 @@ static PyStructSequence_Desc struct_rusage_desc = {
16 /* n_in_sequence */
};
-static int initialized;
-static PyTypeObject StructRUsageType;
+typedef struct {
+ PyTypeObject *StructRUsageType;
+} resourcemodulestate;
+
+
+static inline resourcemodulestate*
+get_resource_state(PyObject *module)
+{
+ void *state = PyModule_GetState(module);
+ assert(state != NULL);
+ return (resourcemodulestate *)state;
+}
+
+static struct PyModuleDef resourcemodule;
/*[clinic input]
resource.getrusage
@@ -91,7 +103,8 @@ resource_getrusage_impl(PyObject *module, int who)
return NULL;
}
- result = PyStructSequence_New(&StructRUsageType);
+ result = PyStructSequence_New(
+ get_resource_state(module)->StructRUsageType);
if (!result)
return NULL;
@@ -336,10 +349,10 @@ resource_methods[] = {
/* Module initialization */
-
static int
resource_exec(PyObject *module)
{
+ resourcemodulestate *state = get_resource_state(module);
#define ADD_INT(module, value) \
do { \
if (PyModule_AddIntConstant(module, #value, value) < 0) { \
@@ -353,13 +366,12 @@ resource_exec(PyObject *module)
Py_DECREF(PyExc_OSError);
return -1;
}
- if (!initialized) {
- if (PyStructSequence_InitType2(&StructRUsageType,
- &struct_rusage_desc) < 0)
- return -1;
- }
- if(PyModule_AddType(module, &StructRUsageType) < 0) {
+ state->StructRUsageType = PyStructSequence_NewType(&struct_rusage_desc);
+ if (state->StructRUsageType == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(module, state->StructRUsageType) < 0) {
return -1;
}
@@ -483,8 +495,6 @@ resource_exec(PyObject *module)
Py_DECREF(v);
return -1;
}
-
- initialized = 1;
return 0;
#undef ADD_INT
@@ -495,12 +505,32 @@ static struct PyModuleDef_Slot resource_slots[] = {
{0, NULL}
};
+static int
+resourcemodule_traverse(PyObject *m, visitproc visit, void *arg) {
+ Py_VISIT(get_resource_state(m)->StructRUsageType);
+ return 0;
+}
+
+static int
+resourcemodule_clear(PyObject *m) {
+ Py_CLEAR(get_resource_state(m)->StructRUsageType);
+ return 0;
+}
+
+static void
+resourcemodule_free(void *m) {
+ resourcemodule_clear((PyObject *)m);
+}
+
static struct PyModuleDef resourcemodule = {
PyModuleDef_HEAD_INIT,
.m_name = "resource",
- .m_size = 0,
+ .m_size = sizeof(resourcemodulestate),
.m_methods = resource_methods,
.m_slots = resource_slots,
+ .m_traverse = resourcemodule_traverse,
+ .m_clear = resourcemodule_clear,
+ .m_free = resourcemodule_free,
};
PyMODINIT_FUNC
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index d02e3905f5..f80da58954 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -77,16 +77,16 @@ get_select_state(PyObject *module)
return (_selectstate *)state;
}
-#define _selectstate_global get_select_state(PyState_FindModule(&selectmodule))
+#define _selectstate_by_type(type) get_select_state(PyType_GetModule(type))
/*[clinic input]
module select
-class select.poll "pollObject *" "&poll_Type"
-class select.devpoll "devpollObject *" "&devpoll_Type"
-class select.epoll "pyEpoll_Object *" "&pyEpoll_Type"
-class select.kqueue "kqueue_queue_Object *" "_selectstate_global->kqueue_queue_Type"
+class select.poll "pollObject *" "_selectstate_by_type(type)->poll_Type"
+class select.devpoll "devpollObject *" "_selectstate_by_type(type)->devpoll_Type"
+class select.epoll "pyEpoll_Object *" "_selectstate_by_type(type)->pyEpoll_Type"
+class select.kqueue "kqueue_queue_Object *" "_selectstate_by_type(type)->kqueue_queue_Type"
[clinic start generated code]*/
-/*[clinic end generated code: output=da39a3ee5e6b4b0d input=41071028e0ede093]*/
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=8072de35824aa327]*/
/* list of Python objects and their file descriptor */
typedef struct {
@@ -294,9 +294,9 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) {
- if (rfd2obj) PyMem_DEL(rfd2obj);
- if (wfd2obj) PyMem_DEL(wfd2obj);
- if (efd2obj) PyMem_DEL(efd2obj);
+ if (rfd2obj) PyMem_Free(rfd2obj);
+ if (wfd2obj) PyMem_Free(wfd2obj);
+ if (efd2obj) PyMem_Free(efd2obj);
return PyErr_NoMemory();
}
#endif /* SELECT_USES_HEAP */
@@ -381,9 +381,9 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
reap_obj(wfd2obj);
reap_obj(efd2obj);
#ifdef SELECT_USES_HEAP
- PyMem_DEL(rfd2obj);
- PyMem_DEL(wfd2obj);
- PyMem_DEL(efd2obj);
+ PyMem_Free(rfd2obj);
+ PyMem_Free(wfd2obj);
+ PyMem_Free(efd2obj);
#endif /* SELECT_USES_HEAP */
return ret;
}
@@ -709,10 +709,10 @@ select_poll_poll_impl(pollObject *self, PyObject *timeout_obj)
}
static pollObject *
-newPollObject(void)
+newPollObject(PyObject *module)
{
pollObject *self;
- self = PyObject_New(pollObject, _selectstate_global->poll_Type);
+ self = PyObject_New(pollObject, get_select_state(module)->poll_Type);
if (self == NULL)
return NULL;
/* ufd_uptodate is a Boolean, denoting whether the
@@ -740,9 +740,9 @@ poll_dealloc(pollObject *self)
{
PyObject* type = (PyObject *)Py_TYPE(self);
if (self->ufds != NULL)
- PyMem_DEL(self->ufds);
+ PyMem_Free(self->ufds);
Py_XDECREF(self->dict);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(type);
}
@@ -1073,7 +1073,7 @@ static PyGetSetDef devpoll_getsetlist[] = {
};
static devpollObject *
-newDevPollObject(void)
+newDevPollObject(PyObject *module)
{
devpollObject *self;
int fd_devpoll, limit_result;
@@ -1103,10 +1103,10 @@ newDevPollObject(void)
return NULL;
}
- self = PyObject_New(devpollObject, _selectstate_global->devpoll_Type);
+ self = PyObject_New(devpollObject, get_select_state(module)->devpoll_Type);
if (self == NULL) {
close(fd_devpoll);
- PyMem_DEL(fds);
+ PyMem_Free(fds);
return NULL;
}
self->fd_devpoll = fd_devpoll;
@@ -1129,8 +1129,8 @@ devpoll_dealloc(devpollObject *self)
{
PyObject *type = (PyObject *)Py_TYPE(self);
(void)devpoll_internal_close(self);
- PyMem_DEL(self->fds);
- PyObject_Del(self);
+ PyMem_Free(self->fds);
+ PyObject_Free(self);
Py_DECREF(type);
}
@@ -1166,7 +1166,7 @@ static PyObject *
select_poll_impl(PyObject *module)
/*[clinic end generated code: output=16a665a4e1d228c5 input=3f877909d5696bbf]*/
{
- return (PyObject *)newPollObject();
+ return (PyObject *)newPollObject(module);
}
#ifdef HAVE_SYS_DEVPOLL_H
@@ -1184,7 +1184,7 @@ static PyObject *
select_devpoll_impl(PyObject *module)
/*[clinic end generated code: output=ea9213cc87fd9581 input=53a1af94564f00a3]*/
{
- return (PyObject *)newDevPollObject();
+ return (PyObject *)newDevPollObject(module);
}
#endif
@@ -1238,8 +1238,6 @@ typedef struct {
SOCKET epfd; /* epoll control file descriptor */
} pyEpoll_Object;
-#define pyepoll_CHECK(op) (PyObject_TypeCheck((op), _selectstate_global->pyEpoll_Type))
-
static PyObject *
pyepoll_err_closed(void)
{
@@ -1667,7 +1665,8 @@ select_epoll___exit___impl(pyEpoll_Object *self, PyObject *exc_type,
PyObject *exc_value, PyObject *exc_tb)
/*[clinic end generated code: output=c480f38ce361748e input=7ae81a5a4c1a98d8]*/
{
- return PyObject_CallMethodObjArgs((PyObject *)self, _selectstate_global->close, NULL);
+ _selectstate *state = _selectstate_by_type(Py_TYPE(self));
+ return PyObject_CallMethodObjArgs((PyObject *)self, state->close, NULL);
}
static PyGetSetDef pyepoll_getsetlist[] = {
@@ -1741,15 +1740,13 @@ typedef struct {
struct kevent e;
} kqueue_event_Object;
-#define kqueue_event_Check(op) (PyObject_TypeCheck((op), _selectstate_global->kqueue_event_Type))
+#define kqueue_event_Check(op, state) (PyObject_TypeCheck((op), state->kqueue_event_Type))
typedef struct {
PyObject_HEAD
SOCKET kqfd; /* kqueue control fd */
} kqueue_queue_Object;
-#define kqueue_queue_Check(op) (PyObject_TypeCheck((op), _selectstate_global->kqueue_queue_Type))
-
#if (SIZEOF_UINTPTR_T != SIZEOF_VOID_P)
# error uintptr_t does not match void *!
#elif (SIZEOF_UINTPTR_T == SIZEOF_LONG_LONG)
@@ -1890,8 +1887,9 @@ kqueue_event_richcompare(kqueue_event_Object *s, kqueue_event_Object *o,
int op)
{
int result;
+ _selectstate *state = _selectstate_by_type(Py_TYPE(s));
- if (!kqueue_event_Check(o)) {
+ if (!kqueue_event_Check(o, state)) {
Py_RETURN_NOTIMPLEMENTED;
}
@@ -2113,6 +2111,7 @@ select_kqueue_control_impl(kqueue_queue_Object *self, PyObject *changelist,
struct timespec timeoutspec;
struct timespec *ptimeoutspec;
_PyTime_t timeout, deadline = 0;
+ _selectstate *state = _selectstate_by_type(Py_TYPE(self));
if (self->kqfd < 0)
return kqueue_queue_err_closed();
@@ -2165,9 +2164,10 @@ select_kqueue_control_impl(kqueue_queue_Object *self, PyObject *changelist,
PyErr_NoMemory();
goto error;
}
+ _selectstate *state = _selectstate_by_type(Py_TYPE(self));
for (i = 0; i < nchanges; ++i) {
ei = PySequence_Fast_GET_ITEM(seq, i);
- if (!kqueue_event_Check(ei)) {
+ if (!kqueue_event_Check(ei, state)) {
PyErr_SetString(PyExc_TypeError,
"changelist must be an iterable of "
"select.kevent objects");
@@ -2229,7 +2229,7 @@ select_kqueue_control_impl(kqueue_queue_Object *self, PyObject *changelist,
for (i = 0; i < gotevents; i++) {
kqueue_event_Object *ch;
- ch = PyObject_New(kqueue_event_Object, _selectstate_global->kqueue_event_Type);
+ ch = PyObject_New(kqueue_event_Object, state->kqueue_event_Type);
if (ch == NULL) {
goto error;
}
@@ -2392,24 +2392,28 @@ On Windows, only sockets are supported; on Unix, all file descriptors.");
static int
_select_traverse(PyObject *module, visitproc visit, void *arg)
{
- Py_VISIT(get_select_state(module)->close);
- Py_VISIT(get_select_state(module)->poll_Type);
- Py_VISIT(get_select_state(module)->devpoll_Type);
- Py_VISIT(get_select_state(module)->pyEpoll_Type);
- Py_VISIT(get_select_state(module)->kqueue_event_Type);
- Py_VISIT(get_select_state(module)->kqueue_queue_Type);
+ _selectstate *state = get_select_state(module);
+
+ Py_VISIT(state->close);
+ Py_VISIT(state->poll_Type);
+ Py_VISIT(state->devpoll_Type);
+ Py_VISIT(state->pyEpoll_Type);
+ Py_VISIT(state->kqueue_event_Type);
+ Py_VISIT(state->kqueue_queue_Type);
return 0;
}
static int
_select_clear(PyObject *module)
{
- Py_CLEAR(get_select_state(module)->close);
- Py_CLEAR(get_select_state(module)->poll_Type);
- Py_CLEAR(get_select_state(module)->devpoll_Type);
- Py_CLEAR(get_select_state(module)->pyEpoll_Type);
- Py_CLEAR(get_select_state(module)->kqueue_event_Type);
- Py_CLEAR(get_select_state(module)->kqueue_queue_Type);
+ _selectstate *state = get_select_state(module);
+
+ Py_CLEAR(state->close);
+ Py_CLEAR(state->poll_Type);
+ Py_CLEAR(state->devpoll_Type);
+ Py_CLEAR(state->pyEpoll_Type);
+ Py_CLEAR(state->kqueue_event_Type);
+ Py_CLEAR(state->kqueue_queue_Type);
return 0;
}
@@ -2419,30 +2423,18 @@ _select_free(void *module)
_select_clear((PyObject *)module);
}
-static struct PyModuleDef selectmodule = {
- PyModuleDef_HEAD_INIT,
- "select",
- module_doc,
- sizeof(_selectstate),
- select_methods,
- NULL,
- _select_traverse,
- _select_clear,
- _select_free,
-};
-
-PyMODINIT_FUNC
-PyInit_select(void)
+int
+_select_exec(PyObject *m)
{
- PyObject *m;
- m = PyModule_Create(&selectmodule);
- if (m == NULL)
- return NULL;
+ _selectstate *state = get_select_state(m);
- get_select_state(m)->close = PyUnicode_InternFromString("close");
-
- Py_INCREF(PyExc_OSError);
- PyModule_AddObject(m, "error", PyExc_OSError);
+ state->close = PyUnicode_InternFromString("close");
+ if (state->close == NULL) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "error", PyExc_OSError) < 0) {
+ return -1;
+ }
#ifdef PIPE_BUF
#ifdef HAVE_BROKEN_PIPE_BUF
@@ -2462,10 +2454,11 @@ PyInit_select(void)
#else
{
#endif
- PyObject *poll_Type = PyType_FromSpec(&poll_Type_spec);
- if (poll_Type == NULL)
- return NULL;
- get_select_state(m)->poll_Type = (PyTypeObject *)poll_Type;
+ state->poll_Type = (PyTypeObject *)PyType_FromModuleAndSpec(
+ m, &poll_Type_spec, NULL);
+ if (state->poll_Type == NULL) {
+ return -1;
+ }
PyModule_AddIntMacro(m, POLLIN);
PyModule_AddIntMacro(m, POLLPRI);
@@ -2497,19 +2490,22 @@ PyInit_select(void)
#endif /* HAVE_POLL */
#ifdef HAVE_SYS_DEVPOLL_H
- PyObject *devpoll_Type = PyType_FromSpec(&devpoll_Type_spec);
- if (devpoll_Type == NULL)
- return NULL;
- get_select_state(m)->devpoll_Type = (PyTypeObject *)devpoll_Type;
+ state->devpoll_Type = (PyTypeObject *)PyType_FromModuleAndSpec(
+ m, &devpoll_Type_spec, NULL);
+ if (state->devpoll_Type == NULL) {
+ return -1;
+ }
#endif
#ifdef HAVE_EPOLL
- PyObject *pyEpoll_Type = PyType_FromSpec(&pyEpoll_Type_spec);
- if (pyEpoll_Type == NULL)
- return NULL;
- get_select_state(m)->pyEpoll_Type = (PyTypeObject *)pyEpoll_Type;
- Py_INCREF(pyEpoll_Type);
- PyModule_AddObject(m, "epoll", (PyObject *)get_select_state(m)->pyEpoll_Type);
+ state->pyEpoll_Type = (PyTypeObject *)PyType_FromModuleAndSpec(
+ m, &pyEpoll_Type_spec, NULL);
+ if (state->pyEpoll_Type == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(m, state->pyEpoll_Type) < 0) {
+ return -1;
+ }
PyModule_AddIntMacro(m, EPOLLIN);
PyModule_AddIntMacro(m, EPOLLOUT);
@@ -2551,19 +2547,23 @@ PyInit_select(void)
#endif /* HAVE_EPOLL */
#ifdef HAVE_KQUEUE
- PyObject *kqueue_event_Type = PyType_FromSpec(&kqueue_event_Type_spec);
- if (kqueue_event_Type == NULL)
- return NULL;
- get_select_state(m)->kqueue_event_Type = (PyTypeObject *)kqueue_event_Type;
- Py_INCREF(get_select_state(m)->kqueue_event_Type);
- PyModule_AddObject(m, "kevent", kqueue_event_Type);
+ state->kqueue_event_Type = (PyTypeObject *)PyType_FromModuleAndSpec(
+ m, &kqueue_event_Type_spec, NULL);
+ if (state->kqueue_event_Type == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(m, state->kqueue_event_Type) < 0) {
+ return -1;
+ }
- PyObject *kqueue_queue_Type = PyType_FromSpec(&kqueue_queue_Type_spec);
- if (kqueue_queue_Type == NULL)
- return NULL;
- get_select_state(m)->kqueue_queue_Type = (PyTypeObject *)kqueue_queue_Type;
- Py_INCREF(get_select_state(m)->kqueue_queue_Type);
- PyModule_AddObject(m, "kqueue", kqueue_queue_Type);
+ state->kqueue_queue_Type = (PyTypeObject *)PyType_FromModuleAndSpec(
+ m, &kqueue_queue_Type_spec, NULL);
+ if (state->kqueue_queue_Type == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(m, state->kqueue_queue_Type) < 0) {
+ return -1;
+ }
/* event filters */
PyModule_AddIntConstant(m, "KQ_FILTER_READ", EVFILT_READ);
@@ -2640,5 +2640,28 @@ PyInit_select(void)
#endif
#endif /* HAVE_KQUEUE */
- return m;
+ return 0;
+}
+
+static PyModuleDef_Slot _select_slots[] = {
+ {Py_mod_exec, _select_exec},
+ {0, NULL}
+};
+
+static struct PyModuleDef selectmodule = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "select",
+ .m_doc = module_doc,
+ .m_size = sizeof(_selectstate),
+ .m_methods = select_methods,
+ .m_slots = _select_slots,
+ .m_traverse = _select_traverse,
+ .m_clear = _select_clear,
+ .m_free = _select_free,
+};
+
+PyMODINIT_FUNC
+PyInit_select(void)
+{
+ return PyModuleDef_Init(&selectmodule);
}
diff --git a/Modules/sha1module.c b/Modules/sha1module.c
index c22437de25..5209857041 100644
--- a/Modules/sha1module.c
+++ b/Modules/sha1module.c
@@ -320,7 +320,7 @@ static void
SHA1_dealloc(PyObject *ptr)
{
PyTypeObject *tp = Py_TYPE(ptr);
- PyObject_Del(ptr);
+ PyObject_Free(ptr);
Py_DECREF(tp);
}
diff --git a/Modules/sha256module.c b/Modules/sha256module.c
index edd4d01092..6b8bd8f1d2 100644
--- a/Modules/sha256module.c
+++ b/Modules/sha256module.c
@@ -397,7 +397,7 @@ static void
SHA_dealloc(PyObject *ptr)
{
PyTypeObject *tp = Py_TYPE(ptr);
- PyObject_Del(ptr);
+ PyObject_Free(ptr);
Py_DECREF(tp);
}
diff --git a/Modules/sha512module.c b/Modules/sha512module.c
index 725098def4..3fd9fa4c8d 100644
--- a/Modules/sha512module.c
+++ b/Modules/sha512module.c
@@ -453,7 +453,7 @@ static void
SHA512_dealloc(PyObject *ptr)
{
PyTypeObject *tp = Py_TYPE(ptr);
- PyObject_Del(ptr);
+ PyObject_Free(ptr);
Py_DECREF(tp);
}
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 0ab3a71b18..7ac797a3aa 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -120,7 +120,11 @@ static volatile struct {
#else
#define INVALID_FD (-1)
static volatile struct {
+#ifdef __VXWORKS__
+ int fd;
+#else
sig_atomic_t fd;
+#endif
int warn_on_full_buffer;
} wakeup = {.fd = INVALID_FD, .warn_on_full_buffer = 1};
#endif
@@ -130,15 +134,16 @@ static _Py_atomic_int is_tripped;
static PyObject *DefaultHandler;
static PyObject *IgnoreHandler;
-static PyObject *IntHandler;
#ifdef MS_WINDOWS
static HANDLE sigint_event = NULL;
#endif
-#ifdef HAVE_GETITIMER
+#if defined(HAVE_GETITIMER) || defined(HAVE_SETITIMER)
static PyObject *ItimerError;
+#endif
+#ifdef HAVE_GETITIMER
/* auxiliary functions for setitimer */
static int
timeval_from_double(PyObject *obj, struct timeval *tv)
@@ -247,10 +252,6 @@ report_wakeup_send_error(void* data)
static void
trip_signal(int sig_num)
{
- unsigned char byte;
- int fd;
- Py_ssize_t rc;
-
_Py_atomic_store_relaxed(&Handlers[sig_num].tripped, 1);
/* Set is_tripped after setting .tripped, as it gets
@@ -282,6 +283,7 @@ trip_signal(int sig_num)
See bpo-30038 for more details.
*/
+ int fd;
#ifdef MS_WINDOWS
fd = Py_SAFE_DOWNCAST(wakeup.fd, SOCKET_T, int);
#else
@@ -289,10 +291,10 @@ trip_signal(int sig_num)
#endif
if (fd != INVALID_FD) {
- byte = (unsigned char)sig_num;
+ unsigned char byte = (unsigned char)sig_num;
#ifdef MS_WINDOWS
if (wakeup.use_send) {
- rc = send(fd, &byte, 1, 0);
+ Py_ssize_t rc = send(fd, &byte, 1, 0);
if (rc < 0) {
int last_error = GetLastError();
@@ -312,7 +314,7 @@ trip_signal(int sig_num)
{
/* _Py_write_noraise() retries write() if write() is interrupted by
a signal (fails with EINTR). */
- rc = _Py_write_noraise(fd, &byte, 1);
+ Py_ssize_t rc = _Py_write_noraise(fd, &byte, 1);
if (rc < 0) {
if (wakeup.warn_on_full_buffer ||
@@ -515,8 +517,7 @@ signal_signal_impl(PyObject *module, int signalnum, PyObject *handler)
}
old_handler = Handlers[signalnum].func;
- Py_INCREF(handler);
- Handlers[signalnum].func = handler;
+ Handlers[signalnum].func = Py_NewRef(handler);
if (old_handler != NULL) {
return old_handler;
@@ -554,8 +555,7 @@ signal_getsignal_impl(PyObject *module, int signalnum)
}
old_handler = Handlers[signalnum].func;
if (old_handler != NULL) {
- Py_INCREF(old_handler);
- return old_handler;
+ return Py_NewRef(old_handler);
}
else {
Py_RETURN_NONE;
@@ -710,7 +710,7 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args, PyObject *kwds)
if (sockfd == (SOCKET_T)(-1) && PyErr_Occurred())
return NULL;
#else
- int fd, old_fd;
+ int fd;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "i|$p:set_wakeup_fd", kwlist,
&fd, &warn_on_full_buffer))
@@ -792,7 +792,7 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args, PyObject *kwds)
}
}
- old_fd = wakeup.fd;
+ int old_fd = wakeup.fd;
wakeup.fd = fd;
wakeup.warn_on_full_buffer = warn_on_full_buffer;
@@ -813,14 +813,14 @@ The fd must be non-blocking.");
int
PySignal_SetWakeupFd(int fd)
{
- int old_fd;
- if (fd < 0)
+ if (fd < 0) {
fd = -1;
+ }
#ifdef MS_WINDOWS
- old_fd = Py_SAFE_DOWNCAST(wakeup.fd, SOCKET_T, int);
+ int old_fd = Py_SAFE_DOWNCAST(wakeup.fd, SOCKET_T, int);
#else
- old_fd = wakeup.fd;
+ int old_fd = wakeup.fd;
#endif
wakeup.fd = fd;
wakeup.warn_on_full_buffer = 1;
@@ -851,7 +851,7 @@ signal_setitimer_impl(PyObject *module, int which, PyObject *seconds,
PyObject *interval)
/*[clinic end generated code: output=65f9dcbddc35527b input=de43daf194e6f66f]*/
{
- struct itimerval new, old;
+ struct itimerval new;
if (timeval_from_double(seconds, &new.it_value) < 0) {
return NULL;
@@ -861,6 +861,7 @@ signal_setitimer_impl(PyObject *module, int which, PyObject *seconds,
}
/* Let OS check "which" value */
+ struct itimerval old;
if (setitimer(which, &new, &old) != 0) {
PyErr_SetFromErrno(ItimerError);
return NULL;
@@ -1074,7 +1075,6 @@ signal_valid_signals_impl(PyObject *module)
#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
-static int initialized;
static PyStructSequence_Field struct_siginfo_fields[] = {
{"si_signo", "signal number"},
{"si_code", "signal code"},
@@ -1380,320 +1380,279 @@ the first is the signal number, the second is the interrupted stack frame.");
static int
-signal_exec(PyObject *m)
+signal_add_constants(PyObject *module)
{
- /* add the functions */
-#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
- if (!initialized) {
- if (PyStructSequence_InitType2(&SiginfoType, &struct_siginfo_desc) < 0) {
- return -1;
- }
+#define ADD_INT_MACRO(macro) \
+ if (PyModule_AddIntConstant(module, #macro, macro) < 0) { \
+ return -1; \
}
- if (PyModule_AddType(m, &SiginfoType) < 0) {
- return -1;
- }
- initialized = 1;
-#endif
-
- /* Add some symbolic constants to the module */
- PyObject *d = PyModule_GetDict(m);
-
- DefaultHandler = PyLong_FromVoidPtr((void *)SIG_DFL);
- if (!DefaultHandler ||
- PyDict_SetItemString(d, "SIG_DFL", DefaultHandler) < 0) {
- return -1;
- }
-
- IgnoreHandler = PyLong_FromVoidPtr((void *)SIG_IGN);
- if (!IgnoreHandler ||
- PyDict_SetItemString(d, "SIG_IGN", IgnoreHandler) < 0) {
- return -1;
- }
-
- if (PyModule_AddIntMacro(m, NSIG))
- return -1;
+ ADD_INT_MACRO(NSIG);
+ // SIG_xxx pthread_sigmask() constants
#ifdef SIG_BLOCK
- if (PyModule_AddIntMacro(m, SIG_BLOCK))
- return -1;
+ ADD_INT_MACRO(SIG_BLOCK);
#endif
#ifdef SIG_UNBLOCK
- if (PyModule_AddIntMacro(m, SIG_UNBLOCK))
- return -1;
+ ADD_INT_MACRO(SIG_UNBLOCK);
#endif
#ifdef SIG_SETMASK
- if (PyModule_AddIntMacro(m, SIG_SETMASK))
- return -1;
+ ADD_INT_MACRO(SIG_SETMASK);
#endif
- IntHandler = PyMapping_GetItemString(d, "default_int_handler");
- if (!IntHandler)
- return -1;
-
- _Py_atomic_store_relaxed(&Handlers[0].tripped, 0);
- for (int i = 1; i < NSIG; i++) {
- void (*t)(int);
- t = PyOS_getsig(i);
- _Py_atomic_store_relaxed(&Handlers[i].tripped, 0);
- if (t == SIG_DFL)
- Handlers[i].func = DefaultHandler;
- else if (t == SIG_IGN)
- Handlers[i].func = IgnoreHandler;
- else
- Handlers[i].func = Py_None; /* None of our business */
- Py_INCREF(Handlers[i].func);
- }
- if (Handlers[SIGINT].func == DefaultHandler) {
- /* Install default int handler */
- Py_INCREF(IntHandler);
- Py_SETREF(Handlers[SIGINT].func, IntHandler);
- PyOS_setsig(SIGINT, signal_handler);
- }
-
+ // SIGxxx signal number constants
#ifdef SIGHUP
- if (PyModule_AddIntMacro(m, SIGHUP))
- return -1;
+ ADD_INT_MACRO(SIGHUP);
#endif
#ifdef SIGINT
- if (PyModule_AddIntMacro(m, SIGINT))
- return -1;
+ ADD_INT_MACRO(SIGINT);
#endif
#ifdef SIGBREAK
- if (PyModule_AddIntMacro(m, SIGBREAK))
- return -1;
+ ADD_INT_MACRO(SIGBREAK);
#endif
#ifdef SIGQUIT
- if (PyModule_AddIntMacro(m, SIGQUIT))
- return -1;
+ ADD_INT_MACRO(SIGQUIT);
#endif
#ifdef SIGILL
- if (PyModule_AddIntMacro(m, SIGILL))
- return -1;
+ ADD_INT_MACRO(SIGILL);
#endif
#ifdef SIGTRAP
- if (PyModule_AddIntMacro(m, SIGTRAP))
- return -1;
+ ADD_INT_MACRO(SIGTRAP);
#endif
#ifdef SIGIOT
- if (PyModule_AddIntMacro(m, SIGIOT))
- return -1;
+ ADD_INT_MACRO(SIGIOT);
#endif
#ifdef SIGABRT
- if (PyModule_AddIntMacro(m, SIGABRT))
- return -1;
+ ADD_INT_MACRO(SIGABRT);
#endif
#ifdef SIGEMT
- if (PyModule_AddIntMacro(m, SIGEMT))
- return -1;
+ ADD_INT_MACRO(SIGEMT);
#endif
#ifdef SIGFPE
- if (PyModule_AddIntMacro(m, SIGFPE))
- return -1;
+ ADD_INT_MACRO(SIGFPE);
#endif
#ifdef SIGKILL
- if (PyModule_AddIntMacro(m, SIGKILL))
- return -1;
+ ADD_INT_MACRO(SIGKILL);
#endif
#ifdef SIGBUS
- if (PyModule_AddIntMacro(m, SIGBUS))
- return -1;
+ ADD_INT_MACRO(SIGBUS);
#endif
#ifdef SIGSEGV
- if (PyModule_AddIntMacro(m, SIGSEGV))
- return -1;
+ ADD_INT_MACRO(SIGSEGV);
#endif
#ifdef SIGSYS
- if (PyModule_AddIntMacro(m, SIGSYS))
- return -1;
+ ADD_INT_MACRO(SIGSYS);
#endif
#ifdef SIGPIPE
- if (PyModule_AddIntMacro(m, SIGPIPE))
- return -1;
+ ADD_INT_MACRO(SIGPIPE);
#endif
#ifdef SIGALRM
- if (PyModule_AddIntMacro(m, SIGALRM))
- return -1;
+ ADD_INT_MACRO(SIGALRM);
#endif
#ifdef SIGTERM
- if (PyModule_AddIntMacro(m, SIGTERM))
- return -1;
+ ADD_INT_MACRO(SIGTERM);
#endif
#ifdef SIGUSR1
- if (PyModule_AddIntMacro(m, SIGUSR1))
- return -1;
+ ADD_INT_MACRO(SIGUSR1);
#endif
#ifdef SIGUSR2
- if (PyModule_AddIntMacro(m, SIGUSR2))
- return -1;
+ ADD_INT_MACRO(SIGUSR2);
#endif
#ifdef SIGCLD
- if (PyModule_AddIntMacro(m, SIGCLD))
- return -1;
+ ADD_INT_MACRO(SIGCLD);
#endif
#ifdef SIGCHLD
- if (PyModule_AddIntMacro(m, SIGCHLD))
- return -1;
+ ADD_INT_MACRO(SIGCHLD);
#endif
#ifdef SIGPWR
- if (PyModule_AddIntMacro(m, SIGPWR))
- return -1;
+ ADD_INT_MACRO(SIGPWR);
#endif
#ifdef SIGIO
- if (PyModule_AddIntMacro(m, SIGIO))
- return -1;
+ ADD_INT_MACRO(SIGIO);
#endif
#ifdef SIGURG
- if (PyModule_AddIntMacro(m, SIGURG))
- return -1;
+ ADD_INT_MACRO(SIGURG);
#endif
#ifdef SIGWINCH
- if (PyModule_AddIntMacro(m, SIGWINCH))
- return -1;
+ ADD_INT_MACRO(SIGWINCH);
#endif
#ifdef SIGPOLL
- if (PyModule_AddIntMacro(m, SIGPOLL))
- return -1;
+ ADD_INT_MACRO(SIGPOLL);
#endif
#ifdef SIGSTOP
- if (PyModule_AddIntMacro(m, SIGSTOP))
- return -1;
+ ADD_INT_MACRO(SIGSTOP);
#endif
#ifdef SIGTSTP
- if (PyModule_AddIntMacro(m, SIGTSTP))
- return -1;
+ ADD_INT_MACRO(SIGTSTP);
#endif
#ifdef SIGCONT
- if (PyModule_AddIntMacro(m, SIGCONT))
- return -1;
+ ADD_INT_MACRO(SIGCONT);
#endif
#ifdef SIGTTIN
- if (PyModule_AddIntMacro(m, SIGTTIN))
- return -1;
+ ADD_INT_MACRO(SIGTTIN);
#endif
#ifdef SIGTTOU
- if (PyModule_AddIntMacro(m, SIGTTOU))
- return -1;
+ ADD_INT_MACRO(SIGTTOU);
#endif
#ifdef SIGVTALRM
- if (PyModule_AddIntMacro(m, SIGVTALRM))
- return -1;
+ ADD_INT_MACRO(SIGVTALRM);
#endif
#ifdef SIGPROF
- if (PyModule_AddIntMacro(m, SIGPROF))
- return -1;
+ ADD_INT_MACRO(SIGPROF);
#endif
#ifdef SIGXCPU
- if (PyModule_AddIntMacro(m, SIGXCPU))
- return -1;
+ ADD_INT_MACRO(SIGXCPU);
#endif
#ifdef SIGXFSZ
- if (PyModule_AddIntMacro(m, SIGXFSZ))
- return -1;
+ ADD_INT_MACRO(SIGXFSZ);
#endif
#ifdef SIGRTMIN
- if (PyModule_AddIntMacro(m, SIGRTMIN))
- return -1;
+ ADD_INT_MACRO(SIGRTMIN);
#endif
#ifdef SIGRTMAX
- if (PyModule_AddIntMacro(m, SIGRTMAX))
- return -1;
+ ADD_INT_MACRO(SIGRTMAX);
#endif
#ifdef SIGINFO
- if (PyModule_AddIntMacro(m, SIGINFO))
- return -1;
+ ADD_INT_MACRO(SIGINFO);
#endif
+ // ITIMER_xxx constants
#ifdef ITIMER_REAL
- if (PyModule_AddIntMacro(m, ITIMER_REAL))
- return -1;
+ ADD_INT_MACRO(ITIMER_REAL);
#endif
#ifdef ITIMER_VIRTUAL
- if (PyModule_AddIntMacro(m, ITIMER_VIRTUAL))
- return -1;
+ ADD_INT_MACRO(ITIMER_VIRTUAL);
#endif
#ifdef ITIMER_PROF
- if (PyModule_AddIntMacro(m, ITIMER_PROF))
- return -1;
-#endif
-
-#if defined (HAVE_SETITIMER) || defined (HAVE_GETITIMER)
- ItimerError = PyErr_NewException("signal.ItimerError",
- PyExc_OSError, NULL);
- if (!ItimerError ||
- PyDict_SetItemString(d, "ItimerError", ItimerError) < 0) {
- return -1;
- }
+ ADD_INT_MACRO(ITIMER_PROF);
#endif
+ // CTRL_xxx Windows signals
#ifdef CTRL_C_EVENT
- if (PyModule_AddIntMacro(m, CTRL_C_EVENT))
- return -1;
+ ADD_INT_MACRO(CTRL_C_EVENT);
#endif
-
#ifdef CTRL_BREAK_EVENT
- if (PyModule_AddIntMacro(m, CTRL_BREAK_EVENT))
- return -1;
+ ADD_INT_MACRO(CTRL_BREAK_EVENT);
#endif
-#ifdef MS_WINDOWS
- /* Create manual-reset event, initially unset */
- sigint_event = CreateEvent(NULL, TRUE, FALSE, FALSE);
-#endif
+ return 0;
- if (PyErr_Occurred()) {
+#undef ADD_INT_MACRO
+}
+
+
+static int
+signal_module_exec(PyObject *m)
+{
+ assert(!PyErr_Occurred());
+
+ if (signal_add_constants(m) < 0) {
return -1;
}
- return 0;
+ /* Add some symbolic constants to the module */
+ PyObject *d = PyModule_GetDict(m);
+ if (PyDict_SetItemString(d, "SIG_DFL", DefaultHandler) < 0) {
+ return -1;
+ }
+ if (PyDict_SetItemString(d, "SIG_IGN", IgnoreHandler) < 0) {
+ return -1;
+ }
+#if defined(HAVE_GETITIMER) || defined(HAVE_SETITIMER)
+ if (PyDict_SetItemString(d, "ItimerError", ItimerError) < 0) {
+ return -1;
+ }
+#endif
+#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
+ if (PyModule_AddType(m, &SiginfoType) < 0) {
+ return -1;
+ }
+#endif
+
+ // Get signal handlers
+ for (int signum = 1; signum < NSIG; signum++) {
+ void (*c_handler)(int) = PyOS_getsig(signum);
+ PyObject *func;
+ if (c_handler == SIG_DFL) {
+ func = DefaultHandler;
+ }
+ else if (c_handler == SIG_IGN) {
+ func = IgnoreHandler;
+ }
+ else {
+ func = Py_None; // None of our business
+ }
+ // If signal_module_exec() is called more than one, we must
+ // clear the strong reference to the previous function.
+ Py_XSETREF(Handlers[signum].func, Py_NewRef(func));
+ }
+
+ // Instal Python SIGINT handler which raises KeyboardInterrupt
+ if (Handlers[SIGINT].func == DefaultHandler) {
+ PyObject *int_handler = PyMapping_GetItemString(d, "default_int_handler");
+ if (!int_handler) {
+ return -1;
+ }
+
+ Py_SETREF(Handlers[SIGINT].func, int_handler);
+ PyOS_setsig(SIGINT, signal_handler);
+ }
+
+ assert(!PyErr_Occurred());
+ return 0;
}
-static struct PyModuleDef signalmodule = {
+static PyModuleDef_Slot signal_slots[] = {
+ {Py_mod_exec, signal_module_exec},
+ {0, NULL}
+};
+
+static struct PyModuleDef signal_module = {
PyModuleDef_HEAD_INIT,
"_signal",
.m_doc = module_doc,
- .m_size = -1,
+ .m_size = 0,
.m_methods = signal_methods,
+ .m_slots = signal_slots,
};
PyMODINIT_FUNC
PyInit__signal(void)
{
- PyObject *mod = PyModule_Create(&signalmodule);
- if (mod == NULL) {
- return NULL;
- }
-
- if (signal_exec(mod) < 0) {
- Py_DECREF(mod);
- return NULL;
- }
- return mod;
+ return PyModuleDef_Init(&signal_module);
}
-static void
-finisignal(void)
+void
+_PySignal_Fini(void)
{
- int i;
- PyObject *func;
-
- for (i = 1; i < NSIG; i++) {
- func = Handlers[i].func;
- _Py_atomic_store_relaxed(&Handlers[i].tripped, 0);
- Handlers[i].func = NULL;
- if (func != NULL && func != Py_None &&
- func != DefaultHandler && func != IgnoreHandler)
- PyOS_setsig(i, SIG_DFL);
+ // Restore default signals and clear handlers
+ for (int signum = 1; signum < NSIG; signum++) {
+ PyObject *func = Handlers[signum].func;
+ _Py_atomic_store_relaxed(&Handlers[signum].tripped, 0);
+ Handlers[signum].func = NULL;
+ if (func != NULL
+ && func != Py_None
+ && func != DefaultHandler
+ && func != IgnoreHandler)
+ {
+ PyOS_setsig(signum, SIG_DFL);
+ }
Py_XDECREF(func);
}
- Py_CLEAR(IntHandler);
+#ifdef MS_WINDOWS
+ if (sigint_event != NULL) {
+ CloseHandle(sigint_event);
+ sigint_event = NULL;
+ }
+#endif
+
Py_CLEAR(DefaultHandler);
Py_CLEAR(IgnoreHandler);
-#ifdef HAVE_GETITIMER
+#if defined(HAVE_GETITIMER) || defined(HAVE_SETITIMER)
Py_CLEAR(ItimerError);
#endif
}
@@ -1792,19 +1751,102 @@ PyErr_SetInterrupt(void)
}
}
-void
-PyOS_InitInterrupts(void)
+static int
+signal_install_handlers(void)
{
- PyObject *m = PyImport_ImportModule("_signal");
- if (m) {
- Py_DECREF(m);
+#ifdef SIGPIPE
+ PyOS_setsig(SIGPIPE, SIG_IGN);
+#endif
+#ifdef SIGXFZ
+ PyOS_setsig(SIGXFZ, SIG_IGN);
+#endif
+#ifdef SIGXFSZ
+ PyOS_setsig(SIGXFSZ, SIG_IGN);
+#endif
+
+ // Import _signal to install the Python SIGINT handler
+ PyObject *module = PyImport_ImportModule("_signal");
+ if (!module) {
+ return -1;
}
+ Py_DECREF(module);
+
+ return 0;
}
+
+/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL.
+ *
+ * All of the code in this function must only use async-signal-safe functions,
+ * listed at `man 7 signal` or
+ * http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html.
+ *
+ * If this function is updated, update also _posix_spawn() of subprocess.py.
+ */
void
-PyOS_FiniInterrupts(void)
+_Py_RestoreSignals(void)
{
- finisignal();
+#ifdef SIGPIPE
+ PyOS_setsig(SIGPIPE, SIG_DFL);
+#endif
+#ifdef SIGXFZ
+ PyOS_setsig(SIGXFZ, SIG_DFL);
+#endif
+#ifdef SIGXFSZ
+ PyOS_setsig(SIGXFSZ, SIG_DFL);
+#endif
+}
+
+
+int
+_PySignal_Init(int install_signal_handlers)
+{
+ DefaultHandler = PyLong_FromVoidPtr((void *)SIG_DFL);
+ if (!DefaultHandler) {
+ return -1;
+ }
+
+ IgnoreHandler = PyLong_FromVoidPtr((void *)SIG_IGN);
+ if (!IgnoreHandler) {
+ return -1;
+ }
+
+#if defined(HAVE_GETITIMER) || defined(HAVE_SETITIMER)
+ ItimerError = PyErr_NewException("signal.ItimerError",
+ PyExc_OSError, NULL);
+ if (!ItimerError) {
+ return -1;
+ }
+#endif
+
+#ifdef MS_WINDOWS
+ /* Create manual-reset event, initially unset */
+ sigint_event = CreateEvent(NULL, TRUE, FALSE, FALSE);
+ if (sigint_event == NULL) {
+ PyErr_SetFromWindowsErr(0);
+ return -1;
+ }
+#endif
+
+#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
+ if (SiginfoType.tp_name == NULL) {
+ if (PyStructSequence_InitType2(&SiginfoType, &struct_siginfo_desc) < 0) {
+ return -1;
+ }
+ }
+#endif
+
+ for (int signum = 1; signum < NSIG; signum++) {
+ _Py_atomic_store_relaxed(&Handlers[signum].tripped, 0);
+ }
+
+ if (install_signal_handlers) {
+ if (signal_install_handlers() < 0) {
+ return -1;
+ }
+ }
+
+ return 0;
}
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index d773836702..bb33db0fa4 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -514,7 +514,6 @@ remove_unusable_flags(PyObject *m)
by this module (but not argument type or memory errors, etc.). */
static PyObject *socket_herror;
static PyObject *socket_gaierror;
-static PyObject *socket_timeout;
/* A forward reference to the socket type object.
The sock_type variable contains pointers to various functions,
@@ -886,7 +885,7 @@ sock_call_ex(PySocketSockObject *s,
if (err)
*err = SOCK_TIMEOUT_ERR;
else
- PyErr_SetString(socket_timeout, "timed out");
+ PyErr_SetString(PyExc_TimeoutError, "timed out");
return -1;
}
@@ -2880,7 +2879,7 @@ sock_settimeout(PySocketSockObject *s, PyObject *arg)
/* Blocking mode for a Python socket object means that operations
like :meth:`recv` or :meth:`sendall` will block the execution of
the current thread until they are complete or aborted with a
- `socket.timeout` or `socket.error` errors. When timeout is `None`,
+ `TimeoutError` or `socket.error` errors. When timeout is `None`,
the underlying FD is in a blocking mode. When timeout is a positive
number, the FD is in a non-blocking mode, and socket ops are
implemented with a `select()` call.
@@ -3366,8 +3365,9 @@ sock_getsockname(PySocketSockObject *s, PyObject *Py_UNUSED(ignored))
PyDoc_STRVAR(getsockname_doc,
"getsockname() -> address info\n\
\n\
-Return the address of the local endpoint. For IP sockets, the address\n\
-info is a pair (hostaddr, port).");
+Return the address of the local endpoint. The format depends on the\n\
+address family. For IPv4 sockets, the address info is a pair\n\
+(hostaddr, port).");
#ifdef HAVE_GETPEERNAME /* Cray APP doesn't have this :-( */
@@ -4206,7 +4206,7 @@ sock_sendall(PySocketSockObject *s, PyObject *args)
}
if (interval <= 0) {
- PyErr_SetString(socket_timeout, "timed out");
+ PyErr_SetString(PyExc_TimeoutError, "timed out");
goto done;
}
}
@@ -7123,13 +7123,10 @@ PyInit__socket(void)
return NULL;
Py_INCREF(socket_gaierror);
PyModule_AddObject(m, "gaierror", socket_gaierror);
- socket_timeout = PyErr_NewException("socket.timeout",
- PyExc_OSError, NULL);
- if (socket_timeout == NULL)
- return NULL;
- PySocketModuleAPI.timeout_error = socket_timeout;
- Py_INCREF(socket_timeout);
- PyModule_AddObject(m, "timeout", socket_timeout);
+
+ PySocketModuleAPI.timeout_error = PyExc_TimeoutError;
+ PyModule_AddObjectRef(m, "timeout", PyExc_TimeoutError);
+
Py_INCREF((PyObject *)&sock_type);
if (PyModule_AddObject(m, "SocketType",
(PyObject *)&sock_type) != 0)
diff --git a/Modules/spwdmodule.c b/Modules/spwdmodule.c
index 1601ec0f2f..acea30679b 100644
--- a/Modules/spwdmodule.c
+++ b/Modules/spwdmodule.c
@@ -59,9 +59,19 @@ static PyStructSequence_Desc struct_spwd_type_desc = {
9,
};
-static int initialized;
-static PyTypeObject StructSpwdType;
+typedef struct {
+ PyTypeObject *StructSpwdType;
+} spwdmodulestate;
+static inline spwdmodulestate*
+get_spwd_state(PyObject *module)
+{
+ void *state = PyModule_GetState(module);
+ assert(state != NULL);
+ return (spwdmodulestate *)state;
+}
+
+static struct PyModuleDef spwdmodule;
static void
sets(PyObject *v, int i, const char* val)
@@ -75,10 +85,10 @@ sets(PyObject *v, int i, const char* val)
}
}
-static PyObject *mkspent(struct spwd *p)
+static PyObject *mkspent(PyObject *module, struct spwd *p)
{
int setIndex = 0;
- PyObject *v = PyStructSequence_New(&StructSpwdType);
+ PyObject *v = PyStructSequence_New(get_spwd_state(module)->StructSpwdType);
if (v == NULL)
return NULL;
@@ -144,7 +154,7 @@ spwd_getspnam_impl(PyObject *module, PyObject *arg)
PyErr_SetString(PyExc_KeyError, "getspnam(): name not found");
goto out;
}
- retval = mkspent(p);
+ retval = mkspent(module, p);
out:
Py_DECREF(bytes);
return retval;
@@ -172,7 +182,7 @@ spwd_getspall_impl(PyObject *module)
return NULL;
setspent();
while ((p = getspent()) != NULL) {
- PyObject *v = mkspent(p);
+ PyObject *v = mkspent(module, p);
if (v == NULL || PyList_Append(d, v) != 0) {
Py_XDECREF(v);
Py_DECREF(d);
@@ -197,34 +207,54 @@ static PyMethodDef spwd_methods[] = {
{NULL, NULL} /* sentinel */
};
+static int
+spwdmodule_exec(PyObject *module)
+{
+ spwdmodulestate *state = get_spwd_state(module);
+
+ state->StructSpwdType = PyStructSequence_NewType(&struct_spwd_type_desc);
+ if (state->StructSpwdType == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(module, state->StructSpwdType) < 0) {
+ return -1;
+ }
+ return 0;
+}
+
+static PyModuleDef_Slot spwdmodule_slots[] = {
+ {Py_mod_exec, spwdmodule_exec},
+ {0, NULL}
+};
+
+static int spwdmodule_traverse(PyObject *m, visitproc visit, void *arg) {
+ Py_VISIT(get_spwd_state(m)->StructSpwdType);
+ return 0;
+}
+static int spwdmodule_clear(PyObject *m) {
+ Py_CLEAR(get_spwd_state(m)->StructSpwdType);
+ return 0;
+}
+
+static void spwdmodule_free(void *m) {
+ spwdmodule_clear((PyObject *)m);
+}
static struct PyModuleDef spwdmodule = {
PyModuleDef_HEAD_INIT,
- "spwd",
- spwd__doc__,
- -1,
- spwd_methods,
- NULL,
- NULL,
- NULL,
- NULL
+ .m_name = "spwd",
+ .m_doc = spwd__doc__,
+ .m_size = sizeof(spwdmodulestate),
+ .m_methods = spwd_methods,
+ .m_slots = spwdmodule_slots,
+ .m_traverse = spwdmodule_traverse,
+ .m_clear = spwdmodule_clear,
+ .m_free = spwdmodule_free,
};
PyMODINIT_FUNC
PyInit_spwd(void)
{
- PyObject *m;
- m=PyModule_Create(&spwdmodule);
- if (m == NULL)
- return NULL;
- if (!initialized) {
- if (PyStructSequence_InitType2(&StructSpwdType,
- &struct_spwd_type_desc) < 0)
- return NULL;
- }
- Py_INCREF((PyObject *) &StructSpwdType);
- PyModule_AddObject(m, "struct_spwd", (PyObject *) &StructSpwdType);
- initialized = 1;
- return m;
+ return PyModuleDef_Init(&spwdmodule);
}
diff --git a/Modules/sre_lib.h b/Modules/sre_lib.h
index cfe0a4af2c..322f66fb4d 100644
--- a/Modules/sre_lib.h
+++ b/Modules/sre_lib.h
@@ -986,7 +986,7 @@ entrance:
ctx->pattern[1], ctx->pattern[2]));
/* install new repeat context */
- ctx->u.rep = (SRE_REPEAT*) PyObject_MALLOC(sizeof(*ctx->u.rep));
+ ctx->u.rep = (SRE_REPEAT*) PyObject_Malloc(sizeof(*ctx->u.rep));
if (!ctx->u.rep) {
PyErr_NoMemory();
RETURN_FAILURE;
@@ -1000,7 +1000,7 @@ entrance:
state->ptr = ctx->ptr;
DO_JUMP(JUMP_REPEAT, jump_repeat, ctx->pattern+ctx->pattern[0]);
state->repeat = ctx->u.rep->prev;
- PyObject_FREE(ctx->u.rep);
+ PyObject_Free(ctx->u.rep);
if (ret) {
RETURN_ON_ERROR(ret);
diff --git a/Modules/symtablemodule.c b/Modules/symtablemodule.c
index 9180f185e1..f6c378fdae 100644
--- a/Modules/symtablemodule.c
+++ b/Modules/symtablemodule.c
@@ -71,56 +71,60 @@ static PyMethodDef symtable_methods[] = {
{NULL, NULL} /* sentinel */
};
+static int
+symtable_init_stentry_type(PyObject *m)
+{
+ return PyType_Ready(&PySTEntry_Type);
+}
+
+static int
+symtable_init_constants(PyObject *m)
+{
+ if (PyModule_AddIntMacro(m, USE) < 0) return -1;
+ if (PyModule_AddIntMacro(m, DEF_GLOBAL) < 0) return -1;
+ if (PyModule_AddIntMacro(m, DEF_NONLOCAL) < 0) return -1;
+ if (PyModule_AddIntMacro(m, DEF_LOCAL) < 0) return -1;
+ if (PyModule_AddIntMacro(m, DEF_PARAM) < 0) return -1;
+ if (PyModule_AddIntMacro(m, DEF_FREE) < 0) return -1;
+ if (PyModule_AddIntMacro(m, DEF_FREE_CLASS) < 0) return -1;
+ if (PyModule_AddIntMacro(m, DEF_IMPORT) < 0) return -1;
+ if (PyModule_AddIntMacro(m, DEF_BOUND) < 0) return -1;
+ if (PyModule_AddIntMacro(m, DEF_ANNOT) < 0) return -1;
+
+ if (PyModule_AddIntConstant(m, "TYPE_FUNCTION", FunctionBlock) < 0)
+ return -1;
+ if (PyModule_AddIntConstant(m, "TYPE_CLASS", ClassBlock) < 0) return -1;
+ if (PyModule_AddIntConstant(m, "TYPE_MODULE", ModuleBlock) < 0)
+ return -1;
+
+ if (PyModule_AddIntMacro(m, LOCAL) < 0) return -1;
+ if (PyModule_AddIntMacro(m, GLOBAL_EXPLICIT) < 0) return -1;
+ if (PyModule_AddIntMacro(m, GLOBAL_IMPLICIT) < 0) return -1;
+ if (PyModule_AddIntMacro(m, FREE) < 0) return -1;
+ if (PyModule_AddIntMacro(m, CELL) < 0) return -1;
+
+ if (PyModule_AddIntConstant(m, "SCOPE_OFF", SCOPE_OFFSET) < 0) return -1;
+ if (PyModule_AddIntMacro(m, SCOPE_MASK) < 0) return -1;
+
+ return 0;
+}
+
+static PyModuleDef_Slot symtable_slots[] = {
+ {Py_mod_exec, symtable_init_stentry_type},
+ {Py_mod_exec, symtable_init_constants},
+ {0, NULL}
+};
+
static struct PyModuleDef symtablemodule = {
PyModuleDef_HEAD_INIT,
- "_symtable",
- NULL,
- -1,
- symtable_methods,
- NULL,
- NULL,
- NULL,
- NULL
+ .m_name = "_symtable",
+ .m_size = 0,
+ .m_methods = symtable_methods,
+ .m_slots = symtable_slots,
};
PyMODINIT_FUNC
PyInit__symtable(void)
{
- PyObject *m;
-
- if (PyType_Ready(&PySTEntry_Type) < 0)
- return NULL;
-
- m = PyModule_Create(&symtablemodule);
- if (m == NULL)
- return NULL;
- PyModule_AddIntMacro(m, USE);
- PyModule_AddIntMacro(m, DEF_GLOBAL);
- PyModule_AddIntMacro(m, DEF_NONLOCAL);
- PyModule_AddIntMacro(m, DEF_LOCAL);
- PyModule_AddIntMacro(m, DEF_PARAM);
- PyModule_AddIntMacro(m, DEF_FREE);
- PyModule_AddIntMacro(m, DEF_FREE_CLASS);
- PyModule_AddIntMacro(m, DEF_IMPORT);
- PyModule_AddIntMacro(m, DEF_BOUND);
- PyModule_AddIntMacro(m, DEF_ANNOT);
-
- PyModule_AddIntConstant(m, "TYPE_FUNCTION", FunctionBlock);
- PyModule_AddIntConstant(m, "TYPE_CLASS", ClassBlock);
- PyModule_AddIntConstant(m, "TYPE_MODULE", ModuleBlock);
-
- PyModule_AddIntMacro(m, LOCAL);
- PyModule_AddIntMacro(m, GLOBAL_EXPLICIT);
- PyModule_AddIntMacro(m, GLOBAL_IMPLICIT);
- PyModule_AddIntMacro(m, FREE);
- PyModule_AddIntMacro(m, CELL);
-
- PyModule_AddIntConstant(m, "SCOPE_OFF", SCOPE_OFFSET);
- PyModule_AddIntMacro(m, SCOPE_MASK);
-
- if (PyErr_Occurred()) {
- Py_DECREF(m);
- m = 0;
- }
- return m;
+ return PyModuleDef_Init(&symtablemodule);
}
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index eb192c5e7f..4caacc3b64 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -51,6 +51,15 @@
#define _Py_tzname tzname
#endif
+#if defined(__APPLE__ ) && defined(__has_builtin)
+# if __has_builtin(__builtin_available)
+# define HAVE_CLOCK_GETTIME_RUNTIME __builtin_available(macOS 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *)
+# endif
+#endif
+#ifndef HAVE_CLOCK_GETTIME_RUNTIME
+# define HAVE_CLOCK_GETTIME_RUNTIME 1
+#endif
+
#define SEC_TO_NS (1000 * 1000 * 1000)
/* Forward declarations */
@@ -65,10 +74,21 @@ _PyFloat_FromPyTime(_PyTime_t t)
}
+static int
+get_system_time(_PyTime_t *t)
+{
+ // Avoid _PyTime_GetSystemClock() which silently ignores errors.
+ return _PyTime_GetSystemClockWithInfo(t, NULL);
+}
+
+
static PyObject *
time_time(PyObject *self, PyObject *unused)
{
- _PyTime_t t = _PyTime_GetSystemClock();
+ _PyTime_t t;
+ if (get_system_time(&t) < 0) {
+ return NULL;
+ }
return _PyFloat_FromPyTime(t);
}
@@ -82,7 +102,10 @@ Fractions of a second may be present if the system clock provides them.");
static PyObject *
time_time_ns(PyObject *self, PyObject *unused)
{
- _PyTime_t t = _PyTime_GetSystemClock();
+ _PyTime_t t;
+ if (get_system_time(&t) < 0) {
+ return NULL;
+ }
return _PyTime_AsNanosecondsObject(t);
}
@@ -138,17 +161,18 @@ _PyTime_GetClockWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
}
#endif /* HAVE_CLOCK */
-static PyObject*
-perf_counter(_Py_clock_info_t *info)
-{
- _PyTime_t t;
- if (_PyTime_GetPerfCounterWithInfo(&t, info) < 0) {
- return NULL;
- }
- return _PyFloat_FromPyTime(t);
-}
#ifdef HAVE_CLOCK_GETTIME
+
+#ifdef __APPLE__
+/*
+ * The clock_* functions will be removed from the module
+ * dict entirely when the C API is not available.
+ */
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunguarded-availability"
+#endif
+
static PyObject *
time_clock_gettime(PyObject *self, PyObject *args)
{
@@ -297,6 +321,11 @@ PyDoc_STRVAR(clock_getres_doc,
"clock_getres(clk_id) -> floating point number\n\
\n\
Return the resolution (precision) of the specified clock clk_id.");
+
+#ifdef __APPLE__
+#pragma clang diagnostic pop
+#endif
+
#endif /* HAVE_CLOCK_GETRES */
#ifdef HAVE_PTHREAD_GETCPUCLOCKID
@@ -1072,10 +1101,22 @@ the local timezone used by methods such as localtime, but this behaviour\n\
should not be relied on.");
#endif /* HAVE_WORKING_TZSET */
+
+static int
+get_monotonic(_PyTime_t *t)
+{
+ // Avoid _PyTime_GetMonotonicClock() which silently ignores errors.
+ return _PyTime_GetMonotonicClockWithInfo(t, NULL);
+}
+
+
static PyObject *
time_monotonic(PyObject *self, PyObject *unused)
{
- _PyTime_t t = _PyTime_GetMonotonicClock();
+ _PyTime_t t;
+ if (get_monotonic(&t) < 0) {
+ return NULL;
+ }
return _PyFloat_FromPyTime(t);
}
@@ -1087,7 +1128,10 @@ Monotonic clock, cannot go backward.");
static PyObject *
time_monotonic_ns(PyObject *self, PyObject *unused)
{
- _PyTime_t t = _PyTime_GetMonotonicClock();
+ _PyTime_t t;
+ if (get_monotonic(&t) < 0) {
+ return NULL;
+ }
return _PyTime_AsNanosecondsObject(t);
}
@@ -1096,10 +1140,23 @@ PyDoc_STRVAR(monotonic_ns_doc,
\n\
Monotonic clock, cannot go backward, as nanoseconds.");
+
+static int
+get_perf_counter(_PyTime_t *t)
+{
+ // Avoid _PyTime_GetPerfCounter() which silently ignores errors.
+ return _PyTime_GetPerfCounterWithInfo(t, NULL);
+}
+
+
static PyObject *
time_perf_counter(PyObject *self, PyObject *unused)
{
- return perf_counter(NULL);
+ _PyTime_t t;
+ if (get_perf_counter(&t) < 0) {
+ return NULL;
+ }
+ return _PyFloat_FromPyTime(t);
}
PyDoc_STRVAR(perf_counter_doc,
@@ -1107,10 +1164,14 @@ PyDoc_STRVAR(perf_counter_doc,
\n\
Performance counter for benchmarking.");
+
static PyObject *
time_perf_counter_ns(PyObject *self, PyObject *unused)
{
- _PyTime_t t = _PyTime_GetPerfCounter();
+ _PyTime_t t;
+ if (get_perf_counter(&t) < 0) {
+ return NULL;
+ }
return _PyTime_AsNanosecondsObject(t);
}
@@ -1162,31 +1223,35 @@ _PyTime_GetProcessTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
#if defined(HAVE_CLOCK_GETTIME) \
&& (defined(CLOCK_PROCESS_CPUTIME_ID) || defined(CLOCK_PROF))
struct timespec ts;
+
+ if (HAVE_CLOCK_GETTIME_RUNTIME) {
+
#ifdef CLOCK_PROF
- const clockid_t clk_id = CLOCK_PROF;
- const char *function = "clock_gettime(CLOCK_PROF)";
+ const clockid_t clk_id = CLOCK_PROF;
+ const char *function = "clock_gettime(CLOCK_PROF)";
#else
- const clockid_t clk_id = CLOCK_PROCESS_CPUTIME_ID;
- const char *function = "clock_gettime(CLOCK_PROCESS_CPUTIME_ID)";
+ const clockid_t clk_id = CLOCK_PROCESS_CPUTIME_ID;
+ const char *function = "clock_gettime(CLOCK_PROCESS_CPUTIME_ID)";
#endif
- if (clock_gettime(clk_id, &ts) == 0) {
- if (info) {
- struct timespec res;
- info->implementation = function;
- info->monotonic = 1;
- info->adjustable = 0;
- if (clock_getres(clk_id, &res)) {
- PyErr_SetFromErrno(PyExc_OSError);
- return -1;
+ if (clock_gettime(clk_id, &ts) == 0) {
+ if (info) {
+ struct timespec res;
+ info->implementation = function;
+ info->monotonic = 1;
+ info->adjustable = 0;
+ if (clock_getres(clk_id, &res)) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return -1;
+ }
+ info->resolution = res.tv_sec + res.tv_nsec * 1e-9;
}
- info->resolution = res.tv_sec + res.tv_nsec * 1e-9;
- }
- if (_PyTime_FromTimespec(tp, &ts) < 0) {
- return -1;
+ if (_PyTime_FromTimespec(tp, &ts) < 0) {
+ return -1;
+ }
+ return 0;
}
- return 0;
}
#endif
@@ -1390,6 +1455,16 @@ _PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID)
#define HAVE_THREAD_TIME
+
+#if defined(__APPLE__) && defined(__has_attribute) && __has_attribute(availability)
+static int
+_PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
+ __attribute__((availability(macos, introduced=10.12)))
+ __attribute__((availability(ios, introduced=10.0)))
+ __attribute__((availability(tvos, introduced=10.0)))
+ __attribute__((availability(watchos, introduced=3.0)));
+#endif
+
static int
_PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
{
@@ -1421,6 +1496,15 @@ _PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
#endif
#ifdef HAVE_THREAD_TIME
+#ifdef __APPLE__
+/*
+ * The clock_* functions will be removed from the module
+ * dict entirely when the C API is not available.
+ */
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunguarded-availability"
+#endif
+
static PyObject *
time_thread_time(PyObject *self, PyObject *unused)
{
@@ -1451,6 +1535,11 @@ PyDoc_STRVAR(thread_time_ns_doc,
\n\
Thread time for profiling as nanoseconds:\n\
sum of the kernel and user-space CPU time.");
+
+#ifdef __APPLE__
+#pragma clang diagnostic pop
+#endif
+
#endif
@@ -1500,9 +1589,19 @@ time_get_clock_info(PyObject *self, PyObject *args)
}
#ifdef HAVE_THREAD_TIME
else if (strcmp(name, "thread_time") == 0) {
- if (_PyTime_GetThreadTimeWithInfo(&t, &info) < 0) {
+
+#ifdef __APPLE__
+ if (HAVE_CLOCK_GETTIME_RUNTIME) {
+#endif
+ if (_PyTime_GetThreadTimeWithInfo(&t, &info) < 0) {
+ return NULL;
+ }
+#ifdef __APPLE__
+ } else {
+ PyErr_SetString(PyExc_ValueError, "unknown clock");
return NULL;
}
+#endif
}
#endif
else {
@@ -1783,68 +1882,116 @@ if it is -1, mktime() should guess based on the date and time.\n");
static int
time_exec(PyObject *module)
{
+#if defined(__APPLE__) && defined(HAVE_CLOCK_GETTIME)
+ if (HAVE_CLOCK_GETTIME_RUNTIME) {
+ /* pass: ^^^ cannot use '!' here */
+ } else {
+ PyObject* dct = PyModule_GetDict(module);
+ if (dct == NULL) {
+ return -1;
+ }
+
+ if (PyDict_DelItemString(dct, "clock_gettime") == -1) {
+ PyErr_Clear();
+ }
+ if (PyDict_DelItemString(dct, "clock_gettime_ns") == -1) {
+ PyErr_Clear();
+ }
+ if (PyDict_DelItemString(dct, "clock_settime") == -1) {
+ PyErr_Clear();
+ }
+ if (PyDict_DelItemString(dct, "clock_settime_ns") == -1) {
+ PyErr_Clear();
+ }
+ if (PyDict_DelItemString(dct, "clock_getres") == -1) {
+ PyErr_Clear();
+ }
+ }
+#endif
+#if defined(__APPLE__) && defined(HAVE_THREAD_TIME)
+ if (HAVE_CLOCK_GETTIME_RUNTIME) {
+ /* pass: ^^^ cannot use '!' here */
+ } else {
+ PyObject* dct = PyModule_GetDict(module);
+
+ if (PyDict_DelItemString(dct, "thread_time") == -1) {
+ PyErr_Clear();
+ }
+ if (PyDict_DelItemString(dct, "thread_time_ns") == -1) {
+ PyErr_Clear();
+ }
+ }
+#endif
/* Set, or reset, module variables like time.timezone */
if (init_timezone(module) < 0) {
return -1;
}
#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_CLOCK_SETTIME) || defined(HAVE_CLOCK_GETRES)
+ if (HAVE_CLOCK_GETTIME_RUNTIME) {
#ifdef CLOCK_REALTIME
- if (PyModule_AddIntMacro(module, CLOCK_REALTIME) < 0) {
- return -1;
- }
+ if (PyModule_AddIntMacro(module, CLOCK_REALTIME) < 0) {
+ return -1;
+ }
#endif
+
#ifdef CLOCK_MONOTONIC
- if (PyModule_AddIntMacro(module, CLOCK_MONOTONIC) < 0) {
- return -1;
- }
+
+ if (PyModule_AddIntMacro(module, CLOCK_MONOTONIC) < 0) {
+ return -1;
+ }
+
#endif
#ifdef CLOCK_MONOTONIC_RAW
- if (PyModule_AddIntMacro(module, CLOCK_MONOTONIC_RAW) < 0) {
- return -1;
- }
+ if (PyModule_AddIntMacro(module, CLOCK_MONOTONIC_RAW) < 0) {
+ return -1;
+ }
#endif
+
#ifdef CLOCK_HIGHRES
- if (PyModule_AddIntMacro(module, CLOCK_HIGHRES) < 0) {
- return -1;
- }
+ if (PyModule_AddIntMacro(module, CLOCK_HIGHRES) < 0) {
+ return -1;
+ }
#endif
#ifdef CLOCK_PROCESS_CPUTIME_ID
- if (PyModule_AddIntMacro(module, CLOCK_PROCESS_CPUTIME_ID) < 0) {
- return -1;
- }
+ if (PyModule_AddIntMacro(module, CLOCK_PROCESS_CPUTIME_ID) < 0) {
+ return -1;
+ }
#endif
+
#ifdef CLOCK_THREAD_CPUTIME_ID
- if (PyModule_AddIntMacro(module, CLOCK_THREAD_CPUTIME_ID) < 0) {
- return -1;
- }
+ if (PyModule_AddIntMacro(module, CLOCK_THREAD_CPUTIME_ID) < 0) {
+ return -1;
+ }
#endif
#ifdef CLOCK_PROF
- if (PyModule_AddIntMacro(module, CLOCK_PROF) < 0) {
- return -1;
- }
+ if (PyModule_AddIntMacro(module, CLOCK_PROF) < 0) {
+ return -1;
+ }
#endif
#ifdef CLOCK_BOOTTIME
- if (PyModule_AddIntMacro(module, CLOCK_BOOTTIME) < 0) {
- return -1;
- }
+ if (PyModule_AddIntMacro(module, CLOCK_BOOTTIME) < 0) {
+ return -1;
+ }
#endif
#ifdef CLOCK_TAI
- if (PyModule_AddIntMacro(module, CLOCK_TAI) < 0) {
- return -1;
- }
+ if (PyModule_AddIntMacro(module, CLOCK_TAI) < 0) {
+ return -1;
+ }
#endif
#ifdef CLOCK_UPTIME
- if (PyModule_AddIntMacro(module, CLOCK_UPTIME) < 0) {
- return -1;
- }
+ if (PyModule_AddIntMacro(module, CLOCK_UPTIME) < 0) {
+ return -1;
+ }
#endif
#ifdef CLOCK_UPTIME_RAW
- if (PyModule_AddIntMacro(module, CLOCK_UPTIME_RAW) < 0) {
- return -1;
- }
+
+ if (PyModule_AddIntMacro(module, CLOCK_UPTIME_RAW) < 0) {
+ return -1;
+ }
#endif
+ }
#endif /* defined(HAVE_CLOCK_GETTIME) || defined(HAVE_CLOCK_SETTIME) || defined(HAVE_CLOCK_GETRES) */
@@ -1915,7 +2062,10 @@ pysleep(_PyTime_t secs)
HANDLE hInterruptEvent;
#endif
- deadline = _PyTime_GetMonotonicClock() + secs;
+ if (get_monotonic(&monotonic) < 0) {
+ return -1;
+ }
+ deadline = monotonic + secs;
do {
#ifndef MS_WINDOWS
@@ -1967,10 +2117,13 @@ pysleep(_PyTime_t secs)
if (PyErr_CheckSignals())
return -1;
- monotonic = _PyTime_GetMonotonicClock();
+ if (get_monotonic(&monotonic) < 0) {
+ return -1;
+ }
secs = deadline - monotonic;
- if (secs < 0)
+ if (secs < 0) {
break;
+ }
/* retry with the recomputed delay */
} while (1);
diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c
index fcf801dc9e..4b8c46c779 100644
--- a/Modules/unicodedata.c
+++ b/Modules/unicodedata.c
@@ -1418,7 +1418,7 @@ static void
ucd_dealloc(PreviousDBVersion *self)
{
PyTypeObject *tp = Py_TYPE(self);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(tp);
}
diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c
index 5b05a9454a..883c8a9b5e 100644
--- a/Modules/xxlimited.c
+++ b/Modules/xxlimited.c
@@ -3,47 +3,103 @@
also declares object types. All occurrences of 'Xxo' should be changed
to something reasonable for your objects. After that, all other
occurrences of 'xx' should be changed to something reasonable for your
- module. If your module is named foo your sourcefile should be named
- foomodule.c.
+ module. If your module is named foo your source file should be named
+ foo.c or foomodule.c.
You will probably want to delete all references to 'x_attr' and add
your own types of attributes instead. Maybe you want to name your
local variables other than 'self'. If your object type is needed in
other files, you'll have to create a file "foobarobject.h"; see
- floatobject.h for an example. */
+ floatobject.h for an example.
-/* Xxo objects */
+ This module roughly corresponds to::
+
+ class Xxo:
+ """A class that explicitly stores attributes in an internal dict"""
+
+ def __init__(self):
+ # In the C class, "_x_attr" is not accessible from Python code
+ self._x_attr = {}
+
+ def __getattr__(self, name):
+ return self._x_attr[name]
+
+ def __setattr__(self, name, value):
+ self._x_attr[name] = value
+
+ def __delattr__(self, name):
+ del self._x_attr[name]
+
+ def demo(o, /):
+ if isinstance(o, str):
+ return o
+ elif isinstance(o, Xxo):
+ return o
+ else:
+ raise Error('argument must be str or Xxo')
+
+ class Error(Exception):
+ """Exception raised by the xxlimited module"""
+
+ def foo(i: int, j: int, /):
+ """Return the sum of i and j."""
+ # Unlike this pseudocode, the C function will *only* work with
+ # integers and perform C long int arithmetic
+ return i + j
+
+ def new():
+ return Xxo()
+
+ def Str(str):
+ # A trivial subclass of a built-in type
+ pass
+ */
#include "Python.h"
-static PyObject *ErrorObject;
+// Module state
+typedef struct {
+ PyObject *Xxo_Type; // Xxo class
+ PyObject *Error_Type; // Error class
+} xx_state;
+
+
+/* Xxo objects */
+// Instance state
typedef struct {
PyObject_HEAD
PyObject *x_attr; /* Attributes dictionary */
} XxoObject;
-static PyObject *Xxo_Type;
-
-#define XxoObject_Check(v) Py_IS_TYPE(v, Xxo_Type)
+// XXX: no good way to do this yet
+// #define XxoObject_Check(v) Py_IS_TYPE(v, Xxo_Type)
static XxoObject *
-newXxoObject(PyObject *arg)
+newXxoObject(PyObject *module)
{
+ xx_state *state = PyModule_GetState(module);
+ if (state == NULL) {
+ return NULL;
+ }
XxoObject *self;
- self = PyObject_GC_New(XxoObject, (PyTypeObject*)Xxo_Type);
- if (self == NULL)
+ self = PyObject_GC_New(XxoObject, (PyTypeObject*)state->Xxo_Type);
+ if (self == NULL) {
return NULL;
+ }
self->x_attr = NULL;
return self;
}
-/* Xxo methods */
+/* Xxo finalization */
static int
Xxo_traverse(XxoObject *self, visitproc visit, void *arg)
{
+ // Visit the type
Py_VISIT(Py_TYPE(self));
+
+ // Visit the attribute dict
Py_VISIT(self->x_attr);
return 0;
}
@@ -54,26 +110,18 @@ Xxo_finalize(XxoObject *self)
Py_CLEAR(self->x_attr);
}
-static PyObject *
-Xxo_demo(XxoObject *self, PyObject *args)
+static void
+Xxo_dealloc(XxoObject *self)
{
- PyObject *o = NULL;
- if (!PyArg_ParseTuple(args, "|O:demo", &o))
- return NULL;
- /* Test availability of fast type checks */
- if (o != NULL && PyUnicode_Check(o)) {
- Py_INCREF(o);
- return o;
- }
- Py_INCREF(Py_None);
- return Py_None;
+ Xxo_finalize(self);
+ PyTypeObject *tp = Py_TYPE(self);
+ freefunc free = PyType_GetSlot(tp, Py_tp_free);
+ free(self);
+ Py_DECREF(tp);
}
-static PyMethodDef Xxo_methods[] = {
- {"demo", (PyCFunction)Xxo_demo, METH_VARARGS,
- PyDoc_STR("demo() -> None")},
- {NULL, NULL} /* sentinel */
-};
+
+/* Xxo attribute handling */
static PyObject *
Xxo_getattro(XxoObject *self, PyObject *name)
@@ -92,45 +140,109 @@ Xxo_getattro(XxoObject *self, PyObject *name)
}
static int
-Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
+Xxo_setattro(XxoObject *self, PyObject *name, PyObject *v)
{
if (self->x_attr == NULL) {
+ // prepare the attribute dict
self->x_attr = PyDict_New();
- if (self->x_attr == NULL)
+ if (self->x_attr == NULL) {
return -1;
+ }
}
if (v == NULL) {
- int rv = PyDict_DelItemString(self->x_attr, name);
- if (rv < 0 && PyErr_ExceptionMatches(PyExc_KeyError))
+ // delete an attribute
+ int rv = PyDict_DelItem(self->x_attr, name);
+ if (rv < 0 && PyErr_ExceptionMatches(PyExc_KeyError)) {
PyErr_SetString(PyExc_AttributeError,
"delete non-existing Xxo attribute");
+ return -1;
+ }
return rv;
}
- else
- return PyDict_SetItemString(self->x_attr, name, v);
+ else {
+ // set an attribute
+ return PyDict_SetItem(self->x_attr, name, v);
+ }
+}
+
+/* Xxo methods */
+
+static PyObject *
+Xxo_demo(XxoObject *self, PyTypeObject *defining_class,
+ PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ if (kwnames != NULL && PyObject_Length(kwnames)) {
+ PyErr_SetString(PyExc_TypeError, "demo() takes no keyword arguments");
+ return NULL;
+ }
+ if (nargs != 1) {
+ PyErr_SetString(PyExc_TypeError, "demo() takes exactly 1 argument");
+ return NULL;
+ }
+
+ PyObject *o = args[0];
+
+ /* Test if the argument is "str" */
+ if (PyUnicode_Check(o)) {
+ Py_INCREF(o);
+ return o;
+ }
+
+ /* test if the argument is of the Xxo class */
+ if (PyObject_TypeCheck(o, defining_class)) {
+ Py_INCREF(o);
+ return o;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
}
+static PyMethodDef Xxo_methods[] = {
+ {"demo", (PyCFunction)(void(*)(void))Xxo_demo,
+ METH_METHOD | METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("demo(o) -> o")},
+ {NULL, NULL} /* sentinel */
+};
+
+/* Xxo type definition */
+
+PyDoc_STRVAR(Xxo_doc,
+ "A class that explicitly stores attributes in an internal dict");
+
static PyType_Slot Xxo_Type_slots[] = {
- {Py_tp_doc, "The Xxo type"},
+ {Py_tp_doc, (char *)Xxo_doc},
{Py_tp_traverse, Xxo_traverse},
{Py_tp_finalize, Xxo_finalize},
+ {Py_tp_dealloc, Xxo_dealloc},
{Py_tp_getattro, Xxo_getattro},
- {Py_tp_setattr, Xxo_setattr},
+ {Py_tp_setattro, Xxo_setattro},
{Py_tp_methods, Xxo_methods},
- {0, 0},
+ {0, 0}, /* sentinel */
};
static PyType_Spec Xxo_Type_spec = {
- "xxlimited.Xxo",
- sizeof(XxoObject),
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- Xxo_Type_slots
+ .name = "xxlimited.Xxo",
+ .basicsize = sizeof(XxoObject),
+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
+ .slots = Xxo_Type_slots,
};
-/* --------------------------------------------------------------------- */
-/* Function of two integers returning integer */
+/* Str type definition*/
+
+static PyType_Slot Str_Type_slots[] = {
+ {0, 0}, /* sentinel */
+};
+
+static PyType_Spec Str_Type_spec = {
+ .name = "xxlimited.Str",
+ .basicsize = 0,
+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ .slots = Str_Type_slots,
+};
+
+
+/* Function of two integers returning integer (with C "long int" arithmetic) */
PyDoc_STRVAR(xx_foo_doc,
"foo(i,j)\n\
@@ -138,7 +250,7 @@ PyDoc_STRVAR(xx_foo_doc,
Return the sum of i and j.");
static PyObject *
-xx_foo(PyObject *self, PyObject *args)
+xx_foo(PyObject *module, PyObject *args)
{
long i, j;
long res;
@@ -152,153 +264,110 @@ xx_foo(PyObject *self, PyObject *args)
/* Function of no arguments returning new Xxo object */
static PyObject *
-xx_new(PyObject *self, PyObject *args)
+xx_new(PyObject *module, PyObject *Py_UNUSED(unused))
{
XxoObject *rv;
- if (!PyArg_ParseTuple(args, ":new"))
- return NULL;
- rv = newXxoObject(args);
+ rv = newXxoObject(module);
if (rv == NULL)
return NULL;
return (PyObject *)rv;
}
-/* Test bad format character */
-
-static PyObject *
-xx_roj(PyObject *self, PyObject *args)
-{
- PyObject *a;
- long b;
- if (!PyArg_ParseTuple(args, "O#:roj", &a, &b))
- return NULL;
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-
-/* ---------- */
-
-static PyType_Slot Str_Type_slots[] = {
- {Py_tp_base, NULL}, /* filled out in module init function */
- {0, 0},
-};
-
-static PyType_Spec Str_Type_spec = {
- "xxlimited.Str",
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- Str_Type_slots
-};
-
-/* ---------- */
-
-static PyObject *
-null_richcompare(PyObject *self, PyObject *other, int op)
-{
- Py_RETURN_NOTIMPLEMENTED;
-}
-
-static PyType_Slot Null_Type_slots[] = {
- {Py_tp_base, NULL}, /* filled out in module init */
- {Py_tp_new, NULL},
- {Py_tp_richcompare, null_richcompare},
- {0, 0}
-};
-
-static PyType_Spec Null_Type_spec = {
- "xxlimited.Null",
- 0, /* basicsize */
- 0, /* itemsize */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- Null_Type_slots
-};
-/* ---------- */
/* List of functions defined in the module */
static PyMethodDef xx_methods[] = {
- {"roj", xx_roj, METH_VARARGS,
- PyDoc_STR("roj(a,b) -> None")},
{"foo", xx_foo, METH_VARARGS,
xx_foo_doc},
- {"new", xx_new, METH_VARARGS,
+ {"new", xx_new, METH_NOARGS,
PyDoc_STR("new() -> new Xx object")},
{NULL, NULL} /* sentinel */
};
+
+/* The module itself */
+
PyDoc_STRVAR(module_doc,
"This is a template module just for instruction.");
static int
xx_modexec(PyObject *m)
{
- PyObject *o;
-
- /* Due to cross platform compiler issues the slots must be filled
- * here. It's required for portability to Windows without requiring
- * C++. */
- Null_Type_slots[0].pfunc = &PyBaseObject_Type;
- Null_Type_slots[1].pfunc = PyType_GenericNew;
- Str_Type_slots[0].pfunc = &PyUnicode_Type;
-
- Xxo_Type = PyType_FromSpec(&Xxo_Type_spec);
- if (Xxo_Type == NULL)
- goto fail;
-
- /* Add some symbolic constants to the module */
- if (ErrorObject == NULL) {
- ErrorObject = PyErr_NewException("xxlimited.error", NULL, NULL);
- if (ErrorObject == NULL)
- goto fail;
+ xx_state *state = PyModule_GetState(m);
+
+ state->Error_Type = PyErr_NewException("xxlimited.Error", NULL, NULL);
+ if (state->Error_Type == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(m, (PyTypeObject*)state->Error_Type) < 0) {
+ return -1;
+ }
+
+ state->Xxo_Type = PyType_FromModuleAndSpec(m, &Xxo_Type_spec, NULL);
+ if (state->Xxo_Type == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(m, (PyTypeObject*)state->Xxo_Type) < 0) {
+ return -1;
+ }
+
+ // Add the Str type. It is not needed from C code, so it is only
+ // added to the module dict.
+ // It does not inherit from "object" (PyObject_Type), but from "str"
+ // (PyUnincode_Type).
+ PyObject *Str_Type = PyType_FromModuleAndSpec(
+ m, &Str_Type_spec, (PyObject *)&PyUnicode_Type);
+ if (Str_Type == NULL) {
+ return -1;
+ }
+ if (PyModule_AddType(m, (PyTypeObject*)Str_Type) < 0) {
+ return -1;
}
- Py_INCREF(ErrorObject);
- PyModule_AddObject(m, "error", ErrorObject);
-
- /* Add Xxo */
- o = PyType_FromSpec(&Xxo_Type_spec);
- if (o == NULL)
- goto fail;
- PyModule_AddObject(m, "Xxo", o);
-
- /* Add Str */
- o = PyType_FromSpec(&Str_Type_spec);
- if (o == NULL)
- goto fail;
- PyModule_AddObject(m, "Str", o);
-
- /* Add Null */
- o = PyType_FromSpec(&Null_Type_spec);
- if (o == NULL)
- goto fail;
- PyModule_AddObject(m, "Null", o);
+ Py_DECREF(Str_Type);
+
return 0;
- fail:
- Py_XDECREF(m);
- return -1;
}
-
static PyModuleDef_Slot xx_slots[] = {
{Py_mod_exec, xx_modexec},
{0, NULL}
};
+static int
+xx_traverse(PyObject *module, visitproc visit, void *arg)
+{
+ xx_state *state = PyModule_GetState(module);
+ Py_VISIT(state->Xxo_Type);
+ Py_VISIT(state->Error_Type);
+ return 0;
+}
+
+static int
+xx_clear(PyObject *module)
+{
+ xx_state *state = PyModule_GetState(module);
+ Py_CLEAR(state->Xxo_Type);
+ Py_CLEAR(state->Error_Type);
+ return 0;
+}
+
static struct PyModuleDef xxmodule = {
PyModuleDef_HEAD_INIT,
- "xxlimited",
- module_doc,
- 0,
- xx_methods,
- xx_slots,
- NULL,
- NULL,
- NULL
+ .m_name = "xxlimited",
+ .m_doc = module_doc,
+ .m_size = sizeof(xx_state),
+ .m_methods = xx_methods,
+ .m_slots = xx_slots,
+ .m_traverse = xx_traverse,
+ .m_clear = xx_clear,
+ /* m_free is not necessary here: xx_clear clears all references,
+ * and the module state is deallocated along with the module.
+ */
};
+
/* Export function for the module (*must* be called PyInit_xx) */
PyMODINIT_FUNC
diff --git a/Modules/xxlimited_35.c b/Modules/xxlimited_35.c
new file mode 100644
index 0000000000..ce96e8c90e
--- /dev/null
+++ b/Modules/xxlimited_35.c
@@ -0,0 +1,301 @@
+
+/* This module is compiled using limited API from Python 3.5,
+ * making sure that it works as expected.
+ *
+ * See the xxlimited module for an extension module template.
+ */
+
+/* Xxo objects */
+
+#include "Python.h"
+
+static PyObject *ErrorObject;
+
+typedef struct {
+ PyObject_HEAD
+ PyObject *x_attr; /* Attributes dictionary */
+} XxoObject;
+
+static PyObject *Xxo_Type;
+
+#define XxoObject_Check(v) Py_IS_TYPE(v, Xxo_Type)
+
+static XxoObject *
+newXxoObject(PyObject *arg)
+{
+ XxoObject *self;
+ self = PyObject_GC_New(XxoObject, (PyTypeObject*)Xxo_Type);
+ if (self == NULL)
+ return NULL;
+ self->x_attr = NULL;
+ return self;
+}
+
+/* Xxo methods */
+
+static int
+Xxo_traverse(XxoObject *self, visitproc visit, void *arg)
+{
+ Py_VISIT(Py_TYPE(self));
+ Py_VISIT(self->x_attr);
+ return 0;
+}
+
+static void
+Xxo_finalize(XxoObject *self)
+{
+ Py_CLEAR(self->x_attr);
+}
+
+static PyObject *
+Xxo_demo(XxoObject *self, PyObject *args)
+{
+ PyObject *o = NULL;
+ if (!PyArg_ParseTuple(args, "|O:demo", &o))
+ return NULL;
+ /* Test availability of fast type checks */
+ if (o != NULL && PyUnicode_Check(o)) {
+ Py_INCREF(o);
+ return o;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMethodDef Xxo_methods[] = {
+ {"demo", (PyCFunction)Xxo_demo, METH_VARARGS,
+ PyDoc_STR("demo() -> None")},
+ {NULL, NULL} /* sentinel */
+};
+
+static PyObject *
+Xxo_getattro(XxoObject *self, PyObject *name)
+{
+ if (self->x_attr != NULL) {
+ PyObject *v = PyDict_GetItemWithError(self->x_attr, name);
+ if (v != NULL) {
+ Py_INCREF(v);
+ return v;
+ }
+ else if (PyErr_Occurred()) {
+ return NULL;
+ }
+ }
+ return PyObject_GenericGetAttr((PyObject *)self, name);
+}
+
+static int
+Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
+{
+ if (self->x_attr == NULL) {
+ self->x_attr = PyDict_New();
+ if (self->x_attr == NULL)
+ return -1;
+ }
+ if (v == NULL) {
+ int rv = PyDict_DelItemString(self->x_attr, name);
+ if (rv < 0 && PyErr_ExceptionMatches(PyExc_KeyError))
+ PyErr_SetString(PyExc_AttributeError,
+ "delete non-existing Xxo attribute");
+ return rv;
+ }
+ else
+ return PyDict_SetItemString(self->x_attr, name, v);
+}
+
+static PyType_Slot Xxo_Type_slots[] = {
+ {Py_tp_doc, "The Xxo type"},
+ {Py_tp_traverse, Xxo_traverse},
+ {Py_tp_finalize, Xxo_finalize},
+ {Py_tp_getattro, Xxo_getattro},
+ {Py_tp_setattr, Xxo_setattr},
+ {Py_tp_methods, Xxo_methods},
+ {0, 0},
+};
+
+static PyType_Spec Xxo_Type_spec = {
+ "xxlimited.Xxo",
+ sizeof(XxoObject),
+ 0,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
+ Xxo_Type_slots
+};
+
+/* --------------------------------------------------------------------- */
+
+/* Function of two integers returning integer */
+
+PyDoc_STRVAR(xx_foo_doc,
+"foo(i,j)\n\
+\n\
+Return the sum of i and j.");
+
+static PyObject *
+xx_foo(PyObject *self, PyObject *args)
+{
+ long i, j;
+ long res;
+ if (!PyArg_ParseTuple(args, "ll:foo", &i, &j))
+ return NULL;
+ res = i+j; /* XXX Do something here */
+ return PyLong_FromLong(res);
+}
+
+
+/* Function of no arguments returning new Xxo object */
+
+static PyObject *
+xx_new(PyObject *self, PyObject *args)
+{
+ XxoObject *rv;
+
+ if (!PyArg_ParseTuple(args, ":new"))
+ return NULL;
+ rv = newXxoObject(args);
+ if (rv == NULL)
+ return NULL;
+ return (PyObject *)rv;
+}
+
+/* Test bad format character */
+
+static PyObject *
+xx_roj(PyObject *self, PyObject *args)
+{
+ PyObject *a;
+ long b;
+ if (!PyArg_ParseTuple(args, "O#:roj", &a, &b))
+ return NULL;
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/* ---------- */
+
+static PyType_Slot Str_Type_slots[] = {
+ {Py_tp_base, NULL}, /* filled out in module init function */
+ {0, 0},
+};
+
+static PyType_Spec Str_Type_spec = {
+ "xxlimited.Str",
+ 0,
+ 0,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ Str_Type_slots
+};
+
+/* ---------- */
+
+static PyObject *
+null_richcompare(PyObject *self, PyObject *other, int op)
+{
+ Py_RETURN_NOTIMPLEMENTED;
+}
+
+static PyType_Slot Null_Type_slots[] = {
+ {Py_tp_base, NULL}, /* filled out in module init */
+ {Py_tp_new, NULL},
+ {Py_tp_richcompare, null_richcompare},
+ {0, 0}
+};
+
+static PyType_Spec Null_Type_spec = {
+ "xxlimited.Null",
+ 0, /* basicsize */
+ 0, /* itemsize */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ Null_Type_slots
+};
+
+/* ---------- */
+
+/* List of functions defined in the module */
+
+static PyMethodDef xx_methods[] = {
+ {"roj", xx_roj, METH_VARARGS,
+ PyDoc_STR("roj(a,b) -> None")},
+ {"foo", xx_foo, METH_VARARGS,
+ xx_foo_doc},
+ {"new", xx_new, METH_VARARGS,
+ PyDoc_STR("new() -> new Xx object")},
+ {NULL, NULL} /* sentinel */
+};
+
+PyDoc_STRVAR(module_doc,
+"This is a module for testing limited API from Python 3.5.");
+
+static int
+xx_modexec(PyObject *m)
+{
+ PyObject *o;
+
+ /* Due to cross platform compiler issues the slots must be filled
+ * here. It's required for portability to Windows without requiring
+ * C++. */
+ Null_Type_slots[0].pfunc = &PyBaseObject_Type;
+ Null_Type_slots[1].pfunc = PyType_GenericNew;
+ Str_Type_slots[0].pfunc = &PyUnicode_Type;
+
+ Xxo_Type = PyType_FromSpec(&Xxo_Type_spec);
+ if (Xxo_Type == NULL)
+ goto fail;
+
+ /* Add some symbolic constants to the module */
+ if (ErrorObject == NULL) {
+ ErrorObject = PyErr_NewException("xxlimited.error", NULL, NULL);
+ if (ErrorObject == NULL)
+ goto fail;
+ }
+ Py_INCREF(ErrorObject);
+ PyModule_AddObject(m, "error", ErrorObject);
+
+ /* Add Xxo */
+ o = PyType_FromSpec(&Xxo_Type_spec);
+ if (o == NULL)
+ goto fail;
+ PyModule_AddObject(m, "Xxo", o);
+
+ /* Add Str */
+ o = PyType_FromSpec(&Str_Type_spec);
+ if (o == NULL)
+ goto fail;
+ PyModule_AddObject(m, "Str", o);
+
+ /* Add Null */
+ o = PyType_FromSpec(&Null_Type_spec);
+ if (o == NULL)
+ goto fail;
+ PyModule_AddObject(m, "Null", o);
+ return 0;
+ fail:
+ Py_XDECREF(m);
+ return -1;
+}
+
+
+static PyModuleDef_Slot xx_slots[] = {
+ {Py_mod_exec, xx_modexec},
+ {0, NULL}
+};
+
+static struct PyModuleDef xxmodule = {
+ PyModuleDef_HEAD_INIT,
+ "xxlimited_35",
+ module_doc,
+ 0,
+ xx_methods,
+ xx_slots,
+ NULL,
+ NULL,
+ NULL
+};
+
+/* Export function for the module (*must* be called PyInit_xx) */
+
+PyMODINIT_FUNC
+PyInit_xxlimited_35(void)
+{
+ return PyModuleDef_Init(&xxmodule);
+}
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c
index 17b049c4b9..edcd62157c 100644
--- a/Modules/xxmodule.c
+++ b/Modules/xxmodule.c
@@ -44,7 +44,7 @@ static void
Xxo_dealloc(XxoObject *self)
{
Py_XDECREF(self->x_attr);
- PyObject_Del(self);
+ PyObject_Free(self);
}
static PyObject *
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index def617671f..a537087d19 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -591,7 +591,7 @@ Dealloc(compobject *self)
Py_XDECREF(self->unused_data);
Py_XDECREF(self->unconsumed_tail);
Py_XDECREF(self->zdict);
- PyObject_Del(self);
+ PyObject_Free(self);
Py_DECREF(type);
}
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 562549876b..44ed5b3932 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2669,6 +2669,32 @@ PyIter_Next(PyObject *iter)
return result;
}
+PySendResult
+PyIter_Send(PyObject *iter, PyObject *arg, PyObject **result)
+{
+ _Py_IDENTIFIER(send);
+ assert(arg != NULL);
+ assert(result != NULL);
+ if (PyType_HasFeature(Py_TYPE(iter), Py_TPFLAGS_HAVE_AM_SEND)) {
+ assert (Py_TYPE(iter)->tp_as_async != NULL);
+ assert (Py_TYPE(iter)->tp_as_async->am_send != NULL);
+ return Py_TYPE(iter)->tp_as_async->am_send(iter, arg, result);
+ }
+ if (arg == Py_None && PyIter_Check(iter)) {
+ *result = Py_TYPE(iter)->tp_iternext(iter);
+ }
+ else {
+ *result = _PyObject_CallMethodIdOneArg(iter, &PyId_send, arg);
+ }
+ if (*result != NULL) {
+ return PYGEN_NEXT;
+ }
+ if (_PyGen_FetchStopIterationValue(result) == 0) {
+ return PYGEN_RETURN;
+ }
+ return PYGEN_ERROR;
+}
+
/*
* Flatten a sequence of bytes() objects into a C array of
* NULL terminated string pointers with a NULL char* terminating the array.
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 8b57fb679d..7cb2b1478c 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -13,10 +13,9 @@ class bytearray "PyByteArrayObject *" "&PyByteArray_Type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=5535b77c37a119e0]*/
+/* For PyByteArray_AS_STRING(). */
char _PyByteArray_empty_string[] = "";
-/* end nullbytes support */
-
/* Helpers */
static int
@@ -266,7 +265,7 @@ PyByteArray_Concat(PyObject *a, PyObject *b)
result = (PyByteArrayObject *) \
PyByteArray_FromStringAndSize(NULL, va.len + vb.len);
- // result->ob_bytes is NULL if result is an empty string:
+ // result->ob_bytes is NULL if result is an empty bytearray:
// if va.len + vb.len equals zero.
if (result != NULL && result->ob_bytes != NULL) {
memcpy(result->ob_bytes, va.buf, va.len);
@@ -1005,26 +1004,20 @@ bytearray_richcompare(PyObject *self, PyObject *other, int op)
{
Py_ssize_t self_size, other_size;
Py_buffer self_bytes, other_bytes;
- int cmp, rc;
-
- /* Bytes can be compared to anything that supports the (binary)
- buffer API. Except that a comparison with Unicode is always an
- error, even if the comparison is for equality. */
- rc = PyObject_IsInstance(self, (PyObject*)&PyUnicode_Type);
- if (!rc)
- rc = PyObject_IsInstance(other, (PyObject*)&PyUnicode_Type);
- if (rc < 0)
- return NULL;
- if (rc) {
- if (_Py_GetConfig()->bytes_warning && (op == Py_EQ || op == Py_NE)) {
- if (PyErr_WarnEx(PyExc_BytesWarning,
- "Comparison between bytearray and string", 1))
- return NULL;
+ int cmp;
+
+ if (!PyObject_CheckBuffer(self) || !PyObject_CheckBuffer(other)) {
+ if (PyUnicode_Check(self) || PyUnicode_Check(other)) {
+ if (_Py_GetConfig()->bytes_warning && (op == Py_EQ || op == Py_NE)) {
+ if (PyErr_WarnEx(PyExc_BytesWarning,
+ "Comparison between bytearray and string", 1))
+ return NULL;
+ }
}
-
Py_RETURN_NOTIMPLEMENTED;
}
+ /* Bytearrays can be compared to anything that supports the buffer API. */
if (PyObject_GetBuffer(self, &self_bytes, PyBUF_SIMPLE) != 0) {
PyErr_Clear();
Py_RETURN_NOTIMPLEMENTED;
@@ -1332,7 +1325,7 @@ bytearray_translate_impl(PyByteArrayObject *self, PyObject *table,
if (trans_table[c] != -1)
*output++ = (char)trans_table[c];
}
- /* Fix the size of the resulting string */
+ /* Fix the size of the resulting bytearray */
if (inlen > 0)
if (PyByteArray_Resize(result, output - output_start) < 0) {
Py_CLEAR(result);
@@ -2087,7 +2080,7 @@ bytearray.hex
How many bytes between separators. Positive values count from the
right, negative values count from the left.
-Create a str of hexadecimal numbers from a bytearray object.
+Create a string of hexadecimal numbers from a bytearray object.
Example:
>>> value = bytearray([0xb9, 0x01, 0xef])
@@ -2103,7 +2096,7 @@ Example:
static PyObject *
bytearray_hex_impl(PyByteArrayObject *self, PyObject *sep, int bytes_per_sep)
-/*[clinic end generated code: output=29c4e5ef72c565a0 input=814c15830ac8c4b5]*/
+/*[clinic end generated code: output=29c4e5ef72c565a0 input=808667e49bcccb54]*/
{
char* argbuf = PyByteArray_AS_STRING(self);
Py_ssize_t arglen = PyByteArray_GET_SIZE(self);
@@ -2362,7 +2355,7 @@ PyTypeObject PyByteArray_Type = {
PyObject_Del, /* tp_free */
};
-/*********************** Bytes Iterator ****************************/
+/*********************** Bytearray Iterator ****************************/
typedef struct {
PyObject_HEAD
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 990730cd8c..ccabbdca1d 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -5,6 +5,7 @@
#include "Python.h"
#include "pycore_abstract.h" // _PyIndex_Check()
#include "pycore_bytes_methods.h" // _Py_bytes_startswith()
+#include "pycore_format.h" // F_LJUST
#include "pycore_initconfig.h" // _PyStatus_OK()
#include "pycore_object.h" // _PyObject_GC_TRACK
#include "pycore_pymem.h" // PYMEM_CLEANBYTE
@@ -21,11 +22,11 @@ class bytes "PyBytesObject *" "&PyBytes_Type"
_Py_IDENTIFIER(__bytes__);
-/* PyBytesObject_SIZE gives the basic size of a string; any memory allocation
- for a string of length n should request PyBytesObject_SIZE + n bytes.
+/* PyBytesObject_SIZE gives the basic size of a bytes object; any memory allocation
+ for a bytes object of length n should request PyBytesObject_SIZE + n bytes.
Using PyBytesObject_SIZE instead of sizeof(PyBytesObject) saves
- 3 bytes per string allocation on a typical system.
+ 3 or 7 bytes per bytes object allocation on a typical system.
*/
#define PyBytesObject_SIZE (offsetof(PyBytesObject, ob_sval) + 1)
@@ -198,7 +199,7 @@ PyBytes_FromString(const char *str)
}
/* Inline PyObject_NewVar */
- op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + size);
+ op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + size);
if (op == NULL) {
return PyErr_NoMemory();
}
@@ -439,19 +440,6 @@ getnextarg(PyObject *args, Py_ssize_t arglen, Py_ssize_t *p_argidx)
return NULL;
}
-/* Format codes
- * F_LJUST '-'
- * F_SIGN '+'
- * F_BLANK ' '
- * F_ALT '#'
- * F_ZERO '0'
- */
-#define F_LJUST (1<<0)
-#define F_SIGN (1<<1)
-#define F_BLANK (1<<2)
-#define F_ALT (1<<3)
-#define F_ZERO (1<<4)
-
/* Returns a new reference to a PyBytes object, or NULL on failure. */
static char*
@@ -1475,7 +1463,7 @@ bytes_repeat(PyBytesObject *a, Py_ssize_t n)
"repeated bytes are too long");
return NULL;
}
- op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + nbytes);
+ op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + nbytes);
if (op == NULL) {
return PyErr_NoMemory();
}
@@ -1538,36 +1526,19 @@ bytes_richcompare(PyBytesObject *a, PyBytesObject *b, int op)
int c;
Py_ssize_t len_a, len_b;
Py_ssize_t min_len;
- int rc;
/* Make sure both arguments are strings. */
if (!(PyBytes_Check(a) && PyBytes_Check(b))) {
if (_Py_GetConfig()->bytes_warning && (op == Py_EQ || op == Py_NE)) {
- rc = PyObject_IsInstance((PyObject*)a,
- (PyObject*)&PyUnicode_Type);
- if (!rc)
- rc = PyObject_IsInstance((PyObject*)b,
- (PyObject*)&PyUnicode_Type);
- if (rc < 0)
- return NULL;
- if (rc) {
+ if (PyUnicode_Check(a) || PyUnicode_Check(b)) {
if (PyErr_WarnEx(PyExc_BytesWarning,
"Comparison between bytes and string", 1))
return NULL;
}
- else {
- rc = PyObject_IsInstance((PyObject*)a,
- (PyObject*)&PyLong_Type);
- if (!rc)
- rc = PyObject_IsInstance((PyObject*)b,
- (PyObject*)&PyLong_Type);
- if (rc < 0)
+ if (PyLong_Check(a) || PyLong_Check(b)) {
+ if (PyErr_WarnEx(PyExc_BytesWarning,
+ "Comparison between bytes and int", 1))
return NULL;
- if (rc) {
- if (PyErr_WarnEx(PyExc_BytesWarning,
- "Comparison between bytes and int", 1))
- return NULL;
- }
}
}
Py_RETURN_NOTIMPLEMENTED;
@@ -1577,7 +1548,7 @@ bytes_richcompare(PyBytesObject *a, PyBytesObject *b, int op)
case Py_EQ:
case Py_LE:
case Py_GE:
- /* a string is equal to itself */
+ /* a byte string is equal to itself */
Py_RETURN_TRUE;
case Py_NE:
case Py_LT:
@@ -2166,7 +2137,7 @@ bytes_translate_impl(PyBytesObject *self, PyObject *table,
Py_INCREF(input_obj);
return input_obj;
}
- /* Fix the size of the resulting string */
+ /* Fix the size of the resulting byte string */
if (inlen > 0)
_PyBytes_Resize(&result, output - output_start);
return result;
@@ -2470,7 +2441,7 @@ bytes.hex
How many bytes between separators. Positive values count from the
right, negative values count from the left.
-Create a str of hexadecimal numbers from a bytes object.
+Create a string of hexadecimal numbers from a bytes object.
Example:
>>> value = b'\xb9\x01\xef'
@@ -2486,7 +2457,7 @@ Example:
static PyObject *
bytes_hex_impl(PyBytesObject *self, PyObject *sep, int bytes_per_sep)
-/*[clinic end generated code: output=1f134da504064139 input=f1238d3455990218]*/
+/*[clinic end generated code: output=1f134da504064139 input=1a21282b1f1ae595]*/
{
const char *argbuf = PyBytes_AS_STRING(self);
Py_ssize_t arglen = PyBytes_GET_SIZE(self);
@@ -2788,7 +2759,7 @@ _PyBytes_FromIterator(PyObject *it, PyObject *x)
Py_ssize_t i, size;
_PyBytesWriter writer;
- /* For iterator version, create a string object and resize as needed */
+ /* For iterator version, create a bytes object and resize as needed */
size = PyObject_LengthHint(x, 64);
if (size == -1 && PyErr_Occurred())
return NULL;
@@ -3071,9 +3042,9 @@ _PyBytes_Resize(PyObject **pv, Py_ssize_t newsize)
_Py_ForgetReference(v);
#endif
*pv = (PyObject *)
- PyObject_REALLOC(v, PyBytesObject_SIZE + newsize);
+ PyObject_Realloc(v, PyBytesObject_SIZE + newsize);
if (*pv == NULL) {
- PyObject_Del(v);
+ PyObject_Free(v);
PyErr_NoMemory();
return -1;
}
diff --git a/Objects/capsule.c b/Objects/capsule.c
index ed24cc1d6a..800a6c4b25 100644
--- a/Objects/capsule.c
+++ b/Objects/capsule.c
@@ -198,7 +198,7 @@ PyCapsule_Import(const char *name, int no_block)
void *return_value = NULL;
char *trace;
size_t name_length = (strlen(name) + 1) * sizeof(char);
- char *name_dup = (char *)PyMem_MALLOC(name_length);
+ char *name_dup = (char *)PyMem_Malloc(name_length);
if (!name_dup) {
return PyErr_NoMemory();
@@ -247,7 +247,7 @@ PyCapsule_Import(const char *name, int no_block)
EXIT:
Py_XDECREF(object);
if (name_dup) {
- PyMem_FREE(name_dup);
+ PyMem_Free(name_dup);
}
return return_value;
}
@@ -260,7 +260,7 @@ capsule_dealloc(PyObject *o)
if (capsule->destructor) {
capsule->destructor(o);
}
- PyObject_DEL(o);
+ PyObject_Free(o);
}
diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h
index 3452b24174..1e3f197561 100644
--- a/Objects/clinic/bytearrayobject.c.h
+++ b/Objects/clinic/bytearrayobject.c.h
@@ -990,7 +990,7 @@ PyDoc_STRVAR(bytearray_hex__doc__,
"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n"
"--\n"
"\n"
-"Create a str of hexadecimal numbers from a bytearray object.\n"
+"Create a string of hexadecimal numbers from a bytearray object.\n"
"\n"
" sep\n"
" An optional single character or byte to separate hex bytes.\n"
@@ -1120,4 +1120,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{
return bytearray_sizeof_impl(self);
}
-/*[clinic end generated code: output=47cd9ad3fdc3ac0c input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a82659f581e55629 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h
index 27ac6b1067..9e365ce1a0 100644
--- a/Objects/clinic/bytesobject.c.h
+++ b/Objects/clinic/bytesobject.c.h
@@ -750,7 +750,7 @@ PyDoc_STRVAR(bytes_hex__doc__,
"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n"
"--\n"
"\n"
-"Create a str of hexadecimal numbers from a bytes object.\n"
+"Create a string of hexadecimal numbers from a bytes object.\n"
"\n"
" sep\n"
" An optional single character or byte to separate hex bytes.\n"
@@ -878,4 +878,4 @@ skip_optional_pos:
exit:
return return_value;
}
-/*[clinic end generated code: output=6101b417d6a6a717 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b3f0ec2753246b9c input=a9049054013a1b77]*/
diff --git a/Objects/clinic/codeobject.c.h b/Objects/clinic/codeobject.c.h
index c7395375e6..bae2ab0764 100644
--- a/Objects/clinic/codeobject.c.h
+++ b/Objects/clinic/codeobject.c.h
@@ -5,7 +5,7 @@ preserve
PyDoc_STRVAR(code_new__doc__,
"code(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize,\n"
" flags, codestring, constants, names, varnames, filename, name,\n"
-" firstlineno, lnotab, freevars=(), cellvars=(), /)\n"
+" firstlineno, linetable, freevars=(), cellvars=(), /)\n"
"--\n"
"\n"
"Create a code object. Not for the faint of heart.");
@@ -15,7 +15,7 @@ code_new_impl(PyTypeObject *type, int argcount, int posonlyargcount,
int kwonlyargcount, int nlocals, int stacksize, int flags,
PyObject *code, PyObject *consts, PyObject *names,
PyObject *varnames, PyObject *filename, PyObject *name,
- int firstlineno, PyObject *lnotab, PyObject *freevars,
+ int firstlineno, PyObject *linetable, PyObject *freevars,
PyObject *cellvars);
static PyObject *
@@ -35,7 +35,7 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
PyObject *filename;
PyObject *name;
int firstlineno;
- PyObject *lnotab;
+ PyObject *linetable;
PyObject *freevars = NULL;
PyObject *cellvars = NULL;
@@ -114,7 +114,7 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
_PyArg_BadArgument("code", "argument 14", "bytes", PyTuple_GET_ITEM(args, 13));
goto exit;
}
- lnotab = PyTuple_GET_ITEM(args, 13);
+ linetable = PyTuple_GET_ITEM(args, 13);
if (PyTuple_GET_SIZE(args) < 15) {
goto skip_optional;
}
@@ -132,7 +132,7 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
}
cellvars = PyTuple_GET_ITEM(args, 15);
skip_optional:
- return_value = code_new_impl(type, argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize, flags, code, consts, names, varnames, filename, name, firstlineno, lnotab, freevars, cellvars);
+ return_value = code_new_impl(type, argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize, flags, code, consts, names, varnames, filename, name, firstlineno, linetable, freevars, cellvars);
exit:
return return_value;
@@ -144,7 +144,7 @@ PyDoc_STRVAR(code_replace__doc__,
" co_flags=-1, co_firstlineno=-1, co_code=None, co_consts=None,\n"
" co_names=None, co_varnames=None, co_freevars=None,\n"
" co_cellvars=None, co_filename=None, co_name=None,\n"
-" co_lnotab=None)\n"
+" co_linetable=None)\n"
"--\n"
"\n"
"Return a copy of the code object with new values for the specified fields.");
@@ -160,13 +160,13 @@ code_replace_impl(PyCodeObject *self, int co_argcount,
PyObject *co_consts, PyObject *co_names,
PyObject *co_varnames, PyObject *co_freevars,
PyObject *co_cellvars, PyObject *co_filename,
- PyObject *co_name, PyBytesObject *co_lnotab);
+ PyObject *co_name, PyBytesObject *co_linetable);
static PyObject *
code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
- static const char * const _keywords[] = {"co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_firstlineno", "co_code", "co_consts", "co_names", "co_varnames", "co_freevars", "co_cellvars", "co_filename", "co_name", "co_lnotab", NULL};
+ static const char * const _keywords[] = {"co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_firstlineno", "co_code", "co_consts", "co_names", "co_varnames", "co_freevars", "co_cellvars", "co_filename", "co_name", "co_linetable", NULL};
static _PyArg_Parser _parser = {NULL, _keywords, "replace", 0};
PyObject *argsbuf[16];
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
@@ -185,7 +185,7 @@ code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje
PyObject *co_cellvars = self->co_cellvars;
PyObject *co_filename = self->co_filename;
PyObject *co_name = self->co_name;
- PyBytesObject *co_lnotab = (PyBytesObject *)self->co_lnotab;
+ PyBytesObject *co_linetable = (PyBytesObject *)self->co_linetable;
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
if (!args) {
@@ -344,14 +344,14 @@ code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje
}
}
if (!PyBytes_Check(args[15])) {
- _PyArg_BadArgument("replace", "argument 'co_lnotab'", "bytes", args[15]);
+ _PyArg_BadArgument("replace", "argument 'co_linetable'", "bytes", args[15]);
goto exit;
}
- co_lnotab = (PyBytesObject *)args[15];
+ co_linetable = (PyBytesObject *)args[15];
skip_optional_kwonly:
- return_value = code_replace_impl(self, co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals, co_stacksize, co_flags, co_firstlineno, co_code, co_consts, co_names, co_varnames, co_freevars, co_cellvars, co_filename, co_name, co_lnotab);
+ return_value = code_replace_impl(self, co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals, co_stacksize, co_flags, co_firstlineno, co_code, co_consts, co_names, co_varnames, co_freevars, co_cellvars, co_filename, co_name, co_linetable);
exit:
return return_value;
}
-/*[clinic end generated code: output=18c31941ec09e9ca input=a9049054013a1b77]*/
+/*[clinic end generated code: output=e3091c7baaaaa420 input=a9049054013a1b77]*/
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index c86d0e1f4a..0b0b8f98ae 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -119,7 +119,7 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount,
PyObject *code, PyObject *consts, PyObject *names,
PyObject *varnames, PyObject *freevars, PyObject *cellvars,
PyObject *filename, PyObject *name, int firstlineno,
- PyObject *lnotab)
+ PyObject *linetable)
{
PyCodeObject *co;
Py_ssize_t *cell2arg = NULL;
@@ -137,7 +137,7 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount,
cellvars == NULL || !PyTuple_Check(cellvars) ||
name == NULL || !PyUnicode_Check(name) ||
filename == NULL || !PyUnicode_Check(filename) ||
- lnotab == NULL || !PyBytes_Check(lnotab)) {
+ linetable == NULL || !PyBytes_Check(linetable)) {
PyErr_BadInternalCall();
return NULL;
}
@@ -213,7 +213,7 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount,
PyObject *arg = PyTuple_GET_ITEM(varnames, j);
int cmp = PyUnicode_Compare(cell, arg);
if (cmp == -1 && PyErr_Occurred()) {
- PyMem_FREE(cell2arg);
+ PyMem_Free(cell2arg);
return NULL;
}
if (cmp == 0) {
@@ -224,14 +224,14 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount,
}
}
if (!used_cell2arg) {
- PyMem_FREE(cell2arg);
+ PyMem_Free(cell2arg);
cell2arg = NULL;
}
}
co = PyObject_New(PyCodeObject, &PyCode_Type);
if (co == NULL) {
if (cell2arg)
- PyMem_FREE(cell2arg);
+ PyMem_Free(cell2arg);
return NULL;
}
co->co_argcount = argcount;
@@ -258,8 +258,8 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount,
Py_INCREF(name);
co->co_name = name;
co->co_firstlineno = firstlineno;
- Py_INCREF(lnotab);
- co->co_lnotab = lnotab;
+ Py_INCREF(linetable);
+ co->co_linetable = linetable;
co->co_zombieframe = NULL;
co->co_weakreflist = NULL;
co->co_extra = NULL;
@@ -277,12 +277,12 @@ PyCode_New(int argcount, int kwonlyargcount,
PyObject *code, PyObject *consts, PyObject *names,
PyObject *varnames, PyObject *freevars, PyObject *cellvars,
PyObject *filename, PyObject *name, int firstlineno,
- PyObject *lnotab)
+ PyObject *linetable)
{
return PyCode_NewWithPosOnlyArgs(argcount, 0, kwonlyargcount, nlocals,
stacksize, flags, code, consts, names,
varnames, freevars, cellvars, filename,
- name, firstlineno, lnotab);
+ name, firstlineno, linetable);
}
int
@@ -314,12 +314,12 @@ _PyCode_InitOpcache(PyCodeObject *co)
if (opts) {
co->co_opcache = (_PyOpcache *)PyMem_Calloc(opts, sizeof(_PyOpcache));
if (co->co_opcache == NULL) {
- PyMem_FREE(co->co_opcache_map);
+ PyMem_Free(co->co_opcache_map);
return -1;
}
}
else {
- PyMem_FREE(co->co_opcache_map);
+ PyMem_Free(co->co_opcache_map);
co->co_opcache_map = NULL;
co->co_opcache = NULL;
}
@@ -369,7 +369,7 @@ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
filename_ob, /* filename */
funcname_ob, /* name */
firstlineno, /* firstlineno */
- emptystring /* lnotab */
+ emptystring /* linetable */
);
failed:
@@ -395,11 +395,89 @@ static PyMemberDef code_memberlist[] = {
{"co_cellvars", T_OBJECT, OFF(co_cellvars), READONLY},
{"co_filename", T_OBJECT, OFF(co_filename), READONLY},
{"co_name", T_OBJECT, OFF(co_name), READONLY},
- {"co_firstlineno", T_INT, OFF(co_firstlineno), READONLY},
- {"co_lnotab", T_OBJECT, OFF(co_lnotab), READONLY},
+ {"co_firstlineno", T_INT, OFF(co_firstlineno), READONLY},
+ {"co_linetable", T_OBJECT, OFF(co_linetable), READONLY},
{NULL} /* Sentinel */
};
+static int
+emit_pair(PyObject **bytes, int *offset, int a, int b)
+{
+ Py_ssize_t len = PyBytes_GET_SIZE(*bytes);
+ if (*offset + 2 >= len) {
+ if (_PyBytes_Resize(bytes, len * 2) < 0)
+ return 0;
+ }
+ unsigned char *lnotab = (unsigned char *)
+ PyBytes_AS_STRING(*bytes) + *offset;
+ *lnotab++ = a;
+ *lnotab++ = b;
+ *offset += 2;
+ return 1;
+}
+
+static int
+emit_delta(PyObject **bytes, int bdelta, int ldelta, int *offset)
+{
+ while (bdelta > 255) {
+ if (!emit_pair(bytes, offset, 255, 0)) {
+ return 0;
+ }
+ bdelta -= 255;
+ }
+ while (ldelta > 127) {
+ if (!emit_pair(bytes, offset, bdelta, 127)) {
+ return 0;
+ }
+ bdelta = 0;
+ ldelta -= 127;
+ }
+ while (ldelta < -128) {
+ if (!emit_pair(bytes, offset, bdelta, -128)) {
+ return 0;
+ }
+ bdelta = 0;
+ ldelta += 128;
+ }
+ return emit_pair(bytes, offset, bdelta, ldelta);
+}
+
+static PyObject *
+code_getlnotab(PyCodeObject *code, void *closure)
+{
+ PyCodeAddressRange bounds;
+ PyObject *bytes;
+ int table_offset = 0;
+ int code_offset = 0;
+ int line = code->co_firstlineno;
+ bytes = PyBytes_FromStringAndSize(NULL, 64);
+ if (bytes == NULL) {
+ return NULL;
+ }
+ _PyCode_InitAddressRange(code, &bounds);
+ while (PyLineTable_NextAddressRange(&bounds)) {
+ if (bounds.ar_computed_line != line) {
+ int bdelta = bounds.ar_start - code_offset;
+ int ldelta = bounds.ar_computed_line - line;
+ if (!emit_delta(&bytes, bdelta, ldelta, &table_offset)) {
+ Py_DECREF(bytes);
+ return NULL;
+ }
+ code_offset = bounds.ar_start;
+ line = bounds.ar_computed_line;
+ }
+ }
+ _PyBytes_Resize(&bytes, table_offset);
+ return bytes;
+}
+
+
+static PyGetSetDef code_getsetlist[] = {
+ {"co_lnotab", (getter)code_getlnotab, NULL, NULL},
+ {0}
+};
+
+
/* Helper for code_new: return a shallow copy of a tuple that is
guaranteed to contain exact strings, by converting string subclasses
to exact strings and complaining if a non-string is found. */
@@ -459,7 +537,7 @@ code.__new__ as code_new
filename: unicode
name: unicode
firstlineno: int
- lnotab: object(subclass_of="&PyBytes_Type")
+ linetable: object(subclass_of="&PyBytes_Type")
freevars: object(subclass_of="&PyTuple_Type", c_default="NULL") = ()
cellvars: object(subclass_of="&PyTuple_Type", c_default="NULL") = ()
/
@@ -472,9 +550,9 @@ code_new_impl(PyTypeObject *type, int argcount, int posonlyargcount,
int kwonlyargcount, int nlocals, int stacksize, int flags,
PyObject *code, PyObject *consts, PyObject *names,
PyObject *varnames, PyObject *filename, PyObject *name,
- int firstlineno, PyObject *lnotab, PyObject *freevars,
+ int firstlineno, PyObject *linetable, PyObject *freevars,
PyObject *cellvars)
-/*[clinic end generated code: output=612aac5395830184 input=85e678ea4178f234]*/
+/*[clinic end generated code: output=42c1839b082ba293 input=0ec80da632b99f57]*/
{
PyObject *co = NULL;
PyObject *ournames = NULL;
@@ -540,7 +618,7 @@ code_new_impl(PyTypeObject *type, int argcount, int posonlyargcount,
code, consts, ournames,
ourvarnames, ourfreevars,
ourcellvars, filename,
- name, firstlineno, lnotab);
+ name, firstlineno, linetable);
cleanup:
Py_XDECREF(ournames);
Py_XDECREF(ourvarnames);
@@ -553,10 +631,10 @@ static void
code_dealloc(PyCodeObject *co)
{
if (co->co_opcache != NULL) {
- PyMem_FREE(co->co_opcache);
+ PyMem_Free(co->co_opcache);
}
if (co->co_opcache_map != NULL) {
- PyMem_FREE(co->co_opcache_map);
+ PyMem_Free(co->co_opcache_map);
}
co->co_opcache_flag = 0;
co->co_opcache_size = 0;
@@ -584,14 +662,14 @@ code_dealloc(PyCodeObject *co)
Py_XDECREF(co->co_cellvars);
Py_XDECREF(co->co_filename);
Py_XDECREF(co->co_name);
- Py_XDECREF(co->co_lnotab);
+ Py_XDECREF(co->co_linetable);
if (co->co_cell2arg != NULL)
- PyMem_FREE(co->co_cell2arg);
+ PyMem_Free(co->co_cell2arg);
if (co->co_zombieframe != NULL)
PyObject_GC_Del(co->co_zombieframe);
if (co->co_weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject*)co);
- PyObject_DEL(co);
+ PyObject_Free(co);
}
static PyObject *
@@ -636,7 +714,7 @@ code.replace
co_cellvars: object(subclass_of="&PyTuple_Type", c_default="self->co_cellvars") = None
co_filename: unicode(c_default="self->co_filename") = None
co_name: unicode(c_default="self->co_name") = None
- co_lnotab: PyBytesObject(c_default="(PyBytesObject *)self->co_lnotab") = None
+ co_linetable: PyBytesObject(c_default="(PyBytesObject *)self->co_linetable") = None
Return a copy of the code object with new values for the specified fields.
[clinic start generated code]*/
@@ -649,8 +727,8 @@ code_replace_impl(PyCodeObject *self, int co_argcount,
PyObject *co_consts, PyObject *co_names,
PyObject *co_varnames, PyObject *co_freevars,
PyObject *co_cellvars, PyObject *co_filename,
- PyObject *co_name, PyBytesObject *co_lnotab)
-/*[clinic end generated code: output=25c8e303913bcace input=d9051bc8f24e6b28]*/
+ PyObject *co_name, PyBytesObject *co_linetable)
+/*[clinic end generated code: output=50d77e668d3b449b input=a5f997b173d7f636]*/
{
#define CHECK_INT_ARG(ARG) \
if (ARG < 0) { \
@@ -680,7 +758,7 @@ code_replace_impl(PyCodeObject *self, int co_argcount,
co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals,
co_stacksize, co_flags, (PyObject*)co_code, co_consts, co_names,
co_varnames, co_freevars, co_cellvars, co_filename, co_name,
- co_firstlineno, (PyObject*)co_lnotab);
+ co_firstlineno, (PyObject*)co_linetable);
}
static PyObject *
@@ -933,10 +1011,189 @@ code_hash(PyCodeObject *co)
return h;
}
+typedef struct {
+ PyObject_HEAD
+ PyCodeObject *li_code;
+ PyCodeAddressRange li_line;
+ char *li_end;
+} lineiterator;
+
+
+static void
+lineiter_dealloc(lineiterator *li)
+{
+ Py_DECREF(li->li_code);
+ Py_TYPE(li)->tp_free(li);
+}
+
+static PyObject *
+lineiter_next(lineiterator *li)
+{
+ PyCodeAddressRange *bounds = &li->li_line;
+ if (!PyLineTable_NextAddressRange(bounds)) {
+ return NULL;
+ }
+ PyObject *start = NULL;
+ PyObject *end = NULL;
+ PyObject *line = NULL;
+ PyObject *result = PyTuple_New(3);
+ start = PyLong_FromLong(bounds->ar_start);
+ end = PyLong_FromLong(bounds->ar_end);
+ if (bounds->ar_line < 0) {
+ Py_INCREF(Py_None);
+ line = Py_None;
+ }
+ else {
+ line = PyLong_FromLong(bounds->ar_line);
+ }
+ if (result == NULL || start == NULL || end == NULL || line == NULL) {
+ goto error;
+ }
+ PyTuple_SET_ITEM(result, 0, start);
+ PyTuple_SET_ITEM(result, 1, end);
+ PyTuple_SET_ITEM(result, 2, line);
+ return result;
+error:
+ Py_XDECREF(start);
+ Py_XDECREF(end);
+ Py_XDECREF(line);
+ Py_XDECREF(result);
+ return result;
+}
+
+static PyTypeObject LineIterator = {
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ "line_iterator", /* tp_name */
+ sizeof(lineiterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)lineiter_dealloc, /* tp_dealloc */
+ 0, /* tp_vectorcall_offset */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_as_async */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ PyObject_SelfIter, /* tp_iter */
+ (iternextfunc)lineiter_next, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ PyObject_Del, /* tp_free */
+};
+
+static PyObject *
+code_linesiterator(PyCodeObject *code, PyObject *Py_UNUSED(args))
+{
+ lineiterator *li = (lineiterator *)PyType_GenericAlloc(&LineIterator, 0);
+ if (li == NULL) {
+ return NULL;
+ }
+ Py_INCREF(code);
+ li->li_code = code;
+ _PyCode_InitAddressRange(code, &li->li_line);
+ return (PyObject *)li;
+}
+
+static void
+retreat(PyCodeAddressRange *bounds)
+{
+ int ldelta = ((signed char *)bounds->lo_next)[-1];
+ if (ldelta == -128) {
+ ldelta = 0;
+ }
+ bounds->ar_computed_line -= ldelta;
+ bounds->lo_next -= 2;
+ bounds->ar_end = bounds->ar_start;
+ bounds->ar_start -= ((unsigned char *)bounds->lo_next)[-2];
+ ldelta = ((signed char *)bounds->lo_next)[-1];
+ if (ldelta == -128) {
+ bounds->ar_line = -1;
+ }
+ else {
+ bounds->ar_line = bounds->ar_computed_line;
+ }
+}
+
+static void
+advance(PyCodeAddressRange *bounds)
+{
+ bounds->ar_start = bounds->ar_end;
+ int delta = ((unsigned char *)bounds->lo_next)[0];
+ assert (delta < 255);
+ bounds->ar_end += delta;
+ int ldelta = ((signed char *)bounds->lo_next)[1];
+ bounds->lo_next += 2;
+ if (ldelta == -128) {
+ bounds->ar_line = -1;
+ }
+ else {
+ bounds->ar_computed_line += ldelta;
+ bounds->ar_line = bounds->ar_computed_line;
+ }
+}
+
+static inline int
+at_end(PyCodeAddressRange *bounds) {
+ return ((unsigned char *)bounds->lo_next)[0] == 255;
+}
+
+int
+PyLineTable_PreviousAddressRange(PyCodeAddressRange *range)
+{
+ if (range->ar_start <= 0) {
+ return 0;
+ }
+ retreat(range);
+ while (range->ar_start == range->ar_end) {
+ assert(range->ar_start > 0);
+ retreat(range);
+ }
+ return 1;
+}
+
+int
+PyLineTable_NextAddressRange(PyCodeAddressRange *range)
+{
+ if (at_end(range)) {
+ return 0;
+ }
+ advance(range);
+ while (range->ar_start == range->ar_end) {
+ assert(!at_end(range));
+ advance(range);
+ }
+ return 1;
+}
+
+
/* XXX code objects need to participate in GC? */
static struct PyMethodDef code_methods[] = {
{"__sizeof__", (PyCFunction)code_sizeof, METH_NOARGS},
+ {"co_lines", (PyCFunction)code_linesiterator, METH_NOARGS},
CODE_REPLACE_METHODDEF
{NULL, NULL} /* sentinel */
};
@@ -971,7 +1228,7 @@ PyTypeObject PyCode_Type = {
0, /* tp_iternext */
code_methods, /* tp_methods */
code_memberlist, /* tp_members */
- 0, /* tp_getset */
+ code_getsetlist, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
@@ -982,78 +1239,55 @@ PyTypeObject PyCode_Type = {
code_new, /* tp_new */
};
-/* Use co_lnotab to compute the line number from a bytecode index, addrq. See
+/* Use co_linetable to compute the line number from a bytecode index, addrq. See
lnotab_notes.txt for the details of the lnotab representation.
*/
int
PyCode_Addr2Line(PyCodeObject *co, int addrq)
{
- Py_ssize_t size = PyBytes_Size(co->co_lnotab) / 2;
- unsigned char *p = (unsigned char*)PyBytes_AsString(co->co_lnotab);
- int line = co->co_firstlineno;
- int addr = 0;
- while (--size >= 0) {
- addr += *p++;
- if (addr > addrq)
- break;
- line += (signed char)*p;
- p++;
- }
- return line;
+ if (addrq == -1) {
+ return co->co_firstlineno;
+ }
+ assert(addrq >= 0 && addrq < PyBytes_GET_SIZE(co->co_code));
+ PyCodeAddressRange bounds;
+ _PyCode_InitAddressRange(co, &bounds);
+ return _PyCode_CheckLineNumber(addrq, &bounds);
+}
+
+void
+PyLineTable_InitAddressRange(char *linetable, int firstlineno, PyCodeAddressRange *range)
+{
+ range->lo_next = linetable;
+ range->ar_start = -1;
+ range->ar_end = 0;
+ range->ar_computed_line = range->ar_line = firstlineno;
+}
+
+int
+_PyCode_InitAddressRange(PyCodeObject* co, PyCodeAddressRange *bounds)
+{
+ char *linetable = PyBytes_AS_STRING(co->co_linetable);
+ PyLineTable_InitAddressRange(linetable, co->co_firstlineno, bounds);
+ return bounds->ar_line;
}
/* Update *bounds to describe the first and one-past-the-last instructions in
- the same line as lasti. Return the number of that line. */
+ the same line as lasti. Return the number of that line, or -1 if lasti is out of bounds. */
int
-_PyCode_CheckLineNumber(PyCodeObject* co, int lasti, PyAddrPair *bounds)
+_PyCode_CheckLineNumber(int lasti, PyCodeAddressRange *bounds)
{
- Py_ssize_t size;
- int addr, line;
- unsigned char* p;
-
- p = (unsigned char*)PyBytes_AS_STRING(co->co_lnotab);
- size = PyBytes_GET_SIZE(co->co_lnotab) / 2;
-
- addr = 0;
- line = co->co_firstlineno;
- assert(line > 0);
-
- /* possible optimization: if f->f_lasti == instr_ub
- (likely to be a common case) then we already know
- instr_lb -- if we stored the matching value of p
- somewhere we could skip the first while loop. */
-
- /* See lnotab_notes.txt for the description of
- co_lnotab. A point to remember: increments to p
- come in (addr, line) pairs. */
-
- bounds->ap_lower = 0;
- while (size > 0) {
- if (addr + *p > lasti)
- break;
- addr += *p++;
- if ((signed char)*p)
- bounds->ap_lower = addr;
- line += (signed char)*p;
- p++;
- --size;
- }
-
- if (size > 0) {
- while (--size >= 0) {
- addr += *p++;
- if ((signed char)*p)
- break;
- p++;
+ while (bounds->ar_end <= lasti) {
+ if (!PyLineTable_NextAddressRange(bounds)) {
+ return -1;
}
- bounds->ap_upper = addr;
}
- else {
- bounds->ap_upper = INT_MAX;
+ while (bounds->ar_start > lasti) {
+ if (!PyLineTable_PreviousAddressRange(bounds)) {
+ return -1;
+ }
}
-
- return line;
+ return bounds->ar_line;
}
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index a481d9ad8b..a65ebdfa6c 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -233,7 +233,7 @@ PyObject *
PyComplex_FromCComplex(Py_complex cval)
{
/* Inline PyObject_New */
- PyComplexObject *op = PyObject_MALLOC(sizeof(PyComplexObject));
+ PyComplexObject *op = PyObject_Malloc(sizeof(PyComplexObject));
if (op == NULL) {
return PyErr_NoMemory();
}
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index faa8696153..35e881fe27 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -269,7 +269,7 @@ _PyDict_ClearFreeList(PyThreadState *tstate)
PyObject_GC_Del(op);
}
while (state->keys_numfree) {
- PyObject_FREE(state->keys_free_list[--state->keys_numfree]);
+ PyObject_Free(state->keys_free_list[--state->keys_numfree]);
}
}
@@ -597,7 +597,7 @@ new_keys_object(Py_ssize_t size)
}
else
{
- dk = PyObject_MALLOC(sizeof(PyDictKeysObject)
+ dk = PyObject_Malloc(sizeof(PyDictKeysObject)
+ es * size
+ sizeof(PyDictKeyEntry) * usable);
if (dk == NULL) {
@@ -636,11 +636,11 @@ free_keys_object(PyDictKeysObject *keys)
state->keys_free_list[state->keys_numfree++] = keys;
return;
}
- PyObject_FREE(keys);
+ PyObject_Free(keys);
}
#define new_values(size) PyMem_NEW(PyObject *, size)
-#define free_values(values) PyMem_FREE(values)
+#define free_values(values) PyMem_Free(values)
/* Consumes a reference to the keys object */
static PyObject *
@@ -1303,7 +1303,7 @@ dictresize(PyDictObject *mp, Py_ssize_t newsize)
state->keys_free_list[state->keys_numfree++] = oldkeys;
}
else {
- PyObject_FREE(oldkeys);
+ PyObject_Free(oldkeys);
}
}
@@ -3989,6 +3989,11 @@ dictiter_iternextitem(dictiterobject *di)
Py_INCREF(result);
Py_DECREF(oldkey);
Py_DECREF(oldvalue);
+ // bpo-42536: The GC may have untracked this result tuple. Since we're
+ // recycling it, make sure it's tracked again:
+ if (!_PyObject_GC_IS_TRACKED(result)) {
+ _PyObject_GC_TRACK(result);
+ }
}
else {
result = PyTuple_New(2);
@@ -4104,6 +4109,11 @@ dictreviter_iternext(dictiterobject *di)
Py_INCREF(result);
Py_DECREF(oldkey);
Py_DECREF(oldvalue);
+ // bpo-42536: The GC may have untracked this result tuple. Since
+ // we're recycling it, make sure it's tracked again:
+ if (!_PyObject_GC_IS_TRACKED(result)) {
+ _PyObject_GC_TRACK(result);
+ }
}
else {
result = PyTuple_New(2);
diff --git a/Objects/enumobject.c b/Objects/enumobject.c
index 8b5e7d3a3c..98ece3f13f 100644
--- a/Objects/enumobject.c
+++ b/Objects/enumobject.c
@@ -2,6 +2,7 @@
#include "Python.h"
#include "pycore_long.h" // _PyLong_GetOne()
+#include "pycore_object.h" // _PyObject_GC_TRACK()
#include "clinic/enumobject.c.h"
@@ -131,6 +132,11 @@ enum_next_long(enumobject *en, PyObject* next_item)
PyTuple_SET_ITEM(result, 1, next_item);
Py_DECREF(old_index);
Py_DECREF(old_item);
+ // bpo-42536: The GC may have untracked this result tuple. Since we're
+ // recycling it, make sure it's tracked again:
+ if (!_PyObject_GC_IS_TRACKED(result)) {
+ _PyObject_GC_TRACK(result);
+ }
return result;
}
result = PyTuple_New(2);
@@ -176,6 +182,11 @@ enum_next(enumobject *en)
PyTuple_SET_ITEM(result, 1, next_item);
Py_DECREF(old_index);
Py_DECREF(old_item);
+ // bpo-42536: The GC may have untracked this result tuple. Since we're
+ // recycling it, make sure it's tracked again:
+ if (!_PyObject_GC_IS_TRACKED(result)) {
+ _PyObject_GC_TRACK(result);
+ }
return result;
}
result = PyTuple_New(2);
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index b14da20db0..d4824938a0 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -2547,8 +2547,10 @@ _PyExc_Init(PyThreadState *tstate)
do { \
PyObject *_code = PyLong_FromLong(CODE); \
assert(_PyObject_RealIsSubclass(PyExc_ ## TYPE, PyExc_OSError)); \
- if (!_code || PyDict_SetItem(state->errnomap, _code, PyExc_ ## TYPE)) \
+ if (!_code || PyDict_SetItem(state->errnomap, _code, PyExc_ ## TYPE)) { \
+ Py_XDECREF(_code); \
return _PyStatus_ERR("errmap insertion problem."); \
+ } \
Py_DECREF(_code); \
} while (0)
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 1550b2eedc..34fb57a946 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -237,7 +237,7 @@ float_dealloc(PyFloatObject *op)
assert(state->numfree != -1);
#endif
if (state->numfree >= PyFloat_MAXFREELIST) {
- PyObject_FREE(op);
+ PyObject_Free(op);
return;
}
state->numfree++;
@@ -2032,7 +2032,7 @@ _PyFloat_ClearFreeList(PyThreadState *tstate)
PyFloatObject *f = state->free_list;
while (f != NULL) {
PyFloatObject *next = (PyFloatObject*) Py_TYPE(f);
- PyObject_FREE(f);
+ PyObject_Free(f);
f = next;
}
state->free_list = NULL;
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 8838b80746..787cd8b272 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -249,36 +249,22 @@ explain_incompatible_block_stack(int64_t to_stack)
static int *
marklines(PyCodeObject *code, int len)
{
+ PyCodeAddressRange bounds;
+ _PyCode_InitAddressRange(code, &bounds);
+ assert (bounds.ar_end == 0);
+
int *linestarts = PyMem_New(int, len);
if (linestarts == NULL) {
return NULL;
}
- Py_ssize_t size = PyBytes_GET_SIZE(code->co_lnotab) / 2;
- unsigned char *p = (unsigned char*)PyBytes_AS_STRING(code->co_lnotab);
- int line = code->co_firstlineno;
- int addr = 0;
- int index = 0;
- while (--size >= 0) {
- addr += *p++;
- if (index*2 < addr) {
- linestarts[index++] = line;
- }
- while (index*2 < addr) {
- linestarts[index++] = -1;
- if (index >= len) {
- break;
- }
- }
- line += (signed char)*p;
- p++;
- }
- if (index < len) {
- linestarts[index++] = line;
+ for (int i = 0; i < len; i++) {
+ linestarts[i] = -1;
}
- while (index < len) {
- linestarts[index++] = -1;
+
+ while (PyLineTable_NextAddressRange(&bounds)) {
+ assert(bounds.ar_start/2 < len);
+ linestarts[bounds.ar_start/2] = bounds.ar_line;
}
- assert(index == len);
return linestarts;
}
@@ -925,7 +911,7 @@ _PyFrame_New_NoTrack(PyThreadState *tstate, PyCodeObject *code,
}
f->f_lasti = -1;
- f->f_lineno = code->co_firstlineno;
+ f->f_lineno = 0;
f->f_iblock = 0;
f->f_state = FRAME_CREATED;
f->f_gen = NULL;
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 9b4302a13c..e7961b3e6e 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -424,6 +424,25 @@ func_get_annotations(PyFunctionObject *op, void *Py_UNUSED(ignored))
if (op->func_annotations == NULL)
return NULL;
}
+ if (PyTuple_CheckExact(op->func_annotations)) {
+ PyObject *ann_tuple = op->func_annotations;
+ PyObject *ann_dict = PyDict_New();
+ if (ann_dict == NULL) {
+ return NULL;
+ }
+
+ assert(PyTuple_GET_SIZE(ann_tuple) % 2 == 0);
+
+ for (Py_ssize_t i = 0; i < PyTuple_GET_SIZE(ann_tuple); i += 2) {
+ int err = PyDict_SetItem(ann_dict,
+ PyTuple_GET_ITEM(ann_tuple, i),
+ PyTuple_GET_ITEM(ann_tuple, i + 1));
+
+ if (err < 0)
+ return NULL;
+ }
+ Py_SETREF(op->func_annotations, ann_dict);
+ }
Py_INCREF(op->func_annotations);
return op->func_annotations;
}
diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c
index 6508c69cbf..4cc82ffcdf 100644
--- a/Objects/genericaliasobject.c
+++ b/Objects/genericaliasobject.c
@@ -2,6 +2,7 @@
#include "Python.h"
#include "pycore_object.h"
+#include "pycore_unionobject.h" // _Py_union_as_number
#include "structmember.h" // PyMemberDef
typedef struct {
@@ -9,6 +10,7 @@ typedef struct {
PyObject *origin;
PyObject *args;
PyObject *parameters;
+ PyObject* weakreflist;
} gaobject;
static void
@@ -17,6 +19,9 @@ ga_dealloc(PyObject *self)
gaobject *alias = (gaobject *)self;
_PyObject_GC_UNTRACK(self);
+ if (alias->weakreflist != NULL) {
+ PyObject_ClearWeakRefs((PyObject *)alias);
+ }
Py_XDECREF(alias->origin);
Py_XDECREF(alias->args);
Py_XDECREF(alias->parameters);
@@ -151,13 +156,24 @@ error:
return NULL;
}
-// isinstance(obj, TypeVar) without importing typing.py.
-// Returns -1 for errors.
-static int
-is_typevar(PyObject *obj)
+/* Checks if a variable number of names are from typing.py.
+* If any one of the names are found, return 1, else 0.
+**/
+static inline int
+is_typing_name(PyObject *obj, int num, ...)
{
+ va_list names;
+ va_start(names, num);
+
PyTypeObject *type = Py_TYPE(obj);
- if (strcmp(type->tp_name, "TypeVar") != 0) {
+ int hit = 0;
+ for (int i = 0; i < num; ++i) {
+ if (!strcmp(type->tp_name, va_arg(names, const char *))) {
+ hit = 1;
+ break;
+ }
+ }
+ if (!hit) {
return 0;
}
PyObject *module = PyObject_GetAttrString((PyObject *)type, "__module__");
@@ -167,9 +183,25 @@ is_typevar(PyObject *obj)
int res = PyUnicode_Check(module)
&& _PyUnicode_EqualToASCIIString(module, "typing");
Py_DECREF(module);
+
+ va_end(names);
return res;
}
+// isinstance(obj, (TypeVar, ParamSpec)) without importing typing.py.
+// Returns -1 for errors.
+static inline int
+is_typevarlike(PyObject *obj)
+{
+ return is_typing_name(obj, 2, "TypeVar", "ParamSpec");
+}
+
+static inline int
+is_paramspec(PyObject *obj)
+{
+ return is_typing_name(obj, 1, "ParamSpec");
+}
+
// Index of item in self[:len], or -1 if not found (self is a tuple)
static Py_ssize_t
tuple_index(PyObject *self, Py_ssize_t len, PyObject *item)
@@ -204,7 +236,7 @@ make_parameters(PyObject *args)
Py_ssize_t iparam = 0;
for (Py_ssize_t iarg = 0; iarg < nargs; iarg++) {
PyObject *t = PyTuple_GET_ITEM(args, iarg);
- int typevar = is_typevar(t);
+ int typevar = is_typevarlike(t);
if (typevar < 0) {
Py_DECREF(parameters);
return NULL;
@@ -274,7 +306,14 @@ subs_tvars(PyObject *obj, PyObject *params, PyObject **argitems)
if (iparam >= 0) {
arg = argitems[iparam];
}
- Py_INCREF(arg);
+ // convert all the lists inside args to tuples to help
+ // with caching in other libaries
+ if (PyList_CheckExact(arg)) {
+ arg = PyList_AsTuple(arg);
+ }
+ else {
+ Py_INCREF(arg);
+ }
PyTuple_SET_ITEM(subargs, i, arg);
}
@@ -309,11 +348,19 @@ ga_getitem(PyObject *self, PyObject *item)
int is_tuple = PyTuple_Check(item);
Py_ssize_t nitems = is_tuple ? PyTuple_GET_SIZE(item) : 1;
PyObject **argitems = is_tuple ? &PyTuple_GET_ITEM(item, 0) : &item;
- if (nitems != nparams) {
- return PyErr_Format(PyExc_TypeError,
- "Too %s arguments for %R",
- nitems > nparams ? "many" : "few",
- self);
+ // A special case in PEP 612 where if X = Callable[P, int],
+ // then X[int, str] == X[[int, str]].
+ if (nparams == 1 && nitems > 1 && is_tuple &&
+ is_paramspec(PyTuple_GET_ITEM(alias->parameters, 0))) {
+ argitems = &item;
+ }
+ else {
+ if (nitems != nparams) {
+ return PyErr_Format(PyExc_TypeError,
+ "Too %s arguments for %R",
+ nitems > nparams ? "many" : "few",
+ self);
+ }
}
/* Replace all type variables (specified by alias->parameters)
with corresponding values specified by argitems.
@@ -328,7 +375,7 @@ ga_getitem(PyObject *self, PyObject *item)
}
for (Py_ssize_t iarg = 0; iarg < nargs; iarg++) {
PyObject *arg = PyTuple_GET_ITEM(alias->args, iarg);
- int typevar = is_typevar(arg);
+ int typevar = is_typevarlike(arg);
if (typevar < 0) {
Py_DECREF(newargs);
return NULL;
@@ -337,7 +384,13 @@ ga_getitem(PyObject *self, PyObject *item)
Py_ssize_t iparam = tuple_index(alias->parameters, nparams, arg);
assert(iparam >= 0);
arg = argitems[iparam];
- Py_INCREF(arg);
+ // convert lists to tuples to help with caching in other libaries.
+ if (PyList_CheckExact(arg)) {
+ arg = PyList_AsTuple(arg);
+ }
+ else {
+ Py_INCREF(arg);
+ }
}
else {
arg = subs_tvars(arg, alias->parameters, argitems);
@@ -424,8 +477,8 @@ ga_getattro(PyObject *self, PyObject *name)
static PyObject *
ga_richcompare(PyObject *a, PyObject *b, int op)
{
- if (!Py_IS_TYPE(a, &Py_GenericAliasType) ||
- !Py_IS_TYPE(b, &Py_GenericAliasType) ||
+ if (!PyObject_TypeCheck(a, &Py_GenericAliasType) ||
+ !PyObject_TypeCheck(b, &Py_GenericAliasType) ||
(op != Py_EQ && op != Py_NE))
{
Py_RETURN_NOTIMPLEMENTED;
@@ -559,10 +612,33 @@ static PyGetSetDef ga_properties[] = {
{0}
};
+/* A helper function to create GenericAlias' args tuple and set its attributes.
+ * Returns 1 on success, 0 on failure.
+ */
+static inline int
+setup_ga(gaobject *alias, PyObject *origin, PyObject *args) {
+ if (!PyTuple_Check(args)) {
+ args = PyTuple_Pack(1, args);
+ if (args == NULL) {
+ return 0;
+ }
+ }
+ else {
+ Py_INCREF(args);
+ }
+
+ Py_INCREF(origin);
+ alias->origin = origin;
+ alias->args = args;
+ alias->parameters = NULL;
+ alias->weakreflist = NULL;
+ return 1;
+}
+
static PyObject *
ga_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- if (!_PyArg_NoKwnames("GenericAlias", kwds)) {
+ if (!_PyArg_NoKeywords("GenericAlias", kwds)) {
return NULL;
}
if (!_PyArg_CheckPositional("GenericAlias", PyTuple_GET_SIZE(args), 2, 2)) {
@@ -570,9 +646,21 @@ ga_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
PyObject *origin = PyTuple_GET_ITEM(args, 0);
PyObject *arguments = PyTuple_GET_ITEM(args, 1);
- return Py_GenericAlias(origin, arguments);
+ gaobject *self = (gaobject *)type->tp_alloc(type, 0);
+ if (self == NULL) {
+ return NULL;
+ }
+ if (!setup_ga(self, origin, arguments)) {
+ type->tp_free((PyObject *)self);
+ return NULL;
+ }
+ return (PyObject *)self;
}
+static PyNumberMethods ga_as_number = {
+ .nb_or = (binaryfunc)_Py_union_type_or, // Add __or__ function
+};
+
// TODO:
// - argument clinic?
// - __doc__?
@@ -586,13 +674,15 @@ PyTypeObject Py_GenericAliasType = {
.tp_basicsize = sizeof(gaobject),
.tp_dealloc = ga_dealloc,
.tp_repr = ga_repr,
+ .tp_as_number = &ga_as_number, // allow X | Y of GenericAlias objs
.tp_as_mapping = &ga_as_mapping,
.tp_hash = ga_hash,
.tp_call = ga_call,
.tp_getattro = ga_getattro,
- .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
.tp_traverse = ga_traverse,
.tp_richcompare = ga_richcompare,
+ .tp_weaklistoffset = offsetof(gaobject, weakreflist),
.tp_methods = ga_methods,
.tp_members = ga_members,
.tp_alloc = PyType_GenericAlloc,
@@ -604,26 +694,14 @@ PyTypeObject Py_GenericAliasType = {
PyObject *
Py_GenericAlias(PyObject *origin, PyObject *args)
{
- if (!PyTuple_Check(args)) {
- args = PyTuple_Pack(1, args);
- if (args == NULL) {
- return NULL;
- }
- }
- else {
- Py_INCREF(args);
- }
-
gaobject *alias = PyObject_GC_New(gaobject, &Py_GenericAliasType);
if (alias == NULL) {
- Py_DECREF(args);
return NULL;
}
-
- Py_INCREF(origin);
- alias->origin = origin;
- alias->args = args;
- alias->parameters = NULL;
+ if (!setup_ga(alias, origin, args)) {
+ PyObject_GC_Del((PyObject *)alias);
+ return NULL;
+ }
_PyObject_GC_TRACK(alias);
return (PyObject *)alias;
}
diff --git a/Objects/genobject.c b/Objects/genobject.c
index c1b26e9da3..bde92b462d 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -268,30 +268,10 @@ gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult,
return result ? PYGEN_RETURN : PYGEN_ERROR;
}
-PySendResult
-PyIter_Send(PyObject *iter, PyObject *arg, PyObject **result)
+static PySendResult
+PyGen_am_send(PyGenObject *gen, PyObject *arg, PyObject **result)
{
- _Py_IDENTIFIER(send);
- assert(arg != NULL);
- assert(result != NULL);
-
- if (PyGen_CheckExact(iter) || PyCoro_CheckExact(iter)) {
- return gen_send_ex2((PyGenObject *)iter, arg, result, 0, 0);
- }
-
- if (arg == Py_None && PyIter_Check(iter)) {
- *result = Py_TYPE(iter)->tp_iternext(iter);
- }
- else {
- *result = _PyObject_CallMethodIdOneArg(iter, &PyId_send, arg);
- }
- if (*result != NULL) {
- return PYGEN_NEXT;
- }
- if (_PyGen_FetchStopIterationValue(result) == 0) {
- return PYGEN_RETURN;
- }
- return PYGEN_ERROR;
+ return gen_send_ex2(gen, arg, result, 0, 0);
}
static PyObject *
@@ -788,6 +768,14 @@ static PyMethodDef gen_methods[] = {
{NULL, NULL} /* Sentinel */
};
+static PyAsyncMethods gen_as_async = {
+ 0, /* am_await */
+ 0, /* am_aiter */
+ 0, /* am_anext */
+ (sendfunc)PyGen_am_send, /* am_send */
+};
+
+
PyTypeObject PyGen_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"generator", /* tp_name */
@@ -798,7 +786,7 @@ PyTypeObject PyGen_Type = {
0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_as_async */
+ &gen_as_async, /* tp_as_async */
(reprfunc)gen_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -809,7 +797,8 @@ PyTypeObject PyGen_Type = {
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
+ Py_TPFLAGS_HAVE_AM_SEND, /* tp_flags */
0, /* tp_doc */
(traverseproc)gen_traverse, /* tp_traverse */
0, /* tp_clear */
@@ -1031,7 +1020,8 @@ static PyMethodDef coro_methods[] = {
static PyAsyncMethods coro_as_async = {
(unaryfunc)coro_await, /* am_await */
0, /* am_aiter */
- 0 /* am_anext */
+ 0, /* am_anext */
+ (sendfunc)PyGen_am_send, /* am_send */
};
PyTypeObject PyCoro_Type = {
@@ -1055,7 +1045,8 @@ PyTypeObject PyCoro_Type = {
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
+ Py_TPFLAGS_HAVE_AM_SEND, /* tp_flags */
0, /* tp_doc */
(traverseproc)gen_traverse, /* tp_traverse */
0, /* tp_clear */
@@ -1413,7 +1404,8 @@ static PyMethodDef async_gen_methods[] = {
static PyAsyncMethods async_gen_as_async = {
0, /* am_await */
PyObject_SelfIter, /* am_aiter */
- (unaryfunc)async_gen_anext /* am_anext */
+ (unaryfunc)async_gen_anext, /* am_anext */
+ (sendfunc)PyGen_am_send, /* am_send */
};
@@ -1438,7 +1430,8 @@ PyTypeObject PyAsyncGen_Type = {
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
+ Py_TPFLAGS_HAVE_AM_SEND, /* tp_flags */
0, /* tp_doc */
(traverseproc)async_gen_traverse, /* tp_traverse */
0, /* tp_clear */
@@ -1676,7 +1669,8 @@ static PyMethodDef async_gen_asend_methods[] = {
static PyAsyncMethods async_gen_asend_as_async = {
PyObject_SelfIter, /* am_await */
0, /* am_aiter */
- 0 /* am_anext */
+ 0, /* am_anext */
+ 0, /* am_send */
};
@@ -2084,7 +2078,8 @@ static PyMethodDef async_gen_athrow_methods[] = {
static PyAsyncMethods async_gen_athrow_as_async = {
PyObject_SelfIter, /* am_await */
0, /* am_aiter */
- 0 /* am_anext */
+ 0, /* am_anext */
+ 0, /* am_send */
};
diff --git a/Objects/listobject.c b/Objects/listobject.c
index aac87ea1b6..ca9df599a0 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -341,7 +341,7 @@ list_dealloc(PyListObject *op)
while (--i >= 0) {
Py_XDECREF(op->ob_item[i]);
}
- PyMem_FREE(op->ob_item);
+ PyMem_Free(op->ob_item);
}
struct _Py_list_state *state = get_list_state();
#ifdef Py_DEBUG
@@ -592,7 +592,7 @@ _list_clear(PyListObject *a)
while (--i >= 0) {
Py_XDECREF(item[i]);
}
- PyMem_FREE(item);
+ PyMem_Free(item);
}
/* Never fails; the return value can be ignored.
Note that there is no guarantee that the list is actually empty
@@ -668,7 +668,7 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
/* If norig == 0, item might be NULL, in which case we may not memcpy from it. */
if (s) {
if (s > sizeof(recycle_on_stack)) {
- recycle = (PyObject **)PyMem_MALLOC(s);
+ recycle = (PyObject **)PyMem_Malloc(s);
if (recycle == NULL) {
PyErr_NoMemory();
goto Error;
@@ -706,7 +706,7 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
result = 0;
Error:
if (recycle != recycle_on_stack)
- PyMem_FREE(recycle);
+ PyMem_Free(recycle);
Py_XDECREF(v_as_SF);
return result;
#undef b
@@ -2230,7 +2230,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
/* Leverage stack space we allocated but won't otherwise use */
keys = &ms.temparray[saved_ob_size+1];
else {
- keys = PyMem_MALLOC(sizeof(PyObject *) * saved_ob_size);
+ keys = PyMem_Malloc(sizeof(PyObject *) * saved_ob_size);
if (keys == NULL) {
PyErr_NoMemory();
goto keyfunc_fail;
@@ -2243,7 +2243,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
for (i=i-1 ; i>=0 ; i--)
Py_DECREF(keys[i]);
if (saved_ob_size >= MERGESTATE_TEMP_SIZE/2)
- PyMem_FREE(keys);
+ PyMem_Free(keys);
goto keyfunc_fail;
}
}
@@ -2414,7 +2414,7 @@ fail:
for (i = 0; i < saved_ob_size; i++)
Py_DECREF(keys[i]);
if (saved_ob_size >= MERGESTATE_TEMP_SIZE/2)
- PyMem_FREE(keys);
+ PyMem_Free(keys);
}
if (self->allocated != -1 && result != NULL) {
@@ -2442,7 +2442,7 @@ keyfunc_fail:
while (--i >= 0) {
Py_XDECREF(final_ob_item[i]);
}
- PyMem_FREE(final_ob_item);
+ PyMem_Free(final_ob_item);
}
Py_XINCREF(result);
return result;
@@ -2908,7 +2908,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
}
garbage = (PyObject**)
- PyMem_MALLOC(slicelength*sizeof(PyObject*));
+ PyMem_Malloc(slicelength*sizeof(PyObject*));
if (!garbage) {
PyErr_NoMemory();
return -1;
@@ -2949,7 +2949,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
for (i = 0; i < slicelength; i++) {
Py_DECREF(garbage[i]);
}
- PyMem_FREE(garbage);
+ PyMem_Free(garbage);
return res;
}
@@ -2990,7 +2990,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
}
garbage = (PyObject**)
- PyMem_MALLOC(slicelength*sizeof(PyObject*));
+ PyMem_Malloc(slicelength*sizeof(PyObject*));
if (!garbage) {
Py_DECREF(seq);
PyErr_NoMemory();
@@ -3011,7 +3011,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
Py_DECREF(garbage[i]);
}
- PyMem_FREE(garbage);
+ PyMem_Free(garbage);
Py_DECREF(seq);
return 0;
diff --git a/Objects/lnotab_notes.txt b/Objects/lnotab_notes.txt
index 71a2979718..046f753ed3 100644
--- a/Objects/lnotab_notes.txt
+++ b/Objects/lnotab_notes.txt
@@ -1,11 +1,103 @@
-All about co_lnotab, the line number table.
-
-Code objects store a field named co_lnotab. This is an array of unsigned bytes
-disguised as a Python bytes object. It is used to map bytecode offsets to
-source code line #s for tracebacks and to identify line number boundaries for
-line tracing. Because of internals of the peephole optimizer, it's possible
-for lnotab to contain bytecode offsets that are no longer valid (for example
-if the optimizer removed the last line in a function).
+Description of the internal format of the line number table
+
+Conceptually, the line number table consists of a sequence of triples:
+ start-offset (inclusive), end-offset (exclusive), line-number.
+
+Note that note all byte codes have a line number so we need handle `None` for the line-number.
+
+However, storing the above sequence directly would be very inefficient as we would need 12 bytes per entry.
+
+First of all, we can note that the end of one entry is the same as the start of the next, so we can overlap entries.
+Secondly we also note that we don't really need arbitrary access to the sequence, so we can store deltas.
+
+We just need to store (end - start, line delta) pairs. The start offset of the first entry is always zero.
+
+Thirdly, most deltas are small, so we can use a single byte for each value, as long we allow several entries for the same line.
+
+Consider the following table
+ Start End Line
+ 0 6 1
+ 6 50 2
+ 50 350 7
+ 350 360 No line number
+ 360 376 8
+ 376 380 208
+
+Stripping the redundant ends gives:
+
+ End-Start Line-delta
+ 6 +1
+ 44 +1
+ 300 +5
+ 10 No line number
+ 16 +1
+ 4 +200
+
+
+Note that the end - start value is always positive.
+
+Finally in order, to fit into a single byte we need to convert start deltas to the range 0 <= delta <= 254,
+and line deltas to the range -127 <= delta <= 127.
+A line delta of -128 is used to indicate no line number.
+A start delta of 255 is used as a sentinel to mark the end of the table.
+Also note that a delta of zero indicates that there are no bytecodes in the given range,
+which means can use an invalidate line number for that range.
+
+Final form:
+
+ Start delta Line delta
+ 6 +1
+ 44 +1
+ 254 +5
+ 46 0
+ 10 -128 (No line number, treated as a delta of zero)
+ 16 +1
+ 0 +127 (line 135, but the range is empty as no bytecodes are at line 135)
+ 4 +73
+ 255 (end mark) ---
+
+Iterating over the table.
+-------------------------
+
+For the `co_lines` attribute we want to emit the full form, omitting the (350, 360, No line number) and empty entries.
+
+The code is as follows:
+
+def co_lines(code):
+ line = code.co_firstlineno
+ end = 0
+ table_iter = iter(code.internal_line_table):
+ for sdelta, ldelta in table_iter:
+ if sdelta == 255:
+ break
+ if ldelta == 0: # No change to line number, just accumulate changes to end
+ end += odelta
+ continue
+ start = end
+ end = start + sdelta
+ if ldelta == -128: # No valid line number -- skip entry
+ continue
+ line += ldelta
+ if end == start: # Empty range, omit.
+ continue
+ yield start, end, line
+
+
+
+
+The historical co_lnotab format
+-------------------------------
+
+prior to 3.10 code objects stored a field named co_lnotab.
+This was an array of unsigned bytes disguised as a Python bytes object.
+
+The old co_lnotab did not account for the presence of bytecodes without a line number,
+nor was it well suited to tracing as a number of workarounds were required.
+
+The old format can still be accessed via `code.co_lnotab`, which is lazily computed from the new format.
+
+Below is the description of the old co_lnotab format:
+
The array is conceptually a compressed list of
(bytecode offset increment, line number increment)
diff --git a/Objects/longobject.c b/Objects/longobject.c
index e0d6410fe6..240e92a41e 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -131,7 +131,7 @@ _PyLong_New(Py_ssize_t size)
"too many digits in integer");
return NULL;
}
- result = PyObject_MALLOC(offsetof(PyLongObject, ob_digit) +
+ result = PyObject_Malloc(offsetof(PyLongObject, ob_digit) +
size*sizeof(digit));
if (!result) {
PyErr_NoMemory();
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index c3ceb788e8..6590387dac 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -211,7 +211,7 @@ _PyModule_CreateInitialized(struct PyModuleDef* module, int module_api_version)
return NULL;
if (module->m_size > 0) {
- m->md_state = PyMem_MALLOC(module->m_size);
+ m->md_state = PyMem_Malloc(module->m_size);
if (!m->md_state) {
PyErr_NoMemory();
Py_DECREF(m);
@@ -377,7 +377,7 @@ PyModule_ExecDef(PyObject *module, PyModuleDef *def)
if (md->md_state == NULL) {
/* Always set a state pointer; this serves as a marker to skip
* multiple initialization (importlib.reload() is no-op) */
- md->md_state = PyMem_MALLOC(def->m_size);
+ md->md_state = PyMem_Malloc(def->m_size);
if (!md->md_state) {
PyErr_NoMemory();
return -1;
@@ -681,7 +681,7 @@ module_dealloc(PyModuleObject *m)
Py_XDECREF(m->md_dict);
Py_XDECREF(m->md_name);
if (m->md_state != NULL)
- PyMem_FREE(m->md_state);
+ PyMem_Free(m->md_state);
Py_TYPE(m)->tp_free((PyObject *)m);
}
diff --git a/Objects/object.c b/Objects/object.c
index 7bc3e48d40..0a8621b350 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -161,7 +161,7 @@ PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, Py_ssize_t size)
PyObject *
_PyObject_New(PyTypeObject *tp)
{
- PyObject *op = (PyObject *) PyObject_MALLOC(_PyObject_SIZE(tp));
+ PyObject *op = (PyObject *) PyObject_Malloc(_PyObject_SIZE(tp));
if (op == NULL) {
return PyErr_NoMemory();
}
@@ -174,7 +174,7 @@ _PyObject_NewVar(PyTypeObject *tp, Py_ssize_t nitems)
{
PyVarObject *op;
const size_t size = _PyObject_VAR_SIZE(tp, nitems);
- op = (PyVarObject *) PyObject_MALLOC(size);
+ op = (PyVarObject *) PyObject_Malloc(size);
if (op == NULL) {
return (PyVarObject *)PyErr_NoMemory();
}
@@ -2134,6 +2134,15 @@ _PyTrash_end(PyThreadState *tstate)
}
+/* bpo-40170: It's only be used in Py_TRASHCAN_BEGIN macro to hide
+ implementation details. */
+int
+_PyTrash_cond(PyObject *op, destructor dealloc)
+{
+ return Py_TYPE(op)->tp_dealloc == dealloc;
+}
+
+
void _Py_NO_RETURN
_PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
const char *file, int line, const char *function)
@@ -2208,6 +2217,22 @@ PyObject_GET_WEAKREFS_LISTPTR(PyObject *op)
}
+#undef Py_NewRef
+#undef Py_XNewRef
+
+// Export Py_NewRef() and Py_XNewRef() as regular functions for the stable ABI.
+PyObject*
+Py_NewRef(PyObject *obj)
+{
+ return _Py_NewRef(obj);
+}
+
+PyObject*
+Py_XNewRef(PyObject *obj)
+{
+ return _Py_XNewRef(obj);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index b4ac560d23..6c7f1175cd 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -459,7 +459,7 @@ later:
- implement a fuller MutableMapping API in C?
- move the MutableMapping implementation to abstract.c?
- optimize mutablemapping_update
-- use PyObject_MALLOC (small object allocator) for odict nodes?
+- use PyObject_Malloc (small object allocator) for odict nodes?
- support subclasses better (e.g. in odict_richcompare)
*/
@@ -567,14 +567,14 @@ _odict_resize(PyODictObject *od)
i = _odict_get_index_raw(od, _odictnode_KEY(node),
_odictnode_HASH(node));
if (i < 0) {
- PyMem_FREE(fast_nodes);
+ PyMem_Free(fast_nodes);
return -1;
}
fast_nodes[i] = node;
}
/* Replace the old fast nodes table. */
- PyMem_FREE(od->od_fast_nodes);
+ PyMem_Free(od->od_fast_nodes);
od->od_fast_nodes = fast_nodes;
od->od_fast_nodes_size = size;
od->od_resize_sentinel = ((PyDictObject *)od)->ma_keys;
@@ -683,7 +683,7 @@ _odict_add_new_node(PyODictObject *od, PyObject *key, Py_hash_t hash)
}
/* must not be added yet */
- node = (_ODictNode *)PyMem_MALLOC(sizeof(_ODictNode));
+ node = (_ODictNode *)PyMem_Malloc(sizeof(_ODictNode));
if (node == NULL) {
Py_DECREF(key);
PyErr_NoMemory();
@@ -701,7 +701,7 @@ _odict_add_new_node(PyODictObject *od, PyObject *key, Py_hash_t hash)
#define _odictnode_DEALLOC(node) \
do { \
Py_DECREF(_odictnode_KEY(node)); \
- PyMem_FREE((void *)node); \
+ PyMem_Free((void *)node); \
} while (0)
/* Repeated calls on the same node are no-ops. */
@@ -776,7 +776,7 @@ _odict_clear_nodes(PyODictObject *od)
{
_ODictNode *node, *next;
- PyMem_FREE(od->od_fast_nodes);
+ PyMem_Free(od->od_fast_nodes);
od->od_fast_nodes = NULL;
od->od_fast_nodes_size = 0;
od->od_resize_sentinel = NULL;
@@ -1814,6 +1814,11 @@ odictiter_iternext(odictiterobject *di)
Py_INCREF(result);
Py_DECREF(PyTuple_GET_ITEM(result, 0)); /* borrowed */
Py_DECREF(PyTuple_GET_ITEM(result, 1)); /* borrowed */
+ // bpo-42536: The GC may have untracked this result tuple. Since we're
+ // recycling it, make sure it's tracked again:
+ if (!_PyObject_GC_IS_TRACKED(result)) {
+ _PyObject_GC_TRACK(result);
+ }
}
else {
result = PyTuple_New(2);
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index 787d113800..530426c8ac 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -171,7 +171,7 @@ range_dealloc(rangeobject *r)
Py_DECREF(r->stop);
Py_DECREF(r->step);
Py_DECREF(r->length);
- PyObject_Del(r);
+ PyObject_Free(r);
}
/* Return number of items in range (lo, hi, step) as a PyLong object,
@@ -1021,7 +1021,7 @@ longrangeiter_dealloc(longrangeiterobject *r)
Py_XDECREF(r->start);
Py_XDECREF(r->step);
Py_XDECREF(r->len);
- PyObject_Del(r);
+ PyObject_Free(r);
}
static PyObject *
diff --git a/Objects/setobject.c b/Objects/setobject.c
index af8ee03d83..79e8451192 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -289,7 +289,7 @@ set_table_resize(PySetObject *so, Py_ssize_t minused)
}
if (is_oldtable_malloced)
- PyMem_DEL(oldtable);
+ PyMem_Free(oldtable);
return 0;
}
@@ -424,7 +424,7 @@ set_clear_internal(PySetObject *so)
}
if (table_is_malloced)
- PyMem_DEL(table);
+ PyMem_Free(table);
return 0;
}
@@ -484,7 +484,7 @@ set_dealloc(PySetObject *so)
}
}
if (so->table != so->smalltable)
- PyMem_DEL(so->table);
+ PyMem_Free(so->table);
Py_TYPE(so)->tp_free(so);
Py_TRASHCAN_END
}
diff --git a/Objects/stringlib/join.h b/Objects/stringlib/join.h
index 53bcbdea7a..62e4c98de7 100644
--- a/Objects/stringlib/join.h
+++ b/Objects/stringlib/join.h
@@ -155,7 +155,7 @@ done:
for (i = 0; i < nbufs; i++)
PyBuffer_Release(&buffers[i]);
if (buffers != static_buffers)
- PyMem_FREE(buffers);
+ PyMem_Free(buffers);
return res;
}
diff --git a/Objects/stringlib/unicode_format.h b/Objects/stringlib/unicode_format.h
index b526ad21b8..7152ec6ebe 100644
--- a/Objects/stringlib/unicode_format.h
+++ b/Objects/stringlib/unicode_format.h
@@ -983,7 +983,7 @@ static void
formatteriter_dealloc(formatteriterobject *it)
{
Py_XDECREF(it->str);
- PyObject_FREE(it);
+ PyObject_Free(it);
}
/* returns a tuple:
@@ -1147,7 +1147,7 @@ static void
fieldnameiter_dealloc(fieldnameiterobject *it)
{
Py_XDECREF(it->str);
- PyObject_FREE(it);
+ PyObject_Free(it);
}
/* returns a tuple:
diff --git a/Objects/structseq.c b/Objects/structseq.c
index 5caa3bd52e..5d71fcff34 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -467,14 +467,14 @@ PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc *desc)
type->tp_members = members;
if (PyType_Ready(type) < 0) {
- PyMem_FREE(members);
+ PyMem_Free(members);
return -1;
}
Py_INCREF(type);
if (initialize_structseq_dict(
desc, type->tp_dict, n_members, n_unnamed_members) < 0) {
- PyMem_FREE(members);
+ PyMem_Free(members);
Py_DECREF(type);
return -1;
}
@@ -492,7 +492,6 @@ PyTypeObject *
PyStructSequence_NewType(PyStructSequence_Desc *desc)
{
PyMemberDef *members;
- PyObject *bases;
PyTypeObject *type;
PyType_Slot slots[8];
PyType_Spec spec;
@@ -526,14 +525,8 @@ PyStructSequence_NewType(PyStructSequence_Desc *desc)
spec.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC;
spec.slots = slots;
- bases = PyTuple_Pack(1, &PyTuple_Type);
- if (bases == NULL) {
- PyMem_FREE(members);
- return NULL;
- }
- type = (PyTypeObject *)PyType_FromSpecWithBases(&spec, bases);
- Py_DECREF(bases);
- PyMem_FREE(members);
+ type = (PyTypeObject *)PyType_FromSpecWithBases(&spec, (PyObject *)&PyTuple_Type);
+ PyMem_Free(members);
if (type == NULL) {
return NULL;
}
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index bd1587ace8..3498f0d484 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -6,7 +6,7 @@
#include "pycore_object.h"
#include "pycore_pyerrors.h"
#include "pycore_pystate.h" // _PyThreadState_GET()
-#include "pycore_unionobject.h" // _Py_Union()
+#include "pycore_unionobject.h" // _Py_Union(), _Py_union_type_or
#include "frameobject.h"
#include "structmember.h" // PyMemberDef
@@ -20,20 +20,13 @@ class object "PyObject *" "&PyBaseObject_Type"
#include "clinic/typeobject.c.h"
-/* bpo-40521: Type method cache is shared by all subinterpreters */
-#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
-# define MCACHE
-#endif
-
-#ifdef MCACHE
-/* Support type attribute cache */
+/* Support type attribute lookup cache */
/* The cache can keep references to the names alive for longer than
they normally would. This is why the maximum size is limited to
MCACHE_MAX_ATTR_SIZE, since it might be a problem if very large
strings are used as attribute names. */
#define MCACHE_MAX_ATTR_SIZE 100
-#define MCACHE_SIZE_EXP 12
#define MCACHE_HASH(version, name_hash) \
(((unsigned int)(version) ^ (unsigned int)(name_hash)) \
& ((1 << MCACHE_SIZE_EXP) - 1))
@@ -44,30 +37,16 @@ class object "PyObject *" "&PyBaseObject_Type"
#define MCACHE_CACHEABLE_NAME(name) \
PyUnicode_CheckExact(name) && \
PyUnicode_IS_READY(name) && \
- PyUnicode_GET_LENGTH(name) <= MCACHE_MAX_ATTR_SIZE
-
-struct method_cache_entry {
- unsigned int version;
- PyObject *name; /* reference to exactly a str or None */
- PyObject *value; /* borrowed */
-};
+ (PyUnicode_GET_LENGTH(name) <= MCACHE_MAX_ATTR_SIZE)
-static struct method_cache_entry method_cache[1 << MCACHE_SIZE_EXP];
+// Used to set PyTypeObject.tp_version_tag
static unsigned int next_version_tag = 0;
-#endif
-#define MCACHE_STATS 0
+typedef struct PySlot_Offset {
+ short subslot_offset;
+ short slot_offset;
+} PySlot_Offset;
-#if MCACHE_STATS
-static size_t method_cache_hits = 0;
-static size_t method_cache_misses = 0;
-static size_t method_cache_collisions = 0;
-#endif
-
-/* bpo-40521: Interned strings are shared by all subinterpreters */
-#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
-# define INTERN_NAME_STRINGS
-#endif
/* alphabetical order */
_Py_IDENTIFIER(__abstractmethods__);
@@ -224,46 +203,95 @@ _PyType_GetTextSignatureFromInternalDoc(const char *name, const char *internal_d
return PyUnicode_FromStringAndSize(start, end - start);
}
-unsigned int
-PyType_ClearCache(void)
+
+static struct type_cache*
+get_type_cache(void)
{
-#ifdef MCACHE
- Py_ssize_t i;
- unsigned int cur_version_tag = next_version_tag - 1;
+ PyInterpreterState *interp = _PyInterpreterState_GET();
+ return &interp->type_cache;
+}
+
+
+static void
+type_cache_clear(struct type_cache *cache, int use_none)
+{
+ for (Py_ssize_t i = 0; i < (1 << MCACHE_SIZE_EXP); i++) {
+ struct type_cache_entry *entry = &cache->hashtable[i];
+ entry->version = 0;
+ if (use_none) {
+ // Set to None so _PyType_Lookup() can use Py_SETREF(),
+ // rather than using slower Py_XSETREF().
+ Py_XSETREF(entry->name, Py_NewRef(Py_None));
+ }
+ else {
+ Py_CLEAR(entry->name);
+ }
+ entry->value = NULL;
+ }
+
+ // Mark all version tags as invalid
+ PyType_Modified(&PyBaseObject_Type);
+}
+
+
+void
+_PyType_InitCache(PyInterpreterState *interp)
+{
+ struct type_cache *cache = &interp->type_cache;
+ for (Py_ssize_t i = 0; i < (1 << MCACHE_SIZE_EXP); i++) {
+ struct type_cache_entry *entry = &cache->hashtable[i];
+ assert(entry->name == NULL);
+ entry->version = 0;
+ // Set to None so _PyType_Lookup() can use Py_SETREF(),
+ // rather than using slower Py_XSETREF().
+ entry->name = Py_NewRef(Py_None);
+ entry->value = NULL;
+ }
+}
+
+
+static unsigned int
+_PyType_ClearCache(struct type_cache *cache)
+{
#if MCACHE_STATS
- size_t total = method_cache_hits + method_cache_collisions + method_cache_misses;
+ size_t total = cache->hits + cache->collisions + cache->misses;
fprintf(stderr, "-- Method cache hits = %zd (%d%%)\n",
- method_cache_hits, (int) (100.0 * method_cache_hits / total));
+ cache->hits, (int) (100.0 * cache->hits / total));
fprintf(stderr, "-- Method cache true misses = %zd (%d%%)\n",
- method_cache_misses, (int) (100.0 * method_cache_misses / total));
+ cache->misses, (int) (100.0 * cache->misses / total));
fprintf(stderr, "-- Method cache collisions = %zd (%d%%)\n",
- method_cache_collisions, (int) (100.0 * method_cache_collisions / total));
+ cache->collisions, (int) (100.0 * cache->collisions / total));
fprintf(stderr, "-- Method cache size = %zd KiB\n",
- sizeof(method_cache) / 1024);
+ sizeof(cache->hashtable) / 1024);
#endif
- for (i = 0; i < (1 << MCACHE_SIZE_EXP); i++) {
- method_cache[i].version = 0;
- Py_CLEAR(method_cache[i].name);
- method_cache[i].value = NULL;
- }
+ unsigned int cur_version_tag = next_version_tag - 1;
next_version_tag = 0;
- /* mark all version tags as invalid */
- PyType_Modified(&PyBaseObject_Type);
+ type_cache_clear(cache, 0);
+
return cur_version_tag;
-#else
- return 0;
-#endif
}
+
+unsigned int
+PyType_ClearCache(void)
+{
+ struct type_cache *cache = get_type_cache();
+ return _PyType_ClearCache(cache);
+}
+
+
void
-_PyType_Fini(void)
+_PyType_Fini(PyThreadState *tstate)
{
- PyType_ClearCache();
- clear_slotdefs();
+ _PyType_ClearCache(&tstate->interp->type_cache);
+ if (_Py_IsMainInterpreter(tstate)) {
+ clear_slotdefs();
+ }
}
+
void
PyType_Modified(PyTypeObject *type)
{
@@ -365,9 +393,8 @@ type_mro_modified(PyTypeObject *type, PyObject *bases) {
Py_TPFLAGS_VALID_VERSION_TAG);
}
-#ifdef MCACHE
static int
-assign_version_tag(PyTypeObject *type)
+assign_version_tag(struct type_cache *cache, PyTypeObject *type)
{
/* Ensure that the tp_version_tag is valid and set
Py_TPFLAGS_VALID_VERSION_TAG. To respect the invariant, this
@@ -388,31 +415,22 @@ assign_version_tag(PyTypeObject *type)
/* for stress-testing: next_version_tag &= 0xFF; */
if (type->tp_version_tag == 0) {
- /* wrap-around or just starting Python - clear the whole
- cache by filling names with references to Py_None.
- Values are also set to NULL for added protection, as they
- are borrowed reference */
- for (i = 0; i < (1 << MCACHE_SIZE_EXP); i++) {
- method_cache[i].value = NULL;
- Py_INCREF(Py_None);
- Py_XSETREF(method_cache[i].name, Py_None);
- }
- /* mark all version tags as invalid */
- PyType_Modified(&PyBaseObject_Type);
+ // Wrap-around or just starting Python - clear the whole cache
+ type_cache_clear(cache, 1);
return 1;
}
+
bases = type->tp_bases;
n = PyTuple_GET_SIZE(bases);
for (i = 0; i < n; i++) {
PyObject *b = PyTuple_GET_ITEM(bases, i);
assert(PyType_Check(b));
- if (!assign_version_tag((PyTypeObject *)b))
+ if (!assign_version_tag(cache, (PyTypeObject *)b))
return 0;
}
type->tp_flags |= Py_TPFLAGS_VALID_VERSION_TAG;
return 1;
}
-#endif
static PyMemberDef type_members[] = {
@@ -1054,7 +1072,7 @@ PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
obj = _PyObject_GC_Malloc(size);
}
else {
- obj = (PyObject *)PyObject_MALLOC(size);
+ obj = (PyObject *)PyObject_Malloc(size);
}
if (obj == NULL) {
@@ -1774,7 +1792,7 @@ pmerge(PyObject *acc, PyObject **to_merge, Py_ssize_t to_merge_size)
}
out:
- PyMem_Del(remain);
+ PyMem_Free(remain);
return res;
}
@@ -1854,7 +1872,7 @@ mro_implementation(PyTypeObject *type)
result = PyList_New(1);
if (result == NULL) {
- PyMem_Del(to_merge);
+ PyMem_Free(to_merge);
return NULL;
}
@@ -1864,7 +1882,7 @@ mro_implementation(PyTypeObject *type)
Py_CLEAR(result);
}
- PyMem_Del(to_merge);
+ PyMem_Free(to_merge);
return result;
}
@@ -2702,7 +2720,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
goto error;
/* Silently truncate the docstring if it contains null bytes. */
len = strlen(doc_str);
- tp_doc = (char *)PyObject_MALLOC(len + 1);
+ tp_doc = (char *)PyObject_Malloc(len + 1);
if (tp_doc == NULL) {
PyErr_NoMemory();
goto error;
@@ -2870,8 +2888,18 @@ error:
return NULL;
}
-static const short slotoffsets[] = {
- -1, /* invalid slot */
+/* An array of type slot offsets corresponding to Py_tp_* constants,
+ * for use in e.g. PyType_Spec and PyType_GetSlot.
+ * Each entry has two offsets: "slot_offset" and "subslot_offset".
+ * If is subslot_offset is -1, slot_offset is an offset within the
+ * PyTypeObject struct.
+ * Otherwise slot_offset is an offset to a pointer to a sub-slots struct
+ * (such as "tp_as_number"), and subslot_offset is the offset within
+ * that struct.
+ * The actual table is generated by a script.
+ */
+static const PySlot_Offset pyslot_offsets[] = {
+ {0, 0},
#include "typeslots.inc"
};
@@ -2892,6 +2920,7 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
const PyType_Slot *slot;
Py_ssize_t nmembers, weaklistoffset, dictoffset, vectorcalloffset;
char *res_start;
+ short slot_offset, subslot_offset;
nmembers = weaklistoffset = dictoffset = vectorcalloffset = 0;
for (slot = spec->slots; slot->slot; slot++) {
@@ -2961,26 +2990,41 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
base = slot->pfunc;
else if (slot->slot == Py_tp_bases) {
bases = slot->pfunc;
- Py_INCREF(bases);
}
}
- if (!bases)
+ if (!bases) {
bases = PyTuple_Pack(1, base);
+ if (!bases)
+ goto fail;
+ }
+ else if (!PyTuple_Check(bases)) {
+ PyErr_SetString(PyExc_SystemError, "Py_tp_bases is not a tuple");
+ goto fail;
+ }
+ else {
+ Py_INCREF(bases);
+ }
+ }
+ else if (!PyTuple_Check(bases)) {
+ bases = PyTuple_Pack(1, bases);
if (!bases)
goto fail;
}
- else
+ else {
Py_INCREF(bases);
+ }
/* Calculate best base, and check that all bases are type objects */
base = best_base(bases);
if (base == NULL) {
+ Py_DECREF(bases);
goto fail;
}
if (!_PyType_HasFeature(base, Py_TPFLAGS_BASETYPE)) {
PyErr_Format(PyExc_TypeError,
"type '%.100s' is not an acceptable base type",
base->tp_name);
+ Py_DECREF(bases);
goto fail;
}
@@ -2992,7 +3036,6 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
type->tp_as_buffer = &res->as_buffer;
/* Set tp_base and tp_bases */
type->tp_bases = bases;
- bases = NULL;
Py_INCREF(base);
type->tp_base = base;
@@ -3001,7 +3044,7 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
for (slot = spec->slots; slot->slot; slot++) {
if (slot->slot < 0
- || (size_t)slot->slot >= Py_ARRAY_LENGTH(slotoffsets)) {
+ || (size_t)slot->slot >= Py_ARRAY_LENGTH(pyslot_offsets)) {
PyErr_SetString(PyExc_RuntimeError, "invalid slot offset");
goto fail;
}
@@ -3012,8 +3055,12 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
else if (slot->slot == Py_tp_doc) {
/* For the docstring slot, which usually points to a static string
literal, we need to make a copy */
+ if (slot->pfunc == NULL) {
+ type->tp_doc = NULL;
+ continue;
+ }
size_t len = strlen(slot->pfunc)+1;
- char *tp_doc = PyObject_MALLOC(len);
+ char *tp_doc = PyObject_Malloc(len);
if (tp_doc == NULL) {
type->tp_doc = NULL;
PyErr_NoMemory();
@@ -3030,7 +3077,15 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
}
else {
/* Copy other slots directly */
- *(void**)(res_start + slotoffsets[slot->slot]) = slot->pfunc;
+ PySlot_Offset slotoffsets = pyslot_offsets[slot->slot];
+ slot_offset = slotoffsets.slot_offset;
+ if (slotoffsets.subslot_offset == -1) {
+ *(void**)((char*)res_start + slot_offset) = slot->pfunc;
+ } else {
+ void *parent_slot = *(void**)((char*)res_start + slot_offset);
+ subslot_offset = slotoffsets.subslot_offset;
+ *(void**)((char*)parent_slot + subslot_offset) = slot->pfunc;
+ }
}
}
if (type->tp_dealloc == NULL) {
@@ -3113,15 +3168,23 @@ PyType_FromSpec(PyType_Spec *spec)
void *
PyType_GetSlot(PyTypeObject *type, int slot)
{
- if (!_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE) || slot < 0) {
+ void *parent_slot;
+ int slots_len = Py_ARRAY_LENGTH(pyslot_offsets);
+
+ if (slot <= 0 || slot >= slots_len) {
PyErr_BadInternalCall();
return NULL;
}
- if ((size_t)slot >= Py_ARRAY_LENGTH(slotoffsets)) {
- /* Extension module requesting slot from a future version */
+
+ parent_slot = *(void**)((char*)type + pyslot_offsets[slot].slot_offset);
+ if (parent_slot == NULL) {
return NULL;
}
- return *(void**)(((char*)type) + slotoffsets[slot]);
+ /* Return slot directly if we have no sub slot. */
+ if (pyslot_offsets[slot].subslot_offset == -1) {
+ return parent_slot;
+ }
+ return *(void**)((char*)parent_slot + pyslot_offsets[slot].subslot_offset);
}
PyObject *
@@ -3158,6 +3221,44 @@ PyType_GetModuleState(PyTypeObject *type)
return PyModule_GetState(m);
}
+
+/* Get the module of the first superclass where the module has the
+ * given PyModuleDef.
+ * Implemented by walking the MRO, is relatively slow.
+ *
+ * This is internal API for experimentation within stdlib. Discussion:
+ * https://mail.python.org/archives/list/capi-sig@python.org/thread/T3P2QNLNLBRFHWSKYSTPMVEIL2EEKFJU/
+ */
+PyObject *
+_PyType_GetModuleByDef(PyTypeObject *type, struct PyModuleDef *def)
+{
+ assert(PyType_Check(type));
+ assert(type->tp_mro);
+ int i;
+ for (i = 0; i < PyTuple_GET_SIZE(type->tp_mro); i++) {
+ PyObject *super = PyTuple_GET_ITEM(type->tp_mro, i);
+ if (!PyType_HasFeature((PyTypeObject *)super, Py_TPFLAGS_HEAPTYPE)) {
+ /* Currently, there's no way for static types to inherit
+ * from heap types, but to allow that possibility,
+ * we `continue` rather than `break`.
+ * We'll just potentially loop a few more times before throwing
+ * the error.
+ */
+ continue;
+ }
+ PyHeapTypeObject *ht = (PyHeapTypeObject*)super;
+ if (ht->ht_module && PyModule_GetDef(ht->ht_module) == def) {
+ return ht->ht_module;
+ }
+ }
+ PyErr_Format(
+ PyExc_TypeError,
+ "_PyType_GetModuleByDef: No superclass of '%s' has the given module",
+ type->tp_name);
+ return NULL;
+}
+
+
/* Internal API to look for a name through the MRO, bypassing the method cache.
This returns a borrowed reference, and might set an exception.
'error' is set to: -1: error with exception; 1: error without exception; 0: ok */
@@ -3228,20 +3329,19 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name)
PyObject *res;
int error;
-#ifdef MCACHE
if (MCACHE_CACHEABLE_NAME(name) &&
_PyType_HasFeature(type, Py_TPFLAGS_VALID_VERSION_TAG)) {
/* fast path */
unsigned int h = MCACHE_HASH_METHOD(type, name);
- if (method_cache[h].version == type->tp_version_tag &&
- method_cache[h].name == name) {
+ struct type_cache *cache = get_type_cache();
+ struct type_cache_entry *entry = &cache->hashtable[h];
+ if (entry->version == type->tp_version_tag && entry->name == name) {
#if MCACHE_STATS
- method_cache_hits++;
+ cache->hits++;
#endif
- return method_cache[h].value;
+ return entry->value;
}
}
-#endif
/* We may end up clearing live exceptions below, so make sure it's ours. */
assert(!PyErr_Occurred());
@@ -3263,22 +3363,25 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name)
return NULL;
}
-#ifdef MCACHE
- if (MCACHE_CACHEABLE_NAME(name) && assign_version_tag(type)) {
- unsigned int h = MCACHE_HASH_METHOD(type, name);
- method_cache[h].version = type->tp_version_tag;
- method_cache[h].value = res; /* borrowed */
- Py_INCREF(name);
- assert(((PyASCIIObject *)(name))->hash != -1);
+ if (MCACHE_CACHEABLE_NAME(name)) {
+ struct type_cache *cache = get_type_cache();
+ if (assign_version_tag(cache, type)) {
+ unsigned int h = MCACHE_HASH_METHOD(type, name);
+ struct type_cache_entry *entry = &cache->hashtable[h];
+ entry->version = type->tp_version_tag;
+ entry->value = res; /* borrowed */
+ assert(((PyASCIIObject *)(name))->hash != -1);
#if MCACHE_STATS
- if (method_cache[h].name != Py_None && method_cache[h].name != name)
- method_cache_collisions++;
- else
- method_cache_misses++;
+ if (entry->name != Py_None && entry->name != name) {
+ cache->collisions++;
+ }
+ else {
+ cache->misses++;
+ }
#endif
- Py_SETREF(method_cache[h].name, name);
+ Py_SETREF(entry->name, Py_NewRef(name));
+ }
}
-#endif
return res;
}
@@ -3421,7 +3524,6 @@ type_setattro(PyTypeObject *type, PyObject *name, PyObject *value)
if (name == NULL)
return -1;
}
-#ifdef INTERN_NAME_STRINGS
if (!PyUnicode_CHECK_INTERNED(name)) {
PyUnicode_InternInPlace(&name);
if (!PyUnicode_CHECK_INTERNED(name)) {
@@ -3431,7 +3533,6 @@ type_setattro(PyTypeObject *type, PyObject *name, PyObject *value)
return -1;
}
}
-#endif
}
else {
/* Will fail in _PyObject_GenericSetAttrWithDict. */
@@ -3747,19 +3848,9 @@ type_is_gc(PyTypeObject *type)
return type->tp_flags & Py_TPFLAGS_HEAPTYPE;
}
-static PyObject *
-type_or(PyTypeObject* self, PyObject* param) {
- PyObject *tuple = PyTuple_Pack(2, self, param);
- if (tuple == NULL) {
- return NULL;
- }
- PyObject *new_union = _Py_Union(tuple);
- Py_DECREF(tuple);
- return new_union;
-}
static PyNumberMethods type_as_number = {
- .nb_or = (binaryfunc)type_or, // Add __or__ function
+ .nb_or = _Py_union_type_or, // Add __or__ function
};
PyTypeObject PyType_Type = {
@@ -5395,6 +5486,13 @@ PyType_Ready(PyTypeObject *type)
_PyObject_ASSERT((PyObject *)type, type->tp_vectorcall_offset > 0);
_PyObject_ASSERT((PyObject *)type, type->tp_call != NULL);
}
+ /* Consistency check for Py_TPFLAGS_HAVE_AM_SEND - flag requires
+ * type->tp_as_async->am_send to be present.
+ */
+ if (type->tp_flags & Py_TPFLAGS_HAVE_AM_SEND) {
+ _PyObject_ASSERT((PyObject *)type, type->tp_as_async != NULL);
+ _PyObject_ASSERT((PyObject *)type, type->tp_as_async->am_send != NULL);
+ }
type->tp_flags |= Py_TPFLAGS_READYING;
@@ -5416,8 +5514,13 @@ PyType_Ready(PyTypeObject *type)
/* Initialize tp_base (defaults to BaseObject unless that's us) */
base = type->tp_base;
if (base == NULL && type != &PyBaseObject_Type) {
- base = type->tp_base = &PyBaseObject_Type;
- Py_INCREF(base);
+ base = &PyBaseObject_Type;
+ if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) {
+ type->tp_base = (PyTypeObject*)Py_NewRef((PyObject*)base);
+ }
+ else {
+ type->tp_base = base;
+ }
}
/* Now the only way base can still be NULL is if type is
@@ -7575,17 +7678,10 @@ _PyTypes_InitSlotDefs(void)
for (slotdef *p = slotdefs; p->name; p++) {
/* Slots must be ordered by their offset in the PyHeapTypeObject. */
assert(!p[1].name || p->offset <= p[1].offset);
-#ifdef INTERN_NAME_STRINGS
p->name_strobj = PyUnicode_InternFromString(p->name);
if (!p->name_strobj || !PyUnicode_CHECK_INTERNED(p->name_strobj)) {
return _PyStatus_NO_MEMORY();
}
-#else
- p->name_strobj = PyUnicode_FromString(p->name);
- if (!p->name_strobj) {
- return _PyStatus_NO_MEMORY();
- }
-#endif
}
slotdefs_initialized = 1;
return _PyStatus_OK();
@@ -7610,24 +7706,16 @@ update_slot(PyTypeObject *type, PyObject *name)
int offset;
assert(PyUnicode_CheckExact(name));
-#ifdef INTERN_NAME_STRINGS
assert(PyUnicode_CHECK_INTERNED(name));
-#endif
assert(slotdefs_initialized);
pp = ptrs;
for (p = slotdefs; p->name; p++) {
assert(PyUnicode_CheckExact(p->name_strobj));
assert(PyUnicode_CheckExact(name));
-#ifdef INTERN_NAME_STRINGS
if (p->name_strobj == name) {
*pp++ = p;
}
-#else
- if (p->name_strobj == name || _PyUnicode_EQ(p->name_strobj, name)) {
- *pp++ = p;
- }
-#endif
}
*pp = NULL;
for (pp = ptrs; *pp; pp++) {
diff --git a/Objects/typeslots.inc b/Objects/typeslots.inc
index ffc9bb2e1c..896daa7d80 100644
--- a/Objects/typeslots.inc
+++ b/Objects/typeslots.inc
@@ -1,81 +1,82 @@
/* Generated by typeslots.py */
-offsetof(PyHeapTypeObject, as_buffer.bf_getbuffer),
-offsetof(PyHeapTypeObject, as_buffer.bf_releasebuffer),
-offsetof(PyHeapTypeObject, as_mapping.mp_ass_subscript),
-offsetof(PyHeapTypeObject, as_mapping.mp_length),
-offsetof(PyHeapTypeObject, as_mapping.mp_subscript),
-offsetof(PyHeapTypeObject, as_number.nb_absolute),
-offsetof(PyHeapTypeObject, as_number.nb_add),
-offsetof(PyHeapTypeObject, as_number.nb_and),
-offsetof(PyHeapTypeObject, as_number.nb_bool),
-offsetof(PyHeapTypeObject, as_number.nb_divmod),
-offsetof(PyHeapTypeObject, as_number.nb_float),
-offsetof(PyHeapTypeObject, as_number.nb_floor_divide),
-offsetof(PyHeapTypeObject, as_number.nb_index),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_add),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_and),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_floor_divide),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_lshift),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_multiply),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_or),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_power),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_remainder),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_rshift),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_subtract),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_true_divide),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_xor),
-offsetof(PyHeapTypeObject, as_number.nb_int),
-offsetof(PyHeapTypeObject, as_number.nb_invert),
-offsetof(PyHeapTypeObject, as_number.nb_lshift),
-offsetof(PyHeapTypeObject, as_number.nb_multiply),
-offsetof(PyHeapTypeObject, as_number.nb_negative),
-offsetof(PyHeapTypeObject, as_number.nb_or),
-offsetof(PyHeapTypeObject, as_number.nb_positive),
-offsetof(PyHeapTypeObject, as_number.nb_power),
-offsetof(PyHeapTypeObject, as_number.nb_remainder),
-offsetof(PyHeapTypeObject, as_number.nb_rshift),
-offsetof(PyHeapTypeObject, as_number.nb_subtract),
-offsetof(PyHeapTypeObject, as_number.nb_true_divide),
-offsetof(PyHeapTypeObject, as_number.nb_xor),
-offsetof(PyHeapTypeObject, as_sequence.sq_ass_item),
-offsetof(PyHeapTypeObject, as_sequence.sq_concat),
-offsetof(PyHeapTypeObject, as_sequence.sq_contains),
-offsetof(PyHeapTypeObject, as_sequence.sq_inplace_concat),
-offsetof(PyHeapTypeObject, as_sequence.sq_inplace_repeat),
-offsetof(PyHeapTypeObject, as_sequence.sq_item),
-offsetof(PyHeapTypeObject, as_sequence.sq_length),
-offsetof(PyHeapTypeObject, as_sequence.sq_repeat),
-offsetof(PyHeapTypeObject, ht_type.tp_alloc),
-offsetof(PyHeapTypeObject, ht_type.tp_base),
-offsetof(PyHeapTypeObject, ht_type.tp_bases),
-offsetof(PyHeapTypeObject, ht_type.tp_call),
-offsetof(PyHeapTypeObject, ht_type.tp_clear),
-offsetof(PyHeapTypeObject, ht_type.tp_dealloc),
-offsetof(PyHeapTypeObject, ht_type.tp_del),
-offsetof(PyHeapTypeObject, ht_type.tp_descr_get),
-offsetof(PyHeapTypeObject, ht_type.tp_descr_set),
-offsetof(PyHeapTypeObject, ht_type.tp_doc),
-offsetof(PyHeapTypeObject, ht_type.tp_getattr),
-offsetof(PyHeapTypeObject, ht_type.tp_getattro),
-offsetof(PyHeapTypeObject, ht_type.tp_hash),
-offsetof(PyHeapTypeObject, ht_type.tp_init),
-offsetof(PyHeapTypeObject, ht_type.tp_is_gc),
-offsetof(PyHeapTypeObject, ht_type.tp_iter),
-offsetof(PyHeapTypeObject, ht_type.tp_iternext),
-offsetof(PyHeapTypeObject, ht_type.tp_methods),
-offsetof(PyHeapTypeObject, ht_type.tp_new),
-offsetof(PyHeapTypeObject, ht_type.tp_repr),
-offsetof(PyHeapTypeObject, ht_type.tp_richcompare),
-offsetof(PyHeapTypeObject, ht_type.tp_setattr),
-offsetof(PyHeapTypeObject, ht_type.tp_setattro),
-offsetof(PyHeapTypeObject, ht_type.tp_str),
-offsetof(PyHeapTypeObject, ht_type.tp_traverse),
-offsetof(PyHeapTypeObject, ht_type.tp_members),
-offsetof(PyHeapTypeObject, ht_type.tp_getset),
-offsetof(PyHeapTypeObject, ht_type.tp_free),
-offsetof(PyHeapTypeObject, as_number.nb_matrix_multiply),
-offsetof(PyHeapTypeObject, as_number.nb_inplace_matrix_multiply),
-offsetof(PyHeapTypeObject, as_async.am_await),
-offsetof(PyHeapTypeObject, as_async.am_aiter),
-offsetof(PyHeapTypeObject, as_async.am_anext),
-offsetof(PyHeapTypeObject, ht_type.tp_finalize),
+{offsetof(PyBufferProcs, bf_getbuffer), offsetof(PyTypeObject, tp_as_buffer)},
+{offsetof(PyBufferProcs, bf_releasebuffer), offsetof(PyTypeObject, tp_as_buffer)},
+{offsetof(PyMappingMethods, mp_ass_subscript), offsetof(PyTypeObject, tp_as_mapping)},
+{offsetof(PyMappingMethods, mp_length), offsetof(PyTypeObject, tp_as_mapping)},
+{offsetof(PyMappingMethods, mp_subscript), offsetof(PyTypeObject, tp_as_mapping)},
+{offsetof(PyNumberMethods, nb_absolute), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_add), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_and), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_bool), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_divmod), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_float), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_floor_divide), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_index), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_add), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_and), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_floor_divide), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_lshift), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_multiply), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_or), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_power), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_remainder), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_rshift), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_subtract), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_true_divide), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_xor), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_int), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_invert), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_lshift), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_multiply), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_negative), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_or), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_positive), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_power), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_remainder), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_rshift), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_subtract), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_true_divide), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_xor), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PySequenceMethods, sq_ass_item), offsetof(PyTypeObject, tp_as_sequence)},
+{offsetof(PySequenceMethods, sq_concat), offsetof(PyTypeObject, tp_as_sequence)},
+{offsetof(PySequenceMethods, sq_contains), offsetof(PyTypeObject, tp_as_sequence)},
+{offsetof(PySequenceMethods, sq_inplace_concat), offsetof(PyTypeObject, tp_as_sequence)},
+{offsetof(PySequenceMethods, sq_inplace_repeat), offsetof(PyTypeObject, tp_as_sequence)},
+{offsetof(PySequenceMethods, sq_item), offsetof(PyTypeObject, tp_as_sequence)},
+{offsetof(PySequenceMethods, sq_length), offsetof(PyTypeObject, tp_as_sequence)},
+{offsetof(PySequenceMethods, sq_repeat), offsetof(PyTypeObject, tp_as_sequence)},
+{-1, offsetof(PyTypeObject, tp_alloc)},
+{-1, offsetof(PyTypeObject, tp_base)},
+{-1, offsetof(PyTypeObject, tp_bases)},
+{-1, offsetof(PyTypeObject, tp_call)},
+{-1, offsetof(PyTypeObject, tp_clear)},
+{-1, offsetof(PyTypeObject, tp_dealloc)},
+{-1, offsetof(PyTypeObject, tp_del)},
+{-1, offsetof(PyTypeObject, tp_descr_get)},
+{-1, offsetof(PyTypeObject, tp_descr_set)},
+{-1, offsetof(PyTypeObject, tp_doc)},
+{-1, offsetof(PyTypeObject, tp_getattr)},
+{-1, offsetof(PyTypeObject, tp_getattro)},
+{-1, offsetof(PyTypeObject, tp_hash)},
+{-1, offsetof(PyTypeObject, tp_init)},
+{-1, offsetof(PyTypeObject, tp_is_gc)},
+{-1, offsetof(PyTypeObject, tp_iter)},
+{-1, offsetof(PyTypeObject, tp_iternext)},
+{-1, offsetof(PyTypeObject, tp_methods)},
+{-1, offsetof(PyTypeObject, tp_new)},
+{-1, offsetof(PyTypeObject, tp_repr)},
+{-1, offsetof(PyTypeObject, tp_richcompare)},
+{-1, offsetof(PyTypeObject, tp_setattr)},
+{-1, offsetof(PyTypeObject, tp_setattro)},
+{-1, offsetof(PyTypeObject, tp_str)},
+{-1, offsetof(PyTypeObject, tp_traverse)},
+{-1, offsetof(PyTypeObject, tp_members)},
+{-1, offsetof(PyTypeObject, tp_getset)},
+{-1, offsetof(PyTypeObject, tp_free)},
+{offsetof(PyNumberMethods, nb_matrix_multiply), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyNumberMethods, nb_inplace_matrix_multiply), offsetof(PyTypeObject, tp_as_number)},
+{offsetof(PyAsyncMethods, am_await), offsetof(PyTypeObject, tp_as_async)},
+{offsetof(PyAsyncMethods, am_aiter), offsetof(PyTypeObject, tp_as_async)},
+{offsetof(PyAsyncMethods, am_anext), offsetof(PyTypeObject, tp_as_async)},
+{-1, offsetof(PyTypeObject, tp_finalize)},
+{offsetof(PyAsyncMethods, am_send), offsetof(PyTypeObject, tp_as_async)},
diff --git a/Objects/typeslots.py b/Objects/typeslots.py
index 9b6d4adbc7..8ab05f91be 100755
--- a/Objects/typeslots.py
+++ b/Objects/typeslots.py
@@ -3,6 +3,7 @@
import sys, re
+
def generate_typeslots(out=sys.stdout):
out.write("/* Generated by typeslots.py */\n")
res = {}
@@ -10,27 +11,34 @@ def generate_typeslots(out=sys.stdout):
m = re.match("#define Py_([a-z_]+) ([0-9]+)", line)
if not m:
continue
+
member = m.group(1)
if member.startswith("tp_"):
- member = "ht_type."+member
+ member = f'{{-1, offsetof(PyTypeObject, {member})}}'
elif member.startswith("am_"):
- member = "as_async."+member
+ member = (f'{{offsetof(PyAsyncMethods, {member}),'+
+ ' offsetof(PyTypeObject, tp_as_async)}')
elif member.startswith("nb_"):
- member = "as_number."+member
+ member = (f'{{offsetof(PyNumberMethods, {member}),'+
+ ' offsetof(PyTypeObject, tp_as_number)}')
elif member.startswith("mp_"):
- member = "as_mapping."+member
+ member = (f'{{offsetof(PyMappingMethods, {member}),'+
+ ' offsetof(PyTypeObject, tp_as_mapping)}')
elif member.startswith("sq_"):
- member = "as_sequence."+member
+ member = (f'{{offsetof(PySequenceMethods, {member}),'+
+ ' offsetof(PyTypeObject, tp_as_sequence)}')
elif member.startswith("bf_"):
- member = "as_buffer."+member
+ member = (f'{{offsetof(PyBufferProcs, {member}),'+
+ ' offsetof(PyTypeObject, tp_as_buffer)}')
res[int(m.group(2))] = member
M = max(res.keys())+1
for i in range(1,M):
if i in res:
- out.write("offsetof(PyHeapTypeObject, %s),\n" % res[i])
+ out.write("%s,\n" % res[i])
else:
- out.write("0,\n")
+ out.write("{0, 0},\n")
+
def main():
if len(sys.argv) == 2:
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 9058018201..ad32a062d4 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -41,7 +41,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycore_abstract.h" // _PyIndex_Check()
+#include "pycore_atomic_funcs.h" // _Py_atomic_size_get()
#include "pycore_bytes_methods.h" // _Py_bytes_lower()
+#include "pycore_format.h" // F_LJUST
#include "pycore_initconfig.h" // _PyStatus_OK()
#include "pycore_interp.h" // PyInterpreterState.fs_codec
#include "pycore_object.h" // _PyObject_GC_TRACK()
@@ -204,22 +206,6 @@ extern "C" {
# define OVERALLOCATE_FACTOR 4
#endif
-/* bpo-40521: Interned strings are shared by all interpreters. */
-#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
-# define INTERNED_STRINGS
-#endif
-
-/* This dictionary holds all interned unicode strings. Note that references
- to strings in this dictionary are *not* counted in the string's ob_refcnt.
- When the interned string reaches a refcnt of 0 the string deallocation
- function will delete the reference from this dictionary.
-
- Another way to look at this is that to say that the actual reference
- count of a string is: s->ob_refcnt + (s->state ? 2 : 0)
-*/
-#ifdef INTERNED_STRINGS
-static PyObject *interned = NULL;
-#endif
static struct _Py_unicode_state*
get_unicode_state(void)
@@ -301,9 +287,6 @@ unicode_decode_utf8(const char *s, Py_ssize_t size,
_Py_error_handler error_handler, const char *errors,
Py_ssize_t *consumed);
-/* List of static strings. */
-static _Py_Identifier *static_strings = NULL;
-
/* Fast detection of the most frequent whitespace characters */
const unsigned char _Py_ascii_whitespace[] = {
0, 0, 0, 0, 0, 0, 0, 0,
@@ -839,7 +822,11 @@ xmlcharrefreplace(_PyBytesWriter *writer, char *str,
/* generate replacement */
for (i = collstart; i < collend; ++i) {
- str += sprintf(str, "&#%d;", PyUnicode_READ(kind, data, i));
+ size = sprintf(str, "&#%d;", PyUnicode_READ(kind, data, i));
+ if (size < 0) {
+ return NULL;
+ }
+ str += size;
}
return str;
}
@@ -1057,7 +1044,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
new_size = (struct_size + (length + 1) * char_size);
if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) {
- PyObject_DEL(_PyUnicode_UTF8(unicode));
+ PyObject_Free(_PyUnicode_UTF8(unicode));
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
}
@@ -1068,7 +1055,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
_Py_ForgetReference(unicode);
#endif
- new_unicode = (PyObject *)PyObject_REALLOC(unicode, new_size);
+ new_unicode = (PyObject *)PyObject_Realloc(unicode, new_size);
if (new_unicode == NULL) {
_Py_NewReference(unicode);
PyErr_NoMemory();
@@ -1084,7 +1071,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
_PyUnicode_WSTR_LENGTH(unicode) = length;
}
else if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
- PyObject_DEL(_PyUnicode_WSTR(unicode));
+ PyObject_Free(_PyUnicode_WSTR(unicode));
_PyUnicode_WSTR(unicode) = NULL;
if (!PyUnicode_IS_ASCII(unicode))
_PyUnicode_WSTR_LENGTH(unicode) = 0;
@@ -1127,12 +1114,12 @@ resize_inplace(PyObject *unicode, Py_ssize_t length)
if (!share_utf8 && _PyUnicode_HAS_UTF8_MEMORY(unicode))
{
- PyObject_DEL(_PyUnicode_UTF8(unicode));
+ PyObject_Free(_PyUnicode_UTF8(unicode));
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
}
- data = (PyObject *)PyObject_REALLOC(data, new_size);
+ data = (PyObject *)PyObject_Realloc(data, new_size);
if (data == NULL) {
PyErr_NoMemory();
return -1;
@@ -1165,7 +1152,7 @@ resize_inplace(PyObject *unicode, Py_ssize_t length)
}
new_size = sizeof(wchar_t) * (length + 1);
wstr = _PyUnicode_WSTR(unicode);
- wstr = PyObject_REALLOC(wstr, new_size);
+ wstr = PyObject_Realloc(wstr, new_size);
if (!wstr) {
PyErr_NoMemory();
return -1;
@@ -1255,7 +1242,7 @@ _PyUnicode_New(Py_ssize_t length)
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
- _PyUnicode_WSTR(unicode) = (Py_UNICODE*) PyObject_MALLOC(new_size);
+ _PyUnicode_WSTR(unicode) = (Py_UNICODE*) PyObject_Malloc(new_size);
if (!_PyUnicode_WSTR(unicode)) {
Py_DECREF(unicode);
PyErr_NoMemory();
@@ -1452,7 +1439,7 @@ PyUnicode_New(Py_ssize_t size, Py_UCS4 maxchar)
* PyObject_New() so we are able to allocate space for the object and
* it's data buffer.
*/
- obj = (PyObject *) PyObject_MALLOC(struct_size + (size + 1) * char_size);
+ obj = (PyObject *) PyObject_Malloc(struct_size + (size + 1) * char_size);
if (obj == NULL) {
return PyErr_NoMemory();
}
@@ -1834,7 +1821,7 @@ _PyUnicode_Ready(PyObject *unicode)
return -1;
if (maxchar < 256) {
- _PyUnicode_DATA_ANY(unicode) = PyObject_MALLOC(_PyUnicode_WSTR_LENGTH(unicode) + 1);
+ _PyUnicode_DATA_ANY(unicode) = PyObject_Malloc(_PyUnicode_WSTR_LENGTH(unicode) + 1);
if (!_PyUnicode_DATA_ANY(unicode)) {
PyErr_NoMemory();
return -1;
@@ -1855,7 +1842,7 @@ _PyUnicode_Ready(PyObject *unicode)
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
}
- PyObject_FREE(_PyUnicode_WSTR(unicode));
+ PyObject_Free(_PyUnicode_WSTR(unicode));
_PyUnicode_WSTR(unicode) = NULL;
_PyUnicode_WSTR_LENGTH(unicode) = 0;
}
@@ -1875,7 +1862,7 @@ _PyUnicode_Ready(PyObject *unicode)
_PyUnicode_UTF8_LENGTH(unicode) = 0;
#else
/* sizeof(wchar_t) == 4 */
- _PyUnicode_DATA_ANY(unicode) = PyObject_MALLOC(
+ _PyUnicode_DATA_ANY(unicode) = PyObject_Malloc(
2 * (_PyUnicode_WSTR_LENGTH(unicode) + 1));
if (!_PyUnicode_DATA_ANY(unicode)) {
PyErr_NoMemory();
@@ -1889,12 +1876,12 @@ _PyUnicode_Ready(PyObject *unicode)
_PyUnicode_STATE(unicode).kind = PyUnicode_2BYTE_KIND;
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
- PyObject_FREE(_PyUnicode_WSTR(unicode));
+ PyObject_Free(_PyUnicode_WSTR(unicode));
_PyUnicode_WSTR(unicode) = NULL;
_PyUnicode_WSTR_LENGTH(unicode) = 0;
#endif
}
- /* maxchar exeeds 16 bit, wee need 4 bytes for unicode characters */
+ /* maxchar exceeds 16 bit, wee need 4 bytes for unicode characters */
else {
#if SIZEOF_WCHAR_T == 2
/* in case the native representation is 2-bytes, we need to allocate a
@@ -1904,7 +1891,7 @@ _PyUnicode_Ready(PyObject *unicode)
PyErr_NoMemory();
return -1;
}
- _PyUnicode_DATA_ANY(unicode) = PyObject_MALLOC(4 * (length_wo_surrogates + 1));
+ _PyUnicode_DATA_ANY(unicode) = PyObject_Malloc(4 * (length_wo_surrogates + 1));
if (!_PyUnicode_DATA_ANY(unicode)) {
PyErr_NoMemory();
return -1;
@@ -1916,7 +1903,7 @@ _PyUnicode_Ready(PyObject *unicode)
/* unicode_convert_wchar_to_ucs4() requires a ready string */
_PyUnicode_STATE(unicode).ready = 1;
unicode_convert_wchar_to_ucs4(_PyUnicode_WSTR(unicode), end, unicode);
- PyObject_FREE(_PyUnicode_WSTR(unicode));
+ PyObject_Free(_PyUnicode_WSTR(unicode));
_PyUnicode_WSTR(unicode) = NULL;
_PyUnicode_WSTR_LENGTH(unicode) = 0;
#else
@@ -1943,7 +1930,8 @@ unicode_dealloc(PyObject *unicode)
break;
case SSTATE_INTERNED_MORTAL:
-#ifdef INTERNED_STRINGS
+ {
+ struct _Py_unicode_state *state = get_unicode_state();
/* Revive the dead object temporarily. PyDict_DelItem() removes two
references (key and value) which were ignored by
PyUnicode_InternInPlace(). Use refcnt=3 rather than refcnt=2
@@ -1951,14 +1939,14 @@ unicode_dealloc(PyObject *unicode)
PyDict_DelItem(). */
assert(Py_REFCNT(unicode) == 0);
Py_SET_REFCNT(unicode, 3);
- if (PyDict_DelItem(interned, unicode) != 0) {
+ if (PyDict_DelItem(state->interned, unicode) != 0) {
_PyErr_WriteUnraisableMsg("deletion of interned string failed",
NULL);
}
assert(Py_REFCNT(unicode) == 1);
Py_SET_REFCNT(unicode, 0);
-#endif
break;
+ }
case SSTATE_INTERNED_IMMORTAL:
_PyObject_ASSERT_FAILED_MSG(unicode, "Immortal interned string died");
@@ -1969,13 +1957,13 @@ unicode_dealloc(PyObject *unicode)
}
if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
- PyObject_DEL(_PyUnicode_WSTR(unicode));
+ PyObject_Free(_PyUnicode_WSTR(unicode));
}
if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) {
- PyObject_DEL(_PyUnicode_UTF8(unicode));
+ PyObject_Free(_PyUnicode_UTF8(unicode));
}
if (!PyUnicode_IS_COMPACT(unicode) && _PyUnicode_DATA_ANY(unicode)) {
- PyObject_DEL(_PyUnicode_DATA_ANY(unicode));
+ PyObject_Free(_PyUnicode_DATA_ANY(unicode));
}
Py_TYPE(unicode)->tp_free(unicode);
@@ -2307,42 +2295,84 @@ PyUnicode_FromString(const char *u)
return PyUnicode_DecodeUTF8Stateful(u, (Py_ssize_t)size, NULL, NULL);
}
+
PyObject *
_PyUnicode_FromId(_Py_Identifier *id)
{
- if (id->object) {
- return id->object;
+ PyInterpreterState *interp = _PyInterpreterState_GET();
+ struct _Py_unicode_ids *ids = &interp->unicode.ids;
+
+ int index = _Py_atomic_size_get(&id->index);
+ if (index < 0) {
+ struct _Py_unicode_runtime_ids *rt_ids = &interp->runtime->unicode_ids;
+
+ PyThread_acquire_lock(rt_ids->lock, WAIT_LOCK);
+ // Check again to detect concurrent access. Another thread can have
+ // initialized the index while this thread waited for the lock.
+ index = _Py_atomic_size_get(&id->index);
+ if (index < 0) {
+ assert(rt_ids->next_index < PY_SSIZE_T_MAX);
+ index = rt_ids->next_index;
+ rt_ids->next_index++;
+ _Py_atomic_size_set(&id->index, index);
+ }
+ PyThread_release_lock(rt_ids->lock);
}
+ assert(index >= 0);
PyObject *obj;
- obj = PyUnicode_DecodeUTF8Stateful(id->string,
- strlen(id->string),
+ if (index < ids->size) {
+ obj = ids->array[index];
+ if (obj) {
+ // Return a borrowed reference
+ return obj;
+ }
+ }
+
+ obj = PyUnicode_DecodeUTF8Stateful(id->string, strlen(id->string),
NULL, NULL);
if (!obj) {
return NULL;
}
PyUnicode_InternInPlace(&obj);
- assert(!id->next);
- id->object = obj;
- id->next = static_strings;
- static_strings = id;
- return id->object;
+ if (index >= ids->size) {
+ // Overallocate to reduce the number of realloc
+ Py_ssize_t new_size = Py_MAX(index * 2, 16);
+ Py_ssize_t item_size = sizeof(ids->array[0]);
+ PyObject **new_array = PyMem_Realloc(ids->array, new_size * item_size);
+ if (new_array == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ memset(&new_array[ids->size], 0, (new_size - ids->size) * item_size);
+ ids->array = new_array;
+ ids->size = new_size;
+ }
+
+ // The array stores a strong reference
+ ids->array[index] = obj;
+
+ // Return a borrowed reference
+ return obj;
}
+
static void
-unicode_clear_static_strings(void)
+unicode_clear_identifiers(struct _Py_unicode_state *state)
{
- _Py_Identifier *tmp, *s = static_strings;
- while (s) {
- Py_CLEAR(s->object);
- tmp = s->next;
- s->next = NULL;
- s = tmp;
+ struct _Py_unicode_ids *ids = &state->ids;
+ for (Py_ssize_t i=0; i < ids->size; i++) {
+ Py_XDECREF(ids->array[i]);
}
- static_strings = NULL;
+ ids->size = 0;
+ PyMem_Free(ids->array);
+ ids->array = NULL;
+ // Don't reset _PyRuntime next_index: _Py_Identifier.id remains valid
+ // after Py_Finalize().
}
+
/* Internal function, doesn't check maximum character */
PyObject*
@@ -3294,7 +3324,7 @@ PyUnicode_AsWideCharString(PyObject *unicode,
*size = buflen;
}
else if (wcslen(buffer) != (size_t)buflen) {
- PyMem_FREE(buffer);
+ PyMem_Free(buffer);
PyErr_SetString(PyExc_ValueError,
"embedded null character");
return NULL;
@@ -4195,7 +4225,7 @@ PyUnicode_AsUnicodeAndSize(PyObject *unicode, Py_ssize_t *size)
PyErr_NoMemory();
return NULL;
}
- w = (wchar_t *) PyObject_MALLOC(sizeof(wchar_t) * (wlen + 1));
+ w = (wchar_t *) PyObject_Malloc(sizeof(wchar_t) * (wlen + 1));
if (w == NULL) {
PyErr_NoMemory();
return NULL;
@@ -5623,7 +5653,7 @@ unicode_fill_utf8(PyObject *unicode)
PyBytes_AS_STRING(writer.buffer);
Py_ssize_t len = end - start;
- char *cache = PyObject_MALLOC(len + 1);
+ char *cache = PyObject_Malloc(len + 1);
if (cache == NULL) {
_PyBytesWriter_Dealloc(&writer);
PyErr_NoMemory();
@@ -8540,7 +8570,7 @@ PyUnicode_BuildEncodingMap(PyObject* string)
}
/* Create a three-level trie */
- result = PyObject_MALLOC(sizeof(struct encoding_map) +
+ result = PyObject_Malloc(sizeof(struct encoding_map) +
16*count2 + 128*count3 - 1);
if (!result) {
return PyErr_NoMemory();
@@ -10207,7 +10237,7 @@ case_operation(PyObject *self,
PyErr_SetString(PyExc_OverflowError, "string is too long");
return NULL;
}
- tmp = PyMem_MALLOC(sizeof(Py_UCS4) * 3 * length);
+ tmp = PyMem_Malloc(sizeof(Py_UCS4) * 3 * length);
if (tmp == NULL)
return PyErr_NoMemory();
newlength = perform(kind, data, length, tmp, &maxchar);
@@ -10231,7 +10261,7 @@ case_operation(PyObject *self,
Py_UNREACHABLE();
}
leave:
- PyMem_FREE(tmp);
+ PyMem_Free(tmp);
return res;
}
@@ -11046,11 +11076,11 @@ replace(PyObject *self, PyObject *str1,
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
if (srelease)
- PyMem_FREE((void *)sbuf);
+ PyMem_Free((void *)sbuf);
if (release1)
- PyMem_FREE((void *)buf1);
+ PyMem_Free((void *)buf1);
if (release2)
- PyMem_FREE((void *)buf2);
+ PyMem_Free((void *)buf2);
assert(_PyUnicode_CheckConsistency(u, 1));
return u;
@@ -11060,11 +11090,11 @@ replace(PyObject *self, PyObject *str1,
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
if (srelease)
- PyMem_FREE((void *)sbuf);
+ PyMem_Free((void *)sbuf);
if (release1)
- PyMem_FREE((void *)buf1);
+ PyMem_Free((void *)buf1);
if (release2)
- PyMem_FREE((void *)buf2);
+ PyMem_Free((void *)buf2);
return unicode_result_unchanged(self);
error:
@@ -11072,11 +11102,11 @@ replace(PyObject *self, PyObject *str1,
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
if (srelease)
- PyMem_FREE((void *)sbuf);
+ PyMem_Free((void *)sbuf);
if (release1)
- PyMem_FREE((void *)buf1);
+ PyMem_Free((void *)buf1);
if (release2)
- PyMem_FREE((void *)buf2);
+ PyMem_Free((void *)buf2);
return NULL;
}
@@ -11490,12 +11520,11 @@ _PyUnicode_EqualToASCIIId(PyObject *left, _Py_Identifier *right)
if (PyUnicode_CHECK_INTERNED(left))
return 0;
-#ifdef INTERNED_STRINGS
assert(_PyUnicode_HASH(right_uni) != -1);
Py_hash_t hash = _PyUnicode_HASH(left);
- if (hash != -1 && hash != _PyUnicode_HASH(right_uni))
+ if (hash != -1 && hash != _PyUnicode_HASH(right_uni)) {
return 0;
-#endif
+ }
return unicode_compare_eq(left, right_uni);
}
@@ -15563,7 +15592,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject *unicode)
PyErr_NoMemory();
goto onError;
}
- data = PyObject_MALLOC((length + 1) * char_size);
+ data = PyObject_Malloc((length + 1) * char_size);
if (data == NULL) {
PyErr_NoMemory();
goto onError;
@@ -15719,23 +15748,21 @@ PyUnicode_InternInPlace(PyObject **p)
return;
}
-#ifdef INTERNED_STRINGS
if (PyUnicode_READY(s) == -1) {
PyErr_Clear();
return;
}
- if (interned == NULL) {
- interned = PyDict_New();
- if (interned == NULL) {
+ struct _Py_unicode_state *state = get_unicode_state();
+ if (state->interned == NULL) {
+ state->interned = PyDict_New();
+ if (state->interned == NULL) {
PyErr_Clear(); /* Don't leave an exception */
return;
}
}
- PyObject *t;
- t = PyDict_SetDefault(interned, s, s);
-
+ PyObject *t = PyDict_SetDefault(state->interned, s, s);
if (t == NULL) {
PyErr_Clear();
return;
@@ -15752,13 +15779,9 @@ PyUnicode_InternInPlace(PyObject **p)
this. */
Py_SET_REFCNT(s, Py_REFCNT(s) - 2);
_PyUnicode_STATE(s).interned = SSTATE_INTERNED_MORTAL;
-#else
- // PyDict expects that interned strings have their hash
- // (PyASCIIObject.hash) already computed.
- (void)unicode_hash(s);
-#endif
}
+
void
PyUnicode_InternImmortal(PyObject **p)
{
@@ -15792,35 +15815,25 @@ PyUnicode_InternFromString(const char *cp)
void
_PyUnicode_ClearInterned(PyThreadState *tstate)
{
- if (!_Py_IsMainInterpreter(tstate)) {
- // interned dict is shared by all interpreters
- return;
- }
-
- if (interned == NULL) {
- return;
- }
- assert(PyDict_CheckExact(interned));
-
- PyObject *keys = PyDict_Keys(interned);
- if (keys == NULL) {
- PyErr_Clear();
+ struct _Py_unicode_state *state = &tstate->interp->unicode;
+ if (state->interned == NULL) {
return;
}
- assert(PyList_CheckExact(keys));
+ assert(PyDict_CheckExact(state->interned));
/* Interned unicode strings are not forcibly deallocated; rather, we give
them their stolen references back, and then clear and DECREF the
interned dict. */
- Py_ssize_t n = PyList_GET_SIZE(keys);
#ifdef INTERNED_STATS
- fprintf(stderr, "releasing %zd interned strings\n", n);
+ fprintf(stderr, "releasing %zd interned strings\n",
+ PyDict_GET_SIZE(state->interned));
Py_ssize_t immortal_size = 0, mortal_size = 0;
#endif
- for (Py_ssize_t i = 0; i < n; i++) {
- PyObject *s = PyList_GET_ITEM(keys, i);
+ Py_ssize_t pos = 0;
+ PyObject *s, *ignored_value;
+ while (PyDict_Next(state->interned, &pos, &s, &ignored_value)) {
assert(PyUnicode_IS_READY(s));
switch (PyUnicode_CHECK_INTERNED(s)) {
@@ -15850,10 +15863,9 @@ _PyUnicode_ClearInterned(PyThreadState *tstate)
"total size of all interned strings: %zd/%zd mortal/immortal\n",
mortal_size, immortal_size);
#endif
- Py_DECREF(keys);
- PyDict_Clear(interned);
- Py_CLEAR(interned);
+ PyDict_Clear(state->interned);
+ Py_CLEAR(state->interned);
}
@@ -16223,21 +16235,19 @@ _PyUnicode_EnableLegacyWindowsFSEncoding(void)
void
_PyUnicode_Fini(PyThreadState *tstate)
{
+ struct _Py_unicode_state *state = &tstate->interp->unicode;
+
// _PyUnicode_ClearInterned() must be called before
+ assert(state->interned == NULL);
- struct _Py_unicode_state *state = &tstate->interp->unicode;
+ _PyUnicode_FiniEncodings(&state->fs_codec);
- Py_CLEAR(state->empty_string);
+ unicode_clear_identifiers(state);
for (Py_ssize_t i = 0; i < 256; i++) {
Py_CLEAR(state->latin1[i]);
}
-
- if (_Py_IsMainInterpreter(tstate)) {
- unicode_clear_static_strings();
- }
-
- _PyUnicode_FiniEncodings(&tstate->interp->unicode.fs_codec);
+ Py_CLEAR(state->empty_string);
}
diff --git a/Objects/unionobject.c b/Objects/unionobject.c
index 1b7f8ab51a..32aa5078af 100644
--- a/Objects/unionobject.c
+++ b/Objects/unionobject.c
@@ -237,9 +237,19 @@ dedup_and_flatten_args(PyObject* args)
PyObject* i_element = PyTuple_GET_ITEM(args, i);
for (Py_ssize_t j = i + 1; j < arg_length; j++) {
PyObject* j_element = PyTuple_GET_ITEM(args, j);
- if (i_element == j_element) {
- is_duplicate = 1;
+ int is_ga = PyObject_TypeCheck(i_element, &Py_GenericAliasType) &&
+ PyObject_TypeCheck(j_element, &Py_GenericAliasType);
+ // RichCompare to also deduplicate GenericAlias types (slower)
+ is_duplicate = is_ga ? PyObject_RichCompareBool(i_element, j_element, Py_EQ)
+ : i_element == j_element;
+ // Should only happen if RichCompare fails
+ if (is_duplicate < 0) {
+ Py_DECREF(args);
+ Py_DECREF(new_args);
+ return NULL;
}
+ if (is_duplicate)
+ break;
}
if (!is_duplicate) {
Py_INCREF(i_element);
@@ -286,12 +296,12 @@ is_unionable(PyObject *obj)
is_new_type(obj) ||
is_special_form(obj) ||
PyType_Check(obj) ||
- type == &Py_GenericAliasType ||
+ PyObject_TypeCheck(obj, &Py_GenericAliasType) ||
type == &_Py_UnionType);
}
-static PyObject *
-type_or(PyTypeObject* self, PyObject* param)
+PyObject *
+_Py_union_type_or(PyObject* self, PyObject* param)
{
PyObject *tuple = PyTuple_Pack(2, self, param);
if (tuple == NULL) {
@@ -404,7 +414,7 @@ static PyMethodDef union_methods[] = {
{0}};
static PyNumberMethods union_as_number = {
- .nb_or = (binaryfunc)type_or, // Add __or__ function
+ .nb_or = _Py_union_type_or, // Add __or__ function
};
PyTypeObject _Py_UnionType = {
diff --git a/PC/_msi.c b/PC/_msi.c
index 504899d075..01516e85cc 100644
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -351,7 +351,7 @@ msiobj_dealloc(msiobj* msidb)
{
MsiCloseHandle(msidb->h);
msidb->h = 0;
- PyObject_Del(msidb);
+ PyObject_Free(msidb);
}
static PyObject*
diff --git a/PC/launcher.c b/PC/launcher.c
index 106fc66075..cc2d35b2c4 100644
--- a/PC/launcher.c
+++ b/PC/launcher.c
@@ -425,11 +425,21 @@ compare_pythons(const void * p1, const void * p2)
INSTALLED_PYTHON * ip1 = (INSTALLED_PYTHON *) p1;
INSTALLED_PYTHON * ip2 = (INSTALLED_PYTHON *) p2;
/* note reverse sorting on version */
- int result = wcscmp(ip2->version, ip1->version);
-
- if (result == 0)
- result = ip2->bits - ip1->bits; /* 64 before 32 */
- return result;
+ int result = CompareStringW(LOCALE_INVARIANT, SORT_DIGITSASNUMBERS,
+ ip2->version, -1, ip1->version, -1);
+ switch (result) {
+ case 0:
+ error(0, L"CompareStringW failed");
+ return 0;
+ case CSTR_LESS_THAN:
+ return -1;
+ case CSTR_EQUAL:
+ return ip2->bits - ip1->bits; /* 64 before 32 */
+ case CSTR_GREATER_THAN:
+ return 1;
+ default:
+ return 0; // This should never be reached.
+ }
}
static void
@@ -1248,6 +1258,7 @@ static PYC_MAGIC magic_values[] = {
{ 3390, 3399, L"3.7" },
{ 3400, 3419, L"3.8" },
{ 3420, 3429, L"3.9" },
+ { 3430, 3439, L"3.10" },
{ 0 }
};
diff --git a/PC/layout/main.py b/PC/layout/main.py
index 3eef755629..8c69c91542 100644
--- a/PC/layout/main.py
+++ b/PC/layout/main.py
@@ -36,7 +36,7 @@ from .support.nuspec import *
BDIST_WININST_FILES_ONLY = FileNameSet("wininst-*", "bdist_wininst.py")
BDIST_WININST_STUB = "PC/layout/support/distutils.command.bdist_wininst.py"
-TEST_PYDS_ONLY = FileStemSet("xxlimited", "_ctypes_test", "_test*")
+TEST_PYDS_ONLY = FileStemSet("xxlimited", "xxlimited_35", "_ctypes_test", "_test*")
TEST_DIRS_ONLY = FileNameSet("test", "tests")
IDLE_DIRS_ONLY = FileNameSet("idlelib")
diff --git a/PC/pyconfig.h b/PC/pyconfig.h
index b29f63c35b..592b487adc 100644
--- a/PC/pyconfig.h
+++ b/PC/pyconfig.h
@@ -193,7 +193,6 @@ typedef int pid_t;
#define Py_IS_NAN _isnan
#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
#define Py_IS_FINITE(X) _finite(X)
-#define copysign _copysign
/* define some ANSI types that are not defined in earlier Win headers */
#if _MSC_VER >= 1200
diff --git a/PC/python3dll.c b/PC/python3dll.c
index 7e4a510177..fa44a46fb7 100644
--- a/PC/python3dll.c
+++ b/PC/python3dll.c
@@ -40,8 +40,8 @@ EXPORT_FUNC(Py_AddPendingCall)
EXPORT_FUNC(Py_AtExit)
EXPORT_FUNC(Py_BuildValue)
EXPORT_FUNC(Py_CompileString)
-EXPORT_FUNC(Py_DecodeLocale)
EXPORT_FUNC(Py_DecRef)
+EXPORT_FUNC(Py_DecodeLocale)
EXPORT_FUNC(Py_EncodeLocale)
EXPORT_FUNC(Py_EndInterpreter)
EXPORT_FUNC(Py_EnterRecursiveCall)
@@ -49,6 +49,7 @@ EXPORT_FUNC(Py_Exit)
EXPORT_FUNC(Py_FatalError)
EXPORT_FUNC(Py_Finalize)
EXPORT_FUNC(Py_FinalizeEx)
+EXPORT_FUNC(Py_FrozenMain)
EXPORT_FUNC(Py_GenericAlias)
EXPORT_FUNC(Py_GenericAliasType)
EXPORT_FUNC(Py_GetArgcArgv)
@@ -72,6 +73,7 @@ EXPORT_FUNC(Py_LeaveRecursiveCall)
EXPORT_FUNC(Py_Main)
EXPORT_FUNC(Py_MakePendingCalls)
EXPORT_FUNC(Py_NewInterpreter)
+EXPORT_FUNC(Py_NewRef)
EXPORT_FUNC(Py_ReprEnter)
EXPORT_FUNC(Py_ReprLeave)
EXPORT_FUNC(Py_SetPath)
@@ -80,6 +82,7 @@ EXPORT_FUNC(Py_SetPythonHome)
EXPORT_FUNC(Py_SetRecursionLimit)
EXPORT_FUNC(Py_SymtableString)
EXPORT_FUNC(Py_VaBuildValue)
+EXPORT_FUNC(Py_XNewRef)
EXPORT_FUNC(PyArg_Parse)
EXPORT_FUNC(PyArg_ParseTuple)
EXPORT_FUNC(PyArg_ParseTupleAndKeywords)
@@ -254,6 +257,8 @@ EXPORT_FUNC(PyFloat_FromString)
EXPORT_FUNC(PyFloat_GetInfo)
EXPORT_FUNC(PyFloat_GetMax)
EXPORT_FUNC(PyFloat_GetMin)
+EXPORT_FUNC(PyFrame_GetLineNumber)
+EXPORT_FUNC(PyFrame_GetCode)
EXPORT_FUNC(PyFrozenSet_New)
EXPORT_FUNC(PyGC_Collect)
EXPORT_FUNC(PyGILState_Ensure)
@@ -342,6 +347,7 @@ EXPORT_FUNC(PyModule_AddFunctions)
EXPORT_FUNC(PyModule_AddIntConstant)
EXPORT_FUNC(PyModule_AddObject)
EXPORT_FUNC(PyModule_AddStringConstant)
+EXPORT_FUNC(PyModule_AddType)
EXPORT_FUNC(PyModule_Create2)
EXPORT_FUNC(PyModule_ExecDef)
EXPORT_FUNC(PyModule_FromDefAndSpec2)
@@ -401,6 +407,7 @@ EXPORT_FUNC(PyObject_CallFunction)
EXPORT_FUNC(PyObject_CallFunctionObjArgs)
EXPORT_FUNC(PyObject_CallMethod)
EXPORT_FUNC(PyObject_CallMethodObjArgs)
+EXPORT_FUNC(PyObject_CallNoArgs)
EXPORT_FUNC(PyObject_CallObject)
EXPORT_FUNC(PyObject_Calloc)
EXPORT_FUNC(PyObject_ClearWeakRefs)
@@ -531,6 +538,9 @@ EXPORT_FUNC(PyThreadState_Delete)
EXPORT_FUNC(PyThreadState_DeleteCurrent)
EXPORT_FUNC(PyThreadState_Get)
EXPORT_FUNC(PyThreadState_GetDict)
+EXPORT_FUNC(PyThreadState_GetFrame)
+EXPORT_FUNC(PyThreadState_GetID)
+EXPORT_FUNC(PyThreadState_GetInterpreter)
EXPORT_FUNC(PyThreadState_New)
EXPORT_FUNC(PyThreadState_SetAsyncExc)
EXPORT_FUNC(PyThreadState_Swap)
@@ -545,9 +555,12 @@ EXPORT_FUNC(PyTuple_Size)
EXPORT_FUNC(PyType_ClearCache)
EXPORT_FUNC(PyType_FromSpec)
EXPORT_FUNC(PyType_FromSpecWithBases)
+EXPORT_FUNC(PyType_FromModuleAndSpec)
EXPORT_FUNC(PyType_GenericAlloc)
EXPORT_FUNC(PyType_GenericNew)
EXPORT_FUNC(PyType_GetFlags)
+EXPORT_FUNC(PyType_GetModule)
+EXPORT_FUNC(PyType_GetModuleState)
EXPORT_FUNC(PyType_GetSlot)
EXPORT_FUNC(PyType_IsSubtype)
EXPORT_FUNC(PyType_Modified)
@@ -784,6 +797,7 @@ EXPORT_DATA(PyMemoryView_Type)
EXPORT_DATA(PyMethodDescr_Type)
EXPORT_DATA(PyModule_Type)
EXPORT_DATA(PyModuleDef_Type)
+EXPORT_DATA(PyModule_AddObjectRef)
EXPORT_DATA(PyNullImporter_Type)
EXPORT_DATA(PyODict_Type)
EXPORT_DATA(PyODictItems_Type)
diff --git a/PC/winreg.c b/PC/winreg.c
index 78c08693a8..d62a7be28d 100644
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -145,7 +145,7 @@ PyHKEY_deallocFunc(PyObject *ob)
PyHKEYObject *obkey = (PyHKEYObject *)ob;
if (obkey->hkey)
RegCloseKey((HKEY)obkey->hkey);
- PyObject_DEL(ob);
+ PyObject_Free(ob);
}
static int
@@ -459,7 +459,7 @@ PyObject *
PyHKEY_FromHKEY(HKEY h)
{
/* Inline PyObject_New */
- PyHKEYObject *op = (PyHKEYObject *) PyObject_MALLOC(sizeof(PyHKEYObject));
+ PyHKEYObject *op = (PyHKEYObject *) PyObject_Malloc(sizeof(PyHKEYObject));
if (op == NULL) {
return PyErr_NoMemory();
}
@@ -1818,7 +1818,7 @@ winreg_SetValueEx_impl(PyObject *module, HKEY key,
Py_BEGIN_ALLOW_THREADS
rc = RegSetValueExW(key, value_name, 0, type, data, len);
Py_END_ALLOW_THREADS
- PyMem_DEL(data);
+ PyMem_Free(data);
if (rc != ERROR_SUCCESS)
return PyErr_SetFromWindowsErrWithFunction(rc,
"RegSetValueEx");
diff --git a/PCbuild/build.bat b/PCbuild/build.bat
index ba7154d8cb..5a41ca57b1 100644
--- a/PCbuild/build.bat
+++ b/PCbuild/build.bat
@@ -46,7 +46,7 @@ echo.Available arguments:
echo. -c Release ^| Debug ^| PGInstrument ^| PGUpdate
echo. Set the configuration (default: Release)
echo. -p x64 ^| Win32 ^| ARM ^| ARM64
-echo. Set the platform (default: Win32)
+echo. Set the platform (default: x64)
echo. -t Build ^| Rebuild ^| Clean ^| CleanAll
echo. Set the target manually
echo. --pgo-job The job to use for PGO training; implies --pgo
@@ -55,7 +55,7 @@ exit /b 127
:Run
setlocal
-set platf=Win32
+set platf=x64
set conf=Release
set target=Build
set dir=%~dp0
diff --git a/PCbuild/env.bat b/PCbuild/env.bat
index 9d4c9d1c32..2820e30458 100644
--- a/PCbuild/env.bat
+++ b/PCbuild/env.bat
@@ -9,8 +9,19 @@ rem 'v110', 'v120' or 'v140') to the build script.
echo Build environments: x86, amd64, x86_amd64
echo.
-set VSTOOLS=%VS140COMNTOOLS%
-if "%VSTOOLS%"=="" set VSTOOLS=%VS120COMNTOOLS%
-if "%VSTOOLS%"=="" set VSTOOLS=%VS110COMNTOOLS%
-if "%VSTOOLS%"=="" set VSTOOLS=%VS100COMNTOOLS%
-call "%VSTOOLS%..\..\VC\vcvarsall.bat" %*
+set _ARGS=%*
+if NOT DEFINED _ARGS set _ARGS=amd64
+
+if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" goto :skip_vswhere
+set VSTOOLS=
+for /F "tokens=*" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -property installationPath -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64') DO @(set VSTOOLS=%%i\VC\Auxiliary\Build\vcvarsall.bat)
+if not defined VSTOOLS goto :skip_vswhere
+call "%VSTOOLS%" %_ARGS%
+exit /B 0
+
+:skip_vswhere
+if not defined VSTOOLS set VSTOOLS=%VS140COMNTOOLS%
+if not defined VSTOOLS set VSTOOLS=%VS120COMNTOOLS%
+if not defined VSTOOLS set VSTOOLS=%VS110COMNTOOLS%
+if not defined VSTOOLS set VSTOOLS=%VS100COMNTOOLS%
+call "%VSTOOLS%..\..\VC\vcvarsall.bat" %_ARGS%
diff --git a/PCbuild/env.ps1 b/PCbuild/env.ps1
new file mode 100644
index 0000000000..19d7ada4c1
--- /dev/null
+++ b/PCbuild/env.ps1
@@ -0,0 +1,2 @@
+$pcbuild = $script:MyInvocation.MyCommand.Path | Split-Path -parent;
+& cmd /K "$pcbuild\env.bat" $args
diff --git a/PCbuild/idle.bat b/PCbuild/idle.bat
index 1978b99f6e..70f3817f09 100644
--- a/PCbuild/idle.bat
+++ b/PCbuild/idle.bat
@@ -4,12 +4,24 @@ rem Usage: idle [-d]
rem -d Run Debug build (python_d.exe). Else release build.
setlocal
-set exe=win32\python
+set PCBUILD=%~dp0
+set exedir=%PCBUILD%\amd64
+set exe=python
PATH %PATH%;..\externals\tcltk\bin
-if "%1"=="-d" (set exe=%exe%_d) & shift
+:CheckOpts
+if "%1"=="-d" (set exe=%exe%_d) & shift & goto :CheckOpts
+if "%1"=="-p" (call :SetExeDir %2) & shift & shift & goto :CheckOpts
-set cmd=%exe% ../Lib/idlelib/idle.py %1 %2 %3 %4 %5 %6 %7 %8 %9
+set cmd=%exedir%\%exe% %PCBUILD%\..\Lib\idlelib\idle.py %1 %2 %3 %4 %5 %6 %7 %8 %9
echo on
%cmd%
+exit /B %LASTERRORCODE%
+
+:SetExeDir
+if /I %1 EQU Win32 (set exedir=%PCBUILD%\win32)
+if /I %1 EQU x64 (set exedir=%PCBUILD%\amd64)
+if /I %1 EQU ARM (set exedir=%PCBUILD%\arm32)
+if /I %1 EQU ARM64 (set exedir=%PCBUILD%\arm64)
+exit /B 0
diff --git a/PCbuild/lib.pyproj b/PCbuild/lib.pyproj
index a15165d92e..1be60b1a11 100644
--- a/PCbuild/lib.pyproj
+++ b/PCbuild/lib.pyproj
@@ -1196,6 +1196,7 @@
<Compile Include="test\test_nntplib.py" />
<Compile Include="test\test_ntpath.py" />
<Compile Include="test\test_numeric_tower.py" />
+ <Compile Include="test\test_opcache.py" />
<Compile Include="test\test_opcodes.py" />
<Compile Include="test\test_openpty.py" />
<Compile Include="test\test_operator.py" />
diff --git a/PCbuild/pcbuild.proj b/PCbuild/pcbuild.proj
index 4d416c589e..8e7088d47d 100644
--- a/PCbuild/pcbuild.proj
+++ b/PCbuild/pcbuild.proj
@@ -66,6 +66,7 @@
<!-- Test modules -->
<TestModules Include="_ctypes_test;_testbuffer;_testcapi;_testinternalcapi;_testembed;_testimportmultiple;_testmultiphase;_testconsole" />
<TestModules Include="xxlimited" Condition="'$(Configuration)' == 'Release'" />
+ <TestModules Include="xxlimited_35" Condition="'$(Configuration)' == 'Release'" />
<Projects Include="@(TestModules->'%(Identity).vcxproj')" Condition="$(IncludeTests)">
<!-- Disable parallel build for test modules -->
<BuildInParallel>false</BuildInParallel>
diff --git a/PCbuild/prepare_libffi.bat b/PCbuild/prepare_libffi.bat
index f41ba83379..922a47565c 100644
--- a/PCbuild/prepare_libffi.bat
+++ b/PCbuild/prepare_libffi.bat
@@ -22,10 +22,10 @@ echo Based on https://github.com/libffi/libffi/blob/master/.appveyor.yml
echo.
echo.
echo.Available flags:
-echo. -x64 build for x64
-echo. -x86 build for x86
-echo. -arm32 build for arm32
-echo. -arm64 build for arm64
+echo. -x64 enable x64 build
+echo. -x86 enable x86 build
+echo. -arm32 enable arm32 build
+echo. -arm64 enable arm64 build
echo. -? this help
echo. --install-cygwin install cygwin to c:\cygwin
exit /b 127
@@ -44,6 +44,7 @@ set INSTALL_CYGWIN=
if "%1"=="" goto :CheckOptsDone
if /I "%1"=="-x64" (set BUILD_X64=1) & shift & goto :CheckOpts
if /I "%1"=="-x86" (set BUILD_X86=1) & shift & goto :CheckOpts
+if /I "%1"=="-win32" (set BUILD_X86=1) & shift & goto :CheckOpts
if /I "%1"=="-arm32" (set BUILD_ARM32=1) & shift & goto :CheckOpts
if /I "%1"=="-arm64" (set BUILD_ARM64=1) & shift & goto :CheckOpts
if /I "%1"=="-pdb" (set BUILD_PDB=-g) & shift & goto :CheckOpts
@@ -67,9 +68,7 @@ setlocal
if NOT DEFINED SH if exist c:\cygwin\bin\sh.exe set SH=c:\cygwin\bin\sh.exe
if NOT DEFINED VCVARSALL (
- if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" (
- set VCVARSALL="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
- )
+ for /F "tokens=*" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -property installationPath -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64') DO @(set VCVARSALL="%%i\VC\Auxiliary\Build\vcvarsall.bat")
)
if ^%VCVARSALL:~0,1% NEQ ^" SET VCVARSALL="%VCVARSALL%"
diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props
index c659d14ff8..d7762ca1bc 100644
--- a/PCbuild/pyproject.props
+++ b/PCbuild/pyproject.props
@@ -176,8 +176,8 @@ public override bool Execute() {
<SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86</SdkBinPath>
<SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86</SdkBinPath>
<SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)\Bin\</SdkBinPath>
- <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificate)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /a /n "$(SigningCertificate)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)"</_SignCommand>
- <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificateSha1)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /a /sha1 "$(SigningCertificateSha1)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)"</_SignCommand>
+ <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificate)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /a /n "$(SigningCertificate)" /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d "Python $(PythonVersion)"</_SignCommand>
+ <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificateSha1)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /a /sha1 "$(SigningCertificateSha1)" /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d "Python $(PythonVersion)"</_SignCommand>
<_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe"</_MakeCatCommand>
</PropertyGroup>
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 18edba855d..fd27dea9da 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -146,6 +146,7 @@
<ClInclude Include="..\Include\cpython\pylifecycle.h" />
<ClInclude Include="..\Include\cpython\pymem.h" />
<ClInclude Include="..\Include\cpython\pystate.h" />
+ <ClInclude Include="..\Include\cpython\pythonrun.h" />
<ClInclude Include="..\Include\cpython\sysmodule.h" />
<ClInclude Include="..\Include\cpython\traceback.h" />
<ClInclude Include="..\Include\cpython\tupleobject.h" />
@@ -167,6 +168,7 @@
<ClInclude Include="..\Include\internal\pycore_abstract.h" />
<ClInclude Include="..\Include\internal\pycore_accu.h" />
<ClInclude Include="..\Include\internal\pycore_atomic.h" />
+ <ClInclude Include="..\Include\internal\pycore_atomic_funcs.h" />
<ClInclude Include="..\Include\internal\pycore_bitutils.h" />
<ClInclude Include="..\Include\internal\pycore_bytes_methods.h" />
<ClInclude Include="..\Include\internal\pycore_call.h" />
@@ -176,6 +178,7 @@
<ClInclude Include="..\Include\internal\pycore_context.h" />
<ClInclude Include="..\Include\internal\pycore_dtoa.h" />
<ClInclude Include="..\Include\internal\pycore_fileutils.h" />
+ <ClInclude Include="..\Include\internal\pycore_format.h" />
<ClInclude Include="..\Include\internal\pycore_gc.h" />
<ClInclude Include="..\Include\internal\pycore_getopt.h" />
<ClInclude Include="..\Include\internal\pycore_gil.h" />
diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters
index 281bce1c5f..75a653dcbd 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -459,6 +459,9 @@
<ClInclude Include="..\Include\cpython\interpreteridobject.h">
<Filter>Include\cpython</Filter>
</ClInclude>
+ <ClInclude Include="..\Include\cpython\pythonrun.h">
+ <Filter>Include\cpython</Filter>
+ </ClInclude>
<ClInclude Include="..\Include\cpython\sysmodule.h">
<Filter>Include\cpython</Filter>
</ClInclude>
@@ -483,6 +486,9 @@
<ClInclude Include="..\Include\internal\pycore_atomic.h">
<Filter>Include\internal</Filter>
</ClInclude>
+ <ClInclude Include="..\Include\internal\pycore_atomic_funcs.h">
+ <Filter>Include</Filter>
+ </ClInclude>
<ClInclude Include="..\Include\internal\pycore_bitutils.h">
<Filter>Include\internal</Filter>
</ClInclude>
@@ -510,6 +516,9 @@
<ClInclude Include="..\Include\internal\pycore_fileutils.h">
<Filter>Include\internal</Filter>
</ClInclude>
+ <ClInclude Include="..\Include\internal\pycore_format.h">
+ <Filter>Include\internal</Filter>
+ </ClInclude>
<ClInclude Include="..\Include\internal\pycore_gc.h">
<Filter>Include\internal</Filter>
</ClInclude>
diff --git a/PCbuild/readme.txt b/PCbuild/readme.txt
index 73833d5463..4335c9f71d 100644
--- a/PCbuild/readme.txt
+++ b/PCbuild/readme.txt
@@ -125,6 +125,9 @@ python3dll
xxlimited
builds an example module that makes use of the PEP 384 Stable ABI,
see Modules\xxlimited.c
+xxlimited_35
+ ditto for testing the Python 3.5 stable ABI, see
+ Modules\xxlimited_35.c
The following sub-projects are for individual modules of the standard
library which are implemented in C; each one builds a DLL (renamed to
diff --git a/PCbuild/rt.bat b/PCbuild/rt.bat
index 59f757c0f5..29813c5a87 100644
--- a/PCbuild/rt.bat
+++ b/PCbuild/rt.bat
@@ -6,8 +6,9 @@ rem -O Run python.exe or python_d.exe (see -d) with -O.
rem -q "quick" -- normally the tests are run twice, the first time
rem after deleting all the .pyc files reachable from Lib/.
rem -q runs the tests just once, and without deleting .pyc files.
-rem -x64 Run the 64-bit build of python (or python_d if -d was specified)
-rem When omitted, uses %PREFIX% if set or the 32-bit build
+rem -p <Win32|x64|ARM|ARM64> or -win32, -x64, -arm32, -arm64
+rem Run the specified architecture of python (or python_d if -d
+rem was specified). If omitted, uses %PREFIX% if set or 64-bit.
rem All leading instances of these switches are shifted off, and
rem whatever remains (up to 9 arguments) is passed to regrtest.py.
rem For example,
@@ -38,12 +39,14 @@ set exe=
if "%1"=="-O" (set dashO=-O) & shift & goto CheckOpts
if "%1"=="-q" (set qmode=yes) & shift & goto CheckOpts
if "%1"=="-d" (set suffix=_d) & shift & goto CheckOpts
+if "%1"=="-win32" (set prefix=%pcbuild%win32) & shift & goto CheckOpts
if "%1"=="-x64" (set prefix=%pcbuild%amd64) & shift & goto CheckOpts
if "%1"=="-arm64" (set prefix=%pcbuild%arm64) & shift & goto CheckOpts
if "%1"=="-arm32" (set prefix=%pcbuild%arm32) & shift & goto CheckOpts
+if "%1"=="-p" (call :SetPlatform %~2) & shift & shift & goto CheckOpts
if NOT "%1"=="" (set regrtestargs=%regrtestargs% %1) & shift & goto CheckOpts
-if not defined prefix set prefix=%pcbuild%win32
+if not defined prefix set prefix=%pcbuild%amd64
set exe=%prefix%\python%suffix%.exe
set cmd="%exe%" %dashO% -u -Wd -E -bb -m test %regrtestargs%
if defined qmode goto Qmode
@@ -60,6 +63,15 @@ echo on
echo About to run again without deleting .pyc first:
pause
+goto Qmode
+
+:SetPlatform
+if /I %1 EQU Win32 (set prefix=%pcbuild%win32) & exit /B 0
+if /I %1 EQU x64 (set prefix=%pcbuild%amd64) & exit /B 0
+if /I %1 EQU ARM64 (set prefix=%pcbuild%arm64) & exit /B 0
+if /I %1 EQU ARM (set prefix=%pcbuild%arm32) & exit /B 0
+echo Invalid platform "%1"
+exit /B 1
:Qmode
echo on
diff --git a/PCbuild/xxlimited.vcxproj b/PCbuild/xxlimited.vcxproj
index 776335a15c..ece169127a 100644
--- a/PCbuild/xxlimited.vcxproj
+++ b/PCbuild/xxlimited.vcxproj
@@ -94,7 +94,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <PreprocessorDefinitions>%(PreprocessorDefinitions);Py_LIMITED_API=0x03060000</PreprocessorDefinitions>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);Py_LIMITED_API=0x03100000</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>wsock32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -111,4 +111,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/PCbuild/xxlimited_35.vcxproj b/PCbuild/xxlimited_35.vcxproj
new file mode 100644
index 0000000000..7e49eadf90
--- /dev/null
+++ b/PCbuild/xxlimited_35.vcxproj
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="PGInstrument|ARM">
+ <Configuration>PGInstrument</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="PGInstrument|ARM64">
+ <Configuration>PGInstrument</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="PGInstrument|Win32">
+ <Configuration>PGInstrument</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="PGInstrument|x64">
+ <Configuration>PGInstrument</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="PGUpdate|ARM">
+ <Configuration>PGUpdate</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="PGUpdate|ARM64">
+ <Configuration>PGUpdate</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="PGUpdate|Win32">
+ <Configuration>PGUpdate</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="PGUpdate|x64">
+ <Configuration>PGUpdate</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{fb868ea7-f93a-4d9b-be78-ca4e9ba14fff}</ProjectGuid>
+ <RootNamespace>xxlimited_35</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="python.props" />
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ <SupportPGO>false</SupportPGO>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <PropertyGroup>
+ <TargetExt>.pyd</TargetExt>
+ </PropertyGroup>
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="pyproject.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);Py_LIMITED_API=0x03060000</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>wsock32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\Modules\xxlimited_35.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="python3dll.vcxproj">
+ <Project>{885d4898-d08d-4091-9c40-c700cfe3fc5a}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
diff --git a/PCbuild/xxlimited_35.vcxproj.filters b/PCbuild/xxlimited_35.vcxproj.filters
new file mode 100644
index 0000000000..35bfb05c23
--- /dev/null
+++ b/PCbuild/xxlimited_35.vcxproj.filters
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{5be27194-6530-452d-8d86-3767b991fa83}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\Modules\xxlimited_35.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project>
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 9a833e841d..34bd7010cf 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -1015,18 +1015,35 @@ static int add_ast_fields(struct ast_state *state)
""", 0, reflow=False)
- self.emit("static int init_types(struct ast_state *state)",0)
- self.emit("{", 0)
- self.emit("if (state->initialized) return 1;", 1)
- self.emit("if (init_identifiers(state) < 0) return 0;", 1)
- self.emit("state->AST_type = PyType_FromSpec(&AST_type_spec);", 1)
- self.emit("if (!state->AST_type) return 0;", 1)
- self.emit("if (add_ast_fields(state) < 0) return 0;", 1)
+ self.file.write(textwrap.dedent('''
+ static int
+ init_types(struct ast_state *state)
+ {
+ // init_types() must not be called after _PyAST_Fini()
+ // has been called
+ assert(state->initialized >= 0);
+
+ if (state->initialized) {
+ return 1;
+ }
+ if (init_identifiers(state) < 0) {
+ return 0;
+ }
+ state->AST_type = PyType_FromSpec(&AST_type_spec);
+ if (!state->AST_type) {
+ return 0;
+ }
+ if (add_ast_fields(state) < 0) {
+ return 0;
+ }
+ '''))
for dfn in mod.dfns:
self.visit(dfn)
- self.emit("state->initialized = 1;", 1)
- self.emit("return 1;", 1);
- self.emit("}", 0)
+ self.file.write(textwrap.dedent('''
+ state->initialized = 1;
+ return 1;
+ }
+ '''))
def visitProduct(self, prod, name):
if prod.fields:
@@ -1098,10 +1115,9 @@ class ASTModuleVisitor(PickleVisitor):
self.emit('if (state == NULL) {', 1)
self.emit('return -1;', 2)
self.emit('}', 1)
- self.emit('if (PyModule_AddObject(m, "AST", state->AST_type) < 0) {', 1)
+ self.emit('if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {', 1)
self.emit('return -1;', 2)
self.emit('}', 1)
- self.emit('Py_INCREF(state->AST_type);', 1)
self.emit('if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {', 1)
self.emit("return -1;", 2)
self.emit('}', 1)
@@ -1149,11 +1165,10 @@ PyInit__ast(void)
self.addObj(cons.name)
def addObj(self, name):
- self.emit("if (PyModule_AddObject(m, \"%s\", "
+ self.emit("if (PyModule_AddObjectRef(m, \"%s\", "
"state->%s_type) < 0) {" % (name, name), 1)
self.emit("return -1;", 2)
self.emit('}', 1)
- self.emit("Py_INCREF(state->%s_type);" % name, 1)
class StaticVisitor(PickleVisitor):
@@ -1353,23 +1368,27 @@ def generate_ast_state(module_state, f):
def generate_ast_fini(module_state, f):
- f.write("""
-void _PyAST_Fini(PyThreadState *tstate)
-{
-#ifdef Py_BUILD_CORE
- struct ast_state *state = &tstate->interp->ast;
-#else
- struct ast_state *state = &global_ast_state;
-#endif
-
-""")
+ f.write(textwrap.dedent("""
+ void _PyAST_Fini(PyInterpreterState *interp)
+ {
+ #ifdef Py_BUILD_CORE
+ struct ast_state *state = &interp->ast;
+ #else
+ struct ast_state *state = &global_ast_state;
+ #endif
+
+ """))
for s in module_state:
f.write(" Py_CLEAR(state->" + s + ');\n')
- f.write("""
- state->initialized = 0;
-}
+ f.write(textwrap.dedent("""
+ #if defined(Py_BUILD_CORE) && !defined(NDEBUG)
+ state->initialized = -1;
+ #else
+ state->initialized = 0;
+ #endif
+ }
-""")
+ """))
def generate_module_def(mod, f, internal_h):
diff --git a/Parser/parser.c b/Parser/parser.c
index 48ebfe65ae..2559969f86 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -75,8 +75,8 @@ static KeywordToken *reserved_keywords[] = {
#define statements_type 1006
#define statement_type 1007
#define statement_newline_type 1008
-#define simple_stmt_type 1009
-#define small_stmt_type 1010
+#define simple_stmts_type 1009
+#define simple_stmt_type 1010
#define compound_stmt_type 1011
#define assignment_type 1012
#define augassign_type 1013
@@ -125,265 +125,262 @@ static KeywordToken *reserved_keywords[] = {
#define class_def_type 1056
#define class_def_raw_type 1057
#define block_type 1058
-#define expressions_list_type 1059
-#define star_expressions_type 1060
-#define star_expression_type 1061
-#define star_named_expressions_type 1062
-#define star_named_expression_type 1063
-#define named_expression_type 1064
-#define annotated_rhs_type 1065
-#define expressions_type 1066
-#define expression_type 1067
-#define lambdef_type 1068
-#define lambda_params_type 1069
-#define lambda_parameters_type 1070
-#define lambda_slash_no_default_type 1071
-#define lambda_slash_with_default_type 1072
-#define lambda_star_etc_type 1073
-#define lambda_kwds_type 1074
-#define lambda_param_no_default_type 1075
-#define lambda_param_with_default_type 1076
-#define lambda_param_maybe_default_type 1077
-#define lambda_param_type 1078
-#define disjunction_type 1079
-#define conjunction_type 1080
-#define inversion_type 1081
-#define comparison_type 1082
-#define compare_op_bitwise_or_pair_type 1083
-#define eq_bitwise_or_type 1084
-#define noteq_bitwise_or_type 1085
-#define lte_bitwise_or_type 1086
-#define lt_bitwise_or_type 1087
-#define gte_bitwise_or_type 1088
-#define gt_bitwise_or_type 1089
-#define notin_bitwise_or_type 1090
-#define in_bitwise_or_type 1091
-#define isnot_bitwise_or_type 1092
-#define is_bitwise_or_type 1093
-#define bitwise_or_type 1094 // Left-recursive
-#define bitwise_xor_type 1095 // Left-recursive
-#define bitwise_and_type 1096 // Left-recursive
-#define shift_expr_type 1097 // Left-recursive
-#define sum_type 1098 // Left-recursive
-#define term_type 1099 // Left-recursive
-#define factor_type 1100
-#define power_type 1101
-#define await_primary_type 1102
-#define primary_type 1103 // Left-recursive
-#define slices_type 1104
-#define slice_type 1105
-#define atom_type 1106
-#define strings_type 1107
-#define list_type 1108
-#define listcomp_type 1109
-#define tuple_type 1110
-#define group_type 1111
-#define genexp_type 1112
-#define set_type 1113
-#define setcomp_type 1114
-#define dict_type 1115
-#define dictcomp_type 1116
-#define double_starred_kvpairs_type 1117
-#define double_starred_kvpair_type 1118
-#define kvpair_type 1119
-#define for_if_clauses_type 1120
-#define for_if_clause_type 1121
-#define yield_expr_type 1122
-#define arguments_type 1123
-#define args_type 1124
-#define kwargs_type 1125
-#define starred_expression_type 1126
-#define kwarg_or_starred_type 1127
-#define kwarg_or_double_starred_type 1128
-#define star_targets_type 1129
-#define star_targets_seq_type 1130
-#define star_target_type 1131
-#define star_atom_type 1132
-#define single_target_type 1133
-#define single_subscript_attribute_target_type 1134
-#define del_targets_type 1135
-#define del_target_type 1136
-#define del_t_atom_type 1137
-#define targets_type 1138
-#define target_type 1139
-#define t_primary_type 1140 // Left-recursive
-#define t_lookahead_type 1141
-#define t_atom_type 1142
-#define invalid_arguments_type 1143
-#define invalid_kwarg_type 1144
-#define invalid_named_expression_type 1145
-#define invalid_assignment_type 1146
-#define invalid_ann_assign_target_type 1147
-#define invalid_del_stmt_type 1148
-#define invalid_block_type 1149
-#define invalid_primary_type 1150 // Left-recursive
-#define invalid_comprehension_type 1151
-#define invalid_dict_comprehension_type 1152
-#define invalid_parameters_type 1153
-#define invalid_lambda_parameters_type 1154
-#define invalid_star_etc_type 1155
-#define invalid_lambda_star_etc_type 1156
-#define invalid_double_type_comments_type 1157
-#define invalid_with_item_type 1158
-#define invalid_for_target_type 1159
-#define invalid_group_type 1160
-#define invalid_import_from_targets_type 1161
-#define _loop0_1_type 1162
-#define _loop0_2_type 1163
-#define _loop0_4_type 1164
-#define _gather_3_type 1165
-#define _loop0_6_type 1166
-#define _gather_5_type 1167
-#define _loop0_8_type 1168
-#define _gather_7_type 1169
-#define _loop0_10_type 1170
-#define _gather_9_type 1171
-#define _loop1_11_type 1172
-#define _loop0_13_type 1173
-#define _gather_12_type 1174
-#define _tmp_14_type 1175
-#define _tmp_15_type 1176
-#define _tmp_16_type 1177
-#define _tmp_17_type 1178
-#define _tmp_18_type 1179
-#define _tmp_19_type 1180
-#define _tmp_20_type 1181
-#define _tmp_21_type 1182
-#define _loop1_22_type 1183
-#define _tmp_23_type 1184
-#define _tmp_24_type 1185
-#define _loop0_26_type 1186
-#define _gather_25_type 1187
-#define _loop0_28_type 1188
-#define _gather_27_type 1189
-#define _tmp_29_type 1190
-#define _tmp_30_type 1191
-#define _loop0_31_type 1192
-#define _loop1_32_type 1193
-#define _loop0_34_type 1194
-#define _gather_33_type 1195
-#define _tmp_35_type 1196
-#define _loop0_37_type 1197
-#define _gather_36_type 1198
-#define _tmp_38_type 1199
-#define _loop0_40_type 1200
-#define _gather_39_type 1201
-#define _loop0_42_type 1202
-#define _gather_41_type 1203
-#define _loop0_44_type 1204
-#define _gather_43_type 1205
-#define _loop0_46_type 1206
-#define _gather_45_type 1207
-#define _tmp_47_type 1208
-#define _loop1_48_type 1209
-#define _tmp_49_type 1210
-#define _tmp_50_type 1211
-#define _tmp_51_type 1212
-#define _tmp_52_type 1213
-#define _tmp_53_type 1214
-#define _loop0_54_type 1215
-#define _loop0_55_type 1216
-#define _loop0_56_type 1217
-#define _loop1_57_type 1218
-#define _loop0_58_type 1219
-#define _loop1_59_type 1220
-#define _loop1_60_type 1221
-#define _loop1_61_type 1222
-#define _loop0_62_type 1223
-#define _loop1_63_type 1224
-#define _loop0_64_type 1225
-#define _loop1_65_type 1226
-#define _loop0_66_type 1227
-#define _loop1_67_type 1228
-#define _loop1_68_type 1229
-#define _tmp_69_type 1230
-#define _loop0_71_type 1231
-#define _gather_70_type 1232
-#define _loop1_72_type 1233
+#define star_expressions_type 1059
+#define star_expression_type 1060
+#define star_named_expressions_type 1061
+#define star_named_expression_type 1062
+#define named_expression_type 1063
+#define annotated_rhs_type 1064
+#define expressions_type 1065
+#define expression_type 1066
+#define lambdef_type 1067
+#define lambda_params_type 1068
+#define lambda_parameters_type 1069
+#define lambda_slash_no_default_type 1070
+#define lambda_slash_with_default_type 1071
+#define lambda_star_etc_type 1072
+#define lambda_kwds_type 1073
+#define lambda_param_no_default_type 1074
+#define lambda_param_with_default_type 1075
+#define lambda_param_maybe_default_type 1076
+#define lambda_param_type 1077
+#define disjunction_type 1078
+#define conjunction_type 1079
+#define inversion_type 1080
+#define comparison_type 1081
+#define compare_op_bitwise_or_pair_type 1082
+#define eq_bitwise_or_type 1083
+#define noteq_bitwise_or_type 1084
+#define lte_bitwise_or_type 1085
+#define lt_bitwise_or_type 1086
+#define gte_bitwise_or_type 1087
+#define gt_bitwise_or_type 1088
+#define notin_bitwise_or_type 1089
+#define in_bitwise_or_type 1090
+#define isnot_bitwise_or_type 1091
+#define is_bitwise_or_type 1092
+#define bitwise_or_type 1093 // Left-recursive
+#define bitwise_xor_type 1094 // Left-recursive
+#define bitwise_and_type 1095 // Left-recursive
+#define shift_expr_type 1096 // Left-recursive
+#define sum_type 1097 // Left-recursive
+#define term_type 1098 // Left-recursive
+#define factor_type 1099
+#define power_type 1100
+#define await_primary_type 1101
+#define primary_type 1102 // Left-recursive
+#define slices_type 1103
+#define slice_type 1104
+#define atom_type 1105
+#define strings_type 1106
+#define list_type 1107
+#define listcomp_type 1108
+#define tuple_type 1109
+#define group_type 1110
+#define genexp_type 1111
+#define set_type 1112
+#define setcomp_type 1113
+#define dict_type 1114
+#define dictcomp_type 1115
+#define double_starred_kvpairs_type 1116
+#define double_starred_kvpair_type 1117
+#define kvpair_type 1118
+#define for_if_clauses_type 1119
+#define for_if_clause_type 1120
+#define yield_expr_type 1121
+#define arguments_type 1122
+#define args_type 1123
+#define kwargs_type 1124
+#define starred_expression_type 1125
+#define kwarg_or_starred_type 1126
+#define kwarg_or_double_starred_type 1127
+#define star_targets_type 1128
+#define star_targets_seq_type 1129
+#define star_target_type 1130
+#define star_atom_type 1131
+#define single_target_type 1132
+#define single_subscript_attribute_target_type 1133
+#define del_targets_type 1134
+#define del_target_type 1135
+#define del_t_atom_type 1136
+#define targets_type 1137
+#define target_type 1138
+#define t_primary_type 1139 // Left-recursive
+#define t_lookahead_type 1140
+#define t_atom_type 1141
+#define invalid_arguments_type 1142
+#define invalid_kwarg_type 1143
+#define invalid_named_expression_type 1144
+#define invalid_assignment_type 1145
+#define invalid_ann_assign_target_type 1146
+#define invalid_del_stmt_type 1147
+#define invalid_block_type 1148
+#define invalid_primary_type 1149 // Left-recursive
+#define invalid_comprehension_type 1150
+#define invalid_dict_comprehension_type 1151
+#define invalid_parameters_type 1152
+#define invalid_lambda_parameters_type 1153
+#define invalid_star_etc_type 1154
+#define invalid_lambda_star_etc_type 1155
+#define invalid_double_type_comments_type 1156
+#define invalid_with_item_type 1157
+#define invalid_for_target_type 1158
+#define invalid_group_type 1159
+#define invalid_import_from_targets_type 1160
+#define _loop0_1_type 1161
+#define _loop0_2_type 1162
+#define _loop0_4_type 1163
+#define _gather_3_type 1164
+#define _loop0_6_type 1165
+#define _gather_5_type 1166
+#define _loop0_8_type 1167
+#define _gather_7_type 1168
+#define _loop0_10_type 1169
+#define _gather_9_type 1170
+#define _loop1_11_type 1171
+#define _loop0_13_type 1172
+#define _gather_12_type 1173
+#define _tmp_14_type 1174
+#define _tmp_15_type 1175
+#define _tmp_16_type 1176
+#define _tmp_17_type 1177
+#define _tmp_18_type 1178
+#define _tmp_19_type 1179
+#define _tmp_20_type 1180
+#define _tmp_21_type 1181
+#define _loop1_22_type 1182
+#define _tmp_23_type 1183
+#define _tmp_24_type 1184
+#define _loop0_26_type 1185
+#define _gather_25_type 1186
+#define _loop0_28_type 1187
+#define _gather_27_type 1188
+#define _tmp_29_type 1189
+#define _tmp_30_type 1190
+#define _loop0_31_type 1191
+#define _loop1_32_type 1192
+#define _loop0_34_type 1193
+#define _gather_33_type 1194
+#define _tmp_35_type 1195
+#define _loop0_37_type 1196
+#define _gather_36_type 1197
+#define _tmp_38_type 1198
+#define _loop0_40_type 1199
+#define _gather_39_type 1200
+#define _loop0_42_type 1201
+#define _gather_41_type 1202
+#define _loop0_44_type 1203
+#define _gather_43_type 1204
+#define _loop0_46_type 1205
+#define _gather_45_type 1206
+#define _tmp_47_type 1207
+#define _loop1_48_type 1208
+#define _tmp_49_type 1209
+#define _tmp_50_type 1210
+#define _tmp_51_type 1211
+#define _tmp_52_type 1212
+#define _tmp_53_type 1213
+#define _loop0_54_type 1214
+#define _loop0_55_type 1215
+#define _loop0_56_type 1216
+#define _loop1_57_type 1217
+#define _loop0_58_type 1218
+#define _loop1_59_type 1219
+#define _loop1_60_type 1220
+#define _loop1_61_type 1221
+#define _loop0_62_type 1222
+#define _loop1_63_type 1223
+#define _loop0_64_type 1224
+#define _loop1_65_type 1225
+#define _loop0_66_type 1226
+#define _loop1_67_type 1227
+#define _loop1_68_type 1228
+#define _tmp_69_type 1229
+#define _loop1_70_type 1230
+#define _loop0_72_type 1231
+#define _gather_71_type 1232
+#define _loop1_73_type 1233
#define _loop0_74_type 1234
-#define _gather_73_type 1235
-#define _loop1_75_type 1236
-#define _loop0_76_type 1237
-#define _loop0_77_type 1238
-#define _loop0_78_type 1239
-#define _loop1_79_type 1240
-#define _loop0_80_type 1241
-#define _loop1_81_type 1242
-#define _loop1_82_type 1243
-#define _loop1_83_type 1244
-#define _loop0_84_type 1245
-#define _loop1_85_type 1246
-#define _loop0_86_type 1247
-#define _loop1_87_type 1248
-#define _loop0_88_type 1249
-#define _loop1_89_type 1250
-#define _loop1_90_type 1251
-#define _loop1_91_type 1252
-#define _loop1_92_type 1253
-#define _tmp_93_type 1254
-#define _loop0_95_type 1255
-#define _gather_94_type 1256
-#define _tmp_96_type 1257
-#define _tmp_97_type 1258
-#define _tmp_98_type 1259
-#define _tmp_99_type 1260
-#define _loop1_100_type 1261
-#define _tmp_101_type 1262
-#define _tmp_102_type 1263
+#define _loop0_75_type 1235
+#define _loop0_76_type 1236
+#define _loop1_77_type 1237
+#define _loop0_78_type 1238
+#define _loop1_79_type 1239
+#define _loop1_80_type 1240
+#define _loop1_81_type 1241
+#define _loop0_82_type 1242
+#define _loop1_83_type 1243
+#define _loop0_84_type 1244
+#define _loop1_85_type 1245
+#define _loop0_86_type 1246
+#define _loop1_87_type 1247
+#define _loop1_88_type 1248
+#define _loop1_89_type 1249
+#define _loop1_90_type 1250
+#define _tmp_91_type 1251
+#define _loop0_93_type 1252
+#define _gather_92_type 1253
+#define _tmp_94_type 1254
+#define _tmp_95_type 1255
+#define _tmp_96_type 1256
+#define _tmp_97_type 1257
+#define _loop1_98_type 1258
+#define _tmp_99_type 1259
+#define _tmp_100_type 1260
+#define _loop0_102_type 1261
+#define _gather_101_type 1262
+#define _loop1_103_type 1263
#define _loop0_104_type 1264
-#define _gather_103_type 1265
-#define _loop1_105_type 1266
-#define _loop0_106_type 1267
-#define _loop0_107_type 1268
-#define _loop0_109_type 1269
-#define _gather_108_type 1270
-#define _tmp_110_type 1271
-#define _loop0_112_type 1272
-#define _gather_111_type 1273
-#define _loop0_114_type 1274
-#define _gather_113_type 1275
-#define _loop0_116_type 1276
-#define _gather_115_type 1277
-#define _loop0_118_type 1278
-#define _gather_117_type 1279
-#define _loop0_119_type 1280
-#define _loop0_121_type 1281
-#define _gather_120_type 1282
-#define _tmp_122_type 1283
-#define _loop0_124_type 1284
-#define _gather_123_type 1285
+#define _loop0_105_type 1265
+#define _loop0_107_type 1266
+#define _gather_106_type 1267
+#define _tmp_108_type 1268
+#define _loop0_110_type 1269
+#define _gather_109_type 1270
+#define _loop0_112_type 1271
+#define _gather_111_type 1272
+#define _loop0_114_type 1273
+#define _gather_113_type 1274
+#define _loop0_116_type 1275
+#define _gather_115_type 1276
+#define _loop0_117_type 1277
+#define _loop0_119_type 1278
+#define _gather_118_type 1279
+#define _tmp_120_type 1280
+#define _loop0_122_type 1281
+#define _gather_121_type 1282
+#define _loop0_124_type 1283
+#define _gather_123_type 1284
+#define _tmp_125_type 1285
#define _loop0_126_type 1286
-#define _gather_125_type 1287
-#define _tmp_127_type 1288
-#define _loop0_128_type 1289
-#define _loop0_129_type 1290
-#define _loop0_130_type 1291
-#define _tmp_131_type 1292
-#define _tmp_132_type 1293
-#define _loop0_133_type 1294
-#define _tmp_134_type 1295
-#define _loop0_135_type 1296
-#define _tmp_136_type 1297
-#define _tmp_137_type 1298
-#define _tmp_138_type 1299
-#define _tmp_139_type 1300
-#define _tmp_140_type 1301
-#define _tmp_141_type 1302
-#define _tmp_142_type 1303
-#define _tmp_143_type 1304
-#define _tmp_144_type 1305
-#define _tmp_145_type 1306
-#define _tmp_146_type 1307
-#define _tmp_147_type 1308
-#define _tmp_148_type 1309
-#define _tmp_149_type 1310
-#define _tmp_150_type 1311
-#define _tmp_151_type 1312
-#define _tmp_152_type 1313
-#define _loop1_153_type 1314
-#define _loop1_154_type 1315
-#define _tmp_155_type 1316
-#define _tmp_156_type 1317
+#define _loop0_127_type 1287
+#define _loop0_128_type 1288
+#define _tmp_129_type 1289
+#define _tmp_130_type 1290
+#define _loop0_131_type 1291
+#define _tmp_132_type 1292
+#define _loop0_133_type 1293
+#define _tmp_134_type 1294
+#define _tmp_135_type 1295
+#define _tmp_136_type 1296
+#define _tmp_137_type 1297
+#define _tmp_138_type 1298
+#define _tmp_139_type 1299
+#define _tmp_140_type 1300
+#define _tmp_141_type 1301
+#define _tmp_142_type 1302
+#define _tmp_143_type 1303
+#define _tmp_144_type 1304
+#define _tmp_145_type 1305
+#define _tmp_146_type 1306
+#define _tmp_147_type 1307
+#define _tmp_148_type 1308
+#define _tmp_149_type 1309
+#define _tmp_150_type 1310
+#define _loop1_151_type 1311
+#define _loop1_152_type 1312
+#define _tmp_153_type 1313
+#define _tmp_154_type 1314
static mod_ty file_rule(Parser *p);
static mod_ty interactive_rule(Parser *p);
@@ -394,8 +391,8 @@ static asdl_expr_seq* type_expressions_rule(Parser *p);
static asdl_stmt_seq* statements_rule(Parser *p);
static asdl_stmt_seq* statement_rule(Parser *p);
static asdl_stmt_seq* statement_newline_rule(Parser *p);
-static asdl_stmt_seq* simple_stmt_rule(Parser *p);
-static stmt_ty small_stmt_rule(Parser *p);
+static asdl_stmt_seq* simple_stmts_rule(Parser *p);
+static stmt_ty simple_stmt_rule(Parser *p);
static stmt_ty compound_stmt_rule(Parser *p);
static stmt_ty assignment_rule(Parser *p);
static AugOperator* augassign_rule(Parser *p);
@@ -444,7 +441,6 @@ static asdl_expr_seq* decorators_rule(Parser *p);
static stmt_ty class_def_rule(Parser *p);
static stmt_ty class_def_raw_rule(Parser *p);
static asdl_stmt_seq* block_rule(Parser *p);
-static asdl_expr_seq* expressions_list_rule(Parser *p);
static expr_ty star_expressions_rule(Parser *p);
static expr_ty star_expression_rule(Parser *p);
static asdl_expr_seq* star_named_expressions_rule(Parser *p);
@@ -616,72 +612,72 @@ static asdl_seq *_loop0_66_rule(Parser *p);
static asdl_seq *_loop1_67_rule(Parser *p);
static asdl_seq *_loop1_68_rule(Parser *p);
static void *_tmp_69_rule(Parser *p);
-static asdl_seq *_loop0_71_rule(Parser *p);
-static asdl_seq *_gather_70_rule(Parser *p);
-static asdl_seq *_loop1_72_rule(Parser *p);
+static asdl_seq *_loop1_70_rule(Parser *p);
+static asdl_seq *_loop0_72_rule(Parser *p);
+static asdl_seq *_gather_71_rule(Parser *p);
+static asdl_seq *_loop1_73_rule(Parser *p);
static asdl_seq *_loop0_74_rule(Parser *p);
-static asdl_seq *_gather_73_rule(Parser *p);
-static asdl_seq *_loop1_75_rule(Parser *p);
+static asdl_seq *_loop0_75_rule(Parser *p);
static asdl_seq *_loop0_76_rule(Parser *p);
-static asdl_seq *_loop0_77_rule(Parser *p);
+static asdl_seq *_loop1_77_rule(Parser *p);
static asdl_seq *_loop0_78_rule(Parser *p);
static asdl_seq *_loop1_79_rule(Parser *p);
-static asdl_seq *_loop0_80_rule(Parser *p);
+static asdl_seq *_loop1_80_rule(Parser *p);
static asdl_seq *_loop1_81_rule(Parser *p);
-static asdl_seq *_loop1_82_rule(Parser *p);
+static asdl_seq *_loop0_82_rule(Parser *p);
static asdl_seq *_loop1_83_rule(Parser *p);
static asdl_seq *_loop0_84_rule(Parser *p);
static asdl_seq *_loop1_85_rule(Parser *p);
static asdl_seq *_loop0_86_rule(Parser *p);
static asdl_seq *_loop1_87_rule(Parser *p);
-static asdl_seq *_loop0_88_rule(Parser *p);
+static asdl_seq *_loop1_88_rule(Parser *p);
static asdl_seq *_loop1_89_rule(Parser *p);
static asdl_seq *_loop1_90_rule(Parser *p);
-static asdl_seq *_loop1_91_rule(Parser *p);
-static asdl_seq *_loop1_92_rule(Parser *p);
-static void *_tmp_93_rule(Parser *p);
-static asdl_seq *_loop0_95_rule(Parser *p);
-static asdl_seq *_gather_94_rule(Parser *p);
+static void *_tmp_91_rule(Parser *p);
+static asdl_seq *_loop0_93_rule(Parser *p);
+static asdl_seq *_gather_92_rule(Parser *p);
+static void *_tmp_94_rule(Parser *p);
+static void *_tmp_95_rule(Parser *p);
static void *_tmp_96_rule(Parser *p);
static void *_tmp_97_rule(Parser *p);
-static void *_tmp_98_rule(Parser *p);
+static asdl_seq *_loop1_98_rule(Parser *p);
static void *_tmp_99_rule(Parser *p);
-static asdl_seq *_loop1_100_rule(Parser *p);
-static void *_tmp_101_rule(Parser *p);
-static void *_tmp_102_rule(Parser *p);
+static void *_tmp_100_rule(Parser *p);
+static asdl_seq *_loop0_102_rule(Parser *p);
+static asdl_seq *_gather_101_rule(Parser *p);
+static asdl_seq *_loop1_103_rule(Parser *p);
static asdl_seq *_loop0_104_rule(Parser *p);
-static asdl_seq *_gather_103_rule(Parser *p);
-static asdl_seq *_loop1_105_rule(Parser *p);
-static asdl_seq *_loop0_106_rule(Parser *p);
+static asdl_seq *_loop0_105_rule(Parser *p);
static asdl_seq *_loop0_107_rule(Parser *p);
-static asdl_seq *_loop0_109_rule(Parser *p);
-static asdl_seq *_gather_108_rule(Parser *p);
-static void *_tmp_110_rule(Parser *p);
+static asdl_seq *_gather_106_rule(Parser *p);
+static void *_tmp_108_rule(Parser *p);
+static asdl_seq *_loop0_110_rule(Parser *p);
+static asdl_seq *_gather_109_rule(Parser *p);
static asdl_seq *_loop0_112_rule(Parser *p);
static asdl_seq *_gather_111_rule(Parser *p);
static asdl_seq *_loop0_114_rule(Parser *p);
static asdl_seq *_gather_113_rule(Parser *p);
static asdl_seq *_loop0_116_rule(Parser *p);
static asdl_seq *_gather_115_rule(Parser *p);
-static asdl_seq *_loop0_118_rule(Parser *p);
-static asdl_seq *_gather_117_rule(Parser *p);
+static asdl_seq *_loop0_117_rule(Parser *p);
static asdl_seq *_loop0_119_rule(Parser *p);
-static asdl_seq *_loop0_121_rule(Parser *p);
-static asdl_seq *_gather_120_rule(Parser *p);
-static void *_tmp_122_rule(Parser *p);
+static asdl_seq *_gather_118_rule(Parser *p);
+static void *_tmp_120_rule(Parser *p);
+static asdl_seq *_loop0_122_rule(Parser *p);
+static asdl_seq *_gather_121_rule(Parser *p);
static asdl_seq *_loop0_124_rule(Parser *p);
static asdl_seq *_gather_123_rule(Parser *p);
+static void *_tmp_125_rule(Parser *p);
static asdl_seq *_loop0_126_rule(Parser *p);
-static asdl_seq *_gather_125_rule(Parser *p);
-static void *_tmp_127_rule(Parser *p);
+static asdl_seq *_loop0_127_rule(Parser *p);
static asdl_seq *_loop0_128_rule(Parser *p);
-static asdl_seq *_loop0_129_rule(Parser *p);
-static asdl_seq *_loop0_130_rule(Parser *p);
-static void *_tmp_131_rule(Parser *p);
+static void *_tmp_129_rule(Parser *p);
+static void *_tmp_130_rule(Parser *p);
+static asdl_seq *_loop0_131_rule(Parser *p);
static void *_tmp_132_rule(Parser *p);
static asdl_seq *_loop0_133_rule(Parser *p);
static void *_tmp_134_rule(Parser *p);
-static asdl_seq *_loop0_135_rule(Parser *p);
+static void *_tmp_135_rule(Parser *p);
static void *_tmp_136_rule(Parser *p);
static void *_tmp_137_rule(Parser *p);
static void *_tmp_138_rule(Parser *p);
@@ -697,12 +693,10 @@ static void *_tmp_147_rule(Parser *p);
static void *_tmp_148_rule(Parser *p);
static void *_tmp_149_rule(Parser *p);
static void *_tmp_150_rule(Parser *p);
-static void *_tmp_151_rule(Parser *p);
-static void *_tmp_152_rule(Parser *p);
-static asdl_seq *_loop1_153_rule(Parser *p);
-static asdl_seq *_loop1_154_rule(Parser *p);
-static void *_tmp_155_rule(Parser *p);
-static void *_tmp_156_rule(Parser *p);
+static asdl_seq *_loop1_151_rule(Parser *p);
+static asdl_seq *_loop1_152_rule(Parser *p);
+static void *_tmp_153_rule(Parser *p);
+static void *_tmp_154_rule(Parser *p);
// file: statements? $
@@ -1219,7 +1213,7 @@ statements_rule(Parser *p)
return _res;
}
-// statement: compound_stmt | simple_stmt
+// statement: compound_stmt | simple_stmts
static asdl_stmt_seq*
statement_rule(Parser *p)
{
@@ -1254,18 +1248,18 @@ statement_rule(Parser *p)
D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt"));
}
- { // simple_stmt
+ { // simple_stmts
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
+ D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
asdl_stmt_seq* a;
if (
- (a = (asdl_stmt_seq*)simple_stmt_rule(p)) // simple_stmt
+ (a = (asdl_stmt_seq*)simple_stmts_rule(p)) // simple_stmts
)
{
- D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
+ D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
_res = a;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -1276,7 +1270,7 @@ statement_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmts"));
}
_res = NULL;
done:
@@ -1284,7 +1278,7 @@ statement_rule(Parser *p)
return _res;
}
-// statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $
+// statement_newline: compound_stmt NEWLINE | simple_stmts | NEWLINE | $
static asdl_stmt_seq*
statement_newline_rule(Parser *p)
{
@@ -1331,24 +1325,24 @@ statement_newline_rule(Parser *p)
D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt NEWLINE"));
}
- { // simple_stmt
+ { // simple_stmts
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- asdl_stmt_seq* simple_stmt_var;
+ D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
+ asdl_stmt_seq* simple_stmts_var;
if (
- (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
+ (simple_stmts_var = simple_stmts_rule(p)) // simple_stmts
)
{
- D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- _res = simple_stmt_var;
+ D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
+ _res = simple_stmts_var;
goto done;
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmts"));
}
{ // NEWLINE
if (p->error_indicator) {
@@ -1413,9 +1407,9 @@ statement_newline_rule(Parser *p)
return _res;
}
-// simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE
+// simple_stmts: simple_stmt !';' NEWLINE | ';'.simple_stmt+ ';'? NEWLINE
static asdl_stmt_seq*
-simple_stmt_rule(Parser *p)
+simple_stmts_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -1424,23 +1418,23 @@ simple_stmt_rule(Parser *p)
}
asdl_stmt_seq* _res = NULL;
int _mark = p->mark;
- { // small_stmt !';' NEWLINE
+ { // simple_stmt !';' NEWLINE
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt !';' NEWLINE"));
+ D(fprintf(stderr, "%*c> simple_stmts[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt !';' NEWLINE"));
stmt_ty a;
Token * newline_var;
if (
- (a = small_stmt_rule(p)) // small_stmt
+ (a = simple_stmt_rule(p)) // simple_stmt
&&
_PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';'
&&
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
)
{
- D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt !';' NEWLINE"));
+ D(fprintf(stderr, "%*c+ simple_stmts[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt !';' NEWLINE"));
_res = ( asdl_stmt_seq * ) _PyPegen_singleton_seq ( p , a );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -1450,28 +1444,28 @@ simple_stmt_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt !';' NEWLINE"));
+ D(fprintf(stderr, "%*c%s simple_stmts[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt !';' NEWLINE"));
}
- { // ';'.small_stmt+ ';'? NEWLINE
+ { // ';'.simple_stmt+ ';'? NEWLINE
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
+ D(fprintf(stderr, "%*c> simple_stmts[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'.simple_stmt+ ';'? NEWLINE"));
void *_opt_var;
UNUSED(_opt_var); // Silence compiler warnings
asdl_stmt_seq* a;
Token * newline_var;
if (
- (a = (asdl_stmt_seq*)_gather_12_rule(p)) // ';'.small_stmt+
+ (a = (asdl_stmt_seq*)_gather_12_rule(p)) // ';'.simple_stmt+
&&
(_opt_var = _PyPegen_expect_token(p, 13), 1) // ';'?
&&
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
)
{
- D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
+ D(fprintf(stderr, "%*c+ simple_stmts[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'.simple_stmt+ ';'? NEWLINE"));
_res = a;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -1481,8 +1475,8 @@ simple_stmt_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
+ D(fprintf(stderr, "%*c%s simple_stmts[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'.simple_stmt+ ';'? NEWLINE"));
}
_res = NULL;
done:
@@ -1490,7 +1484,7 @@ simple_stmt_rule(Parser *p)
return _res;
}
-// small_stmt:
+// simple_stmt:
// | assignment
// | star_expressions
// | &'return' return_stmt
@@ -1505,7 +1499,7 @@ simple_stmt_rule(Parser *p)
// | &'global' global_stmt
// | &'nonlocal' nonlocal_stmt
static stmt_ty
-small_stmt_rule(Parser *p)
+simple_stmt_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -1513,7 +1507,7 @@ small_stmt_rule(Parser *p)
return NULL;
}
stmt_ty _res = NULL;
- if (_PyPegen_is_memoized(p, small_stmt_type, &_res)) {
+ if (_PyPegen_is_memoized(p, simple_stmt_type, &_res)) {
D(p->level--);
return _res;
}
@@ -1532,18 +1526,18 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment"));
stmt_ty assignment_var;
if (
(assignment_var = assignment_rule(p)) // assignment
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment"));
_res = assignment_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment"));
}
{ // star_expressions
@@ -1551,13 +1545,13 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
expr_ty e;
if (
(e = star_expressions_rule(p)) // star_expressions
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
if (_token == NULL) {
D(p->level--);
@@ -1576,7 +1570,7 @@ small_stmt_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
}
{ // &'return' return_stmt
@@ -1584,7 +1578,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
stmt_ty return_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return'
@@ -1592,12 +1586,12 @@ small_stmt_rule(Parser *p)
(return_stmt_var = return_stmt_rule(p)) // return_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
_res = return_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'return' return_stmt"));
}
{ // &('import' | 'from') import_stmt
@@ -1605,7 +1599,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
stmt_ty import_stmt_var;
if (
_PyPegen_lookahead(1, _tmp_14_rule, p)
@@ -1613,12 +1607,12 @@ small_stmt_rule(Parser *p)
(import_stmt_var = import_stmt_rule(p)) // import_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
_res = import_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('import' | 'from') import_stmt"));
}
{ // &'raise' raise_stmt
@@ -1626,7 +1620,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
stmt_ty raise_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise'
@@ -1634,12 +1628,12 @@ small_stmt_rule(Parser *p)
(raise_stmt_var = raise_stmt_rule(p)) // raise_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
_res = raise_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'raise' raise_stmt"));
}
{ // 'pass'
@@ -1647,13 +1641,13 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'pass'"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'pass'"));
Token * _keyword;
if (
(_keyword = _PyPegen_expect_token(p, 502)) // token='pass'
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'pass'"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'pass'"));
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
if (_token == NULL) {
D(p->level--);
@@ -1672,7 +1666,7 @@ small_stmt_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'pass'"));
}
{ // &'del' del_stmt
@@ -1680,7 +1674,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
stmt_ty del_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del'
@@ -1688,12 +1682,12 @@ small_stmt_rule(Parser *p)
(del_stmt_var = del_stmt_rule(p)) // del_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
_res = del_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'del' del_stmt"));
}
{ // &'yield' yield_stmt
@@ -1701,7 +1695,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
stmt_ty yield_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield'
@@ -1709,12 +1703,12 @@ small_stmt_rule(Parser *p)
(yield_stmt_var = yield_stmt_rule(p)) // yield_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
_res = yield_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'yield' yield_stmt"));
}
{ // &'assert' assert_stmt
@@ -1722,7 +1716,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
stmt_ty assert_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert'
@@ -1730,12 +1724,12 @@ small_stmt_rule(Parser *p)
(assert_stmt_var = assert_stmt_rule(p)) // assert_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
_res = assert_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'assert' assert_stmt"));
}
{ // 'break'
@@ -1743,13 +1737,13 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'break'"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'break'"));
Token * _keyword;
if (
(_keyword = _PyPegen_expect_token(p, 506)) // token='break'
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'break'"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'break'"));
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
if (_token == NULL) {
D(p->level--);
@@ -1768,7 +1762,7 @@ small_stmt_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'break'"));
}
{ // 'continue'
@@ -1776,13 +1770,13 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'continue'"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'continue'"));
Token * _keyword;
if (
(_keyword = _PyPegen_expect_token(p, 507)) // token='continue'
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'continue'"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'continue'"));
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
if (_token == NULL) {
D(p->level--);
@@ -1801,7 +1795,7 @@ small_stmt_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'continue'"));
}
{ // &'global' global_stmt
@@ -1809,7 +1803,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
stmt_ty global_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global'
@@ -1817,12 +1811,12 @@ small_stmt_rule(Parser *p)
(global_stmt_var = global_stmt_rule(p)) // global_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
_res = global_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'global' global_stmt"));
}
{ // &'nonlocal' nonlocal_stmt
@@ -1830,7 +1824,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
stmt_ty nonlocal_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal'
@@ -1838,17 +1832,17 @@ small_stmt_rule(Parser *p)
(nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
_res = nonlocal_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
}
_res = NULL;
done:
- _PyPegen_insert_memo(p, _mark, small_stmt_type, _res);
+ _PyPegen_insert_memo(p, _mark, simple_stmt_type, _res);
D(p->level--);
return _res;
}
@@ -6241,7 +6235,7 @@ class_def_raw_rule(Parser *p)
return _res;
}
-// block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block
+// block: NEWLINE INDENT statements DEDENT | simple_stmts | invalid_block
static asdl_stmt_seq*
block_rule(Parser *p)
{
@@ -6289,24 +6283,24 @@ block_rule(Parser *p)
D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT statements DEDENT"));
}
- { // simple_stmt
+ { // simple_stmts
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- asdl_stmt_seq* simple_stmt_var;
+ D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
+ asdl_stmt_seq* simple_stmts_var;
if (
- (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
+ (simple_stmts_var = simple_stmts_rule(p)) // simple_stmts
)
{
- D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- _res = simple_stmt_var;
+ D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
+ _res = simple_stmts_var;
goto done;
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmts"));
}
if (p->call_invalid_rules) { // invalid_block
if (p->error_indicator) {
@@ -6334,51 +6328,6 @@ block_rule(Parser *p)
return _res;
}
-// expressions_list: ','.star_expression+ ','?
-static asdl_expr_seq*
-expressions_list_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_expr_seq* _res = NULL;
- int _mark = p->mark;
- { // ','.star_expression+ ','?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> expressions_list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_expression+ ','?"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- asdl_expr_seq* a;
- if (
- (a = (asdl_expr_seq*)_gather_70_rule(p)) // ','.star_expression+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- )
- {
- D(fprintf(stderr, "%*c+ expressions_list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_expression+ ','?"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s expressions_list[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_expression+ ','?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
// star_expressions:
// | star_expression ((',' star_expression))+ ','?
// | star_expression ','
@@ -6415,7 +6364,7 @@ star_expressions_rule(Parser *p)
if (
(a = star_expression_rule(p)) // star_expression
&&
- (b = _loop1_72_rule(p)) // ((',' star_expression))+
+ (b = _loop1_70_rule(p)) // ((',' star_expression))+
&&
(_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
)
@@ -6610,7 +6559,7 @@ star_named_expressions_rule(Parser *p)
UNUSED(_opt_var); // Silence compiler warnings
asdl_expr_seq* a;
if (
- (a = (asdl_expr_seq*)_gather_73_rule(p)) // ','.star_named_expression+
+ (a = (asdl_expr_seq*)_gather_71_rule(p)) // ','.star_named_expression+
&&
(_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
)
@@ -6915,7 +6864,7 @@ expressions_rule(Parser *p)
if (
(a = expression_rule(p)) // expression
&&
- (b = _loop1_75_rule(p)) // ((',' expression))+
+ (b = _loop1_73_rule(p)) // ((',' expression))+
&&
(_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
)
@@ -7269,9 +7218,9 @@ lambda_parameters_rule(Parser *p)
if (
(a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default
&&
- (b = (asdl_arg_seq*)_loop0_76_rule(p)) // lambda_param_no_default*
+ (b = (asdl_arg_seq*)_loop0_74_rule(p)) // lambda_param_no_default*
&&
- (c = _loop0_77_rule(p)) // lambda_param_with_default*
+ (c = _loop0_75_rule(p)) // lambda_param_with_default*
&&
(d = lambda_star_etc_rule(p), 1) // lambda_star_etc?
)
@@ -7301,7 +7250,7 @@ lambda_parameters_rule(Parser *p)
if (
(a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default
&&
- (b = _loop0_78_rule(p)) // lambda_param_with_default*
+ (b = _loop0_76_rule(p)) // lambda_param_with_default*
&&
(c = lambda_star_etc_rule(p), 1) // lambda_star_etc?
)
@@ -7329,9 +7278,9 @@ lambda_parameters_rule(Parser *p)
asdl_seq * b;
void *c;
if (
- (a = (asdl_arg_seq*)_loop1_79_rule(p)) // lambda_param_no_default+
+ (a = (asdl_arg_seq*)_loop1_77_rule(p)) // lambda_param_no_default+
&&
- (b = _loop0_80_rule(p)) // lambda_param_with_default*
+ (b = _loop0_78_rule(p)) // lambda_param_with_default*
&&
(c = lambda_star_etc_rule(p), 1) // lambda_star_etc?
)
@@ -7358,7 +7307,7 @@ lambda_parameters_rule(Parser *p)
asdl_seq * a;
void *b;
if (
- (a = _loop1_81_rule(p)) // lambda_param_with_default+
+ (a = _loop1_79_rule(p)) // lambda_param_with_default+
&&
(b = lambda_star_etc_rule(p), 1) // lambda_star_etc?
)
@@ -7429,7 +7378,7 @@ lambda_slash_no_default_rule(Parser *p)
Token * _literal_1;
asdl_arg_seq* a;
if (
- (a = (asdl_arg_seq*)_loop1_82_rule(p)) // lambda_param_no_default+
+ (a = (asdl_arg_seq*)_loop1_80_rule(p)) // lambda_param_no_default+
&&
(_literal = _PyPegen_expect_token(p, 17)) // token='/'
&&
@@ -7458,7 +7407,7 @@ lambda_slash_no_default_rule(Parser *p)
Token * _literal;
asdl_arg_seq* a;
if (
- (a = (asdl_arg_seq*)_loop1_83_rule(p)) // lambda_param_no_default+
+ (a = (asdl_arg_seq*)_loop1_81_rule(p)) // lambda_param_no_default+
&&
(_literal = _PyPegen_expect_token(p, 17)) // token='/'
&&
@@ -7508,9 +7457,9 @@ lambda_slash_with_default_rule(Parser *p)
asdl_seq * a;
asdl_seq * b;
if (
- (a = _loop0_84_rule(p)) // lambda_param_no_default*
+ (a = _loop0_82_rule(p)) // lambda_param_no_default*
&&
- (b = _loop1_85_rule(p)) // lambda_param_with_default+
+ (b = _loop1_83_rule(p)) // lambda_param_with_default+
&&
(_literal = _PyPegen_expect_token(p, 17)) // token='/'
&&
@@ -7540,9 +7489,9 @@ lambda_slash_with_default_rule(Parser *p)
asdl_seq * a;
asdl_seq * b;
if (
- (a = _loop0_86_rule(p)) // lambda_param_no_default*
+ (a = _loop0_84_rule(p)) // lambda_param_no_default*
&&
- (b = _loop1_87_rule(p)) // lambda_param_with_default+
+ (b = _loop1_85_rule(p)) // lambda_param_with_default+
&&
(_literal = _PyPegen_expect_token(p, 17)) // token='/'
&&
@@ -7598,7 +7547,7 @@ lambda_star_etc_rule(Parser *p)
&&
(a = lambda_param_no_default_rule(p)) // lambda_param_no_default
&&
- (b = _loop0_88_rule(p)) // lambda_param_maybe_default*
+ (b = _loop0_86_rule(p)) // lambda_param_maybe_default*
&&
(c = lambda_kwds_rule(p), 1) // lambda_kwds?
)
@@ -7631,7 +7580,7 @@ lambda_star_etc_rule(Parser *p)
&&
(_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
&&
- (b = _loop1_89_rule(p)) // lambda_param_maybe_default+
+ (b = _loop1_87_rule(p)) // lambda_param_maybe_default+
&&
(c = lambda_kwds_rule(p), 1) // lambda_kwds?
)
@@ -8058,7 +8007,7 @@ disjunction_rule(Parser *p)
if (
(a = conjunction_rule(p)) // conjunction
&&
- (b = _loop1_90_rule(p)) // (('or' conjunction))+
+ (b = _loop1_88_rule(p)) // (('or' conjunction))+
)
{
D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+"));
@@ -8144,7 +8093,7 @@ conjunction_rule(Parser *p)
if (
(a = inversion_rule(p)) // inversion
&&
- (b = _loop1_91_rule(p)) // (('and' inversion))+
+ (b = _loop1_89_rule(p)) // (('and' inversion))+
)
{
D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+"));
@@ -8312,7 +8261,7 @@ comparison_rule(Parser *p)
if (
(a = bitwise_or_rule(p)) // bitwise_or
&&
- (b = _loop1_92_rule(p)) // compare_op_bitwise_or_pair+
+ (b = _loop1_90_rule(p)) // compare_op_bitwise_or_pair+
)
{
D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+"));
@@ -8640,10 +8589,10 @@ noteq_bitwise_or_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or"));
- void *_tmp_93_var;
+ void *_tmp_91_var;
expr_ty a;
if (
- (_tmp_93_var = _tmp_93_rule(p)) // '!='
+ (_tmp_91_var = _tmp_91_rule(p)) // '!='
&&
(a = bitwise_or_rule(p)) // bitwise_or
)
@@ -10606,7 +10555,7 @@ slices_rule(Parser *p)
UNUSED(_opt_var); // Silence compiler warnings
asdl_expr_seq* a;
if (
- (a = (asdl_expr_seq*)_gather_94_rule(p)) // ','.slice+
+ (a = (asdl_expr_seq*)_gather_92_rule(p)) // ','.slice+
&&
(_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
)
@@ -10639,7 +10588,7 @@ slices_rule(Parser *p)
return _res;
}
-// slice: expression? ':' expression? [':' expression?] | expression
+// slice: expression? ':' expression? [':' expression?] | named_expression
static expr_ty
slice_rule(Parser *p)
{
@@ -10676,7 +10625,7 @@ slice_rule(Parser *p)
&&
(b = expression_rule(p), 1) // expression?
&&
- (c = _tmp_96_rule(p), 1) // [':' expression?]
+ (c = _tmp_94_rule(p), 1) // [':' expression?]
)
{
D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]"));
@@ -10701,18 +10650,18 @@ slice_rule(Parser *p)
D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression? ':' expression? [':' expression?]"));
}
- { // expression
+ { // named_expression
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression"));
+ D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression"));
expr_ty a;
if (
- (a = expression_rule(p)) // expression
+ (a = named_expression_rule(p)) // named_expression
)
{
- D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression"));
+ D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression"));
_res = a;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -10723,7 +10672,7 @@ slice_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression"));
}
_res = NULL;
done:
@@ -10925,15 +10874,15 @@ atom_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)"));
- void *_tmp_97_var;
+ void *_tmp_95_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='('
&&
- (_tmp_97_var = _tmp_97_rule(p)) // tuple | group | genexp
+ (_tmp_95_var = _tmp_95_rule(p)) // tuple | group | genexp
)
{
D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)"));
- _res = _tmp_97_var;
+ _res = _tmp_95_var;
goto done;
}
p->mark = _mark;
@@ -10946,15 +10895,15 @@ atom_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)"));
- void *_tmp_98_var;
+ void *_tmp_96_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='['
&&
- (_tmp_98_var = _tmp_98_rule(p)) // list | listcomp
+ (_tmp_96_var = _tmp_96_rule(p)) // list | listcomp
)
{
D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)"));
- _res = _tmp_98_var;
+ _res = _tmp_96_var;
goto done;
}
p->mark = _mark;
@@ -10967,15 +10916,15 @@ atom_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)"));
- void *_tmp_99_var;
+ void *_tmp_97_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{'
&&
- (_tmp_99_var = _tmp_99_rule(p)) // dict | set | dictcomp | setcomp
+ (_tmp_97_var = _tmp_97_rule(p)) // dict | set | dictcomp | setcomp
)
{
D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)"));
- _res = _tmp_99_var;
+ _res = _tmp_97_var;
goto done;
}
p->mark = _mark;
@@ -11044,7 +10993,7 @@ strings_rule(Parser *p)
D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+"));
asdl_seq * a;
if (
- (a = _loop1_100_rule(p)) // STRING+
+ (a = _loop1_98_rule(p)) // STRING+
)
{
D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+"));
@@ -11258,7 +11207,7 @@ tuple_rule(Parser *p)
if (
(_literal = _PyPegen_expect_token(p, 7)) // token='('
&&
- (a = _tmp_101_rule(p), 1) // [star_named_expression ',' star_named_expressions?]
+ (a = _tmp_99_rule(p), 1) // [star_named_expression ',' star_named_expressions?]
&&
(_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
)
@@ -11314,7 +11263,7 @@ group_rule(Parser *p)
if (
(_literal = _PyPegen_expect_token(p, 7)) // token='('
&&
- (a = _tmp_102_rule(p)) // yield_expr | named_expression
+ (a = _tmp_100_rule(p)) // yield_expr | named_expression
&&
(_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
)
@@ -11357,7 +11306,7 @@ group_rule(Parser *p)
return _res;
}
-// genexp: '(' expression ~ for_if_clauses ')' | invalid_comprehension
+// genexp: '(' named_expression ~ for_if_clauses ')' | invalid_comprehension
static expr_ty
genexp_rule(Parser *p)
{
@@ -11377,12 +11326,12 @@ genexp_rule(Parser *p)
UNUSED(_start_lineno); // Only used by EXTRA macro
int _start_col_offset = p->tokens[_mark]->col_offset;
UNUSED(_start_col_offset); // Only used by EXTRA macro
- { // '(' expression ~ for_if_clauses ')'
+ { // '(' named_expression ~ for_if_clauses ')'
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' expression ~ for_if_clauses ')'"));
+ D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' named_expression ~ for_if_clauses ')'"));
int _cut_var = 0;
Token * _literal;
Token * _literal_1;
@@ -11391,7 +11340,7 @@ genexp_rule(Parser *p)
if (
(_literal = _PyPegen_expect_token(p, 7)) // token='('
&&
- (a = expression_rule(p)) // expression
+ (a = named_expression_rule(p)) // named_expression
&&
(_cut_var = 1)
&&
@@ -11400,7 +11349,7 @@ genexp_rule(Parser *p)
(_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
)
{
- D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' expression ~ for_if_clauses ')'"));
+ D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' named_expression ~ for_if_clauses ')'"));
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
if (_token == NULL) {
D(p->level--);
@@ -11420,7 +11369,7 @@ genexp_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' expression ~ for_if_clauses ')'"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' named_expression ~ for_if_clauses ')'"));
if (_cut_var) {
D(p->level--);
return NULL;
@@ -11451,7 +11400,7 @@ genexp_rule(Parser *p)
return _res;
}
-// set: '{' expressions_list '}'
+// set: '{' star_named_expressions '}'
static expr_ty
set_rule(Parser *p)
{
@@ -11471,24 +11420,24 @@ set_rule(Parser *p)
UNUSED(_start_lineno); // Only used by EXTRA macro
int _start_col_offset = p->tokens[_mark]->col_offset;
UNUSED(_start_col_offset); // Only used by EXTRA macro
- { // '{' expressions_list '}'
+ { // '{' star_named_expressions '}'
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> set[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' expressions_list '}'"));
+ D(fprintf(stderr, "%*c> set[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' star_named_expressions '}'"));
Token * _literal;
Token * _literal_1;
asdl_expr_seq* a;
if (
(_literal = _PyPegen_expect_token(p, 25)) // token='{'
&&
- (a = expressions_list_rule(p)) // expressions_list
+ (a = star_named_expressions_rule(p)) // star_named_expressions
&&
(_literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
)
{
- D(fprintf(stderr, "%*c+ set[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' expressions_list '}'"));
+ D(fprintf(stderr, "%*c+ set[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' star_named_expressions '}'"));
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
if (_token == NULL) {
D(p->level--);
@@ -11508,7 +11457,7 @@ set_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s set[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' expressions_list '}'"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' star_named_expressions '}'"));
}
_res = NULL;
done:
@@ -11516,7 +11465,7 @@ set_rule(Parser *p)
return _res;
}
-// setcomp: '{' expression ~ for_if_clauses '}' | invalid_comprehension
+// setcomp: '{' named_expression ~ for_if_clauses '}' | invalid_comprehension
static expr_ty
setcomp_rule(Parser *p)
{
@@ -11536,12 +11485,12 @@ setcomp_rule(Parser *p)
UNUSED(_start_lineno); // Only used by EXTRA macro
int _start_col_offset = p->tokens[_mark]->col_offset;
UNUSED(_start_col_offset); // Only used by EXTRA macro
- { // '{' expression ~ for_if_clauses '}'
+ { // '{' named_expression ~ for_if_clauses '}'
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' expression ~ for_if_clauses '}'"));
+ D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' named_expression ~ for_if_clauses '}'"));
int _cut_var = 0;
Token * _literal;
Token * _literal_1;
@@ -11550,7 +11499,7 @@ setcomp_rule(Parser *p)
if (
(_literal = _PyPegen_expect_token(p, 25)) // token='{'
&&
- (a = expression_rule(p)) // expression
+ (a = named_expression_rule(p)) // named_expression
&&
(_cut_var = 1)
&&
@@ -11559,7 +11508,7 @@ setcomp_rule(Parser *p)
(_literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
)
{
- D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' expression ~ for_if_clauses '}'"));
+ D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' named_expression ~ for_if_clauses '}'"));
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
if (_token == NULL) {
D(p->level--);
@@ -11579,7 +11528,7 @@ setcomp_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' expression ~ for_if_clauses '}'"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' named_expression ~ for_if_clauses '}'"));
if (_cut_var) {
D(p->level--);
return NULL;
@@ -11783,7 +11732,7 @@ double_starred_kvpairs_rule(Parser *p)
UNUSED(_opt_var); // Silence compiler warnings
asdl_seq * a;
if (
- (a = _gather_103_rule(p)) // ','.double_starred_kvpair+
+ (a = _gather_101_rule(p)) // ','.double_starred_kvpair+
&&
(_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
)
@@ -11936,7 +11885,7 @@ for_if_clauses_rule(Parser *p)
D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+"));
asdl_comprehension_seq* a;
if (
- (a = (asdl_comprehension_seq*)_loop1_105_rule(p)) // for_if_clause+
+ (a = (asdl_comprehension_seq*)_loop1_103_rule(p)) // for_if_clause+
)
{
D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+"));
@@ -11998,7 +11947,7 @@ for_if_clause_rule(Parser *p)
&&
(b = disjunction_rule(p)) // disjunction
&&
- (c = (asdl_expr_seq*)_loop0_106_rule(p)) // (('if' disjunction))*
+ (c = (asdl_expr_seq*)_loop0_104_rule(p)) // (('if' disjunction))*
)
{
D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' ~ disjunction (('if' disjunction))*"));
@@ -12041,7 +11990,7 @@ for_if_clause_rule(Parser *p)
&&
(b = disjunction_rule(p)) // disjunction
&&
- (c = (asdl_expr_seq*)_loop0_107_rule(p)) // (('if' disjunction))*
+ (c = (asdl_expr_seq*)_loop0_105_rule(p)) // (('if' disjunction))*
)
{
D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' ~ disjunction (('if' disjunction))*"));
@@ -12287,9 +12236,9 @@ args_rule(Parser *p)
asdl_expr_seq* a;
void *b;
if (
- (a = (asdl_expr_seq*)_gather_108_rule(p)) // ','.(starred_expression | named_expression !'=')+
+ (a = (asdl_expr_seq*)_gather_106_rule(p)) // ','.(starred_expression | named_expression !'=')+
&&
- (b = _tmp_110_rule(p), 1) // [',' kwargs]
+ (b = _tmp_108_rule(p), 1) // [',' kwargs]
)
{
D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(starred_expression | named_expression !'=')+ [',' kwargs]"));
@@ -12377,11 +12326,11 @@ kwargs_rule(Parser *p)
asdl_seq * a;
asdl_seq * b;
if (
- (a = _gather_111_rule(p)) // ','.kwarg_or_starred+
+ (a = _gather_109_rule(p)) // ','.kwarg_or_starred+
&&
(_literal = _PyPegen_expect_token(p, 12)) // token=','
&&
- (b = _gather_113_rule(p)) // ','.kwarg_or_double_starred+
+ (b = _gather_111_rule(p)) // ','.kwarg_or_double_starred+
)
{
D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+"));
@@ -12403,13 +12352,13 @@ kwargs_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+"));
- asdl_seq * _gather_115_var;
+ asdl_seq * _gather_113_var;
if (
- (_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_starred+
+ (_gather_113_var = _gather_113_rule(p)) // ','.kwarg_or_starred+
)
{
D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+"));
- _res = _gather_115_var;
+ _res = _gather_113_var;
goto done;
}
p->mark = _mark;
@@ -12422,13 +12371,13 @@ kwargs_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+"));
- asdl_seq * _gather_117_var;
+ asdl_seq * _gather_115_var;
if (
- (_gather_117_var = _gather_117_rule(p)) // ','.kwarg_or_double_starred+
+ (_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_double_starred+
)
{
D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+"));
- _res = _gather_117_var;
+ _res = _gather_115_var;
goto done;
}
p->mark = _mark;
@@ -12790,7 +12739,7 @@ star_targets_rule(Parser *p)
if (
(a = star_target_rule(p)) // star_target
&&
- (b = _loop0_119_rule(p)) // ((',' star_target))*
+ (b = _loop0_117_rule(p)) // ((',' star_target))*
&&
(_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
)
@@ -12844,7 +12793,7 @@ star_targets_seq_rule(Parser *p)
UNUSED(_opt_var); // Silence compiler warnings
asdl_expr_seq* a;
if (
- (a = (asdl_expr_seq*)_gather_120_rule(p)) // ','.star_target+
+ (a = (asdl_expr_seq*)_gather_118_rule(p)) // ','.star_target+
&&
(_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
)
@@ -12907,7 +12856,7 @@ star_target_rule(Parser *p)
if (
(_literal = _PyPegen_expect_token(p, 16)) // token='*'
&&
- (a = _tmp_122_rule(p)) // !'*' star_target
+ (a = _tmp_120_rule(p)) // !'*' star_target
)
{
D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)"));
@@ -13429,7 +13378,7 @@ del_targets_rule(Parser *p)
UNUSED(_opt_var); // Silence compiler warnings
asdl_expr_seq* a;
if (
- (a = (asdl_expr_seq*)_gather_123_rule(p)) // ','.del_target+
+ (a = (asdl_expr_seq*)_gather_121_rule(p)) // ','.del_target+
&&
(_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
)
@@ -13770,7 +13719,7 @@ targets_rule(Parser *p)
UNUSED(_opt_var); // Silence compiler warnings
asdl_expr_seq* a;
if (
- (a = (asdl_expr_seq*)_gather_125_rule(p)) // ','.target+
+ (a = (asdl_expr_seq*)_gather_123_rule(p)) // ','.target+
&&
(_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
)
@@ -14484,7 +14433,7 @@ invalid_arguments_rule(Parser *p)
&&
(_literal = _PyPegen_expect_token(p, 12)) // token=','
&&
- (_opt_var = _tmp_127_rule(p), 1) // [args | expression for_if_clauses]
+ (_opt_var = _tmp_125_rule(p), 1) // [args | expression for_if_clauses]
)
{
D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]"));
@@ -14613,12 +14562,12 @@ invalid_kwarg_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression '='"));
- Token * _literal;
- expr_ty a;
+ Token * a;
+ expr_ty expression_var;
if (
- (a = expression_rule(p)) // expression
+ (expression_var = expression_rule(p)) // expression
&&
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ (a = _PyPegen_expect_token(p, 22)) // token='='
)
{
D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression '='"));
@@ -14742,7 +14691,7 @@ invalid_assignment_rule(Parser *p)
D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression"));
Token * _literal;
Token * _literal_1;
- asdl_seq * _loop0_128_var;
+ asdl_seq * _loop0_126_var;
expr_ty a;
expr_ty expression_var;
if (
@@ -14750,7 +14699,7 @@ invalid_assignment_rule(Parser *p)
&&
(_literal = _PyPegen_expect_token(p, 12)) // token=','
&&
- (_loop0_128_var = _loop0_128_rule(p)) // star_named_expressions*
+ (_loop0_126_var = _loop0_126_rule(p)) // star_named_expressions*
&&
(_literal_1 = _PyPegen_expect_token(p, 11)) // token=':'
&&
@@ -14807,10 +14756,10 @@ invalid_assignment_rule(Parser *p)
}
D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='"));
Token * _literal;
- asdl_seq * _loop0_129_var;
+ asdl_seq * _loop0_127_var;
expr_ty a;
if (
- (_loop0_129_var = _loop0_129_rule(p)) // ((star_targets '='))*
+ (_loop0_127_var = _loop0_127_rule(p)) // ((star_targets '='))*
&&
(a = star_expressions_rule(p)) // star_expressions
&&
@@ -14837,10 +14786,10 @@ invalid_assignment_rule(Parser *p)
}
D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='"));
Token * _literal;
- asdl_seq * _loop0_130_var;
+ asdl_seq * _loop0_128_var;
expr_ty a;
if (
- (_loop0_130_var = _loop0_130_rule(p)) // ((star_targets '='))*
+ (_loop0_128_var = _loop0_128_rule(p)) // ((star_targets '='))*
&&
(a = yield_expr_rule(p)) // yield_expr
&&
@@ -14866,7 +14815,7 @@ invalid_assignment_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)"));
- void *_tmp_131_var;
+ void *_tmp_129_var;
expr_ty a;
AugOperator* augassign_var;
if (
@@ -14874,7 +14823,7 @@ invalid_assignment_rule(Parser *p)
&&
(augassign_var = augassign_rule(p)) // augassign
&&
- (_tmp_131_var = _tmp_131_rule(p)) // yield_expr | star_expressions
+ (_tmp_129_var = _tmp_129_rule(p)) // yield_expr | star_expressions
)
{
D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)"));
@@ -15130,11 +15079,11 @@ invalid_comprehension_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses"));
- void *_tmp_132_var;
+ void *_tmp_130_var;
expr_ty a;
asdl_comprehension_seq* for_if_clauses_var;
if (
- (_tmp_132_var = _tmp_132_rule(p)) // '[' | '(' | '{'
+ (_tmp_130_var = _tmp_130_rule(p)) // '[' | '(' | '{'
&&
(a = starred_expression_rule(p)) // starred_expression
&&
@@ -15231,13 +15180,13 @@ invalid_parameters_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default"));
- asdl_seq * _loop0_133_var;
- void *_tmp_134_var;
+ asdl_seq * _loop0_131_var;
+ void *_tmp_132_var;
arg_ty param_no_default_var;
if (
- (_loop0_133_var = _loop0_133_rule(p)) // param_no_default*
+ (_loop0_131_var = _loop0_131_rule(p)) // param_no_default*
&&
- (_tmp_134_var = _tmp_134_rule(p)) // slash_with_default | param_with_default+
+ (_tmp_132_var = _tmp_132_rule(p)) // slash_with_default | param_with_default+
&&
(param_no_default_var = param_no_default_rule(p)) // param_no_default
)
@@ -15279,13 +15228,13 @@ invalid_lambda_parameters_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default"));
- asdl_seq * _loop0_135_var;
- void *_tmp_136_var;
+ asdl_seq * _loop0_133_var;
+ void *_tmp_134_var;
arg_ty lambda_param_no_default_var;
if (
- (_loop0_135_var = _loop0_135_rule(p)) // lambda_param_no_default*
+ (_loop0_133_var = _loop0_133_rule(p)) // lambda_param_no_default*
&&
- (_tmp_136_var = _tmp_136_rule(p)) // lambda_slash_with_default | lambda_param_with_default+
+ (_tmp_134_var = _tmp_134_rule(p)) // lambda_slash_with_default | lambda_param_with_default+
&&
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
)
@@ -15327,11 +15276,11 @@ invalid_star_etc_rule(Parser *p)
}
D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))"));
Token * _literal;
- void *_tmp_137_var;
+ void *_tmp_135_var;
if (
(_literal = _PyPegen_expect_token(p, 16)) // token='*'
&&
- (_tmp_137_var = _tmp_137_rule(p)) // ')' | ',' (')' | '**')
+ (_tmp_135_var = _tmp_135_rule(p)) // ')' | ',' (')' | '**')
)
{
D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))"));
@@ -15401,11 +15350,11 @@ invalid_lambda_star_etc_rule(Parser *p)
}
D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))"));
Token * _literal;
- void *_tmp_138_var;
+ void *_tmp_136_var;
if (
(_literal = _PyPegen_expect_token(p, 16)) // token='*'
&&
- (_tmp_138_var = _tmp_138_rule(p)) // ':' | ',' (':' | '**')
+ (_tmp_136_var = _tmp_136_rule(p)) // ':' | ',' (':' | '**')
)
{
D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))"));
@@ -16325,7 +16274,7 @@ _loop1_11_rule(Parser *p)
return _seq;
}
-// _loop0_13: ';' small_stmt
+// _loop0_13: ';' simple_stmt
static asdl_seq *
_loop0_13_rule(Parser *p)
{
@@ -16346,18 +16295,18 @@ _loop0_13_rule(Parser *p)
}
ssize_t _children_capacity = 1;
ssize_t _n = 0;
- { // ';' small_stmt
+ { // ';' simple_stmt
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' small_stmt"));
+ D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' simple_stmt"));
Token * _literal;
stmt_ty elem;
while (
(_literal = _PyPegen_expect_token(p, 13)) // token=';'
&&
- (elem = small_stmt_rule(p)) // small_stmt
+ (elem = simple_stmt_rule(p)) // simple_stmt
)
{
_res = elem;
@@ -16383,7 +16332,7 @@ _loop0_13_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s _loop0_13[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' small_stmt"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' simple_stmt"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
if (!_seq) {
@@ -16400,7 +16349,7 @@ _loop0_13_rule(Parser *p)
return _seq;
}
-// _gather_12: small_stmt _loop0_13
+// _gather_12: simple_stmt _loop0_13
static asdl_seq *
_gather_12_rule(Parser *p)
{
@@ -16411,27 +16360,27 @@ _gather_12_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // small_stmt _loop0_13
+ { // simple_stmt _loop0_13
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13"));
+ D(fprintf(stderr, "%*c> _gather_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt _loop0_13"));
stmt_ty elem;
asdl_seq * seq;
if (
- (elem = small_stmt_rule(p)) // small_stmt
+ (elem = simple_stmt_rule(p)) // simple_stmt
&&
(seq = _loop0_13_rule(p)) // _loop0_13
)
{
- D(fprintf(stderr, "%*c+ _gather_12[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13"));
+ D(fprintf(stderr, "%*c+ _gather_12[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt _loop0_13"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s _gather_12[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt _loop0_13"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt _loop0_13"));
}
_res = NULL;
done:
@@ -16914,12 +16863,12 @@ _loop1_22_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> _loop1_22[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')"));
- void *_tmp_139_var;
+ void *_tmp_137_var;
while (
- (_tmp_139_var = _tmp_139_rule(p)) // star_targets '='
+ (_tmp_137_var = _tmp_137_rule(p)) // star_targets '='
)
{
- _res = _tmp_139_var;
+ _res = _tmp_137_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -17422,12 +17371,12 @@ _loop0_31_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> _loop0_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')"));
- void *_tmp_140_var;
+ void *_tmp_138_var;
while (
- (_tmp_140_var = _tmp_140_rule(p)) // '.' | '...'
+ (_tmp_138_var = _tmp_138_rule(p)) // '.' | '...'
)
{
- _res = _tmp_140_var;
+ _res = _tmp_138_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -17488,12 +17437,12 @@ _loop1_32_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> _loop1_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')"));
- void *_tmp_141_var;
+ void *_tmp_139_var;
while (
- (_tmp_141_var = _tmp_141_rule(p)) // '.' | '...'
+ (_tmp_139_var = _tmp_139_rule(p)) // '.' | '...'
)
{
- _res = _tmp_141_var;
+ _res = _tmp_139_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -19650,12 +19599,12 @@ _loop1_68_rule(Parser *p)
return NULL;
}
D(fprintf(stderr, "%*c> _loop1_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)"));
- void *_tmp_142_var;
+ void *_tmp_140_var;
while (
- (_tmp_142_var = _tmp_142_rule(p)) // '@' named_expression NEWLINE
+ (_tmp_140_var = _tmp_140_rule(p)) // '@' named_expression NEWLINE
)
{
- _res = _tmp_142_var;
+ _res = _tmp_140_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -19741,123 +19690,9 @@ _tmp_69_rule(Parser *p)
return _res;
}
-// _loop0_71: ',' star_expression
+// _loop1_70: (',' star_expression)
static asdl_seq *
-_loop0_71_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' star_expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = star_expression_rule(p)) // star_expression
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression"));
- }
- asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_71_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_70: star_expression _loop0_71
-static asdl_seq *
-_gather_70_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // star_expression _loop0_71
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_71"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = star_expression_rule(p)) // star_expression
- &&
- (seq = _loop0_71_rule(p)) // _loop0_71
- )
- {
- D(fprintf(stderr, "%*c+ _gather_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_71"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_70[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_71"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop1_72: (',' star_expression)
-static asdl_seq *
-_loop1_72_rule(Parser *p)
+_loop1_70_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -19881,13 +19716,13 @@ _loop1_72_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)"));
- void *_tmp_143_var;
+ D(fprintf(stderr, "%*c> _loop1_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)"));
+ void *_tmp_141_var;
while (
- (_tmp_143_var = _tmp_143_rule(p)) // ',' star_expression
+ (_tmp_141_var = _tmp_141_rule(p)) // ',' star_expression
)
{
- _res = _tmp_143_var;
+ _res = _tmp_141_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -19903,7 +19738,7 @@ _loop1_72_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_72[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_70[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)"));
}
if (_n == 0 || p->error_indicator) {
@@ -19921,14 +19756,14 @@ _loop1_72_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_72_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_70_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_74: ',' star_named_expression
+// _loop0_72: ',' star_named_expression
static asdl_seq *
-_loop0_74_rule(Parser *p)
+_loop0_72_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -19952,7 +19787,7 @@ _loop0_74_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression"));
+ D(fprintf(stderr, "%*c> _loop0_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression"));
Token * _literal;
expr_ty elem;
while (
@@ -19983,7 +19818,7 @@ _loop0_74_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_74[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_72[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -19996,14 +19831,14 @@ _loop0_74_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_74_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_72_type, _seq);
D(p->level--);
return _seq;
}
-// _gather_73: star_named_expression _loop0_74
+// _gather_71: star_named_expression _loop0_72
static asdl_seq *
-_gather_73_rule(Parser *p)
+_gather_71_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20012,27 +19847,27 @@ _gather_73_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // star_named_expression _loop0_74
+ { // star_named_expression _loop0_72
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_74"));
+ D(fprintf(stderr, "%*c> _gather_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_72"));
expr_ty elem;
asdl_seq * seq;
if (
(elem = star_named_expression_rule(p)) // star_named_expression
&&
- (seq = _loop0_74_rule(p)) // _loop0_74
+ (seq = _loop0_72_rule(p)) // _loop0_72
)
{
- D(fprintf(stderr, "%*c+ _gather_73[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_74"));
+ D(fprintf(stderr, "%*c+ _gather_71[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_72"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_73[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_74"));
+ D(fprintf(stderr, "%*c%s _gather_71[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_72"));
}
_res = NULL;
done:
@@ -20040,9 +19875,9 @@ _gather_73_rule(Parser *p)
return _res;
}
-// _loop1_75: (',' expression)
+// _loop1_73: (',' expression)
static asdl_seq *
-_loop1_75_rule(Parser *p)
+_loop1_73_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20066,13 +19901,13 @@ _loop1_75_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)"));
- void *_tmp_144_var;
+ D(fprintf(stderr, "%*c> _loop1_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)"));
+ void *_tmp_142_var;
while (
- (_tmp_144_var = _tmp_144_rule(p)) // ',' expression
+ (_tmp_142_var = _tmp_142_rule(p)) // ',' expression
)
{
- _res = _tmp_144_var;
+ _res = _tmp_142_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -20088,7 +19923,7 @@ _loop1_75_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_75[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_73[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)"));
}
if (_n == 0 || p->error_indicator) {
@@ -20106,14 +19941,14 @@ _loop1_75_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_75_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_73_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_76: lambda_param_no_default
+// _loop0_74: lambda_param_no_default
static asdl_seq *
-_loop0_76_rule(Parser *p)
+_loop0_74_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20137,7 +19972,7 @@ _loop0_76_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ D(fprintf(stderr, "%*c> _loop0_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
arg_ty lambda_param_no_default_var;
while (
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
@@ -20159,7 +19994,7 @@ _loop0_76_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_76[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_74[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -20172,14 +20007,14 @@ _loop0_76_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_76_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_74_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_77: lambda_param_with_default
+// _loop0_75: lambda_param_with_default
static asdl_seq *
-_loop0_77_rule(Parser *p)
+_loop0_75_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20203,7 +20038,7 @@ _loop0_77_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ D(fprintf(stderr, "%*c> _loop0_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
NameDefaultPair* lambda_param_with_default_var;
while (
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
@@ -20225,7 +20060,7 @@ _loop0_77_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_77[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_75[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -20238,14 +20073,14 @@ _loop0_77_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_77_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_75_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_78: lambda_param_with_default
+// _loop0_76: lambda_param_with_default
static asdl_seq *
-_loop0_78_rule(Parser *p)
+_loop0_76_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20269,7 +20104,7 @@ _loop0_78_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ D(fprintf(stderr, "%*c> _loop0_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
NameDefaultPair* lambda_param_with_default_var;
while (
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
@@ -20291,7 +20126,7 @@ _loop0_78_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_76[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -20304,14 +20139,14 @@ _loop0_78_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_76_type, _seq);
D(p->level--);
return _seq;
}
-// _loop1_79: lambda_param_no_default
+// _loop1_77: lambda_param_no_default
static asdl_seq *
-_loop1_79_rule(Parser *p)
+_loop1_77_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20335,7 +20170,7 @@ _loop1_79_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ D(fprintf(stderr, "%*c> _loop1_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
arg_ty lambda_param_no_default_var;
while (
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
@@ -20357,7 +20192,7 @@ _loop1_79_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_79[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_77[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
}
if (_n == 0 || p->error_indicator) {
@@ -20375,14 +20210,14 @@ _loop1_79_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_79_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_77_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_80: lambda_param_with_default
+// _loop0_78: lambda_param_with_default
static asdl_seq *
-_loop0_80_rule(Parser *p)
+_loop0_78_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20406,7 +20241,7 @@ _loop0_80_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ D(fprintf(stderr, "%*c> _loop0_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
NameDefaultPair* lambda_param_with_default_var;
while (
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
@@ -20428,7 +20263,7 @@ _loop0_80_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_80[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -20441,14 +20276,14 @@ _loop0_80_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_80_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq);
D(p->level--);
return _seq;
}
-// _loop1_81: lambda_param_with_default
+// _loop1_79: lambda_param_with_default
static asdl_seq *
-_loop1_81_rule(Parser *p)
+_loop1_79_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20472,7 +20307,7 @@ _loop1_81_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ D(fprintf(stderr, "%*c> _loop1_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
NameDefaultPair* lambda_param_with_default_var;
while (
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
@@ -20494,7 +20329,7 @@ _loop1_81_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_79[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
}
if (_n == 0 || p->error_indicator) {
@@ -20512,14 +20347,14 @@ _loop1_81_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_79_type, _seq);
D(p->level--);
return _seq;
}
-// _loop1_82: lambda_param_no_default
+// _loop1_80: lambda_param_no_default
static asdl_seq *
-_loop1_82_rule(Parser *p)
+_loop1_80_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20543,7 +20378,7 @@ _loop1_82_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ D(fprintf(stderr, "%*c> _loop1_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
arg_ty lambda_param_no_default_var;
while (
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
@@ -20565,7 +20400,7 @@ _loop1_82_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
}
if (_n == 0 || p->error_indicator) {
@@ -20583,14 +20418,14 @@ _loop1_82_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_82_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq);
D(p->level--);
return _seq;
}
-// _loop1_83: lambda_param_no_default
+// _loop1_81: lambda_param_no_default
static asdl_seq *
-_loop1_83_rule(Parser *p)
+_loop1_81_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20614,7 +20449,7 @@ _loop1_83_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
arg_ty lambda_param_no_default_var;
while (
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
@@ -20636,7 +20471,7 @@ _loop1_83_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
}
if (_n == 0 || p->error_indicator) {
@@ -20654,14 +20489,14 @@ _loop1_83_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_84: lambda_param_no_default
+// _loop0_82: lambda_param_no_default
static asdl_seq *
-_loop0_84_rule(Parser *p)
+_loop0_82_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20685,7 +20520,7 @@ _loop0_84_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
arg_ty lambda_param_no_default_var;
while (
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
@@ -20707,7 +20542,7 @@ _loop0_84_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_84[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -20720,14 +20555,14 @@ _loop0_84_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_84_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_82_type, _seq);
D(p->level--);
return _seq;
}
-// _loop1_85: lambda_param_with_default
+// _loop1_83: lambda_param_with_default
static asdl_seq *
-_loop1_85_rule(Parser *p)
+_loop1_83_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20751,7 +20586,7 @@ _loop1_85_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
NameDefaultPair* lambda_param_with_default_var;
while (
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
@@ -20773,7 +20608,7 @@ _loop1_85_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
}
if (_n == 0 || p->error_indicator) {
@@ -20791,14 +20626,14 @@ _loop1_85_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_85_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_86: lambda_param_no_default
+// _loop0_84: lambda_param_no_default
static asdl_seq *
-_loop0_86_rule(Parser *p)
+_loop0_84_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20822,7 +20657,7 @@ _loop0_86_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ D(fprintf(stderr, "%*c> _loop0_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
arg_ty lambda_param_no_default_var;
while (
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
@@ -20844,7 +20679,7 @@ _loop0_86_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_86[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_84[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -20857,14 +20692,14 @@ _loop0_86_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_86_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_84_type, _seq);
D(p->level--);
return _seq;
}
-// _loop1_87: lambda_param_with_default
+// _loop1_85: lambda_param_with_default
static asdl_seq *
-_loop1_87_rule(Parser *p)
+_loop1_85_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20888,7 +20723,7 @@ _loop1_87_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ D(fprintf(stderr, "%*c> _loop1_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
NameDefaultPair* lambda_param_with_default_var;
while (
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
@@ -20910,7 +20745,7 @@ _loop1_87_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
}
if (_n == 0 || p->error_indicator) {
@@ -20928,14 +20763,14 @@ _loop1_87_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_85_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_88: lambda_param_maybe_default
+// _loop0_86: lambda_param_maybe_default
static asdl_seq *
-_loop0_88_rule(Parser *p)
+_loop0_86_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -20959,7 +20794,7 @@ _loop0_88_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default"));
+ D(fprintf(stderr, "%*c> _loop0_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default"));
NameDefaultPair* lambda_param_maybe_default_var;
while (
(lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default
@@ -20981,7 +20816,7 @@ _loop0_88_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_88[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_86[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -20994,14 +20829,14 @@ _loop0_88_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_88_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_86_type, _seq);
D(p->level--);
return _seq;
}
-// _loop1_89: lambda_param_maybe_default
+// _loop1_87: lambda_param_maybe_default
static asdl_seq *
-_loop1_89_rule(Parser *p)
+_loop1_87_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21025,7 +20860,7 @@ _loop1_89_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default"));
+ D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default"));
NameDefaultPair* lambda_param_maybe_default_var;
while (
(lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default
@@ -21047,7 +20882,7 @@ _loop1_89_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default"));
}
if (_n == 0 || p->error_indicator) {
@@ -21065,14 +20900,14 @@ _loop1_89_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq);
D(p->level--);
return _seq;
}
-// _loop1_90: ('or' conjunction)
+// _loop1_88: ('or' conjunction)
static asdl_seq *
-_loop1_90_rule(Parser *p)
+_loop1_88_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21096,13 +20931,13 @@ _loop1_90_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)"));
- void *_tmp_145_var;
+ D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)"));
+ void *_tmp_143_var;
while (
- (_tmp_145_var = _tmp_145_rule(p)) // 'or' conjunction
+ (_tmp_143_var = _tmp_143_rule(p)) // 'or' conjunction
)
{
- _res = _tmp_145_var;
+ _res = _tmp_143_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -21118,7 +20953,7 @@ _loop1_90_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_90[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)"));
}
if (_n == 0 || p->error_indicator) {
@@ -21136,14 +20971,14 @@ _loop1_90_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq);
D(p->level--);
return _seq;
}
-// _loop1_91: ('and' inversion)
+// _loop1_89: ('and' inversion)
static asdl_seq *
-_loop1_91_rule(Parser *p)
+_loop1_89_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21167,13 +21002,13 @@ _loop1_91_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)"));
- void *_tmp_146_var;
+ D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)"));
+ void *_tmp_144_var;
while (
- (_tmp_146_var = _tmp_146_rule(p)) // 'and' inversion
+ (_tmp_144_var = _tmp_144_rule(p)) // 'and' inversion
)
{
- _res = _tmp_146_var;
+ _res = _tmp_144_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -21189,7 +21024,7 @@ _loop1_91_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)"));
}
if (_n == 0 || p->error_indicator) {
@@ -21207,14 +21042,14 @@ _loop1_91_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq);
D(p->level--);
return _seq;
}
-// _loop1_92: compare_op_bitwise_or_pair
+// _loop1_90: compare_op_bitwise_or_pair
static asdl_seq *
-_loop1_92_rule(Parser *p)
+_loop1_90_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21238,7 +21073,7 @@ _loop1_92_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair"));
+ D(fprintf(stderr, "%*c> _loop1_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair"));
CmpopExprPair* compare_op_bitwise_or_pair_var;
while (
(compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair
@@ -21260,7 +21095,7 @@ _loop1_92_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_92[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_90[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair"));
}
if (_n == 0 || p->error_indicator) {
@@ -21278,14 +21113,14 @@ _loop1_92_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_92_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq);
D(p->level--);
return _seq;
}
-// _tmp_93: '!='
+// _tmp_91: '!='
static void *
-_tmp_93_rule(Parser *p)
+_tmp_91_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21299,13 +21134,13 @@ _tmp_93_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='"));
+ D(fprintf(stderr, "%*c> _tmp_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='"));
Token * tok;
if (
(tok = _PyPegen_expect_token(p, 28)) // token='!='
)
{
- D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='"));
+ D(fprintf(stderr, "%*c+ _tmp_91[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='"));
_res = _PyPegen_check_barry_as_flufl ( p , tok ) ? NULL : tok;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -21315,7 +21150,7 @@ _tmp_93_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_91[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='"));
}
_res = NULL;
@@ -21324,9 +21159,9 @@ _tmp_93_rule(Parser *p)
return _res;
}
-// _loop0_95: ',' slice
+// _loop0_93: ',' slice
static asdl_seq *
-_loop0_95_rule(Parser *p)
+_loop0_93_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21350,7 +21185,7 @@ _loop0_95_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice"));
+ D(fprintf(stderr, "%*c> _loop0_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice"));
Token * _literal;
expr_ty elem;
while (
@@ -21381,7 +21216,7 @@ _loop0_95_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_95[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_93[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -21394,14 +21229,14 @@ _loop0_95_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_95_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_93_type, _seq);
D(p->level--);
return _seq;
}
-// _gather_94: slice _loop0_95
+// _gather_92: slice _loop0_93
static asdl_seq *
-_gather_94_rule(Parser *p)
+_gather_92_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21410,27 +21245,27 @@ _gather_94_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // slice _loop0_95
+ { // slice _loop0_93
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_95"));
+ D(fprintf(stderr, "%*c> _gather_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_93"));
expr_ty elem;
asdl_seq * seq;
if (
(elem = slice_rule(p)) // slice
&&
- (seq = _loop0_95_rule(p)) // _loop0_95
+ (seq = _loop0_93_rule(p)) // _loop0_93
)
{
- D(fprintf(stderr, "%*c+ _gather_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_95"));
+ D(fprintf(stderr, "%*c+ _gather_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_93"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_94[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_95"));
+ D(fprintf(stderr, "%*c%s _gather_92[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_93"));
}
_res = NULL;
done:
@@ -21438,9 +21273,9 @@ _gather_94_rule(Parser *p)
return _res;
}
-// _tmp_96: ':' expression?
+// _tmp_94: ':' expression?
static void *
-_tmp_96_rule(Parser *p)
+_tmp_94_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21454,7 +21289,7 @@ _tmp_96_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?"));
+ D(fprintf(stderr, "%*c> _tmp_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?"));
Token * _literal;
void *d;
if (
@@ -21463,7 +21298,7 @@ _tmp_96_rule(Parser *p)
(d = expression_rule(p), 1) // expression?
)
{
- D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?"));
+ D(fprintf(stderr, "%*c+ _tmp_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?"));
_res = d;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -21473,7 +21308,7 @@ _tmp_96_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_94[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?"));
}
_res = NULL;
@@ -21482,9 +21317,9 @@ _tmp_96_rule(Parser *p)
return _res;
}
-// _tmp_97: tuple | group | genexp
+// _tmp_95: tuple | group | genexp
static void *
-_tmp_97_rule(Parser *p)
+_tmp_95_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21498,18 +21333,18 @@ _tmp_97_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple"));
+ D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple"));
expr_ty tuple_var;
if (
(tuple_var = tuple_rule(p)) // tuple
)
{
- D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple"));
+ D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple"));
_res = tuple_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple"));
}
{ // group
@@ -21517,18 +21352,18 @@ _tmp_97_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group"));
+ D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group"));
expr_ty group_var;
if (
(group_var = group_rule(p)) // group
)
{
- D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group"));
+ D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group"));
_res = group_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group"));
}
{ // genexp
@@ -21536,18 +21371,18 @@ _tmp_97_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp"));
+ D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp"));
expr_ty genexp_var;
if (
(genexp_var = genexp_rule(p)) // genexp
)
{
- D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp"));
+ D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp"));
_res = genexp_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp"));
}
_res = NULL;
@@ -21556,9 +21391,9 @@ _tmp_97_rule(Parser *p)
return _res;
}
-// _tmp_98: list | listcomp
+// _tmp_96: list | listcomp
static void *
-_tmp_98_rule(Parser *p)
+_tmp_96_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21572,18 +21407,18 @@ _tmp_98_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list"));
+ D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list"));
expr_ty list_var;
if (
(list_var = list_rule(p)) // list
)
{
- D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list"));
+ D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list"));
_res = list_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list"));
}
{ // listcomp
@@ -21591,18 +21426,18 @@ _tmp_98_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp"));
+ D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp"));
expr_ty listcomp_var;
if (
(listcomp_var = listcomp_rule(p)) // listcomp
)
{
- D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp"));
+ D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp"));
_res = listcomp_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp"));
}
_res = NULL;
@@ -21611,9 +21446,9 @@ _tmp_98_rule(Parser *p)
return _res;
}
-// _tmp_99: dict | set | dictcomp | setcomp
+// _tmp_97: dict | set | dictcomp | setcomp
static void *
-_tmp_99_rule(Parser *p)
+_tmp_97_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21627,18 +21462,18 @@ _tmp_99_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict"));
+ D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict"));
expr_ty dict_var;
if (
(dict_var = dict_rule(p)) // dict
)
{
- D(fprintf(stderr, "%*c+ _tmp_99[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict"));
+ D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict"));
_res = dict_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_99[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict"));
}
{ // set
@@ -21646,18 +21481,18 @@ _tmp_99_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set"));
+ D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set"));
expr_ty set_var;
if (
(set_var = set_rule(p)) // set
)
{
- D(fprintf(stderr, "%*c+ _tmp_99[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set"));
+ D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set"));
_res = set_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_99[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set"));
}
{ // dictcomp
@@ -21665,18 +21500,18 @@ _tmp_99_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp"));
+ D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp"));
expr_ty dictcomp_var;
if (
(dictcomp_var = dictcomp_rule(p)) // dictcomp
)
{
- D(fprintf(stderr, "%*c+ _tmp_99[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp"));
+ D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp"));
_res = dictcomp_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_99[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp"));
}
{ // setcomp
@@ -21684,18 +21519,18 @@ _tmp_99_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp"));
+ D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp"));
expr_ty setcomp_var;
if (
(setcomp_var = setcomp_rule(p)) // setcomp
)
{
- D(fprintf(stderr, "%*c+ _tmp_99[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp"));
+ D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp"));
_res = setcomp_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_99[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp"));
}
_res = NULL;
@@ -21704,9 +21539,9 @@ _tmp_99_rule(Parser *p)
return _res;
}
-// _loop1_100: STRING
+// _loop1_98: STRING
static asdl_seq *
-_loop1_100_rule(Parser *p)
+_loop1_98_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21730,7 +21565,7 @@ _loop1_100_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING"));
+ D(fprintf(stderr, "%*c> _loop1_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING"));
expr_ty string_var;
while (
(string_var = _PyPegen_string_token(p)) // STRING
@@ -21752,7 +21587,7 @@ _loop1_100_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_100[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_98[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING"));
}
if (_n == 0 || p->error_indicator) {
@@ -21770,14 +21605,14 @@ _loop1_100_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_100_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_98_type, _seq);
D(p->level--);
return _seq;
}
-// _tmp_101: star_named_expression ',' star_named_expressions?
+// _tmp_99: star_named_expression ',' star_named_expressions?
static void *
-_tmp_101_rule(Parser *p)
+_tmp_99_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21791,7 +21626,7 @@ _tmp_101_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?"));
+ D(fprintf(stderr, "%*c> _tmp_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?"));
Token * _literal;
expr_ty y;
void *z;
@@ -21803,7 +21638,7 @@ _tmp_101_rule(Parser *p)
(z = star_named_expressions_rule(p), 1) // star_named_expressions?
)
{
- D(fprintf(stderr, "%*c+ _tmp_101[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?"));
+ D(fprintf(stderr, "%*c+ _tmp_99[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?"));
_res = _PyPegen_seq_insert_in_front ( p , y , z );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -21813,7 +21648,7 @@ _tmp_101_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_101[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_99[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?"));
}
_res = NULL;
@@ -21822,9 +21657,9 @@ _tmp_101_rule(Parser *p)
return _res;
}
-// _tmp_102: yield_expr | named_expression
+// _tmp_100: yield_expr | named_expression
static void *
-_tmp_102_rule(Parser *p)
+_tmp_100_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21838,18 +21673,18 @@ _tmp_102_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ D(fprintf(stderr, "%*c> _tmp_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
expr_ty yield_expr_var;
if (
(yield_expr_var = yield_expr_rule(p)) // yield_expr
)
{
- D(fprintf(stderr, "%*c+ _tmp_102[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ D(fprintf(stderr, "%*c+ _tmp_100[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
_res = yield_expr_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_102[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_100[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
}
{ // named_expression
@@ -21857,18 +21692,18 @@ _tmp_102_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression"));
+ D(fprintf(stderr, "%*c> _tmp_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression"));
expr_ty named_expression_var;
if (
(named_expression_var = named_expression_rule(p)) // named_expression
)
{
- D(fprintf(stderr, "%*c+ _tmp_102[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression"));
+ D(fprintf(stderr, "%*c+ _tmp_100[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression"));
_res = named_expression_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_102[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_100[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression"));
}
_res = NULL;
@@ -21877,9 +21712,9 @@ _tmp_102_rule(Parser *p)
return _res;
}
-// _loop0_104: ',' double_starred_kvpair
+// _loop0_102: ',' double_starred_kvpair
static asdl_seq *
-_loop0_104_rule(Parser *p)
+_loop0_102_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21903,7 +21738,7 @@ _loop0_104_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair"));
+ D(fprintf(stderr, "%*c> _loop0_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair"));
Token * _literal;
KeyValuePair* elem;
while (
@@ -21934,7 +21769,7 @@ _loop0_104_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_102[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -21947,14 +21782,14 @@ _loop0_104_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_104_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_102_type, _seq);
D(p->level--);
return _seq;
}
-// _gather_103: double_starred_kvpair _loop0_104
+// _gather_101: double_starred_kvpair _loop0_102
static asdl_seq *
-_gather_103_rule(Parser *p)
+_gather_101_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -21963,27 +21798,27 @@ _gather_103_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // double_starred_kvpair _loop0_104
+ { // double_starred_kvpair _loop0_102
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_104"));
+ D(fprintf(stderr, "%*c> _gather_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_102"));
KeyValuePair* elem;
asdl_seq * seq;
if (
(elem = double_starred_kvpair_rule(p)) // double_starred_kvpair
&&
- (seq = _loop0_104_rule(p)) // _loop0_104
+ (seq = _loop0_102_rule(p)) // _loop0_102
)
{
- D(fprintf(stderr, "%*c+ _gather_103[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_104"));
+ D(fprintf(stderr, "%*c+ _gather_101[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_102"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_103[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_104"));
+ D(fprintf(stderr, "%*c%s _gather_101[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_102"));
}
_res = NULL;
done:
@@ -21991,9 +21826,9 @@ _gather_103_rule(Parser *p)
return _res;
}
-// _loop1_105: for_if_clause
+// _loop1_103: for_if_clause
static asdl_seq *
-_loop1_105_rule(Parser *p)
+_loop1_103_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22017,7 +21852,7 @@ _loop1_105_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause"));
+ D(fprintf(stderr, "%*c> _loop1_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause"));
comprehension_ty for_if_clause_var;
while (
(for_if_clause_var = for_if_clause_rule(p)) // for_if_clause
@@ -22039,7 +21874,7 @@ _loop1_105_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_103[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause"));
}
if (_n == 0 || p->error_indicator) {
@@ -22057,14 +21892,14 @@ _loop1_105_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_103_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_106: ('if' disjunction)
+// _loop0_104: ('if' disjunction)
static asdl_seq *
-_loop0_106_rule(Parser *p)
+_loop0_104_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22088,13 +21923,13 @@ _loop0_106_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)"));
- void *_tmp_147_var;
+ D(fprintf(stderr, "%*c> _loop0_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)"));
+ void *_tmp_145_var;
while (
- (_tmp_147_var = _tmp_147_rule(p)) // 'if' disjunction
+ (_tmp_145_var = _tmp_145_rule(p)) // 'if' disjunction
)
{
- _res = _tmp_147_var;
+ _res = _tmp_145_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -22110,7 +21945,7 @@ _loop0_106_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_106[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -22123,14 +21958,14 @@ _loop0_106_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_106_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_104_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_107: ('if' disjunction)
+// _loop0_105: ('if' disjunction)
static asdl_seq *
-_loop0_107_rule(Parser *p)
+_loop0_105_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22154,13 +21989,13 @@ _loop0_107_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)"));
- void *_tmp_148_var;
+ D(fprintf(stderr, "%*c> _loop0_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)"));
+ void *_tmp_146_var;
while (
- (_tmp_148_var = _tmp_148_rule(p)) // 'if' disjunction
+ (_tmp_146_var = _tmp_146_rule(p)) // 'if' disjunction
)
{
- _res = _tmp_148_var;
+ _res = _tmp_146_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -22176,7 +22011,7 @@ _loop0_107_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_107[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_105[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -22189,14 +22024,14 @@ _loop0_107_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_107_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_105_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_109: ',' (starred_expression | named_expression !'=')
+// _loop0_107: ',' (starred_expression | named_expression !'=')
static asdl_seq *
-_loop0_109_rule(Parser *p)
+_loop0_107_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22220,13 +22055,13 @@ _loop0_109_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | named_expression !'=')"));
+ D(fprintf(stderr, "%*c> _loop0_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | named_expression !'=')"));
Token * _literal;
void *elem;
while (
(_literal = _PyPegen_expect_token(p, 12)) // token=','
&&
- (elem = _tmp_149_rule(p)) // starred_expression | named_expression !'='
+ (elem = _tmp_147_rule(p)) // starred_expression | named_expression !'='
)
{
_res = elem;
@@ -22251,7 +22086,7 @@ _loop0_109_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_109[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_107[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (starred_expression | named_expression !'=')"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -22264,14 +22099,14 @@ _loop0_109_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_109_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_107_type, _seq);
D(p->level--);
return _seq;
}
-// _gather_108: (starred_expression | named_expression !'=') _loop0_109
+// _gather_106: (starred_expression | named_expression !'=') _loop0_107
static asdl_seq *
-_gather_108_rule(Parser *p)
+_gather_106_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22280,27 +22115,27 @@ _gather_108_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // (starred_expression | named_expression !'=') _loop0_109
+ { // (starred_expression | named_expression !'=') _loop0_107
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_109"));
+ D(fprintf(stderr, "%*c> _gather_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_107"));
void *elem;
asdl_seq * seq;
if (
- (elem = _tmp_149_rule(p)) // starred_expression | named_expression !'='
+ (elem = _tmp_147_rule(p)) // starred_expression | named_expression !'='
&&
- (seq = _loop0_109_rule(p)) // _loop0_109
+ (seq = _loop0_107_rule(p)) // _loop0_107
)
{
- D(fprintf(stderr, "%*c+ _gather_108[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_109"));
+ D(fprintf(stderr, "%*c+ _gather_106[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_107"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_108[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_109"));
+ D(fprintf(stderr, "%*c%s _gather_106[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_107"));
}
_res = NULL;
done:
@@ -22308,9 +22143,9 @@ _gather_108_rule(Parser *p)
return _res;
}
-// _tmp_110: ',' kwargs
+// _tmp_108: ',' kwargs
static void *
-_tmp_110_rule(Parser *p)
+_tmp_108_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22324,7 +22159,7 @@ _tmp_110_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs"));
+ D(fprintf(stderr, "%*c> _tmp_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs"));
Token * _literal;
asdl_seq* k;
if (
@@ -22333,7 +22168,7 @@ _tmp_110_rule(Parser *p)
(k = kwargs_rule(p)) // kwargs
)
{
- D(fprintf(stderr, "%*c+ _tmp_110[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs"));
+ D(fprintf(stderr, "%*c+ _tmp_108[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs"));
_res = k;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -22343,7 +22178,7 @@ _tmp_110_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_110[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_108[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwargs"));
}
_res = NULL;
@@ -22352,9 +22187,9 @@ _tmp_110_rule(Parser *p)
return _res;
}
-// _loop0_112: ',' kwarg_or_starred
+// _loop0_110: ',' kwarg_or_starred
static asdl_seq *
-_loop0_112_rule(Parser *p)
+_loop0_110_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22378,7 +22213,7 @@ _loop0_112_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred"));
+ D(fprintf(stderr, "%*c> _loop0_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred"));
Token * _literal;
KeywordOrStarred* elem;
while (
@@ -22409,7 +22244,7 @@ _loop0_112_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -22422,14 +22257,14 @@ _loop0_112_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq);
D(p->level--);
return _seq;
}
-// _gather_111: kwarg_or_starred _loop0_112
+// _gather_109: kwarg_or_starred _loop0_110
static asdl_seq *
-_gather_111_rule(Parser *p)
+_gather_109_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22438,27 +22273,27 @@ _gather_111_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // kwarg_or_starred _loop0_112
+ { // kwarg_or_starred _loop0_110
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_112"));
+ D(fprintf(stderr, "%*c> _gather_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_110"));
KeywordOrStarred* elem;
asdl_seq * seq;
if (
(elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
&&
- (seq = _loop0_112_rule(p)) // _loop0_112
+ (seq = _loop0_110_rule(p)) // _loop0_110
)
{
- D(fprintf(stderr, "%*c+ _gather_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_112"));
+ D(fprintf(stderr, "%*c+ _gather_109[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_110"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_111[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_112"));
+ D(fprintf(stderr, "%*c%s _gather_109[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_110"));
}
_res = NULL;
done:
@@ -22466,9 +22301,9 @@ _gather_111_rule(Parser *p)
return _res;
}
-// _loop0_114: ',' kwarg_or_double_starred
+// _loop0_112: ',' kwarg_or_double_starred
static asdl_seq *
-_loop0_114_rule(Parser *p)
+_loop0_112_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22492,7 +22327,7 @@ _loop0_114_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred"));
+ D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred"));
Token * _literal;
KeywordOrStarred* elem;
while (
@@ -22523,7 +22358,7 @@ _loop0_114_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_114[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -22536,14 +22371,14 @@ _loop0_114_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_114_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq);
D(p->level--);
return _seq;
}
-// _gather_113: kwarg_or_double_starred _loop0_114
+// _gather_111: kwarg_or_double_starred _loop0_112
static asdl_seq *
-_gather_113_rule(Parser *p)
+_gather_111_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22552,27 +22387,27 @@ _gather_113_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // kwarg_or_double_starred _loop0_114
+ { // kwarg_or_double_starred _loop0_112
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_114"));
+ D(fprintf(stderr, "%*c> _gather_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_112"));
KeywordOrStarred* elem;
asdl_seq * seq;
if (
(elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
&&
- (seq = _loop0_114_rule(p)) // _loop0_114
+ (seq = _loop0_112_rule(p)) // _loop0_112
)
{
- D(fprintf(stderr, "%*c+ _gather_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_114"));
+ D(fprintf(stderr, "%*c+ _gather_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_112"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_113[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_114"));
+ D(fprintf(stderr, "%*c%s _gather_111[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_112"));
}
_res = NULL;
done:
@@ -22580,9 +22415,9 @@ _gather_113_rule(Parser *p)
return _res;
}
-// _loop0_116: ',' kwarg_or_starred
+// _loop0_114: ',' kwarg_or_starred
static asdl_seq *
-_loop0_116_rule(Parser *p)
+_loop0_114_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22606,7 +22441,7 @@ _loop0_116_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred"));
+ D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred"));
Token * _literal;
KeywordOrStarred* elem;
while (
@@ -22637,7 +22472,7 @@ _loop0_116_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_116[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_114[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -22650,14 +22485,14 @@ _loop0_116_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_116_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_114_type, _seq);
D(p->level--);
return _seq;
}
-// _gather_115: kwarg_or_starred _loop0_116
+// _gather_113: kwarg_or_starred _loop0_114
static asdl_seq *
-_gather_115_rule(Parser *p)
+_gather_113_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22666,27 +22501,27 @@ _gather_115_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // kwarg_or_starred _loop0_116
+ { // kwarg_or_starred _loop0_114
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_116"));
+ D(fprintf(stderr, "%*c> _gather_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_114"));
KeywordOrStarred* elem;
asdl_seq * seq;
if (
(elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
&&
- (seq = _loop0_116_rule(p)) // _loop0_116
+ (seq = _loop0_114_rule(p)) // _loop0_114
)
{
- D(fprintf(stderr, "%*c+ _gather_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_116"));
+ D(fprintf(stderr, "%*c+ _gather_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_114"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_115[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_116"));
+ D(fprintf(stderr, "%*c%s _gather_113[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_114"));
}
_res = NULL;
done:
@@ -22694,9 +22529,9 @@ _gather_115_rule(Parser *p)
return _res;
}
-// _loop0_118: ',' kwarg_or_double_starred
+// _loop0_116: ',' kwarg_or_double_starred
static asdl_seq *
-_loop0_118_rule(Parser *p)
+_loop0_116_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22720,7 +22555,7 @@ _loop0_118_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred"));
+ D(fprintf(stderr, "%*c> _loop0_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred"));
Token * _literal;
KeywordOrStarred* elem;
while (
@@ -22751,7 +22586,7 @@ _loop0_118_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_118[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_116[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -22764,14 +22599,14 @@ _loop0_118_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_118_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_116_type, _seq);
D(p->level--);
return _seq;
}
-// _gather_117: kwarg_or_double_starred _loop0_118
+// _gather_115: kwarg_or_double_starred _loop0_116
static asdl_seq *
-_gather_117_rule(Parser *p)
+_gather_115_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22780,27 +22615,27 @@ _gather_117_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // kwarg_or_double_starred _loop0_118
+ { // kwarg_or_double_starred _loop0_116
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_118"));
+ D(fprintf(stderr, "%*c> _gather_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_116"));
KeywordOrStarred* elem;
asdl_seq * seq;
if (
(elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
&&
- (seq = _loop0_118_rule(p)) // _loop0_118
+ (seq = _loop0_116_rule(p)) // _loop0_116
)
{
- D(fprintf(stderr, "%*c+ _gather_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_118"));
+ D(fprintf(stderr, "%*c+ _gather_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_116"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_117[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_118"));
+ D(fprintf(stderr, "%*c%s _gather_115[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_116"));
}
_res = NULL;
done:
@@ -22808,9 +22643,9 @@ _gather_117_rule(Parser *p)
return _res;
}
-// _loop0_119: (',' star_target)
+// _loop0_117: (',' star_target)
static asdl_seq *
-_loop0_119_rule(Parser *p)
+_loop0_117_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22834,13 +22669,13 @@ _loop0_119_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)"));
- void *_tmp_150_var;
+ D(fprintf(stderr, "%*c> _loop0_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)"));
+ void *_tmp_148_var;
while (
- (_tmp_150_var = _tmp_150_rule(p)) // ',' star_target
+ (_tmp_148_var = _tmp_148_rule(p)) // ',' star_target
)
{
- _res = _tmp_150_var;
+ _res = _tmp_148_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -22856,7 +22691,7 @@ _loop0_119_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_117[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -22869,14 +22704,14 @@ _loop0_119_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_117_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_121: ',' star_target
+// _loop0_119: ',' star_target
static asdl_seq *
-_loop0_121_rule(Parser *p)
+_loop0_119_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22900,7 +22735,7 @@ _loop0_121_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target"));
+ D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target"));
Token * _literal;
expr_ty elem;
while (
@@ -22931,7 +22766,7 @@ _loop0_121_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_121[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -22944,14 +22779,14 @@ _loop0_121_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_121_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq);
D(p->level--);
return _seq;
}
-// _gather_120: star_target _loop0_121
+// _gather_118: star_target _loop0_119
static asdl_seq *
-_gather_120_rule(Parser *p)
+_gather_118_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -22960,27 +22795,27 @@ _gather_120_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // star_target _loop0_121
+ { // star_target _loop0_119
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_121"));
+ D(fprintf(stderr, "%*c> _gather_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_119"));
expr_ty elem;
asdl_seq * seq;
if (
(elem = star_target_rule(p)) // star_target
&&
- (seq = _loop0_121_rule(p)) // _loop0_121
+ (seq = _loop0_119_rule(p)) // _loop0_119
)
{
- D(fprintf(stderr, "%*c+ _gather_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_121"));
+ D(fprintf(stderr, "%*c+ _gather_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_119"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_120[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_121"));
+ D(fprintf(stderr, "%*c%s _gather_118[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_119"));
}
_res = NULL;
done:
@@ -22988,9 +22823,9 @@ _gather_120_rule(Parser *p)
return _res;
}
-// _tmp_122: !'*' star_target
+// _tmp_120: !'*' star_target
static void *
-_tmp_122_rule(Parser *p)
+_tmp_120_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23004,7 +22839,7 @@ _tmp_122_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target"));
+ D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target"));
expr_ty star_target_var;
if (
_PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*'
@@ -23012,12 +22847,12 @@ _tmp_122_rule(Parser *p)
(star_target_var = star_target_rule(p)) // star_target
)
{
- D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target"));
+ D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target"));
_res = star_target_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target"));
}
_res = NULL;
@@ -23026,9 +22861,9 @@ _tmp_122_rule(Parser *p)
return _res;
}
-// _loop0_124: ',' del_target
+// _loop0_122: ',' del_target
static asdl_seq *
-_loop0_124_rule(Parser *p)
+_loop0_122_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23052,7 +22887,7 @@ _loop0_124_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target"));
+ D(fprintf(stderr, "%*c> _loop0_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target"));
Token * _literal;
expr_ty elem;
while (
@@ -23083,7 +22918,7 @@ _loop0_124_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_124[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_122[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -23096,14 +22931,14 @@ _loop0_124_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_124_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_122_type, _seq);
D(p->level--);
return _seq;
}
-// _gather_123: del_target _loop0_124
+// _gather_121: del_target _loop0_122
static asdl_seq *
-_gather_123_rule(Parser *p)
+_gather_121_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23112,27 +22947,27 @@ _gather_123_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // del_target _loop0_124
+ { // del_target _loop0_122
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_124"));
+ D(fprintf(stderr, "%*c> _gather_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_122"));
expr_ty elem;
asdl_seq * seq;
if (
(elem = del_target_rule(p)) // del_target
&&
- (seq = _loop0_124_rule(p)) // _loop0_124
+ (seq = _loop0_122_rule(p)) // _loop0_122
)
{
- D(fprintf(stderr, "%*c+ _gather_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_124"));
+ D(fprintf(stderr, "%*c+ _gather_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_122"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_123[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_124"));
+ D(fprintf(stderr, "%*c%s _gather_121[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_122"));
}
_res = NULL;
done:
@@ -23140,9 +22975,9 @@ _gather_123_rule(Parser *p)
return _res;
}
-// _loop0_126: ',' target
+// _loop0_124: ',' target
static asdl_seq *
-_loop0_126_rule(Parser *p)
+_loop0_124_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23166,7 +23001,7 @@ _loop0_126_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target"));
+ D(fprintf(stderr, "%*c> _loop0_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target"));
Token * _literal;
expr_ty elem;
while (
@@ -23197,7 +23032,7 @@ _loop0_126_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_126[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_124[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -23210,14 +23045,14 @@ _loop0_126_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_124_type, _seq);
D(p->level--);
return _seq;
}
-// _gather_125: target _loop0_126
+// _gather_123: target _loop0_124
static asdl_seq *
-_gather_125_rule(Parser *p)
+_gather_123_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23226,27 +23061,27 @@ _gather_125_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // target _loop0_126
+ { // target _loop0_124
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_126"));
+ D(fprintf(stderr, "%*c> _gather_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_124"));
expr_ty elem;
asdl_seq * seq;
if (
(elem = target_rule(p)) // target
&&
- (seq = _loop0_126_rule(p)) // _loop0_126
+ (seq = _loop0_124_rule(p)) // _loop0_124
)
{
- D(fprintf(stderr, "%*c+ _gather_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_126"));
+ D(fprintf(stderr, "%*c+ _gather_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_124"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_125[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_126"));
+ D(fprintf(stderr, "%*c%s _gather_123[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_124"));
}
_res = NULL;
done:
@@ -23254,9 +23089,9 @@ _gather_125_rule(Parser *p)
return _res;
}
-// _tmp_127: args | expression for_if_clauses
+// _tmp_125: args | expression for_if_clauses
static void *
-_tmp_127_rule(Parser *p)
+_tmp_125_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23270,18 +23105,18 @@ _tmp_127_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args"));
+ D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args"));
expr_ty args_var;
if (
(args_var = args_rule(p)) // args
)
{
- D(fprintf(stderr, "%*c+ _tmp_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args"));
+ D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args"));
_res = args_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_127[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args"));
}
{ // expression for_if_clauses
@@ -23289,7 +23124,7 @@ _tmp_127_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses"));
+ D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses"));
expr_ty expression_var;
asdl_comprehension_seq* for_if_clauses_var;
if (
@@ -23298,12 +23133,12 @@ _tmp_127_rule(Parser *p)
(for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
)
{
- D(fprintf(stderr, "%*c+ _tmp_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses"));
+ D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses"));
_res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_127[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses"));
}
_res = NULL;
@@ -23312,9 +23147,9 @@ _tmp_127_rule(Parser *p)
return _res;
}
-// _loop0_128: star_named_expressions
+// _loop0_126: star_named_expressions
static asdl_seq *
-_loop0_128_rule(Parser *p)
+_loop0_126_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23338,7 +23173,7 @@ _loop0_128_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions"));
+ D(fprintf(stderr, "%*c> _loop0_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions"));
asdl_expr_seq* star_named_expressions_var;
while (
(star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions
@@ -23360,7 +23195,7 @@ _loop0_128_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_126[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -23373,14 +23208,14 @@ _loop0_128_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_128_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_129: (star_targets '=')
+// _loop0_127: (star_targets '=')
static asdl_seq *
-_loop0_129_rule(Parser *p)
+_loop0_127_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23404,13 +23239,13 @@ _loop0_129_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')"));
- void *_tmp_151_var;
+ D(fprintf(stderr, "%*c> _loop0_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')"));
+ void *_tmp_149_var;
while (
- (_tmp_151_var = _tmp_151_rule(p)) // star_targets '='
+ (_tmp_149_var = _tmp_149_rule(p)) // star_targets '='
)
{
- _res = _tmp_151_var;
+ _res = _tmp_149_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -23426,7 +23261,7 @@ _loop0_129_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_129[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_127[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -23439,14 +23274,14 @@ _loop0_129_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_129_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_127_type, _seq);
D(p->level--);
return _seq;
}
-// _loop0_130: (star_targets '=')
+// _loop0_128: (star_targets '=')
static asdl_seq *
-_loop0_130_rule(Parser *p)
+_loop0_128_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23470,13 +23305,13 @@ _loop0_130_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')"));
- void *_tmp_152_var;
+ D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')"));
+ void *_tmp_150_var;
while (
- (_tmp_152_var = _tmp_152_rule(p)) // star_targets '='
+ (_tmp_150_var = _tmp_150_rule(p)) // star_targets '='
)
{
- _res = _tmp_152_var;
+ _res = _tmp_150_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -23492,7 +23327,7 @@ _loop0_130_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -23505,14 +23340,14 @@ _loop0_130_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_128_type, _seq);
D(p->level--);
return _seq;
}
-// _tmp_131: yield_expr | star_expressions
+// _tmp_129: yield_expr | star_expressions
static void *
-_tmp_131_rule(Parser *p)
+_tmp_129_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23526,18 +23361,18 @@ _tmp_131_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
expr_ty yield_expr_var;
if (
(yield_expr_var = yield_expr_rule(p)) // yield_expr
)
{
- D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
_res = yield_expr_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
}
{ // star_expressions
@@ -23545,18 +23380,18 @@ _tmp_131_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
expr_ty star_expressions_var;
if (
(star_expressions_var = star_expressions_rule(p)) // star_expressions
)
{
- D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
_res = star_expressions_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
}
_res = NULL;
@@ -23565,9 +23400,9 @@ _tmp_131_rule(Parser *p)
return _res;
}
-// _tmp_132: '[' | '(' | '{'
+// _tmp_130: '[' | '(' | '{'
static void *
-_tmp_132_rule(Parser *p)
+_tmp_130_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23581,18 +23416,18 @@ _tmp_132_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['"));
+ D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 9)) // token='['
)
{
- D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['"));
+ D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['"));
}
{ // '('
@@ -23600,18 +23435,18 @@ _tmp_132_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('"));
+ D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 7)) // token='('
)
{
- D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('"));
+ D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('"));
}
{ // '{'
@@ -23619,18 +23454,18 @@ _tmp_132_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'"));
+ D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 25)) // token='{'
)
{
- D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'"));
+ D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'"));
}
_res = NULL;
@@ -23639,9 +23474,9 @@ _tmp_132_rule(Parser *p)
return _res;
}
-// _loop0_133: param_no_default
+// _loop0_131: param_no_default
static asdl_seq *
-_loop0_133_rule(Parser *p)
+_loop0_131_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23665,7 +23500,7 @@ _loop0_133_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
+ D(fprintf(stderr, "%*c> _loop0_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
arg_ty param_no_default_var;
while (
(param_no_default_var = param_no_default_rule(p)) // param_no_default
@@ -23687,7 +23522,7 @@ _loop0_133_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_133[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_131[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -23700,14 +23535,14 @@ _loop0_133_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_133_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_131_type, _seq);
D(p->level--);
return _seq;
}
-// _tmp_134: slash_with_default | param_with_default+
+// _tmp_132: slash_with_default | param_with_default+
static void *
-_tmp_134_rule(Parser *p)
+_tmp_132_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23721,18 +23556,18 @@ _tmp_134_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default"));
+ D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default"));
SlashWithDefault* slash_with_default_var;
if (
(slash_with_default_var = slash_with_default_rule(p)) // slash_with_default
)
{
- D(fprintf(stderr, "%*c+ _tmp_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default"));
+ D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default"));
_res = slash_with_default_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_134[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default"));
}
{ // param_with_default+
@@ -23740,18 +23575,18 @@ _tmp_134_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+"));
- asdl_seq * _loop1_153_var;
+ D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+"));
+ asdl_seq * _loop1_151_var;
if (
- (_loop1_153_var = _loop1_153_rule(p)) // param_with_default+
+ (_loop1_151_var = _loop1_151_rule(p)) // param_with_default+
)
{
- D(fprintf(stderr, "%*c+ _tmp_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+"));
- _res = _loop1_153_var;
+ D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+"));
+ _res = _loop1_151_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_134[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+"));
}
_res = NULL;
@@ -23760,9 +23595,9 @@ _tmp_134_rule(Parser *p)
return _res;
}
-// _loop0_135: lambda_param_no_default
+// _loop0_133: lambda_param_no_default
static asdl_seq *
-_loop0_135_rule(Parser *p)
+_loop0_133_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23786,7 +23621,7 @@ _loop0_135_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
arg_ty lambda_param_no_default_var;
while (
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
@@ -23808,7 +23643,7 @@ _loop0_135_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_135[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_133[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -23821,14 +23656,14 @@ _loop0_135_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_135_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_133_type, _seq);
D(p->level--);
return _seq;
}
-// _tmp_136: lambda_slash_with_default | lambda_param_with_default+
+// _tmp_134: lambda_slash_with_default | lambda_param_with_default+
static void *
-_tmp_136_rule(Parser *p)
+_tmp_134_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23842,18 +23677,18 @@ _tmp_136_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default"));
+ D(fprintf(stderr, "%*c> _tmp_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default"));
SlashWithDefault* lambda_slash_with_default_var;
if (
(lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default
)
{
- D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default"));
+ D(fprintf(stderr, "%*c+ _tmp_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default"));
_res = lambda_slash_with_default_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_134[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default"));
}
{ // lambda_param_with_default+
@@ -23861,18 +23696,18 @@ _tmp_136_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+"));
- asdl_seq * _loop1_154_var;
+ D(fprintf(stderr, "%*c> _tmp_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+"));
+ asdl_seq * _loop1_152_var;
if (
- (_loop1_154_var = _loop1_154_rule(p)) // lambda_param_with_default+
+ (_loop1_152_var = _loop1_152_rule(p)) // lambda_param_with_default+
)
{
- D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+"));
- _res = _loop1_154_var;
+ D(fprintf(stderr, "%*c+ _tmp_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+"));
+ _res = _loop1_152_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_134[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+"));
}
_res = NULL;
@@ -23881,9 +23716,9 @@ _tmp_136_rule(Parser *p)
return _res;
}
-// _tmp_137: ')' | ',' (')' | '**')
+// _tmp_135: ')' | ',' (')' | '**')
static void *
-_tmp_137_rule(Parser *p)
+_tmp_135_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23897,18 +23732,18 @@ _tmp_137_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'"));
+ D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 8)) // token=')'
)
{
- D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'"));
+ D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'"));
}
{ // ',' (')' | '**')
@@ -23916,21 +23751,21 @@ _tmp_137_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')"));
+ D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')"));
Token * _literal;
- void *_tmp_155_var;
+ void *_tmp_153_var;
if (
(_literal = _PyPegen_expect_token(p, 12)) // token=','
&&
- (_tmp_155_var = _tmp_155_rule(p)) // ')' | '**'
+ (_tmp_153_var = _tmp_153_rule(p)) // ')' | '**'
)
{
- D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')"));
- _res = _PyPegen_dummy_name(p, _literal, _tmp_155_var);
+ D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')"));
+ _res = _PyPegen_dummy_name(p, _literal, _tmp_153_var);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')"));
}
_res = NULL;
@@ -23939,9 +23774,9 @@ _tmp_137_rule(Parser *p)
return _res;
}
-// _tmp_138: ':' | ',' (':' | '**')
+// _tmp_136: ':' | ',' (':' | '**')
static void *
-_tmp_138_rule(Parser *p)
+_tmp_136_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -23955,18 +23790,18 @@ _tmp_138_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'"));
+ D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 11)) // token=':'
)
{
- D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'"));
+ D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_138[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'"));
}
{ // ',' (':' | '**')
@@ -23974,21 +23809,21 @@ _tmp_138_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')"));
+ D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')"));
Token * _literal;
- void *_tmp_156_var;
+ void *_tmp_154_var;
if (
(_literal = _PyPegen_expect_token(p, 12)) // token=','
&&
- (_tmp_156_var = _tmp_156_rule(p)) // ':' | '**'
+ (_tmp_154_var = _tmp_154_rule(p)) // ':' | '**'
)
{
- D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')"));
- _res = _PyPegen_dummy_name(p, _literal, _tmp_156_var);
+ D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')"));
+ _res = _PyPegen_dummy_name(p, _literal, _tmp_154_var);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_138[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')"));
}
_res = NULL;
@@ -23997,9 +23832,9 @@ _tmp_138_rule(Parser *p)
return _res;
}
-// _tmp_139: star_targets '='
+// _tmp_137: star_targets '='
static void *
-_tmp_139_rule(Parser *p)
+_tmp_137_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24013,7 +23848,7 @@ _tmp_139_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
+ D(fprintf(stderr, "%*c> _tmp_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
Token * _literal;
expr_ty z;
if (
@@ -24022,7 +23857,7 @@ _tmp_139_rule(Parser *p)
(_literal = _PyPegen_expect_token(p, 22)) // token='='
)
{
- D(fprintf(stderr, "%*c+ _tmp_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
+ D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
_res = z;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -24032,7 +23867,7 @@ _tmp_139_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_139[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='"));
}
_res = NULL;
@@ -24041,9 +23876,9 @@ _tmp_139_rule(Parser *p)
return _res;
}
-// _tmp_140: '.' | '...'
+// _tmp_138: '.' | '...'
static void *
-_tmp_140_rule(Parser *p)
+_tmp_138_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24057,18 +23892,18 @@ _tmp_140_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'"));
+ D(fprintf(stderr, "%*c> _tmp_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 23)) // token='.'
)
{
- D(fprintf(stderr, "%*c+ _tmp_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'"));
+ D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_140[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_138[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'"));
}
{ // '...'
@@ -24076,18 +23911,18 @@ _tmp_140_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'"));
+ D(fprintf(stderr, "%*c> _tmp_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 52)) // token='...'
)
{
- D(fprintf(stderr, "%*c+ _tmp_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'"));
+ D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_140[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_138[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'"));
}
_res = NULL;
@@ -24096,9 +23931,9 @@ _tmp_140_rule(Parser *p)
return _res;
}
-// _tmp_141: '.' | '...'
+// _tmp_139: '.' | '...'
static void *
-_tmp_141_rule(Parser *p)
+_tmp_139_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24112,18 +23947,18 @@ _tmp_141_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'"));
+ D(fprintf(stderr, "%*c> _tmp_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 23)) // token='.'
)
{
- D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'"));
+ D(fprintf(stderr, "%*c+ _tmp_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_139[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'"));
}
{ // '...'
@@ -24131,18 +23966,18 @@ _tmp_141_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'"));
+ D(fprintf(stderr, "%*c> _tmp_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 52)) // token='...'
)
{
- D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'"));
+ D(fprintf(stderr, "%*c+ _tmp_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_139[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'"));
}
_res = NULL;
@@ -24151,9 +23986,9 @@ _tmp_141_rule(Parser *p)
return _res;
}
-// _tmp_142: '@' named_expression NEWLINE
+// _tmp_140: '@' named_expression NEWLINE
static void *
-_tmp_142_rule(Parser *p)
+_tmp_140_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24167,7 +24002,7 @@ _tmp_142_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE"));
+ D(fprintf(stderr, "%*c> _tmp_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE"));
Token * _literal;
expr_ty f;
Token * newline_var;
@@ -24179,7 +24014,7 @@ _tmp_142_rule(Parser *p)
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
)
{
- D(fprintf(stderr, "%*c+ _tmp_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE"));
+ D(fprintf(stderr, "%*c+ _tmp_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE"));
_res = f;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -24189,7 +24024,7 @@ _tmp_142_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_142[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_140[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE"));
}
_res = NULL;
@@ -24198,9 +24033,9 @@ _tmp_142_rule(Parser *p)
return _res;
}
-// _tmp_143: ',' star_expression
+// _tmp_141: ',' star_expression
static void *
-_tmp_143_rule(Parser *p)
+_tmp_141_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24214,7 +24049,7 @@ _tmp_143_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression"));
+ D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression"));
Token * _literal;
expr_ty c;
if (
@@ -24223,7 +24058,7 @@ _tmp_143_rule(Parser *p)
(c = star_expression_rule(p)) // star_expression
)
{
- D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression"));
+ D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression"));
_res = c;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -24233,7 +24068,7 @@ _tmp_143_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression"));
}
_res = NULL;
@@ -24242,9 +24077,9 @@ _tmp_143_rule(Parser *p)
return _res;
}
-// _tmp_144: ',' expression
+// _tmp_142: ',' expression
static void *
-_tmp_144_rule(Parser *p)
+_tmp_142_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24258,7 +24093,7 @@ _tmp_144_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
+ D(fprintf(stderr, "%*c> _tmp_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
Token * _literal;
expr_ty c;
if (
@@ -24267,7 +24102,7 @@ _tmp_144_rule(Parser *p)
(c = expression_rule(p)) // expression
)
{
- D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression"));
+ D(fprintf(stderr, "%*c+ _tmp_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression"));
_res = c;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -24277,7 +24112,7 @@ _tmp_144_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_142[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
}
_res = NULL;
@@ -24286,9 +24121,9 @@ _tmp_144_rule(Parser *p)
return _res;
}
-// _tmp_145: 'or' conjunction
+// _tmp_143: 'or' conjunction
static void *
-_tmp_145_rule(Parser *p)
+_tmp_143_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24302,7 +24137,7 @@ _tmp_145_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction"));
+ D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction"));
Token * _keyword;
expr_ty c;
if (
@@ -24311,7 +24146,7 @@ _tmp_145_rule(Parser *p)
(c = conjunction_rule(p)) // conjunction
)
{
- D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction"));
+ D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction"));
_res = c;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -24321,7 +24156,7 @@ _tmp_145_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction"));
}
_res = NULL;
@@ -24330,9 +24165,9 @@ _tmp_145_rule(Parser *p)
return _res;
}
-// _tmp_146: 'and' inversion
+// _tmp_144: 'and' inversion
static void *
-_tmp_146_rule(Parser *p)
+_tmp_144_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24346,7 +24181,7 @@ _tmp_146_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion"));
+ D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion"));
Token * _keyword;
expr_ty c;
if (
@@ -24355,7 +24190,7 @@ _tmp_146_rule(Parser *p)
(c = inversion_rule(p)) // inversion
)
{
- D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion"));
+ D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion"));
_res = c;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -24365,7 +24200,7 @@ _tmp_146_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion"));
}
_res = NULL;
@@ -24374,9 +24209,9 @@ _tmp_146_rule(Parser *p)
return _res;
}
-// _tmp_147: 'if' disjunction
+// _tmp_145: 'if' disjunction
static void *
-_tmp_147_rule(Parser *p)
+_tmp_145_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24390,7 +24225,7 @@ _tmp_147_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
+ D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
Token * _keyword;
expr_ty z;
if (
@@ -24399,7 +24234,7 @@ _tmp_147_rule(Parser *p)
(z = disjunction_rule(p)) // disjunction
)
{
- D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
+ D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
_res = z;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -24409,7 +24244,7 @@ _tmp_147_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction"));
}
_res = NULL;
@@ -24418,9 +24253,9 @@ _tmp_147_rule(Parser *p)
return _res;
}
-// _tmp_148: 'if' disjunction
+// _tmp_146: 'if' disjunction
static void *
-_tmp_148_rule(Parser *p)
+_tmp_146_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24434,7 +24269,7 @@ _tmp_148_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
+ D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
Token * _keyword;
expr_ty z;
if (
@@ -24443,7 +24278,7 @@ _tmp_148_rule(Parser *p)
(z = disjunction_rule(p)) // disjunction
)
{
- D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
+ D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
_res = z;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -24453,7 +24288,7 @@ _tmp_148_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction"));
}
_res = NULL;
@@ -24462,9 +24297,9 @@ _tmp_148_rule(Parser *p)
return _res;
}
-// _tmp_149: starred_expression | named_expression !'='
+// _tmp_147: starred_expression | named_expression !'='
static void *
-_tmp_149_rule(Parser *p)
+_tmp_147_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24478,18 +24313,18 @@ _tmp_149_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression"));
+ D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression"));
expr_ty starred_expression_var;
if (
(starred_expression_var = starred_expression_rule(p)) // starred_expression
)
{
- D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression"));
+ D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression"));
_res = starred_expression_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression"));
}
{ // named_expression !'='
@@ -24497,7 +24332,7 @@ _tmp_149_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression !'='"));
+ D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression !'='"));
expr_ty named_expression_var;
if (
(named_expression_var = named_expression_rule(p)) // named_expression
@@ -24505,12 +24340,12 @@ _tmp_149_rule(Parser *p)
_PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='='
)
{
- D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression !'='"));
+ D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression !'='"));
_res = named_expression_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression !'='"));
}
_res = NULL;
@@ -24519,9 +24354,9 @@ _tmp_149_rule(Parser *p)
return _res;
}
-// _tmp_150: ',' star_target
+// _tmp_148: ',' star_target
static void *
-_tmp_150_rule(Parser *p)
+_tmp_148_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24535,7 +24370,7 @@ _tmp_150_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target"));
+ D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target"));
Token * _literal;
expr_ty c;
if (
@@ -24544,7 +24379,7 @@ _tmp_150_rule(Parser *p)
(c = star_target_rule(p)) // star_target
)
{
- D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target"));
+ D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target"));
_res = c;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -24554,7 +24389,7 @@ _tmp_150_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target"));
}
_res = NULL;
@@ -24563,9 +24398,9 @@ _tmp_150_rule(Parser *p)
return _res;
}
-// _tmp_151: star_targets '='
+// _tmp_149: star_targets '='
static void *
-_tmp_151_rule(Parser *p)
+_tmp_149_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24579,7 +24414,7 @@ _tmp_151_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
+ D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
Token * _literal;
expr_ty star_targets_var;
if (
@@ -24588,12 +24423,12 @@ _tmp_151_rule(Parser *p)
(_literal = _PyPegen_expect_token(p, 22)) // token='='
)
{
- D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
+ D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
_res = _PyPegen_dummy_name(p, star_targets_var, _literal);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='"));
}
_res = NULL;
@@ -24602,9 +24437,9 @@ _tmp_151_rule(Parser *p)
return _res;
}
-// _tmp_152: star_targets '='
+// _tmp_150: star_targets '='
static void *
-_tmp_152_rule(Parser *p)
+_tmp_150_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24618,7 +24453,7 @@ _tmp_152_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
+ D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
Token * _literal;
expr_ty star_targets_var;
if (
@@ -24627,12 +24462,12 @@ _tmp_152_rule(Parser *p)
(_literal = _PyPegen_expect_token(p, 22)) // token='='
)
{
- D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
+ D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
_res = _PyPegen_dummy_name(p, star_targets_var, _literal);
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='"));
}
_res = NULL;
@@ -24641,9 +24476,9 @@ _tmp_152_rule(Parser *p)
return _res;
}
-// _loop1_153: param_with_default
+// _loop1_151: param_with_default
static asdl_seq *
-_loop1_153_rule(Parser *p)
+_loop1_151_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24667,7 +24502,7 @@ _loop1_153_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
+ D(fprintf(stderr, "%*c> _loop1_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
NameDefaultPair* param_with_default_var;
while (
(param_with_default_var = param_with_default_rule(p)) // param_with_default
@@ -24689,7 +24524,7 @@ _loop1_153_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_153[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_151[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
}
if (_n == 0 || p->error_indicator) {
@@ -24707,14 +24542,14 @@ _loop1_153_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_153_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_151_type, _seq);
D(p->level--);
return _seq;
}
-// _loop1_154: lambda_param_with_default
+// _loop1_152: lambda_param_with_default
static asdl_seq *
-_loop1_154_rule(Parser *p)
+_loop1_152_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24738,7 +24573,7 @@ _loop1_154_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ D(fprintf(stderr, "%*c> _loop1_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
NameDefaultPair* lambda_param_with_default_var;
while (
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
@@ -24760,7 +24595,7 @@ _loop1_154_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_154[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop1_152[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
}
if (_n == 0 || p->error_indicator) {
@@ -24778,14 +24613,14 @@ _loop1_154_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_154_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_152_type, _seq);
D(p->level--);
return _seq;
}
-// _tmp_155: ')' | '**'
+// _tmp_153: ')' | '**'
static void *
-_tmp_155_rule(Parser *p)
+_tmp_153_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24799,18 +24634,18 @@ _tmp_155_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'"));
+ D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 8)) // token=')'
)
{
- D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'"));
+ D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'"));
}
{ // '**'
@@ -24818,18 +24653,18 @@ _tmp_155_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'"));
+ D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 35)) // token='**'
)
{
- D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'"));
+ D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'"));
}
_res = NULL;
@@ -24838,9 +24673,9 @@ _tmp_155_rule(Parser *p)
return _res;
}
-// _tmp_156: ':' | '**'
+// _tmp_154: ':' | '**'
static void *
-_tmp_156_rule(Parser *p)
+_tmp_154_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -24854,18 +24689,18 @@ _tmp_156_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'"));
+ D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 11)) // token=':'
)
{
- D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'"));
+ D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'"));
}
{ // '**'
@@ -24873,18 +24708,18 @@ _tmp_156_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'"));
+ D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'"));
Token * _literal;
if (
(_literal = _PyPegen_expect_token(p, 35)) // token='**'
)
{
- D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'"));
+ D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'"));
_res = _literal;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'"));
}
_res = NULL;
diff --git a/Parser/string_parser.c b/Parser/string_parser.c
index 1285968b31..09b8c35106 100644
--- a/Parser/string_parser.c
+++ b/Parser/string_parser.c
@@ -69,6 +69,9 @@ decode_unicode_with_escapes(Parser *parser, const char *s, size_t len, Token *t)
return NULL;
}
p = buf = PyBytes_AsString(u);
+ if (p == NULL) {
+ return NULL;
+ }
end = s + len;
while (s < end) {
if (*s == '\\') {
@@ -381,7 +384,7 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
int lines, cols;
if (!fstring_find_expr_location(t, str, &lines, &cols)) {
- PyMem_FREE(str);
+ PyMem_Free(str);
return NULL;
}
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index f3c1d9b20a..96539bd556 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -51,7 +51,7 @@ static const char* type_comment_prefix = "# type: ";
static struct tok_state *
tok_new(void)
{
- struct tok_state *tok = (struct tok_state *)PyMem_MALLOC(
+ struct tok_state *tok = (struct tok_state *)PyMem_Malloc(
sizeof(struct tok_state));
if (tok == NULL)
return NULL;
@@ -93,7 +93,7 @@ tok_new(void)
static char *
new_string(const char *s, Py_ssize_t len, struct tok_state *tok)
{
- char* result = (char *)PyMem_MALLOC(len + 1);
+ char* result = (char *)PyMem_Malloc(len + 1);
if (!result) {
tok->done = E_NOMEM;
return NULL;
@@ -108,7 +108,7 @@ error_ret(struct tok_state *tok) /* XXX */
{
tok->decoding_erred = 1;
if (tok->fp != NULL && tok->buf != NULL) /* see PyTokenizer_Free */
- PyMem_FREE(tok->buf);
+ PyMem_Free(tok->buf);
tok->buf = tok->cur = tok->inp = NULL;
tok->start = NULL;
tok->end = NULL;
@@ -184,7 +184,7 @@ get_coding_spec(const char *s, char **spec, Py_ssize_t size, struct tok_state *t
return 0;
q = get_normal_name(r);
if (r != q) {
- PyMem_FREE(r);
+ PyMem_Free(r);
r = new_string(q, strlen(q), tok);
if (!r)
return 0;
@@ -244,7 +244,7 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok,
else {
PyErr_Format(PyExc_SyntaxError,
"encoding problem: %s", cs);
- PyMem_FREE(cs);
+ PyMem_Free(cs);
}
}
} else { /* then, compare cs with BOM */
@@ -252,7 +252,7 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok,
if (!r)
PyErr_Format(PyExc_SyntaxError,
"encoding problem: %s with BOM", cs);
- PyMem_FREE(cs);
+ PyMem_Free(cs);
}
return r;
}
@@ -315,7 +315,7 @@ check_bom(int get_char(struct tok_state *),
return 1;
}
if (tok->encoding != NULL)
- PyMem_FREE(tok->encoding);
+ PyMem_Free(tok->encoding);
tok->encoding = new_string("utf-8", 5, tok);
if (!tok->encoding)
return 0;
@@ -620,7 +620,7 @@ translate_newlines(const char *s, int exec_input, struct tok_state *tok) {
size_t needed_length = strlen(s) + 2, final_length;
char *buf, *current;
char c = '\0';
- buf = PyMem_MALLOC(needed_length);
+ buf = PyMem_Malloc(needed_length);
if (buf == NULL) {
tok->done = E_NOMEM;
return NULL;
@@ -651,9 +651,9 @@ translate_newlines(const char *s, int exec_input, struct tok_state *tok) {
final_length = current - buf + 1;
if (final_length < needed_length && final_length) {
/* should never fail */
- char* result = PyMem_REALLOC(buf, final_length);
+ char* result = PyMem_Realloc(buf, final_length);
if (result == NULL) {
- PyMem_FREE(buf);
+ PyMem_Free(buf);
}
buf = result;
}
@@ -757,7 +757,7 @@ PyTokenizer_FromUTF8(const char *str, int exec_input)
tok->read_coding_spec = 1;
tok->enc = NULL;
tok->str = translated;
- tok->encoding = (char *)PyMem_MALLOC(6);
+ tok->encoding = (char *)PyMem_Malloc(6);
if (!tok->encoding) {
PyTokenizer_Free(tok);
return NULL;
@@ -778,7 +778,7 @@ PyTokenizer_FromFile(FILE *fp, const char* enc,
struct tok_state *tok = tok_new();
if (tok == NULL)
return NULL;
- if ((tok->buf = (char *)PyMem_MALLOC(BUFSIZ)) == NULL) {
+ if ((tok->buf = (char *)PyMem_Malloc(BUFSIZ)) == NULL) {
PyTokenizer_Free(tok);
return NULL;
}
@@ -790,7 +790,7 @@ PyTokenizer_FromFile(FILE *fp, const char* enc,
if (enc != NULL) {
/* Must copy encoding declaration since it
gets copied into the parse tree. */
- tok->encoding = PyMem_MALLOC(strlen(enc)+1);
+ tok->encoding = PyMem_Malloc(strlen(enc)+1);
if (!tok->encoding) {
PyTokenizer_Free(tok);
return NULL;
@@ -808,15 +808,15 @@ void
PyTokenizer_Free(struct tok_state *tok)
{
if (tok->encoding != NULL)
- PyMem_FREE(tok->encoding);
+ PyMem_Free(tok->encoding);
Py_XDECREF(tok->decoding_readline);
Py_XDECREF(tok->decoding_buffer);
Py_XDECREF(tok->filename);
if (tok->fp != NULL && tok->buf != NULL)
- PyMem_FREE(tok->buf);
+ PyMem_Free(tok->buf);
if (tok->input)
- PyMem_FREE(tok->input);
- PyMem_FREE(tok);
+ PyMem_Free(tok->input);
+ PyMem_Free(tok);
}
/* Get next char, updating state; error code goes into tok->done */
@@ -852,7 +852,7 @@ tok_nextc(struct tok_state *tok)
char *newtok = PyOS_Readline(stdin, stdout, tok->prompt);
if (newtok != NULL) {
char *translated = translate_newlines(newtok, 0, tok);
- PyMem_FREE(newtok);
+ PyMem_Free(newtok);
if (translated == NULL)
return EOF;
newtok = translated;
@@ -862,14 +862,14 @@ tok_nextc(struct tok_state *tok)
Py_ssize_t buflen;
const char* buf;
PyObject *u = translate_into_utf8(newtok, tok->encoding);
- PyMem_FREE(newtok);
+ PyMem_Free(newtok);
if (!u) {
tok->done = E_DECODE;
return EOF;
}
buflen = PyBytes_GET_SIZE(u);
buf = PyBytes_AS_STRING(u);
- newtok = PyMem_MALLOC(buflen+1);
+ newtok = PyMem_Malloc(buflen+1);
if (newtok == NULL) {
Py_DECREF(u);
tok->done = E_NOMEM;
@@ -883,7 +883,7 @@ tok_nextc(struct tok_state *tok)
if (newtok == NULL)
tok->done = E_INTR;
else if (*newtok == '\0') {
- PyMem_FREE(newtok);
+ PyMem_Free(newtok);
tok->done = E_EOF;
}
else if (tok->start != NULL) {
@@ -892,12 +892,12 @@ tok_nextc(struct tok_state *tok)
size_t newlen = oldlen + strlen(newtok);
Py_ssize_t cur_multi_line_start = tok->multi_line_start - tok->buf;
char *buf = tok->buf;
- buf = (char *)PyMem_REALLOC(buf, newlen+1);
+ buf = (char *)PyMem_Realloc(buf, newlen+1);
tok->lineno++;
if (buf == NULL) {
- PyMem_FREE(tok->buf);
+ PyMem_Free(tok->buf);
tok->buf = NULL;
- PyMem_FREE(newtok);
+ PyMem_Free(newtok);
tok->done = E_NOMEM;
return EOF;
}
@@ -906,7 +906,7 @@ tok_nextc(struct tok_state *tok)
tok->multi_line_start = tok->buf + cur_multi_line_start;
tok->line_start = tok->cur;
strcpy(tok->buf + oldlen, newtok);
- PyMem_FREE(newtok);
+ PyMem_Free(newtok);
tok->inp = tok->buf + newlen;
tok->end = tok->inp + 1;
tok->start = tok->buf + start;
@@ -914,7 +914,7 @@ tok_nextc(struct tok_state *tok)
else {
tok->lineno++;
if (tok->buf != NULL)
- PyMem_FREE(tok->buf);
+ PyMem_Free(tok->buf);
tok->buf = newtok;
tok->cur = tok->buf;
tok->line_start = tok->buf;
@@ -929,7 +929,7 @@ tok_nextc(struct tok_state *tok)
if (tok->start == NULL) {
if (tok->buf == NULL) {
tok->buf = (char *)
- PyMem_MALLOC(BUFSIZ);
+ PyMem_Malloc(BUFSIZ);
if (tok->buf == NULL) {
tok->done = E_NOMEM;
return EOF;
@@ -966,7 +966,7 @@ tok_nextc(struct tok_state *tok)
Py_ssize_t curvalid = tok->inp - tok->buf;
Py_ssize_t newsize = curvalid + BUFSIZ;
char *newbuf = tok->buf;
- newbuf = (char *)PyMem_REALLOC(newbuf,
+ newbuf = (char *)PyMem_Realloc(newbuf,
newsize);
if (newbuf == NULL) {
tok->done = E_NOMEM;
@@ -1851,7 +1851,7 @@ PyTokenizer_Get(struct tok_state *tok, const char **p_start, const char **p_end)
encoding in the first or second line of the file (in which case the encoding
should be assumed to be UTF-8).
- The char* returned is malloc'ed via PyMem_MALLOC() and thus must be freed
+ The char* returned is malloc'ed via PyMem_Malloc() and thus must be freed
by the caller. */
char *
@@ -1894,7 +1894,7 @@ PyTokenizer_FindEncodingFilename(int fd, PyObject *filename)
}
fclose(fp);
if (tok->encoding) {
- encoding = (char *)PyMem_MALLOC(strlen(tok->encoding) + 1);
+ encoding = (char *)PyMem_Malloc(strlen(tok->encoding) + 1);
if (encoding)
strcpy(encoding, tok->encoding);
}
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index 5aad16a6f7..748ea8a8f3 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -1526,6 +1526,55 @@ static int test_init_warnoptions(void)
}
+static int tune_config(void)
+{
+ PyConfig config;
+ PyConfig_InitPythonConfig(&config);
+ if (_PyInterpreterState_GetConfigCopy(&config) < 0) {
+ PyConfig_Clear(&config);
+ PyErr_Print();
+ return -1;
+ }
+
+ config.bytes_warning = 2;
+
+ if (_PyInterpreterState_SetConfig(&config) < 0) {
+ PyConfig_Clear(&config);
+ return -1;
+ }
+ PyConfig_Clear(&config);
+ return 0;
+}
+
+
+static int test_init_set_config(void)
+{
+ // Initialize core
+ PyConfig config;
+ PyConfig_InitIsolatedConfig(&config);
+ config_set_string(&config, &config.program_name, PROGRAM_NAME);
+ config._init_main = 0;
+ config.bytes_warning = 0;
+ init_from_config_clear(&config);
+
+ // Tune the configuration using _PyInterpreterState_SetConfig()
+ if (tune_config() < 0) {
+ PyErr_Print();
+ return 1;
+ }
+
+ // Finish initialization: main part
+ PyStatus status = _Py_InitializeMain();
+ if (PyStatus_Exception(status)) {
+ Py_ExitStatusException(status);
+ }
+
+ dump_config();
+ Py_Finalize();
+ return 0;
+}
+
+
static void configure_init_main(PyConfig *config)
{
wchar_t* argv[] = {
@@ -1693,6 +1742,7 @@ static struct TestCase TestCases[] = {
{"test_init_setpath_config", test_init_setpath_config},
{"test_init_setpythonhome", test_init_setpythonhome},
{"test_init_warnoptions", test_init_warnoptions},
+ {"test_init_set_config", test_init_set_config},
{"test_run_main", test_run_main},
{"test_get_argc_argv", test_get_argc_argv},
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index f04addbe20..debd3e3542 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -261,10 +261,10 @@ get_ast_state(void)
#include "Python-ast.h"
#include "structmember.h"
-void _PyAST_Fini(PyThreadState *tstate)
+void _PyAST_Fini(PyInterpreterState *interp)
{
#ifdef Py_BUILD_CORE
- struct ast_state *state = &tstate->interp->ast;
+ struct ast_state *state = &interp->ast;
#else
struct ast_state *state = &global_ast_state;
#endif
@@ -483,7 +483,11 @@ void _PyAST_Fini(PyThreadState *tstate)
Py_CLEAR(state->vararg);
Py_CLEAR(state->withitem_type);
+#if defined(Py_BUILD_CORE) && !defined(NDEBUG)
+ state->initialized = -1;
+#else
state->initialized = 0;
+#endif
}
static int init_identifiers(struct ast_state *state)
@@ -1227,13 +1231,27 @@ static int add_ast_fields(struct ast_state *state)
}
-static int init_types(struct ast_state *state)
+
+static int
+init_types(struct ast_state *state)
{
- if (state->initialized) return 1;
- if (init_identifiers(state) < 0) return 0;
+ // init_types() must not be called after _PyAST_Fini()
+ // has been called
+ assert(state->initialized >= 0);
+
+ if (state->initialized) {
+ return 1;
+ }
+ if (init_identifiers(state) < 0) {
+ return 0;
+ }
state->AST_type = PyType_FromSpec(&AST_type_spec);
- if (!state->AST_type) return 0;
- if (add_ast_fields(state) < 0) return 0;
+ if (!state->AST_type) {
+ return 0;
+ }
+ if (add_ast_fields(state) < 0) {
+ return 0;
+ }
state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
"mod = Module(stmt* body, type_ignore* type_ignores)\n"
" | Interactive(stmt* body)\n"
@@ -1902,6 +1920,7 @@ static int init_types(struct ast_state *state)
TypeIgnore_fields, 2,
"TypeIgnore(int lineno, string tag)");
if (!state->TypeIgnore_type) return 0;
+
state->initialized = 1;
return 1;
}
@@ -9699,10 +9718,9 @@ astmodule_exec(PyObject *m)
if (state == NULL) {
return -1;
}
- if (PyModule_AddObject(m, "AST", state->AST_type) < 0) {
+ if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
return -1;
}
- Py_INCREF(state->AST_type);
if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
return -1;
}
@@ -9712,432 +9730,332 @@ astmodule_exec(PyObject *m)
if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
return -1;
}
- if (PyModule_AddObject(m, "mod", state->mod_type) < 0) {
+ if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
return -1;
}
- Py_INCREF(state->mod_type);
- if (PyModule_AddObject(m, "Module", state->Module_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
return -1;
}
- Py_INCREF(state->Module_type);
- if (PyModule_AddObject(m, "Interactive", state->Interactive_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
return -1;
}
- Py_INCREF(state->Interactive_type);
- if (PyModule_AddObject(m, "Expression", state->Expression_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
return -1;
}
- Py_INCREF(state->Expression_type);
- if (PyModule_AddObject(m, "FunctionType", state->FunctionType_type) < 0) {
+ if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
+ {
return -1;
}
- Py_INCREF(state->FunctionType_type);
- if (PyModule_AddObject(m, "stmt", state->stmt_type) < 0) {
+ if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
return -1;
}
- Py_INCREF(state->stmt_type);
- if (PyModule_AddObject(m, "FunctionDef", state->FunctionDef_type) < 0) {
+ if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
return -1;
}
- Py_INCREF(state->FunctionDef_type);
- if (PyModule_AddObject(m, "AsyncFunctionDef", state->AsyncFunctionDef_type)
- < 0) {
+ if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
+ state->AsyncFunctionDef_type) < 0) {
return -1;
}
- Py_INCREF(state->AsyncFunctionDef_type);
- if (PyModule_AddObject(m, "ClassDef", state->ClassDef_type) < 0) {
+ if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
return -1;
}
- Py_INCREF(state->ClassDef_type);
- if (PyModule_AddObject(m, "Return", state->Return_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
return -1;
}
- Py_INCREF(state->Return_type);
- if (PyModule_AddObject(m, "Delete", state->Delete_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
return -1;
}
- Py_INCREF(state->Delete_type);
- if (PyModule_AddObject(m, "Assign", state->Assign_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
return -1;
}
- Py_INCREF(state->Assign_type);
- if (PyModule_AddObject(m, "AugAssign", state->AugAssign_type) < 0) {
+ if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
return -1;
}
- Py_INCREF(state->AugAssign_type);
- if (PyModule_AddObject(m, "AnnAssign", state->AnnAssign_type) < 0) {
+ if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
return -1;
}
- Py_INCREF(state->AnnAssign_type);
- if (PyModule_AddObject(m, "For", state->For_type) < 0) {
+ if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
return -1;
}
- Py_INCREF(state->For_type);
- if (PyModule_AddObject(m, "AsyncFor", state->AsyncFor_type) < 0) {
+ if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
return -1;
}
- Py_INCREF(state->AsyncFor_type);
- if (PyModule_AddObject(m, "While", state->While_type) < 0) {
+ if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
return -1;
}
- Py_INCREF(state->While_type);
- if (PyModule_AddObject(m, "If", state->If_type) < 0) {
+ if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
return -1;
}
- Py_INCREF(state->If_type);
- if (PyModule_AddObject(m, "With", state->With_type) < 0) {
+ if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
return -1;
}
- Py_INCREF(state->With_type);
- if (PyModule_AddObject(m, "AsyncWith", state->AsyncWith_type) < 0) {
+ if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
return -1;
}
- Py_INCREF(state->AsyncWith_type);
- if (PyModule_AddObject(m, "Raise", state->Raise_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
return -1;
}
- Py_INCREF(state->Raise_type);
- if (PyModule_AddObject(m, "Try", state->Try_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
return -1;
}
- Py_INCREF(state->Try_type);
- if (PyModule_AddObject(m, "Assert", state->Assert_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
return -1;
}
- Py_INCREF(state->Assert_type);
- if (PyModule_AddObject(m, "Import", state->Import_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
return -1;
}
- Py_INCREF(state->Import_type);
- if (PyModule_AddObject(m, "ImportFrom", state->ImportFrom_type) < 0) {
+ if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
return -1;
}
- Py_INCREF(state->ImportFrom_type);
- if (PyModule_AddObject(m, "Global", state->Global_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
return -1;
}
- Py_INCREF(state->Global_type);
- if (PyModule_AddObject(m, "Nonlocal", state->Nonlocal_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
return -1;
}
- Py_INCREF(state->Nonlocal_type);
- if (PyModule_AddObject(m, "Expr", state->Expr_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
return -1;
}
- Py_INCREF(state->Expr_type);
- if (PyModule_AddObject(m, "Pass", state->Pass_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
return -1;
}
- Py_INCREF(state->Pass_type);
- if (PyModule_AddObject(m, "Break", state->Break_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
return -1;
}
- Py_INCREF(state->Break_type);
- if (PyModule_AddObject(m, "Continue", state->Continue_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
return -1;
}
- Py_INCREF(state->Continue_type);
- if (PyModule_AddObject(m, "expr", state->expr_type) < 0) {
+ if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
return -1;
}
- Py_INCREF(state->expr_type);
- if (PyModule_AddObject(m, "BoolOp", state->BoolOp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
return -1;
}
- Py_INCREF(state->BoolOp_type);
- if (PyModule_AddObject(m, "NamedExpr", state->NamedExpr_type) < 0) {
+ if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
return -1;
}
- Py_INCREF(state->NamedExpr_type);
- if (PyModule_AddObject(m, "BinOp", state->BinOp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
return -1;
}
- Py_INCREF(state->BinOp_type);
- if (PyModule_AddObject(m, "UnaryOp", state->UnaryOp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
return -1;
}
- Py_INCREF(state->UnaryOp_type);
- if (PyModule_AddObject(m, "Lambda", state->Lambda_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
return -1;
}
- Py_INCREF(state->Lambda_type);
- if (PyModule_AddObject(m, "IfExp", state->IfExp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
return -1;
}
- Py_INCREF(state->IfExp_type);
- if (PyModule_AddObject(m, "Dict", state->Dict_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
return -1;
}
- Py_INCREF(state->Dict_type);
- if (PyModule_AddObject(m, "Set", state->Set_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
return -1;
}
- Py_INCREF(state->Set_type);
- if (PyModule_AddObject(m, "ListComp", state->ListComp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
return -1;
}
- Py_INCREF(state->ListComp_type);
- if (PyModule_AddObject(m, "SetComp", state->SetComp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
return -1;
}
- Py_INCREF(state->SetComp_type);
- if (PyModule_AddObject(m, "DictComp", state->DictComp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
return -1;
}
- Py_INCREF(state->DictComp_type);
- if (PyModule_AddObject(m, "GeneratorExp", state->GeneratorExp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
+ {
return -1;
}
- Py_INCREF(state->GeneratorExp_type);
- if (PyModule_AddObject(m, "Await", state->Await_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
return -1;
}
- Py_INCREF(state->Await_type);
- if (PyModule_AddObject(m, "Yield", state->Yield_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
return -1;
}
- Py_INCREF(state->Yield_type);
- if (PyModule_AddObject(m, "YieldFrom", state->YieldFrom_type) < 0) {
+ if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
return -1;
}
- Py_INCREF(state->YieldFrom_type);
- if (PyModule_AddObject(m, "Compare", state->Compare_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
return -1;
}
- Py_INCREF(state->Compare_type);
- if (PyModule_AddObject(m, "Call", state->Call_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
return -1;
}
- Py_INCREF(state->Call_type);
- if (PyModule_AddObject(m, "FormattedValue", state->FormattedValue_type) <
- 0) {
+ if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
+ < 0) {
return -1;
}
- Py_INCREF(state->FormattedValue_type);
- if (PyModule_AddObject(m, "JoinedStr", state->JoinedStr_type) < 0) {
+ if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
return -1;
}
- Py_INCREF(state->JoinedStr_type);
- if (PyModule_AddObject(m, "Constant", state->Constant_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
return -1;
}
- Py_INCREF(state->Constant_type);
- if (PyModule_AddObject(m, "Attribute", state->Attribute_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
return -1;
}
- Py_INCREF(state->Attribute_type);
- if (PyModule_AddObject(m, "Subscript", state->Subscript_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
return -1;
}
- Py_INCREF(state->Subscript_type);
- if (PyModule_AddObject(m, "Starred", state->Starred_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
return -1;
}
- Py_INCREF(state->Starred_type);
- if (PyModule_AddObject(m, "Name", state->Name_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
return -1;
}
- Py_INCREF(state->Name_type);
- if (PyModule_AddObject(m, "List", state->List_type) < 0) {
+ if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
return -1;
}
- Py_INCREF(state->List_type);
- if (PyModule_AddObject(m, "Tuple", state->Tuple_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
return -1;
}
- Py_INCREF(state->Tuple_type);
- if (PyModule_AddObject(m, "Slice", state->Slice_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
return -1;
}
- Py_INCREF(state->Slice_type);
- if (PyModule_AddObject(m, "expr_context", state->expr_context_type) < 0) {
+ if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
+ {
return -1;
}
- Py_INCREF(state->expr_context_type);
- if (PyModule_AddObject(m, "Load", state->Load_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
return -1;
}
- Py_INCREF(state->Load_type);
- if (PyModule_AddObject(m, "Store", state->Store_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
return -1;
}
- Py_INCREF(state->Store_type);
- if (PyModule_AddObject(m, "Del", state->Del_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
return -1;
}
- Py_INCREF(state->Del_type);
- if (PyModule_AddObject(m, "boolop", state->boolop_type) < 0) {
+ if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
return -1;
}
- Py_INCREF(state->boolop_type);
- if (PyModule_AddObject(m, "And", state->And_type) < 0) {
+ if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
return -1;
}
- Py_INCREF(state->And_type);
- if (PyModule_AddObject(m, "Or", state->Or_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
return -1;
}
- Py_INCREF(state->Or_type);
- if (PyModule_AddObject(m, "operator", state->operator_type) < 0) {
+ if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
return -1;
}
- Py_INCREF(state->operator_type);
- if (PyModule_AddObject(m, "Add", state->Add_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
return -1;
}
- Py_INCREF(state->Add_type);
- if (PyModule_AddObject(m, "Sub", state->Sub_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
return -1;
}
- Py_INCREF(state->Sub_type);
- if (PyModule_AddObject(m, "Mult", state->Mult_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
return -1;
}
- Py_INCREF(state->Mult_type);
- if (PyModule_AddObject(m, "MatMult", state->MatMult_type) < 0) {
+ if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
return -1;
}
- Py_INCREF(state->MatMult_type);
- if (PyModule_AddObject(m, "Div", state->Div_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
return -1;
}
- Py_INCREF(state->Div_type);
- if (PyModule_AddObject(m, "Mod", state->Mod_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
return -1;
}
- Py_INCREF(state->Mod_type);
- if (PyModule_AddObject(m, "Pow", state->Pow_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
return -1;
}
- Py_INCREF(state->Pow_type);
- if (PyModule_AddObject(m, "LShift", state->LShift_type) < 0) {
+ if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
return -1;
}
- Py_INCREF(state->LShift_type);
- if (PyModule_AddObject(m, "RShift", state->RShift_type) < 0) {
+ if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
return -1;
}
- Py_INCREF(state->RShift_type);
- if (PyModule_AddObject(m, "BitOr", state->BitOr_type) < 0) {
+ if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
return -1;
}
- Py_INCREF(state->BitOr_type);
- if (PyModule_AddObject(m, "BitXor", state->BitXor_type) < 0) {
+ if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
return -1;
}
- Py_INCREF(state->BitXor_type);
- if (PyModule_AddObject(m, "BitAnd", state->BitAnd_type) < 0) {
+ if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
return -1;
}
- Py_INCREF(state->BitAnd_type);
- if (PyModule_AddObject(m, "FloorDiv", state->FloorDiv_type) < 0) {
+ if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
return -1;
}
- Py_INCREF(state->FloorDiv_type);
- if (PyModule_AddObject(m, "unaryop", state->unaryop_type) < 0) {
+ if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
return -1;
}
- Py_INCREF(state->unaryop_type);
- if (PyModule_AddObject(m, "Invert", state->Invert_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
return -1;
}
- Py_INCREF(state->Invert_type);
- if (PyModule_AddObject(m, "Not", state->Not_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
return -1;
}
- Py_INCREF(state->Not_type);
- if (PyModule_AddObject(m, "UAdd", state->UAdd_type) < 0) {
+ if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
return -1;
}
- Py_INCREF(state->UAdd_type);
- if (PyModule_AddObject(m, "USub", state->USub_type) < 0) {
+ if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
return -1;
}
- Py_INCREF(state->USub_type);
- if (PyModule_AddObject(m, "cmpop", state->cmpop_type) < 0) {
+ if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
return -1;
}
- Py_INCREF(state->cmpop_type);
- if (PyModule_AddObject(m, "Eq", state->Eq_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
return -1;
}
- Py_INCREF(state->Eq_type);
- if (PyModule_AddObject(m, "NotEq", state->NotEq_type) < 0) {
+ if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
return -1;
}
- Py_INCREF(state->NotEq_type);
- if (PyModule_AddObject(m, "Lt", state->Lt_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
return -1;
}
- Py_INCREF(state->Lt_type);
- if (PyModule_AddObject(m, "LtE", state->LtE_type) < 0) {
+ if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
return -1;
}
- Py_INCREF(state->LtE_type);
- if (PyModule_AddObject(m, "Gt", state->Gt_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
return -1;
}
- Py_INCREF(state->Gt_type);
- if (PyModule_AddObject(m, "GtE", state->GtE_type) < 0) {
+ if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
return -1;
}
- Py_INCREF(state->GtE_type);
- if (PyModule_AddObject(m, "Is", state->Is_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
return -1;
}
- Py_INCREF(state->Is_type);
- if (PyModule_AddObject(m, "IsNot", state->IsNot_type) < 0) {
+ if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
return -1;
}
- Py_INCREF(state->IsNot_type);
- if (PyModule_AddObject(m, "In", state->In_type) < 0) {
+ if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
return -1;
}
- Py_INCREF(state->In_type);
- if (PyModule_AddObject(m, "NotIn", state->NotIn_type) < 0) {
+ if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
return -1;
}
- Py_INCREF(state->NotIn_type);
- if (PyModule_AddObject(m, "comprehension", state->comprehension_type) < 0) {
+ if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
+ 0) {
return -1;
}
- Py_INCREF(state->comprehension_type);
- if (PyModule_AddObject(m, "excepthandler", state->excepthandler_type) < 0) {
+ if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
+ 0) {
return -1;
}
- Py_INCREF(state->excepthandler_type);
- if (PyModule_AddObject(m, "ExceptHandler", state->ExceptHandler_type) < 0) {
+ if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
+ 0) {
return -1;
}
- Py_INCREF(state->ExceptHandler_type);
- if (PyModule_AddObject(m, "arguments", state->arguments_type) < 0) {
+ if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
return -1;
}
- Py_INCREF(state->arguments_type);
- if (PyModule_AddObject(m, "arg", state->arg_type) < 0) {
+ if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
return -1;
}
- Py_INCREF(state->arg_type);
- if (PyModule_AddObject(m, "keyword", state->keyword_type) < 0) {
+ if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
return -1;
}
- Py_INCREF(state->keyword_type);
- if (PyModule_AddObject(m, "alias", state->alias_type) < 0) {
+ if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
return -1;
}
- Py_INCREF(state->alias_type);
- if (PyModule_AddObject(m, "withitem", state->withitem_type) < 0) {
+ if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
return -1;
}
- Py_INCREF(state->withitem_type);
- if (PyModule_AddObject(m, "type_ignore", state->type_ignore_type) < 0) {
+ if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
return -1;
}
- Py_INCREF(state->type_ignore_type);
- if (PyModule_AddObject(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
+ if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
return -1;
}
- Py_INCREF(state->TypeIgnore_type);
return 0;
}
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 3c048af419..021400f558 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -24,9 +24,6 @@ _Py_IDENTIFIER(ignore);
typedef struct _warnings_runtime_state WarningsState;
-/* Forward declaration of the _warnings module definition. */
-static struct PyModuleDef warningsmodule;
-
_Py_IDENTIFIER(__name__);
/* Given a module object, get its per-module state. */
@@ -69,12 +66,14 @@ create_filter(PyObject *category, _Py_Identifier *id, const char *modname)
return NULL;
}
} else {
- modname_obj = Py_None;
+ modname_obj = Py_NewRef(Py_None);
}
/* This assumes the line number is zero for now. */
- return PyTuple_Pack(5, action_str, Py_None,
- category, modname_obj, _PyLong_GetZero());
+ PyObject *filter = PyTuple_Pack(5, action_str, Py_None,
+ category, modname_obj, _PyLong_GetZero());
+ Py_DECREF(modname_obj);
+ return filter;
}
#endif
@@ -114,37 +113,34 @@ init_filters(void)
}
/* Initialize the given warnings module state. */
-static int
-warnings_init_state(WarningsState *st)
+int
+_PyWarnings_InitState(PyThreadState *tstate)
{
+ WarningsState *st = &tstate->interp->warnings;
+
if (st->filters == NULL) {
st->filters = init_filters();
if (st->filters == NULL) {
- goto error;
+ return -1;
}
}
if (st->once_registry == NULL) {
st->once_registry = PyDict_New();
if (st->once_registry == NULL) {
- goto error;
+ return -1;
}
}
if (st->default_action == NULL) {
st->default_action = PyUnicode_FromString("default");
if (st->default_action == NULL) {
- goto error;
+ return -1;
}
}
st->filters_version = 0;
-
return 0;
-
-error:
- warnings_clear_state(st);
- return -1;
}
@@ -1354,70 +1350,45 @@ static PyMethodDef warnings_functions[] = {
};
-static struct PyModuleDef warningsmodule = {
- PyModuleDef_HEAD_INIT,
- MODULE_NAME, /* m_name */
- warnings__doc__, /* m_doc */
- 0, /* m_size */
- warnings_functions, /* m_methods */
- NULL, /* m_reload */
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-
-
-PyStatus
-_PyWarnings_InitState(PyThreadState *tstate)
-{
- if (warnings_init_state(&tstate->interp->warnings) < 0) {
- return _PyStatus_ERR("can't initialize warnings");
- }
- return _PyStatus_OK();
-}
-
-
-PyMODINIT_FUNC
-_PyWarnings_Init(void)
+static int
+warnings_module_exec(PyObject *module)
{
- PyObject *m;
-
- m = PyModule_Create(&warningsmodule);
- if (m == NULL) {
- return NULL;
- }
-
WarningsState *st = warnings_get_state();
if (st == NULL) {
- goto error;
+ return -1;
}
- if (warnings_init_state(st) < 0) {
- goto error;
+ if (PyModule_AddObjectRef(module, "filters", st->filters) < 0) {
+ return -1;
}
-
- Py_INCREF(st->filters);
- if (PyModule_AddObject(m, "filters", st->filters) < 0) {
- goto error;
+ if (PyModule_AddObjectRef(module, "_onceregistry", st->once_registry) < 0) {
+ return -1;
}
-
- Py_INCREF(st->once_registry);
- if (PyModule_AddObject(m, "_onceregistry", st->once_registry) < 0) {
- goto error;
+ if (PyModule_AddObjectRef(module, "_defaultaction", st->default_action) < 0) {
+ return -1;
}
+ return 0;
+}
- Py_INCREF(st->default_action);
- if (PyModule_AddObject(m, "_defaultaction", st->default_action) < 0) {
- goto error;
- }
- return m;
+static PyModuleDef_Slot warnings_slots[] = {
+ {Py_mod_exec, warnings_module_exec},
+ {0, NULL}
+};
-error:
- if (st != NULL) {
- warnings_clear_state(st);
- }
- Py_DECREF(m);
- return NULL;
+static struct PyModuleDef warnings_module = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = MODULE_NAME,
+ .m_doc = warnings__doc__,
+ .m_size = 0,
+ .m_methods = warnings_functions,
+ .m_slots = warnings_slots,
+};
+
+
+PyMODINIT_FUNC
+_PyWarnings_Init(void)
+{
+ return PyModuleDef_Init(&warnings_module);
}
// We need this to ensure that warnings still work until late in finalization.
diff --git a/Python/ast_opt.c b/Python/ast_opt.c
index 22ca6f23ae..8c958ca7f1 100644
--- a/Python/ast_opt.c
+++ b/Python/ast_opt.c
@@ -7,6 +7,8 @@
static int
make_const(expr_ty node, PyObject *val, PyArena *arena)
{
+ // Even if no new value was calculated, make_const may still
+ // need to clear an error (e.g. for division by zero)
if (val == NULL) {
if (PyErr_ExceptionMatches(PyExc_KeyboardInterrupt)) {
return 0;
@@ -49,7 +51,7 @@ fold_unaryop(expr_ty node, PyArena *arena, _PyASTOptimizeState *state)
of !=. Detecting such cases doesn't seem worthwhile.
Python uses </> for 'is subset'/'is superset' operations on sets.
They don't satisfy not folding laws. */
- int op = asdl_seq_GET(arg->v.Compare.ops, 0);
+ cmpop_ty op = asdl_seq_GET(arg->v.Compare.ops, 0);
switch (op) {
case Is:
op = IsNot;
@@ -63,8 +65,17 @@ fold_unaryop(expr_ty node, PyArena *arena, _PyASTOptimizeState *state)
case NotIn:
op = In;
break;
- default:
- op = 0;
+ // The remaining comparison operators can't be safely inverted
+ case Eq:
+ case NotEq:
+ case Lt:
+ case LtE:
+ case Gt:
+ case GtE:
+ op = 0; // The AST enums leave "0" free as an "unused" marker
+ break;
+ // No default case, so the compiler will emit a warning if new
+ // comparison operators are added without being handled here
}
if (op) {
asdl_seq_SET(arg->v.Compare.ops, 0, op);
@@ -224,7 +235,7 @@ fold_binop(expr_ty node, PyArena *arena, _PyASTOptimizeState *state)
PyObject *lv = lhs->v.Constant.value;
PyObject *rv = rhs->v.Constant.value;
- PyObject *newval;
+ PyObject *newval = NULL;
switch (node->v.BinOp.op) {
case Add:
@@ -263,8 +274,11 @@ fold_binop(expr_ty node, PyArena *arena, _PyASTOptimizeState *state)
case BitAnd:
newval = PyNumber_And(lv, rv);
break;
- default: // Unknown operator
+ // No builtin constants implement the following operators
+ case MatMult:
return 1;
+ // No default case, so the compiler will emit a warning if new binary
+ // operators are added without being handled here
}
return make_const(node, newval, arena);
@@ -457,8 +471,11 @@ astfold_mod(mod_ty node_, PyArena *ctx_, _PyASTOptimizeState *state)
case Expression_kind:
CALL(astfold_expr, expr_ty, node_->v.Expression.body);
break;
- default:
+ // The following top level nodes don't participate in constant folding
+ case FunctionType_kind:
break;
+ // No default case, so the compiler will emit a warning if new top level
+ // compilation nodes are added without being handled here
}
return 1;
}
@@ -567,8 +584,14 @@ astfold_expr(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state)
return make_const(node_, PyBool_FromLong(!state->optimize), ctx_);
}
break;
- default:
+ case NamedExpr_kind:
+ CALL(astfold_expr, expr_ty, node_->v.NamedExpr.value);
+ break;
+ case Constant_kind:
+ // Already a constant, nothing further to do
break;
+ // No default case, so the compiler will emit a warning if new expression
+ // kinds are added without being handled here
}
return 1;
}
@@ -686,8 +709,17 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state)
case Expr_kind:
CALL(astfold_expr, expr_ty, node_->v.Expr.value);
break;
- default:
- break;
+ // The following statements don't contain any subexpressions to be folded
+ case Import_kind:
+ case ImportFrom_kind:
+ case Global_kind:
+ case Nonlocal_kind:
+ case Pass_kind:
+ case Break_kind:
+ case Continue_kind:
+ break;
+ // No default case, so the compiler will emit a warning if new statement
+ // kinds are added without being handled here
}
return 1;
}
@@ -700,8 +732,8 @@ astfold_excepthandler(excepthandler_ty node_, PyArena *ctx_, _PyASTOptimizeState
CALL_OPT(astfold_expr, expr_ty, node_->v.ExceptHandler.type);
CALL_SEQ(astfold_stmt, stmt, node_->v.ExceptHandler.body);
break;
- default:
- break;
+ // No default case, so the compiler will emit a warning if new handler
+ // kinds are added without being handled here
}
return 1;
}
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 1ce55b6ec5..352fb83d55 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -2089,7 +2089,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
Py_DECREF(stdin_encoding);
Py_DECREF(stdin_errors);
Py_XDECREF(po);
- PyMem_FREE(s);
+ PyMem_Free(s);
if (result != NULL) {
if (PySys_Audit("builtins.input/result", "O", result) < 0) {
@@ -2636,6 +2636,11 @@ zip_next(zipobject *lz)
PyTuple_SET_ITEM(result, i, item);
Py_DECREF(olditem);
}
+ // bpo-42536: The GC may have untracked this result tuple. Since we're
+ // recycling it, make sure it's tracked again:
+ if (!_PyObject_GC_IS_TRACKED(result)) {
+ _PyObject_GC_TRACK(result);
+ }
} else {
result = PyTuple_New(tuplesize);
if (result == NULL)
diff --git a/Python/bootstrap_hash.c b/Python/bootstrap_hash.c
index 47369305ee..a212f69870 100644
--- a/Python/bootstrap_hash.c
+++ b/Python/bootstrap_hash.c
@@ -25,6 +25,16 @@
# include <sanitizer/msan_interface.h>
#endif
+#if defined(__APPLE__) && defined(__has_builtin)
+# if __has_builtin(__builtin_available)
+# define HAVE_GETENTRYPY_GETRANDOM_RUNTIME __builtin_available(macOS 10.12, iOS 10.10, tvOS 10.0, watchOS 3.0, *)
+# endif
+#endif
+#ifndef HAVE_GETENTRYPY_GETRANDOM_RUNTIME
+# define HAVE_GETENTRYPY_GETRANDOM_RUNTIME 1
+#endif
+
+
#ifdef Py_DEBUG
int _Py_HashSecret_Initialized = 0;
#else
@@ -208,6 +218,16 @@ py_getrandom(void *buffer, Py_ssize_t size, int blocking, int raise)
error.
getentropy() is retried if it failed with EINTR: interrupted by a signal. */
+
+#if defined(__APPLE__) && defined(__has_attribute) && __has_attribute(availability)
+static int
+py_getentropy(char *buffer, Py_ssize_t size, int raise)
+ __attribute__((availability(macos,introduced=10.12)))
+ __attribute__((availability(ios,introduced=10.0)))
+ __attribute__((availability(tvos,introduced=10.0)))
+ __attribute__((availability(watchos,introduced=3.0)));
+#endif
+
static int
py_getentropy(char *buffer, Py_ssize_t size, int raise)
{
@@ -498,19 +518,21 @@ pyurandom(void *buffer, Py_ssize_t size, int blocking, int raise)
#else
#if defined(PY_GETRANDOM) || defined(PY_GETENTROPY)
+ if (HAVE_GETENTRYPY_GETRANDOM_RUNTIME) {
#ifdef PY_GETRANDOM
- res = py_getrandom(buffer, size, blocking, raise);
+ res = py_getrandom(buffer, size, blocking, raise);
#else
- res = py_getentropy(buffer, size, raise);
+ res = py_getentropy(buffer, size, raise);
#endif
- if (res < 0) {
- return -1;
- }
- if (res == 1) {
- return 0;
- }
- /* getrandom() or getentropy() function is not available: failed with
- ENOSYS or EPERM. Fall back on reading from /dev/urandom. */
+ if (res < 0) {
+ return -1;
+ }
+ if (res == 1) {
+ return 0;
+ }
+ /* getrandom() or getentropy() function is not available: failed with
+ ENOSYS or EPERM. Fall back on reading from /dev/urandom. */
+ } /* end of availability block */
#endif
return dev_urandom(buffer, size, raise);
diff --git a/Python/ceval.c b/Python/ceval.c
index 13b209fc70..f0f39539c9 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -66,8 +66,8 @@ static void call_exc_trace(Py_tracefunc, PyObject *,
PyThreadState *, PyFrameObject *);
static int maybe_call_line_trace(Py_tracefunc, PyObject *,
PyThreadState *, PyFrameObject *,
- int *, int *, int *);
-static void maybe_dtrace_line(PyFrameObject *, int *, int *, int *);
+ PyCodeAddressRange *, int *);
+static void maybe_dtrace_line(PyFrameObject *, PyCodeAddressRange *, int *);
static void dtrace_function_entry(PyFrameObject *);
static void dtrace_function_return(PyFrameObject *);
@@ -203,13 +203,18 @@ UNSIGNAL_PENDING_CALLS(PyInterpreterState *interp)
static inline void
-SIGNAL_PENDING_SIGNALS(PyInterpreterState *interp)
+SIGNAL_PENDING_SIGNALS(PyInterpreterState *interp, int force)
{
struct _ceval_runtime_state *ceval = &interp->runtime->ceval;
struct _ceval_state *ceval2 = &interp->ceval;
_Py_atomic_store_relaxed(&ceval->signals_pending, 1);
- /* eval_breaker is not set to 1 if thread_can_handle_signals() is false */
- COMPUTE_EVAL_BREAKER(interp, ceval, ceval2);
+ if (force) {
+ _Py_atomic_store_relaxed(&ceval2->eval_breaker, 1);
+ }
+ else {
+ /* eval_breaker is not set to 1 if thread_can_handle_signals() is false */
+ COMPUTE_EVAL_BREAKER(interp, ceval, ceval2);
+ }
}
@@ -559,10 +564,22 @@ PyEval_RestoreThread(PyThreadState *tstate)
void
_PyEval_SignalReceived(PyInterpreterState *interp)
{
+#ifdef MS_WINDOWS
+ // bpo-42296: On Windows, _PyEval_SignalReceived() is called from a signal
+ // handler which can run in a thread different than the Python thread, in
+ // which case _Py_ThreadCanHandleSignals() is wrong. Ignore
+ // _Py_ThreadCanHandleSignals() and always set eval_breaker to 1.
+ //
+ // The next eval_frame_handle_pending() call will call
+ // _Py_ThreadCanHandleSignals() to recompute eval_breaker.
+ int force = 1;
+#else
+ int force = 0;
+#endif
/* bpo-30703: Function called when the C signal handler of Python gets a
signal. We cannot queue a callback using _PyEval_AddPendingCall() since
that function is not async-signal-safe. */
- SIGNAL_PENDING_SIGNALS(interp);
+ SIGNAL_PENDING_SIGNALS(interp, force);
}
/* Push one item onto the queue while holding the lock. */
@@ -662,7 +679,7 @@ handle_signals(PyThreadState *tstate)
UNSIGNAL_PENDING_SIGNALS(tstate->interp);
if (_PyErr_CheckSignalsTstate(tstate) < 0) {
/* On failure, re-schedule a call to handle_signals(). */
- SIGNAL_PENDING_SIGNALS(tstate->interp);
+ SIGNAL_PENDING_SIGNALS(tstate->interp, 0);
return -1;
}
return 0;
@@ -840,20 +857,22 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where)
return -1;
}
#endif
- if (tstate->overflowed) {
+ if (tstate->recursion_headroom) {
if (tstate->recursion_depth > recursion_limit + 50) {
/* Overflowing while handling an overflow. Give up. */
Py_FatalError("Cannot recover from stack overflow.");
}
- return 0;
}
- if (tstate->recursion_depth > recursion_limit) {
- --tstate->recursion_depth;
- tstate->overflowed = 1;
- _PyErr_Format(tstate, PyExc_RecursionError,
- "maximum recursion depth exceeded%s",
- where);
- return -1;
+ else {
+ if (tstate->recursion_depth > recursion_limit) {
+ tstate->recursion_headroom++;
+ _PyErr_Format(tstate, PyExc_RecursionError,
+ "maximum recursion depth exceeded%s",
+ where);
+ tstate->recursion_headroom--;
+ --tstate->recursion_depth;
+ return -1;
+ }
}
return 0;
}
@@ -948,6 +967,17 @@ eval_frame_handle_pending(PyThreadState *tstate)
return -1;
}
+#ifdef MS_WINDOWS
+ // bpo-42296: On Windows, _PyEval_SignalReceived() can be called in a
+ // different thread than the Python thread, in which case
+ // _Py_ThreadCanHandleSignals() is wrong. Recompute eval_breaker in the
+ // current Python thread with the correct _Py_ThreadCanHandleSignals()
+ // value. It prevents to interrupt the eval loop at every instruction if
+ // the current Python thread cannot handle signals (if
+ // _Py_ThreadCanHandleSignals() is false).
+ COMPUTE_EVAL_BREAKER(tstate->interp, ceval, ceval2);
+#endif
+
return 0;
}
@@ -976,7 +1006,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
is true when the line being executed has changed. The
initial values are such as to make this false the first
time it is tested. */
- int instr_ub = -1, instr_lb = 0, instr_prev = -1;
const _Py_CODEUNIT *first_instr;
PyObject *names;
@@ -1390,6 +1419,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
dtrace_function_entry(f);
co = f->f_code;
+ PyCodeAddressRange bounds;
+ _PyCode_InitAddressRange(co, &bounds);
+ int instr_prev = -1;
+
names = co->co_names;
consts = co->co_consts;
fastlocals = f->f_localsplus;
@@ -1514,7 +1547,7 @@ main_loop:
f->f_lasti = INSTR_OFFSET();
if (PyDTrace_LINE_ENABLED())
- maybe_dtrace_line(f, &instr_lb, &instr_ub, &instr_prev);
+ maybe_dtrace_line(f, &bounds, &instr_prev);
/* line-by-line tracing support */
@@ -1528,7 +1561,7 @@ main_loop:
err = maybe_call_line_trace(tstate->c_tracefunc,
tstate->c_traceobj,
tstate, f,
- &instr_lb, &instr_ub, &instr_prev);
+ &bounds, &instr_prev);
/* Reload possibly changed frame fields */
JUMPTO(f->f_lasti);
stack_pointer = f->f_valuestack+f->f_stackdepth;
@@ -2397,6 +2430,10 @@ main_loop:
}
case TARGET(RERAISE): {
+ assert(f->f_iblock > 0);
+ if (oparg) {
+ f->f_lasti = f->f_blockstack[f->f_iblock-1].b_handler;
+ }
PyObject *exc = POP();
PyObject *val = POP();
PyObject *tb = POP();
@@ -3179,7 +3216,6 @@ main_loop:
if (co_opcache != NULL && /* co_opcache can be NULL after a DEOPT() call. */
type->tp_getattro == PyObject_GenericGetAttr)
{
- PyObject *descr;
Py_ssize_t ret;
if (type->tp_dictoffset > 0) {
@@ -3190,12 +3226,7 @@ main_loop:
goto error;
}
}
-
- descr = _PyType_Lookup(type, name);
- if (descr == NULL ||
- Py_TYPE(descr)->tp_descr_get == NULL ||
- !PyDescr_IsData(descr))
- {
+ if (_PyType_Lookup(type, name) == NULL) {
dictptr = (PyObject **) ((char *)owner + type->tp_dictoffset);
dict = *dictptr;
@@ -3855,7 +3886,7 @@ main_loop:
func ->func_closure = POP();
}
if (oparg & 0x04) {
- assert(PyDict_CheckExact(TOP()));
+ assert(PyTuple_CheckExact(TOP()));
func->func_annotations = POP();
}
if (oparg & 0x02) {
@@ -4012,7 +4043,7 @@ exception_unwind:
int handler = b->b_handler;
_PyErr_StackItem *exc_info = tstate->exc_info;
/* Beware, this invalidates all b->b_* fields */
- PyFrame_BlockSetup(f, EXCEPT_HANDLER, -1, STACK_LEVEL());
+ PyFrame_BlockSetup(f, EXCEPT_HANDLER, f->f_lasti, STACK_LEVEL());
PUSH(exc_info->exc_traceback);
PUSH(exc_info->exc_value);
if (exc_info->exc_type != NULL) {
@@ -4045,14 +4076,7 @@ exception_unwind:
PUSH(exc);
JUMPTO(handler);
if (_Py_TracingPossible(ceval2)) {
- int needs_new_execution_window = (f->f_lasti < instr_lb || f->f_lasti >= instr_ub);
- int needs_line_update = (f->f_lasti == instr_lb || f->f_lasti < instr_prev);
- /* Make sure that we trace line after exception if we are in a new execution
- * window or we don't need a line update and we are not in the first instruction
- * of the line. */
- if (needs_new_execution_window || (!needs_line_update && instr_lb > 0)) {
- instr_prev = INT_MAX;
- }
+ instr_prev = INT_MAX;
}
/* Resume normal execution */
f->f_state = FRAME_EXECUTING;
@@ -4966,7 +4990,7 @@ _PyEval_CallTracing(PyObject *func, PyObject *args)
static int
maybe_call_line_trace(Py_tracefunc func, PyObject *obj,
PyThreadState *tstate, PyFrameObject *frame,
- int *instr_lb, int *instr_ub, int *instr_prev)
+ PyCodeAddressRange *bounds, int *instr_prev)
{
int result = 0;
int line = frame->f_lineno;
@@ -4974,21 +4998,17 @@ maybe_call_line_trace(Py_tracefunc func, PyObject *obj,
/* If the last instruction executed isn't in the current
instruction window, reset the window.
*/
- if (frame->f_lasti < *instr_lb || frame->f_lasti >= *instr_ub) {
- PyAddrPair bounds;
- line = _PyCode_CheckLineNumber(frame->f_code, frame->f_lasti,
- &bounds);
- *instr_lb = bounds.ap_lower;
- *instr_ub = bounds.ap_upper;
- }
+ line = _PyCode_CheckLineNumber(frame->f_lasti, bounds);
/* If the last instruction falls at the start of a line or if it
represents a jump backwards, update the frame's line number and
then call the trace function if we're tracing source lines.
*/
- if ((frame->f_lasti == *instr_lb || frame->f_lasti < *instr_prev)) {
- frame->f_lineno = line;
- if (frame->f_trace_lines) {
- result = call_trace(func, obj, tstate, frame, PyTrace_LINE, Py_None);
+ if ((line != frame->f_lineno || frame->f_lasti < *instr_prev)) {
+ if (line != -1) {
+ frame->f_lineno = line;
+ if (frame->f_trace_lines) {
+ result = call_trace(func, obj, tstate, frame, PyTrace_LINE, Py_None);
+ }
}
}
/* Always emit an opcode event if we're tracing all opcodes. */
@@ -5913,33 +5933,28 @@ dtrace_function_return(PyFrameObject *f)
/* DTrace equivalent of maybe_call_line_trace. */
static void
maybe_dtrace_line(PyFrameObject *frame,
- int *instr_lb, int *instr_ub, int *instr_prev)
+ PyCodeAddressRange *bounds, int *instr_prev)
{
- int line = frame->f_lineno;
const char *co_filename, *co_name;
/* If the last instruction executed isn't in the current
instruction window, reset the window.
*/
- if (frame->f_lasti < *instr_lb || frame->f_lasti >= *instr_ub) {
- PyAddrPair bounds;
- line = _PyCode_CheckLineNumber(frame->f_code, frame->f_lasti,
- &bounds);
- *instr_lb = bounds.ap_lower;
- *instr_ub = bounds.ap_upper;
- }
+ int line = _PyCode_CheckLineNumber(frame->f_lasti, bounds);
/* If the last instruction falls at the start of a line or if
it represents a jump backwards, update the frame's line
number and call the trace function. */
- if (frame->f_lasti == *instr_lb || frame->f_lasti < *instr_prev) {
- frame->f_lineno = line;
- co_filename = PyUnicode_AsUTF8(frame->f_code->co_filename);
- if (!co_filename)
- co_filename = "?";
- co_name = PyUnicode_AsUTF8(frame->f_code->co_name);
- if (!co_name)
- co_name = "?";
- PyDTrace_LINE(co_filename, co_name, line);
+ if (line != frame->f_lineno || frame->f_lasti < *instr_prev) {
+ if (line != -1) {
+ frame->f_lineno = line;
+ co_filename = PyUnicode_AsUTF8(frame->f_code->co_filename);
+ if (!co_filename)
+ co_filename = "?";
+ co_name = PyUnicode_AsUTF8(frame->f_code->co_name);
+ if (!co_name)
+ co_name = "?";
+ PyDTrace_LINE(co_filename, co_name, line);
+ }
}
*instr_prev = frame->f_lasti;
}
diff --git a/Python/compile.c b/Python/compile.c
index 15a9046065..4ba9140000 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -96,6 +96,10 @@ typedef struct basicblock_ {
/* b_return is true if a RETURN_VALUE opcode is inserted. */
unsigned b_return : 1;
unsigned b_reachable : 1;
+ /* Basic block has no fall through (it ends with a return, raise or jump) */
+ unsigned b_nofallthrough : 1;
+ /* Basic block exits scope (it ends with a return or raise) */
+ unsigned b_exit : 1;
/* depth of stack upon entry of block, computed by stackdepth() */
int b_startdepth;
/* instruction offset for block, computed by assemble_jump_offsets() */
@@ -224,7 +228,7 @@ static int compiler_slice(struct compiler *, expr_ty);
static int inplace_binop(operator_ty);
static int are_all_items_const(asdl_expr_seq *, Py_ssize_t, Py_ssize_t);
-static int expr_constant(expr_ty);
+
static int compiler_with(struct compiler *, stmt_ty, int);
static int compiler_async_with(struct compiler *, stmt_ty, int);
@@ -808,6 +812,28 @@ compiler_use_next_block(struct compiler *c, basicblock *block)
return block;
}
+static basicblock *
+compiler_copy_block(struct compiler *c, basicblock *block)
+{
+ /* Cannot copy a block if it has a fallthrough, since
+ * a block can only have one fallthrough predecessor.
+ */
+ assert(block->b_nofallthrough);
+ basicblock *result = compiler_next_block(c);
+ if (result == NULL) {
+ return NULL;
+ }
+ for (int i = 0; i < block->b_iused; i++) {
+ int n = compiler_next_instr(result);
+ if (n < 0) {
+ return NULL;
+ }
+ result->b_instr[n] = block->b_instr[i];
+ }
+ result->b_exit = block->b_exit;
+ return result;
+}
+
/* Returns the offset of the next instruction in the current block's
b_instr array. Resizes the b_instr as necessary.
Returns -1 on failure.
@@ -1406,28 +1432,32 @@ compiler_addop_i(struct compiler *c, int opcode, Py_ssize_t oparg)
return 1;
}
-static int
-compiler_addop_j(struct compiler *c, int opcode, basicblock *b)
+static int add_jump_to_block(basicblock *b, int opcode, int lineno, basicblock *target)
{
- struct instr *i;
- int off;
-
- if (c->c_do_not_emit_bytecode) {
- return 1;
- }
-
assert(HAS_ARG(opcode));
assert(b != NULL);
- off = compiler_next_instr(c->u->u_curblock);
- if (off < 0)
+ assert(target != NULL);
+
+ int off = compiler_next_instr(b);
+ struct instr *i = &b->b_instr[off];
+ if (off < 0) {
return 0;
- i = &c->u->u_curblock->b_instr[off];
+ }
i->i_opcode = opcode;
- i->i_target = b;
- i->i_lineno = c->u->u_lineno;
+ i->i_target = target;
+ i->i_lineno = lineno;
return 1;
}
+static int
+compiler_addop_j(struct compiler *c, int opcode, basicblock *b)
+{
+ if (c->c_do_not_emit_bytecode) {
+ return 1;
+ }
+ return add_jump_to_block(c->u->u_curblock, opcode, c->u->u_lineno, b);
+}
+
/* NEXT_BLOCK() creates an implicit jump from the current block
to the new block.
@@ -1546,17 +1576,6 @@ compiler_addop_j(struct compiler *c, int opcode, basicblock *b)
} \
}
-/* These macros allows to check only for errors and not emmit bytecode
- * while visiting nodes.
-*/
-
-#define BEGIN_DO_NOT_EMIT_BYTECODE { \
- c->c_do_not_emit_bytecode++;
-
-#define END_DO_NOT_EMIT_BYTECODE \
- c->c_do_not_emit_bytecode--; \
-}
-
/* Search if variable annotations are present statically in a block. */
static int
@@ -1680,19 +1699,22 @@ compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info,
return 1;
case FINALLY_TRY:
+ /* This POP_BLOCK gets the line number of the unwinding statement */
ADDOP(c, POP_BLOCK);
if (preserve_tos) {
if (!compiler_push_fblock(c, POP_VALUE, NULL, NULL, NULL)) {
return 0;
}
}
- /* Emit the finally block, restoring the line number when done */
- int saved_lineno = c->u->u_lineno;
+ /* Emit the finally block */
VISIT_SEQ(c, stmt, info->fb_datum);
- c->u->u_lineno = saved_lineno;
if (preserve_tos) {
compiler_pop_fblock(c, POP_VALUE, NULL);
}
+ /* The finally block should appear to execute after the
+ * statement causing the unwinding, so make the unwinding
+ * instruction artificial */
+ c->u->u_lineno = -1;
return 1;
case FINALLY_END:
@@ -1827,7 +1849,7 @@ compiler_mod(struct compiler *c, mod_ty mod)
return NULL;
}
/* Use 0 for firstlineno initially, will fixup in assemble(). */
- if (!compiler_enter_scope(c, module, COMPILER_SCOPE_MODULE, mod, 0))
+ if (!compiler_enter_scope(c, module, COMPILER_SCOPE_MODULE, mod, 1))
return NULL;
switch (mod->kind) {
case Module_kind:
@@ -2023,26 +2045,24 @@ compiler_visit_annexpr(struct compiler *c, expr_ty annotation)
static int
compiler_visit_argannotation(struct compiler *c, identifier id,
- expr_ty annotation, PyObject *names)
+ expr_ty annotation, Py_ssize_t *annotations_len)
{
if (annotation) {
- PyObject *mangled;
- VISIT(c, annexpr, annotation);
- mangled = _Py_Mangle(c->u->u_private, id);
+ PyObject *mangled = _Py_Mangle(c->u->u_private, id);
if (!mangled)
return 0;
- if (PyList_Append(names, mangled) < 0) {
- Py_DECREF(mangled);
- return 0;
- }
+
+ ADDOP_LOAD_CONST(c, mangled);
Py_DECREF(mangled);
+ VISIT(c, annexpr, annotation);
+ *annotations_len += 2;
}
return 1;
}
static int
compiler_visit_argannotations(struct compiler *c, asdl_arg_seq* args,
- PyObject *names)
+ Py_ssize_t *annotations_len)
{
int i;
for (i = 0; i < asdl_seq_LEN(args); i++) {
@@ -2051,7 +2071,7 @@ compiler_visit_argannotations(struct compiler *c, asdl_arg_seq* args,
c,
arg->arg,
arg->annotation,
- names))
+ annotations_len))
return 0;
}
return 1;
@@ -2061,58 +2081,44 @@ static int
compiler_visit_annotations(struct compiler *c, arguments_ty args,
expr_ty returns)
{
- /* Push arg annotation dict.
+ /* Push arg annotation names and values.
The expressions are evaluated out-of-order wrt the source code.
- Return 0 on error, -1 if no dict pushed, 1 if a dict is pushed.
+ Return 0 on error, -1 if no annotations pushed, 1 if a annotations is pushed.
*/
static identifier return_str;
- PyObject *names;
- Py_ssize_t len;
- names = PyList_New(0);
- if (!names)
- return 0;
+ Py_ssize_t annotations_len = 0;
- if (!compiler_visit_argannotations(c, args->args, names))
- goto error;
- if (!compiler_visit_argannotations(c, args->posonlyargs, names))
- goto error;
+ if (!compiler_visit_argannotations(c, args->args, &annotations_len))
+ return 0;
+ if (!compiler_visit_argannotations(c, args->posonlyargs, &annotations_len))
+ return 0;
if (args->vararg && args->vararg->annotation &&
!compiler_visit_argannotation(c, args->vararg->arg,
- args->vararg->annotation, names))
- goto error;
- if (!compiler_visit_argannotations(c, args->kwonlyargs, names))
- goto error;
+ args->vararg->annotation, &annotations_len))
+ return 0;
+ if (!compiler_visit_argannotations(c, args->kwonlyargs, &annotations_len))
+ return 0;
if (args->kwarg && args->kwarg->annotation &&
!compiler_visit_argannotation(c, args->kwarg->arg,
- args->kwarg->annotation, names))
- goto error;
+ args->kwarg->annotation, &annotations_len))
+ return 0;
if (!return_str) {
return_str = PyUnicode_InternFromString("return");
if (!return_str)
- goto error;
+ return 0;
}
- if (!compiler_visit_argannotation(c, return_str, returns, names)) {
- goto error;
+ if (!compiler_visit_argannotation(c, return_str, returns, &annotations_len)) {
+ return 0;
}
- len = PyList_GET_SIZE(names);
- if (len) {
- PyObject *keytuple = PyList_AsTuple(names);
- Py_DECREF(names);
- ADDOP_LOAD_CONST_NEW(c, keytuple);
- ADDOP_I(c, BUILD_CONST_KEY_MAP, len);
+ if (annotations_len) {
+ ADDOP_I(c, BUILD_TUPLE, annotations_len);
return 1;
}
- else {
- Py_DECREF(names);
- return -1;
- }
-error:
- Py_DECREF(names);
- return 0;
+ return -1;
}
static int
@@ -2271,7 +2277,9 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async)
c->u->u_argcount = asdl_seq_LEN(args->args);
c->u->u_posonlyargcount = asdl_seq_LEN(args->posonlyargs);
c->u->u_kwonlyargcount = asdl_seq_LEN(args->kwonlyargs);
- VISIT_SEQ_IN_SCOPE(c, stmt, body);
+ for (i = docstring ? 1 : 0; i < asdl_seq_LEN(body); i++) {
+ VISIT_IN_SCOPE(c, stmt, (stmt_ty)asdl_seq_GET(body, i));
+ }
co = assemble(c, 1);
qualname = c->u->u_qualname;
Py_INCREF(qualname);
@@ -2581,6 +2589,7 @@ compiler_jump_if(struct compiler *c, expr_ty e, basicblock *next, int cond)
VISIT(c, expr, (expr_ty)asdl_seq_GET(e->v.Compare.comparators, n));
ADDOP_COMPARE(c, asdl_seq_GET(e->v.Compare.ops, n));
ADDOP_JUMP(c, cond ? POP_JUMP_IF_TRUE : POP_JUMP_IF_FALSE, next);
+ NEXT_BLOCK(c);
basicblock *end = compiler_new_block(c);
if (end == NULL)
return 0;
@@ -2604,6 +2613,7 @@ compiler_jump_if(struct compiler *c, expr_ty e, basicblock *next, int cond)
/* general implementation */
VISIT(c, expr, e);
ADDOP_JUMP(c, cond ? POP_JUMP_IF_TRUE : POP_JUMP_IF_FALSE, next);
+ NEXT_BLOCK(c);
return 1;
}
@@ -2690,48 +2700,28 @@ static int
compiler_if(struct compiler *c, stmt_ty s)
{
basicblock *end, *next;
- int constant;
assert(s->kind == If_kind);
end = compiler_new_block(c);
- if (end == NULL)
+ if (end == NULL) {
return 0;
-
- constant = expr_constant(s->v.If.test);
- /* constant = 0: "if 0"
- * constant = 1: "if 1", "if 2", ...
- * constant = -1: rest */
- if (constant == 0) {
- BEGIN_DO_NOT_EMIT_BYTECODE
- VISIT_SEQ(c, stmt, s->v.If.body);
- END_DO_NOT_EMIT_BYTECODE
- if (s->v.If.orelse) {
- VISIT_SEQ(c, stmt, s->v.If.orelse);
- }
- } else if (constant == 1) {
- VISIT_SEQ(c, stmt, s->v.If.body);
- if (s->v.If.orelse) {
- BEGIN_DO_NOT_EMIT_BYTECODE
- VISIT_SEQ(c, stmt, s->v.If.orelse);
- END_DO_NOT_EMIT_BYTECODE
- }
- } else {
- if (asdl_seq_LEN(s->v.If.orelse)) {
- next = compiler_new_block(c);
- if (next == NULL)
- return 0;
- }
- else {
- next = end;
- }
- if (!compiler_jump_if(c, s->v.If.test, next, 0)) {
+ }
+ if (asdl_seq_LEN(s->v.If.orelse)) {
+ next = compiler_new_block(c);
+ if (next == NULL) {
return 0;
}
- VISIT_SEQ(c, stmt, s->v.If.body);
- if (asdl_seq_LEN(s->v.If.orelse)) {
- ADDOP_JUMP(c, JUMP_FORWARD, end);
- compiler_use_next_block(c, next);
- VISIT_SEQ(c, stmt, s->v.If.orelse);
- }
+ }
+ else {
+ next = end;
+ }
+ if (!compiler_jump_if(c, s->v.If.test, next, 0)) {
+ return 0;
+ }
+ VISIT_SEQ(c, stmt, s->v.If.body);
+ if (asdl_seq_LEN(s->v.If.orelse)) {
+ ADDOP_JUMP(c, JUMP_FORWARD, end);
+ compiler_use_next_block(c, next);
+ VISIT_SEQ(c, stmt, s->v.If.orelse);
}
compiler_use_next_block(c, end);
return 1;
@@ -2740,12 +2730,13 @@ compiler_if(struct compiler *c, stmt_ty s)
static int
compiler_for(struct compiler *c, stmt_ty s)
{
- basicblock *start, *cleanup, *end;
+ basicblock *start, *body, *cleanup, *end;
start = compiler_new_block(c);
+ body = compiler_new_block(c);
cleanup = compiler_new_block(c);
end = compiler_new_block(c);
- if (start == NULL || end == NULL || cleanup == NULL) {
+ if (start == NULL || body == NULL || end == NULL || cleanup == NULL) {
return 0;
}
if (!compiler_push_fblock(c, FOR_LOOP, start, end, NULL)) {
@@ -2755,8 +2746,11 @@ compiler_for(struct compiler *c, stmt_ty s)
ADDOP(c, GET_ITER);
compiler_use_next_block(c, start);
ADDOP_JUMP(c, FOR_ITER, cleanup);
+ compiler_use_next_block(c, body);
VISIT(c, expr, s->v.For.target);
VISIT_SEQ(c, stmt, s->v.For.body);
+ /* Mark jump as artificial */
+ c->u->u_lineno = -1;
ADDOP_JUMP(c, JUMP_ABSOLUTE, start);
compiler_use_next_block(c, cleanup);
@@ -2808,6 +2802,8 @@ compiler_async_for(struct compiler *c, stmt_ty s)
/* Except block for __anext__ */
compiler_use_next_block(c, except);
+
+ c->u->u_lineno = -1;
ADDOP(c, END_ASYNC_FOR);
/* `else` block */
@@ -2821,63 +2817,35 @@ compiler_async_for(struct compiler *c, stmt_ty s)
static int
compiler_while(struct compiler *c, stmt_ty s)
{
- basicblock *loop, *orelse, *end, *anchor = NULL;
- int constant = expr_constant(s->v.While.test);
-
- if (constant == 0) {
- BEGIN_DO_NOT_EMIT_BYTECODE
- // Push a dummy block so the VISIT_SEQ knows that we are
- // inside a while loop so it can correctly evaluate syntax
- // errors.
- if (!compiler_push_fblock(c, WHILE_LOOP, NULL, NULL, NULL)) {
- return 0;
- }
- VISIT_SEQ(c, stmt, s->v.While.body);
- // Remove the dummy block now that is not needed.
- compiler_pop_fblock(c, WHILE_LOOP, NULL);
- END_DO_NOT_EMIT_BYTECODE
- if (s->v.While.orelse) {
- VISIT_SEQ(c, stmt, s->v.While.orelse);
- }
- return 1;
- }
+ basicblock *loop, *body, *end, *anchor = NULL;
loop = compiler_new_block(c);
+ body = compiler_new_block(c);
+ anchor = compiler_new_block(c);
end = compiler_new_block(c);
- if (constant == -1) {
- anchor = compiler_new_block(c);
- if (anchor == NULL)
- return 0;
- }
- if (loop == NULL || end == NULL)
+ if (loop == NULL || body == NULL || anchor == NULL || end == NULL) {
return 0;
- if (s->v.While.orelse) {
- orelse = compiler_new_block(c);
- if (orelse == NULL)
- return 0;
}
- else
- orelse = NULL;
-
compiler_use_next_block(c, loop);
- if (!compiler_push_fblock(c, WHILE_LOOP, loop, end, NULL))
+ if (!compiler_push_fblock(c, WHILE_LOOP, loop, end, NULL)) {
+ return 0;
+ }
+ if (!compiler_jump_if(c, s->v.While.test, anchor, 0)) {
return 0;
- if (constant == -1) {
- if (!compiler_jump_if(c, s->v.While.test, anchor, 0))
- return 0;
}
- VISIT_SEQ(c, stmt, s->v.While.body);
- ADDOP_JUMP(c, JUMP_ABSOLUTE, loop);
- /* XXX should the two POP instructions be in a separate block
- if there is no else clause ?
- */
+ compiler_use_next_block(c, body);
+ VISIT_SEQ(c, stmt, s->v.While.body);
+ SET_LOC(c, s);
+ if (!compiler_jump_if(c, s->v.While.test, body, 1)) {
+ return 0;
+ }
- if (constant == -1)
- compiler_use_next_block(c, anchor);
compiler_pop_fblock(c, WHILE_LOOP, loop);
- if (orelse != NULL) /* what if orelse is just pass? */
+ compiler_use_next_block(c, anchor);
+ if (s->v.While.orelse) {
VISIT_SEQ(c, stmt, s->v.While.orelse);
+ }
compiler_use_next_block(c, end);
return 1;
@@ -2898,6 +2866,12 @@ compiler_return(struct compiler *c, stmt_ty s)
}
if (preserve_tos) {
VISIT(c, expr, s->v.Return.value);
+ } else {
+ /* Emit instruction with line number for expression */
+ if (s->v.Return.value != NULL) {
+ SET_LOC(c, s->v.Return.value);
+ ADDOP(c, NOP);
+ }
}
if (!compiler_unwind_fblock_stack(c, preserve_tos, NULL))
return 0;
@@ -2905,9 +2879,10 @@ compiler_return(struct compiler *c, stmt_ty s)
ADDOP_LOAD_CONST(c, Py_None);
}
else if (!preserve_tos) {
- VISIT(c, expr, s->v.Return.value);
+ ADDOP_LOAD_CONST(c, s->v.Return.value->v.Constant.value);
}
ADDOP(c, RETURN_VALUE);
+ NEXT_BLOCK(c);
return 1;
}
@@ -2926,6 +2901,7 @@ compiler_break(struct compiler *c)
return 0;
}
ADDOP_JUMP(c, JUMP_ABSOLUTE, loop->fb_exit);
+ NEXT_BLOCK(c);
return 1;
}
@@ -2940,6 +2916,7 @@ compiler_continue(struct compiler *c)
return compiler_error(c, "'continue' not properly in loop");
}
ADDOP_JUMP(c, JUMP_ABSOLUTE, loop->fb_block);
+ NEXT_BLOCK(c)
return 1;
}
@@ -2996,6 +2973,8 @@ compiler_try_finally(struct compiler *c, stmt_ty s)
else {
VISIT_SEQ(c, stmt, s->v.Try.body);
}
+ /* Mark code as artificial */
+ c->u->u_lineno = -1;
ADDOP(c, POP_BLOCK);
compiler_pop_fblock(c, FINALLY_TRY, body);
VISIT_SEQ(c, stmt, s->v.Try.finalbody);
@@ -3006,7 +2985,7 @@ compiler_try_finally(struct compiler *c, stmt_ty s)
return 0;
VISIT_SEQ(c, stmt, s->v.Try.finalbody);
compiler_pop_fblock(c, FINALLY_END, end);
- ADDOP(c, RERAISE);
+ ADDOP_I(c, RERAISE, 0);
compiler_use_next_block(c, exit);
return 1;
}
@@ -3079,6 +3058,7 @@ compiler_try_except(struct compiler *c, stmt_ty s)
ADDOP(c, DUP_TOP);
VISIT(c, expr, handler->v.ExceptHandler.type);
ADDOP_JUMP(c, JUMP_IF_NOT_EXC_MATCH, except);
+ NEXT_BLOCK(c);
}
ADDOP(c, POP_TOP);
if (handler->v.ExceptHandler.name) {
@@ -3115,7 +3095,8 @@ compiler_try_except(struct compiler *c, stmt_ty s)
compiler_pop_fblock(c, HANDLER_CLEANUP, cleanup_body);
ADDOP(c, POP_BLOCK);
ADDOP(c, POP_EXCEPT);
- /* name = None; del name */
+ /* name = None; del name; # Mark as artificial */
+ c->u->u_lineno = -1;
ADDOP_LOAD_CONST(c, Py_None);
compiler_nameop(c, handler->v.ExceptHandler.name, Store);
compiler_nameop(c, handler->v.ExceptHandler.name, Del);
@@ -3124,12 +3105,13 @@ compiler_try_except(struct compiler *c, stmt_ty s)
/* except: */
compiler_use_next_block(c, cleanup_end);
- /* name = None; del name */
+ /* name = None; del name; # Mark as artificial */
+ c->u->u_lineno = -1;
ADDOP_LOAD_CONST(c, Py_None);
compiler_nameop(c, handler->v.ExceptHandler.name, Store);
compiler_nameop(c, handler->v.ExceptHandler.name, Del);
- ADDOP(c, RERAISE);
+ ADDOP_I(c, RERAISE, 1);
}
else {
basicblock *cleanup_body;
@@ -3151,7 +3133,9 @@ compiler_try_except(struct compiler *c, stmt_ty s)
compiler_use_next_block(c, except);
}
compiler_pop_fblock(c, EXCEPTION_HANDLER, NULL);
- ADDOP(c, RERAISE);
+ /* Mark as artificial */
+ c->u->u_lineno = -1;
+ ADDOP_I(c, RERAISE, 0);
compiler_use_next_block(c, orelse);
VISIT_SEQ(c, stmt, s->v.Try.orelse);
compiler_use_next_block(c, end);
@@ -3359,6 +3343,7 @@ compiler_visit_stmt_expr(struct compiler *c, expr_ty value)
if (value->kind == Constant_kind) {
/* ignore constant statement */
+ ADDOP(c, NOP);
return 1;
}
@@ -3416,6 +3401,7 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
}
}
ADDOP_I(c, RAISE_VARARGS, (int)n);
+ NEXT_BLOCK(c);
break;
case Try_kind:
return compiler_try(c, s);
@@ -3431,6 +3417,7 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
case Expr_kind:
return compiler_visit_stmt_expr(c, s->v.Expr.value);
case Pass_kind:
+ ADDOP(c, NOP);
break;
case Break_kind:
return compiler_break(c);
@@ -4771,22 +4758,14 @@ compiler_visit_keyword(struct compiler *c, keyword_ty k)
*/
static int
-expr_constant(expr_ty e)
-{
- if (e->kind == Constant_kind) {
- return PyObject_IsTrue(e->v.Constant.value);
- }
- return -1;
-}
-
-static int
compiler_with_except_finish(struct compiler *c) {
basicblock *exit;
exit = compiler_new_block(c);
if (exit == NULL)
return 0;
ADDOP_JUMP(c, POP_JUMP_IF_TRUE, exit);
- ADDOP(c, RERAISE);
+ NEXT_BLOCK(c);
+ ADDOP_I(c, RERAISE, 1);
compiler_use_next_block(c, exit);
ADDOP(c, POP_TOP);
ADDOP(c, POP_TOP);
@@ -5426,27 +5405,14 @@ struct assembler {
PyObject *a_bytecode; /* string containing bytecode */
int a_offset; /* offset into bytecode */
int a_nblocks; /* number of reachable blocks */
- basicblock **a_reverse_postorder; /* list of blocks in dfs postorder */
PyObject *a_lnotab; /* string containing lnotab */
int a_lnotab_off; /* offset into lnotab */
- int a_lineno; /* last lineno of emitted instruction */
- int a_lineno_off; /* bytecode offset of last lineno */
+ int a_prevlineno; /* lineno of last emitted line in line table */
+ int a_lineno; /* lineno of last emitted instruction */
+ int a_lineno_start; /* bytecode start offset of current lineno */
+ basicblock *a_entry;
};
-static void
-dfs(struct compiler *c, basicblock *b, struct assembler *a, int end)
-{
-
- /* There is no real depth-first-search to do here because all the
- * blocks are emitted in topological order already, so we just need to
- * follow the b_next pointers and place them in a->a_reverse_postorder in
- * reverse order and make sure that the first one starts at 0. */
-
- for (a->a_nblocks = 0; b != NULL; b = b->b_next) {
- a->a_reverse_postorder[a->a_nblocks++] = b;
- }
-}
-
Py_LOCAL_INLINE(void)
stackdepth_push(basicblock ***sp, basicblock *b, int depth)
{
@@ -5522,6 +5488,7 @@ stackdepth(struct compiler *c)
}
}
if (next != NULL) {
+ assert(b->b_nofallthrough == 0);
stackdepth_push(&sp, next, depth);
}
}
@@ -5533,24 +5500,25 @@ static int
assemble_init(struct assembler *a, int nblocks, int firstlineno)
{
memset(a, 0, sizeof(struct assembler));
- a->a_lineno = firstlineno;
+ a->a_prevlineno = a->a_lineno = firstlineno;
+ a->a_lnotab = NULL;
a->a_bytecode = PyBytes_FromStringAndSize(NULL, DEFAULT_CODE_SIZE);
- if (!a->a_bytecode)
- return 0;
+ if (a->a_bytecode == NULL) {
+ goto error;
+ }
a->a_lnotab = PyBytes_FromStringAndSize(NULL, DEFAULT_LNOTAB_SIZE);
- if (!a->a_lnotab)
- return 0;
- if ((size_t)nblocks > SIZE_MAX / sizeof(basicblock *)) {
- PyErr_NoMemory();
- return 0;
+ if (a->a_lnotab == NULL) {
+ goto error;
}
- a->a_reverse_postorder = (basicblock **)PyObject_Malloc(
- sizeof(basicblock *) * nblocks);
- if (!a->a_reverse_postorder) {
+ if ((size_t)nblocks > SIZE_MAX / sizeof(basicblock *)) {
PyErr_NoMemory();
- return 0;
+ goto error;
}
return 1;
+error:
+ Py_XDECREF(a->a_bytecode);
+ Py_XDECREF(a->a_lnotab);
+ return 0;
}
static void
@@ -5558,8 +5526,6 @@ assemble_free(struct assembler *a)
{
Py_XDECREF(a->a_bytecode);
Py_XDECREF(a->a_lnotab);
- if (a->a_reverse_postorder)
- PyObject_Free(a->a_reverse_postorder);
}
static int
@@ -5573,114 +5539,82 @@ blocksize(basicblock *b)
return size;
}
-/* Appends a pair to the end of the line number table, a_lnotab, representing
- the instruction's bytecode offset and line number. See
- Objects/lnotab_notes.txt for the description of the line number table. */
-
static int
-assemble_lnotab(struct assembler *a, struct instr *i)
+assemble_emit_linetable_pair(struct assembler *a, int bdelta, int ldelta)
{
- int d_bytecode, d_lineno;
- Py_ssize_t len;
- unsigned char *lnotab;
-
- d_lineno = i->i_lineno - a->a_lineno;
- if (d_lineno == 0) {
- return 1;
+ Py_ssize_t len = PyBytes_GET_SIZE(a->a_lnotab);
+ if (a->a_lnotab_off + 2 >= len) {
+ if (_PyBytes_Resize(&a->a_lnotab, len * 2) < 0)
+ return 0;
}
+ unsigned char *lnotab = (unsigned char *)
+ PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+
+ a->a_lnotab_off += 2;
+ *lnotab++ = bdelta;
+ *lnotab++ = ldelta;
+ return 1;
+}
- d_bytecode = (a->a_offset - a->a_lineno_off) * sizeof(_Py_CODEUNIT);
- assert(d_bytecode >= 0);
+/* Appends a range to the end of the line number table. See
+ * Objects/lnotab_notes.txt for the description of the line number table. */
- if (d_bytecode > 255) {
- int j, nbytes, ncodes = d_bytecode / 255;
- nbytes = a->a_lnotab_off + 2 * ncodes;
- len = PyBytes_GET_SIZE(a->a_lnotab);
- if (nbytes >= len) {
- if ((len <= INT_MAX / 2) && (len * 2 < nbytes))
- len = nbytes;
- else if (len <= INT_MAX / 2)
- len *= 2;
- else {
- PyErr_NoMemory();
+static int
+assemble_line_range(struct assembler *a)
+{
+ int ldelta, bdelta;
+ bdelta = (a->a_offset - a->a_lineno_start) * 2;
+ if (bdelta == 0) {
+ return 1;
+ }
+ if (a->a_lineno < 0) {
+ ldelta = -128;
+ }
+ else {
+ ldelta = a->a_lineno - a->a_prevlineno;
+ a->a_prevlineno = a->a_lineno;
+ while (ldelta > 127) {
+ if (!assemble_emit_linetable_pair(a, 0, 127)) {
return 0;
}
- if (_PyBytes_Resize(&a->a_lnotab, len) < 0)
- return 0;
- }
- lnotab = (unsigned char *)
- PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
- for (j = 0; j < ncodes; j++) {
- *lnotab++ = 255;
- *lnotab++ = 0;
- }
- d_bytecode -= ncodes * 255;
- a->a_lnotab_off += ncodes * 2;
- }
- assert(0 <= d_bytecode && d_bytecode <= 255);
-
- if (d_lineno < -128 || 127 < d_lineno) {
- int j, nbytes, ncodes, k;
- if (d_lineno < 0) {
- k = -128;
- /* use division on positive numbers */
- ncodes = (-d_lineno) / 128;
+ ldelta -= 127;
}
- else {
- k = 127;
- ncodes = d_lineno / 127;
- }
- d_lineno -= ncodes * k;
- assert(ncodes >= 1);
- nbytes = a->a_lnotab_off + 2 * ncodes;
- len = PyBytes_GET_SIZE(a->a_lnotab);
- if (nbytes >= len) {
- if ((len <= INT_MAX / 2) && len * 2 < nbytes)
- len = nbytes;
- else if (len <= INT_MAX / 2)
- len *= 2;
- else {
- PyErr_NoMemory();
+ while (ldelta < -127) {
+ if (!assemble_emit_linetable_pair(a, 0, -127)) {
return 0;
}
- if (_PyBytes_Resize(&a->a_lnotab, len) < 0)
- return 0;
+ ldelta += 127;
}
- lnotab = (unsigned char *)
- PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
- *lnotab++ = d_bytecode;
- *lnotab++ = k;
- d_bytecode = 0;
- for (j = 1; j < ncodes; j++) {
- *lnotab++ = 0;
- *lnotab++ = k;
- }
- a->a_lnotab_off += ncodes * 2;
}
- assert(-128 <= d_lineno && d_lineno <= 127);
-
- len = PyBytes_GET_SIZE(a->a_lnotab);
- if (a->a_lnotab_off + 2 >= len) {
- if (_PyBytes_Resize(&a->a_lnotab, len * 2) < 0)
+ assert(-128 <= ldelta && ldelta < 128);
+ while (bdelta > 254) {
+ if (!assemble_emit_linetable_pair(a, 254, ldelta)) {
return 0;
+ }
+ ldelta = a->a_lineno < 0 ? -128 : 0;
+ bdelta -= 254;
}
- lnotab = (unsigned char *)
- PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+ if (!assemble_emit_linetable_pair(a, bdelta, ldelta)) {
+ return 0;
+ }
+ a->a_lineno_start = a->a_offset;
+ return 1;
+}
- a->a_lnotab_off += 2;
- if (d_bytecode) {
- *lnotab++ = d_bytecode;
- *lnotab++ = d_lineno;
+static int
+assemble_lnotab(struct assembler *a, struct instr *i)
+{
+ if (i->i_lineno == a->a_lineno) {
+ return 1;
}
- else { /* First line of a block; def stmt, etc. */
- *lnotab++ = 0;
- *lnotab++ = d_lineno;
+ if (!assemble_line_range(a)) {
+ return 0;
}
a->a_lineno = i->i_lineno;
- a->a_lineno_off = a->a_offset;
return 1;
}
+
/* assemble_emit()
Extend the bytecode with a new instruction.
Update lnotab if necessary.
@@ -5720,8 +5654,7 @@ assemble_jump_offsets(struct assembler *a, struct compiler *c)
Replace block pointer with position in bytecode. */
do {
totsize = 0;
- for (i = 0; i < a->a_nblocks; i++) {
- b = a->a_reverse_postorder[i];
+ for (basicblock *b = a->a_entry; b != NULL; b = b->b_next) {
bsize = blocksize(b);
b->b_offset = totsize;
totsize += bsize;
@@ -5981,15 +5914,22 @@ dump_basicblock(const basicblock *b)
}
#endif
+
+static int
+normalize_basic_block(basicblock *bb);
+
static int
optimize_cfg(struct assembler *a, PyObject *consts);
+static int
+ensure_exits_have_lineno(struct compiler *c);
+
static PyCodeObject *
assemble(struct compiler *c, int addNone)
{
basicblock *b, *entryblock;
struct assembler a;
- int i, j, nblocks;
+ int j, nblocks;
PyCodeObject *co = NULL;
PyObject *consts = NULL;
@@ -5998,12 +5938,22 @@ assemble(struct compiler *c, int addNone)
block ends with a jump or return b_next shouldn't set.
*/
if (!c->u->u_curblock->b_return) {
- NEXT_BLOCK(c);
+ c->u->u_lineno = -1;
if (addNone)
ADDOP_LOAD_CONST(c, Py_None);
ADDOP(c, RETURN_VALUE);
}
+ for (basicblock *b = c->u->u_blocks; b != NULL; b = b->b_list) {
+ if (normalize_basic_block(b)) {
+ goto error;
+ }
+ }
+
+ if (ensure_exits_have_lineno(c)) {
+ goto error;
+ }
+
nblocks = 0;
entryblock = NULL;
for (b = c->u->u_blocks; b != NULL; b = b->b_list) {
@@ -6015,12 +5965,14 @@ assemble(struct compiler *c, int addNone)
if (!c->u->u_firstlineno) {
if (entryblock && entryblock->b_instr && entryblock->b_instr->i_lineno)
c->u->u_firstlineno = entryblock->b_instr->i_lineno;
- else
+ else
c->u->u_firstlineno = 1;
}
+
if (!assemble_init(&a, nblocks, c->u->u_firstlineno))
goto error;
- dfs(c, entryblock, &a, nblocks);
+ a.a_entry = entryblock;
+ a.a_nblocks = nblocks;
consts = consts_dict_keys_inorder(c->u->u_consts);
if (consts == NULL) {
@@ -6033,13 +5985,19 @@ assemble(struct compiler *c, int addNone)
/* Can't modify the bytecode after computing jump offsets. */
assemble_jump_offsets(&a, c);
- /* Emit code in reverse postorder from dfs. */
- for (i = 0; i < a.a_nblocks; i++) {
- b = a.a_reverse_postorder[i];
+ /* Emit code. */
+ for(b = entryblock; b != NULL; b = b->b_next) {
for (j = 0; j < b->b_iused; j++)
if (!assemble_emit(&a, &b->b_instr[j]))
goto error;
}
+ if (!assemble_line_range(&a)) {
+ return 0;
+ }
+ /* Emit sentinel at end of line number table */
+ if (!assemble_emit_linetable_pair(&a, 255, -128)) {
+ goto error;
+ }
if (_PyBytes_Resize(&a.a_lnotab, a.a_lnotab_off) < 0)
goto error;
@@ -6114,6 +6072,29 @@ fold_tuple_on_constants(struct instr *inst,
}
+static int
+eliminate_jump_to_jump(basicblock *bb, int opcode) {
+ assert (bb->b_iused > 0);
+ struct instr *inst = &bb->b_instr[bb->b_iused-1];
+ assert (is_jump(inst));
+ assert (inst->i_target->b_iused > 0);
+ struct instr *target = &inst->i_target->b_instr[0];
+ if (inst->i_target == target->i_target) {
+ /* Nothing to do */
+ return 0;
+ }
+ int lineno = target->i_lineno;
+ if (add_jump_to_block(bb, opcode, lineno, target->i_target) == 0) {
+ return -1;
+ }
+ assert (bb->b_iused >= 2);
+ bb->b_instr[bb->b_iused-2].i_opcode = NOP;
+ return 0;
+}
+
+/* Maximum size of basic block that should be copied in optimizer */
+#define MAX_COPY_SIZE 4
+
/* Optimization */
static int
optimize_basic_block(basicblock *bb, PyObject *consts)
@@ -6122,7 +6103,6 @@ optimize_basic_block(basicblock *bb, PyObject *consts)
struct instr nop;
nop.i_opcode = NOP;
struct instr *target;
- int lineno;
for (int i = 0; i < bb->b_iused; i++) {
struct instr *inst = &bb->b_instr[i];
int oparg = inst->i_oparg;
@@ -6138,23 +6118,50 @@ optimize_basic_block(basicblock *bb, PyObject *consts)
target = &nop;
}
switch (inst->i_opcode) {
- /* Skip over LOAD_CONST trueconst
- POP_JUMP_IF_FALSE xx. This improves
- "while 1" performance. */
+ /* Remove LOAD_CONST const; conditional jump */
case LOAD_CONST:
- if (nextop != POP_JUMP_IF_FALSE) {
- break;
- }
- PyObject* cnt = PyList_GET_ITEM(consts, oparg);
- int is_true = PyObject_IsTrue(cnt);
- if (is_true == -1) {
- goto error;
- }
- if (is_true == 1) {
- inst->i_opcode = NOP;
- bb->b_instr[i+1].i_opcode = NOP;
+ {
+ PyObject* cnt;
+ int is_true;
+ int jump_if_true;
+ switch(nextop) {
+ case POP_JUMP_IF_FALSE:
+ case POP_JUMP_IF_TRUE:
+ cnt = PyList_GET_ITEM(consts, oparg);
+ is_true = PyObject_IsTrue(cnt);
+ if (is_true == -1) {
+ goto error;
+ }
+ inst->i_opcode = NOP;
+ jump_if_true = nextop == POP_JUMP_IF_TRUE;
+ if (is_true == jump_if_true) {
+ bb->b_instr[i+1].i_opcode = JUMP_ABSOLUTE;
+ bb->b_nofallthrough = 1;
+ }
+ else {
+ bb->b_instr[i+1].i_opcode = NOP;
+ }
+ break;
+ case JUMP_IF_FALSE_OR_POP:
+ case JUMP_IF_TRUE_OR_POP:
+ cnt = PyList_GET_ITEM(consts, oparg);
+ is_true = PyObject_IsTrue(cnt);
+ if (is_true == -1) {
+ goto error;
+ }
+ jump_if_true = nextop == JUMP_IF_TRUE_OR_POP;
+ if (is_true == jump_if_true) {
+ bb->b_instr[i+1].i_opcode = JUMP_ABSOLUTE;
+ bb->b_nofallthrough = 1;
+ }
+ else {
+ inst->i_opcode = NOP;
+ bb->b_instr[i+1].i_opcode = NOP;
+ }
+ break;
}
break;
+ }
/* Try to fold tuples of constants.
Skip over BUILD_SEQN 1 UNPACK_SEQN 1.
@@ -6201,17 +6208,27 @@ optimize_basic_block(basicblock *bb, PyObject *consts)
case JUMP_IF_FALSE_OR_POP:
switch(target->i_opcode) {
case POP_JUMP_IF_FALSE:
- *inst = *target;
+ if (inst->i_lineno == target->i_lineno) {
+ *inst = *target;
+ i--;
+ }
break;
case JUMP_ABSOLUTE:
case JUMP_FORWARD:
case JUMP_IF_FALSE_OR_POP:
- inst->i_target = target->i_target;
+ if (inst->i_lineno == target->i_lineno &&
+ inst->i_target != target->i_target) {
+ inst->i_target = target->i_target;
+ i--;
+ }
break;
case JUMP_IF_TRUE_OR_POP:
assert (inst->i_target->b_iused == 1);
- inst->i_opcode = POP_JUMP_IF_FALSE;
- inst->i_target = inst->i_target->b_next;
+ if (inst->i_lineno == target->i_lineno) {
+ inst->i_opcode = POP_JUMP_IF_FALSE;
+ inst->i_target = inst->i_target->b_next;
+ --i;
+ }
break;
}
break;
@@ -6219,17 +6236,27 @@ optimize_basic_block(basicblock *bb, PyObject *consts)
case JUMP_IF_TRUE_OR_POP:
switch(target->i_opcode) {
case POP_JUMP_IF_TRUE:
- *inst = *target;
+ if (inst->i_lineno == target->i_lineno) {
+ *inst = *target;
+ i--;
+ }
break;
case JUMP_ABSOLUTE:
case JUMP_FORWARD:
case JUMP_IF_TRUE_OR_POP:
- inst->i_target = target->i_target;
+ if (inst->i_lineno == target->i_lineno &&
+ inst->i_target != target->i_target) {
+ inst->i_target = target->i_target;
+ i--;
+ }
break;
case JUMP_IF_FALSE_OR_POP:
assert (inst->i_target->b_iused == 1);
- inst->i_opcode = POP_JUMP_IF_TRUE;
- inst->i_target = inst->i_target->b_next;
+ if (inst->i_lineno == target->i_lineno) {
+ inst->i_opcode = POP_JUMP_IF_TRUE;
+ inst->i_target = inst->i_target->b_next;
+ --i;
+ }
break;
}
break;
@@ -6238,7 +6265,10 @@ optimize_basic_block(basicblock *bb, PyObject *consts)
switch(target->i_opcode) {
case JUMP_ABSOLUTE:
case JUMP_FORWARD:
- inst->i_target = target->i_target;
+ if (inst->i_lineno == target->i_lineno) {
+ inst->i_target = target->i_target;
+ i--;
+ }
break;
}
break;
@@ -6247,27 +6277,43 @@ optimize_basic_block(basicblock *bb, PyObject *consts)
switch(target->i_opcode) {
case JUMP_ABSOLUTE:
case JUMP_FORWARD:
- inst->i_target = target->i_target;
+ if (inst->i_lineno == target->i_lineno) {
+ inst->i_target = target->i_target;
+ i--;
+ }
break;
}
break;
case JUMP_ABSOLUTE:
case JUMP_FORWARD:
+ assert (i == bb->b_iused-1);
switch(target->i_opcode) {
case JUMP_FORWARD:
- inst->i_target = target->i_target;
+ if (eliminate_jump_to_jump(bb, inst->i_opcode)) {
+ goto error;
+ }
break;
+
case JUMP_ABSOLUTE:
- case RETURN_VALUE:
- case RERAISE:
- case RAISE_VARARGS:
- lineno = inst->i_lineno;
- *inst = *target;
- inst->i_lineno = lineno;
+ if (eliminate_jump_to_jump(bb, JUMP_ABSOLUTE)) {
+ goto error;
+ }
break;
+ default:
+ if (inst->i_target->b_exit && inst->i_target->b_iused <= MAX_COPY_SIZE) {
+ basicblock *to_copy = inst->i_target;
+ inst->i_opcode = NOP;
+ for (i = 0; i < to_copy->b_iused; i++) {
+ int index = compiler_next_instr(bb);
+ if (index < 0) {
+ return -1;
+ }
+ bb->b_instr[index] = to_copy->b_instr[i];
+ }
+ bb->b_exit = 1;
+ }
}
- break;
}
}
return 0;
@@ -6278,45 +6324,99 @@ error:
static void
clean_basic_block(basicblock *bb) {
- /* Remove NOPs and any code following a return or re-raise. */
+ /* Remove NOPs. */
int dest = 0;
+ int prev_lineno = -1;
for (int src = 0; src < bb->b_iused; src++) {
- switch(bb->b_instr[src].i_opcode) {
- case NOP:
- /* skip */
- break;
- case RETURN_VALUE:
- case RERAISE:
- bb->b_next = NULL;
- bb->b_instr[dest] = bb->b_instr[src];
- dest++;
- goto end;
- default:
- if (dest != src) {
- bb->b_instr[dest] = bb->b_instr[src];
+ int lineno = bb->b_instr[src].i_lineno;
+ if (bb->b_instr[src].i_opcode == NOP) {
+ /* Eliminate no-op if it doesn't have a line number */
+ if (lineno < 0) {
+ continue;
+ }
+ /* or, if the previous instruction had the same line number. */
+ if (prev_lineno == lineno) {
+ continue;
+ }
+ /* or, if the next instruction has same line number or no line number */
+ if (src < bb->b_iused - 1) {
+ int next_lineno = bb->b_instr[src+1].i_lineno;
+ if (next_lineno < 0 || next_lineno == lineno) {
+ bb->b_instr[src+1].i_lineno = lineno;
+ continue;
}
- dest++;
- break;
+ }
+ else {
+ basicblock* next = bb->b_next;
+ while (next && next->b_iused == 0) {
+ next = next->b_next;
+ }
+ /* or if last instruction in BB and next BB has same line number */
+ if (next) {
+ if (lineno == next->b_instr[0].i_lineno) {
+ continue;
+ }
+ }
+ }
+
+ }
+ if (dest != src) {
+ bb->b_instr[dest] = bb->b_instr[src];
}
+ dest++;
+ prev_lineno = lineno;
}
-end:
assert(dest <= bb->b_iused);
bb->b_iused = dest;
}
static int
+normalize_basic_block(basicblock *bb) {
+ /* Mark blocks as exit and/or nofallthrough.
+ Raise SystemError if CFG is malformed. */
+ for (int i = 0; i < bb->b_iused; i++) {
+ switch(bb->b_instr[i].i_opcode) {
+ case RETURN_VALUE:
+ case RAISE_VARARGS:
+ case RERAISE:
+ bb->b_exit = 1;
+ bb->b_nofallthrough = 1;
+ break;
+ case JUMP_ABSOLUTE:
+ case JUMP_FORWARD:
+ bb->b_nofallthrough = 1;
+ /* fall through */
+ case POP_JUMP_IF_FALSE:
+ case POP_JUMP_IF_TRUE:
+ case JUMP_IF_FALSE_OR_POP:
+ case JUMP_IF_TRUE_OR_POP:
+ case FOR_ITER:
+ if (i != bb->b_iused-1) {
+ PyErr_SetString(PyExc_SystemError, "malformed control flow graph.");
+ return -1;
+ }
+ /* Skip over empty basic blocks. */
+ while (bb->b_instr[i].i_target->b_iused == 0) {
+ bb->b_instr[i].i_target = bb->b_instr[i].i_target->b_next;
+ }
+
+ }
+ }
+ return 0;
+}
+
+static int
mark_reachable(struct assembler *a) {
basicblock **stack, **sp;
sp = stack = (basicblock **)PyObject_Malloc(sizeof(basicblock *) * a->a_nblocks);
if (stack == NULL) {
return -1;
}
- basicblock *entry = a->a_reverse_postorder[0];
- entry->b_reachable = 1;
- *sp++ = entry;
+ a->a_entry->b_reachable = 1;
+ *sp++ = a->a_entry;
while (sp > stack) {
basicblock *b = *(--sp);
- if (b->b_next && b->b_next->b_reachable == 0) {
+ if (b->b_next && !b->b_nofallthrough && b->b_next->b_reachable == 0) {
b->b_next->b_reachable = 1;
*sp++ = b->b_next;
}
@@ -6335,8 +6435,27 @@ mark_reachable(struct assembler *a) {
return 0;
}
+/* If an instruction has no line number, but it's predecessor in the BB does,
+ * then copy the line number. This reduces the size of the line number table,
+ * but has no impact on the generated line number events.
+ */
+static void
+minimize_lineno_table(struct assembler *a) {
+ for (basicblock *b = a->a_entry; b != NULL; b = b->b_next) {
+ int prev_lineno = -1;
+ for (int i = 0; i < b->b_iused; i++) {
+ if (b->b_instr[i].i_lineno < 0) {
+ b->b_instr[i].i_lineno = prev_lineno;
+ }
+ else {
+ prev_lineno = b->b_instr[i].i_lineno;
+ }
+ }
+
+ }
+}
-/* Perform basic peephole optimizations on a control flow graph.
+/* Perform optimizations on a control flow graph.
The consts object should still be in list form to allow new constants
to be appended.
@@ -6348,25 +6467,127 @@ mark_reachable(struct assembler *a) {
static int
optimize_cfg(struct assembler *a, PyObject *consts)
{
- for (int i = 0; i < a->a_nblocks; i++) {
- if (optimize_basic_block(a->a_reverse_postorder[i], consts)) {
+ for (basicblock *b = a->a_entry; b != NULL; b = b->b_next) {
+ if (optimize_basic_block(b, consts)) {
return -1;
}
- clean_basic_block(a->a_reverse_postorder[i]);
- assert(a->a_reverse_postorder[i]->b_reachable == 0);
+ clean_basic_block(b);
+ assert(b->b_reachable == 0);
}
if (mark_reachable(a)) {
return -1;
}
/* Delete unreachable instructions */
- for (int i = 0; i < a->a_nblocks; i++) {
- if (a->a_reverse_postorder[i]->b_reachable == 0) {
- a->a_reverse_postorder[i]->b_iused = 0;
+ for (basicblock *b = a->a_entry; b != NULL; b = b->b_next) {
+ if (b->b_reachable == 0) {
+ b->b_iused = 0;
+ b->b_nofallthrough = 0;
}
}
+ /* Delete jump instructions made redundant by previous step. If a non-empty
+ block ends with a jump instruction, check if the next non-empty block
+ reached through normal flow control is the target of that jump. If it
+ is, then the jump instruction is redundant and can be deleted.
+ */
+ for (basicblock *b = a->a_entry; b != NULL; b = b->b_next) {
+ if (b->b_iused > 0) {
+ struct instr *b_last_instr = &b->b_instr[b->b_iused - 1];
+ if (b_last_instr->i_opcode == POP_JUMP_IF_FALSE ||
+ b_last_instr->i_opcode == POP_JUMP_IF_TRUE ||
+ b_last_instr->i_opcode == JUMP_ABSOLUTE ||
+ b_last_instr->i_opcode == JUMP_FORWARD) {
+ basicblock *b_next_act = b->b_next;
+ while (b_next_act != NULL && b_next_act->b_iused == 0) {
+ b_next_act = b_next_act->b_next;
+ }
+ if (b_last_instr->i_target == b_next_act) {
+ b->b_nofallthrough = 0;
+ switch(b_last_instr->i_opcode) {
+ case POP_JUMP_IF_FALSE:
+ case POP_JUMP_IF_TRUE:
+ b_last_instr->i_opcode = POP_TOP;
+ b_last_instr->i_target = NULL;
+ b_last_instr->i_oparg = 0;
+ break;
+ case JUMP_ABSOLUTE:
+ case JUMP_FORWARD:
+ b_last_instr->i_opcode = NOP;
+ clean_basic_block(b);
+ break;
+ }
+ /* The blocks after this one are now reachable through it */
+ b_next_act = b->b_next;
+ while (b_next_act != NULL && b_next_act->b_iused == 0) {
+ b_next_act->b_reachable = 1;
+ b_next_act = b_next_act->b_next;
+ }
+ }
+ }
+ }
+ }
+ minimize_lineno_table(a);
return 0;
}
+static inline int
+is_exit_without_lineno(basicblock *b) {
+ return b->b_exit && b->b_instr[0].i_lineno < 0;
+}
+
+/* PEP 626 mandates that the f_lineno of a frame is correct
+ * after a frame terminates. It would be prohibitively expensive
+ * to continuously update the f_lineno field at runtime,
+ * so we make sure that all exiting instruction (raises and returns)
+ * have a valid line number, allowing us to compute f_lineno lazily.
+ * We can do this by duplicating the exit blocks without line number
+ * so that none have more than one predecessor. We can then safely
+ * copy the line number from the sole predecessor block.
+ */
+static int
+ensure_exits_have_lineno(struct compiler *c)
+{
+ basicblock *entry = NULL;
+ /* Copy all exit blocks without line number that are targets of a jump.
+ */
+ for (basicblock *b = c->u->u_blocks; b != NULL; b = b->b_list) {
+ if (b->b_iused > 0 && is_jump(&b->b_instr[b->b_iused-1])) {
+ switch (b->b_instr[b->b_iused-1].i_opcode) {
+ /* Note: Only actual jumps, not exception handlers */
+ case SETUP_ASYNC_WITH:
+ case SETUP_WITH:
+ case SETUP_FINALLY:
+ continue;
+ }
+ basicblock *target = b->b_instr[b->b_iused-1].i_target;
+ if (is_exit_without_lineno(target)) {
+ basicblock *new_target = compiler_copy_block(c, target);
+ if (new_target == NULL) {
+ return -1;
+ }
+ new_target->b_instr[0].i_lineno = b->b_instr[b->b_iused-1].i_lineno;
+ b->b_instr[b->b_iused-1].i_target = new_target;
+ }
+ }
+ entry = b;
+ }
+ assert(entry != NULL);
+ if (is_exit_without_lineno(entry)) {
+ entry->b_instr[0].i_lineno = c->u->u_firstlineno;
+ }
+ /* Any remaining reachable exit blocks without line number can only be reached by
+ * fall through, and thus can only have a single predecessor */
+ for (basicblock *b = c->u->u_blocks; b != NULL; b = b->b_list) {
+ if (!b->b_nofallthrough && b->b_next && b->b_iused > 0) {
+ if (is_exit_without_lineno(b->b_next)) {
+ assert(b->b_next->b_iused > 0);
+ b->b_next->b_instr[0].i_lineno = b->b_instr[b->b_iused-1].i_lineno;
+ }
+ }
+ }
+ return 0;
+}
+
+
/* Retained for API compatibility.
* Optimization is now done in optimize_cfg */
diff --git a/Python/context.c b/Python/context.c
index 15d8b8ea4b..82826bf928 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -703,7 +703,7 @@ static PyMappingMethods PyContext_as_mapping = {
PyTypeObject PyContext_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "Context",
+ "_contextvars.Context",
sizeof(PyContext),
.tp_methods = PyContext_methods,
.tp_as_mapping = &PyContext_as_mapping,
@@ -1056,7 +1056,7 @@ static PyMethodDef PyContextVar_methods[] = {
PyTypeObject PyContextVar_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "ContextVar",
+ "_contextvars.ContextVar",
sizeof(PyContextVar),
.tp_methods = PyContextVar_methods,
.tp_members = PyContextVar_members,
@@ -1197,7 +1197,7 @@ static PyMethodDef PyContextTokenType_methods[] = {
PyTypeObject PyContextToken_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "Token",
+ "_contextvars.Token",
sizeof(PyContextToken),
.tp_methods = PyContextTokenType_methods,
.tp_getset = PyContextTokenType_getsetlist,
diff --git a/Python/errors.c b/Python/errors.c
index f80ae21fdd..9bac7ba70f 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -290,12 +290,14 @@ _PyErr_NormalizeException(PyThreadState *tstate, PyObject **exc,
PyObject **val, PyObject **tb)
{
int recursion_depth = 0;
+ tstate->recursion_headroom++;
PyObject *type, *value, *initial_tb;
restart:
type = *exc;
if (type == NULL) {
/* There was no exception, so nothing to do. */
+ tstate->recursion_headroom--;
return;
}
@@ -347,6 +349,7 @@ _PyErr_NormalizeException(PyThreadState *tstate, PyObject **exc,
}
*exc = type;
*val = value;
+ tstate->recursion_headroom--;
return;
error:
@@ -1531,9 +1534,6 @@ PyErr_WriteUnraisable(PyObject *obj)
}
-extern PyObject *PyModule_GetWarningsModule(void);
-
-
void
PyErr_SyntaxLocation(const char *filename, int lineno)
{
@@ -1697,13 +1697,18 @@ after_loop:
PyObject *
PyErr_ProgramText(const char *filename, int lineno)
{
- FILE *fp;
- if (filename == NULL || *filename == '\0' || lineno <= 0) {
+ if (filename == NULL) {
return NULL;
}
- PyThreadState *tstate = _PyThreadState_GET();
- fp = _Py_fopen(filename, "r" PY_STDIOTEXTMODE);
- return err_programtext(tstate, fp, lineno);
+
+ PyObject *filename_obj = PyUnicode_DecodeFSDefault(filename);
+ if (filename_obj == NULL) {
+ PyErr_Clear();
+ return NULL;
+ }
+ PyObject *res = PyErr_ProgramTextObject(filename_obj, lineno);
+ Py_DECREF(filename_obj);
+ return res;
}
PyObject *
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 5177b37288..8dc90fbe2b 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -55,9 +55,6 @@ get_surrogateescape(_Py_error_handler errors, int *surrogateescape)
PyObject *
_Py_device_encoding(int fd)
{
-#if defined(MS_WINDOWS)
- UINT cp;
-#endif
int valid;
_Py_BEGIN_SUPPRESS_IPH
valid = isatty(fd);
@@ -66,6 +63,7 @@ _Py_device_encoding(int fd)
Py_RETURN_NONE;
#if defined(MS_WINDOWS)
+ UINT cp;
if (fd == 0)
cp = GetConsoleCP();
else if (fd == 1 || fd == 2)
@@ -74,16 +72,14 @@ _Py_device_encoding(int fd)
cp = 0;
/* GetConsoleCP() and GetConsoleOutputCP() return 0 if the application
has no console */
- if (cp != 0)
- return PyUnicode_FromFormat("cp%u", (unsigned int)cp);
-#elif defined(CODESET)
- {
- char *codeset = nl_langinfo(CODESET);
- if (codeset != NULL && codeset[0] != 0)
- return PyUnicode_FromString(codeset);
+ if (cp == 0) {
+ Py_RETURN_NONE;
}
+
+ return PyUnicode_FromFormat("cp%u", (unsigned int)cp);
+#else
+ return _Py_GetLocaleEncodingObject();
#endif
- Py_RETURN_NONE;
}
#if !defined(_Py_FORCE_UTF8_FS_ENCODING) && !defined(MS_WINDOWS)
@@ -1459,33 +1455,6 @@ _Py_wfopen(const wchar_t *path, const wchar_t *mode)
return f;
}
-/* Wrapper to fopen().
-
- The file descriptor is created non-inheritable.
-
- If interrupted by a signal, fail with EINTR. */
-FILE*
-_Py_fopen(const char *pathname, const char *mode)
-{
- PyObject *pathname_obj = PyUnicode_DecodeFSDefault(pathname);
- if (pathname_obj == NULL) {
- return NULL;
- }
- if (PySys_Audit("open", "Osi", pathname_obj, mode, 0) < 0) {
- Py_DECREF(pathname_obj);
- return NULL;
- }
- Py_DECREF(pathname_obj);
-
- FILE *f = fopen(pathname, mode);
- if (f == NULL)
- return NULL;
- if (make_non_inheritable(fileno(f)) < 0) {
- fclose(f);
- return NULL;
- }
- return f;
-}
/* Open a file. Call _wfopen() on Windows, or encode the path to the filesystem
encoding and call fopen() otherwise.
@@ -2074,7 +2043,9 @@ _Py_get_blocking(int fd)
int
_Py_set_blocking(int fd, int blocking)
{
-#if defined(HAVE_SYS_IOCTL_H) && defined(FIONBIO)
+/* bpo-41462: On VxWorks, ioctl(FIONBIO) only works on sockets.
+ Use fcntl() instead. */
+#if defined(HAVE_SYS_IOCTL_H) && defined(FIONBIO) && !defined(__VXWORKS__)
int arg = !blocking;
if (ioctl(fd, FIONBIO, &arg) < 0)
goto error;
diff --git a/Python/getargs.c b/Python/getargs.c
index c85ff6d477..8839492e5e 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -202,7 +202,7 @@ static int
cleanup_ptr(PyObject *self, void *ptr)
{
if (ptr) {
- PyMem_FREE(ptr);
+ PyMem_Free(ptr);
}
return 0;
}
@@ -246,7 +246,7 @@ cleanreturn(int retval, freelist_t *freelist)
}
}
if (freelist->entries_malloced)
- PyMem_FREE(freelist->entries);
+ PyMem_Free(freelist->entries);
return retval;
}
diff --git a/Python/import.c b/Python/import.c
index 77e6baef01..1522abc705 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -4,6 +4,7 @@
#include "Python-ast.h"
#undef Yield /* undefine macro conflicting with <winbase.h> */
+#include "pycore_import.h" // _PyImport_BootstrapImp()
#include "pycore_initconfig.h"
#include "pycore_pyerrors.h"
#include "pycore_pyhash.h"
@@ -52,43 +53,6 @@ module _imp
/* Initialize things */
PyStatus
-_PyImportHooks_Init(PyThreadState *tstate)
-{
- PyObject *v, *path_hooks = NULL;
- int err = 0;
-
- /* adding sys.path_hooks and sys.path_importer_cache */
- v = PyList_New(0);
- if (v == NULL)
- goto error;
- err = PySys_SetObject("meta_path", v);
- Py_DECREF(v);
- if (err)
- goto error;
- v = PyDict_New();
- if (v == NULL)
- goto error;
- err = PySys_SetObject("path_importer_cache", v);
- Py_DECREF(v);
- if (err)
- goto error;
- path_hooks = PyList_New(0);
- if (path_hooks == NULL)
- goto error;
- err = PySys_SetObject("path_hooks", path_hooks);
- if (err) {
- goto error;
- }
- Py_DECREF(path_hooks);
- return _PyStatus_OK();
-
- error:
- _PyErr_Print(tstate);
- return _PyStatus_ERR("initializing sys.meta_path, sys.path_hooks, "
- "or path_importer_cache failed");
-}
-
-PyStatus
_PyImportZip_Init(PyThreadState *tstate)
{
PyObject *path_hooks, *zipimport;
@@ -1015,84 +979,80 @@ PyImport_GetImporter(PyObject *path)
return importer;
}
-/*[clinic input]
-_imp.create_builtin
-
- spec: object
- /
-
-Create an extension module.
-[clinic start generated code]*/
-
-static PyObject *
-_imp_create_builtin(PyObject *module, PyObject *spec)
-/*[clinic end generated code: output=ace7ff22271e6f39 input=37f966f890384e47]*/
+static PyObject*
+create_builtin(PyThreadState *tstate, PyObject *name, PyObject *spec)
{
- PyThreadState *tstate = _PyThreadState_GET();
- struct _inittab *p;
- PyObject *name;
- const char *namestr;
- PyObject *mod;
-
- name = PyObject_GetAttrString(spec, "name");
- if (name == NULL) {
- return NULL;
- }
-
- mod = _PyImport_FindExtensionObject(name, name);
+ PyObject *mod = _PyImport_FindExtensionObject(name, name);
if (mod || _PyErr_Occurred(tstate)) {
- Py_DECREF(name);
Py_XINCREF(mod);
return mod;
}
- namestr = PyUnicode_AsUTF8(name);
- if (namestr == NULL) {
- Py_DECREF(name);
- return NULL;
- }
-
PyObject *modules = tstate->interp->modules;
- for (p = PyImport_Inittab; p->name != NULL; p++) {
- PyModuleDef *def;
+ for (struct _inittab *p = PyImport_Inittab; p->name != NULL; p++) {
if (_PyUnicode_EqualToASCIIString(name, p->name)) {
if (p->initfunc == NULL) {
/* Cannot re-init internal module ("sys" or "builtins") */
- mod = PyImport_AddModule(namestr);
- Py_DECREF(name);
- return mod;
+ return PyImport_AddModuleObject(name);
}
+
mod = (*p->initfunc)();
if (mod == NULL) {
- Py_DECREF(name);
return NULL;
}
+
if (PyObject_TypeCheck(mod, &PyModuleDef_Type)) {
- Py_DECREF(name);
return PyModule_FromDefAndSpec((PyModuleDef*)mod, spec);
- } else {
+ }
+ else {
/* Remember pointer to module init function. */
- def = PyModule_GetDef(mod);
+ PyModuleDef *def = PyModule_GetDef(mod);
if (def == NULL) {
- Py_DECREF(name);
return NULL;
}
+
def->m_base.m_init = p->initfunc;
if (_PyImport_FixupExtensionObject(mod, name, name,
modules) < 0) {
- Py_DECREF(name);
return NULL;
}
- Py_DECREF(name);
return mod;
}
}
}
- Py_DECREF(name);
+
+ // not found
Py_RETURN_NONE;
}
+
+/*[clinic input]
+_imp.create_builtin
+
+ spec: object
+ /
+
+Create an extension module.
+[clinic start generated code]*/
+
+static PyObject *
+_imp_create_builtin(PyObject *module, PyObject *spec)
+/*[clinic end generated code: output=ace7ff22271e6f39 input=37f966f890384e47]*/
+{
+ PyThreadState *tstate = _PyThreadState_GET();
+
+ PyObject *name = PyObject_GetAttrString(spec, "name");
+ if (name == NULL) {
+ return NULL;
+ }
+
+ PyObject *mod = create_builtin(tstate, name, spec);
+ Py_DECREF(name);
+ return mod;
+}
+
+
/* Frozen modules */
static const struct _frozen *
@@ -2164,46 +2124,88 @@ static PyMethodDef imp_methods[] = {
};
-static struct PyModuleDef impmodule = {
+static int
+imp_module_exec(PyObject *module)
+{
+ const wchar_t *mode = _Py_GetConfig()->check_hash_pycs_mode;
+ PyObject *pyc_mode = PyUnicode_FromWideChar(mode, -1);
+ if (pyc_mode == NULL) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(module, "check_hash_based_pycs", pyc_mode) < 0) {
+ Py_DECREF(pyc_mode);
+ return -1;
+ }
+ Py_DECREF(pyc_mode);
+
+ return 0;
+}
+
+
+static PyModuleDef_Slot imp_slots[] = {
+ {Py_mod_exec, imp_module_exec},
+ {0, NULL}
+};
+
+static struct PyModuleDef imp_module = {
PyModuleDef_HEAD_INIT,
- "_imp",
- doc_imp,
- 0,
- imp_methods,
- NULL,
- NULL,
- NULL,
- NULL
+ .m_name = "_imp",
+ .m_doc = doc_imp,
+ .m_size = 0,
+ .m_methods = imp_methods,
+ .m_slots = imp_slots,
};
PyMODINIT_FUNC
PyInit__imp(void)
{
- PyObject *m, *d;
+ return PyModuleDef_Init(&imp_module);
+}
- m = PyModule_Create(&impmodule);
- if (m == NULL) {
- goto failure;
+
+// Import the _imp extension by calling manually _imp.create_builtin() and
+// _imp.exec_builtin() since importlib is not initialized yet. Initializing
+// importlib requires the _imp module: this function fix the bootstrap issue.
+PyObject*
+_PyImport_BootstrapImp(PyThreadState *tstate)
+{
+ PyObject *name = PyUnicode_FromString("_imp");
+ if (name == NULL) {
+ return NULL;
}
- d = PyModule_GetDict(m);
- if (d == NULL) {
- goto failure;
+
+ // Mock a ModuleSpec object just good enough for PyModule_FromDefAndSpec():
+ // an object with just a name attribute.
+ //
+ // _imp.__spec__ is overriden by importlib._bootstrap._instal() anyway.
+ PyObject *attrs = Py_BuildValue("{sO}", "name", name);
+ if (attrs == NULL) {
+ goto error;
+ }
+ PyObject *spec = _PyNamespace_New(attrs);
+ Py_DECREF(attrs);
+ if (spec == NULL) {
+ goto error;
}
- const wchar_t *mode = _Py_GetConfig()->check_hash_pycs_mode;
- PyObject *pyc_mode = PyUnicode_FromWideChar(mode, -1);
- if (pyc_mode == NULL) {
- goto failure;
+ // Create the _imp module from its definition.
+ PyObject *mod = create_builtin(tstate, name, spec);
+ Py_CLEAR(name);
+ Py_DECREF(spec);
+ if (mod == NULL) {
+ goto error;
}
- if (PyDict_SetItemString(d, "check_hash_based_pycs", pyc_mode) < 0) {
- Py_DECREF(pyc_mode);
- goto failure;
+ assert(mod != Py_None); // not found
+
+ // Execute the _imp module: call imp_module_exec().
+ if (exec_builtin_or_dynamic(mod) < 0) {
+ Py_DECREF(mod);
+ goto error;
}
- Py_DECREF(pyc_mode);
+ return mod;
- return m;
- failure:
- Py_XDECREF(m);
+error:
+ Py_XDECREF(name);
return NULL;
}
diff --git a/Python/importdl.c b/Python/importdl.c
index fbeb9fb754..1847eba74a 100644
--- a/Python/importdl.c
+++ b/Python/importdl.c
@@ -220,10 +220,9 @@ _PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *fp)
def->m_base.m_init = p0;
/* Remember the filename as the __file__ attribute */
- if (PyModule_AddObject(m, "__file__", path) < 0)
+ if (PyModule_AddObjectRef(m, "__file__", path) < 0) {
PyErr_Clear(); /* Not important enough to report */
- else
- Py_INCREF(path);
+ }
PyObject *modules = PyImport_GetModuleDict();
if (_PyImport_FixupExtensionObject(m, name_unicode, path, modules) < 0)
diff --git a/Python/importlib.h b/Python/importlib.h
index 00d1f3570b..2f100515b5 100644
--- a/Python/importlib.h
+++ b/Python/importlib.h
@@ -1,485 +1,502 @@
/* Auto-generated by Programs/_freeze_importlib.c */
const unsigned char _Py_M__importlib_bootstrap[] = {
99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,4,0,0,0,64,0,0,0,115,194,1,0,0,100,0,
- 90,0,100,1,97,1,100,2,100,3,132,0,90,2,100,4,
- 100,5,132,0,90,3,105,0,90,4,105,0,90,5,71,0,
- 100,6,100,7,132,0,100,7,101,6,131,3,90,7,71,0,
- 100,8,100,9,132,0,100,9,131,2,90,8,71,0,100,10,
- 100,11,132,0,100,11,131,2,90,9,71,0,100,12,100,13,
- 132,0,100,13,131,2,90,10,100,14,100,15,132,0,90,11,
- 100,16,100,17,132,0,90,12,100,18,100,19,132,0,90,13,
- 100,20,100,21,156,1,100,22,100,23,132,2,90,14,100,24,
- 100,25,132,0,90,15,100,26,100,27,132,0,90,16,100,28,
- 100,29,132,0,90,17,100,30,100,31,132,0,90,18,71,0,
- 100,32,100,33,132,0,100,33,131,2,90,19,100,1,100,1,
- 100,34,156,2,100,35,100,36,132,2,90,20,100,94,100,37,
- 100,38,132,1,90,21,100,39,100,40,156,1,100,41,100,42,
- 132,2,90,22,100,43,100,44,132,0,90,23,100,45,100,46,
- 132,0,90,24,100,47,100,48,132,0,90,25,100,49,100,50,
- 132,0,90,26,100,51,100,52,132,0,90,27,100,53,100,54,
- 132,0,90,28,71,0,100,55,100,56,132,0,100,56,131,2,
- 90,29,71,0,100,57,100,58,132,0,100,58,131,2,90,30,
- 71,0,100,59,100,60,132,0,100,60,131,2,90,31,100,61,
- 100,62,132,0,90,32,100,63,100,64,132,0,90,33,100,95,
- 100,65,100,66,132,1,90,34,100,67,100,68,132,0,90,35,
- 100,69,90,36,101,36,100,70,23,0,90,37,100,71,100,72,
- 132,0,90,38,101,39,131,0,90,40,100,73,100,74,132,0,
- 90,41,100,96,100,76,100,77,132,1,90,42,100,39,100,78,
- 156,1,100,79,100,80,132,2,90,43,100,81,100,82,132,0,
- 90,44,100,97,100,84,100,85,132,1,90,45,100,86,100,87,
- 132,0,90,46,100,88,100,89,132,0,90,47,100,90,100,91,
- 132,0,90,48,100,92,100,93,132,0,90,49,100,1,83,0,
- 41,98,97,83,1,0,0,67,111,114,101,32,105,109,112,108,
- 101,109,101,110,116,97,116,105,111,110,32,111,102,32,105,109,
- 112,111,114,116,46,10,10,84,104,105,115,32,109,111,100,117,
- 108,101,32,105,115,32,78,79,84,32,109,101,97,110,116,32,
- 116,111,32,98,101,32,100,105,114,101,99,116,108,121,32,105,
- 109,112,111,114,116,101,100,33,32,73,116,32,104,97,115,32,
- 98,101,101,110,32,100,101,115,105,103,110,101,100,32,115,117,
- 99,104,10,116,104,97,116,32,105,116,32,99,97,110,32,98,
- 101,32,98,111,111,116,115,116,114,97,112,112,101,100,32,105,
- 110,116,111,32,80,121,116,104,111,110,32,97,115,32,116,104,
- 101,32,105,109,112,108,101,109,101,110,116,97,116,105,111,110,
- 32,111,102,32,105,109,112,111,114,116,46,32,65,115,10,115,
- 117,99,104,32,105,116,32,114,101,113,117,105,114,101,115,32,
- 116,104,101,32,105,110,106,101,99,116,105,111,110,32,111,102,
- 32,115,112,101,99,105,102,105,99,32,109,111,100,117,108,101,
- 115,32,97,110,100,32,97,116,116,114,105,98,117,116,101,115,
- 32,105,110,32,111,114,100,101,114,32,116,111,10,119,111,114,
- 107,46,32,79,110,101,32,115,104,111,117,108,100,32,117,115,
- 101,32,105,109,112,111,114,116,108,105,98,32,97,115,32,116,
- 104,101,32,112,117,98,108,105,99,45,102,97,99,105,110,103,
- 32,118,101,114,115,105,111,110,32,111,102,32,116,104,105,115,
- 32,109,111,100,117,108,101,46,10,10,78,99,2,0,0,0,
- 0,0,0,0,0,0,0,0,3,0,0,0,7,0,0,0,
- 67,0,0,0,115,56,0,0,0,100,1,68,0,93,32,125,
- 2,116,0,124,1,124,2,131,2,114,4,116,1,124,0,124,
- 2,116,2,124,1,124,2,131,2,131,3,1,0,113,4,124,
- 0,106,3,160,4,124,1,106,3,161,1,1,0,100,2,83,
- 0,41,3,122,47,83,105,109,112,108,101,32,115,117,98,115,
- 116,105,116,117,116,101,32,102,111,114,32,102,117,110,99,116,
- 111,111,108,115,46,117,112,100,97,116,101,95,119,114,97,112,
- 112,101,114,46,41,4,218,10,95,95,109,111,100,117,108,101,
- 95,95,218,8,95,95,110,97,109,101,95,95,218,12,95,95,
- 113,117,97,108,110,97,109,101,95,95,218,7,95,95,100,111,
- 99,95,95,78,41,5,218,7,104,97,115,97,116,116,114,218,
- 7,115,101,116,97,116,116,114,218,7,103,101,116,97,116,116,
- 114,218,8,95,95,100,105,99,116,95,95,218,6,117,112,100,
- 97,116,101,41,3,90,3,110,101,119,90,3,111,108,100,218,
- 7,114,101,112,108,97,99,101,169,0,114,10,0,0,0,250,
- 29,60,102,114,111,122,101,110,32,105,109,112,111,114,116,108,
- 105,98,46,95,98,111,111,116,115,116,114,97,112,62,218,5,
- 95,119,114,97,112,27,0,0,0,115,8,0,0,0,0,2,
- 8,1,10,1,20,1,114,12,0,0,0,99,1,0,0,0,
- 0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,
- 67,0,0,0,115,12,0,0,0,116,0,116,1,131,1,124,
- 0,131,1,83,0,169,1,78,41,2,218,4,116,121,112,101,
- 218,3,115,121,115,169,1,218,4,110,97,109,101,114,10,0,
- 0,0,114,10,0,0,0,114,11,0,0,0,218,11,95,110,
- 101,119,95,109,111,100,117,108,101,35,0,0,0,115,2,0,
- 0,0,0,1,114,18,0,0,0,99,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,1,0,0,0,64,0,
- 0,0,115,12,0,0,0,101,0,90,1,100,0,90,2,100,
- 1,83,0,41,2,218,14,95,68,101,97,100,108,111,99,107,
- 69,114,114,111,114,78,41,3,114,1,0,0,0,114,0,0,
- 0,0,114,2,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,10,0,0,0,114,11,0,0,0,114,19,0,0,0,
- 48,0,0,0,115,2,0,0,0,8,1,114,19,0,0,0,
- 99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,2,0,0,0,64,0,0,0,115,56,0,0,0,101,0,
- 90,1,100,0,90,2,100,1,90,3,100,2,100,3,132,0,
- 90,4,100,4,100,5,132,0,90,5,100,6,100,7,132,0,
- 90,6,100,8,100,9,132,0,90,7,100,10,100,11,132,0,
- 90,8,100,12,83,0,41,13,218,11,95,77,111,100,117,108,
- 101,76,111,99,107,122,169,65,32,114,101,99,117,114,115,105,
- 118,101,32,108,111,99,107,32,105,109,112,108,101,109,101,110,
- 116,97,116,105,111,110,32,119,104,105,99,104,32,105,115,32,
- 97,98,108,101,32,116,111,32,100,101,116,101,99,116,32,100,
- 101,97,100,108,111,99,107,115,10,32,32,32,32,40,101,46,
- 103,46,32,116,104,114,101,97,100,32,49,32,116,114,121,105,
- 110,103,32,116,111,32,116,97,107,101,32,108,111,99,107,115,
- 32,65,32,116,104,101,110,32,66,44,32,97,110,100,32,116,
- 104,114,101,97,100,32,50,32,116,114,121,105,110,103,32,116,
- 111,10,32,32,32,32,116,97,107,101,32,108,111,99,107,115,
- 32,66,32,116,104,101,110,32,65,41,46,10,32,32,32,32,
- 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
- 0,2,0,0,0,67,0,0,0,115,48,0,0,0,116,0,
- 160,1,161,0,124,0,95,2,116,0,160,1,161,0,124,0,
- 95,3,124,1,124,0,95,4,100,0,124,0,95,5,100,1,
- 124,0,95,6,100,1,124,0,95,7,100,0,83,0,169,2,
- 78,233,0,0,0,0,41,8,218,7,95,116,104,114,101,97,
- 100,90,13,97,108,108,111,99,97,116,101,95,108,111,99,107,
- 218,4,108,111,99,107,218,6,119,97,107,101,117,112,114,17,
- 0,0,0,218,5,111,119,110,101,114,218,5,99,111,117,110,
- 116,218,7,119,97,105,116,101,114,115,169,2,218,4,115,101,
- 108,102,114,17,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,218,8,95,95,105,110,105,116,95,95,
- 58,0,0,0,115,12,0,0,0,0,1,10,1,10,1,6,
- 1,6,1,6,1,122,20,95,77,111,100,117,108,101,76,111,
- 99,107,46,95,95,105,110,105,116,95,95,99,1,0,0,0,
- 0,0,0,0,0,0,0,0,5,0,0,0,3,0,0,0,
- 67,0,0,0,115,88,0,0,0,116,0,160,1,161,0,125,
- 1,124,0,106,2,125,2,116,3,131,0,125,3,116,4,160,
- 5,124,2,161,1,125,4,124,4,100,0,117,0,114,42,100,
- 1,83,0,124,4,106,2,125,2,124,2,124,1,107,2,114,
- 60,100,2,83,0,124,2,124,3,118,0,114,72,100,1,83,
- 0,124,3,160,6,124,2,161,1,1,0,113,20,100,0,83,
- 0,41,3,78,70,84,41,7,114,23,0,0,0,218,9,103,
- 101,116,95,105,100,101,110,116,114,26,0,0,0,218,3,115,
- 101,116,218,12,95,98,108,111,99,107,105,110,103,95,111,110,
- 218,3,103,101,116,218,3,97,100,100,41,5,114,30,0,0,
- 0,90,2,109,101,218,3,116,105,100,90,4,115,101,101,110,
- 114,24,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
- 11,0,0,0,218,12,104,97,115,95,100,101,97,100,108,111,
- 99,107,66,0,0,0,115,24,0,0,0,0,2,8,1,6,
- 1,6,2,10,1,8,1,4,1,6,1,8,1,4,1,8,
- 6,4,1,122,24,95,77,111,100,117,108,101,76,111,99,107,
- 46,104,97,115,95,100,101,97,100,108,111,99,107,99,1,0,
- 0,0,0,0,0,0,0,0,0,0,2,0,0,0,8,0,
- 0,0,67,0,0,0,115,210,0,0,0,116,0,160,1,161,
- 0,125,1,124,0,116,2,124,1,60,0,122,180,124,0,106,
- 3,143,126,1,0,124,0,106,4,100,1,107,2,115,46,124,
- 0,106,5,124,1,107,2,114,90,124,1,124,0,95,5,124,
- 0,4,0,106,4,100,2,55,0,2,0,95,4,87,0,100,
- 3,4,0,4,0,131,3,1,0,87,0,116,2,124,1,61,
- 0,100,4,83,0,124,0,160,6,161,0,114,110,116,7,100,
- 5,124,0,22,0,131,1,130,1,124,0,106,8,160,9,100,
- 6,161,1,114,136,124,0,4,0,106,10,100,2,55,0,2,
- 0,95,10,87,0,100,3,4,0,4,0,131,3,1,0,110,
- 16,49,0,115,156,48,0,1,0,1,0,1,0,89,0,1,
- 0,124,0,106,8,160,9,161,0,1,0,124,0,106,8,160,
- 11,161,0,1,0,113,18,87,0,116,2,124,1,61,0,110,
- 8,116,2,124,1,61,0,48,0,100,3,83,0,41,7,122,
- 185,10,32,32,32,32,32,32,32,32,65,99,113,117,105,114,
- 101,32,116,104,101,32,109,111,100,117,108,101,32,108,111,99,
- 107,46,32,32,73,102,32,97,32,112,111,116,101,110,116,105,
- 97,108,32,100,101,97,100,108,111,99,107,32,105,115,32,100,
- 101,116,101,99,116,101,100,44,10,32,32,32,32,32,32,32,
- 32,97,32,95,68,101,97,100,108,111,99,107,69,114,114,111,
- 114,32,105,115,32,114,97,105,115,101,100,46,10,32,32,32,
- 32,32,32,32,32,79,116,104,101,114,119,105,115,101,44,32,
- 116,104,101,32,108,111,99,107,32,105,115,32,97,108,119,97,
- 121,115,32,97,99,113,117,105,114,101,100,32,97,110,100,32,
- 84,114,117,101,32,105,115,32,114,101,116,117,114,110,101,100,
- 46,10,32,32,32,32,32,32,32,32,114,22,0,0,0,233,
- 1,0,0,0,78,84,122,23,100,101,97,100,108,111,99,107,
- 32,100,101,116,101,99,116,101,100,32,98,121,32,37,114,70,
- 41,12,114,23,0,0,0,114,32,0,0,0,114,34,0,0,
- 0,114,24,0,0,0,114,27,0,0,0,114,26,0,0,0,
- 114,38,0,0,0,114,19,0,0,0,114,25,0,0,0,218,
- 7,97,99,113,117,105,114,101,114,28,0,0,0,218,7,114,
- 101,108,101,97,115,101,169,2,114,30,0,0,0,114,37,0,
- 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
- 0,114,40,0,0,0,87,0,0,0,115,34,0,0,0,0,
- 6,8,1,8,1,2,2,8,1,20,1,6,1,14,1,14,
- 9,6,247,4,1,8,1,12,1,12,1,44,2,10,1,14,
- 2,122,19,95,77,111,100,117,108,101,76,111,99,107,46,97,
- 99,113,117,105,114,101,99,1,0,0,0,0,0,0,0,0,
- 0,0,0,2,0,0,0,8,0,0,0,67,0,0,0,115,
- 142,0,0,0,116,0,160,1,161,0,125,1,124,0,106,2,
- 143,108,1,0,124,0,106,3,124,1,107,3,114,34,116,4,
- 100,1,131,1,130,1,124,0,106,5,100,2,107,4,115,48,
- 74,0,130,1,124,0,4,0,106,5,100,3,56,0,2,0,
- 95,5,124,0,106,5,100,2,107,2,114,108,100,0,124,0,
- 95,3,124,0,106,6,114,108,124,0,4,0,106,6,100,3,
- 56,0,2,0,95,6,124,0,106,7,160,8,161,0,1,0,
- 87,0,100,0,4,0,4,0,131,3,1,0,110,16,49,0,
- 115,128,48,0,1,0,1,0,1,0,89,0,1,0,100,0,
- 83,0,41,4,78,250,31,99,97,110,110,111,116,32,114,101,
- 108,101,97,115,101,32,117,110,45,97,99,113,117,105,114,101,
- 100,32,108,111,99,107,114,22,0,0,0,114,39,0,0,0,
- 41,9,114,23,0,0,0,114,32,0,0,0,114,24,0,0,
- 0,114,26,0,0,0,218,12,82,117,110,116,105,109,101,69,
- 114,114,111,114,114,27,0,0,0,114,28,0,0,0,114,25,
- 0,0,0,114,41,0,0,0,114,42,0,0,0,114,10,0,
- 0,0,114,10,0,0,0,114,11,0,0,0,114,41,0,0,
- 0,112,0,0,0,115,22,0,0,0,0,1,8,1,8,1,
- 10,1,8,1,14,1,14,1,10,1,6,1,6,1,14,1,
- 122,19,95,77,111,100,117,108,101,76,111,99,107,46,114,101,
- 108,101,97,115,101,99,1,0,0,0,0,0,0,0,0,0,
- 0,0,1,0,0,0,5,0,0,0,67,0,0,0,115,18,
- 0,0,0,100,1,160,0,124,0,106,1,116,2,124,0,131,
- 1,161,2,83,0,41,2,78,122,23,95,77,111,100,117,108,
- 101,76,111,99,107,40,123,33,114,125,41,32,97,116,32,123,
- 125,169,3,218,6,102,111,114,109,97,116,114,17,0,0,0,
- 218,2,105,100,169,1,114,30,0,0,0,114,10,0,0,0,
- 114,10,0,0,0,114,11,0,0,0,218,8,95,95,114,101,
- 112,114,95,95,125,0,0,0,115,2,0,0,0,0,1,122,
- 20,95,77,111,100,117,108,101,76,111,99,107,46,95,95,114,
- 101,112,114,95,95,78,41,9,114,1,0,0,0,114,0,0,
- 0,0,114,2,0,0,0,114,3,0,0,0,114,31,0,0,
- 0,114,38,0,0,0,114,40,0,0,0,114,41,0,0,0,
- 114,49,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,114,20,0,0,0,52,0,
- 0,0,115,12,0,0,0,8,1,4,5,8,8,8,21,8,
- 25,8,13,114,20,0,0,0,99,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,2,0,0,0,64,0,0,
- 0,115,48,0,0,0,101,0,90,1,100,0,90,2,100,1,
- 90,3,100,2,100,3,132,0,90,4,100,4,100,5,132,0,
- 90,5,100,6,100,7,132,0,90,6,100,8,100,9,132,0,
- 90,7,100,10,83,0,41,11,218,16,95,68,117,109,109,121,
- 77,111,100,117,108,101,76,111,99,107,122,86,65,32,115,105,
- 109,112,108,101,32,95,77,111,100,117,108,101,76,111,99,107,
- 32,101,113,117,105,118,97,108,101,110,116,32,102,111,114,32,
- 80,121,116,104,111,110,32,98,117,105,108,100,115,32,119,105,
- 116,104,111,117,116,10,32,32,32,32,109,117,108,116,105,45,
- 116,104,114,101,97,100,105,110,103,32,115,117,112,112,111,114,
- 116,46,99,2,0,0,0,0,0,0,0,0,0,0,0,2,
+ 0,4,0,0,0,64,0,0,0,115,214,1,0,0,100,0,
+ 90,0,100,1,100,2,132,0,90,1,100,3,90,2,100,3,
+ 90,3,100,3,90,4,100,3,97,5,100,4,100,5,132,0,
+ 90,6,100,6,100,7,132,0,90,7,105,0,90,8,105,0,
+ 90,9,71,0,100,8,100,9,132,0,100,9,101,10,131,3,
+ 90,11,71,0,100,10,100,11,132,0,100,11,131,2,90,12,
+ 71,0,100,12,100,13,132,0,100,13,131,2,90,13,71,0,
+ 100,14,100,15,132,0,100,15,131,2,90,14,100,16,100,17,
+ 132,0,90,15,100,18,100,19,132,0,90,16,100,20,100,21,
+ 132,0,90,17,100,22,100,23,156,1,100,24,100,25,132,2,
+ 90,18,100,26,100,27,132,0,90,19,100,28,100,29,132,0,
+ 90,20,100,30,100,31,132,0,90,21,100,32,100,33,132,0,
+ 90,22,71,0,100,34,100,35,132,0,100,35,131,2,90,23,
+ 100,3,100,3,100,36,156,2,100,37,100,38,132,2,90,24,
+ 100,96,100,39,100,40,132,1,90,25,100,41,100,42,156,1,
+ 100,43,100,44,132,2,90,26,100,45,100,46,132,0,90,27,
+ 100,47,100,48,132,0,90,28,100,49,100,50,132,0,90,29,
+ 100,51,100,52,132,0,90,30,100,53,100,54,132,0,90,31,
+ 100,55,100,56,132,0,90,32,71,0,100,57,100,58,132,0,
+ 100,58,131,2,90,33,71,0,100,59,100,60,132,0,100,60,
+ 131,2,90,34,71,0,100,61,100,62,132,0,100,62,131,2,
+ 90,35,100,63,100,64,132,0,90,36,100,65,100,66,132,0,
+ 90,37,100,97,100,67,100,68,132,1,90,38,100,69,100,70,
+ 132,0,90,39,100,71,90,40,101,40,100,72,23,0,90,41,
+ 100,73,100,74,132,0,90,42,101,43,131,0,90,44,100,75,
+ 100,76,132,0,90,45,100,98,100,78,100,79,132,1,90,46,
+ 100,41,100,80,156,1,100,81,100,82,132,2,90,47,100,83,
+ 100,84,132,0,90,48,100,99,100,86,100,87,132,1,90,49,
+ 100,88,100,89,132,0,90,50,100,90,100,91,132,0,90,51,
+ 100,92,100,93,132,0,90,52,100,94,100,95,132,0,90,53,
+ 100,3,83,0,41,100,97,83,1,0,0,67,111,114,101,32,
+ 105,109,112,108,101,109,101,110,116,97,116,105,111,110,32,111,
+ 102,32,105,109,112,111,114,116,46,10,10,84,104,105,115,32,
+ 109,111,100,117,108,101,32,105,115,32,78,79,84,32,109,101,
+ 97,110,116,32,116,111,32,98,101,32,100,105,114,101,99,116,
+ 108,121,32,105,109,112,111,114,116,101,100,33,32,73,116,32,
+ 104,97,115,32,98,101,101,110,32,100,101,115,105,103,110,101,
+ 100,32,115,117,99,104,10,116,104,97,116,32,105,116,32,99,
+ 97,110,32,98,101,32,98,111,111,116,115,116,114,97,112,112,
+ 101,100,32,105,110,116,111,32,80,121,116,104,111,110,32,97,
+ 115,32,116,104,101,32,105,109,112,108,101,109,101,110,116,97,
+ 116,105,111,110,32,111,102,32,105,109,112,111,114,116,46,32,
+ 65,115,10,115,117,99,104,32,105,116,32,114,101,113,117,105,
+ 114,101,115,32,116,104,101,32,105,110,106,101,99,116,105,111,
+ 110,32,111,102,32,115,112,101,99,105,102,105,99,32,109,111,
+ 100,117,108,101,115,32,97,110,100,32,97,116,116,114,105,98,
+ 117,116,101,115,32,105,110,32,111,114,100,101,114,32,116,111,
+ 10,119,111,114,107,46,32,79,110,101,32,115,104,111,117,108,
+ 100,32,117,115,101,32,105,109,112,111,114,116,108,105,98,32,
+ 97,115,32,116,104,101,32,112,117,98,108,105,99,45,102,97,
+ 99,105,110,103,32,118,101,114,115,105,111,110,32,111,102,32,
+ 116,104,105,115,32,109,111,100,117,108,101,46,10,10,99,1,
+ 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,8,
+ 0,0,0,67,0,0,0,115,38,0,0,0,122,8,124,0,
+ 106,0,87,0,83,0,4,0,116,1,121,36,1,0,1,0,
+ 1,0,116,2,124,0,131,1,106,0,6,0,89,0,83,0,
+ 119,0,169,1,78,41,3,218,12,95,95,113,117,97,108,110,
+ 97,109,101,95,95,218,14,65,116,116,114,105,98,117,116,101,
+ 69,114,114,111,114,218,4,116,121,112,101,41,1,218,3,111,
+ 98,106,169,0,114,5,0,0,0,250,29,60,102,114,111,122,
+ 101,110,32,105,109,112,111,114,116,108,105,98,46,95,98,111,
+ 111,116,115,116,114,97,112,62,218,12,95,111,98,106,101,99,
+ 116,95,110,97,109,101,23,0,0,0,115,12,0,0,0,2,
+ 1,8,1,12,1,14,1,2,255,255,128,114,7,0,0,0,
+ 78,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0,
+ 0,0,7,0,0,0,67,0,0,0,115,56,0,0,0,100,
+ 1,68,0,93,32,125,2,116,0,124,1,124,2,131,2,114,
+ 36,116,1,124,0,124,2,116,2,124,1,124,2,131,2,131,
+ 3,1,0,113,4,124,0,106,3,160,4,124,1,106,3,161,
+ 1,1,0,100,2,83,0,41,3,122,47,83,105,109,112,108,
+ 101,32,115,117,98,115,116,105,116,117,116,101,32,102,111,114,
+ 32,102,117,110,99,116,111,111,108,115,46,117,112,100,97,116,
+ 101,95,119,114,97,112,112,101,114,46,41,4,218,10,95,95,
+ 109,111,100,117,108,101,95,95,218,8,95,95,110,97,109,101,
+ 95,95,114,1,0,0,0,218,7,95,95,100,111,99,95,95,
+ 78,41,5,218,7,104,97,115,97,116,116,114,218,7,115,101,
+ 116,97,116,116,114,218,7,103,101,116,97,116,116,114,218,8,
+ 95,95,100,105,99,116,95,95,218,6,117,112,100,97,116,101,
+ 41,3,90,3,110,101,119,90,3,111,108,100,218,7,114,101,
+ 112,108,97,99,101,114,5,0,0,0,114,5,0,0,0,114,
+ 6,0,0,0,218,5,95,119,114,97,112,40,0,0,0,115,
+ 12,0,0,0,8,2,10,1,18,1,2,128,18,1,255,128,
+ 114,17,0,0,0,99,1,0,0,0,0,0,0,0,0,0,
+ 0,0,1,0,0,0,2,0,0,0,67,0,0,0,115,12,
+ 0,0,0,116,0,116,1,131,1,124,0,131,1,83,0,114,
+ 0,0,0,0,41,2,114,3,0,0,0,218,3,115,121,115,
+ 169,1,218,4,110,97,109,101,114,5,0,0,0,114,5,0,
+ 0,0,114,6,0,0,0,218,11,95,110,101,119,95,109,111,
+ 100,117,108,101,48,0,0,0,115,4,0,0,0,12,1,255,
+ 128,114,21,0,0,0,99,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,1,0,0,0,64,0,0,0,115,
+ 12,0,0,0,101,0,90,1,100,0,90,2,100,1,83,0,
+ 41,2,218,14,95,68,101,97,100,108,111,99,107,69,114,114,
+ 111,114,78,41,3,114,9,0,0,0,114,8,0,0,0,114,
+ 1,0,0,0,114,5,0,0,0,114,5,0,0,0,114,5,
+ 0,0,0,114,6,0,0,0,114,22,0,0,0,61,0,0,
+ 0,115,6,0,0,0,8,0,4,1,255,128,114,22,0,0,
+ 0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,2,0,0,0,64,0,0,0,115,56,0,0,0,101,
+ 0,90,1,100,0,90,2,100,1,90,3,100,2,100,3,132,
+ 0,90,4,100,4,100,5,132,0,90,5,100,6,100,7,132,
+ 0,90,6,100,8,100,9,132,0,90,7,100,10,100,11,132,
+ 0,90,8,100,12,83,0,41,13,218,11,95,77,111,100,117,
+ 108,101,76,111,99,107,122,169,65,32,114,101,99,117,114,115,
+ 105,118,101,32,108,111,99,107,32,105,109,112,108,101,109,101,
+ 110,116,97,116,105,111,110,32,119,104,105,99,104,32,105,115,
+ 32,97,98,108,101,32,116,111,32,100,101,116,101,99,116,32,
+ 100,101,97,100,108,111,99,107,115,10,32,32,32,32,40,101,
+ 46,103,46,32,116,104,114,101,97,100,32,49,32,116,114,121,
+ 105,110,103,32,116,111,32,116,97,107,101,32,108,111,99,107,
+ 115,32,65,32,116,104,101,110,32,66,44,32,97,110,100,32,
+ 116,104,114,101,97,100,32,50,32,116,114,121,105,110,103,32,
+ 116,111,10,32,32,32,32,116,97,107,101,32,108,111,99,107,
+ 115,32,66,32,116,104,101,110,32,65,41,46,10,32,32,32,
+ 32,99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,
+ 0,0,2,0,0,0,67,0,0,0,115,48,0,0,0,116,
+ 0,160,1,161,0,124,0,95,2,116,0,160,1,161,0,124,
+ 0,95,3,124,1,124,0,95,4,100,0,124,0,95,5,100,
+ 1,124,0,95,6,100,1,124,0,95,7,100,0,83,0,169,
+ 2,78,233,0,0,0,0,41,8,218,7,95,116,104,114,101,
+ 97,100,90,13,97,108,108,111,99,97,116,101,95,108,111,99,
+ 107,218,4,108,111,99,107,218,6,119,97,107,101,117,112,114,
+ 20,0,0,0,218,5,111,119,110,101,114,218,5,99,111,117,
+ 110,116,218,7,119,97,105,116,101,114,115,169,2,218,4,115,
+ 101,108,102,114,20,0,0,0,114,5,0,0,0,114,5,0,
+ 0,0,114,6,0,0,0,218,8,95,95,105,110,105,116,95,
+ 95,71,0,0,0,115,14,0,0,0,10,1,10,1,6,1,
+ 6,1,6,1,10,1,255,128,122,20,95,77,111,100,117,108,
+ 101,76,111,99,107,46,95,95,105,110,105,116,95,95,99,1,
+ 0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,3,
+ 0,0,0,67,0,0,0,115,86,0,0,0,116,0,160,1,
+ 161,0,125,1,124,0,106,2,125,2,116,3,131,0,125,3,
+ 9,0,116,4,160,5,124,2,161,1,125,4,124,4,100,0,
+ 117,0,114,44,100,2,83,0,124,4,106,2,125,2,124,2,
+ 124,1,107,2,114,62,100,1,83,0,124,2,124,3,118,0,
+ 114,74,100,2,83,0,124,3,160,6,124,2,161,1,1,0,
+ 113,22,41,3,78,84,70,41,7,114,26,0,0,0,218,9,
+ 103,101,116,95,105,100,101,110,116,114,29,0,0,0,218,3,
+ 115,101,116,218,12,95,98,108,111,99,107,105,110,103,95,111,
+ 110,218,3,103,101,116,218,3,97,100,100,41,5,114,33,0,
+ 0,0,90,2,109,101,218,3,116,105,100,90,4,115,101,101,
+ 110,114,27,0,0,0,114,5,0,0,0,114,5,0,0,0,
+ 114,6,0,0,0,218,12,104,97,115,95,100,101,97,100,108,
+ 111,99,107,79,0,0,0,115,30,0,0,0,8,2,6,1,
+ 6,1,2,1,10,1,8,1,4,1,6,1,8,1,4,1,
+ 8,1,4,6,10,1,2,242,255,128,122,24,95,77,111,100,
+ 117,108,101,76,111,99,107,46,104,97,115,95,100,101,97,100,
+ 108,111,99,107,99,1,0,0,0,0,0,0,0,0,0,0,
+ 0,2,0,0,0,8,0,0,0,67,0,0,0,115,198,0,
+ 0,0,116,0,160,1,161,0,125,1,124,0,116,2,124,1,
+ 60,0,122,172,9,0,124,0,106,3,143,126,1,0,124,0,
+ 106,4,100,2,107,2,115,48,124,0,106,5,124,1,107,2,
+ 114,92,124,1,124,0,95,5,124,0,4,0,106,4,100,3,
+ 55,0,2,0,95,4,87,0,100,4,4,0,4,0,131,3,
+ 1,0,87,0,116,2,124,1,61,0,100,1,83,0,124,0,
+ 160,6,161,0,114,112,116,7,100,5,124,0,22,0,131,1,
+ 130,1,124,0,106,8,160,9,100,6,161,1,114,138,124,0,
+ 4,0,106,10,100,3,55,0,2,0,95,10,87,0,100,4,
+ 4,0,4,0,131,3,1,0,110,16,49,0,115,158,119,1,
+ 1,0,1,0,1,0,89,0,1,0,124,0,106,8,160,9,
+ 161,0,1,0,124,0,106,8,160,11,161,0,1,0,113,20,
+ 116,2,124,1,61,0,119,0,41,7,122,185,10,32,32,32,
+ 32,32,32,32,32,65,99,113,117,105,114,101,32,116,104,101,
+ 32,109,111,100,117,108,101,32,108,111,99,107,46,32,32,73,
+ 102,32,97,32,112,111,116,101,110,116,105,97,108,32,100,101,
+ 97,100,108,111,99,107,32,105,115,32,100,101,116,101,99,116,
+ 101,100,44,10,32,32,32,32,32,32,32,32,97,32,95,68,
+ 101,97,100,108,111,99,107,69,114,114,111,114,32,105,115,32,
+ 114,97,105,115,101,100,46,10,32,32,32,32,32,32,32,32,
+ 79,116,104,101,114,119,105,115,101,44,32,116,104,101,32,108,
+ 111,99,107,32,105,115,32,97,108,119,97,121,115,32,97,99,
+ 113,117,105,114,101,100,32,97,110,100,32,84,114,117,101,32,
+ 105,115,32,114,101,116,117,114,110,101,100,46,10,32,32,32,
+ 32,32,32,32,32,84,114,25,0,0,0,233,1,0,0,0,
+ 78,122,23,100,101,97,100,108,111,99,107,32,100,101,116,101,
+ 99,116,101,100,32,98,121,32,37,114,70,41,12,114,26,0,
+ 0,0,114,35,0,0,0,114,37,0,0,0,114,27,0,0,
+ 0,114,30,0,0,0,114,29,0,0,0,114,41,0,0,0,
+ 114,22,0,0,0,114,28,0,0,0,218,7,97,99,113,117,
+ 105,114,101,114,31,0,0,0,218,7,114,101,108,101,97,115,
+ 101,169,2,114,33,0,0,0,114,40,0,0,0,114,5,0,
+ 0,0,114,5,0,0,0,114,6,0,0,0,114,43,0,0,
+ 0,100,0,0,0,115,38,0,0,0,8,6,8,1,2,1,
+ 2,1,8,1,20,1,6,1,14,1,14,1,10,9,8,248,
+ 12,1,12,1,44,1,10,2,10,1,2,244,8,14,255,128,
+ 122,19,95,77,111,100,117,108,101,76,111,99,107,46,97,99,
+ 113,117,105,114,101,99,1,0,0,0,0,0,0,0,0,0,
+ 0,0,2,0,0,0,8,0,0,0,67,0,0,0,115,144,
+ 0,0,0,116,0,160,1,161,0,125,1,124,0,106,2,143,
+ 110,1,0,124,0,106,3,124,1,107,3,114,34,116,4,100,
+ 1,131,1,130,1,124,0,106,5,100,2,107,4,115,48,74,
+ 0,130,1,124,0,4,0,106,5,100,3,56,0,2,0,95,
+ 5,124,0,106,5,100,2,107,2,114,108,100,0,124,0,95,
+ 3,124,0,106,6,114,108,124,0,4,0,106,6,100,3,56,
+ 0,2,0,95,6,124,0,106,7,160,8,161,0,1,0,87,
+ 0,100,0,4,0,4,0,131,3,1,0,100,0,83,0,49,
+ 0,115,130,119,1,1,0,1,0,1,0,89,0,1,0,100,
+ 0,83,0,41,4,78,250,31,99,97,110,110,111,116,32,114,
+ 101,108,101,97,115,101,32,117,110,45,97,99,113,117,105,114,
+ 101,100,32,108,111,99,107,114,25,0,0,0,114,42,0,0,
+ 0,41,9,114,26,0,0,0,114,35,0,0,0,114,27,0,
+ 0,0,114,29,0,0,0,218,12,82,117,110,116,105,109,101,
+ 69,114,114,111,114,114,30,0,0,0,114,31,0,0,0,114,
+ 28,0,0,0,114,44,0,0,0,114,45,0,0,0,114,5,
+ 0,0,0,114,5,0,0,0,114,6,0,0,0,114,44,0,
+ 0,0,125,0,0,0,115,24,0,0,0,8,1,8,1,10,
+ 1,8,1,14,1,14,1,10,1,6,1,6,1,14,1,46,
+ 1,255,128,122,19,95,77,111,100,117,108,101,76,111,99,107,
+ 46,114,101,108,101,97,115,101,99,1,0,0,0,0,0,0,
+ 0,0,0,0,0,1,0,0,0,5,0,0,0,67,0,0,
+ 0,115,18,0,0,0,100,1,160,0,124,0,106,1,116,2,
+ 124,0,131,1,161,2,83,0,41,2,78,122,23,95,77,111,
+ 100,117,108,101,76,111,99,107,40,123,33,114,125,41,32,97,
+ 116,32,123,125,169,3,218,6,102,111,114,109,97,116,114,20,
+ 0,0,0,218,2,105,100,169,1,114,33,0,0,0,114,5,
+ 0,0,0,114,5,0,0,0,114,6,0,0,0,218,8,95,
+ 95,114,101,112,114,95,95,138,0,0,0,115,4,0,0,0,
+ 18,1,255,128,122,20,95,77,111,100,117,108,101,76,111,99,
+ 107,46,95,95,114,101,112,114,95,95,78,41,9,114,9,0,
+ 0,0,114,8,0,0,0,114,1,0,0,0,114,10,0,0,
+ 0,114,34,0,0,0,114,41,0,0,0,114,43,0,0,0,
+ 114,44,0,0,0,114,52,0,0,0,114,5,0,0,0,114,
+ 5,0,0,0,114,5,0,0,0,114,6,0,0,0,114,23,
+ 0,0,0,65,0,0,0,115,16,0,0,0,8,0,4,1,
+ 8,5,8,8,8,21,8,25,12,13,255,128,114,23,0,0,
+ 0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,2,0,0,0,64,0,0,0,115,48,0,0,0,101,
+ 0,90,1,100,0,90,2,100,1,90,3,100,2,100,3,132,
+ 0,90,4,100,4,100,5,132,0,90,5,100,6,100,7,132,
+ 0,90,6,100,8,100,9,132,0,90,7,100,10,83,0,41,
+ 11,218,16,95,68,117,109,109,121,77,111,100,117,108,101,76,
+ 111,99,107,122,86,65,32,115,105,109,112,108,101,32,95,77,
+ 111,100,117,108,101,76,111,99,107,32,101,113,117,105,118,97,
+ 108,101,110,116,32,102,111,114,32,80,121,116,104,111,110,32,
+ 98,117,105,108,100,115,32,119,105,116,104,111,117,116,10,32,
+ 32,32,32,109,117,108,116,105,45,116,104,114,101,97,100,105,
+ 110,103,32,115,117,112,112,111,114,116,46,99,2,0,0,0,
+ 0,0,0,0,0,0,0,0,2,0,0,0,2,0,0,0,
+ 67,0,0,0,115,16,0,0,0,124,1,124,0,95,0,100,
+ 1,124,0,95,1,100,0,83,0,114,24,0,0,0,41,2,
+ 114,20,0,0,0,114,30,0,0,0,114,32,0,0,0,114,
+ 5,0,0,0,114,5,0,0,0,114,6,0,0,0,114,34,
+ 0,0,0,146,0,0,0,115,6,0,0,0,6,1,10,1,
+ 255,128,122,25,95,68,117,109,109,121,77,111,100,117,108,101,
+ 76,111,99,107,46,95,95,105,110,105,116,95,95,99,1,0,
+ 0,0,0,0,0,0,0,0,0,0,1,0,0,0,3,0,
+ 0,0,67,0,0,0,115,18,0,0,0,124,0,4,0,106,
+ 0,100,1,55,0,2,0,95,0,100,2,83,0,41,3,78,
+ 114,42,0,0,0,84,41,1,114,30,0,0,0,114,51,0,
+ 0,0,114,5,0,0,0,114,5,0,0,0,114,6,0,0,
+ 0,114,43,0,0,0,150,0,0,0,115,6,0,0,0,14,
+ 1,4,1,255,128,122,24,95,68,117,109,109,121,77,111,100,
+ 117,108,101,76,111,99,107,46,97,99,113,117,105,114,101,99,
+ 1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,
+ 3,0,0,0,67,0,0,0,115,36,0,0,0,124,0,106,
+ 0,100,1,107,2,114,18,116,1,100,2,131,1,130,1,124,
+ 0,4,0,106,0,100,3,56,0,2,0,95,0,100,0,83,
+ 0,41,4,78,114,25,0,0,0,114,46,0,0,0,114,42,
+ 0,0,0,41,2,114,30,0,0,0,114,47,0,0,0,114,
+ 51,0,0,0,114,5,0,0,0,114,5,0,0,0,114,6,
+ 0,0,0,114,44,0,0,0,154,0,0,0,115,8,0,0,
+ 0,10,1,8,1,18,1,255,128,122,24,95,68,117,109,109,
+ 121,77,111,100,117,108,101,76,111,99,107,46,114,101,108,101,
+ 97,115,101,99,1,0,0,0,0,0,0,0,0,0,0,0,
+ 1,0,0,0,5,0,0,0,67,0,0,0,115,18,0,0,
+ 0,100,1,160,0,124,0,106,1,116,2,124,0,131,1,161,
+ 2,83,0,41,2,78,122,28,95,68,117,109,109,121,77,111,
+ 100,117,108,101,76,111,99,107,40,123,33,114,125,41,32,97,
+ 116,32,123,125,114,48,0,0,0,114,51,0,0,0,114,5,
+ 0,0,0,114,5,0,0,0,114,6,0,0,0,114,52,0,
+ 0,0,159,0,0,0,115,4,0,0,0,18,1,255,128,122,
+ 25,95,68,117,109,109,121,77,111,100,117,108,101,76,111,99,
+ 107,46,95,95,114,101,112,114,95,95,78,41,8,114,9,0,
+ 0,0,114,8,0,0,0,114,1,0,0,0,114,10,0,0,
+ 0,114,34,0,0,0,114,43,0,0,0,114,44,0,0,0,
+ 114,52,0,0,0,114,5,0,0,0,114,5,0,0,0,114,
+ 5,0,0,0,114,6,0,0,0,114,53,0,0,0,142,0,
+ 0,0,115,14,0,0,0,8,0,4,1,8,3,8,4,8,
+ 4,12,5,255,128,114,53,0,0,0,99,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,64,
+ 0,0,0,115,36,0,0,0,101,0,90,1,100,0,90,2,
+ 100,1,100,2,132,0,90,3,100,3,100,4,132,0,90,4,
+ 100,5,100,6,132,0,90,5,100,7,83,0,41,8,218,18,
+ 95,77,111,100,117,108,101,76,111,99,107,77,97,110,97,103,
+ 101,114,99,2,0,0,0,0,0,0,0,0,0,0,0,2,
0,0,0,2,0,0,0,67,0,0,0,115,16,0,0,0,
- 124,1,124,0,95,0,100,1,124,0,95,1,100,0,83,0,
- 114,21,0,0,0,41,2,114,17,0,0,0,114,27,0,0,
- 0,114,29,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,114,31,0,0,0,133,0,0,0,115,4,
- 0,0,0,0,1,6,1,122,25,95,68,117,109,109,121,77,
- 111,100,117,108,101,76,111,99,107,46,95,95,105,110,105,116,
- 95,95,99,1,0,0,0,0,0,0,0,0,0,0,0,1,
- 0,0,0,3,0,0,0,67,0,0,0,115,18,0,0,0,
- 124,0,4,0,106,0,100,1,55,0,2,0,95,0,100,2,
- 83,0,41,3,78,114,39,0,0,0,84,41,1,114,27,0,
- 0,0,114,48,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,114,40,0,0,0,137,0,0,0,115,
- 4,0,0,0,0,1,14,1,122,24,95,68,117,109,109,121,
- 77,111,100,117,108,101,76,111,99,107,46,97,99,113,117,105,
- 114,101,99,1,0,0,0,0,0,0,0,0,0,0,0,1,
- 0,0,0,3,0,0,0,67,0,0,0,115,36,0,0,0,
- 124,0,106,0,100,1,107,2,114,18,116,1,100,2,131,1,
- 130,1,124,0,4,0,106,0,100,3,56,0,2,0,95,0,
- 100,0,83,0,41,4,78,114,22,0,0,0,114,43,0,0,
- 0,114,39,0,0,0,41,2,114,27,0,0,0,114,44,0,
- 0,0,114,48,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,114,41,0,0,0,141,0,0,0,115,
- 6,0,0,0,0,1,10,1,8,1,122,24,95,68,117,109,
- 109,121,77,111,100,117,108,101,76,111,99,107,46,114,101,108,
- 101,97,115,101,99,1,0,0,0,0,0,0,0,0,0,0,
- 0,1,0,0,0,5,0,0,0,67,0,0,0,115,18,0,
- 0,0,100,1,160,0,124,0,106,1,116,2,124,0,131,1,
- 161,2,83,0,41,2,78,122,28,95,68,117,109,109,121,77,
- 111,100,117,108,101,76,111,99,107,40,123,33,114,125,41,32,
- 97,116,32,123,125,114,45,0,0,0,114,48,0,0,0,114,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,114,49,
- 0,0,0,146,0,0,0,115,2,0,0,0,0,1,122,25,
- 95,68,117,109,109,121,77,111,100,117,108,101,76,111,99,107,
- 46,95,95,114,101,112,114,95,95,78,41,8,114,1,0,0,
- 0,114,0,0,0,0,114,2,0,0,0,114,3,0,0,0,
- 114,31,0,0,0,114,40,0,0,0,114,41,0,0,0,114,
- 49,0,0,0,114,10,0,0,0,114,10,0,0,0,114,10,
- 0,0,0,114,11,0,0,0,114,50,0,0,0,129,0,0,
- 0,115,10,0,0,0,8,1,4,3,8,4,8,4,8,5,
- 114,50,0,0,0,99,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,2,0,0,0,64,0,0,0,115,36,
- 0,0,0,101,0,90,1,100,0,90,2,100,1,100,2,132,
- 0,90,3,100,3,100,4,132,0,90,4,100,5,100,6,132,
- 0,90,5,100,7,83,0,41,8,218,18,95,77,111,100,117,
- 108,101,76,111,99,107,77,97,110,97,103,101,114,99,2,0,
- 0,0,0,0,0,0,0,0,0,0,2,0,0,0,2,0,
- 0,0,67,0,0,0,115,16,0,0,0,124,1,124,0,95,
- 0,100,0,124,0,95,1,100,0,83,0,114,13,0,0,0,
- 41,2,218,5,95,110,97,109,101,218,5,95,108,111,99,107,
- 114,29,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
- 11,0,0,0,114,31,0,0,0,152,0,0,0,115,4,0,
- 0,0,0,1,6,1,122,27,95,77,111,100,117,108,101,76,
- 111,99,107,77,97,110,97,103,101,114,46,95,95,105,110,105,
- 116,95,95,99,1,0,0,0,0,0,0,0,0,0,0,0,
- 1,0,0,0,2,0,0,0,67,0,0,0,115,26,0,0,
- 0,116,0,124,0,106,1,131,1,124,0,95,2,124,0,106,
- 2,160,3,161,0,1,0,100,0,83,0,114,13,0,0,0,
- 41,4,218,16,95,103,101,116,95,109,111,100,117,108,101,95,
- 108,111,99,107,114,52,0,0,0,114,53,0,0,0,114,40,
- 0,0,0,114,48,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,218,9,95,95,101,110,116,101,114,
- 95,95,156,0,0,0,115,4,0,0,0,0,1,12,1,122,
- 28,95,77,111,100,117,108,101,76,111,99,107,77,97,110,97,
- 103,101,114,46,95,95,101,110,116,101,114,95,95,99,1,0,
- 0,0,0,0,0,0,0,0,0,0,3,0,0,0,2,0,
- 0,0,79,0,0,0,115,14,0,0,0,124,0,106,0,160,
- 1,161,0,1,0,100,0,83,0,114,13,0,0,0,41,2,
- 114,53,0,0,0,114,41,0,0,0,41,3,114,30,0,0,
- 0,218,4,97,114,103,115,90,6,107,119,97,114,103,115,114,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,8,
- 95,95,101,120,105,116,95,95,160,0,0,0,115,2,0,0,
- 0,0,1,122,27,95,77,111,100,117,108,101,76,111,99,107,
- 77,97,110,97,103,101,114,46,95,95,101,120,105,116,95,95,
- 78,41,6,114,1,0,0,0,114,0,0,0,0,114,2,0,
- 0,0,114,31,0,0,0,114,55,0,0,0,114,57,0,0,
- 0,114,10,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,114,51,0,0,0,150,0,0,0,115,6,
- 0,0,0,8,2,8,4,8,4,114,51,0,0,0,99,1,
- 0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,8,
- 0,0,0,67,0,0,0,115,136,0,0,0,116,0,160,1,
- 161,0,1,0,122,112,122,14,116,2,124,0,25,0,131,0,
- 125,1,87,0,110,22,4,0,116,3,121,46,1,0,1,0,
- 1,0,100,1,125,1,89,0,110,2,48,0,124,1,100,1,
- 117,0,114,110,116,4,100,1,117,0,114,74,116,5,124,0,
- 131,1,125,1,110,8,116,6,124,0,131,1,125,1,124,0,
- 102,1,100,2,100,3,132,1,125,2,116,7,160,8,124,1,
- 124,2,161,2,116,2,124,0,60,0,87,0,116,0,160,9,
- 161,0,1,0,110,10,116,0,160,9,161,0,1,0,48,0,
- 124,1,83,0,41,4,122,139,71,101,116,32,111,114,32,99,
- 114,101,97,116,101,32,116,104,101,32,109,111,100,117,108,101,
- 32,108,111,99,107,32,102,111,114,32,97,32,103,105,118,101,
- 110,32,109,111,100,117,108,101,32,110,97,109,101,46,10,10,
- 32,32,32,32,65,99,113,117,105,114,101,47,114,101,108,101,
- 97,115,101,32,105,110,116,101,114,110,97,108,108,121,32,116,
- 104,101,32,103,108,111,98,97,108,32,105,109,112,111,114,116,
- 32,108,111,99,107,32,116,111,32,112,114,111,116,101,99,116,
- 10,32,32,32,32,95,109,111,100,117,108,101,95,108,111,99,
- 107,115,46,78,99,2,0,0,0,0,0,0,0,0,0,0,
- 0,2,0,0,0,8,0,0,0,83,0,0,0,115,56,0,
- 0,0,116,0,160,1,161,0,1,0,122,32,116,2,160,3,
- 124,1,161,1,124,0,117,0,114,30,116,2,124,1,61,0,
- 87,0,116,0,160,4,161,0,1,0,110,10,116,0,160,4,
- 161,0,1,0,48,0,100,0,83,0,114,13,0,0,0,41,
- 5,218,4,95,105,109,112,218,12,97,99,113,117,105,114,101,
- 95,108,111,99,107,218,13,95,109,111,100,117,108,101,95,108,
- 111,99,107,115,114,35,0,0,0,218,12,114,101,108,101,97,
- 115,101,95,108,111,99,107,41,2,218,3,114,101,102,114,17,
- 0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,
- 0,0,218,2,99,98,185,0,0,0,115,10,0,0,0,0,
- 1,8,1,2,4,14,1,8,2,122,28,95,103,101,116,95,
- 109,111,100,117,108,101,95,108,111,99,107,46,60,108,111,99,
- 97,108,115,62,46,99,98,41,10,114,58,0,0,0,114,59,
- 0,0,0,114,60,0,0,0,218,8,75,101,121,69,114,114,
- 111,114,114,23,0,0,0,114,50,0,0,0,114,20,0,0,
- 0,218,8,95,119,101,97,107,114,101,102,114,62,0,0,0,
- 114,61,0,0,0,41,3,114,17,0,0,0,114,24,0,0,
- 0,114,63,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,114,54,0,0,0,166,0,0,0,115,28,
- 0,0,0,0,6,8,1,2,1,2,1,14,1,12,1,10,
- 2,8,1,8,1,10,2,8,2,12,11,18,2,20,2,114,
- 54,0,0,0,99,1,0,0,0,0,0,0,0,0,0,0,
- 0,2,0,0,0,8,0,0,0,67,0,0,0,115,52,0,
- 0,0,116,0,124,0,131,1,125,1,122,12,124,1,160,1,
- 161,0,1,0,87,0,110,18,4,0,116,2,121,38,1,0,
- 1,0,1,0,89,0,110,10,48,0,124,1,160,3,161,0,
- 1,0,100,1,83,0,41,2,122,189,65,99,113,117,105,114,
- 101,115,32,116,104,101,110,32,114,101,108,101,97,115,101,115,
+ 124,1,124,0,95,0,100,0,124,0,95,1,100,0,83,0,
+ 114,0,0,0,0,41,2,218,5,95,110,97,109,101,218,5,
+ 95,108,111,99,107,114,32,0,0,0,114,5,0,0,0,114,
+ 5,0,0,0,114,6,0,0,0,114,34,0,0,0,165,0,
+ 0,0,115,6,0,0,0,6,1,10,1,255,128,122,27,95,
+ 77,111,100,117,108,101,76,111,99,107,77,97,110,97,103,101,
+ 114,46,95,95,105,110,105,116,95,95,99,1,0,0,0,0,
+ 0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,67,
+ 0,0,0,115,26,0,0,0,116,0,124,0,106,1,131,1,
+ 124,0,95,2,124,0,106,2,160,3,161,0,1,0,100,0,
+ 83,0,114,0,0,0,0,41,4,218,16,95,103,101,116,95,
+ 109,111,100,117,108,101,95,108,111,99,107,114,55,0,0,0,
+ 114,56,0,0,0,114,43,0,0,0,114,51,0,0,0,114,
+ 5,0,0,0,114,5,0,0,0,114,6,0,0,0,218,9,
+ 95,95,101,110,116,101,114,95,95,169,0,0,0,115,6,0,
+ 0,0,12,1,14,1,255,128,122,28,95,77,111,100,117,108,
+ 101,76,111,99,107,77,97,110,97,103,101,114,46,95,95,101,
+ 110,116,101,114,95,95,99,1,0,0,0,0,0,0,0,0,
+ 0,0,0,3,0,0,0,2,0,0,0,79,0,0,0,115,
+ 14,0,0,0,124,0,106,0,160,1,161,0,1,0,100,0,
+ 83,0,114,0,0,0,0,41,2,114,56,0,0,0,114,44,
+ 0,0,0,41,3,114,33,0,0,0,218,4,97,114,103,115,
+ 90,6,107,119,97,114,103,115,114,5,0,0,0,114,5,0,
+ 0,0,114,6,0,0,0,218,8,95,95,101,120,105,116,95,
+ 95,173,0,0,0,115,4,0,0,0,14,1,255,128,122,27,
+ 95,77,111,100,117,108,101,76,111,99,107,77,97,110,97,103,
+ 101,114,46,95,95,101,120,105,116,95,95,78,41,6,114,9,
+ 0,0,0,114,8,0,0,0,114,1,0,0,0,114,34,0,
+ 0,0,114,58,0,0,0,114,60,0,0,0,114,5,0,0,
+ 0,114,5,0,0,0,114,5,0,0,0,114,6,0,0,0,
+ 114,54,0,0,0,163,0,0,0,115,10,0,0,0,8,0,
+ 8,2,8,4,12,4,255,128,114,54,0,0,0,99,1,0,
+ 0,0,0,0,0,0,0,0,0,0,3,0,0,0,8,0,
+ 0,0,67,0,0,0,115,132,0,0,0,116,0,160,1,161,
+ 0,1,0,122,110,122,14,116,2,124,0,25,0,131,0,125,
+ 1,87,0,110,18,4,0,116,3,121,130,1,0,1,0,1,
+ 0,100,1,125,1,89,0,124,1,100,1,117,0,114,106,116,
+ 4,100,1,117,0,114,70,116,5,124,0,131,1,125,1,110,
+ 8,116,6,124,0,131,1,125,1,124,0,102,1,100,2,100,
+ 3,132,1,125,2,116,7,160,8,124,1,124,2,161,2,116,
+ 2,124,0,60,0,87,0,116,0,160,9,161,0,1,0,124,
+ 1,83,0,116,0,160,9,161,0,1,0,119,0,119,0,41,
+ 4,122,139,71,101,116,32,111,114,32,99,114,101,97,116,101,
32,116,104,101,32,109,111,100,117,108,101,32,108,111,99,107,
32,102,111,114,32,97,32,103,105,118,101,110,32,109,111,100,
- 117,108,101,32,110,97,109,101,46,10,10,32,32,32,32,84,
- 104,105,115,32,105,115,32,117,115,101,100,32,116,111,32,101,
- 110,115,117,114,101,32,97,32,109,111,100,117,108,101,32,105,
- 115,32,99,111,109,112,108,101,116,101,108,121,32,105,110,105,
- 116,105,97,108,105,122,101,100,44,32,105,110,32,116,104,101,
- 10,32,32,32,32,101,118,101,110,116,32,105,116,32,105,115,
- 32,98,101,105,110,103,32,105,109,112,111,114,116,101,100,32,
- 98,121,32,97,110,111,116,104,101,114,32,116,104,114,101,97,
- 100,46,10,32,32,32,32,78,41,4,114,54,0,0,0,114,
- 40,0,0,0,114,19,0,0,0,114,41,0,0,0,41,2,
- 114,17,0,0,0,114,24,0,0,0,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,218,19,95,108,111,99,107,
- 95,117,110,108,111,99,107,95,109,111,100,117,108,101,203,0,
- 0,0,115,12,0,0,0,0,6,8,1,2,1,12,1,12,
- 3,6,2,114,66,0,0,0,99,1,0,0,0,0,0,0,
- 0,0,0,0,0,3,0,0,0,4,0,0,0,79,0,0,
- 0,115,14,0,0,0,124,0,124,1,105,0,124,2,164,1,
- 142,1,83,0,41,1,97,46,1,0,0,114,101,109,111,118,
- 101,95,105,109,112,111,114,116,108,105,98,95,102,114,97,109,
- 101,115,32,105,110,32,105,109,112,111,114,116,46,99,32,119,
- 105,108,108,32,97,108,119,97,121,115,32,114,101,109,111,118,
- 101,32,115,101,113,117,101,110,99,101,115,10,32,32,32,32,
- 111,102,32,105,109,112,111,114,116,108,105,98,32,102,114,97,
- 109,101,115,32,116,104,97,116,32,101,110,100,32,119,105,116,
- 104,32,97,32,99,97,108,108,32,116,111,32,116,104,105,115,
- 32,102,117,110,99,116,105,111,110,10,10,32,32,32,32,85,
- 115,101,32,105,116,32,105,110,115,116,101,97,100,32,111,102,
- 32,97,32,110,111,114,109,97,108,32,99,97,108,108,32,105,
- 110,32,112,108,97,99,101,115,32,119,104,101,114,101,32,105,
- 110,99,108,117,100,105,110,103,32,116,104,101,32,105,109,112,
- 111,114,116,108,105,98,10,32,32,32,32,102,114,97,109,101,
- 115,32,105,110,116,114,111,100,117,99,101,115,32,117,110,119,
- 97,110,116,101,100,32,110,111,105,115,101,32,105,110,116,111,
- 32,116,104,101,32,116,114,97,99,101,98,97,99,107,32,40,
- 101,46,103,46,32,119,104,101,110,32,101,120,101,99,117,116,
- 105,110,103,10,32,32,32,32,109,111,100,117,108,101,32,99,
- 111,100,101,41,10,32,32,32,32,114,10,0,0,0,41,3,
- 218,1,102,114,56,0,0,0,90,4,107,119,100,115,114,10,
- 0,0,0,114,10,0,0,0,114,11,0,0,0,218,25,95,
- 99,97,108,108,95,119,105,116,104,95,102,114,97,109,101,115,
- 95,114,101,109,111,118,101,100,220,0,0,0,115,2,0,0,
- 0,0,8,114,68,0,0,0,114,39,0,0,0,41,1,218,
- 9,118,101,114,98,111,115,105,116,121,99,1,0,0,0,0,
- 0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,71,
- 0,0,0,115,54,0,0,0,116,0,106,1,106,2,124,1,
- 107,5,114,50,124,0,160,3,100,1,161,1,115,30,100,2,
- 124,0,23,0,125,0,116,4,124,0,106,5,124,2,142,0,
- 116,0,106,6,100,3,141,2,1,0,100,4,83,0,41,5,
- 122,61,80,114,105,110,116,32,116,104,101,32,109,101,115,115,
- 97,103,101,32,116,111,32,115,116,100,101,114,114,32,105,102,
- 32,45,118,47,80,89,84,72,79,78,86,69,82,66,79,83,
- 69,32,105,115,32,116,117,114,110,101,100,32,111,110,46,41,
- 2,250,1,35,122,7,105,109,112,111,114,116,32,122,2,35,
- 32,41,1,90,4,102,105,108,101,78,41,7,114,15,0,0,
- 0,218,5,102,108,97,103,115,218,7,118,101,114,98,111,115,
- 101,218,10,115,116,97,114,116,115,119,105,116,104,218,5,112,
- 114,105,110,116,114,46,0,0,0,218,6,115,116,100,101,114,
- 114,41,3,218,7,109,101,115,115,97,103,101,114,69,0,0,
- 0,114,56,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,218,16,95,118,101,114,98,111,115,101,95,
- 109,101,115,115,97,103,101,231,0,0,0,115,8,0,0,0,
- 0,2,12,1,10,1,8,1,114,77,0,0,0,99,1,0,
- 0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,0,
- 0,0,3,0,0,0,115,26,0,0,0,135,0,102,1,100,
- 1,100,2,132,8,125,1,116,0,124,1,136,0,131,2,1,
- 0,124,1,83,0,41,3,122,49,68,101,99,111,114,97,116,
- 111,114,32,116,111,32,118,101,114,105,102,121,32,116,104,101,
- 32,110,97,109,101,100,32,109,111,100,117,108,101,32,105,115,
- 32,98,117,105,108,116,45,105,110,46,99,2,0,0,0,0,
- 0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,19,
- 0,0,0,115,38,0,0,0,124,1,116,0,106,1,118,1,
- 114,28,116,2,100,1,160,3,124,1,161,1,124,1,100,2,
- 141,2,130,1,136,0,124,0,124,1,131,2,83,0,41,3,
- 78,250,29,123,33,114,125,32,105,115,32,110,111,116,32,97,
- 32,98,117,105,108,116,45,105,110,32,109,111,100,117,108,101,
- 114,16,0,0,0,41,4,114,15,0,0,0,218,20,98,117,
- 105,108,116,105,110,95,109,111,100,117,108,101,95,110,97,109,
- 101,115,218,11,73,109,112,111,114,116,69,114,114,111,114,114,
- 46,0,0,0,169,2,114,30,0,0,0,218,8,102,117,108,
- 108,110,97,109,101,169,1,218,3,102,120,110,114,10,0,0,
- 0,114,11,0,0,0,218,25,95,114,101,113,117,105,114,101,
- 115,95,98,117,105,108,116,105,110,95,119,114,97,112,112,101,
- 114,241,0,0,0,115,10,0,0,0,0,1,10,1,10,1,
- 2,255,6,2,122,52,95,114,101,113,117,105,114,101,115,95,
- 98,117,105,108,116,105,110,46,60,108,111,99,97,108,115,62,
- 46,95,114,101,113,117,105,114,101,115,95,98,117,105,108,116,
- 105,110,95,119,114,97,112,112,101,114,169,1,114,12,0,0,
- 0,41,2,114,84,0,0,0,114,85,0,0,0,114,10,0,
- 0,0,114,83,0,0,0,114,11,0,0,0,218,17,95,114,
- 101,113,117,105,114,101,115,95,98,117,105,108,116,105,110,239,
- 0,0,0,115,6,0,0,0,0,2,12,5,10,1,114,87,
+ 117,108,101,32,110,97,109,101,46,10,10,32,32,32,32,65,
+ 99,113,117,105,114,101,47,114,101,108,101,97,115,101,32,105,
+ 110,116,101,114,110,97,108,108,121,32,116,104,101,32,103,108,
+ 111,98,97,108,32,105,109,112,111,114,116,32,108,111,99,107,
+ 32,116,111,32,112,114,111,116,101,99,116,10,32,32,32,32,
+ 95,109,111,100,117,108,101,95,108,111,99,107,115,46,78,99,
+ 2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,
+ 8,0,0,0,83,0,0,0,115,54,0,0,0,116,0,160,
+ 1,161,0,1,0,122,34,116,2,160,3,124,1,161,1,124,
+ 0,117,0,114,30,116,2,124,1,61,0,87,0,116,0,160,
+ 4,161,0,1,0,100,0,83,0,116,0,160,4,161,0,1,
+ 0,119,0,114,0,0,0,0,41,5,218,4,95,105,109,112,
+ 218,12,97,99,113,117,105,114,101,95,108,111,99,107,218,13,
+ 95,109,111,100,117,108,101,95,108,111,99,107,115,114,38,0,
+ 0,0,218,12,114,101,108,101,97,115,101,95,108,111,99,107,
+ 41,2,218,3,114,101,102,114,20,0,0,0,114,5,0,0,
+ 0,114,5,0,0,0,114,6,0,0,0,218,2,99,98,198,
+ 0,0,0,115,14,0,0,0,8,1,2,1,14,4,6,1,
+ 2,128,22,2,255,128,122,28,95,103,101,116,95,109,111,100,
+ 117,108,101,95,108,111,99,107,46,60,108,111,99,97,108,115,
+ 62,46,99,98,41,10,114,61,0,0,0,114,62,0,0,0,
+ 114,63,0,0,0,218,8,75,101,121,69,114,114,111,114,114,
+ 26,0,0,0,114,53,0,0,0,114,23,0,0,0,218,8,
+ 95,119,101,97,107,114,101,102,114,65,0,0,0,114,64,0,
+ 0,0,41,3,114,20,0,0,0,114,27,0,0,0,114,66,
+ 0,0,0,114,5,0,0,0,114,5,0,0,0,114,6,0,
+ 0,0,114,57,0,0,0,179,0,0,0,115,36,0,0,0,
+ 8,6,2,1,2,1,14,1,12,1,6,1,8,2,8,1,
+ 10,1,8,2,12,2,16,11,2,128,8,2,4,2,10,254,
+ 2,234,255,128,114,57,0,0,0,99,1,0,0,0,0,0,
+ 0,0,0,0,0,0,2,0,0,0,8,0,0,0,67,0,
+ 0,0,115,54,0,0,0,116,0,124,0,131,1,125,1,122,
+ 12,124,1,160,1,161,0,1,0,87,0,110,18,4,0,116,
+ 2,121,52,1,0,1,0,1,0,89,0,100,1,83,0,124,
+ 1,160,3,161,0,1,0,100,1,83,0,119,0,41,2,122,
+ 189,65,99,113,117,105,114,101,115,32,116,104,101,110,32,114,
+ 101,108,101,97,115,101,115,32,116,104,101,32,109,111,100,117,
+ 108,101,32,108,111,99,107,32,102,111,114,32,97,32,103,105,
+ 118,101,110,32,109,111,100,117,108,101,32,110,97,109,101,46,
+ 10,10,32,32,32,32,84,104,105,115,32,105,115,32,117,115,
+ 101,100,32,116,111,32,101,110,115,117,114,101,32,97,32,109,
+ 111,100,117,108,101,32,105,115,32,99,111,109,112,108,101,116,
+ 101,108,121,32,105,110,105,116,105,97,108,105,122,101,100,44,
+ 32,105,110,32,116,104,101,10,32,32,32,32,101,118,101,110,
+ 116,32,105,116,32,105,115,32,98,101,105,110,103,32,105,109,
+ 112,111,114,116,101,100,32,98,121,32,97,110,111,116,104,101,
+ 114,32,116,104,114,101,97,100,46,10,32,32,32,32,78,41,
+ 4,114,57,0,0,0,114,43,0,0,0,114,22,0,0,0,
+ 114,44,0,0,0,41,2,114,20,0,0,0,114,27,0,0,
+ 0,114,5,0,0,0,114,5,0,0,0,114,6,0,0,0,
+ 218,19,95,108,111,99,107,95,117,110,108,111,99,107,95,109,
+ 111,100,117,108,101,216,0,0,0,115,16,0,0,0,8,6,
+ 2,1,12,1,12,1,6,3,12,2,2,251,255,128,114,69,
+ 0,0,0,99,1,0,0,0,0,0,0,0,0,0,0,0,
+ 3,0,0,0,4,0,0,0,79,0,0,0,115,14,0,0,
+ 0,124,0,124,1,105,0,124,2,164,1,142,1,83,0,41,
+ 2,97,46,1,0,0,114,101,109,111,118,101,95,105,109,112,
+ 111,114,116,108,105,98,95,102,114,97,109,101,115,32,105,110,
+ 32,105,109,112,111,114,116,46,99,32,119,105,108,108,32,97,
+ 108,119,97,121,115,32,114,101,109,111,118,101,32,115,101,113,
+ 117,101,110,99,101,115,10,32,32,32,32,111,102,32,105,109,
+ 112,111,114,116,108,105,98,32,102,114,97,109,101,115,32,116,
+ 104,97,116,32,101,110,100,32,119,105,116,104,32,97,32,99,
+ 97,108,108,32,116,111,32,116,104,105,115,32,102,117,110,99,
+ 116,105,111,110,10,10,32,32,32,32,85,115,101,32,105,116,
+ 32,105,110,115,116,101,97,100,32,111,102,32,97,32,110,111,
+ 114,109,97,108,32,99,97,108,108,32,105,110,32,112,108,97,
+ 99,101,115,32,119,104,101,114,101,32,105,110,99,108,117,100,
+ 105,110,103,32,116,104,101,32,105,109,112,111,114,116,108,105,
+ 98,10,32,32,32,32,102,114,97,109,101,115,32,105,110,116,
+ 114,111,100,117,99,101,115,32,117,110,119,97,110,116,101,100,
+ 32,110,111,105,115,101,32,105,110,116,111,32,116,104,101,32,
+ 116,114,97,99,101,98,97,99,107,32,40,101,46,103,46,32,
+ 119,104,101,110,32,101,120,101,99,117,116,105,110,103,10,32,
+ 32,32,32,109,111,100,117,108,101,32,99,111,100,101,41,10,
+ 32,32,32,32,78,114,5,0,0,0,41,3,218,1,102,114,
+ 59,0,0,0,90,4,107,119,100,115,114,5,0,0,0,114,
+ 5,0,0,0,114,6,0,0,0,218,25,95,99,97,108,108,
+ 95,119,105,116,104,95,102,114,97,109,101,115,95,114,101,109,
+ 111,118,101,100,233,0,0,0,115,4,0,0,0,14,8,255,
+ 128,114,71,0,0,0,114,42,0,0,0,41,1,218,9,118,
+ 101,114,98,111,115,105,116,121,99,1,0,0,0,0,0,0,
+ 0,1,0,0,0,3,0,0,0,4,0,0,0,71,0,0,
+ 0,115,58,0,0,0,116,0,106,1,106,2,124,1,107,5,
+ 114,54,124,0,160,3,100,1,161,1,115,30,100,2,124,0,
+ 23,0,125,0,116,4,124,0,106,5,124,2,142,0,116,0,
+ 106,6,100,3,141,2,1,0,100,4,83,0,100,4,83,0,
+ 41,5,122,61,80,114,105,110,116,32,116,104,101,32,109,101,
+ 115,115,97,103,101,32,116,111,32,115,116,100,101,114,114,32,
+ 105,102,32,45,118,47,80,89,84,72,79,78,86,69,82,66,
+ 79,83,69,32,105,115,32,116,117,114,110,101,100,32,111,110,
+ 46,41,2,250,1,35,122,7,105,109,112,111,114,116,32,122,
+ 2,35,32,41,1,90,4,102,105,108,101,78,41,7,114,18,
+ 0,0,0,218,5,102,108,97,103,115,218,7,118,101,114,98,
+ 111,115,101,218,10,115,116,97,114,116,115,119,105,116,104,218,
+ 5,112,114,105,110,116,114,49,0,0,0,218,6,115,116,100,
+ 101,114,114,41,3,218,7,109,101,115,115,97,103,101,114,72,
+ 0,0,0,114,59,0,0,0,114,5,0,0,0,114,5,0,
+ 0,0,114,6,0,0,0,218,16,95,118,101,114,98,111,115,
+ 101,95,109,101,115,115,97,103,101,244,0,0,0,115,12,0,
+ 0,0,12,2,10,1,8,1,24,1,4,253,255,128,114,80,
0,0,0,99,1,0,0,0,0,0,0,0,0,0,0,0,
2,0,0,0,3,0,0,0,3,0,0,0,115,26,0,0,
0,135,0,102,1,100,1,100,2,132,8,125,1,116,0,124,
- 1,136,0,131,2,1,0,124,1,83,0,41,3,122,47,68,
+ 1,136,0,131,2,1,0,124,1,83,0,41,4,122,49,68,
101,99,111,114,97,116,111,114,32,116,111,32,118,101,114,105,
102,121,32,116,104,101,32,110,97,109,101,100,32,109,111,100,
- 117,108,101,32,105,115,32,102,114,111,122,101,110,46,99,2,
- 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,4,
- 0,0,0,19,0,0,0,115,38,0,0,0,116,0,160,1,
- 124,1,161,1,115,28,116,2,100,1,160,3,124,1,161,1,
- 124,1,100,2,141,2,130,1,136,0,124,0,124,1,131,2,
- 83,0,169,3,78,122,27,123,33,114,125,32,105,115,32,110,
- 111,116,32,97,32,102,114,111,122,101,110,32,109,111,100,117,
- 108,101,114,16,0,0,0,41,4,114,58,0,0,0,218,9,
- 105,115,95,102,114,111,122,101,110,114,80,0,0,0,114,46,
- 0,0,0,114,81,0,0,0,114,83,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,218,24,95,114,101,113,117,105,114,
- 101,115,95,102,114,111,122,101,110,95,119,114,97,112,112,101,
- 114,252,0,0,0,115,10,0,0,0,0,1,10,1,10,1,
- 2,255,6,2,122,50,95,114,101,113,117,105,114,101,115,95,
- 102,114,111,122,101,110,46,60,108,111,99,97,108,115,62,46,
- 95,114,101,113,117,105,114,101,115,95,102,114,111,122,101,110,
- 95,119,114,97,112,112,101,114,114,86,0,0,0,41,2,114,
- 84,0,0,0,114,90,0,0,0,114,10,0,0,0,114,83,
- 0,0,0,114,11,0,0,0,218,16,95,114,101,113,117,105,
- 114,101,115,95,102,114,111,122,101,110,250,0,0,0,115,6,
- 0,0,0,0,2,12,5,10,1,114,91,0,0,0,99,2,
- 0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,3,
- 0,0,0,67,0,0,0,115,58,0,0,0,116,0,124,1,
- 124,0,131,2,125,2,124,1,116,1,106,2,118,0,114,50,
- 116,1,106,2,124,1,25,0,125,3,116,3,124,2,124,3,
- 131,2,1,0,116,1,106,2,124,1,25,0,83,0,116,4,
- 124,2,131,1,83,0,41,2,122,128,76,111,97,100,32,116,
+ 117,108,101,32,105,115,32,98,117,105,108,116,45,105,110,46,
+ 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
+ 0,4,0,0,0,19,0,0,0,115,38,0,0,0,124,1,
+ 116,0,106,1,118,1,114,28,116,2,100,1,160,3,124,1,
+ 161,1,124,1,100,2,141,2,130,1,136,0,124,0,124,1,
+ 131,2,83,0,41,3,78,250,29,123,33,114,125,32,105,115,
+ 32,110,111,116,32,97,32,98,117,105,108,116,45,105,110,32,
+ 109,111,100,117,108,101,114,19,0,0,0,41,4,114,18,0,
+ 0,0,218,20,98,117,105,108,116,105,110,95,109,111,100,117,
+ 108,101,95,110,97,109,101,115,218,11,73,109,112,111,114,116,
+ 69,114,114,111,114,114,49,0,0,0,169,2,114,33,0,0,
+ 0,218,8,102,117,108,108,110,97,109,101,169,1,218,3,102,
+ 120,110,114,5,0,0,0,114,6,0,0,0,218,25,95,114,
+ 101,113,117,105,114,101,115,95,98,117,105,108,116,105,110,95,
+ 119,114,97,112,112,101,114,254,0,0,0,115,12,0,0,0,
+ 10,1,10,1,2,1,6,255,10,2,255,128,122,52,95,114,
+ 101,113,117,105,114,101,115,95,98,117,105,108,116,105,110,46,
+ 60,108,111,99,97,108,115,62,46,95,114,101,113,117,105,114,
+ 101,115,95,98,117,105,108,116,105,110,95,119,114,97,112,112,
+ 101,114,78,169,1,114,17,0,0,0,41,2,114,87,0,0,
+ 0,114,88,0,0,0,114,5,0,0,0,114,86,0,0,0,
+ 114,6,0,0,0,218,17,95,114,101,113,117,105,114,101,115,
+ 95,98,117,105,108,116,105,110,252,0,0,0,115,8,0,0,
+ 0,12,2,10,5,4,1,255,128,114,90,0,0,0,99,1,
+ 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,
+ 0,0,0,3,0,0,0,115,26,0,0,0,135,0,102,1,
+ 100,1,100,2,132,8,125,1,116,0,124,1,136,0,131,2,
+ 1,0,124,1,83,0,41,4,122,47,68,101,99,111,114,97,
+ 116,111,114,32,116,111,32,118,101,114,105,102,121,32,116,104,
+ 101,32,110,97,109,101,100,32,109,111,100,117,108,101,32,105,
+ 115,32,102,114,111,122,101,110,46,99,2,0,0,0,0,0,
+ 0,0,0,0,0,0,2,0,0,0,4,0,0,0,19,0,
+ 0,0,115,38,0,0,0,116,0,160,1,124,1,161,1,115,
+ 28,116,2,100,1,160,3,124,1,161,1,124,1,100,2,141,
+ 2,130,1,136,0,124,0,124,1,131,2,83,0,169,3,78,
+ 122,27,123,33,114,125,32,105,115,32,110,111,116,32,97,32,
+ 102,114,111,122,101,110,32,109,111,100,117,108,101,114,19,0,
+ 0,0,41,4,114,61,0,0,0,218,9,105,115,95,102,114,
+ 111,122,101,110,114,83,0,0,0,114,49,0,0,0,114,84,
+ 0,0,0,114,86,0,0,0,114,5,0,0,0,114,6,0,
+ 0,0,218,24,95,114,101,113,117,105,114,101,115,95,102,114,
+ 111,122,101,110,95,119,114,97,112,112,101,114,9,1,0,0,
+ 115,12,0,0,0,10,1,10,1,2,1,6,255,10,2,255,
+ 128,122,50,95,114,101,113,117,105,114,101,115,95,102,114,111,
+ 122,101,110,46,60,108,111,99,97,108,115,62,46,95,114,101,
+ 113,117,105,114,101,115,95,102,114,111,122,101,110,95,119,114,
+ 97,112,112,101,114,78,114,89,0,0,0,41,2,114,87,0,
+ 0,0,114,93,0,0,0,114,5,0,0,0,114,86,0,0,
+ 0,114,6,0,0,0,218,16,95,114,101,113,117,105,114,101,
+ 115,95,102,114,111,122,101,110,7,1,0,0,115,8,0,0,
+ 0,12,2,10,5,4,1,255,128,114,94,0,0,0,99,2,
+ 0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,4,
+ 0,0,0,67,0,0,0,115,74,0,0,0,100,1,125,2,
+ 116,0,160,1,124,2,116,2,161,2,1,0,116,3,124,1,
+ 124,0,131,2,125,3,124,1,116,4,106,5,118,0,114,66,
+ 116,4,106,5,124,1,25,0,125,4,116,6,124,3,124,4,
+ 131,2,1,0,116,4,106,5,124,1,25,0,83,0,116,7,
+ 124,3,131,1,83,0,41,3,122,128,76,111,97,100,32,116,
104,101,32,115,112,101,99,105,102,105,101,100,32,109,111,100,
117,108,101,32,105,110,116,111,32,115,121,115,46,109,111,100,
117,108,101,115,32,97,110,100,32,114,101,116,117,114,110,32,
@@ -487,554 +504,581 @@ const unsigned char _Py_M__importlib_bootstrap[] = {
116,104,111,100,32,105,115,32,100,101,112,114,101,99,97,116,
101,100,46,32,32,85,115,101,32,108,111,97,100,101,114,46,
101,120,101,99,95,109,111,100,117,108,101,32,105,110,115,116,
- 101,97,100,46,10,10,32,32,32,32,78,41,5,218,16,115,
- 112,101,99,95,102,114,111,109,95,108,111,97,100,101,114,114,
- 15,0,0,0,218,7,109,111,100,117,108,101,115,218,5,95,
- 101,120,101,99,218,5,95,108,111,97,100,41,4,114,30,0,
- 0,0,114,82,0,0,0,218,4,115,112,101,99,218,6,109,
- 111,100,117,108,101,114,10,0,0,0,114,10,0,0,0,114,
- 11,0,0,0,218,17,95,108,111,97,100,95,109,111,100,117,
- 108,101,95,115,104,105,109,6,1,0,0,115,12,0,0,0,
- 0,6,10,1,10,1,10,1,10,1,10,2,114,98,0,0,
- 0,99,1,0,0,0,0,0,0,0,0,0,0,0,5,0,
- 0,0,8,0,0,0,67,0,0,0,115,210,0,0,0,116,
- 0,124,0,100,1,100,0,131,3,125,1,116,1,124,1,100,
- 2,131,2,114,54,122,12,124,1,160,2,124,0,161,1,87,
- 0,83,0,4,0,116,3,121,52,1,0,1,0,1,0,89,
- 0,110,2,48,0,122,10,124,0,106,4,125,2,87,0,110,
- 18,4,0,116,5,121,82,1,0,1,0,1,0,89,0,110,
- 18,48,0,124,2,100,0,117,1,114,100,116,6,124,2,131,
- 1,83,0,122,10,124,0,106,7,125,3,87,0,110,22,4,
- 0,116,5,121,132,1,0,1,0,1,0,100,3,125,3,89,
- 0,110,2,48,0,122,10,124,0,106,8,125,4,87,0,110,
- 52,4,0,116,5,121,196,1,0,1,0,1,0,124,1,100,
- 0,117,0,114,180,100,4,160,9,124,3,161,1,6,0,89,
- 0,83,0,100,5,160,9,124,3,124,1,161,2,6,0,89,
- 0,83,0,48,0,100,6,160,9,124,3,124,4,161,2,83,
- 0,41,7,78,218,10,95,95,108,111,97,100,101,114,95,95,
- 218,11,109,111,100,117,108,101,95,114,101,112,114,250,1,63,
- 250,13,60,109,111,100,117,108,101,32,123,33,114,125,62,250,
- 20,60,109,111,100,117,108,101,32,123,33,114,125,32,40,123,
- 33,114,125,41,62,250,23,60,109,111,100,117,108,101,32,123,
- 33,114,125,32,102,114,111,109,32,123,33,114,125,62,41,10,
- 114,6,0,0,0,114,4,0,0,0,114,100,0,0,0,218,
- 9,69,120,99,101,112,116,105,111,110,218,8,95,95,115,112,
- 101,99,95,95,218,14,65,116,116,114,105,98,117,116,101,69,
- 114,114,111,114,218,22,95,109,111,100,117,108,101,95,114,101,
- 112,114,95,102,114,111,109,95,115,112,101,99,114,1,0,0,
- 0,218,8,95,95,102,105,108,101,95,95,114,46,0,0,0,
- 41,5,114,97,0,0,0,218,6,108,111,97,100,101,114,114,
- 96,0,0,0,114,17,0,0,0,218,8,102,105,108,101,110,
- 97,109,101,114,10,0,0,0,114,10,0,0,0,114,11,0,
- 0,0,218,12,95,109,111,100,117,108,101,95,114,101,112,114,
- 22,1,0,0,115,46,0,0,0,0,2,12,1,10,4,2,
- 1,12,1,12,1,6,1,2,1,10,1,12,1,6,2,8,
- 1,8,4,2,1,10,1,12,1,10,1,2,1,10,1,12,
- 1,8,1,14,2,18,2,114,112,0,0,0,99,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,
- 0,64,0,0,0,115,114,0,0,0,101,0,90,1,100,0,
- 90,2,100,1,90,3,100,2,100,2,100,2,100,3,156,3,
- 100,4,100,5,132,2,90,4,100,6,100,7,132,0,90,5,
- 100,8,100,9,132,0,90,6,101,7,100,10,100,11,132,0,
- 131,1,90,8,101,8,106,9,100,12,100,11,132,0,131,1,
- 90,8,101,7,100,13,100,14,132,0,131,1,90,10,101,7,
- 100,15,100,16,132,0,131,1,90,11,101,11,106,9,100,17,
- 100,16,132,0,131,1,90,11,100,2,83,0,41,18,218,10,
- 77,111,100,117,108,101,83,112,101,99,97,208,5,0,0,84,
- 104,101,32,115,112,101,99,105,102,105,99,97,116,105,111,110,
- 32,102,111,114,32,97,32,109,111,100,117,108,101,44,32,117,
- 115,101,100,32,102,111,114,32,108,111,97,100,105,110,103,46,
- 10,10,32,32,32,32,65,32,109,111,100,117,108,101,39,115,
- 32,115,112,101,99,32,105,115,32,116,104,101,32,115,111,117,
- 114,99,101,32,102,111,114,32,105,110,102,111,114,109,97,116,
- 105,111,110,32,97,98,111,117,116,32,116,104,101,32,109,111,
- 100,117,108,101,46,32,32,70,111,114,10,32,32,32,32,100,
- 97,116,97,32,97,115,115,111,99,105,97,116,101,100,32,119,
- 105,116,104,32,116,104,101,32,109,111,100,117,108,101,44,32,
- 105,110,99,108,117,100,105,110,103,32,115,111,117,114,99,101,
- 44,32,117,115,101,32,116,104,101,32,115,112,101,99,39,115,
- 10,32,32,32,32,108,111,97,100,101,114,46,10,10,32,32,
- 32,32,96,110,97,109,101,96,32,105,115,32,116,104,101,32,
- 97,98,115,111,108,117,116,101,32,110,97,109,101,32,111,102,
- 32,116,104,101,32,109,111,100,117,108,101,46,32,32,96,108,
- 111,97,100,101,114,96,32,105,115,32,116,104,101,32,108,111,
- 97,100,101,114,10,32,32,32,32,116,111,32,117,115,101,32,
- 119,104,101,110,32,108,111,97,100,105,110,103,32,116,104,101,
- 32,109,111,100,117,108,101,46,32,32,96,112,97,114,101,110,
- 116,96,32,105,115,32,116,104,101,32,110,97,109,101,32,111,
- 102,32,116,104,101,10,32,32,32,32,112,97,99,107,97,103,
- 101,32,116,104,101,32,109,111,100,117,108,101,32,105,115,32,
- 105,110,46,32,32,84,104,101,32,112,97,114,101,110,116,32,
- 105,115,32,100,101,114,105,118,101,100,32,102,114,111,109,32,
- 116,104,101,32,110,97,109,101,46,10,10,32,32,32,32,96,
- 105,115,95,112,97,99,107,97,103,101,96,32,100,101,116,101,
- 114,109,105,110,101,115,32,105,102,32,116,104,101,32,109,111,
- 100,117,108,101,32,105,115,32,99,111,110,115,105,100,101,114,
- 101,100,32,97,32,112,97,99,107,97,103,101,32,111,114,10,
- 32,32,32,32,110,111,116,46,32,32,79,110,32,109,111,100,
- 117,108,101,115,32,116,104,105,115,32,105,115,32,114,101,102,
- 108,101,99,116,101,100,32,98,121,32,116,104,101,32,96,95,
- 95,112,97,116,104,95,95,96,32,97,116,116,114,105,98,117,
- 116,101,46,10,10,32,32,32,32,96,111,114,105,103,105,110,
- 96,32,105,115,32,116,104,101,32,115,112,101,99,105,102,105,
- 99,32,108,111,99,97,116,105,111,110,32,117,115,101,100,32,
- 98,121,32,116,104,101,32,108,111,97,100,101,114,32,102,114,
- 111,109,32,119,104,105,99,104,32,116,111,10,32,32,32,32,
- 108,111,97,100,32,116,104,101,32,109,111,100,117,108,101,44,
- 32,105,102,32,116,104,97,116,32,105,110,102,111,114,109,97,
- 116,105,111,110,32,105,115,32,97,118,97,105,108,97,98,108,
- 101,46,32,32,87,104,101,110,32,102,105,108,101,110,97,109,
- 101,32,105,115,10,32,32,32,32,115,101,116,44,32,111,114,
- 105,103,105,110,32,119,105,108,108,32,109,97,116,99,104,46,
- 10,10,32,32,32,32,96,104,97,115,95,108,111,99,97,116,
- 105,111,110,96,32,105,110,100,105,99,97,116,101,115,32,116,
- 104,97,116,32,97,32,115,112,101,99,39,115,32,34,111,114,
- 105,103,105,110,34,32,114,101,102,108,101,99,116,115,32,97,
- 32,108,111,99,97,116,105,111,110,46,10,32,32,32,32,87,
- 104,101,110,32,116,104,105,115,32,105,115,32,84,114,117,101,
- 44,32,96,95,95,102,105,108,101,95,95,96,32,97,116,116,
- 114,105,98,117,116,101,32,111,102,32,116,104,101,32,109,111,
- 100,117,108,101,32,105,115,32,115,101,116,46,10,10,32,32,
- 32,32,96,99,97,99,104,101,100,96,32,105,115,32,116,104,
- 101,32,108,111,99,97,116,105,111,110,32,111,102,32,116,104,
- 101,32,99,97,99,104,101,100,32,98,121,116,101,99,111,100,
- 101,32,102,105,108,101,44,32,105,102,32,97,110,121,46,32,
- 32,73,116,10,32,32,32,32,99,111,114,114,101,115,112,111,
- 110,100,115,32,116,111,32,116,104,101,32,96,95,95,99,97,
- 99,104,101,100,95,95,96,32,97,116,116,114,105,98,117,116,
- 101,46,10,10,32,32,32,32,96,115,117,98,109,111,100,117,
- 108,101,95,115,101,97,114,99,104,95,108,111,99,97,116,105,
- 111,110,115,96,32,105,115,32,116,104,101,32,115,101,113,117,
- 101,110,99,101,32,111,102,32,112,97,116,104,32,101,110,116,
- 114,105,101,115,32,116,111,10,32,32,32,32,115,101,97,114,
- 99,104,32,119,104,101,110,32,105,109,112,111,114,116,105,110,
- 103,32,115,117,98,109,111,100,117,108,101,115,46,32,32,73,
- 102,32,115,101,116,44,32,105,115,95,112,97,99,107,97,103,
- 101,32,115,104,111,117,108,100,32,98,101,10,32,32,32,32,
- 84,114,117,101,45,45,97,110,100,32,70,97,108,115,101,32,
- 111,116,104,101,114,119,105,115,101,46,10,10,32,32,32,32,
- 80,97,99,107,97,103,101,115,32,97,114,101,32,115,105,109,
- 112,108,121,32,109,111,100,117,108,101,115,32,116,104,97,116,
- 32,40,109,97,121,41,32,104,97,118,101,32,115,117,98,109,
- 111,100,117,108,101,115,46,32,32,73,102,32,97,32,115,112,
- 101,99,10,32,32,32,32,104,97,115,32,97,32,110,111,110,
- 45,78,111,110,101,32,118,97,108,117,101,32,105,110,32,96,
- 115,117,98,109,111,100,117,108,101,95,115,101,97,114,99,104,
- 95,108,111,99,97,116,105,111,110,115,96,44,32,116,104,101,
- 32,105,109,112,111,114,116,10,32,32,32,32,115,121,115,116,
- 101,109,32,119,105,108,108,32,99,111,110,115,105,100,101,114,
- 32,109,111,100,117,108,101,115,32,108,111,97,100,101,100,32,
- 102,114,111,109,32,116,104,101,32,115,112,101,99,32,97,115,
- 32,112,97,99,107,97,103,101,115,46,10,10,32,32,32,32,
- 79,110,108,121,32,102,105,110,100,101,114,115,32,40,115,101,
- 101,32,105,109,112,111,114,116,108,105,98,46,97,98,99,46,
- 77,101,116,97,80,97,116,104,70,105,110,100,101,114,32,97,
- 110,100,10,32,32,32,32,105,109,112,111,114,116,108,105,98,
- 46,97,98,99,46,80,97,116,104,69,110,116,114,121,70,105,
- 110,100,101,114,41,32,115,104,111,117,108,100,32,109,111,100,
- 105,102,121,32,77,111,100,117,108,101,83,112,101,99,32,105,
- 110,115,116,97,110,99,101,115,46,10,10,32,32,32,32,78,
- 41,3,218,6,111,114,105,103,105,110,218,12,108,111,97,100,
- 101,114,95,115,116,97,116,101,218,10,105,115,95,112,97,99,
- 107,97,103,101,99,3,0,0,0,0,0,0,0,3,0,0,
- 0,6,0,0,0,2,0,0,0,67,0,0,0,115,54,0,
- 0,0,124,1,124,0,95,0,124,2,124,0,95,1,124,3,
- 124,0,95,2,124,4,124,0,95,3,124,5,114,32,103,0,
- 110,2,100,0,124,0,95,4,100,1,124,0,95,5,100,0,
- 124,0,95,6,100,0,83,0,41,2,78,70,41,7,114,17,
- 0,0,0,114,110,0,0,0,114,114,0,0,0,114,115,0,
- 0,0,218,26,115,117,98,109,111,100,117,108,101,95,115,101,
- 97,114,99,104,95,108,111,99,97,116,105,111,110,115,218,13,
- 95,115,101,116,95,102,105,108,101,97,116,116,114,218,7,95,
- 99,97,99,104,101,100,41,6,114,30,0,0,0,114,17,0,
- 0,0,114,110,0,0,0,114,114,0,0,0,114,115,0,0,
- 0,114,116,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,114,31,0,0,0,95,1,0,0,115,14,
- 0,0,0,0,2,6,1,6,1,6,1,6,1,14,3,6,
- 1,122,19,77,111,100,117,108,101,83,112,101,99,46,95,95,
- 105,110,105,116,95,95,99,1,0,0,0,0,0,0,0,0,
- 0,0,0,2,0,0,0,6,0,0,0,67,0,0,0,115,
- 102,0,0,0,100,1,160,0,124,0,106,1,161,1,100,2,
- 160,0,124,0,106,2,161,1,103,2,125,1,124,0,106,3,
- 100,0,117,1,114,52,124,1,160,4,100,3,160,0,124,0,
- 106,3,161,1,161,1,1,0,124,0,106,5,100,0,117,1,
- 114,80,124,1,160,4,100,4,160,0,124,0,106,5,161,1,
- 161,1,1,0,100,5,160,0,124,0,106,6,106,7,100,6,
- 160,8,124,1,161,1,161,2,83,0,41,7,78,122,9,110,
- 97,109,101,61,123,33,114,125,122,11,108,111,97,100,101,114,
- 61,123,33,114,125,122,11,111,114,105,103,105,110,61,123,33,
- 114,125,122,29,115,117,98,109,111,100,117,108,101,95,115,101,
- 97,114,99,104,95,108,111,99,97,116,105,111,110,115,61,123,
- 125,122,6,123,125,40,123,125,41,122,2,44,32,41,9,114,
- 46,0,0,0,114,17,0,0,0,114,110,0,0,0,114,114,
- 0,0,0,218,6,97,112,112,101,110,100,114,117,0,0,0,
- 218,9,95,95,99,108,97,115,115,95,95,114,1,0,0,0,
- 218,4,106,111,105,110,41,2,114,30,0,0,0,114,56,0,
- 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
- 0,114,49,0,0,0,107,1,0,0,115,20,0,0,0,0,
- 1,10,1,10,255,4,2,10,1,18,1,10,1,8,1,4,
- 255,6,2,122,19,77,111,100,117,108,101,83,112,101,99,46,
- 95,95,114,101,112,114,95,95,99,2,0,0,0,0,0,0,
- 0,0,0,0,0,3,0,0,0,8,0,0,0,67,0,0,
- 0,115,102,0,0,0,124,0,106,0,125,2,122,72,124,0,
- 106,1,124,1,106,1,107,2,111,76,124,0,106,2,124,1,
- 106,2,107,2,111,76,124,0,106,3,124,1,106,3,107,2,
- 111,76,124,2,124,1,106,0,107,2,111,76,124,0,106,4,
- 124,1,106,4,107,2,111,76,124,0,106,5,124,1,106,5,
- 107,2,87,0,83,0,4,0,116,6,121,100,1,0,1,0,
- 1,0,116,7,6,0,89,0,83,0,48,0,114,13,0,0,
- 0,41,8,114,117,0,0,0,114,17,0,0,0,114,110,0,
- 0,0,114,114,0,0,0,218,6,99,97,99,104,101,100,218,
- 12,104,97,115,95,108,111,99,97,116,105,111,110,114,107,0,
- 0,0,218,14,78,111,116,73,109,112,108,101,109,101,110,116,
- 101,100,41,3,114,30,0,0,0,90,5,111,116,104,101,114,
- 90,4,115,109,115,108,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,218,6,95,95,101,113,95,95,117,1,0,
- 0,115,30,0,0,0,0,1,6,1,2,1,12,1,10,255,
- 2,2,10,254,2,3,8,253,2,4,10,252,2,5,10,251,
- 4,6,12,1,122,17,77,111,100,117,108,101,83,112,101,99,
- 46,95,95,101,113,95,95,99,1,0,0,0,0,0,0,0,
- 0,0,0,0,1,0,0,0,3,0,0,0,67,0,0,0,
- 115,58,0,0,0,124,0,106,0,100,0,117,0,114,52,124,
- 0,106,1,100,0,117,1,114,52,124,0,106,2,114,52,116,
- 3,100,0,117,0,114,38,116,4,130,1,116,3,160,5,124,
- 0,106,1,161,1,124,0,95,0,124,0,106,0,83,0,114,
- 13,0,0,0,41,6,114,119,0,0,0,114,114,0,0,0,
- 114,118,0,0,0,218,19,95,98,111,111,116,115,116,114,97,
- 112,95,101,120,116,101,114,110,97,108,218,19,78,111,116,73,
- 109,112,108,101,109,101,110,116,101,100,69,114,114,111,114,90,
- 11,95,103,101,116,95,99,97,99,104,101,100,114,48,0,0,
- 0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
- 114,123,0,0,0,129,1,0,0,115,12,0,0,0,0,2,
- 10,1,16,1,8,1,4,1,14,1,122,17,77,111,100,117,
- 108,101,83,112,101,99,46,99,97,99,104,101,100,99,2,0,
- 0,0,0,0,0,0,0,0,0,0,2,0,0,0,2,0,
- 0,0,67,0,0,0,115,10,0,0,0,124,1,124,0,95,
- 0,100,0,83,0,114,13,0,0,0,41,1,114,119,0,0,
- 0,41,2,114,30,0,0,0,114,123,0,0,0,114,10,0,
- 0,0,114,10,0,0,0,114,11,0,0,0,114,123,0,0,
- 0,138,1,0,0,115,2,0,0,0,0,2,99,1,0,0,
+ 101,97,100,46,10,10,32,32,32,32,122,103,116,104,101,32,
+ 108,111,97,100,95,109,111,100,117,108,101,40,41,32,109,101,
+ 116,104,111,100,32,105,115,32,100,101,112,114,101,99,97,116,
+ 101,100,32,97,110,100,32,115,108,97,116,101,100,32,102,111,
+ 114,32,114,101,109,111,118,97,108,32,105,110,32,80,121,116,
+ 104,111,110,32,51,46,49,50,59,32,117,115,101,32,101,120,
+ 101,99,95,109,111,100,117,108,101,40,41,32,105,110,115,116,
+ 101,97,100,78,41,8,218,9,95,119,97,114,110,105,110,103,
+ 115,218,4,119,97,114,110,218,18,68,101,112,114,101,99,97,
+ 116,105,111,110,87,97,114,110,105,110,103,218,16,115,112,101,
+ 99,95,102,114,111,109,95,108,111,97,100,101,114,114,18,0,
+ 0,0,218,7,109,111,100,117,108,101,115,218,5,95,101,120,
+ 101,99,218,5,95,108,111,97,100,41,5,114,33,0,0,0,
+ 114,85,0,0,0,218,3,109,115,103,218,4,115,112,101,99,
+ 218,6,109,111,100,117,108,101,114,5,0,0,0,114,5,0,
+ 0,0,114,6,0,0,0,218,17,95,108,111,97,100,95,109,
+ 111,100,117,108,101,95,115,104,105,109,19,1,0,0,115,18,
+ 0,0,0,4,6,12,2,10,1,10,1,10,1,10,1,10,
+ 1,8,2,255,128,114,105,0,0,0,99,1,0,0,0,0,
+ 0,0,0,0,0,0,0,5,0,0,0,8,0,0,0,67,
+ 0,0,0,115,206,0,0,0,116,0,124,0,100,1,100,0,
+ 131,3,125,1,116,1,124,1,100,2,131,2,114,50,122,12,
+ 124,1,160,2,124,0,161,1,87,0,83,0,4,0,116,3,
+ 121,204,1,0,1,0,1,0,89,0,122,10,124,0,106,4,
+ 125,2,87,0,110,16,4,0,116,5,121,202,1,0,1,0,
+ 1,0,89,0,110,16,124,2,100,0,117,1,114,94,116,6,
+ 124,2,131,1,83,0,122,10,124,0,106,7,125,3,87,0,
+ 110,18,4,0,116,5,121,200,1,0,1,0,1,0,100,3,
+ 125,3,89,0,122,10,124,0,106,8,125,4,87,0,110,50,
+ 4,0,116,5,121,198,1,0,1,0,1,0,124,1,100,0,
+ 117,0,114,170,100,4,160,9,124,3,161,1,6,0,89,0,
+ 83,0,100,5,160,9,124,3,124,1,161,2,6,0,89,0,
+ 83,0,100,6,160,9,124,3,124,4,161,2,83,0,119,0,
+ 119,0,119,0,119,0,41,7,78,218,10,95,95,108,111,97,
+ 100,101,114,95,95,218,11,109,111,100,117,108,101,95,114,101,
+ 112,114,250,1,63,250,13,60,109,111,100,117,108,101,32,123,
+ 33,114,125,62,250,20,60,109,111,100,117,108,101,32,123,33,
+ 114,125,32,40,123,33,114,125,41,62,250,23,60,109,111,100,
+ 117,108,101,32,123,33,114,125,32,102,114,111,109,32,123,33,
+ 114,125,62,41,10,114,13,0,0,0,114,11,0,0,0,114,
+ 107,0,0,0,218,9,69,120,99,101,112,116,105,111,110,218,
+ 8,95,95,115,112,101,99,95,95,114,2,0,0,0,218,22,
+ 95,109,111,100,117,108,101,95,114,101,112,114,95,102,114,111,
+ 109,95,115,112,101,99,114,9,0,0,0,218,8,95,95,102,
+ 105,108,101,95,95,114,49,0,0,0,41,5,114,104,0,0,
+ 0,218,6,108,111,97,100,101,114,114,103,0,0,0,114,20,
+ 0,0,0,218,8,102,105,108,101,110,97,109,101,114,5,0,
+ 0,0,114,5,0,0,0,114,6,0,0,0,218,12,95,109,
+ 111,100,117,108,101,95,114,101,112,114,38,1,0,0,115,56,
+ 0,0,0,12,2,10,1,2,4,12,1,12,1,2,1,2,
+ 1,10,1,12,1,4,1,8,2,8,1,2,4,10,1,12,
+ 1,6,1,2,1,10,1,12,1,8,1,14,1,16,2,12,
+ 2,2,250,2,252,2,246,2,252,255,128,114,118,0,0,0,
+ 99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,4,0,0,0,64,0,0,0,115,114,0,0,0,101,0,
+ 90,1,100,0,90,2,100,1,90,3,100,2,100,2,100,2,
+ 100,3,156,3,100,4,100,5,132,2,90,4,100,6,100,7,
+ 132,0,90,5,100,8,100,9,132,0,90,6,101,7,100,10,
+ 100,11,132,0,131,1,90,8,101,8,106,9,100,12,100,11,
+ 132,0,131,1,90,8,101,7,100,13,100,14,132,0,131,1,
+ 90,10,101,7,100,15,100,16,132,0,131,1,90,11,101,11,
+ 106,9,100,17,100,16,132,0,131,1,90,11,100,2,83,0,
+ 41,18,218,10,77,111,100,117,108,101,83,112,101,99,97,208,
+ 5,0,0,84,104,101,32,115,112,101,99,105,102,105,99,97,
+ 116,105,111,110,32,102,111,114,32,97,32,109,111,100,117,108,
+ 101,44,32,117,115,101,100,32,102,111,114,32,108,111,97,100,
+ 105,110,103,46,10,10,32,32,32,32,65,32,109,111,100,117,
+ 108,101,39,115,32,115,112,101,99,32,105,115,32,116,104,101,
+ 32,115,111,117,114,99,101,32,102,111,114,32,105,110,102,111,
+ 114,109,97,116,105,111,110,32,97,98,111,117,116,32,116,104,
+ 101,32,109,111,100,117,108,101,46,32,32,70,111,114,10,32,
+ 32,32,32,100,97,116,97,32,97,115,115,111,99,105,97,116,
+ 101,100,32,119,105,116,104,32,116,104,101,32,109,111,100,117,
+ 108,101,44,32,105,110,99,108,117,100,105,110,103,32,115,111,
+ 117,114,99,101,44,32,117,115,101,32,116,104,101,32,115,112,
+ 101,99,39,115,10,32,32,32,32,108,111,97,100,101,114,46,
+ 10,10,32,32,32,32,96,110,97,109,101,96,32,105,115,32,
+ 116,104,101,32,97,98,115,111,108,117,116,101,32,110,97,109,
+ 101,32,111,102,32,116,104,101,32,109,111,100,117,108,101,46,
+ 32,32,96,108,111,97,100,101,114,96,32,105,115,32,116,104,
+ 101,32,108,111,97,100,101,114,10,32,32,32,32,116,111,32,
+ 117,115,101,32,119,104,101,110,32,108,111,97,100,105,110,103,
+ 32,116,104,101,32,109,111,100,117,108,101,46,32,32,96,112,
+ 97,114,101,110,116,96,32,105,115,32,116,104,101,32,110,97,
+ 109,101,32,111,102,32,116,104,101,10,32,32,32,32,112,97,
+ 99,107,97,103,101,32,116,104,101,32,109,111,100,117,108,101,
+ 32,105,115,32,105,110,46,32,32,84,104,101,32,112,97,114,
+ 101,110,116,32,105,115,32,100,101,114,105,118,101,100,32,102,
+ 114,111,109,32,116,104,101,32,110,97,109,101,46,10,10,32,
+ 32,32,32,96,105,115,95,112,97,99,107,97,103,101,96,32,
+ 100,101,116,101,114,109,105,110,101,115,32,105,102,32,116,104,
+ 101,32,109,111,100,117,108,101,32,105,115,32,99,111,110,115,
+ 105,100,101,114,101,100,32,97,32,112,97,99,107,97,103,101,
+ 32,111,114,10,32,32,32,32,110,111,116,46,32,32,79,110,
+ 32,109,111,100,117,108,101,115,32,116,104,105,115,32,105,115,
+ 32,114,101,102,108,101,99,116,101,100,32,98,121,32,116,104,
+ 101,32,96,95,95,112,97,116,104,95,95,96,32,97,116,116,
+ 114,105,98,117,116,101,46,10,10,32,32,32,32,96,111,114,
+ 105,103,105,110,96,32,105,115,32,116,104,101,32,115,112,101,
+ 99,105,102,105,99,32,108,111,99,97,116,105,111,110,32,117,
+ 115,101,100,32,98,121,32,116,104,101,32,108,111,97,100,101,
+ 114,32,102,114,111,109,32,119,104,105,99,104,32,116,111,10,
+ 32,32,32,32,108,111,97,100,32,116,104,101,32,109,111,100,
+ 117,108,101,44,32,105,102,32,116,104,97,116,32,105,110,102,
+ 111,114,109,97,116,105,111,110,32,105,115,32,97,118,97,105,
+ 108,97,98,108,101,46,32,32,87,104,101,110,32,102,105,108,
+ 101,110,97,109,101,32,105,115,10,32,32,32,32,115,101,116,
+ 44,32,111,114,105,103,105,110,32,119,105,108,108,32,109,97,
+ 116,99,104,46,10,10,32,32,32,32,96,104,97,115,95,108,
+ 111,99,97,116,105,111,110,96,32,105,110,100,105,99,97,116,
+ 101,115,32,116,104,97,116,32,97,32,115,112,101,99,39,115,
+ 32,34,111,114,105,103,105,110,34,32,114,101,102,108,101,99,
+ 116,115,32,97,32,108,111,99,97,116,105,111,110,46,10,32,
+ 32,32,32,87,104,101,110,32,116,104,105,115,32,105,115,32,
+ 84,114,117,101,44,32,96,95,95,102,105,108,101,95,95,96,
+ 32,97,116,116,114,105,98,117,116,101,32,111,102,32,116,104,
+ 101,32,109,111,100,117,108,101,32,105,115,32,115,101,116,46,
+ 10,10,32,32,32,32,96,99,97,99,104,101,100,96,32,105,
+ 115,32,116,104,101,32,108,111,99,97,116,105,111,110,32,111,
+ 102,32,116,104,101,32,99,97,99,104,101,100,32,98,121,116,
+ 101,99,111,100,101,32,102,105,108,101,44,32,105,102,32,97,
+ 110,121,46,32,32,73,116,10,32,32,32,32,99,111,114,114,
+ 101,115,112,111,110,100,115,32,116,111,32,116,104,101,32,96,
+ 95,95,99,97,99,104,101,100,95,95,96,32,97,116,116,114,
+ 105,98,117,116,101,46,10,10,32,32,32,32,96,115,117,98,
+ 109,111,100,117,108,101,95,115,101,97,114,99,104,95,108,111,
+ 99,97,116,105,111,110,115,96,32,105,115,32,116,104,101,32,
+ 115,101,113,117,101,110,99,101,32,111,102,32,112,97,116,104,
+ 32,101,110,116,114,105,101,115,32,116,111,10,32,32,32,32,
+ 115,101,97,114,99,104,32,119,104,101,110,32,105,109,112,111,
+ 114,116,105,110,103,32,115,117,98,109,111,100,117,108,101,115,
+ 46,32,32,73,102,32,115,101,116,44,32,105,115,95,112,97,
+ 99,107,97,103,101,32,115,104,111,117,108,100,32,98,101,10,
+ 32,32,32,32,84,114,117,101,45,45,97,110,100,32,70,97,
+ 108,115,101,32,111,116,104,101,114,119,105,115,101,46,10,10,
+ 32,32,32,32,80,97,99,107,97,103,101,115,32,97,114,101,
+ 32,115,105,109,112,108,121,32,109,111,100,117,108,101,115,32,
+ 116,104,97,116,32,40,109,97,121,41,32,104,97,118,101,32,
+ 115,117,98,109,111,100,117,108,101,115,46,32,32,73,102,32,
+ 97,32,115,112,101,99,10,32,32,32,32,104,97,115,32,97,
+ 32,110,111,110,45,78,111,110,101,32,118,97,108,117,101,32,
+ 105,110,32,96,115,117,98,109,111,100,117,108,101,95,115,101,
+ 97,114,99,104,95,108,111,99,97,116,105,111,110,115,96,44,
+ 32,116,104,101,32,105,109,112,111,114,116,10,32,32,32,32,
+ 115,121,115,116,101,109,32,119,105,108,108,32,99,111,110,115,
+ 105,100,101,114,32,109,111,100,117,108,101,115,32,108,111,97,
+ 100,101,100,32,102,114,111,109,32,116,104,101,32,115,112,101,
+ 99,32,97,115,32,112,97,99,107,97,103,101,115,46,10,10,
+ 32,32,32,32,79,110,108,121,32,102,105,110,100,101,114,115,
+ 32,40,115,101,101,32,105,109,112,111,114,116,108,105,98,46,
+ 97,98,99,46,77,101,116,97,80,97,116,104,70,105,110,100,
+ 101,114,32,97,110,100,10,32,32,32,32,105,109,112,111,114,
+ 116,108,105,98,46,97,98,99,46,80,97,116,104,69,110,116,
+ 114,121,70,105,110,100,101,114,41,32,115,104,111,117,108,100,
+ 32,109,111,100,105,102,121,32,77,111,100,117,108,101,83,112,
+ 101,99,32,105,110,115,116,97,110,99,101,115,46,10,10,32,
+ 32,32,32,78,41,3,218,6,111,114,105,103,105,110,218,12,
+ 108,111,97,100,101,114,95,115,116,97,116,101,218,10,105,115,
+ 95,112,97,99,107,97,103,101,99,3,0,0,0,0,0,0,
+ 0,3,0,0,0,6,0,0,0,2,0,0,0,67,0,0,
+ 0,115,54,0,0,0,124,1,124,0,95,0,124,2,124,0,
+ 95,1,124,3,124,0,95,2,124,4,124,0,95,3,124,5,
+ 114,32,103,0,110,2,100,0,124,0,95,4,100,1,124,0,
+ 95,5,100,0,124,0,95,6,100,0,83,0,41,2,78,70,
+ 41,7,114,20,0,0,0,114,116,0,0,0,114,120,0,0,
+ 0,114,121,0,0,0,218,26,115,117,98,109,111,100,117,108,
+ 101,95,115,101,97,114,99,104,95,108,111,99,97,116,105,111,
+ 110,115,218,13,95,115,101,116,95,102,105,108,101,97,116,116,
+ 114,218,7,95,99,97,99,104,101,100,41,6,114,33,0,0,
+ 0,114,20,0,0,0,114,116,0,0,0,114,120,0,0,0,
+ 114,121,0,0,0,114,122,0,0,0,114,5,0,0,0,114,
+ 5,0,0,0,114,6,0,0,0,114,34,0,0,0,111,1,
+ 0,0,115,16,0,0,0,6,2,6,1,6,1,6,1,14,
+ 1,6,3,10,1,255,128,122,19,77,111,100,117,108,101,83,
+ 112,101,99,46,95,95,105,110,105,116,95,95,99,1,0,0,
+ 0,0,0,0,0,0,0,0,0,2,0,0,0,6,0,0,
+ 0,67,0,0,0,115,102,0,0,0,100,1,160,0,124,0,
+ 106,1,161,1,100,2,160,0,124,0,106,2,161,1,103,2,
+ 125,1,124,0,106,3,100,0,117,1,114,52,124,1,160,4,
+ 100,3,160,0,124,0,106,3,161,1,161,1,1,0,124,0,
+ 106,5,100,0,117,1,114,80,124,1,160,4,100,4,160,0,
+ 124,0,106,5,161,1,161,1,1,0,100,5,160,0,124,0,
+ 106,6,106,7,100,6,160,8,124,1,161,1,161,2,83,0,
+ 41,7,78,122,9,110,97,109,101,61,123,33,114,125,122,11,
+ 108,111,97,100,101,114,61,123,33,114,125,122,11,111,114,105,
+ 103,105,110,61,123,33,114,125,122,29,115,117,98,109,111,100,
+ 117,108,101,95,115,101,97,114,99,104,95,108,111,99,97,116,
+ 105,111,110,115,61,123,125,122,6,123,125,40,123,125,41,122,
+ 2,44,32,41,9,114,49,0,0,0,114,20,0,0,0,114,
+ 116,0,0,0,114,120,0,0,0,218,6,97,112,112,101,110,
+ 100,114,123,0,0,0,218,9,95,95,99,108,97,115,115,95,
+ 95,114,9,0,0,0,218,4,106,111,105,110,41,2,114,33,
+ 0,0,0,114,59,0,0,0,114,5,0,0,0,114,5,0,
+ 0,0,114,6,0,0,0,114,52,0,0,0,123,1,0,0,
+ 115,22,0,0,0,10,1,10,1,4,255,10,2,18,1,10,
+ 1,8,1,4,1,6,255,22,2,255,128,122,19,77,111,100,
+ 117,108,101,83,112,101,99,46,95,95,114,101,112,114,95,95,
+ 99,2,0,0,0,0,0,0,0,0,0,0,0,3,0,0,
+ 0,8,0,0,0,67,0,0,0,115,102,0,0,0,124,0,
+ 106,0,125,2,122,72,124,0,106,1,124,1,106,1,107,2,
+ 111,76,124,0,106,2,124,1,106,2,107,2,111,76,124,0,
+ 106,3,124,1,106,3,107,2,111,76,124,2,124,1,106,0,
+ 107,2,111,76,124,0,106,4,124,1,106,4,107,2,111,76,
+ 124,0,106,5,124,1,106,5,107,2,87,0,83,0,4,0,
+ 116,6,121,100,1,0,1,0,1,0,116,7,6,0,89,0,
+ 83,0,119,0,114,0,0,0,0,41,8,114,123,0,0,0,
+ 114,20,0,0,0,114,116,0,0,0,114,120,0,0,0,218,
+ 6,99,97,99,104,101,100,218,12,104,97,115,95,108,111,99,
+ 97,116,105,111,110,114,2,0,0,0,218,14,78,111,116,73,
+ 109,112,108,101,109,101,110,116,101,100,41,3,114,33,0,0,
+ 0,90,5,111,116,104,101,114,90,4,115,109,115,108,114,5,
+ 0,0,0,114,5,0,0,0,114,6,0,0,0,218,6,95,
+ 95,101,113,95,95,133,1,0,0,115,34,0,0,0,6,1,
+ 2,1,12,1,10,1,2,255,10,2,2,254,8,3,2,253,
+ 10,4,2,252,10,5,4,251,12,6,8,1,2,255,255,128,
+ 122,17,77,111,100,117,108,101,83,112,101,99,46,95,95,101,
+ 113,95,95,99,1,0,0,0,0,0,0,0,0,0,0,0,
+ 1,0,0,0,3,0,0,0,67,0,0,0,115,58,0,0,
+ 0,124,0,106,0,100,0,117,0,114,52,124,0,106,1,100,
+ 0,117,1,114,52,124,0,106,2,114,52,116,3,100,0,117,
+ 0,114,38,116,4,130,1,116,3,160,5,124,0,106,1,161,
+ 1,124,0,95,0,124,0,106,0,83,0,114,0,0,0,0,
+ 41,6,114,125,0,0,0,114,120,0,0,0,114,124,0,0,
+ 0,218,19,95,98,111,111,116,115,116,114,97,112,95,101,120,
+ 116,101,114,110,97,108,218,19,78,111,116,73,109,112,108,101,
+ 109,101,110,116,101,100,69,114,114,111,114,90,11,95,103,101,
+ 116,95,99,97,99,104,101,100,114,51,0,0,0,114,5,0,
+ 0,0,114,5,0,0,0,114,6,0,0,0,114,129,0,0,
+ 0,145,1,0,0,115,14,0,0,0,10,2,16,1,8,1,
+ 4,1,14,1,6,1,255,128,122,17,77,111,100,117,108,101,
+ 83,112,101,99,46,99,97,99,104,101,100,99,2,0,0,0,
+ 0,0,0,0,0,0,0,0,2,0,0,0,2,0,0,0,
+ 67,0,0,0,115,10,0,0,0,124,1,124,0,95,0,100,
+ 0,83,0,114,0,0,0,0,41,1,114,125,0,0,0,41,
+ 2,114,33,0,0,0,114,129,0,0,0,114,5,0,0,0,
+ 114,5,0,0,0,114,6,0,0,0,114,129,0,0,0,154,
+ 1,0,0,115,4,0,0,0,10,2,255,128,99,1,0,0,
0,0,0,0,0,0,0,0,0,1,0,0,0,3,0,0,
0,67,0,0,0,115,32,0,0,0,124,0,106,0,100,1,
117,0,114,26,124,0,106,1,160,2,100,2,161,1,100,3,
25,0,83,0,124,0,106,1,83,0,41,4,122,32,84,104,
101,32,110,97,109,101,32,111,102,32,116,104,101,32,109,111,
100,117,108,101,39,115,32,112,97,114,101,110,116,46,78,218,
- 1,46,114,22,0,0,0,41,3,114,117,0,0,0,114,17,
+ 1,46,114,25,0,0,0,41,3,114,123,0,0,0,114,20,
0,0,0,218,10,114,112,97,114,116,105,116,105,111,110,114,
- 48,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
- 0,0,0,218,6,112,97,114,101,110,116,142,1,0,0,115,
- 6,0,0,0,0,3,10,1,16,2,122,17,77,111,100,117,
- 108,101,83,112,101,99,46,112,97,114,101,110,116,99,1,0,
- 0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,
- 0,0,67,0,0,0,115,6,0,0,0,124,0,106,0,83,
- 0,114,13,0,0,0,41,1,114,118,0,0,0,114,48,0,
- 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
- 0,114,124,0,0,0,150,1,0,0,115,2,0,0,0,0,
- 2,122,23,77,111,100,117,108,101,83,112,101,99,46,104,97,
- 115,95,108,111,99,97,116,105,111,110,99,2,0,0,0,0,
- 0,0,0,0,0,0,0,2,0,0,0,2,0,0,0,67,
- 0,0,0,115,14,0,0,0,116,0,124,1,131,1,124,0,
- 95,1,100,0,83,0,114,13,0,0,0,41,2,218,4,98,
- 111,111,108,114,118,0,0,0,41,2,114,30,0,0,0,218,
- 5,118,97,108,117,101,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,114,124,0,0,0,154,1,0,0,115,2,
- 0,0,0,0,2,41,12,114,1,0,0,0,114,0,0,0,
- 0,114,2,0,0,0,114,3,0,0,0,114,31,0,0,0,
- 114,49,0,0,0,114,126,0,0,0,218,8,112,114,111,112,
- 101,114,116,121,114,123,0,0,0,218,6,115,101,116,116,101,
- 114,114,131,0,0,0,114,124,0,0,0,114,10,0,0,0,
- 114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,114,
- 113,0,0,0,58,1,0,0,115,32,0,0,0,8,1,4,
- 36,4,1,2,255,12,12,8,10,8,12,2,1,10,8,4,
- 1,10,3,2,1,10,7,2,1,10,3,4,1,114,113,0,
- 0,0,169,2,114,114,0,0,0,114,116,0,0,0,99,2,
- 0,0,0,0,0,0,0,2,0,0,0,6,0,0,0,8,
- 0,0,0,67,0,0,0,115,150,0,0,0,116,0,124,1,
- 100,1,131,2,114,74,116,1,100,2,117,0,114,22,116,2,
- 130,1,116,1,106,3,125,4,124,3,100,2,117,0,114,48,
- 124,4,124,0,124,1,100,3,141,2,83,0,124,3,114,56,
- 103,0,110,2,100,2,125,5,124,4,124,0,124,1,124,5,
- 100,4,141,3,83,0,124,3,100,2,117,0,114,134,116,0,
- 124,1,100,5,131,2,114,130,122,14,124,1,160,4,124,0,
- 161,1,125,3,87,0,110,26,4,0,116,5,121,128,1,0,
- 1,0,1,0,100,2,125,3,89,0,110,6,48,0,100,6,
- 125,3,116,6,124,0,124,1,124,2,124,3,100,7,141,4,
- 83,0,41,8,122,53,82,101,116,117,114,110,32,97,32,109,
- 111,100,117,108,101,32,115,112,101,99,32,98,97,115,101,100,
- 32,111,110,32,118,97,114,105,111,117,115,32,108,111,97,100,
- 101,114,32,109,101,116,104,111,100,115,46,90,12,103,101,116,
- 95,102,105,108,101,110,97,109,101,78,41,1,114,110,0,0,
- 0,41,2,114,110,0,0,0,114,117,0,0,0,114,116,0,
- 0,0,70,114,136,0,0,0,41,7,114,4,0,0,0,114,
- 127,0,0,0,114,128,0,0,0,218,23,115,112,101,99,95,
- 102,114,111,109,95,102,105,108,101,95,108,111,99,97,116,105,
- 111,110,114,116,0,0,0,114,80,0,0,0,114,113,0,0,
- 0,41,6,114,17,0,0,0,114,110,0,0,0,114,114,0,
- 0,0,114,116,0,0,0,114,137,0,0,0,90,6,115,101,
- 97,114,99,104,114,10,0,0,0,114,10,0,0,0,114,11,
- 0,0,0,114,92,0,0,0,159,1,0,0,115,36,0,0,
- 0,0,2,10,1,8,1,4,1,6,2,8,1,12,1,12,
- 1,6,1,2,255,6,3,8,1,10,1,2,1,14,1,12,
- 1,10,3,4,2,114,92,0,0,0,99,3,0,0,0,0,
- 0,0,0,0,0,0,0,8,0,0,0,8,0,0,0,67,
- 0,0,0,115,40,1,0,0,122,10,124,0,106,0,125,3,
- 87,0,110,18,4,0,116,1,121,28,1,0,1,0,1,0,
- 89,0,110,14,48,0,124,3,100,0,117,1,114,42,124,3,
- 83,0,124,0,106,2,125,4,124,1,100,0,117,0,114,86,
- 122,10,124,0,106,3,125,1,87,0,110,18,4,0,116,1,
- 121,84,1,0,1,0,1,0,89,0,110,2,48,0,122,10,
- 124,0,106,4,125,5,87,0,110,22,4,0,116,1,121,118,
- 1,0,1,0,1,0,100,0,125,5,89,0,110,2,48,0,
- 124,2,100,0,117,0,114,174,124,5,100,0,117,0,114,170,
- 122,10,124,1,106,5,125,2,87,0,110,26,4,0,116,1,
- 121,168,1,0,1,0,1,0,100,0,125,2,89,0,110,6,
- 48,0,124,5,125,2,122,10,124,0,106,6,125,6,87,0,
- 110,22,4,0,116,1,121,206,1,0,1,0,1,0,100,0,
- 125,6,89,0,110,2,48,0,122,14,116,7,124,0,106,8,
- 131,1,125,7,87,0,110,22,4,0,116,1,121,244,1,0,
- 1,0,1,0,100,0,125,7,89,0,110,2,48,0,116,9,
- 124,4,124,1,124,2,100,1,141,3,125,3,124,5,100,0,
- 117,0,144,1,114,18,100,2,110,2,100,3,124,3,95,10,
- 124,6,124,3,95,11,124,7,124,3,95,12,124,3,83,0,
- 41,4,78,169,1,114,114,0,0,0,70,84,41,13,114,106,
- 0,0,0,114,107,0,0,0,114,1,0,0,0,114,99,0,
- 0,0,114,109,0,0,0,218,7,95,79,82,73,71,73,78,
- 218,10,95,95,99,97,99,104,101,100,95,95,218,4,108,105,
- 115,116,218,8,95,95,112,97,116,104,95,95,114,113,0,0,
- 0,114,118,0,0,0,114,123,0,0,0,114,117,0,0,0,
- 41,8,114,97,0,0,0,114,110,0,0,0,114,114,0,0,
- 0,114,96,0,0,0,114,17,0,0,0,90,8,108,111,99,
- 97,116,105,111,110,114,123,0,0,0,114,117,0,0,0,114,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,17,
- 95,115,112,101,99,95,102,114,111,109,95,109,111,100,117,108,
- 101,185,1,0,0,115,72,0,0,0,0,2,2,1,10,1,
- 12,1,6,2,8,1,4,2,6,1,8,1,2,1,10,1,
- 12,2,6,1,2,1,10,1,12,1,10,1,8,1,8,1,
- 2,1,10,1,12,1,10,2,4,1,2,1,10,1,12,1,
- 10,1,2,1,14,1,12,1,10,2,14,1,20,1,6,1,
- 6,1,114,143,0,0,0,70,169,1,218,8,111,118,101,114,
+ 51,0,0,0,114,5,0,0,0,114,5,0,0,0,114,6,
+ 0,0,0,218,6,112,97,114,101,110,116,158,1,0,0,115,
+ 8,0,0,0,10,3,16,1,6,2,255,128,122,17,77,111,
+ 100,117,108,101,83,112,101,99,46,112,97,114,101,110,116,99,
+ 1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,
+ 1,0,0,0,67,0,0,0,115,6,0,0,0,124,0,106,
+ 0,83,0,114,0,0,0,0,41,1,114,124,0,0,0,114,
+ 51,0,0,0,114,5,0,0,0,114,5,0,0,0,114,6,
+ 0,0,0,114,130,0,0,0,166,1,0,0,115,4,0,0,
+ 0,6,2,255,128,122,23,77,111,100,117,108,101,83,112,101,
+ 99,46,104,97,115,95,108,111,99,97,116,105,111,110,99,2,
+ 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,2,
+ 0,0,0,67,0,0,0,115,14,0,0,0,116,0,124,1,
+ 131,1,124,0,95,1,100,0,83,0,114,0,0,0,0,41,
+ 2,218,4,98,111,111,108,114,124,0,0,0,41,2,114,33,
+ 0,0,0,218,5,118,97,108,117,101,114,5,0,0,0,114,
+ 5,0,0,0,114,6,0,0,0,114,130,0,0,0,170,1,
+ 0,0,115,4,0,0,0,14,2,255,128,41,12,114,9,0,
+ 0,0,114,8,0,0,0,114,1,0,0,0,114,10,0,0,
+ 0,114,34,0,0,0,114,52,0,0,0,114,132,0,0,0,
+ 218,8,112,114,111,112,101,114,116,121,114,129,0,0,0,218,
+ 6,115,101,116,116,101,114,114,137,0,0,0,114,130,0,0,
+ 0,114,5,0,0,0,114,5,0,0,0,114,5,0,0,0,
+ 114,6,0,0,0,114,119,0,0,0,74,1,0,0,115,36,
+ 0,0,0,8,0,4,1,4,36,2,1,12,255,8,12,8,
+ 10,2,12,10,1,4,8,10,1,2,3,10,1,2,7,10,
+ 1,4,3,14,1,255,128,114,119,0,0,0,169,2,114,120,
+ 0,0,0,114,122,0,0,0,99,2,0,0,0,0,0,0,
+ 0,2,0,0,0,6,0,0,0,8,0,0,0,67,0,0,
+ 0,115,150,0,0,0,116,0,124,1,100,1,131,2,114,74,
+ 116,1,100,2,117,0,114,22,116,2,130,1,116,1,106,3,
+ 125,4,124,3,100,2,117,0,114,48,124,4,124,0,124,1,
+ 100,3,141,2,83,0,124,3,114,56,103,0,110,2,100,2,
+ 125,5,124,4,124,0,124,1,124,5,100,4,141,3,83,0,
+ 124,3,100,2,117,0,114,132,116,0,124,1,100,5,131,2,
+ 114,128,122,14,124,1,160,4,124,0,161,1,125,3,87,0,
+ 110,24,4,0,116,5,121,148,1,0,1,0,1,0,100,2,
+ 125,3,89,0,110,4,100,6,125,3,116,6,124,0,124,1,
+ 124,2,124,3,100,7,141,4,83,0,119,0,41,8,122,53,
+ 82,101,116,117,114,110,32,97,32,109,111,100,117,108,101,32,
+ 115,112,101,99,32,98,97,115,101,100,32,111,110,32,118,97,
+ 114,105,111,117,115,32,108,111,97,100,101,114,32,109,101,116,
+ 104,111,100,115,46,90,12,103,101,116,95,102,105,108,101,110,
+ 97,109,101,78,41,1,114,116,0,0,0,41,2,114,116,0,
+ 0,0,114,123,0,0,0,114,122,0,0,0,70,114,142,0,
+ 0,0,41,7,114,11,0,0,0,114,133,0,0,0,114,134,
+ 0,0,0,218,23,115,112,101,99,95,102,114,111,109,95,102,
+ 105,108,101,95,108,111,99,97,116,105,111,110,114,122,0,0,
+ 0,114,83,0,0,0,114,119,0,0,0,41,6,114,20,0,
+ 0,0,114,116,0,0,0,114,120,0,0,0,114,122,0,0,
+ 0,114,143,0,0,0,90,6,115,101,97,114,99,104,114,5,
+ 0,0,0,114,5,0,0,0,114,6,0,0,0,114,98,0,
+ 0,0,175,1,0,0,115,40,0,0,0,10,2,8,1,4,
+ 1,6,1,8,2,12,1,12,1,6,1,2,1,6,255,8,
+ 3,10,1,2,1,14,1,12,1,8,1,4,3,16,2,2,
+ 250,255,128,114,98,0,0,0,99,3,0,0,0,0,0,0,
+ 0,0,0,0,0,8,0,0,0,8,0,0,0,67,0,0,
+ 0,115,44,1,0,0,122,10,124,0,106,0,125,3,87,0,
+ 110,18,4,0,116,1,144,1,121,42,1,0,1,0,1,0,
+ 89,0,110,12,124,3,100,0,117,1,114,42,124,3,83,0,
+ 124,0,106,2,125,4,124,1,100,0,117,0,114,84,122,10,
+ 124,0,106,3,125,1,87,0,110,16,4,0,116,1,144,1,
+ 121,40,1,0,1,0,1,0,89,0,122,10,124,0,106,4,
+ 125,5,87,0,110,20,4,0,116,1,144,1,121,38,1,0,
+ 1,0,1,0,100,0,125,5,89,0,124,2,100,0,117,0,
+ 114,170,124,5,100,0,117,0,114,166,122,10,124,1,106,5,
+ 125,2,87,0,110,26,4,0,116,1,144,1,121,36,1,0,
+ 1,0,1,0,100,0,125,2,89,0,110,4,124,5,125,2,
+ 122,10,124,0,106,6,125,6,87,0,110,20,4,0,116,1,
+ 144,1,121,34,1,0,1,0,1,0,100,0,125,6,89,0,
+ 122,14,116,7,124,0,106,8,131,1,125,7,87,0,110,20,
+ 4,0,116,1,144,1,121,32,1,0,1,0,1,0,100,0,
+ 125,7,89,0,116,9,124,4,124,1,124,2,100,1,141,3,
+ 125,3,124,5,100,0,117,0,144,1,114,10,100,2,110,2,
+ 100,3,124,3,95,10,124,6,124,3,95,11,124,7,124,3,
+ 95,12,124,3,83,0,119,0,119,0,119,0,119,0,119,0,
+ 119,0,41,4,78,169,1,114,120,0,0,0,70,84,41,13,
+ 114,113,0,0,0,114,2,0,0,0,114,9,0,0,0,114,
+ 106,0,0,0,114,115,0,0,0,218,7,95,79,82,73,71,
+ 73,78,218,10,95,95,99,97,99,104,101,100,95,95,218,4,
+ 108,105,115,116,218,8,95,95,112,97,116,104,95,95,114,119,
+ 0,0,0,114,124,0,0,0,114,129,0,0,0,114,123,0,
+ 0,0,41,8,114,104,0,0,0,114,116,0,0,0,114,120,
+ 0,0,0,114,103,0,0,0,114,20,0,0,0,90,8,108,
+ 111,99,97,116,105,111,110,114,129,0,0,0,114,123,0,0,
+ 0,114,5,0,0,0,114,5,0,0,0,114,6,0,0,0,
+ 218,17,95,115,112,101,99,95,102,114,111,109,95,109,111,100,
+ 117,108,101,201,1,0,0,115,86,0,0,0,2,2,10,1,
+ 14,1,4,1,8,2,4,1,6,2,8,1,2,1,10,1,
+ 14,1,2,2,2,1,10,1,14,1,6,1,8,1,8,1,
+ 2,1,10,1,14,1,8,1,4,2,2,1,10,1,14,1,
+ 6,1,2,1,14,1,14,1,6,1,14,2,20,1,6,1,
+ 6,1,4,1,2,249,2,252,2,250,2,250,2,251,2,246,
+ 255,128,114,149,0,0,0,70,169,1,218,8,111,118,101,114,
114,105,100,101,99,2,0,0,0,0,0,0,0,1,0,0,
0,5,0,0,0,8,0,0,0,67,0,0,0,115,210,1,
0,0,124,2,115,20,116,0,124,1,100,1,100,0,131,3,
- 100,0,117,0,114,52,122,12,124,0,106,1,124,1,95,2,
- 87,0,110,18,4,0,116,3,121,50,1,0,1,0,1,0,
- 89,0,110,2,48,0,124,2,115,72,116,0,124,1,100,2,
- 100,0,131,3,100,0,117,0,114,174,124,0,106,4,125,3,
- 124,3,100,0,117,0,114,144,124,0,106,5,100,0,117,1,
- 114,144,116,6,100,0,117,0,114,108,116,7,130,1,116,6,
- 106,8,125,4,124,4,160,9,124,4,161,1,125,3,124,0,
- 106,5,124,3,95,10,124,3,124,0,95,4,100,0,124,1,
- 95,11,122,10,124,3,124,1,95,12,87,0,110,18,4,0,
- 116,3,121,172,1,0,1,0,1,0,89,0,110,2,48,0,
- 124,2,115,194,116,0,124,1,100,3,100,0,131,3,100,0,
- 117,0,114,226,122,12,124,0,106,13,124,1,95,14,87,0,
- 110,18,4,0,116,3,121,224,1,0,1,0,1,0,89,0,
- 110,2,48,0,122,10,124,0,124,1,95,15,87,0,110,18,
- 4,0,116,3,121,254,1,0,1,0,1,0,89,0,110,2,
- 48,0,124,2,144,1,115,24,116,0,124,1,100,4,100,0,
- 131,3,100,0,117,0,144,1,114,70,124,0,106,5,100,0,
- 117,1,144,1,114,70,122,12,124,0,106,5,124,1,95,16,
- 87,0,110,20,4,0,116,3,144,1,121,68,1,0,1,0,
- 1,0,89,0,110,2,48,0,124,0,106,17,144,1,114,206,
- 124,2,144,1,115,102,116,0,124,1,100,5,100,0,131,3,
- 100,0,117,0,144,1,114,136,122,12,124,0,106,18,124,1,
- 95,11,87,0,110,20,4,0,116,3,144,1,121,134,1,0,
- 1,0,1,0,89,0,110,2,48,0,124,2,144,1,115,160,
+ 100,0,117,0,114,50,122,12,124,0,106,1,124,1,95,2,
+ 87,0,110,16,4,0,116,3,144,1,121,208,1,0,1,0,
+ 1,0,89,0,124,2,115,70,116,0,124,1,100,2,100,0,
+ 131,3,100,0,117,0,114,170,124,0,106,4,125,3,124,3,
+ 100,0,117,0,114,142,124,0,106,5,100,0,117,1,114,142,
+ 116,6,100,0,117,0,114,106,116,7,130,1,116,6,106,8,
+ 125,4,124,4,160,9,124,4,161,1,125,3,124,0,106,5,
+ 124,3,95,10,124,3,124,0,95,4,100,0,124,1,95,11,
+ 122,10,124,3,124,1,95,12,87,0,110,16,4,0,116,3,
+ 144,1,121,206,1,0,1,0,1,0,89,0,124,2,115,190,
+ 116,0,124,1,100,3,100,0,131,3,100,0,117,0,114,220,
+ 122,12,124,0,106,13,124,1,95,14,87,0,110,16,4,0,
+ 116,3,144,1,121,204,1,0,1,0,1,0,89,0,122,10,
+ 124,0,124,1,95,15,87,0,110,16,4,0,116,3,144,1,
+ 121,202,1,0,1,0,1,0,89,0,124,2,144,1,115,16,
+ 116,0,124,1,100,4,100,0,131,3,100,0,117,0,144,1,
+ 114,58,124,0,106,5,100,0,117,1,144,1,114,58,122,12,
+ 124,0,106,5,124,1,95,16,87,0,110,16,4,0,116,3,
+ 144,1,121,200,1,0,1,0,1,0,89,0,124,0,106,17,
+ 144,1,114,192,124,2,144,1,115,90,116,0,124,1,100,5,
+ 100,0,131,3,100,0,117,0,144,1,114,120,122,12,124,0,
+ 106,18,124,1,95,11,87,0,110,16,4,0,116,3,144,1,
+ 121,198,1,0,1,0,1,0,89,0,124,2,144,1,115,144,
116,0,124,1,100,6,100,0,131,3,100,0,117,0,144,1,
- 114,206,124,0,106,19,100,0,117,1,144,1,114,206,122,12,
- 124,0,106,19,124,1,95,20,87,0,110,20,4,0,116,3,
- 144,1,121,204,1,0,1,0,1,0,89,0,110,2,48,0,
- 124,1,83,0,41,7,78,114,1,0,0,0,114,99,0,0,
- 0,218,11,95,95,112,97,99,107,97,103,101,95,95,114,142,
- 0,0,0,114,109,0,0,0,114,140,0,0,0,41,21,114,
- 6,0,0,0,114,17,0,0,0,114,1,0,0,0,114,107,
- 0,0,0,114,110,0,0,0,114,117,0,0,0,114,127,0,
- 0,0,114,128,0,0,0,218,16,95,78,97,109,101,115,112,
+ 114,192,124,0,106,19,100,0,117,1,144,1,114,192,122,14,
+ 124,0,106,19,124,1,95,20,87,0,124,1,83,0,4,0,
+ 116,3,144,1,121,196,1,0,1,0,1,0,89,0,124,1,
+ 83,0,124,1,83,0,119,0,119,0,119,0,119,0,119,0,
+ 119,0,119,0,41,7,78,114,9,0,0,0,114,106,0,0,
+ 0,218,11,95,95,112,97,99,107,97,103,101,95,95,114,148,
+ 0,0,0,114,115,0,0,0,114,146,0,0,0,41,21,114,
+ 13,0,0,0,114,20,0,0,0,114,9,0,0,0,114,2,
+ 0,0,0,114,116,0,0,0,114,123,0,0,0,114,133,0,
+ 0,0,114,134,0,0,0,218,16,95,78,97,109,101,115,112,
97,99,101,76,111,97,100,101,114,218,7,95,95,110,101,119,
- 95,95,90,5,95,112,97,116,104,114,109,0,0,0,114,99,
- 0,0,0,114,131,0,0,0,114,146,0,0,0,114,106,0,
- 0,0,114,142,0,0,0,114,124,0,0,0,114,114,0,0,
- 0,114,123,0,0,0,114,140,0,0,0,41,5,114,96,0,
- 0,0,114,97,0,0,0,114,145,0,0,0,114,110,0,0,
- 0,114,147,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,218,18,95,105,110,105,116,95,109,111,100,
- 117,108,101,95,97,116,116,114,115,230,1,0,0,115,96,0,
- 0,0,0,4,20,1,2,1,12,1,12,1,6,2,20,1,
- 6,1,8,2,10,1,8,1,4,1,6,2,10,1,8,1,
- 6,11,6,1,2,1,10,1,12,1,6,2,20,1,2,1,
- 12,1,12,1,6,2,2,1,10,1,12,1,6,2,24,1,
- 12,1,2,1,12,1,14,1,6,2,8,1,24,1,2,1,
- 12,1,14,1,6,2,24,1,12,1,2,1,12,1,14,1,
- 6,1,114,149,0,0,0,99,1,0,0,0,0,0,0,0,
- 0,0,0,0,2,0,0,0,3,0,0,0,67,0,0,0,
- 115,82,0,0,0,100,1,125,1,116,0,124,0,106,1,100,
- 2,131,2,114,30,124,0,106,1,160,2,124,0,161,1,125,
- 1,110,20,116,0,124,0,106,1,100,3,131,2,114,50,116,
- 3,100,4,131,1,130,1,124,1,100,1,117,0,114,68,116,
- 4,124,0,106,5,131,1,125,1,116,6,124,0,124,1,131,
- 2,1,0,124,1,83,0,41,5,122,43,67,114,101,97,116,
- 101,32,97,32,109,111,100,117,108,101,32,98,97,115,101,100,
- 32,111,110,32,116,104,101,32,112,114,111,118,105,100,101,100,
- 32,115,112,101,99,46,78,218,13,99,114,101,97,116,101,95,
- 109,111,100,117,108,101,218,11,101,120,101,99,95,109,111,100,
- 117,108,101,122,66,108,111,97,100,101,114,115,32,116,104,97,
- 116,32,100,101,102,105,110,101,32,101,120,101,99,95,109,111,
- 100,117,108,101,40,41,32,109,117,115,116,32,97,108,115,111,
- 32,100,101,102,105,110,101,32,99,114,101,97,116,101,95,109,
- 111,100,117,108,101,40,41,41,7,114,4,0,0,0,114,110,
- 0,0,0,114,150,0,0,0,114,80,0,0,0,114,18,0,
- 0,0,114,17,0,0,0,114,149,0,0,0,169,2,114,96,
- 0,0,0,114,97,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,218,16,109,111,100,117,108,101,95,
- 102,114,111,109,95,115,112,101,99,46,2,0,0,115,18,0,
- 0,0,0,3,4,1,12,3,14,1,12,1,8,2,8,1,
- 10,1,10,1,114,153,0,0,0,99,1,0,0,0,0,0,
- 0,0,0,0,0,0,2,0,0,0,4,0,0,0,67,0,
- 0,0,115,100,0,0,0,124,0,106,0,100,1,117,0,114,
- 14,100,2,110,4,124,0,106,0,125,1,124,0,106,1,100,
- 1,117,0,114,64,124,0,106,2,100,1,117,0,114,50,100,
- 3,160,3,124,1,161,1,83,0,100,4,160,3,124,1,124,
- 0,106,2,161,2,83,0,124,0,106,4,114,84,100,5,160,
- 3,124,1,124,0,106,1,161,2,83,0,100,6,160,3,124,
- 0,106,0,124,0,106,1,161,2,83,0,41,7,122,38,82,
- 101,116,117,114,110,32,116,104,101,32,114,101,112,114,32,116,
- 111,32,117,115,101,32,102,111,114,32,116,104,101,32,109,111,
- 100,117,108,101,46,78,114,101,0,0,0,114,102,0,0,0,
- 114,103,0,0,0,114,104,0,0,0,250,18,60,109,111,100,
- 117,108,101,32,123,33,114,125,32,40,123,125,41,62,41,5,
- 114,17,0,0,0,114,114,0,0,0,114,110,0,0,0,114,
- 46,0,0,0,114,124,0,0,0,41,2,114,96,0,0,0,
- 114,17,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
- 11,0,0,0,114,108,0,0,0,63,2,0,0,115,16,0,
- 0,0,0,3,20,1,10,1,10,1,10,2,14,2,6,1,
- 14,2,114,108,0,0,0,99,2,0,0,0,0,0,0,0,
- 0,0,0,0,4,0,0,0,10,0,0,0,67,0,0,0,
- 115,250,0,0,0,124,0,106,0,125,2,116,1,124,2,131,
- 1,143,216,1,0,116,2,106,3,160,4,124,2,161,1,124,
- 1,117,1,114,54,100,1,160,5,124,2,161,1,125,3,116,
- 6,124,3,124,2,100,2,141,2,130,1,122,132,124,0,106,
- 7,100,3,117,0,114,106,124,0,106,8,100,3,117,0,114,
- 90,116,6,100,4,124,0,106,0,100,2,141,2,130,1,116,
- 9,124,0,124,1,100,5,100,6,141,3,1,0,110,52,116,
- 9,124,0,124,1,100,5,100,6,141,3,1,0,116,10,124,
- 0,106,7,100,7,131,2,115,146,124,0,106,7,160,11,124,
- 2,161,1,1,0,110,12,124,0,106,7,160,12,124,1,161,
- 1,1,0,87,0,116,2,106,3,160,13,124,0,106,0,161,
- 1,125,1,124,1,116,2,106,3,124,0,106,0,60,0,110,
- 28,116,2,106,3,160,13,124,0,106,0,161,1,125,1,124,
- 1,116,2,106,3,124,0,106,0,60,0,48,0,87,0,100,
- 3,4,0,4,0,131,3,1,0,110,16,49,0,115,236,48,
- 0,1,0,1,0,1,0,89,0,1,0,124,1,83,0,41,
- 8,122,70,69,120,101,99,117,116,101,32,116,104,101,32,115,
- 112,101,99,39,115,32,115,112,101,99,105,102,105,101,100,32,
- 109,111,100,117,108,101,32,105,110,32,97,110,32,101,120,105,
- 115,116,105,110,103,32,109,111,100,117,108,101,39,115,32,110,
- 97,109,101,115,112,97,99,101,46,122,30,109,111,100,117,108,
- 101,32,123,33,114,125,32,110,111,116,32,105,110,32,115,121,
- 115,46,109,111,100,117,108,101,115,114,16,0,0,0,78,250,
- 14,109,105,115,115,105,110,103,32,108,111,97,100,101,114,84,
- 114,144,0,0,0,114,151,0,0,0,41,14,114,17,0,0,
- 0,114,51,0,0,0,114,15,0,0,0,114,93,0,0,0,
- 114,35,0,0,0,114,46,0,0,0,114,80,0,0,0,114,
- 110,0,0,0,114,117,0,0,0,114,149,0,0,0,114,4,
- 0,0,0,218,11,108,111,97,100,95,109,111,100,117,108,101,
- 114,151,0,0,0,218,3,112,111,112,41,4,114,96,0,0,
- 0,114,97,0,0,0,114,17,0,0,0,218,3,109,115,103,
- 114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,114,
- 94,0,0,0,80,2,0,0,115,38,0,0,0,0,2,6,
- 1,10,1,16,1,10,1,12,1,2,1,10,1,10,1,14,
- 2,16,2,14,1,12,4,14,2,14,4,14,1,14,255,14,
- 1,44,1,114,94,0,0,0,99,1,0,0,0,0,0,0,
- 0,0,0,0,0,2,0,0,0,8,0,0,0,67,0,0,
- 0,115,20,1,0,0,122,18,124,0,106,0,160,1,124,0,
- 106,2,161,1,1,0,87,0,110,52,1,0,1,0,1,0,
- 124,0,106,2,116,3,106,4,118,0,114,64,116,3,106,4,
- 160,5,124,0,106,2,161,1,125,1,124,1,116,3,106,4,
- 124,0,106,2,60,0,130,0,89,0,110,2,48,0,116,3,
- 106,4,160,5,124,0,106,2,161,1,125,1,124,1,116,3,
- 106,4,124,0,106,2,60,0,116,6,124,1,100,1,100,0,
- 131,3,100,0,117,0,114,146,122,12,124,0,106,0,124,1,
- 95,7,87,0,110,18,4,0,116,8,121,144,1,0,1,0,
- 1,0,89,0,110,2,48,0,116,6,124,1,100,2,100,0,
- 131,3,100,0,117,0,114,222,122,40,124,1,106,9,124,1,
- 95,10,116,11,124,1,100,3,131,2,115,200,124,0,106,2,
- 160,12,100,4,161,1,100,5,25,0,124,1,95,10,87,0,
- 110,18,4,0,116,8,121,220,1,0,1,0,1,0,89,0,
- 110,2,48,0,116,6,124,1,100,6,100,0,131,3,100,0,
- 117,0,144,1,114,16,122,10,124,0,124,1,95,13,87,0,
- 110,20,4,0,116,8,144,1,121,14,1,0,1,0,1,0,
- 89,0,110,2,48,0,124,1,83,0,41,7,78,114,99,0,
- 0,0,114,146,0,0,0,114,142,0,0,0,114,129,0,0,
- 0,114,22,0,0,0,114,106,0,0,0,41,14,114,110,0,
- 0,0,114,156,0,0,0,114,17,0,0,0,114,15,0,0,
- 0,114,93,0,0,0,114,157,0,0,0,114,6,0,0,0,
- 114,99,0,0,0,114,107,0,0,0,114,1,0,0,0,114,
- 146,0,0,0,114,4,0,0,0,114,130,0,0,0,114,106,
- 0,0,0,114,152,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,218,25,95,108,111,97,100,95,98,
- 97,99,107,119,97,114,100,95,99,111,109,112,97,116,105,98,
- 108,101,110,2,0,0,115,54,0,0,0,0,4,2,1,18,
- 1,6,1,12,1,14,1,12,1,8,3,14,1,12,1,16,
- 1,2,1,12,1,12,1,6,1,16,1,2,4,8,1,10,
- 1,22,1,12,1,6,1,18,1,2,1,10,1,14,1,6,
- 1,114,159,0,0,0,99,1,0,0,0,0,0,0,0,0,
- 0,0,0,2,0,0,0,11,0,0,0,67,0,0,0,115,
- 216,0,0,0,124,0,106,0,100,0,117,1,114,30,116,1,
- 124,0,106,0,100,1,131,2,115,30,116,2,124,0,131,1,
- 83,0,116,3,124,0,131,1,125,1,100,2,124,0,95,4,
- 122,158,124,1,116,5,106,6,124,0,106,7,60,0,122,52,
- 124,0,106,0,100,0,117,0,114,96,124,0,106,8,100,0,
- 117,0,114,108,116,9,100,3,124,0,106,7,100,4,141,2,
- 130,1,110,12,124,0,106,0,160,10,124,1,161,1,1,0,
- 87,0,110,40,1,0,1,0,1,0,122,14,116,5,106,6,
- 124,0,106,7,61,0,87,0,130,0,4,0,116,11,121,150,
- 1,0,1,0,1,0,89,0,130,0,48,0,116,5,106,6,
- 160,12,124,0,106,7,161,1,125,1,124,1,116,5,106,6,
- 124,0,106,7,60,0,116,13,100,5,124,0,106,7,124,0,
- 106,0,131,3,1,0,87,0,100,6,124,0,95,4,110,8,
- 100,6,124,0,95,4,48,0,124,1,83,0,41,7,78,114,
- 151,0,0,0,84,114,155,0,0,0,114,16,0,0,0,122,
+ 95,95,90,5,95,112,97,116,104,114,115,0,0,0,114,106,
+ 0,0,0,114,137,0,0,0,114,152,0,0,0,114,113,0,
+ 0,0,114,148,0,0,0,114,130,0,0,0,114,120,0,0,
+ 0,114,129,0,0,0,114,146,0,0,0,41,5,114,103,0,
+ 0,0,114,104,0,0,0,114,151,0,0,0,114,116,0,0,
+ 0,114,153,0,0,0,114,5,0,0,0,114,5,0,0,0,
+ 114,6,0,0,0,218,18,95,105,110,105,116,95,109,111,100,
+ 117,108,101,95,97,116,116,114,115,246,1,0,0,115,114,0,
+ 0,0,20,4,2,1,12,1,14,1,2,1,20,2,6,1,
+ 8,1,10,2,8,1,4,1,6,1,10,2,8,1,6,1,
+ 6,11,2,1,10,1,14,1,2,1,20,2,2,1,12,1,
+ 14,1,2,1,2,2,10,1,14,1,2,1,24,2,12,1,
+ 2,1,12,1,14,1,2,1,8,2,24,1,2,1,12,1,
+ 14,1,2,1,24,2,12,1,2,1,10,1,4,3,14,254,
+ 2,1,8,1,2,254,2,249,2,249,2,249,2,251,2,250,
+ 2,228,255,128,114,155,0,0,0,99,1,0,0,0,0,0,
+ 0,0,0,0,0,0,2,0,0,0,3,0,0,0,67,0,
+ 0,0,115,82,0,0,0,100,1,125,1,116,0,124,0,106,
+ 1,100,2,131,2,114,30,124,0,106,1,160,2,124,0,161,
+ 1,125,1,110,20,116,0,124,0,106,1,100,3,131,2,114,
+ 50,116,3,100,4,131,1,130,1,124,1,100,1,117,0,114,
+ 68,116,4,124,0,106,5,131,1,125,1,116,6,124,0,124,
+ 1,131,2,1,0,124,1,83,0,41,5,122,43,67,114,101,
+ 97,116,101,32,97,32,109,111,100,117,108,101,32,98,97,115,
+ 101,100,32,111,110,32,116,104,101,32,112,114,111,118,105,100,
+ 101,100,32,115,112,101,99,46,78,218,13,99,114,101,97,116,
+ 101,95,109,111,100,117,108,101,218,11,101,120,101,99,95,109,
+ 111,100,117,108,101,122,66,108,111,97,100,101,114,115,32,116,
+ 104,97,116,32,100,101,102,105,110,101,32,101,120,101,99,95,
+ 109,111,100,117,108,101,40,41,32,109,117,115,116,32,97,108,
+ 115,111,32,100,101,102,105,110,101,32,99,114,101,97,116,101,
+ 95,109,111,100,117,108,101,40,41,41,7,114,11,0,0,0,
+ 114,116,0,0,0,114,156,0,0,0,114,83,0,0,0,114,
+ 21,0,0,0,114,20,0,0,0,114,155,0,0,0,169,2,
+ 114,103,0,0,0,114,104,0,0,0,114,5,0,0,0,114,
+ 5,0,0,0,114,6,0,0,0,218,16,109,111,100,117,108,
+ 101,95,102,114,111,109,95,115,112,101,99,62,2,0,0,115,
+ 20,0,0,0,4,3,12,1,14,3,12,1,8,1,8,2,
+ 10,1,10,1,4,1,255,128,114,159,0,0,0,99,1,0,
+ 0,0,0,0,0,0,0,0,0,0,2,0,0,0,4,0,
+ 0,0,67,0,0,0,115,100,0,0,0,124,0,106,0,100,
+ 1,117,0,114,14,100,2,110,4,124,0,106,0,125,1,124,
+ 0,106,1,100,1,117,0,114,64,124,0,106,2,100,1,117,
+ 0,114,50,100,3,160,3,124,1,161,1,83,0,100,4,160,
+ 3,124,1,124,0,106,2,161,2,83,0,124,0,106,4,114,
+ 84,100,5,160,3,124,1,124,0,106,1,161,2,83,0,100,
+ 6,160,3,124,0,106,0,124,0,106,1,161,2,83,0,41,
+ 7,122,38,82,101,116,117,114,110,32,116,104,101,32,114,101,
+ 112,114,32,116,111,32,117,115,101,32,102,111,114,32,116,104,
+ 101,32,109,111,100,117,108,101,46,78,114,108,0,0,0,114,
+ 109,0,0,0,114,110,0,0,0,114,111,0,0,0,250,18,
+ 60,109,111,100,117,108,101,32,123,33,114,125,32,40,123,125,
+ 41,62,41,5,114,20,0,0,0,114,120,0,0,0,114,116,
+ 0,0,0,114,49,0,0,0,114,130,0,0,0,41,2,114,
+ 103,0,0,0,114,20,0,0,0,114,5,0,0,0,114,5,
+ 0,0,0,114,6,0,0,0,114,114,0,0,0,79,2,0,
+ 0,115,18,0,0,0,20,3,10,1,10,1,10,1,14,2,
+ 6,2,14,1,16,2,255,128,114,114,0,0,0,99,2,0,
+ 0,0,0,0,0,0,0,0,0,0,4,0,0,0,10,0,
+ 0,0,67,0,0,0,115,26,1,0,0,124,0,106,0,125,
+ 2,116,1,124,2,131,1,143,246,1,0,116,2,106,3,160,
+ 4,124,2,161,1,124,1,117,1,114,54,100,1,160,5,124,
+ 2,161,1,125,3,116,6,124,3,124,2,100,2,141,2,130,
+ 1,122,160,124,0,106,7,100,3,117,0,114,106,124,0,106,
+ 8,100,3,117,0,114,90,116,6,100,4,124,0,106,0,100,
+ 2,141,2,130,1,116,9,124,0,124,1,100,5,100,6,141,
+ 3,1,0,110,80,116,9,124,0,124,1,100,5,100,6,141,
+ 3,1,0,116,10,124,0,106,7,100,7,131,2,115,174,116,
+ 11,124,0,106,7,131,1,155,0,100,8,157,2,125,3,116,
+ 12,160,13,124,3,116,14,161,2,1,0,124,0,106,7,160,
+ 15,124,2,161,1,1,0,110,12,124,0,106,7,160,16,124,
+ 1,161,1,1,0,87,0,116,2,106,3,160,17,124,0,106,
+ 0,161,1,125,1,124,1,116,2,106,3,124,0,106,0,60,
+ 0,110,28,116,2,106,3,160,17,124,0,106,0,161,1,125,
+ 1,124,1,116,2,106,3,124,0,106,0,60,0,119,0,87,
+ 0,100,3,4,0,4,0,131,3,1,0,124,1,83,0,49,
+ 0,144,1,115,12,119,1,1,0,1,0,1,0,89,0,1,
+ 0,124,1,83,0,41,9,122,70,69,120,101,99,117,116,101,
+ 32,116,104,101,32,115,112,101,99,39,115,32,115,112,101,99,
+ 105,102,105,101,100,32,109,111,100,117,108,101,32,105,110,32,
+ 97,110,32,101,120,105,115,116,105,110,103,32,109,111,100,117,
+ 108,101,39,115,32,110,97,109,101,115,112,97,99,101,46,122,
+ 30,109,111,100,117,108,101,32,123,33,114,125,32,110,111,116,
+ 32,105,110,32,115,121,115,46,109,111,100,117,108,101,115,114,
+ 19,0,0,0,78,250,14,109,105,115,115,105,110,103,32,108,
+ 111,97,100,101,114,84,114,150,0,0,0,114,157,0,0,0,
+ 250,55,46,101,120,101,99,95,109,111,100,117,108,101,40,41,
+ 32,110,111,116,32,102,111,117,110,100,59,32,102,97,108,108,
+ 105,110,103,32,98,97,99,107,32,116,111,32,108,111,97,100,
+ 95,109,111,100,117,108,101,40,41,41,18,114,20,0,0,0,
+ 114,54,0,0,0,114,18,0,0,0,114,99,0,0,0,114,
+ 38,0,0,0,114,49,0,0,0,114,83,0,0,0,114,116,
+ 0,0,0,114,123,0,0,0,114,155,0,0,0,114,11,0,
+ 0,0,114,7,0,0,0,114,95,0,0,0,114,96,0,0,
+ 0,218,13,73,109,112,111,114,116,87,97,114,110,105,110,103,
+ 218,11,108,111,97,100,95,109,111,100,117,108,101,114,157,0,
+ 0,0,218,3,112,111,112,41,4,114,103,0,0,0,114,104,
+ 0,0,0,114,20,0,0,0,114,102,0,0,0,114,5,0,
+ 0,0,114,5,0,0,0,114,6,0,0,0,114,100,0,0,
+ 0,96,2,0,0,115,50,0,0,0,6,2,10,1,16,1,
+ 10,1,12,1,2,1,10,1,10,1,14,1,16,2,14,2,
+ 12,1,16,1,12,2,14,1,12,2,2,128,14,4,14,1,
+ 14,255,26,1,4,1,18,255,4,1,255,128,114,100,0,0,
+ 0,99,1,0,0,0,0,0,0,0,0,0,0,0,2,0,
+ 0,0,8,0,0,0,67,0,0,0,115,18,1,0,0,122,
+ 18,124,0,106,0,160,1,124,0,106,2,161,1,1,0,87,
+ 0,110,46,1,0,1,0,1,0,124,0,106,2,116,3,106,
+ 4,118,0,114,64,116,3,106,4,160,5,124,0,106,2,161,
+ 1,125,1,124,1,116,3,106,4,124,0,106,2,60,0,130,
+ 0,116,3,106,4,160,5,124,0,106,2,161,1,125,1,124,
+ 1,116,3,106,4,124,0,106,2,60,0,116,6,124,1,100,
+ 1,100,0,131,3,100,0,117,0,114,138,122,12,124,0,106,
+ 0,124,1,95,7,87,0,110,16,4,0,116,8,144,1,121,
+ 16,1,0,1,0,1,0,89,0,116,6,124,1,100,2,100,
+ 0,131,3,100,0,117,0,114,212,122,40,124,1,106,9,124,
+ 1,95,10,116,11,124,1,100,3,131,2,115,192,124,0,106,
+ 2,160,12,100,4,161,1,100,5,25,0,124,1,95,10,87,
+ 0,110,16,4,0,116,8,144,1,121,14,1,0,1,0,1,
+ 0,89,0,116,6,124,1,100,6,100,0,131,3,100,0,117,
+ 0,144,1,114,8,122,12,124,0,124,1,95,13,87,0,124,
+ 1,83,0,4,0,116,8,144,1,121,12,1,0,1,0,1,
+ 0,89,0,124,1,83,0,124,1,83,0,119,0,119,0,119,
+ 0,41,7,78,114,106,0,0,0,114,152,0,0,0,114,148,
+ 0,0,0,114,135,0,0,0,114,25,0,0,0,114,113,0,
+ 0,0,41,14,114,116,0,0,0,114,164,0,0,0,114,20,
+ 0,0,0,114,18,0,0,0,114,99,0,0,0,114,165,0,
+ 0,0,114,13,0,0,0,114,106,0,0,0,114,2,0,0,
+ 0,114,9,0,0,0,114,152,0,0,0,114,11,0,0,0,
+ 114,136,0,0,0,114,113,0,0,0,114,158,0,0,0,114,
+ 5,0,0,0,114,5,0,0,0,114,6,0,0,0,218,25,
+ 95,108,111,97,100,95,98,97,99,107,119,97,114,100,95,99,
+ 111,109,112,97,116,105,98,108,101,126,2,0,0,115,64,0,
+ 0,0,2,3,18,1,6,1,12,1,14,1,12,1,2,1,
+ 14,3,12,1,16,1,2,1,12,1,14,1,2,1,16,1,
+ 2,1,8,4,10,1,22,1,14,1,2,1,18,1,2,1,
+ 8,1,4,3,14,254,2,1,8,1,2,254,2,251,2,246,
+ 255,128,114,166,0,0,0,99,1,0,0,0,0,0,0,0,
+ 0,0,0,0,3,0,0,0,11,0,0,0,67,0,0,0,
+ 115,242,0,0,0,124,0,106,0,100,0,117,1,114,58,116,
+ 1,124,0,106,0,100,1,131,2,115,58,116,2,124,0,106,
+ 0,131,1,155,0,100,2,157,2,125,1,116,3,160,4,124,
+ 1,116,5,161,2,1,0,116,6,124,0,131,1,83,0,116,
+ 7,124,0,131,1,125,2,100,3,124,0,95,8,122,158,124,
+ 2,116,9,106,10,124,0,106,11,60,0,122,52,124,0,106,
+ 0,100,0,117,0,114,124,124,0,106,12,100,0,117,0,114,
+ 122,116,13,100,4,124,0,106,11,100,5,141,2,130,1,110,
+ 12,124,0,106,0,160,14,124,2,161,1,1,0,87,0,110,
+ 38,1,0,1,0,1,0,122,14,116,9,106,10,124,0,106,
+ 11,61,0,87,0,130,0,4,0,116,15,121,240,1,0,1,
+ 0,1,0,89,0,130,0,116,9,106,10,160,16,124,0,106,
+ 11,161,1,125,2,124,2,116,9,106,10,124,0,106,11,60,
+ 0,116,17,100,6,124,0,106,11,124,0,106,0,131,3,1,
+ 0,87,0,100,7,124,0,95,8,124,2,83,0,100,7,124,
+ 0,95,8,119,0,119,0,41,8,78,114,157,0,0,0,114,
+ 162,0,0,0,84,114,161,0,0,0,114,19,0,0,0,122,
18,105,109,112,111,114,116,32,123,33,114,125,32,35,32,123,
- 33,114,125,70,41,14,114,110,0,0,0,114,4,0,0,0,
- 114,159,0,0,0,114,153,0,0,0,90,13,95,105,110,105,
- 116,105,97,108,105,122,105,110,103,114,15,0,0,0,114,93,
- 0,0,0,114,17,0,0,0,114,117,0,0,0,114,80,0,
- 0,0,114,151,0,0,0,114,64,0,0,0,114,157,0,0,
- 0,114,77,0,0,0,114,152,0,0,0,114,10,0,0,0,
- 114,10,0,0,0,114,11,0,0,0,218,14,95,108,111,97,
- 100,95,117,110,108,111,99,107,101,100,147,2,0,0,115,44,
- 0,0,0,0,2,10,2,12,1,8,2,8,5,6,1,2,
- 1,12,1,2,1,10,1,10,1,16,3,16,1,6,1,2,
- 1,14,1,12,1,6,6,14,1,12,1,18,2,16,2,114,
- 160,0,0,0,99,1,0,0,0,0,0,0,0,0,0,0,
- 0,1,0,0,0,8,0,0,0,67,0,0,0,115,54,0,
- 0,0,116,0,124,0,106,1,131,1,143,24,1,0,116,2,
- 124,0,131,1,87,0,2,0,100,1,4,0,4,0,131,3,
- 1,0,83,0,49,0,115,40,48,0,1,0,1,0,1,0,
- 89,0,1,0,100,1,83,0,41,2,122,191,82,101,116,117,
- 114,110,32,97,32,110,101,119,32,109,111,100,117,108,101,32,
- 111,98,106,101,99,116,44,32,108,111,97,100,101,100,32,98,
- 121,32,116,104,101,32,115,112,101,99,39,115,32,108,111,97,
- 100,101,114,46,10,10,32,32,32,32,84,104,101,32,109,111,
- 100,117,108,101,32,105,115,32,110,111,116,32,97,100,100,101,
- 100,32,116,111,32,105,116,115,32,112,97,114,101,110,116,46,
- 10,10,32,32,32,32,73,102,32,97,32,109,111,100,117,108,
- 101,32,105,115,32,97,108,114,101,97,100,121,32,105,110,32,
- 115,121,115,46,109,111,100,117,108,101,115,44,32,116,104,97,
- 116,32,101,120,105,115,116,105,110,103,32,109,111,100,117,108,
- 101,32,103,101,116,115,10,32,32,32,32,99,108,111,98,98,
- 101,114,101,100,46,10,10,32,32,32,32,78,41,3,114,51,
- 0,0,0,114,17,0,0,0,114,160,0,0,0,41,1,114,
- 96,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
- 0,0,0,114,95,0,0,0,189,2,0,0,115,4,0,0,
- 0,0,9,12,1,114,95,0,0,0,99,0,0,0,0,0,
+ 33,114,125,70,41,18,114,116,0,0,0,114,11,0,0,0,
+ 114,7,0,0,0,114,95,0,0,0,114,96,0,0,0,114,
+ 163,0,0,0,114,166,0,0,0,114,159,0,0,0,90,13,
+ 95,105,110,105,116,105,97,108,105,122,105,110,103,114,18,0,
+ 0,0,114,99,0,0,0,114,20,0,0,0,114,123,0,0,
+ 0,114,83,0,0,0,114,157,0,0,0,114,67,0,0,0,
+ 114,165,0,0,0,114,80,0,0,0,41,3,114,103,0,0,
+ 0,114,102,0,0,0,114,104,0,0,0,114,5,0,0,0,
+ 114,5,0,0,0,114,6,0,0,0,218,14,95,108,111,97,
+ 100,95,117,110,108,111,99,107,101,100,162,2,0,0,115,58,
+ 0,0,0,10,2,12,2,16,1,12,2,8,1,8,2,6,
+ 5,2,1,12,1,2,1,10,1,10,1,16,1,16,3,6,
+ 1,2,1,12,1,2,3,12,254,2,1,2,1,14,5,12,
+ 1,18,1,6,2,4,2,8,254,2,245,255,128,114,167,0,
+ 0,0,99,1,0,0,0,0,0,0,0,0,0,0,0,1,
+ 0,0,0,8,0,0,0,67,0,0,0,115,54,0,0,0,
+ 116,0,124,0,106,1,131,1,143,24,1,0,116,2,124,0,
+ 131,1,87,0,2,0,100,1,4,0,4,0,131,3,1,0,
+ 83,0,49,0,115,40,119,1,1,0,1,0,1,0,89,0,
+ 1,0,100,1,83,0,41,2,122,191,82,101,116,117,114,110,
+ 32,97,32,110,101,119,32,109,111,100,117,108,101,32,111,98,
+ 106,101,99,116,44,32,108,111,97,100,101,100,32,98,121,32,
+ 116,104,101,32,115,112,101,99,39,115,32,108,111,97,100,101,
+ 114,46,10,10,32,32,32,32,84,104,101,32,109,111,100,117,
+ 108,101,32,105,115,32,110,111,116,32,97,100,100,101,100,32,
+ 116,111,32,105,116,115,32,112,97,114,101,110,116,46,10,10,
+ 32,32,32,32,73,102,32,97,32,109,111,100,117,108,101,32,
+ 105,115,32,97,108,114,101,97,100,121,32,105,110,32,115,121,
+ 115,46,109,111,100,117,108,101,115,44,32,116,104,97,116,32,
+ 101,120,105,115,116,105,110,103,32,109,111,100,117,108,101,32,
+ 103,101,116,115,10,32,32,32,32,99,108,111,98,98,101,114,
+ 101,100,46,10,10,32,32,32,32,78,41,3,114,54,0,0,
+ 0,114,20,0,0,0,114,167,0,0,0,169,1,114,103,0,
+ 0,0,114,5,0,0,0,114,5,0,0,0,114,6,0,0,
+ 0,114,101,0,0,0,207,2,0,0,115,6,0,0,0,12,
+ 9,42,1,255,128,114,101,0,0,0,99,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,64,
0,0,0,115,140,0,0,0,101,0,90,1,100,0,90,2,
100,1,90,3,100,2,90,4,101,5,100,3,100,4,132,0,
131,1,90,6,101,7,100,20,100,6,100,7,132,1,131,1,
90,8,101,7,100,21,100,8,100,9,132,1,131,1,90,9,
- 101,7,100,10,100,11,132,0,131,1,90,10,101,7,100,12,
+ 101,5,100,10,100,11,132,0,131,1,90,10,101,5,100,12,
100,13,132,0,131,1,90,11,101,7,101,12,100,14,100,15,
132,0,131,1,131,1,90,13,101,7,101,12,100,16,100,17,
132,0,131,1,131,1,90,14,101,7,101,12,100,18,100,19,
@@ -1053,7 +1097,7 @@ const unsigned char _Py_M__importlib_bootstrap[] = {
45,105,110,99,1,0,0,0,0,0,0,0,0,0,0,0,
1,0,0,0,5,0,0,0,67,0,0,0,115,22,0,0,
0,100,1,124,0,106,0,155,2,100,2,116,1,106,2,155,
- 0,100,3,157,5,83,0,41,4,250,115,82,101,116,117,114,
+ 0,100,3,157,5,83,0,41,5,250,115,82,101,116,117,114,
110,32,114,101,112,114,32,102,111,114,32,116,104,101,32,109,
111,100,117,108,101,46,10,10,32,32,32,32,32,32,32,32,
84,104,101,32,109,101,116,104,111,100,32,105,115,32,100,101,
@@ -1062,747 +1106,754 @@ const unsigned char _Py_M__importlib_bootstrap[] = {
100,111,101,115,32,116,104,101,32,106,111,98,32,105,116,115,
101,108,102,46,10,10,32,32,32,32,32,32,32,32,122,8,
60,109,111,100,117,108,101,32,122,2,32,40,122,2,41,62,
- 41,3,114,1,0,0,0,114,161,0,0,0,114,139,0,0,
- 0,41,1,114,97,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,114,100,0,0,0,215,2,0,0,
- 115,2,0,0,0,0,7,122,27,66,117,105,108,116,105,110,
- 73,109,112,111,114,116,101,114,46,109,111,100,117,108,101,95,
- 114,101,112,114,78,99,4,0,0,0,0,0,0,0,0,0,
- 0,0,4,0,0,0,5,0,0,0,67,0,0,0,115,42,
- 0,0,0,124,2,100,0,117,1,114,12,100,0,83,0,116,
- 0,160,1,124,1,161,1,114,38,116,2,124,1,124,0,124,
- 0,106,3,100,1,141,3,83,0,100,0,83,0,169,2,78,
- 114,138,0,0,0,41,4,114,58,0,0,0,90,10,105,115,
- 95,98,117,105,108,116,105,110,114,92,0,0,0,114,139,0,
- 0,0,169,4,218,3,99,108,115,114,82,0,0,0,218,4,
- 112,97,116,104,218,6,116,97,114,103,101,116,114,10,0,0,
- 0,114,10,0,0,0,114,11,0,0,0,218,9,102,105,110,
- 100,95,115,112,101,99,224,2,0,0,115,10,0,0,0,0,
- 2,8,1,4,1,10,1,16,2,122,25,66,117,105,108,116,
- 105,110,73,109,112,111,114,116,101,114,46,102,105,110,100,95,
- 115,112,101,99,99,3,0,0,0,0,0,0,0,0,0,0,
- 0,4,0,0,0,4,0,0,0,67,0,0,0,115,30,0,
- 0,0,124,0,160,0,124,1,124,2,161,2,125,3,124,3,
- 100,1,117,1,114,26,124,3,106,1,83,0,100,1,83,0,
- 41,2,122,175,70,105,110,100,32,116,104,101,32,98,117,105,
- 108,116,45,105,110,32,109,111,100,117,108,101,46,10,10,32,
- 32,32,32,32,32,32,32,73,102,32,39,112,97,116,104,39,
- 32,105,115,32,101,118,101,114,32,115,112,101,99,105,102,105,
- 101,100,32,116,104,101,110,32,116,104,101,32,115,101,97,114,
- 99,104,32,105,115,32,99,111,110,115,105,100,101,114,101,100,
- 32,97,32,102,97,105,108,117,114,101,46,10,10,32,32,32,
- 32,32,32,32,32,84,104,105,115,32,109,101,116,104,111,100,
- 32,105,115,32,100,101,112,114,101,99,97,116,101,100,46,32,
- 32,85,115,101,32,102,105,110,100,95,115,112,101,99,40,41,
- 32,105,110,115,116,101,97,100,46,10,10,32,32,32,32,32,
- 32,32,32,78,41,2,114,168,0,0,0,114,110,0,0,0,
- 41,4,114,165,0,0,0,114,82,0,0,0,114,166,0,0,
- 0,114,96,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,218,11,102,105,110,100,95,109,111,100,117,
- 108,101,233,2,0,0,115,4,0,0,0,0,9,12,1,122,
- 27,66,117,105,108,116,105,110,73,109,112,111,114,116,101,114,
- 46,102,105,110,100,95,109,111,100,117,108,101,99,2,0,0,
- 0,0,0,0,0,0,0,0,0,2,0,0,0,4,0,0,
- 0,67,0,0,0,115,46,0,0,0,124,1,106,0,116,1,
- 106,2,118,1,114,34,116,3,100,1,160,4,124,1,106,0,
- 161,1,124,1,106,0,100,2,141,2,130,1,116,5,116,6,
- 106,7,124,1,131,2,83,0,41,3,122,24,67,114,101,97,
- 116,101,32,97,32,98,117,105,108,116,45,105,110,32,109,111,
- 100,117,108,101,114,78,0,0,0,114,16,0,0,0,41,8,
- 114,17,0,0,0,114,15,0,0,0,114,79,0,0,0,114,
- 80,0,0,0,114,46,0,0,0,114,68,0,0,0,114,58,
- 0,0,0,90,14,99,114,101,97,116,101,95,98,117,105,108,
- 116,105,110,41,2,114,30,0,0,0,114,96,0,0,0,114,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,114,150,
- 0,0,0,245,2,0,0,115,10,0,0,0,0,3,12,1,
- 12,1,4,255,6,2,122,29,66,117,105,108,116,105,110,73,
- 109,112,111,114,116,101,114,46,99,114,101,97,116,101,95,109,
- 111,100,117,108,101,99,2,0,0,0,0,0,0,0,0,0,
- 0,0,2,0,0,0,3,0,0,0,67,0,0,0,115,16,
- 0,0,0,116,0,116,1,106,2,124,1,131,2,1,0,100,
- 1,83,0,41,2,122,22,69,120,101,99,32,97,32,98,117,
- 105,108,116,45,105,110,32,109,111,100,117,108,101,78,41,3,
- 114,68,0,0,0,114,58,0,0,0,90,12,101,120,101,99,
- 95,98,117,105,108,116,105,110,41,2,114,30,0,0,0,114,
- 97,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
- 0,0,0,114,151,0,0,0,253,2,0,0,115,2,0,0,
- 0,0,3,122,27,66,117,105,108,116,105,110,73,109,112,111,
- 114,116,101,114,46,101,120,101,99,95,109,111,100,117,108,101,
- 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
- 0,1,0,0,0,67,0,0,0,115,4,0,0,0,100,1,
- 83,0,41,2,122,57,82,101,116,117,114,110,32,78,111,110,
- 101,32,97,115,32,98,117,105,108,116,45,105,110,32,109,111,
- 100,117,108,101,115,32,100,111,32,110,111,116,32,104,97,118,
- 101,32,99,111,100,101,32,111,98,106,101,99,116,115,46,78,
- 114,10,0,0,0,169,2,114,165,0,0,0,114,82,0,0,
- 0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
- 218,8,103,101,116,95,99,111,100,101,2,3,0,0,115,2,
- 0,0,0,0,4,122,24,66,117,105,108,116,105,110,73,109,
+ 78,41,3,114,9,0,0,0,114,169,0,0,0,114,145,0,
+ 0,0,169,1,114,104,0,0,0,114,5,0,0,0,114,5,
+ 0,0,0,114,6,0,0,0,114,107,0,0,0,233,2,0,
+ 0,115,4,0,0,0,22,7,255,128,122,27,66,117,105,108,
+ 116,105,110,73,109,112,111,114,116,101,114,46,109,111,100,117,
+ 108,101,95,114,101,112,114,78,99,4,0,0,0,0,0,0,
+ 0,0,0,0,0,4,0,0,0,5,0,0,0,67,0,0,
+ 0,115,42,0,0,0,124,2,100,0,117,1,114,12,100,0,
+ 83,0,116,0,160,1,124,1,161,1,114,38,116,2,124,1,
+ 124,0,124,0,106,3,100,1,141,3,83,0,100,0,83,0,
+ 169,2,78,114,144,0,0,0,41,4,114,61,0,0,0,90,
+ 10,105,115,95,98,117,105,108,116,105,110,114,98,0,0,0,
+ 114,145,0,0,0,169,4,218,3,99,108,115,114,85,0,0,
+ 0,218,4,112,97,116,104,218,6,116,97,114,103,101,116,114,
+ 5,0,0,0,114,5,0,0,0,114,6,0,0,0,218,9,
+ 102,105,110,100,95,115,112,101,99,242,2,0,0,115,12,0,
+ 0,0,8,2,4,1,10,1,16,1,4,2,255,128,122,25,
+ 66,117,105,108,116,105,110,73,109,112,111,114,116,101,114,46,
+ 102,105,110,100,95,115,112,101,99,99,3,0,0,0,0,0,
+ 0,0,0,0,0,0,4,0,0,0,4,0,0,0,67,0,
+ 0,0,115,30,0,0,0,124,0,160,0,124,1,124,2,161,
+ 2,125,3,124,3,100,1,117,1,114,26,124,3,106,1,83,
+ 0,100,1,83,0,41,2,122,175,70,105,110,100,32,116,104,
+ 101,32,98,117,105,108,116,45,105,110,32,109,111,100,117,108,
+ 101,46,10,10,32,32,32,32,32,32,32,32,73,102,32,39,
+ 112,97,116,104,39,32,105,115,32,101,118,101,114,32,115,112,
+ 101,99,105,102,105,101,100,32,116,104,101,110,32,116,104,101,
+ 32,115,101,97,114,99,104,32,105,115,32,99,111,110,115,105,
+ 100,101,114,101,100,32,97,32,102,97,105,108,117,114,101,46,
+ 10,10,32,32,32,32,32,32,32,32,84,104,105,115,32,109,
+ 101,116,104,111,100,32,105,115,32,100,101,112,114,101,99,97,
+ 116,101,100,46,32,32,85,115,101,32,102,105,110,100,95,115,
+ 112,101,99,40,41,32,105,110,115,116,101,97,100,46,10,10,
+ 32,32,32,32,32,32,32,32,78,41,2,114,177,0,0,0,
+ 114,116,0,0,0,41,4,114,174,0,0,0,114,85,0,0,
+ 0,114,175,0,0,0,114,103,0,0,0,114,5,0,0,0,
+ 114,5,0,0,0,114,6,0,0,0,218,11,102,105,110,100,
+ 95,109,111,100,117,108,101,251,2,0,0,115,6,0,0,0,
+ 12,9,18,1,255,128,122,27,66,117,105,108,116,105,110,73,
+ 109,112,111,114,116,101,114,46,102,105,110,100,95,109,111,100,
+ 117,108,101,99,1,0,0,0,0,0,0,0,0,0,0,0,
+ 1,0,0,0,4,0,0,0,67,0,0,0,115,46,0,0,
+ 0,124,0,106,0,116,1,106,2,118,1,114,34,116,3,100,
+ 1,160,4,124,0,106,0,161,1,124,0,106,0,100,2,141,
+ 2,130,1,116,5,116,6,106,7,124,0,131,2,83,0,41,
+ 4,122,24,67,114,101,97,116,101,32,97,32,98,117,105,108,
+ 116,45,105,110,32,109,111,100,117,108,101,114,81,0,0,0,
+ 114,19,0,0,0,78,41,8,114,20,0,0,0,114,18,0,
+ 0,0,114,82,0,0,0,114,83,0,0,0,114,49,0,0,
+ 0,114,71,0,0,0,114,61,0,0,0,90,14,99,114,101,
+ 97,116,101,95,98,117,105,108,116,105,110,114,168,0,0,0,
+ 114,5,0,0,0,114,5,0,0,0,114,6,0,0,0,114,
+ 156,0,0,0,7,3,0,0,115,12,0,0,0,12,3,12,
+ 1,4,1,6,255,12,2,255,128,122,29,66,117,105,108,116,
+ 105,110,73,109,112,111,114,116,101,114,46,99,114,101,97,116,
+ 101,95,109,111,100,117,108,101,99,1,0,0,0,0,0,0,
+ 0,0,0,0,0,1,0,0,0,3,0,0,0,67,0,0,
+ 0,115,16,0,0,0,116,0,116,1,106,2,124,0,131,2,
+ 1,0,100,1,83,0,41,2,122,22,69,120,101,99,32,97,
+ 32,98,117,105,108,116,45,105,110,32,109,111,100,117,108,101,
+ 78,41,3,114,71,0,0,0,114,61,0,0,0,90,12,101,
+ 120,101,99,95,98,117,105,108,116,105,110,114,171,0,0,0,
+ 114,5,0,0,0,114,5,0,0,0,114,6,0,0,0,114,
+ 157,0,0,0,15,3,0,0,115,4,0,0,0,16,3,255,
+ 128,122,27,66,117,105,108,116,105,110,73,109,112,111,114,116,
+ 101,114,46,101,120,101,99,95,109,111,100,117,108,101,99,2,
+ 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,1,
+ 0,0,0,67,0,0,0,115,4,0,0,0,100,1,83,0,
+ 41,2,122,57,82,101,116,117,114,110,32,78,111,110,101,32,
+ 97,115,32,98,117,105,108,116,45,105,110,32,109,111,100,117,
+ 108,101,115,32,100,111,32,110,111,116,32,104,97,118,101,32,
+ 99,111,100,101,32,111,98,106,101,99,116,115,46,78,114,5,
+ 0,0,0,169,2,114,174,0,0,0,114,85,0,0,0,114,
+ 5,0,0,0,114,5,0,0,0,114,6,0,0,0,218,8,
+ 103,101,116,95,99,111,100,101,20,3,0,0,115,4,0,0,
+ 0,4,4,255,128,122,24,66,117,105,108,116,105,110,73,109,
112,111,114,116,101,114,46,103,101,116,95,99,111,100,101,99,
2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,
1,0,0,0,67,0,0,0,115,4,0,0,0,100,1,83,
0,41,2,122,56,82,101,116,117,114,110,32,78,111,110,101,
32,97,115,32,98,117,105,108,116,45,105,110,32,109,111,100,
117,108,101,115,32,100,111,32,110,111,116,32,104,97,118,101,
- 32,115,111,117,114,99,101,32,99,111,100,101,46,78,114,10,
- 0,0,0,114,170,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,218,10,103,101,116,95,115,111,117,
- 114,99,101,8,3,0,0,115,2,0,0,0,0,4,122,26,
- 66,117,105,108,116,105,110,73,109,112,111,114,116,101,114,46,
- 103,101,116,95,115,111,117,114,99,101,99,2,0,0,0,0,
- 0,0,0,0,0,0,0,2,0,0,0,1,0,0,0,67,
- 0,0,0,115,4,0,0,0,100,1,83,0,41,2,122,52,
- 82,101,116,117,114,110,32,70,97,108,115,101,32,97,115,32,
- 98,117,105,108,116,45,105,110,32,109,111,100,117,108,101,115,
- 32,97,114,101,32,110,101,118,101,114,32,112,97,99,107,97,
- 103,101,115,46,70,114,10,0,0,0,114,170,0,0,0,114,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,114,116,
- 0,0,0,14,3,0,0,115,2,0,0,0,0,4,122,26,
- 66,117,105,108,116,105,110,73,109,112,111,114,116,101,114,46,
- 105,115,95,112,97,99,107,97,103,101,41,2,78,78,41,1,
- 78,41,18,114,1,0,0,0,114,0,0,0,0,114,2,0,
- 0,0,114,3,0,0,0,114,139,0,0,0,218,12,115,116,
- 97,116,105,99,109,101,116,104,111,100,114,100,0,0,0,218,
- 11,99,108,97,115,115,109,101,116,104,111,100,114,168,0,0,
- 0,114,169,0,0,0,114,150,0,0,0,114,151,0,0,0,
- 114,87,0,0,0,114,171,0,0,0,114,172,0,0,0,114,
- 116,0,0,0,114,98,0,0,0,114,156,0,0,0,114,10,
- 0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,
- 0,0,114,161,0,0,0,204,2,0,0,115,44,0,0,0,
- 8,2,4,7,4,2,2,1,10,8,2,1,12,8,2,1,
- 12,11,2,1,10,7,2,1,10,4,2,1,2,1,12,4,
- 2,1,2,1,12,4,2,1,2,1,12,4,114,161,0,0,
- 0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,4,0,0,0,64,0,0,0,115,144,0,0,0,101,
- 0,90,1,100,0,90,2,100,1,90,3,100,2,90,4,101,
- 5,100,3,100,4,132,0,131,1,90,6,101,7,100,22,100,
- 6,100,7,132,1,131,1,90,8,101,7,100,23,100,8,100,
- 9,132,1,131,1,90,9,101,7,100,10,100,11,132,0,131,
- 1,90,10,101,5,100,12,100,13,132,0,131,1,90,11,101,
- 7,100,14,100,15,132,0,131,1,90,12,101,7,101,13,100,
- 16,100,17,132,0,131,1,131,1,90,14,101,7,101,13,100,
- 18,100,19,132,0,131,1,131,1,90,15,101,7,101,13,100,
- 20,100,21,132,0,131,1,131,1,90,16,100,5,83,0,41,
- 24,218,14,70,114,111,122,101,110,73,109,112,111,114,116,101,
- 114,122,142,77,101,116,97,32,112,97,116,104,32,105,109,112,
- 111,114,116,32,102,111,114,32,102,114,111,122,101,110,32,109,
- 111,100,117,108,101,115,46,10,10,32,32,32,32,65,108,108,
- 32,109,101,116,104,111,100,115,32,97,114,101,32,101,105,116,
- 104,101,114,32,99,108,97,115,115,32,111,114,32,115,116,97,
- 116,105,99,32,109,101,116,104,111,100,115,32,116,111,32,97,
- 118,111,105,100,32,116,104,101,32,110,101,101,100,32,116,111,
- 10,32,32,32,32,105,110,115,116,97,110,116,105,97,116,101,
- 32,116,104,101,32,99,108,97,115,115,46,10,10,32,32,32,
- 32,90,6,102,114,111,122,101,110,99,1,0,0,0,0,0,
- 0,0,0,0,0,0,1,0,0,0,4,0,0,0,67,0,
- 0,0,115,16,0,0,0,100,1,160,0,124,0,106,1,116,
- 2,106,3,161,2,83,0,41,2,114,162,0,0,0,114,154,
- 0,0,0,41,4,114,46,0,0,0,114,1,0,0,0,114,
- 175,0,0,0,114,139,0,0,0,41,1,218,1,109,114,10,
- 0,0,0,114,10,0,0,0,114,11,0,0,0,114,100,0,
- 0,0,34,3,0,0,115,2,0,0,0,0,7,122,26,70,
- 114,111,122,101,110,73,109,112,111,114,116,101,114,46,109,111,
- 100,117,108,101,95,114,101,112,114,78,99,4,0,0,0,0,
- 0,0,0,0,0,0,0,4,0,0,0,5,0,0,0,67,
- 0,0,0,115,30,0,0,0,116,0,160,1,124,1,161,1,
- 114,26,116,2,124,1,124,0,124,0,106,3,100,1,141,3,
- 83,0,100,0,83,0,114,163,0,0,0,41,4,114,58,0,
- 0,0,114,89,0,0,0,114,92,0,0,0,114,139,0,0,
- 0,114,164,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,114,168,0,0,0,43,3,0,0,115,6,
- 0,0,0,0,2,10,1,16,2,122,24,70,114,111,122,101,
- 110,73,109,112,111,114,116,101,114,46,102,105,110,100,95,115,
- 112,101,99,99,3,0,0,0,0,0,0,0,0,0,0,0,
- 3,0,0,0,3,0,0,0,67,0,0,0,115,18,0,0,
- 0,116,0,160,1,124,1,161,1,114,14,124,0,83,0,100,
- 1,83,0,41,2,122,93,70,105,110,100,32,97,32,102,114,
- 111,122,101,110,32,109,111,100,117,108,101,46,10,10,32,32,
- 32,32,32,32,32,32,84,104,105,115,32,109,101,116,104,111,
- 100,32,105,115,32,100,101,112,114,101,99,97,116,101,100,46,
- 32,32,85,115,101,32,102,105,110,100,95,115,112,101,99,40,
- 41,32,105,110,115,116,101,97,100,46,10,10,32,32,32,32,
- 32,32,32,32,78,41,2,114,58,0,0,0,114,89,0,0,
- 0,41,3,114,165,0,0,0,114,82,0,0,0,114,166,0,
- 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
- 0,114,169,0,0,0,50,3,0,0,115,2,0,0,0,0,
- 7,122,26,70,114,111,122,101,110,73,109,112,111,114,116,101,
- 114,46,102,105,110,100,95,109,111,100,117,108,101,99,2,0,
- 0,0,0,0,0,0,0,0,0,0,2,0,0,0,1,0,
+ 32,115,111,117,114,99,101,32,99,111,100,101,46,78,114,5,
+ 0,0,0,114,179,0,0,0,114,5,0,0,0,114,5,0,
+ 0,0,114,6,0,0,0,218,10,103,101,116,95,115,111,117,
+ 114,99,101,26,3,0,0,115,4,0,0,0,4,4,255,128,
+ 122,26,66,117,105,108,116,105,110,73,109,112,111,114,116,101,
+ 114,46,103,101,116,95,115,111,117,114,99,101,99,2,0,0,
+ 0,0,0,0,0,0,0,0,0,2,0,0,0,1,0,0,
+ 0,67,0,0,0,115,4,0,0,0,100,1,83,0,41,3,
+ 122,52,82,101,116,117,114,110,32,70,97,108,115,101,32,97,
+ 115,32,98,117,105,108,116,45,105,110,32,109,111,100,117,108,
+ 101,115,32,97,114,101,32,110,101,118,101,114,32,112,97,99,
+ 107,97,103,101,115,46,70,78,114,5,0,0,0,114,179,0,
+ 0,0,114,5,0,0,0,114,5,0,0,0,114,6,0,0,
+ 0,114,122,0,0,0,32,3,0,0,115,4,0,0,0,4,
+ 4,255,128,122,26,66,117,105,108,116,105,110,73,109,112,111,
+ 114,116,101,114,46,105,115,95,112,97,99,107,97,103,101,41,
+ 2,78,78,41,1,78,41,18,114,9,0,0,0,114,8,0,
+ 0,0,114,1,0,0,0,114,10,0,0,0,114,145,0,0,
+ 0,218,12,115,116,97,116,105,99,109,101,116,104,111,100,114,
+ 107,0,0,0,218,11,99,108,97,115,115,109,101,116,104,111,
+ 100,114,177,0,0,0,114,178,0,0,0,114,156,0,0,0,
+ 114,157,0,0,0,114,90,0,0,0,114,180,0,0,0,114,
+ 181,0,0,0,114,122,0,0,0,114,105,0,0,0,114,164,
+ 0,0,0,114,5,0,0,0,114,5,0,0,0,114,5,0,
+ 0,0,114,6,0,0,0,114,169,0,0,0,222,2,0,0,
+ 115,48,0,0,0,8,0,4,2,4,7,2,2,10,1,2,
+ 8,12,1,2,8,12,1,2,11,10,1,2,7,10,1,2,
+ 4,2,1,12,1,2,4,2,1,12,1,2,4,2,1,12,
+ 1,12,4,255,128,114,169,0,0,0,99,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,64,
+ 0,0,0,115,144,0,0,0,101,0,90,1,100,0,90,2,
+ 100,1,90,3,100,2,90,4,101,5,100,3,100,4,132,0,
+ 131,1,90,6,101,7,100,22,100,6,100,7,132,1,131,1,
+ 90,8,101,7,100,23,100,8,100,9,132,1,131,1,90,9,
+ 101,5,100,10,100,11,132,0,131,1,90,10,101,5,100,12,
+ 100,13,132,0,131,1,90,11,101,7,100,14,100,15,132,0,
+ 131,1,90,12,101,7,101,13,100,16,100,17,132,0,131,1,
+ 131,1,90,14,101,7,101,13,100,18,100,19,132,0,131,1,
+ 131,1,90,15,101,7,101,13,100,20,100,21,132,0,131,1,
+ 131,1,90,16,100,5,83,0,41,24,218,14,70,114,111,122,
+ 101,110,73,109,112,111,114,116,101,114,122,142,77,101,116,97,
+ 32,112,97,116,104,32,105,109,112,111,114,116,32,102,111,114,
+ 32,102,114,111,122,101,110,32,109,111,100,117,108,101,115,46,
+ 10,10,32,32,32,32,65,108,108,32,109,101,116,104,111,100,
+ 115,32,97,114,101,32,101,105,116,104,101,114,32,99,108,97,
+ 115,115,32,111,114,32,115,116,97,116,105,99,32,109,101,116,
+ 104,111,100,115,32,116,111,32,97,118,111,105,100,32,116,104,
+ 101,32,110,101,101,100,32,116,111,10,32,32,32,32,105,110,
+ 115,116,97,110,116,105,97,116,101,32,116,104,101,32,99,108,
+ 97,115,115,46,10,10,32,32,32,32,90,6,102,114,111,122,
+ 101,110,99,1,0,0,0,0,0,0,0,0,0,0,0,1,
+ 0,0,0,4,0,0,0,67,0,0,0,115,16,0,0,0,
+ 100,1,160,0,124,0,106,1,116,2,106,3,161,2,83,0,
+ 41,3,114,170,0,0,0,114,160,0,0,0,78,41,4,114,
+ 49,0,0,0,114,9,0,0,0,114,184,0,0,0,114,145,
+ 0,0,0,41,1,218,1,109,114,5,0,0,0,114,5,0,
+ 0,0,114,6,0,0,0,114,107,0,0,0,52,3,0,0,
+ 115,4,0,0,0,16,7,255,128,122,26,70,114,111,122,101,
+ 110,73,109,112,111,114,116,101,114,46,109,111,100,117,108,101,
+ 95,114,101,112,114,78,99,4,0,0,0,0,0,0,0,0,
+ 0,0,0,4,0,0,0,5,0,0,0,67,0,0,0,115,
+ 30,0,0,0,116,0,160,1,124,1,161,1,114,26,116,2,
+ 124,1,124,0,124,0,106,3,100,1,141,3,83,0,100,0,
+ 83,0,114,172,0,0,0,41,4,114,61,0,0,0,114,92,
+ 0,0,0,114,98,0,0,0,114,145,0,0,0,114,173,0,
+ 0,0,114,5,0,0,0,114,5,0,0,0,114,6,0,0,
+ 0,114,177,0,0,0,61,3,0,0,115,8,0,0,0,10,
+ 2,16,1,4,2,255,128,122,24,70,114,111,122,101,110,73,
+ 109,112,111,114,116,101,114,46,102,105,110,100,95,115,112,101,
+ 99,99,3,0,0,0,0,0,0,0,0,0,0,0,3,0,
+ 0,0,3,0,0,0,67,0,0,0,115,18,0,0,0,116,
+ 0,160,1,124,1,161,1,114,14,124,0,83,0,100,1,83,
+ 0,41,2,122,93,70,105,110,100,32,97,32,102,114,111,122,
+ 101,110,32,109,111,100,117,108,101,46,10,10,32,32,32,32,
+ 32,32,32,32,84,104,105,115,32,109,101,116,104,111,100,32,
+ 105,115,32,100,101,112,114,101,99,97,116,101,100,46,32,32,
+ 85,115,101,32,102,105,110,100,95,115,112,101,99,40,41,32,
+ 105,110,115,116,101,97,100,46,10,10,32,32,32,32,32,32,
+ 32,32,78,41,2,114,61,0,0,0,114,92,0,0,0,41,
+ 3,114,174,0,0,0,114,85,0,0,0,114,175,0,0,0,
+ 114,5,0,0,0,114,5,0,0,0,114,6,0,0,0,114,
+ 178,0,0,0,68,3,0,0,115,4,0,0,0,18,7,255,
+ 128,122,26,70,114,111,122,101,110,73,109,112,111,114,116,101,
+ 114,46,102,105,110,100,95,109,111,100,117,108,101,99,1,0,
+ 0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,
0,0,67,0,0,0,115,4,0,0,0,100,1,83,0,41,
2,122,42,85,115,101,32,100,101,102,97,117,108,116,32,115,
101,109,97,110,116,105,99,115,32,102,111,114,32,109,111,100,
- 117,108,101,32,99,114,101,97,116,105,111,110,46,78,114,10,
- 0,0,0,41,2,114,165,0,0,0,114,96,0,0,0,114,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,114,150,
- 0,0,0,59,3,0,0,115,2,0,0,0,0,2,122,28,
- 70,114,111,122,101,110,73,109,112,111,114,116,101,114,46,99,
- 114,101,97,116,101,95,109,111,100,117,108,101,99,1,0,0,
- 0,0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,
- 0,67,0,0,0,115,64,0,0,0,124,0,106,0,106,1,
- 125,1,116,2,160,3,124,1,161,1,115,36,116,4,100,1,
- 160,5,124,1,161,1,124,1,100,2,141,2,130,1,116,6,
- 116,2,106,7,124,1,131,2,125,2,116,8,124,2,124,0,
- 106,9,131,2,1,0,100,0,83,0,114,88,0,0,0,41,
- 10,114,106,0,0,0,114,17,0,0,0,114,58,0,0,0,
- 114,89,0,0,0,114,80,0,0,0,114,46,0,0,0,114,
- 68,0,0,0,218,17,103,101,116,95,102,114,111,122,101,110,
- 95,111,98,106,101,99,116,218,4,101,120,101,99,114,7,0,
- 0,0,41,3,114,97,0,0,0,114,17,0,0,0,218,4,
- 99,111,100,101,114,10,0,0,0,114,10,0,0,0,114,11,
- 0,0,0,114,151,0,0,0,63,3,0,0,115,14,0,0,
- 0,0,2,8,1,10,1,10,1,2,255,6,2,12,1,122,
- 26,70,114,111,122,101,110,73,109,112,111,114,116,101,114,46,
- 101,120,101,99,95,109,111,100,117,108,101,99,2,0,0,0,
- 0,0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,
- 67,0,0,0,115,10,0,0,0,116,0,124,0,124,1,131,
- 2,83,0,41,1,122,95,76,111,97,100,32,97,32,102,114,
- 111,122,101,110,32,109,111,100,117,108,101,46,10,10,32,32,
- 32,32,32,32,32,32,84,104,105,115,32,109,101,116,104,111,
- 100,32,105,115,32,100,101,112,114,101,99,97,116,101,100,46,
- 32,32,85,115,101,32,101,120,101,99,95,109,111,100,117,108,
- 101,40,41,32,105,110,115,116,101,97,100,46,10,10,32,32,
- 32,32,32,32,32,32,41,1,114,98,0,0,0,114,170,0,
- 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
- 0,114,156,0,0,0,72,3,0,0,115,2,0,0,0,0,
- 7,122,26,70,114,111,122,101,110,73,109,112,111,114,116,101,
+ 117,108,101,32,99,114,101,97,116,105,111,110,46,78,114,5,
+ 0,0,0,114,168,0,0,0,114,5,0,0,0,114,5,0,
+ 0,0,114,6,0,0,0,114,156,0,0,0,77,3,0,0,
+ 115,4,0,0,0,4,0,255,128,122,28,70,114,111,122,101,
+ 110,73,109,112,111,114,116,101,114,46,99,114,101,97,116,101,
+ 95,109,111,100,117,108,101,99,1,0,0,0,0,0,0,0,
+ 0,0,0,0,3,0,0,0,4,0,0,0,67,0,0,0,
+ 115,64,0,0,0,124,0,106,0,106,1,125,1,116,2,160,
+ 3,124,1,161,1,115,36,116,4,100,1,160,5,124,1,161,
+ 1,124,1,100,2,141,2,130,1,116,6,116,2,106,7,124,
+ 1,131,2,125,2,116,8,124,2,124,0,106,9,131,2,1,
+ 0,100,0,83,0,114,91,0,0,0,41,10,114,113,0,0,
+ 0,114,20,0,0,0,114,61,0,0,0,114,92,0,0,0,
+ 114,83,0,0,0,114,49,0,0,0,114,71,0,0,0,218,
+ 17,103,101,116,95,102,114,111,122,101,110,95,111,98,106,101,
+ 99,116,218,4,101,120,101,99,114,14,0,0,0,41,3,114,
+ 104,0,0,0,114,20,0,0,0,218,4,99,111,100,101,114,
+ 5,0,0,0,114,5,0,0,0,114,6,0,0,0,114,157,
+ 0,0,0,81,3,0,0,115,16,0,0,0,8,2,10,1,
+ 10,1,2,1,6,255,12,2,16,1,255,128,122,26,70,114,
+ 111,122,101,110,73,109,112,111,114,116,101,114,46,101,120,101,
+ 99,95,109,111,100,117,108,101,99,2,0,0,0,0,0,0,
+ 0,0,0,0,0,2,0,0,0,3,0,0,0,67,0,0,
+ 0,115,10,0,0,0,116,0,124,0,124,1,131,2,83,0,
+ 41,2,122,95,76,111,97,100,32,97,32,102,114,111,122,101,
+ 110,32,109,111,100,117,108,101,46,10,10,32,32,32,32,32,
+ 32,32,32,84,104,105,115,32,109,101,116,104,111,100,32,105,
+ 115,32,100,101,112,114,101,99,97,116,101,100,46,32,32,85,
+ 115,101,32,101,120,101,99,95,109,111,100,117,108,101,40,41,
+ 32,105,110,115,116,101,97,100,46,10,10,32,32,32,32,32,
+ 32,32,32,78,41,1,114,105,0,0,0,114,179,0,0,0,
+ 114,5,0,0,0,114,5,0,0,0,114,6,0,0,0,114,
+ 164,0,0,0,90,3,0,0,115,4,0,0,0,10,8,255,
+ 128,122,26,70,114,111,122,101,110,73,109,112,111,114,116,101,
114,46,108,111,97,100,95,109,111,100,117,108,101,99,2,0,
0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,0,
0,0,67,0,0,0,115,10,0,0,0,116,0,160,1,124,
- 1,161,1,83,0,41,1,122,45,82,101,116,117,114,110,32,
+ 1,161,1,83,0,41,2,122,45,82,101,116,117,114,110,32,
116,104,101,32,99,111,100,101,32,111,98,106,101,99,116,32,
102,111,114,32,116,104,101,32,102,114,111,122,101,110,32,109,
- 111,100,117,108,101,46,41,2,114,58,0,0,0,114,177,0,
- 0,0,114,170,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,114,171,0,0,0,81,3,0,0,115,
- 2,0,0,0,0,4,122,23,70,114,111,122,101,110,73,109,
- 112,111,114,116,101,114,46,103,101,116,95,99,111,100,101,99,
- 2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,
- 1,0,0,0,67,0,0,0,115,4,0,0,0,100,1,83,
- 0,41,2,122,54,82,101,116,117,114,110,32,78,111,110,101,
- 32,97,115,32,102,114,111,122,101,110,32,109,111,100,117,108,
- 101,115,32,100,111,32,110,111,116,32,104,97,118,101,32,115,
- 111,117,114,99,101,32,99,111,100,101,46,78,114,10,0,0,
- 0,114,170,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,114,172,0,0,0,87,3,0,0,115,2,
- 0,0,0,0,4,122,25,70,114,111,122,101,110,73,109,112,
- 111,114,116,101,114,46,103,101,116,95,115,111,117,114,99,101,
- 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
- 0,3,0,0,0,67,0,0,0,115,10,0,0,0,116,0,
- 160,1,124,1,161,1,83,0,41,1,122,46,82,101,116,117,
- 114,110,32,84,114,117,101,32,105,102,32,116,104,101,32,102,
- 114,111,122,101,110,32,109,111,100,117,108,101,32,105,115,32,
- 97,32,112,97,99,107,97,103,101,46,41,2,114,58,0,0,
- 0,90,17,105,115,95,102,114,111,122,101,110,95,112,97,99,
- 107,97,103,101,114,170,0,0,0,114,10,0,0,0,114,10,
- 0,0,0,114,11,0,0,0,114,116,0,0,0,93,3,0,
- 0,115,2,0,0,0,0,4,122,25,70,114,111,122,101,110,
- 73,109,112,111,114,116,101,114,46,105,115,95,112,97,99,107,
- 97,103,101,41,2,78,78,41,1,78,41,17,114,1,0,0,
- 0,114,0,0,0,0,114,2,0,0,0,114,3,0,0,0,
- 114,139,0,0,0,114,173,0,0,0,114,100,0,0,0,114,
- 174,0,0,0,114,168,0,0,0,114,169,0,0,0,114,150,
- 0,0,0,114,151,0,0,0,114,156,0,0,0,114,91,0,
- 0,0,114,171,0,0,0,114,172,0,0,0,114,116,0,0,
- 0,114,10,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,114,175,0,0,0,23,3,0,0,115,46,
- 0,0,0,8,2,4,7,4,2,2,1,10,8,2,1,12,
- 6,2,1,12,8,2,1,10,3,2,1,10,8,2,1,10,
- 8,2,1,2,1,12,4,2,1,2,1,12,4,2,1,2,
- 1,114,175,0,0,0,99,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,2,0,0,0,64,0,0,0,115,
- 32,0,0,0,101,0,90,1,100,0,90,2,100,1,90,3,
- 100,2,100,3,132,0,90,4,100,4,100,5,132,0,90,5,
- 100,6,83,0,41,7,218,18,95,73,109,112,111,114,116,76,
- 111,99,107,67,111,110,116,101,120,116,122,36,67,111,110,116,
- 101,120,116,32,109,97,110,97,103,101,114,32,102,111,114,32,
- 116,104,101,32,105,109,112,111,114,116,32,108,111,99,107,46,
- 99,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
- 0,2,0,0,0,67,0,0,0,115,12,0,0,0,116,0,
- 160,1,161,0,1,0,100,1,83,0,41,2,122,24,65,99,
- 113,117,105,114,101,32,116,104,101,32,105,109,112,111,114,116,
- 32,108,111,99,107,46,78,41,2,114,58,0,0,0,114,59,
- 0,0,0,114,48,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,114,55,0,0,0,106,3,0,0,
- 115,2,0,0,0,0,2,122,28,95,73,109,112,111,114,116,
- 76,111,99,107,67,111,110,116,101,120,116,46,95,95,101,110,
- 116,101,114,95,95,99,4,0,0,0,0,0,0,0,0,0,
- 0,0,4,0,0,0,2,0,0,0,67,0,0,0,115,12,
- 0,0,0,116,0,160,1,161,0,1,0,100,1,83,0,41,
- 2,122,60,82,101,108,101,97,115,101,32,116,104,101,32,105,
- 109,112,111,114,116,32,108,111,99,107,32,114,101,103,97,114,
- 100,108,101,115,115,32,111,102,32,97,110,121,32,114,97,105,
- 115,101,100,32,101,120,99,101,112,116,105,111,110,115,46,78,
- 41,2,114,58,0,0,0,114,61,0,0,0,41,4,114,30,
- 0,0,0,218,8,101,120,99,95,116,121,112,101,218,9,101,
- 120,99,95,118,97,108,117,101,218,13,101,120,99,95,116,114,
- 97,99,101,98,97,99,107,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,114,57,0,0,0,110,3,0,0,115,
- 2,0,0,0,0,2,122,27,95,73,109,112,111,114,116,76,
+ 111,100,117,108,101,46,78,41,2,114,61,0,0,0,114,186,
+ 0,0,0,114,179,0,0,0,114,5,0,0,0,114,5,0,
+ 0,0,114,6,0,0,0,114,180,0,0,0,100,3,0,0,
+ 115,4,0,0,0,10,4,255,128,122,23,70,114,111,122,101,
+ 110,73,109,112,111,114,116,101,114,46,103,101,116,95,99,111,
+ 100,101,99,2,0,0,0,0,0,0,0,0,0,0,0,2,
+ 0,0,0,1,0,0,0,67,0,0,0,115,4,0,0,0,
+ 100,1,83,0,41,2,122,54,82,101,116,117,114,110,32,78,
+ 111,110,101,32,97,115,32,102,114,111,122,101,110,32,109,111,
+ 100,117,108,101,115,32,100,111,32,110,111,116,32,104,97,118,
+ 101,32,115,111,117,114,99,101,32,99,111,100,101,46,78,114,
+ 5,0,0,0,114,179,0,0,0,114,5,0,0,0,114,5,
+ 0,0,0,114,6,0,0,0,114,181,0,0,0,106,3,0,
+ 0,115,4,0,0,0,4,4,255,128,122,25,70,114,111,122,
+ 101,110,73,109,112,111,114,116,101,114,46,103,101,116,95,115,
+ 111,117,114,99,101,99,2,0,0,0,0,0,0,0,0,0,
+ 0,0,2,0,0,0,3,0,0,0,67,0,0,0,115,10,
+ 0,0,0,116,0,160,1,124,1,161,1,83,0,41,2,122,
+ 46,82,101,116,117,114,110,32,84,114,117,101,32,105,102,32,
+ 116,104,101,32,102,114,111,122,101,110,32,109,111,100,117,108,
+ 101,32,105,115,32,97,32,112,97,99,107,97,103,101,46,78,
+ 41,2,114,61,0,0,0,90,17,105,115,95,102,114,111,122,
+ 101,110,95,112,97,99,107,97,103,101,114,179,0,0,0,114,
+ 5,0,0,0,114,5,0,0,0,114,6,0,0,0,114,122,
+ 0,0,0,112,3,0,0,115,4,0,0,0,10,4,255,128,
+ 122,25,70,114,111,122,101,110,73,109,112,111,114,116,101,114,
+ 46,105,115,95,112,97,99,107,97,103,101,41,2,78,78,41,
+ 1,78,41,17,114,9,0,0,0,114,8,0,0,0,114,1,
+ 0,0,0,114,10,0,0,0,114,145,0,0,0,114,182,0,
+ 0,0,114,107,0,0,0,114,183,0,0,0,114,177,0,0,
+ 0,114,178,0,0,0,114,156,0,0,0,114,157,0,0,0,
+ 114,164,0,0,0,114,94,0,0,0,114,180,0,0,0,114,
+ 181,0,0,0,114,122,0,0,0,114,5,0,0,0,114,5,
+ 0,0,0,114,5,0,0,0,114,6,0,0,0,114,184,0,
+ 0,0,41,3,0,0,115,50,0,0,0,8,0,4,2,4,
+ 7,2,2,10,1,2,8,12,1,2,6,12,1,2,8,10,
+ 1,2,3,10,1,2,8,10,1,2,9,2,1,12,1,2,
+ 4,2,1,12,1,2,4,2,1,16,1,255,128,114,184,0,
+ 0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,2,0,0,0,64,0,0,0,115,32,0,0,0,
+ 101,0,90,1,100,0,90,2,100,1,90,3,100,2,100,3,
+ 132,0,90,4,100,4,100,5,132,0,90,5,100,6,83,0,
+ 41,7,218,18,95,73,109,112,111,114,116,76,111,99,107,67,
+ 111,110,116,101,120,116,122,36,67,111,110,116,101,120,116,32,
+ 109,97,110,97,103,101,114,32,102,111,114,32,116,104,101,32,
+ 105,109,112,111,114,116,32,108,111,99,107,46,99,1,0,0,
+ 0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,
+ 0,67,0,0,0,115,12,0,0,0,116,0,160,1,161,0,
+ 1,0,100,1,83,0,41,2,122,24,65,99,113,117,105,114,
+ 101,32,116,104,101,32,105,109,112,111,114,116,32,108,111,99,
+ 107,46,78,41,2,114,61,0,0,0,114,62,0,0,0,114,
+ 51,0,0,0,114,5,0,0,0,114,5,0,0,0,114,6,
+ 0,0,0,114,58,0,0,0,125,3,0,0,115,4,0,0,
+ 0,12,2,255,128,122,28,95,73,109,112,111,114,116,76,111,
+ 99,107,67,111,110,116,101,120,116,46,95,95,101,110,116,101,
+ 114,95,95,99,4,0,0,0,0,0,0,0,0,0,0,0,
+ 4,0,0,0,2,0,0,0,67,0,0,0,115,12,0,0,
+ 0,116,0,160,1,161,0,1,0,100,1,83,0,41,2,122,
+ 60,82,101,108,101,97,115,101,32,116,104,101,32,105,109,112,
+ 111,114,116,32,108,111,99,107,32,114,101,103,97,114,100,108,
+ 101,115,115,32,111,102,32,97,110,121,32,114,97,105,115,101,
+ 100,32,101,120,99,101,112,116,105,111,110,115,46,78,41,2,
+ 114,61,0,0,0,114,64,0,0,0,41,4,114,33,0,0,
+ 0,218,8,101,120,99,95,116,121,112,101,218,9,101,120,99,
+ 95,118,97,108,117,101,218,13,101,120,99,95,116,114,97,99,
+ 101,98,97,99,107,114,5,0,0,0,114,5,0,0,0,114,
+ 6,0,0,0,114,60,0,0,0,129,3,0,0,115,4,0,
+ 0,0,12,2,255,128,122,27,95,73,109,112,111,114,116,76,
111,99,107,67,111,110,116,101,120,116,46,95,95,101,120,105,
- 116,95,95,78,41,6,114,1,0,0,0,114,0,0,0,0,
- 114,2,0,0,0,114,3,0,0,0,114,55,0,0,0,114,
- 57,0,0,0,114,10,0,0,0,114,10,0,0,0,114,10,
- 0,0,0,114,11,0,0,0,114,180,0,0,0,102,3,0,
- 0,115,6,0,0,0,8,2,4,2,8,4,114,180,0,0,
- 0,99,3,0,0,0,0,0,0,0,0,0,0,0,5,0,
- 0,0,5,0,0,0,67,0,0,0,115,64,0,0,0,124,
- 1,160,0,100,1,124,2,100,2,24,0,161,2,125,3,116,
- 1,124,3,131,1,124,2,107,0,114,36,116,2,100,3,131,
- 1,130,1,124,3,100,4,25,0,125,4,124,0,114,60,100,
- 5,160,3,124,4,124,0,161,2,83,0,124,4,83,0,41,
- 6,122,50,82,101,115,111,108,118,101,32,97,32,114,101,108,
- 97,116,105,118,101,32,109,111,100,117,108,101,32,110,97,109,
- 101,32,116,111,32,97,110,32,97,98,115,111,108,117,116,101,
- 32,111,110,101,46,114,129,0,0,0,114,39,0,0,0,122,
- 50,97,116,116,101,109,112,116,101,100,32,114,101,108,97,116,
- 105,118,101,32,105,109,112,111,114,116,32,98,101,121,111,110,
- 100,32,116,111,112,45,108,101,118,101,108,32,112,97,99,107,
- 97,103,101,114,22,0,0,0,250,5,123,125,46,123,125,41,
- 4,218,6,114,115,112,108,105,116,218,3,108,101,110,114,80,
- 0,0,0,114,46,0,0,0,41,5,114,17,0,0,0,218,
- 7,112,97,99,107,97,103,101,218,5,108,101,118,101,108,90,
- 4,98,105,116,115,90,4,98,97,115,101,114,10,0,0,0,
- 114,10,0,0,0,114,11,0,0,0,218,13,95,114,101,115,
- 111,108,118,101,95,110,97,109,101,115,3,0,0,115,10,0,
- 0,0,0,2,16,1,12,1,8,1,8,1,114,189,0,0,
- 0,99,3,0,0,0,0,0,0,0,0,0,0,0,4,0,
- 0,0,4,0,0,0,67,0,0,0,115,34,0,0,0,124,
- 0,160,0,124,1,124,2,161,2,125,3,124,3,100,0,117,
- 0,114,24,100,0,83,0,116,1,124,1,124,3,131,2,83,
- 0,114,13,0,0,0,41,2,114,169,0,0,0,114,92,0,
- 0,0,41,4,218,6,102,105,110,100,101,114,114,17,0,0,
- 0,114,166,0,0,0,114,110,0,0,0,114,10,0,0,0,
- 114,10,0,0,0,114,11,0,0,0,218,17,95,102,105,110,
- 100,95,115,112,101,99,95,108,101,103,97,99,121,124,3,0,
- 0,115,8,0,0,0,0,3,12,1,8,1,4,1,114,191,
- 0,0,0,99,3,0,0,0,0,0,0,0,0,0,0,0,
- 10,0,0,0,10,0,0,0,67,0,0,0,115,28,1,0,
- 0,116,0,106,1,125,3,124,3,100,1,117,0,114,22,116,
- 2,100,2,131,1,130,1,124,3,115,38,116,3,160,4,100,
- 3,116,5,161,2,1,0,124,0,116,0,106,6,118,0,125,
- 4,124,3,68,0,93,226,125,5,116,7,131,0,143,94,1,
- 0,122,10,124,5,106,8,125,6,87,0,110,54,4,0,116,
- 9,121,128,1,0,1,0,1,0,116,10,124,5,124,0,124,
- 1,131,3,125,7,124,7,100,1,117,0,114,124,89,0,87,
- 0,100,1,4,0,4,0,131,3,1,0,113,52,89,0,110,
- 14,48,0,124,6,124,0,124,1,124,2,131,3,125,7,87,
- 0,100,1,4,0,4,0,131,3,1,0,110,16,49,0,115,
- 162,48,0,1,0,1,0,1,0,89,0,1,0,124,7,100,
- 1,117,1,114,52,124,4,144,1,115,16,124,0,116,0,106,
- 6,118,0,144,1,114,16,116,0,106,6,124,0,25,0,125,
- 8,122,10,124,8,106,11,125,9,87,0,110,26,4,0,116,
- 9,121,244,1,0,1,0,1,0,124,7,6,0,89,0,2,
- 0,1,0,83,0,48,0,124,9,100,1,117,0,144,1,114,
- 8,124,7,2,0,1,0,83,0,124,9,2,0,1,0,83,
- 0,124,7,2,0,1,0,83,0,100,1,83,0,41,4,122,
- 21,70,105,110,100,32,97,32,109,111,100,117,108,101,39,115,
- 32,115,112,101,99,46,78,122,53,115,121,115,46,109,101,116,
- 97,95,112,97,116,104,32,105,115,32,78,111,110,101,44,32,
- 80,121,116,104,111,110,32,105,115,32,108,105,107,101,108,121,
- 32,115,104,117,116,116,105,110,103,32,100,111,119,110,122,22,
- 115,121,115,46,109,101,116,97,95,112,97,116,104,32,105,115,
- 32,101,109,112,116,121,41,12,114,15,0,0,0,218,9,109,
- 101,116,97,95,112,97,116,104,114,80,0,0,0,218,9,95,
- 119,97,114,110,105,110,103,115,218,4,119,97,114,110,218,13,
- 73,109,112,111,114,116,87,97,114,110,105,110,103,114,93,0,
- 0,0,114,180,0,0,0,114,168,0,0,0,114,107,0,0,
- 0,114,191,0,0,0,114,106,0,0,0,41,10,114,17,0,
- 0,0,114,166,0,0,0,114,167,0,0,0,114,192,0,0,
- 0,90,9,105,115,95,114,101,108,111,97,100,114,190,0,0,
- 0,114,168,0,0,0,114,96,0,0,0,114,97,0,0,0,
- 114,106,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
- 11,0,0,0,218,10,95,102,105,110,100,95,115,112,101,99,
- 133,3,0,0,115,54,0,0,0,0,2,6,1,8,2,8,
- 3,4,1,12,5,10,1,8,1,8,1,2,1,10,1,12,
- 1,12,1,8,1,22,2,42,1,8,2,18,1,10,1,2,
- 1,10,1,12,4,14,2,10,1,8,2,8,2,8,2,114,
- 196,0,0,0,99,3,0,0,0,0,0,0,0,0,0,0,
- 0,3,0,0,0,5,0,0,0,67,0,0,0,115,108,0,
- 0,0,116,0,124,0,116,1,131,2,115,28,116,2,100,1,
- 160,3,116,4,124,0,131,1,161,1,131,1,130,1,124,2,
- 100,2,107,0,114,44,116,5,100,3,131,1,130,1,124,2,
- 100,2,107,4,114,84,116,0,124,1,116,1,131,2,115,72,
- 116,2,100,4,131,1,130,1,110,12,124,1,115,84,116,6,
- 100,5,131,1,130,1,124,0,115,104,124,2,100,2,107,2,
- 114,104,116,5,100,6,131,1,130,1,100,7,83,0,41,8,
- 122,28,86,101,114,105,102,121,32,97,114,103,117,109,101,110,
- 116,115,32,97,114,101,32,34,115,97,110,101,34,46,122,31,
- 109,111,100,117,108,101,32,110,97,109,101,32,109,117,115,116,
- 32,98,101,32,115,116,114,44,32,110,111,116,32,123,125,114,
- 22,0,0,0,122,18,108,101,118,101,108,32,109,117,115,116,
- 32,98,101,32,62,61,32,48,122,31,95,95,112,97,99,107,
- 97,103,101,95,95,32,110,111,116,32,115,101,116,32,116,111,
- 32,97,32,115,116,114,105,110,103,122,54,97,116,116,101,109,
- 112,116,101,100,32,114,101,108,97,116,105,118,101,32,105,109,
- 112,111,114,116,32,119,105,116,104,32,110,111,32,107,110,111,
- 119,110,32,112,97,114,101,110,116,32,112,97,99,107,97,103,
- 101,122,17,69,109,112,116,121,32,109,111,100,117,108,101,32,
- 110,97,109,101,78,41,7,218,10,105,115,105,110,115,116,97,
- 110,99,101,218,3,115,116,114,218,9,84,121,112,101,69,114,
- 114,111,114,114,46,0,0,0,114,14,0,0,0,218,10,86,
- 97,108,117,101,69,114,114,111,114,114,80,0,0,0,169,3,
- 114,17,0,0,0,114,187,0,0,0,114,188,0,0,0,114,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,13,
- 95,115,97,110,105,116,121,95,99,104,101,99,107,180,3,0,
- 0,115,22,0,0,0,0,2,10,1,18,1,8,1,8,1,
- 8,1,10,1,10,1,4,1,8,2,12,1,114,202,0,0,
- 0,122,16,78,111,32,109,111,100,117,108,101,32,110,97,109,
- 101,100,32,122,4,123,33,114,125,99,2,0,0,0,0,0,
- 0,0,0,0,0,0,9,0,0,0,8,0,0,0,67,0,
- 0,0,115,22,1,0,0,100,0,125,2,124,0,160,0,100,
- 1,161,1,100,2,25,0,125,3,124,3,114,132,124,3,116,
- 1,106,2,118,1,114,42,116,3,124,1,124,3,131,2,1,
- 0,124,0,116,1,106,2,118,0,114,62,116,1,106,2,124,
- 0,25,0,83,0,116,1,106,2,124,3,25,0,125,4,122,
- 10,124,4,106,4,125,2,87,0,110,48,4,0,116,5,121,
- 130,1,0,1,0,1,0,116,6,100,3,23,0,160,7,124,
+ 116,95,95,78,41,6,114,9,0,0,0,114,8,0,0,0,
+ 114,1,0,0,0,114,10,0,0,0,114,58,0,0,0,114,
+ 60,0,0,0,114,5,0,0,0,114,5,0,0,0,114,5,
+ 0,0,0,114,6,0,0,0,114,189,0,0,0,121,3,0,
+ 0,115,10,0,0,0,8,0,4,2,8,2,12,4,255,128,
+ 114,189,0,0,0,99,3,0,0,0,0,0,0,0,0,0,
+ 0,0,5,0,0,0,5,0,0,0,67,0,0,0,115,64,
+ 0,0,0,124,1,160,0,100,1,124,2,100,2,24,0,161,
+ 2,125,3,116,1,124,3,131,1,124,2,107,0,114,36,116,
+ 2,100,3,131,1,130,1,124,3,100,4,25,0,125,4,124,
+ 0,114,60,100,5,160,3,124,4,124,0,161,2,83,0,124,
+ 4,83,0,41,7,122,50,82,101,115,111,108,118,101,32,97,
+ 32,114,101,108,97,116,105,118,101,32,109,111,100,117,108,101,
+ 32,110,97,109,101,32,116,111,32,97,110,32,97,98,115,111,
+ 108,117,116,101,32,111,110,101,46,114,135,0,0,0,114,42,
+ 0,0,0,122,50,97,116,116,101,109,112,116,101,100,32,114,
+ 101,108,97,116,105,118,101,32,105,109,112,111,114,116,32,98,
+ 101,121,111,110,100,32,116,111,112,45,108,101,118,101,108,32,
+ 112,97,99,107,97,103,101,114,25,0,0,0,250,5,123,125,
+ 46,123,125,78,41,4,218,6,114,115,112,108,105,116,218,3,
+ 108,101,110,114,83,0,0,0,114,49,0,0,0,41,5,114,
+ 20,0,0,0,218,7,112,97,99,107,97,103,101,218,5,108,
+ 101,118,101,108,90,4,98,105,116,115,90,4,98,97,115,101,
+ 114,5,0,0,0,114,5,0,0,0,114,6,0,0,0,218,
+ 13,95,114,101,115,111,108,118,101,95,110,97,109,101,134,3,
+ 0,0,115,12,0,0,0,16,2,12,1,8,1,8,1,20,
+ 1,255,128,114,198,0,0,0,99,3,0,0,0,0,0,0,
+ 0,0,0,0,0,4,0,0,0,4,0,0,0,67,0,0,
+ 0,115,34,0,0,0,124,0,160,0,124,1,124,2,161,2,
+ 125,3,124,3,100,0,117,0,114,24,100,0,83,0,116,1,
+ 124,1,124,3,131,2,83,0,114,0,0,0,0,41,2,114,
+ 178,0,0,0,114,98,0,0,0,41,4,218,6,102,105,110,
+ 100,101,114,114,20,0,0,0,114,175,0,0,0,114,116,0,
+ 0,0,114,5,0,0,0,114,5,0,0,0,114,6,0,0,
+ 0,218,17,95,102,105,110,100,95,115,112,101,99,95,108,101,
+ 103,97,99,121,143,3,0,0,115,10,0,0,0,12,3,8,
+ 1,4,1,10,1,255,128,114,200,0,0,0,99,3,0,0,
+ 0,0,0,0,0,0,0,0,0,10,0,0,0,10,0,0,
+ 0,67,0,0,0,115,36,1,0,0,116,0,106,1,125,3,
+ 124,3,100,1,117,0,114,22,116,2,100,2,131,1,130,1,
+ 124,3,115,38,116,3,160,4,100,3,116,5,161,2,1,0,
+ 124,0,116,0,106,6,118,0,125,4,124,3,68,0,93,230,
+ 125,5,116,7,131,0,143,94,1,0,122,10,124,5,106,8,
+ 125,6,87,0,110,54,4,0,116,9,144,1,121,34,1,0,
+ 1,0,1,0,116,10,124,5,124,0,124,1,131,3,125,7,
+ 124,7,100,1,117,0,114,126,89,0,87,0,100,1,4,0,
+ 4,0,131,3,1,0,113,52,89,0,110,12,124,6,124,0,
+ 124,1,124,2,131,3,125,7,87,0,100,1,4,0,4,0,
+ 131,3,1,0,110,16,49,0,115,162,119,1,1,0,1,0,
+ 1,0,89,0,1,0,124,7,100,1,117,1,144,1,114,26,
+ 124,4,144,1,115,18,124,0,116,0,106,6,118,0,144,1,
+ 114,18,116,0,106,6,124,0,25,0,125,8,122,10,124,8,
+ 106,11,125,9,87,0,110,26,4,0,116,9,144,1,121,32,
+ 1,0,1,0,1,0,124,7,6,0,89,0,2,0,1,0,
+ 83,0,124,9,100,1,117,0,144,1,114,10,124,7,2,0,
+ 1,0,83,0,124,9,2,0,1,0,83,0,124,7,2,0,
+ 1,0,83,0,113,52,100,1,83,0,119,0,119,0,41,4,
+ 122,21,70,105,110,100,32,97,32,109,111,100,117,108,101,39,
+ 115,32,115,112,101,99,46,78,122,53,115,121,115,46,109,101,
+ 116,97,95,112,97,116,104,32,105,115,32,78,111,110,101,44,
+ 32,80,121,116,104,111,110,32,105,115,32,108,105,107,101,108,
+ 121,32,115,104,117,116,116,105,110,103,32,100,111,119,110,122,
+ 22,115,121,115,46,109,101,116,97,95,112,97,116,104,32,105,
+ 115,32,101,109,112,116,121,41,12,114,18,0,0,0,218,9,
+ 109,101,116,97,95,112,97,116,104,114,83,0,0,0,114,95,
+ 0,0,0,114,96,0,0,0,114,163,0,0,0,114,99,0,
+ 0,0,114,189,0,0,0,114,177,0,0,0,114,2,0,0,
+ 0,114,200,0,0,0,114,113,0,0,0,41,10,114,20,0,
+ 0,0,114,175,0,0,0,114,176,0,0,0,114,201,0,0,
+ 0,90,9,105,115,95,114,101,108,111,97,100,114,199,0,0,
+ 0,114,177,0,0,0,114,103,0,0,0,114,104,0,0,0,
+ 114,113,0,0,0,114,5,0,0,0,114,5,0,0,0,114,
+ 6,0,0,0,218,10,95,102,105,110,100,95,115,112,101,99,
+ 152,3,0,0,115,62,0,0,0,6,2,8,1,8,2,4,
+ 3,12,1,10,5,8,1,8,1,2,1,10,1,14,1,12,
+ 1,8,1,20,1,42,2,10,1,18,2,10,1,2,1,10,
+ 1,14,1,12,4,10,2,8,1,8,2,8,2,2,128,4,
+ 2,2,243,2,244,255,128,114,202,0,0,0,99,3,0,0,
+ 0,0,0,0,0,0,0,0,0,3,0,0,0,5,0,0,
+ 0,67,0,0,0,115,110,0,0,0,116,0,124,0,116,1,
+ 131,2,115,28,116,2,100,1,160,3,116,4,124,0,131,1,
+ 161,1,131,1,130,1,124,2,100,2,107,0,114,44,116,5,
+ 100,3,131,1,130,1,124,2,100,2,107,4,114,82,116,0,
+ 124,1,116,1,131,2,115,70,116,2,100,4,131,1,130,1,
+ 124,1,115,82,116,6,100,5,131,1,130,1,124,0,115,106,
+ 124,2,100,2,107,2,114,102,116,5,100,6,131,1,130,1,
+ 100,7,83,0,100,7,83,0,41,8,122,28,86,101,114,105,
+ 102,121,32,97,114,103,117,109,101,110,116,115,32,97,114,101,
+ 32,34,115,97,110,101,34,46,122,31,109,111,100,117,108,101,
+ 32,110,97,109,101,32,109,117,115,116,32,98,101,32,115,116,
+ 114,44,32,110,111,116,32,123,125,114,25,0,0,0,122,18,
+ 108,101,118,101,108,32,109,117,115,116,32,98,101,32,62,61,
+ 32,48,122,31,95,95,112,97,99,107,97,103,101,95,95,32,
+ 110,111,116,32,115,101,116,32,116,111,32,97,32,115,116,114,
+ 105,110,103,122,54,97,116,116,101,109,112,116,101,100,32,114,
+ 101,108,97,116,105,118,101,32,105,109,112,111,114,116,32,119,
+ 105,116,104,32,110,111,32,107,110,111,119,110,32,112,97,114,
+ 101,110,116,32,112,97,99,107,97,103,101,122,17,69,109,112,
+ 116,121,32,109,111,100,117,108,101,32,110,97,109,101,78,41,
+ 7,218,10,105,115,105,110,115,116,97,110,99,101,218,3,115,
+ 116,114,218,9,84,121,112,101,69,114,114,111,114,114,49,0,
+ 0,0,114,3,0,0,0,218,10,86,97,108,117,101,69,114,
+ 114,111,114,114,83,0,0,0,169,3,114,20,0,0,0,114,
+ 196,0,0,0,114,197,0,0,0,114,5,0,0,0,114,5,
+ 0,0,0,114,6,0,0,0,218,13,95,115,97,110,105,116,
+ 121,95,99,104,101,99,107,199,3,0,0,115,26,0,0,0,
+ 10,2,18,1,8,1,8,1,8,1,10,1,8,1,4,1,
+ 8,1,12,2,8,1,8,255,255,128,114,208,0,0,0,122,
+ 16,78,111,32,109,111,100,117,108,101,32,110,97,109,101,100,
+ 32,122,4,123,33,114,125,99,2,0,0,0,0,0,0,0,
+ 0,0,0,0,9,0,0,0,8,0,0,0,67,0,0,0,
+ 115,22,1,0,0,100,0,125,2,124,0,160,0,100,1,161,
+ 1,100,2,25,0,125,3,124,3,114,128,124,3,116,1,106,
+ 2,118,1,114,42,116,3,124,1,124,3,131,2,1,0,124,
+ 0,116,1,106,2,118,0,114,62,116,1,106,2,124,0,25,
+ 0,83,0,116,1,106,2,124,3,25,0,125,4,122,10,124,
+ 4,106,4,125,2,87,0,110,44,4,0,116,5,144,1,121,
+ 20,1,0,1,0,1,0,116,6,100,3,23,0,160,7,124,
0,124,3,161,2,125,5,116,8,124,5,124,0,100,4,141,
- 2,100,0,130,2,89,0,110,2,48,0,116,9,124,0,124,
- 2,131,2,125,6,124,6,100,0,117,0,114,170,116,8,116,
- 6,160,7,124,0,161,1,124,0,100,4,141,2,130,1,110,
- 8,116,10,124,6,131,1,125,7,124,3,144,1,114,18,116,
- 1,106,2,124,3,25,0,125,4,124,0,160,0,100,1,161,
- 1,100,5,25,0,125,8,122,16,116,11,124,4,124,8,124,
- 7,131,3,1,0,87,0,110,48,4,0,116,5,144,1,121,
- 16,1,0,1,0,1,0,100,6,124,3,155,2,100,7,124,
- 8,155,2,157,4,125,5,116,12,160,13,124,5,116,14,161,
- 2,1,0,89,0,110,2,48,0,124,7,83,0,41,8,78,
- 114,129,0,0,0,114,22,0,0,0,122,23,59,32,123,33,
- 114,125,32,105,115,32,110,111,116,32,97,32,112,97,99,107,
- 97,103,101,114,16,0,0,0,233,2,0,0,0,122,27,67,
- 97,110,110,111,116,32,115,101,116,32,97,110,32,97,116,116,
- 114,105,98,117,116,101,32,111,110,32,122,18,32,102,111,114,
- 32,99,104,105,108,100,32,109,111,100,117,108,101,32,41,15,
- 114,130,0,0,0,114,15,0,0,0,114,93,0,0,0,114,
- 68,0,0,0,114,142,0,0,0,114,107,0,0,0,218,8,
- 95,69,82,82,95,77,83,71,114,46,0,0,0,218,19,77,
- 111,100,117,108,101,78,111,116,70,111,117,110,100,69,114,114,
- 111,114,114,196,0,0,0,114,160,0,0,0,114,5,0,0,
- 0,114,193,0,0,0,114,194,0,0,0,114,195,0,0,0,
- 41,9,114,17,0,0,0,218,7,105,109,112,111,114,116,95,
- 114,166,0,0,0,114,131,0,0,0,90,13,112,97,114,101,
- 110,116,95,109,111,100,117,108,101,114,158,0,0,0,114,96,
- 0,0,0,114,97,0,0,0,90,5,99,104,105,108,100,114,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,23,
- 95,102,105,110,100,95,97,110,100,95,108,111,97,100,95,117,
- 110,108,111,99,107,101,100,199,3,0,0,115,52,0,0,0,
- 0,1,4,1,14,1,4,1,10,1,10,2,10,1,10,1,
- 10,1,2,1,10,1,12,1,16,1,20,1,10,1,8,1,
- 20,2,8,1,6,2,10,1,14,1,2,1,16,1,14,1,
- 16,1,18,1,114,207,0,0,0,99,2,0,0,0,0,0,
- 0,0,0,0,0,0,4,0,0,0,8,0,0,0,67,0,
- 0,0,115,128,0,0,0,116,0,124,0,131,1,143,62,1,
- 0,116,1,106,2,160,3,124,0,116,4,161,2,125,2,124,
- 2,116,4,117,0,114,56,116,5,124,0,124,1,131,2,87,
- 0,2,0,100,1,4,0,4,0,131,3,1,0,83,0,87,
- 0,100,1,4,0,4,0,131,3,1,0,110,16,49,0,115,
- 76,48,0,1,0,1,0,1,0,89,0,1,0,124,2,100,
- 1,117,0,114,116,100,2,160,6,124,0,161,1,125,3,116,
- 7,124,3,124,0,100,3,141,2,130,1,116,8,124,0,131,
- 1,1,0,124,2,83,0,41,4,122,25,70,105,110,100,32,
- 97,110,100,32,108,111,97,100,32,116,104,101,32,109,111,100,
- 117,108,101,46,78,122,40,105,109,112,111,114,116,32,111,102,
- 32,123,125,32,104,97,108,116,101,100,59,32,78,111,110,101,
- 32,105,110,32,115,121,115,46,109,111,100,117,108,101,115,114,
- 16,0,0,0,41,9,114,51,0,0,0,114,15,0,0,0,
- 114,93,0,0,0,114,35,0,0,0,218,14,95,78,69,69,
- 68,83,95,76,79,65,68,73,78,71,114,207,0,0,0,114,
- 46,0,0,0,114,205,0,0,0,114,66,0,0,0,41,4,
- 114,17,0,0,0,114,206,0,0,0,114,97,0,0,0,114,
- 76,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
- 0,0,0,218,14,95,102,105,110,100,95,97,110,100,95,108,
- 111,97,100,234,3,0,0,115,22,0,0,0,0,2,10,1,
- 14,1,8,1,54,2,8,1,4,1,2,255,4,2,12,2,
- 8,1,114,209,0,0,0,114,22,0,0,0,99,3,0,0,
- 0,0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,
- 0,67,0,0,0,115,42,0,0,0,116,0,124,0,124,1,
- 124,2,131,3,1,0,124,2,100,1,107,4,114,32,116,1,
- 124,0,124,1,124,2,131,3,125,0,116,2,124,0,116,3,
- 131,2,83,0,41,2,97,50,1,0,0,73,109,112,111,114,
- 116,32,97,110,100,32,114,101,116,117,114,110,32,116,104,101,
- 32,109,111,100,117,108,101,32,98,97,115,101,100,32,111,110,
- 32,105,116,115,32,110,97,109,101,44,32,116,104,101,32,112,
- 97,99,107,97,103,101,32,116,104,101,32,99,97,108,108,32,
- 105,115,10,32,32,32,32,98,101,105,110,103,32,109,97,100,
- 101,32,102,114,111,109,44,32,97,110,100,32,116,104,101,32,
- 108,101,118,101,108,32,97,100,106,117,115,116,109,101,110,116,
- 46,10,10,32,32,32,32,84,104,105,115,32,102,117,110,99,
- 116,105,111,110,32,114,101,112,114,101,115,101,110,116,115,32,
- 116,104,101,32,103,114,101,97,116,101,115,116,32,99,111,109,
- 109,111,110,32,100,101,110,111,109,105,110,97,116,111,114,32,
- 111,102,32,102,117,110,99,116,105,111,110,97,108,105,116,121,
- 10,32,32,32,32,98,101,116,119,101,101,110,32,105,109,112,
- 111,114,116,95,109,111,100,117,108,101,32,97,110,100,32,95,
- 95,105,109,112,111,114,116,95,95,46,32,84,104,105,115,32,
- 105,110,99,108,117,100,101,115,32,115,101,116,116,105,110,103,
- 32,95,95,112,97,99,107,97,103,101,95,95,32,105,102,10,
- 32,32,32,32,116,104,101,32,108,111,97,100,101,114,32,100,
- 105,100,32,110,111,116,46,10,10,32,32,32,32,114,22,0,
- 0,0,41,4,114,202,0,0,0,114,189,0,0,0,114,209,
- 0,0,0,218,11,95,103,99,100,95,105,109,112,111,114,116,
- 114,201,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
- 11,0,0,0,114,210,0,0,0,250,3,0,0,115,8,0,
- 0,0,0,9,12,1,8,1,12,1,114,210,0,0,0,169,
- 1,218,9,114,101,99,117,114,115,105,118,101,99,3,0,0,
- 0,0,0,0,0,1,0,0,0,8,0,0,0,11,0,0,
- 0,67,0,0,0,115,232,0,0,0,124,1,68,0,93,222,
- 125,4,116,0,124,4,116,1,131,2,115,66,124,3,114,34,
- 124,0,106,2,100,1,23,0,125,5,110,4,100,2,125,5,
- 116,3,100,3,124,5,155,0,100,4,116,4,124,4,131,1,
- 106,2,155,0,157,4,131,1,130,1,113,4,124,4,100,5,
- 107,2,114,108,124,3,115,226,116,5,124,0,100,6,131,2,
- 114,226,116,6,124,0,124,0,106,7,124,2,100,7,100,8,
- 141,4,1,0,113,4,116,5,124,0,124,4,131,2,115,4,
- 100,9,160,8,124,0,106,2,124,4,161,2,125,6,122,14,
- 116,9,124,2,124,6,131,2,1,0,87,0,113,4,4,0,
- 116,10,121,224,1,0,125,7,1,0,122,54,124,7,106,11,
- 124,6,107,2,114,202,116,12,106,13,160,14,124,6,116,15,
- 161,2,100,10,117,1,114,202,87,0,89,0,100,10,125,7,
- 126,7,113,4,130,0,87,0,89,0,100,10,125,7,126,7,
- 113,4,100,10,125,7,126,7,48,0,48,0,113,4,124,0,
- 83,0,41,11,122,238,70,105,103,117,114,101,32,111,117,116,
- 32,119,104,97,116,32,95,95,105,109,112,111,114,116,95,95,
- 32,115,104,111,117,108,100,32,114,101,116,117,114,110,46,10,
- 10,32,32,32,32,84,104,101,32,105,109,112,111,114,116,95,
- 32,112,97,114,97,109,101,116,101,114,32,105,115,32,97,32,
- 99,97,108,108,97,98,108,101,32,119,104,105,99,104,32,116,
- 97,107,101,115,32,116,104,101,32,110,97,109,101,32,111,102,
- 32,109,111,100,117,108,101,32,116,111,10,32,32,32,32,105,
- 109,112,111,114,116,46,32,73,116,32,105,115,32,114,101,113,
- 117,105,114,101,100,32,116,111,32,100,101,99,111,117,112,108,
- 101,32,116,104,101,32,102,117,110,99,116,105,111,110,32,102,
- 114,111,109,32,97,115,115,117,109,105,110,103,32,105,109,112,
- 111,114,116,108,105,98,39,115,10,32,32,32,32,105,109,112,
- 111,114,116,32,105,109,112,108,101,109,101,110,116,97,116,105,
- 111,110,32,105,115,32,100,101,115,105,114,101,100,46,10,10,
- 32,32,32,32,122,8,46,95,95,97,108,108,95,95,122,13,
- 96,96,102,114,111,109,32,108,105,115,116,39,39,122,8,73,
- 116,101,109,32,105,110,32,122,18,32,109,117,115,116,32,98,
- 101,32,115,116,114,44,32,110,111,116,32,250,1,42,218,7,
- 95,95,97,108,108,95,95,84,114,211,0,0,0,114,184,0,
- 0,0,78,41,16,114,197,0,0,0,114,198,0,0,0,114,
- 1,0,0,0,114,199,0,0,0,114,14,0,0,0,114,4,
- 0,0,0,218,16,95,104,97,110,100,108,101,95,102,114,111,
- 109,108,105,115,116,114,214,0,0,0,114,46,0,0,0,114,
- 68,0,0,0,114,205,0,0,0,114,17,0,0,0,114,15,
- 0,0,0,114,93,0,0,0,114,35,0,0,0,114,208,0,
- 0,0,41,8,114,97,0,0,0,218,8,102,114,111,109,108,
- 105,115,116,114,206,0,0,0,114,212,0,0,0,218,1,120,
- 90,5,119,104,101,114,101,90,9,102,114,111,109,95,110,97,
- 109,101,90,3,101,120,99,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,114,215,0,0,0,9,4,0,0,115,
- 48,0,0,0,0,10,8,1,10,1,4,1,12,2,4,1,
- 10,1,8,255,10,2,8,1,14,1,10,1,2,255,8,2,
- 10,1,14,1,2,1,14,1,14,4,10,1,16,255,2,2,
- 12,1,26,1,114,215,0,0,0,99,1,0,0,0,0,0,
- 0,0,0,0,0,0,3,0,0,0,6,0,0,0,67,0,
- 0,0,115,146,0,0,0,124,0,160,0,100,1,161,1,125,
- 1,124,0,160,0,100,2,161,1,125,2,124,1,100,3,117,
- 1,114,82,124,2,100,3,117,1,114,78,124,1,124,2,106,
- 1,107,3,114,78,116,2,106,3,100,4,124,1,155,2,100,
- 5,124,2,106,1,155,2,100,6,157,5,116,4,100,7,100,
- 8,141,3,1,0,124,1,83,0,124,2,100,3,117,1,114,
- 96,124,2,106,1,83,0,116,2,106,3,100,9,116,4,100,
- 7,100,8,141,3,1,0,124,0,100,10,25,0,125,1,100,
- 11,124,0,118,1,114,142,124,1,160,5,100,12,161,1,100,
- 13,25,0,125,1,124,1,83,0,41,14,122,167,67,97,108,
- 99,117,108,97,116,101,32,119,104,97,116,32,95,95,112,97,
- 99,107,97,103,101,95,95,32,115,104,111,117,108,100,32,98,
- 101,46,10,10,32,32,32,32,95,95,112,97,99,107,97,103,
- 101,95,95,32,105,115,32,110,111,116,32,103,117,97,114,97,
- 110,116,101,101,100,32,116,111,32,98,101,32,100,101,102,105,
- 110,101,100,32,111,114,32,99,111,117,108,100,32,98,101,32,
- 115,101,116,32,116,111,32,78,111,110,101,10,32,32,32,32,
- 116,111,32,114,101,112,114,101,115,101,110,116,32,116,104,97,
- 116,32,105,116,115,32,112,114,111,112,101,114,32,118,97,108,
- 117,101,32,105,115,32,117,110,107,110,111,119,110,46,10,10,
- 32,32,32,32,114,146,0,0,0,114,106,0,0,0,78,122,
- 32,95,95,112,97,99,107,97,103,101,95,95,32,33,61,32,
- 95,95,115,112,101,99,95,95,46,112,97,114,101,110,116,32,
- 40,122,4,32,33,61,32,250,1,41,233,3,0,0,0,41,
- 1,90,10,115,116,97,99,107,108,101,118,101,108,122,89,99,
- 97,110,39,116,32,114,101,115,111,108,118,101,32,112,97,99,
- 107,97,103,101,32,102,114,111,109,32,95,95,115,112,101,99,
- 95,95,32,111,114,32,95,95,112,97,99,107,97,103,101,95,
- 95,44,32,102,97,108,108,105,110,103,32,98,97,99,107,32,
- 111,110,32,95,95,110,97,109,101,95,95,32,97,110,100,32,
- 95,95,112,97,116,104,95,95,114,1,0,0,0,114,142,0,
- 0,0,114,129,0,0,0,114,22,0,0,0,41,6,114,35,
- 0,0,0,114,131,0,0,0,114,193,0,0,0,114,194,0,
- 0,0,114,195,0,0,0,114,130,0,0,0,41,3,218,7,
- 103,108,111,98,97,108,115,114,187,0,0,0,114,96,0,0,
- 0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
- 218,17,95,99,97,108,99,95,95,95,112,97,99,107,97,103,
- 101,95,95,46,4,0,0,115,42,0,0,0,0,7,10,1,
- 10,1,8,1,18,1,6,1,2,255,4,1,4,255,6,2,
- 4,254,6,3,4,1,8,1,6,2,6,2,4,254,6,3,
- 8,1,8,1,14,1,114,221,0,0,0,114,10,0,0,0,
- 99,5,0,0,0,0,0,0,0,0,0,0,0,9,0,0,
- 0,5,0,0,0,67,0,0,0,115,174,0,0,0,124,4,
- 100,1,107,2,114,18,116,0,124,0,131,1,125,5,110,36,
- 124,1,100,2,117,1,114,30,124,1,110,2,105,0,125,6,
- 116,1,124,6,131,1,125,7,116,0,124,0,124,7,124,4,
- 131,3,125,5,124,3,115,148,124,4,100,1,107,2,114,84,
- 116,0,124,0,160,2,100,3,161,1,100,1,25,0,131,1,
- 83,0,124,0,115,92,124,5,83,0,116,3,124,0,131,1,
- 116,3,124,0,160,2,100,3,161,1,100,1,25,0,131,1,
- 24,0,125,8,116,4,106,5,124,5,106,6,100,2,116,3,
- 124,5,106,6,131,1,124,8,24,0,133,2,25,0,25,0,
- 83,0,116,7,124,5,100,4,131,2,114,170,116,8,124,5,
- 124,3,116,0,131,3,83,0,124,5,83,0,41,5,97,215,
- 1,0,0,73,109,112,111,114,116,32,97,32,109,111,100,117,
- 108,101,46,10,10,32,32,32,32,84,104,101,32,39,103,108,
- 111,98,97,108,115,39,32,97,114,103,117,109,101,110,116,32,
- 105,115,32,117,115,101,100,32,116,111,32,105,110,102,101,114,
- 32,119,104,101,114,101,32,116,104,101,32,105,109,112,111,114,
- 116,32,105,115,32,111,99,99,117,114,114,105,110,103,32,102,
- 114,111,109,10,32,32,32,32,116,111,32,104,97,110,100,108,
- 101,32,114,101,108,97,116,105,118,101,32,105,109,112,111,114,
- 116,115,46,32,84,104,101,32,39,108,111,99,97,108,115,39,
- 32,97,114,103,117,109,101,110,116,32,105,115,32,105,103,110,
- 111,114,101,100,46,32,84,104,101,10,32,32,32,32,39,102,
- 114,111,109,108,105,115,116,39,32,97,114,103,117,109,101,110,
- 116,32,115,112,101,99,105,102,105,101,115,32,119,104,97,116,
- 32,115,104,111,117,108,100,32,101,120,105,115,116,32,97,115,
- 32,97,116,116,114,105,98,117,116,101,115,32,111,110,32,116,
- 104,101,32,109,111,100,117,108,101,10,32,32,32,32,98,101,
- 105,110,103,32,105,109,112,111,114,116,101,100,32,40,101,46,
- 103,46,32,96,96,102,114,111,109,32,109,111,100,117,108,101,
- 32,105,109,112,111,114,116,32,60,102,114,111,109,108,105,115,
- 116,62,96,96,41,46,32,32,84,104,101,32,39,108,101,118,
- 101,108,39,10,32,32,32,32,97,114,103,117,109,101,110,116,
- 32,114,101,112,114,101,115,101,110,116,115,32,116,104,101,32,
- 112,97,99,107,97,103,101,32,108,111,99,97,116,105,111,110,
- 32,116,111,32,105,109,112,111,114,116,32,102,114,111,109,32,
- 105,110,32,97,32,114,101,108,97,116,105,118,101,10,32,32,
- 32,32,105,109,112,111,114,116,32,40,101,46,103,46,32,96,
- 96,102,114,111,109,32,46,46,112,107,103,32,105,109,112,111,
- 114,116,32,109,111,100,96,96,32,119,111,117,108,100,32,104,
- 97,118,101,32,97,32,39,108,101,118,101,108,39,32,111,102,
- 32,50,41,46,10,10,32,32,32,32,114,22,0,0,0,78,
- 114,129,0,0,0,114,142,0,0,0,41,9,114,210,0,0,
- 0,114,221,0,0,0,218,9,112,97,114,116,105,116,105,111,
- 110,114,186,0,0,0,114,15,0,0,0,114,93,0,0,0,
- 114,1,0,0,0,114,4,0,0,0,114,215,0,0,0,41,
- 9,114,17,0,0,0,114,220,0,0,0,218,6,108,111,99,
- 97,108,115,114,216,0,0,0,114,188,0,0,0,114,97,0,
- 0,0,90,8,103,108,111,98,97,108,115,95,114,187,0,0,
- 0,90,7,99,117,116,95,111,102,102,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,218,10,95,95,105,109,112,
- 111,114,116,95,95,73,4,0,0,115,30,0,0,0,0,11,
- 8,1,10,2,16,1,8,1,12,1,4,3,8,1,18,1,
- 4,1,4,4,26,3,30,1,10,1,12,2,114,224,0,0,
- 0,99,1,0,0,0,0,0,0,0,0,0,0,0,2,0,
- 0,0,3,0,0,0,67,0,0,0,115,38,0,0,0,116,
- 0,160,1,124,0,161,1,125,1,124,1,100,0,117,0,114,
- 30,116,2,100,1,124,0,23,0,131,1,130,1,116,3,124,
- 1,131,1,83,0,41,2,78,122,25,110,111,32,98,117,105,
- 108,116,45,105,110,32,109,111,100,117,108,101,32,110,97,109,
- 101,100,32,41,4,114,161,0,0,0,114,168,0,0,0,114,
- 80,0,0,0,114,160,0,0,0,41,2,114,17,0,0,0,
- 114,96,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
- 11,0,0,0,218,18,95,98,117,105,108,116,105,110,95,102,
- 114,111,109,95,110,97,109,101,110,4,0,0,115,8,0,0,
- 0,0,1,10,1,8,1,12,1,114,225,0,0,0,99,2,
- 0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,5,
- 0,0,0,67,0,0,0,115,166,0,0,0,124,1,97,0,
- 124,0,97,1,116,2,116,1,131,1,125,2,116,1,106,3,
- 160,4,161,0,68,0,93,72,92,2,125,3,125,4,116,5,
- 124,4,124,2,131,2,114,26,124,3,116,1,106,6,118,0,
- 114,60,116,7,125,5,110,18,116,0,160,8,124,3,161,1,
- 114,26,116,9,125,5,110,2,113,26,116,10,124,4,124,5,
- 131,2,125,6,116,11,124,6,124,4,131,2,1,0,113,26,
- 116,1,106,3,116,12,25,0,125,7,100,1,68,0,93,46,
- 125,8,124,8,116,1,106,3,118,1,114,138,116,13,124,8,
- 131,1,125,9,110,10,116,1,106,3,124,8,25,0,125,9,
- 116,14,124,7,124,8,124,9,131,3,1,0,113,114,100,2,
- 83,0,41,3,122,250,83,101,116,117,112,32,105,109,112,111,
- 114,116,108,105,98,32,98,121,32,105,109,112,111,114,116,105,
- 110,103,32,110,101,101,100,101,100,32,98,117,105,108,116,45,
- 105,110,32,109,111,100,117,108,101,115,32,97,110,100,32,105,
- 110,106,101,99,116,105,110,103,32,116,104,101,109,10,32,32,
- 32,32,105,110,116,111,32,116,104,101,32,103,108,111,98,97,
- 108,32,110,97,109,101,115,112,97,99,101,46,10,10,32,32,
- 32,32,65,115,32,115,121,115,32,105,115,32,110,101,101,100,
- 101,100,32,102,111,114,32,115,121,115,46,109,111,100,117,108,
- 101,115,32,97,99,99,101,115,115,32,97,110,100,32,95,105,
- 109,112,32,105,115,32,110,101,101,100,101,100,32,116,111,32,
- 108,111,97,100,32,98,117,105,108,116,45,105,110,10,32,32,
- 32,32,109,111,100,117,108,101,115,44,32,116,104,111,115,101,
- 32,116,119,111,32,109,111,100,117,108,101,115,32,109,117,115,
- 116,32,98,101,32,101,120,112,108,105,99,105,116,108,121,32,
- 112,97,115,115,101,100,32,105,110,46,10,10,32,32,32,32,
- 41,3,114,23,0,0,0,114,193,0,0,0,114,65,0,0,
- 0,78,41,15,114,58,0,0,0,114,15,0,0,0,114,14,
- 0,0,0,114,93,0,0,0,218,5,105,116,101,109,115,114,
- 197,0,0,0,114,79,0,0,0,114,161,0,0,0,114,89,
- 0,0,0,114,175,0,0,0,114,143,0,0,0,114,149,0,
- 0,0,114,1,0,0,0,114,225,0,0,0,114,5,0,0,
- 0,41,10,218,10,115,121,115,95,109,111,100,117,108,101,218,
- 11,95,105,109,112,95,109,111,100,117,108,101,90,11,109,111,
- 100,117,108,101,95,116,121,112,101,114,17,0,0,0,114,97,
- 0,0,0,114,110,0,0,0,114,96,0,0,0,90,11,115,
- 101,108,102,95,109,111,100,117,108,101,90,12,98,117,105,108,
- 116,105,110,95,110,97,109,101,90,14,98,117,105,108,116,105,
- 110,95,109,111,100,117,108,101,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,218,6,95,115,101,116,117,112,117,
- 4,0,0,115,36,0,0,0,0,9,4,1,4,3,8,1,
- 18,1,10,1,10,1,6,1,10,1,6,2,2,1,10,1,
- 12,3,10,1,8,1,10,1,10,2,10,1,114,229,0,0,
- 0,99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,
- 0,0,3,0,0,0,67,0,0,0,115,38,0,0,0,116,
- 0,124,0,124,1,131,2,1,0,116,1,106,2,160,3,116,
- 4,161,1,1,0,116,1,106,2,160,3,116,5,161,1,1,
- 0,100,1,83,0,41,2,122,48,73,110,115,116,97,108,108,
- 32,105,109,112,111,114,116,101,114,115,32,102,111,114,32,98,
- 117,105,108,116,105,110,32,97,110,100,32,102,114,111,122,101,
- 110,32,109,111,100,117,108,101,115,78,41,6,114,229,0,0,
- 0,114,15,0,0,0,114,192,0,0,0,114,120,0,0,0,
- 114,161,0,0,0,114,175,0,0,0,41,2,114,227,0,0,
- 0,114,228,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,218,8,95,105,110,115,116,97,108,108,152,
- 4,0,0,115,6,0,0,0,0,2,10,2,12,1,114,230,
- 0,0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,
- 1,0,0,0,4,0,0,0,67,0,0,0,115,32,0,0,
- 0,100,1,100,2,108,0,125,0,124,0,97,1,124,0,160,
- 2,116,3,106,4,116,5,25,0,161,1,1,0,100,2,83,
- 0,41,3,122,57,73,110,115,116,97,108,108,32,105,109,112,
- 111,114,116,101,114,115,32,116,104,97,116,32,114,101,113,117,
- 105,114,101,32,101,120,116,101,114,110,97,108,32,102,105,108,
- 101,115,121,115,116,101,109,32,97,99,99,101,115,115,114,22,
- 0,0,0,78,41,6,218,26,95,102,114,111,122,101,110,95,
- 105,109,112,111,114,116,108,105,98,95,101,120,116,101,114,110,
- 97,108,114,127,0,0,0,114,230,0,0,0,114,15,0,0,
- 0,114,93,0,0,0,114,1,0,0,0,41,1,114,231,0,
- 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
- 0,218,27,95,105,110,115,116,97,108,108,95,101,120,116,101,
- 114,110,97,108,95,105,109,112,111,114,116,101,114,115,160,4,
- 0,0,115,6,0,0,0,0,3,8,1,4,1,114,232,0,
- 0,0,41,2,78,78,41,1,78,41,2,78,114,22,0,0,
- 0,41,4,78,78,114,10,0,0,0,114,22,0,0,0,41,
- 50,114,3,0,0,0,114,127,0,0,0,114,12,0,0,0,
- 114,18,0,0,0,114,60,0,0,0,114,34,0,0,0,114,
- 44,0,0,0,114,19,0,0,0,114,20,0,0,0,114,50,
- 0,0,0,114,51,0,0,0,114,54,0,0,0,114,66,0,
- 0,0,114,68,0,0,0,114,77,0,0,0,114,87,0,0,
- 0,114,91,0,0,0,114,98,0,0,0,114,112,0,0,0,
- 114,113,0,0,0,114,92,0,0,0,114,143,0,0,0,114,
- 149,0,0,0,114,153,0,0,0,114,108,0,0,0,114,94,
- 0,0,0,114,159,0,0,0,114,160,0,0,0,114,95,0,
- 0,0,114,161,0,0,0,114,175,0,0,0,114,180,0,0,
- 0,114,189,0,0,0,114,191,0,0,0,114,196,0,0,0,
- 114,202,0,0,0,90,15,95,69,82,82,95,77,83,71,95,
- 80,82,69,70,73,88,114,204,0,0,0,114,207,0,0,0,
- 218,6,111,98,106,101,99,116,114,208,0,0,0,114,209,0,
- 0,0,114,210,0,0,0,114,215,0,0,0,114,221,0,0,
- 0,114,224,0,0,0,114,225,0,0,0,114,229,0,0,0,
- 114,230,0,0,0,114,232,0,0,0,114,10,0,0,0,114,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,8,
- 60,109,111,100,117,108,101,62,1,0,0,0,115,94,0,0,
- 0,4,24,4,2,8,8,8,8,4,2,4,3,16,4,14,
- 77,14,21,14,16,8,37,8,17,8,11,14,8,8,11,8,
- 12,8,16,8,36,14,101,16,26,10,45,14,72,8,17,8,
- 17,8,30,8,37,8,42,8,15,14,75,14,79,14,13,8,
- 9,8,9,10,47,8,16,4,1,8,2,8,32,6,3,8,
- 16,10,15,14,37,8,27,10,37,8,7,8,35,8,8,
+ 2,100,0,130,2,116,9,124,0,124,2,131,2,125,6,124,
+ 6,100,0,117,0,114,164,116,8,116,6,160,7,124,0,161,
+ 1,124,0,100,4,141,2,130,1,116,10,124,6,131,1,125,
+ 7,124,3,144,1,114,14,116,1,106,2,124,3,25,0,125,
+ 4,124,0,160,0,100,1,161,1,100,5,25,0,125,8,122,
+ 18,116,11,124,4,124,8,124,7,131,3,1,0,87,0,124,
+ 7,83,0,4,0,116,5,144,1,121,18,1,0,1,0,1,
+ 0,100,6,124,3,155,2,100,7,124,8,155,2,157,4,125,
+ 5,116,12,160,13,124,5,116,14,161,2,1,0,89,0,124,
+ 7,83,0,124,7,83,0,119,0,119,0,41,8,78,114,135,
+ 0,0,0,114,25,0,0,0,122,23,59,32,123,33,114,125,
+ 32,105,115,32,110,111,116,32,97,32,112,97,99,107,97,103,
+ 101,114,19,0,0,0,233,2,0,0,0,122,27,67,97,110,
+ 110,111,116,32,115,101,116,32,97,110,32,97,116,116,114,105,
+ 98,117,116,101,32,111,110,32,122,18,32,102,111,114,32,99,
+ 104,105,108,100,32,109,111,100,117,108,101,32,41,15,114,136,
+ 0,0,0,114,18,0,0,0,114,99,0,0,0,114,71,0,
+ 0,0,114,148,0,0,0,114,2,0,0,0,218,8,95,69,
+ 82,82,95,77,83,71,114,49,0,0,0,218,19,77,111,100,
+ 117,108,101,78,111,116,70,111,117,110,100,69,114,114,111,114,
+ 114,202,0,0,0,114,167,0,0,0,114,12,0,0,0,114,
+ 95,0,0,0,114,96,0,0,0,114,163,0,0,0,41,9,
+ 114,20,0,0,0,218,7,105,109,112,111,114,116,95,114,175,
+ 0,0,0,114,137,0,0,0,90,13,112,97,114,101,110,116,
+ 95,109,111,100,117,108,101,114,102,0,0,0,114,103,0,0,
+ 0,114,104,0,0,0,90,5,99,104,105,108,100,114,5,0,
+ 0,0,114,5,0,0,0,114,6,0,0,0,218,23,95,102,
+ 105,110,100,95,97,110,100,95,108,111,97,100,95,117,110,108,
+ 111,99,107,101,100,218,3,0,0,115,60,0,0,0,4,1,
+ 14,1,4,1,10,1,10,1,10,2,10,1,10,1,2,1,
+ 10,1,14,1,16,1,14,1,10,1,8,1,18,1,8,2,
+ 6,1,10,2,14,1,2,1,14,1,4,4,14,253,16,1,
+ 14,1,8,1,2,253,2,242,255,128,114,213,0,0,0,99,
+ 2,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,
+ 8,0,0,0,67,0,0,0,115,128,0,0,0,116,0,124,
+ 0,131,1,143,62,1,0,116,1,106,2,160,3,124,0,116,
+ 4,161,2,125,2,124,2,116,4,117,0,114,56,116,5,124,
+ 0,124,1,131,2,87,0,2,0,100,1,4,0,4,0,131,
+ 3,1,0,83,0,87,0,100,1,4,0,4,0,131,3,1,
+ 0,110,16,49,0,115,76,119,1,1,0,1,0,1,0,89,
+ 0,1,0,124,2,100,1,117,0,114,116,100,2,160,6,124,
+ 0,161,1,125,3,116,7,124,3,124,0,100,3,141,2,130,
+ 1,116,8,124,0,131,1,1,0,124,2,83,0,41,4,122,
+ 25,70,105,110,100,32,97,110,100,32,108,111,97,100,32,116,
+ 104,101,32,109,111,100,117,108,101,46,78,122,40,105,109,112,
+ 111,114,116,32,111,102,32,123,125,32,104,97,108,116,101,100,
+ 59,32,78,111,110,101,32,105,110,32,115,121,115,46,109,111,
+ 100,117,108,101,115,114,19,0,0,0,41,9,114,54,0,0,
+ 0,114,18,0,0,0,114,99,0,0,0,114,38,0,0,0,
+ 218,14,95,78,69,69,68,83,95,76,79,65,68,73,78,71,
+ 114,213,0,0,0,114,49,0,0,0,114,211,0,0,0,114,
+ 69,0,0,0,41,4,114,20,0,0,0,114,212,0,0,0,
+ 114,104,0,0,0,114,79,0,0,0,114,5,0,0,0,114,
+ 5,0,0,0,114,6,0,0,0,218,14,95,102,105,110,100,
+ 95,97,110,100,95,108,111,97,100,253,3,0,0,115,24,0,
+ 0,0,10,2,14,1,8,1,54,1,8,2,4,1,2,1,
+ 4,255,12,2,8,2,4,1,255,128,114,215,0,0,0,114,
+ 25,0,0,0,99,3,0,0,0,0,0,0,0,0,0,0,
+ 0,3,0,0,0,4,0,0,0,67,0,0,0,115,42,0,
+ 0,0,116,0,124,0,124,1,124,2,131,3,1,0,124,2,
+ 100,1,107,4,114,32,116,1,124,0,124,1,124,2,131,3,
+ 125,0,116,2,124,0,116,3,131,2,83,0,41,3,97,50,
+ 1,0,0,73,109,112,111,114,116,32,97,110,100,32,114,101,
+ 116,117,114,110,32,116,104,101,32,109,111,100,117,108,101,32,
+ 98,97,115,101,100,32,111,110,32,105,116,115,32,110,97,109,
+ 101,44,32,116,104,101,32,112,97,99,107,97,103,101,32,116,
+ 104,101,32,99,97,108,108,32,105,115,10,32,32,32,32,98,
+ 101,105,110,103,32,109,97,100,101,32,102,114,111,109,44,32,
+ 97,110,100,32,116,104,101,32,108,101,118,101,108,32,97,100,
+ 106,117,115,116,109,101,110,116,46,10,10,32,32,32,32,84,
+ 104,105,115,32,102,117,110,99,116,105,111,110,32,114,101,112,
+ 114,101,115,101,110,116,115,32,116,104,101,32,103,114,101,97,
+ 116,101,115,116,32,99,111,109,109,111,110,32,100,101,110,111,
+ 109,105,110,97,116,111,114,32,111,102,32,102,117,110,99,116,
+ 105,111,110,97,108,105,116,121,10,32,32,32,32,98,101,116,
+ 119,101,101,110,32,105,109,112,111,114,116,95,109,111,100,117,
+ 108,101,32,97,110,100,32,95,95,105,109,112,111,114,116,95,
+ 95,46,32,84,104,105,115,32,105,110,99,108,117,100,101,115,
+ 32,115,101,116,116,105,110,103,32,95,95,112,97,99,107,97,
+ 103,101,95,95,32,105,102,10,32,32,32,32,116,104,101,32,
+ 108,111,97,100,101,114,32,100,105,100,32,110,111,116,46,10,
+ 10,32,32,32,32,114,25,0,0,0,78,41,4,114,208,0,
+ 0,0,114,198,0,0,0,114,215,0,0,0,218,11,95,103,
+ 99,100,95,105,109,112,111,114,116,114,207,0,0,0,114,5,
+ 0,0,0,114,5,0,0,0,114,6,0,0,0,114,216,0,
+ 0,0,13,4,0,0,115,10,0,0,0,12,9,8,1,12,
+ 1,10,1,255,128,114,216,0,0,0,169,1,218,9,114,101,
+ 99,117,114,115,105,118,101,99,3,0,0,0,0,0,0,0,
+ 1,0,0,0,8,0,0,0,11,0,0,0,67,0,0,0,
+ 115,218,0,0,0,124,1,68,0,93,206,125,4,116,0,124,
+ 4,116,1,131,2,115,64,124,3,114,34,124,0,106,2,100,
+ 1,23,0,125,5,110,4,100,2,125,5,116,3,100,3,124,
+ 5,155,0,100,4,116,4,124,4,131,1,106,2,155,0,157,
+ 4,131,1,130,1,124,4,100,5,107,2,114,106,124,3,115,
+ 104,116,5,124,0,100,6,131,2,114,104,116,6,124,0,124,
+ 0,106,7,124,2,100,7,100,8,141,4,1,0,113,4,116,
+ 5,124,0,124,4,131,2,115,210,100,9,160,8,124,0,106,
+ 2,124,4,161,2,125,6,122,14,116,9,124,2,124,6,131,
+ 2,1,0,87,0,113,4,4,0,116,10,121,216,1,0,125,
+ 7,1,0,122,42,124,7,106,11,124,6,107,2,114,200,116,
+ 12,106,13,160,14,124,6,116,15,161,2,100,10,117,1,114,
+ 200,87,0,89,0,100,10,125,7,126,7,113,4,130,0,100,
+ 10,125,7,126,7,119,1,113,4,124,0,83,0,119,0,41,
+ 11,122,238,70,105,103,117,114,101,32,111,117,116,32,119,104,
+ 97,116,32,95,95,105,109,112,111,114,116,95,95,32,115,104,
+ 111,117,108,100,32,114,101,116,117,114,110,46,10,10,32,32,
+ 32,32,84,104,101,32,105,109,112,111,114,116,95,32,112,97,
+ 114,97,109,101,116,101,114,32,105,115,32,97,32,99,97,108,
+ 108,97,98,108,101,32,119,104,105,99,104,32,116,97,107,101,
+ 115,32,116,104,101,32,110,97,109,101,32,111,102,32,109,111,
+ 100,117,108,101,32,116,111,10,32,32,32,32,105,109,112,111,
+ 114,116,46,32,73,116,32,105,115,32,114,101,113,117,105,114,
+ 101,100,32,116,111,32,100,101,99,111,117,112,108,101,32,116,
+ 104,101,32,102,117,110,99,116,105,111,110,32,102,114,111,109,
+ 32,97,115,115,117,109,105,110,103,32,105,109,112,111,114,116,
+ 108,105,98,39,115,10,32,32,32,32,105,109,112,111,114,116,
+ 32,105,109,112,108,101,109,101,110,116,97,116,105,111,110,32,
+ 105,115,32,100,101,115,105,114,101,100,46,10,10,32,32,32,
+ 32,122,8,46,95,95,97,108,108,95,95,122,13,96,96,102,
+ 114,111,109,32,108,105,115,116,39,39,122,8,73,116,101,109,
+ 32,105,110,32,122,18,32,109,117,115,116,32,98,101,32,115,
+ 116,114,44,32,110,111,116,32,250,1,42,218,7,95,95,97,
+ 108,108,95,95,84,114,217,0,0,0,114,193,0,0,0,78,
+ 41,16,114,203,0,0,0,114,204,0,0,0,114,9,0,0,
+ 0,114,205,0,0,0,114,3,0,0,0,114,11,0,0,0,
+ 218,16,95,104,97,110,100,108,101,95,102,114,111,109,108,105,
+ 115,116,114,220,0,0,0,114,49,0,0,0,114,71,0,0,
+ 0,114,211,0,0,0,114,20,0,0,0,114,18,0,0,0,
+ 114,99,0,0,0,114,38,0,0,0,114,214,0,0,0,41,
+ 8,114,104,0,0,0,218,8,102,114,111,109,108,105,115,116,
+ 114,212,0,0,0,114,218,0,0,0,218,1,120,90,5,119,
+ 104,101,114,101,90,9,102,114,111,109,95,110,97,109,101,90,
+ 3,101,120,99,114,5,0,0,0,114,5,0,0,0,114,6,
+ 0,0,0,114,221,0,0,0,28,4,0,0,115,54,0,0,
+ 0,8,10,10,1,4,1,12,1,4,2,10,1,8,1,8,
+ 255,8,2,14,1,10,1,2,1,8,255,10,2,14,1,2,
+ 1,14,1,14,1,10,4,16,1,2,255,12,2,2,1,10,
+ 128,4,1,2,248,255,128,114,221,0,0,0,99,1,0,0,
+ 0,0,0,0,0,0,0,0,0,3,0,0,0,6,0,0,
+ 0,67,0,0,0,115,146,0,0,0,124,0,160,0,100,1,
+ 161,1,125,1,124,0,160,0,100,2,161,1,125,2,124,1,
+ 100,3,117,1,114,82,124,2,100,3,117,1,114,78,124,1,
+ 124,2,106,1,107,3,114,78,116,2,106,3,100,4,124,1,
+ 155,2,100,5,124,2,106,1,155,2,100,6,157,5,116,4,
+ 100,7,100,8,141,3,1,0,124,1,83,0,124,2,100,3,
+ 117,1,114,96,124,2,106,1,83,0,116,2,106,3,100,9,
+ 116,4,100,7,100,8,141,3,1,0,124,0,100,10,25,0,
+ 125,1,100,11,124,0,118,1,114,142,124,1,160,5,100,12,
+ 161,1,100,13,25,0,125,1,124,1,83,0,41,14,122,167,
+ 67,97,108,99,117,108,97,116,101,32,119,104,97,116,32,95,
+ 95,112,97,99,107,97,103,101,95,95,32,115,104,111,117,108,
+ 100,32,98,101,46,10,10,32,32,32,32,95,95,112,97,99,
+ 107,97,103,101,95,95,32,105,115,32,110,111,116,32,103,117,
+ 97,114,97,110,116,101,101,100,32,116,111,32,98,101,32,100,
+ 101,102,105,110,101,100,32,111,114,32,99,111,117,108,100,32,
+ 98,101,32,115,101,116,32,116,111,32,78,111,110,101,10,32,
+ 32,32,32,116,111,32,114,101,112,114,101,115,101,110,116,32,
+ 116,104,97,116,32,105,116,115,32,112,114,111,112,101,114,32,
+ 118,97,108,117,101,32,105,115,32,117,110,107,110,111,119,110,
+ 46,10,10,32,32,32,32,114,152,0,0,0,114,113,0,0,
+ 0,78,122,32,95,95,112,97,99,107,97,103,101,95,95,32,
+ 33,61,32,95,95,115,112,101,99,95,95,46,112,97,114,101,
+ 110,116,32,40,122,4,32,33,61,32,250,1,41,233,3,0,
+ 0,0,41,1,90,10,115,116,97,99,107,108,101,118,101,108,
+ 122,89,99,97,110,39,116,32,114,101,115,111,108,118,101,32,
+ 112,97,99,107,97,103,101,32,102,114,111,109,32,95,95,115,
+ 112,101,99,95,95,32,111,114,32,95,95,112,97,99,107,97,
+ 103,101,95,95,44,32,102,97,108,108,105,110,103,32,98,97,
+ 99,107,32,111,110,32,95,95,110,97,109,101,95,95,32,97,
+ 110,100,32,95,95,112,97,116,104,95,95,114,9,0,0,0,
+ 114,148,0,0,0,114,135,0,0,0,114,25,0,0,0,41,
+ 6,114,38,0,0,0,114,137,0,0,0,114,95,0,0,0,
+ 114,96,0,0,0,114,163,0,0,0,114,136,0,0,0,41,
+ 3,218,7,103,108,111,98,97,108,115,114,196,0,0,0,114,
+ 103,0,0,0,114,5,0,0,0,114,5,0,0,0,114,6,
+ 0,0,0,218,17,95,99,97,108,99,95,95,95,112,97,99,
+ 107,97,103,101,95,95,65,4,0,0,115,44,0,0,0,10,
+ 7,10,1,8,1,18,1,6,1,2,1,4,255,4,1,6,
+ 255,4,2,6,254,4,3,8,1,6,1,6,2,4,2,6,
+ 254,8,3,8,1,14,1,4,1,255,128,114,227,0,0,0,
+ 114,5,0,0,0,99,5,0,0,0,0,0,0,0,0,0,
+ 0,0,9,0,0,0,5,0,0,0,67,0,0,0,115,174,
+ 0,0,0,124,4,100,1,107,2,114,18,116,0,124,0,131,
+ 1,125,5,110,36,124,1,100,2,117,1,114,30,124,1,110,
+ 2,105,0,125,6,116,1,124,6,131,1,125,7,116,0,124,
+ 0,124,7,124,4,131,3,125,5,124,3,115,148,124,4,100,
+ 1,107,2,114,84,116,0,124,0,160,2,100,3,161,1,100,
+ 1,25,0,131,1,83,0,124,0,115,92,124,5,83,0,116,
+ 3,124,0,131,1,116,3,124,0,160,2,100,3,161,1,100,
+ 1,25,0,131,1,24,0,125,8,116,4,106,5,124,5,106,
+ 6,100,2,116,3,124,5,106,6,131,1,124,8,24,0,133,
+ 2,25,0,25,0,83,0,116,7,124,5,100,4,131,2,114,
+ 170,116,8,124,5,124,3,116,0,131,3,83,0,124,5,83,
+ 0,41,5,97,215,1,0,0,73,109,112,111,114,116,32,97,
+ 32,109,111,100,117,108,101,46,10,10,32,32,32,32,84,104,
+ 101,32,39,103,108,111,98,97,108,115,39,32,97,114,103,117,
+ 109,101,110,116,32,105,115,32,117,115,101,100,32,116,111,32,
+ 105,110,102,101,114,32,119,104,101,114,101,32,116,104,101,32,
+ 105,109,112,111,114,116,32,105,115,32,111,99,99,117,114,114,
+ 105,110,103,32,102,114,111,109,10,32,32,32,32,116,111,32,
+ 104,97,110,100,108,101,32,114,101,108,97,116,105,118,101,32,
+ 105,109,112,111,114,116,115,46,32,84,104,101,32,39,108,111,
+ 99,97,108,115,39,32,97,114,103,117,109,101,110,116,32,105,
+ 115,32,105,103,110,111,114,101,100,46,32,84,104,101,10,32,
+ 32,32,32,39,102,114,111,109,108,105,115,116,39,32,97,114,
+ 103,117,109,101,110,116,32,115,112,101,99,105,102,105,101,115,
+ 32,119,104,97,116,32,115,104,111,117,108,100,32,101,120,105,
+ 115,116,32,97,115,32,97,116,116,114,105,98,117,116,101,115,
+ 32,111,110,32,116,104,101,32,109,111,100,117,108,101,10,32,
+ 32,32,32,98,101,105,110,103,32,105,109,112,111,114,116,101,
+ 100,32,40,101,46,103,46,32,96,96,102,114,111,109,32,109,
+ 111,100,117,108,101,32,105,109,112,111,114,116,32,60,102,114,
+ 111,109,108,105,115,116,62,96,96,41,46,32,32,84,104,101,
+ 32,39,108,101,118,101,108,39,10,32,32,32,32,97,114,103,
+ 117,109,101,110,116,32,114,101,112,114,101,115,101,110,116,115,
+ 32,116,104,101,32,112,97,99,107,97,103,101,32,108,111,99,
+ 97,116,105,111,110,32,116,111,32,105,109,112,111,114,116,32,
+ 102,114,111,109,32,105,110,32,97,32,114,101,108,97,116,105,
+ 118,101,10,32,32,32,32,105,109,112,111,114,116,32,40,101,
+ 46,103,46,32,96,96,102,114,111,109,32,46,46,112,107,103,
+ 32,105,109,112,111,114,116,32,109,111,100,96,96,32,119,111,
+ 117,108,100,32,104,97,118,101,32,97,32,39,108,101,118,101,
+ 108,39,32,111,102,32,50,41,46,10,10,32,32,32,32,114,
+ 25,0,0,0,78,114,135,0,0,0,114,148,0,0,0,41,
+ 9,114,216,0,0,0,114,227,0,0,0,218,9,112,97,114,
+ 116,105,116,105,111,110,114,195,0,0,0,114,18,0,0,0,
+ 114,99,0,0,0,114,9,0,0,0,114,11,0,0,0,114,
+ 221,0,0,0,41,9,114,20,0,0,0,114,226,0,0,0,
+ 218,6,108,111,99,97,108,115,114,222,0,0,0,114,197,0,
+ 0,0,114,104,0,0,0,90,8,103,108,111,98,97,108,115,
+ 95,114,196,0,0,0,90,7,99,117,116,95,111,102,102,114,
+ 5,0,0,0,114,5,0,0,0,114,6,0,0,0,218,10,
+ 95,95,105,109,112,111,114,116,95,95,92,4,0,0,115,32,
+ 0,0,0,8,11,10,1,16,2,8,1,12,1,4,1,8,
+ 3,18,1,4,1,4,1,26,4,30,3,10,1,12,1,4,
+ 2,255,128,114,230,0,0,0,99,1,0,0,0,0,0,0,
+ 0,0,0,0,0,2,0,0,0,3,0,0,0,67,0,0,
+ 0,115,38,0,0,0,116,0,160,1,124,0,161,1,125,1,
+ 124,1,100,0,117,0,114,30,116,2,100,1,124,0,23,0,
+ 131,1,130,1,116,3,124,1,131,1,83,0,41,2,78,122,
+ 25,110,111,32,98,117,105,108,116,45,105,110,32,109,111,100,
+ 117,108,101,32,110,97,109,101,100,32,41,4,114,169,0,0,
+ 0,114,177,0,0,0,114,83,0,0,0,114,167,0,0,0,
+ 41,2,114,20,0,0,0,114,103,0,0,0,114,5,0,0,
+ 0,114,5,0,0,0,114,6,0,0,0,218,18,95,98,117,
+ 105,108,116,105,110,95,102,114,111,109,95,110,97,109,101,129,
+ 4,0,0,115,10,0,0,0,10,1,8,1,12,1,8,1,
+ 255,128,114,231,0,0,0,99,2,0,0,0,0,0,0,0,
+ 0,0,0,0,10,0,0,0,5,0,0,0,67,0,0,0,
+ 115,166,0,0,0,124,1,97,0,124,0,97,1,116,2,116,
+ 1,131,1,125,2,116,1,106,3,160,4,161,0,68,0,93,
+ 72,92,2,125,3,125,4,116,5,124,4,124,2,131,2,114,
+ 98,124,3,116,1,106,6,118,0,114,60,116,7,125,5,110,
+ 18,116,0,160,8,124,3,161,1,114,76,116,9,125,5,110,
+ 2,113,26,116,10,124,4,124,5,131,2,125,6,116,11,124,
+ 6,124,4,131,2,1,0,113,26,116,1,106,3,116,12,25,
+ 0,125,7,100,1,68,0,93,46,125,8,124,8,116,1,106,
+ 3,118,1,114,138,116,13,124,8,131,1,125,9,110,10,116,
+ 1,106,3,124,8,25,0,125,9,116,14,124,7,124,8,124,
+ 9,131,3,1,0,113,114,100,2,83,0,41,3,122,250,83,
+ 101,116,117,112,32,105,109,112,111,114,116,108,105,98,32,98,
+ 121,32,105,109,112,111,114,116,105,110,103,32,110,101,101,100,
+ 101,100,32,98,117,105,108,116,45,105,110,32,109,111,100,117,
+ 108,101,115,32,97,110,100,32,105,110,106,101,99,116,105,110,
+ 103,32,116,104,101,109,10,32,32,32,32,105,110,116,111,32,
+ 116,104,101,32,103,108,111,98,97,108,32,110,97,109,101,115,
+ 112,97,99,101,46,10,10,32,32,32,32,65,115,32,115,121,
+ 115,32,105,115,32,110,101,101,100,101,100,32,102,111,114,32,
+ 115,121,115,46,109,111,100,117,108,101,115,32,97,99,99,101,
+ 115,115,32,97,110,100,32,95,105,109,112,32,105,115,32,110,
+ 101,101,100,101,100,32,116,111,32,108,111,97,100,32,98,117,
+ 105,108,116,45,105,110,10,32,32,32,32,109,111,100,117,108,
+ 101,115,44,32,116,104,111,115,101,32,116,119,111,32,109,111,
+ 100,117,108,101,115,32,109,117,115,116,32,98,101,32,101,120,
+ 112,108,105,99,105,116,108,121,32,112,97,115,115,101,100,32,
+ 105,110,46,10,10,32,32,32,32,41,3,114,26,0,0,0,
+ 114,95,0,0,0,114,68,0,0,0,78,41,15,114,61,0,
+ 0,0,114,18,0,0,0,114,3,0,0,0,114,99,0,0,
+ 0,218,5,105,116,101,109,115,114,203,0,0,0,114,82,0,
+ 0,0,114,169,0,0,0,114,92,0,0,0,114,184,0,0,
+ 0,114,149,0,0,0,114,155,0,0,0,114,9,0,0,0,
+ 114,231,0,0,0,114,12,0,0,0,41,10,218,10,115,121,
+ 115,95,109,111,100,117,108,101,218,11,95,105,109,112,95,109,
+ 111,100,117,108,101,90,11,109,111,100,117,108,101,95,116,121,
+ 112,101,114,20,0,0,0,114,104,0,0,0,114,116,0,0,
+ 0,114,103,0,0,0,90,11,115,101,108,102,95,109,111,100,
+ 117,108,101,90,12,98,117,105,108,116,105,110,95,110,97,109,
+ 101,90,14,98,117,105,108,116,105,110,95,109,111,100,117,108,
+ 101,114,5,0,0,0,114,5,0,0,0,114,6,0,0,0,
+ 218,6,95,115,101,116,117,112,136,4,0,0,115,42,0,0,
+ 0,4,9,4,1,8,3,18,1,10,1,10,1,6,1,10,
+ 1,6,1,2,2,10,1,10,1,2,128,10,3,8,1,10,
+ 1,10,1,10,2,14,1,4,251,255,128,114,235,0,0,0,
+ 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
+ 0,3,0,0,0,67,0,0,0,115,38,0,0,0,116,0,
+ 124,0,124,1,131,2,1,0,116,1,106,2,160,3,116,4,
+ 161,1,1,0,116,1,106,2,160,3,116,5,161,1,1,0,
+ 100,1,83,0,41,2,122,48,73,110,115,116,97,108,108,32,
+ 105,109,112,111,114,116,101,114,115,32,102,111,114,32,98,117,
+ 105,108,116,105,110,32,97,110,100,32,102,114,111,122,101,110,
+ 32,109,111,100,117,108,101,115,78,41,6,114,235,0,0,0,
+ 114,18,0,0,0,114,201,0,0,0,114,126,0,0,0,114,
+ 169,0,0,0,114,184,0,0,0,41,2,114,233,0,0,0,
+ 114,234,0,0,0,114,5,0,0,0,114,5,0,0,0,114,
+ 6,0,0,0,218,8,95,105,110,115,116,97,108,108,171,4,
+ 0,0,115,8,0,0,0,10,2,12,2,16,1,255,128,114,
+ 236,0,0,0,99,0,0,0,0,0,0,0,0,0,0,0,
+ 0,1,0,0,0,4,0,0,0,67,0,0,0,115,32,0,
+ 0,0,100,1,100,2,108,0,125,0,124,0,97,1,124,0,
+ 160,2,116,3,106,4,116,5,25,0,161,1,1,0,100,2,
+ 83,0,41,3,122,57,73,110,115,116,97,108,108,32,105,109,
+ 112,111,114,116,101,114,115,32,116,104,97,116,32,114,101,113,
+ 117,105,114,101,32,101,120,116,101,114,110,97,108,32,102,105,
+ 108,101,115,121,115,116,101,109,32,97,99,99,101,115,115,114,
+ 25,0,0,0,78,41,6,218,26,95,102,114,111,122,101,110,
+ 95,105,109,112,111,114,116,108,105,98,95,101,120,116,101,114,
+ 110,97,108,114,133,0,0,0,114,236,0,0,0,114,18,0,
+ 0,0,114,99,0,0,0,114,9,0,0,0,41,1,114,237,
+ 0,0,0,114,5,0,0,0,114,5,0,0,0,114,6,0,
+ 0,0,218,27,95,105,110,115,116,97,108,108,95,101,120,116,
+ 101,114,110,97,108,95,105,109,112,111,114,116,101,114,115,179,
+ 4,0,0,115,8,0,0,0,8,3,4,1,20,1,255,128,
+ 114,238,0,0,0,41,2,78,78,41,1,78,41,2,78,114,
+ 25,0,0,0,41,4,78,78,114,5,0,0,0,114,25,0,
+ 0,0,41,54,114,10,0,0,0,114,7,0,0,0,114,26,
+ 0,0,0,114,95,0,0,0,114,68,0,0,0,114,133,0,
+ 0,0,114,17,0,0,0,114,21,0,0,0,114,63,0,0,
+ 0,114,37,0,0,0,114,47,0,0,0,114,22,0,0,0,
+ 114,23,0,0,0,114,53,0,0,0,114,54,0,0,0,114,
+ 57,0,0,0,114,69,0,0,0,114,71,0,0,0,114,80,
+ 0,0,0,114,90,0,0,0,114,94,0,0,0,114,105,0,
+ 0,0,114,118,0,0,0,114,119,0,0,0,114,98,0,0,
+ 0,114,149,0,0,0,114,155,0,0,0,114,159,0,0,0,
+ 114,114,0,0,0,114,100,0,0,0,114,166,0,0,0,114,
+ 167,0,0,0,114,101,0,0,0,114,169,0,0,0,114,184,
+ 0,0,0,114,189,0,0,0,114,198,0,0,0,114,200,0,
+ 0,0,114,202,0,0,0,114,208,0,0,0,90,15,95,69,
+ 82,82,95,77,83,71,95,80,82,69,70,73,88,114,210,0,
+ 0,0,114,213,0,0,0,218,6,111,98,106,101,99,116,114,
+ 214,0,0,0,114,215,0,0,0,114,216,0,0,0,114,221,
+ 0,0,0,114,227,0,0,0,114,230,0,0,0,114,231,0,
+ 0,0,114,235,0,0,0,114,236,0,0,0,114,238,0,0,
+ 0,114,5,0,0,0,114,5,0,0,0,114,5,0,0,0,
+ 114,6,0,0,0,218,8,60,109,111,100,117,108,101,62,1,
+ 0,0,0,115,106,0,0,0,4,0,8,22,4,9,4,1,
+ 4,1,4,3,8,3,8,8,4,8,4,2,16,3,14,4,
+ 14,77,14,21,8,16,8,37,8,17,14,11,8,8,8,11,
+ 8,12,8,19,14,36,16,101,10,26,14,45,8,72,8,17,
+ 8,17,8,30,8,36,8,45,14,15,14,75,14,80,8,13,
+ 8,9,10,9,8,47,4,16,8,1,8,2,6,32,8,3,
+ 10,16,14,15,8,37,10,27,8,37,8,7,8,35,12,8,
+ 255,128,
};
diff --git a/Python/importlib_external.h b/Python/importlib_external.h
index 6daddb1fb8..93dcfb1410 100644
--- a/Python/importlib_external.h
+++ b/Python/importlib_external.h
@@ -1,615 +1,647 @@
/* Auto-generated by Programs/_freeze_importlib.c */
const unsigned char _Py_M__importlib_bootstrap_external[] = {
99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,5,0,0,0,64,0,0,0,115,32,2,0,0,100,0,
- 90,0,100,1,90,1,100,2,90,2,101,2,101,1,23,0,
- 90,3,100,3,100,4,132,0,90,4,100,5,100,6,132,0,
- 90,5,100,7,100,8,132,0,90,6,100,9,100,10,132,0,
- 90,7,100,11,100,12,132,0,90,8,100,13,100,14,132,0,
- 90,9,100,15,100,16,132,0,90,10,100,17,100,18,132,0,
- 90,11,100,19,100,20,132,0,90,12,100,21,100,22,132,0,
- 90,13,100,23,100,24,132,0,90,14,100,101,100,26,100,27,
- 132,1,90,15,101,16,101,15,106,17,131,1,90,18,100,28,
- 160,19,100,29,100,30,161,2,100,31,23,0,90,20,101,21,
- 160,22,101,20,100,30,161,2,90,23,100,32,90,24,100,33,
- 90,25,100,34,103,1,90,26,100,35,103,1,90,27,101,27,
- 4,0,90,28,90,29,100,102,100,36,100,37,156,1,100,38,
- 100,39,132,3,90,30,100,40,100,41,132,0,90,31,100,42,
- 100,43,132,0,90,32,100,44,100,45,132,0,90,33,100,46,
- 100,47,132,0,90,34,100,48,100,49,132,0,90,35,100,50,
- 100,51,132,0,90,36,100,52,100,53,132,0,90,37,100,54,
- 100,55,132,0,90,38,100,56,100,57,132,0,90,39,100,103,
- 100,58,100,59,132,1,90,40,100,104,100,61,100,62,132,1,
- 90,41,100,105,100,64,100,65,132,1,90,42,100,66,100,67,
- 132,0,90,43,101,44,131,0,90,45,100,106,100,36,101,45,
- 100,68,156,2,100,69,100,70,132,3,90,46,71,0,100,71,
- 100,72,132,0,100,72,131,2,90,47,71,0,100,73,100,74,
- 132,0,100,74,131,2,90,48,71,0,100,75,100,76,132,0,
- 100,76,101,48,131,3,90,49,71,0,100,77,100,78,132,0,
- 100,78,131,2,90,50,71,0,100,79,100,80,132,0,100,80,
- 101,50,101,49,131,4,90,51,71,0,100,81,100,82,132,0,
- 100,82,101,50,101,48,131,4,90,52,103,0,90,53,71,0,
- 100,83,100,84,132,0,100,84,101,50,101,48,131,4,90,54,
- 71,0,100,85,100,86,132,0,100,86,131,2,90,55,71,0,
- 100,87,100,88,132,0,100,88,131,2,90,56,71,0,100,89,
- 100,90,132,0,100,90,131,2,90,57,71,0,100,91,100,92,
- 132,0,100,92,131,2,90,58,100,107,100,93,100,94,132,1,
- 90,59,100,95,100,96,132,0,90,60,100,97,100,98,132,0,
- 90,61,100,99,100,100,132,0,90,62,100,36,83,0,41,108,
- 97,94,1,0,0,67,111,114,101,32,105,109,112,108,101,109,
- 101,110,116,97,116,105,111,110,32,111,102,32,112,97,116,104,
- 45,98,97,115,101,100,32,105,109,112,111,114,116,46,10,10,
- 84,104,105,115,32,109,111,100,117,108,101,32,105,115,32,78,
- 79,84,32,109,101,97,110,116,32,116,111,32,98,101,32,100,
- 105,114,101,99,116,108,121,32,105,109,112,111,114,116,101,100,
- 33,32,73,116,32,104,97,115,32,98,101,101,110,32,100,101,
- 115,105,103,110,101,100,32,115,117,99,104,10,116,104,97,116,
- 32,105,116,32,99,97,110,32,98,101,32,98,111,111,116,115,
- 116,114,97,112,112,101,100,32,105,110,116,111,32,80,121,116,
- 104,111,110,32,97,115,32,116,104,101,32,105,109,112,108,101,
- 109,101,110,116,97,116,105,111,110,32,111,102,32,105,109,112,
- 111,114,116,46,32,65,115,10,115,117,99,104,32,105,116,32,
- 114,101,113,117,105,114,101,115,32,116,104,101,32,105,110,106,
- 101,99,116,105,111,110,32,111,102,32,115,112,101,99,105,102,
- 105,99,32,109,111,100,117,108,101,115,32,97,110,100,32,97,
- 116,116,114,105,98,117,116,101,115,32,105,110,32,111,114,100,
- 101,114,32,116,111,10,119,111,114,107,46,32,79,110,101,32,
- 115,104,111,117,108,100,32,117,115,101,32,105,109,112,111,114,
- 116,108,105,98,32,97,115,32,116,104,101,32,112,117,98,108,
- 105,99,45,102,97,99,105,110,103,32,118,101,114,115,105,111,
- 110,32,111,102,32,116,104,105,115,32,109,111,100,117,108,101,
- 46,10,10,41,1,218,3,119,105,110,41,2,90,6,99,121,
- 103,119,105,110,90,6,100,97,114,119,105,110,99,0,0,0,
- 0,0,0,0,0,0,0,0,0,1,0,0,0,3,0,0,
- 0,3,0,0,0,115,60,0,0,0,116,0,106,1,160,2,
- 116,3,161,1,114,48,116,0,106,1,160,2,116,4,161,1,
- 114,30,100,1,137,0,110,4,100,2,137,0,135,0,102,1,
- 100,3,100,4,132,8,125,0,110,8,100,5,100,4,132,0,
- 125,0,124,0,83,0,41,6,78,90,12,80,89,84,72,79,
- 78,67,65,83,69,79,75,115,12,0,0,0,80,89,84,72,
- 79,78,67,65,83,69,79,75,99,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,2,0,0,0,19,0,0,
- 0,115,20,0,0,0,116,0,106,1,106,2,12,0,111,18,
- 136,0,116,3,106,4,118,0,83,0,41,1,122,94,84,114,
- 117,101,32,105,102,32,102,105,108,101,110,97,109,101,115,32,
- 109,117,115,116,32,98,101,32,99,104,101,99,107,101,100,32,
- 99,97,115,101,45,105,110,115,101,110,115,105,116,105,118,101,
- 108,121,32,97,110,100,32,105,103,110,111,114,101,32,101,110,
- 118,105,114,111,110,109,101,110,116,32,102,108,97,103,115,32,
- 97,114,101,32,110,111,116,32,115,101,116,46,41,5,218,3,
- 115,121,115,218,5,102,108,97,103,115,218,18,105,103,110,111,
- 114,101,95,101,110,118,105,114,111,110,109,101,110,116,218,3,
- 95,111,115,90,7,101,110,118,105,114,111,110,169,0,169,1,
- 218,3,107,101,121,114,5,0,0,0,250,38,60,102,114,111,
- 122,101,110,32,105,109,112,111,114,116,108,105,98,46,95,98,
- 111,111,116,115,116,114,97,112,95,101,120,116,101,114,110,97,
- 108,62,218,11,95,114,101,108,97,120,95,99,97,115,101,36,
- 0,0,0,115,2,0,0,0,0,2,122,37,95,109,97,107,
- 101,95,114,101,108,97,120,95,99,97,115,101,46,60,108,111,
- 99,97,108,115,62,46,95,114,101,108,97,120,95,99,97,115,
- 101,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,1,0,0,0,83,0,0,0,115,4,0,0,0,100,
- 1,83,0,41,2,122,53,84,114,117,101,32,105,102,32,102,
- 105,108,101,110,97,109,101,115,32,109,117,115,116,32,98,101,
- 32,99,104,101,99,107,101,100,32,99,97,115,101,45,105,110,
- 115,101,110,115,105,116,105,118,101,108,121,46,70,114,5,0,
- 0,0,114,5,0,0,0,114,5,0,0,0,114,5,0,0,
- 0,114,8,0,0,0,114,9,0,0,0,40,0,0,0,115,
- 2,0,0,0,0,2,41,5,114,1,0,0,0,218,8,112,
- 108,97,116,102,111,114,109,218,10,115,116,97,114,116,115,119,
- 105,116,104,218,27,95,67,65,83,69,95,73,78,83,69,78,
- 83,73,84,73,86,69,95,80,76,65,84,70,79,82,77,83,
- 218,35,95,67,65,83,69,95,73,78,83,69,78,83,73,84,
- 73,86,69,95,80,76,65,84,70,79,82,77,83,95,83,84,
- 82,95,75,69,89,41,1,114,9,0,0,0,114,5,0,0,
- 0,114,6,0,0,0,114,8,0,0,0,218,16,95,109,97,
- 107,101,95,114,101,108,97,120,95,99,97,115,101,29,0,0,
- 0,115,14,0,0,0,0,1,12,1,12,1,6,2,4,2,
- 14,4,8,3,114,14,0,0,0,99,1,0,0,0,0,0,
- 0,0,0,0,0,0,1,0,0,0,4,0,0,0,67,0,
- 0,0,115,20,0,0,0,116,0,124,0,131,1,100,1,64,
- 0,160,1,100,2,100,3,161,2,83,0,41,4,122,42,67,
- 111,110,118,101,114,116,32,97,32,51,50,45,98,105,116,32,
- 105,110,116,101,103,101,114,32,116,111,32,108,105,116,116,108,
- 101,45,101,110,100,105,97,110,46,236,3,0,0,0,255,127,
- 255,127,3,0,233,4,0,0,0,218,6,108,105,116,116,108,
- 101,41,2,218,3,105,110,116,218,8,116,111,95,98,121,116,
- 101,115,41,1,218,1,120,114,5,0,0,0,114,5,0,0,
- 0,114,8,0,0,0,218,12,95,112,97,99,107,95,117,105,
- 110,116,51,50,46,0,0,0,115,2,0,0,0,0,2,114,
- 21,0,0,0,99,1,0,0,0,0,0,0,0,0,0,0,
- 0,1,0,0,0,4,0,0,0,67,0,0,0,115,28,0,
- 0,0,116,0,124,0,131,1,100,1,107,2,115,16,74,0,
- 130,1,116,1,160,2,124,0,100,2,161,2,83,0,41,3,
- 122,47,67,111,110,118,101,114,116,32,52,32,98,121,116,101,
- 115,32,105,110,32,108,105,116,116,108,101,45,101,110,100,105,
- 97,110,32,116,111,32,97,110,32,105,110,116,101,103,101,114,
- 46,114,16,0,0,0,114,17,0,0,0,169,3,218,3,108,
- 101,110,114,18,0,0,0,218,10,102,114,111,109,95,98,121,
- 116,101,115,169,1,218,4,100,97,116,97,114,5,0,0,0,
- 114,5,0,0,0,114,8,0,0,0,218,14,95,117,110,112,
- 97,99,107,95,117,105,110,116,51,50,51,0,0,0,115,4,
- 0,0,0,0,2,16,1,114,27,0,0,0,99,1,0,0,
- 0,0,0,0,0,0,0,0,0,1,0,0,0,4,0,0,
- 0,67,0,0,0,115,28,0,0,0,116,0,124,0,131,1,
- 100,1,107,2,115,16,74,0,130,1,116,1,160,2,124,0,
- 100,2,161,2,83,0,41,3,122,47,67,111,110,118,101,114,
- 116,32,50,32,98,121,116,101,115,32,105,110,32,108,105,116,
- 116,108,101,45,101,110,100,105,97,110,32,116,111,32,97,110,
- 32,105,110,116,101,103,101,114,46,233,2,0,0,0,114,17,
- 0,0,0,114,22,0,0,0,114,25,0,0,0,114,5,0,
- 0,0,114,5,0,0,0,114,8,0,0,0,218,14,95,117,
- 110,112,97,99,107,95,117,105,110,116,49,54,56,0,0,0,
- 115,4,0,0,0,0,2,16,1,114,29,0,0,0,99,0,
- 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,4,
- 0,0,0,71,0,0,0,115,20,0,0,0,116,0,160,1,
- 100,1,100,2,132,0,124,0,68,0,131,1,161,1,83,0,
- 41,3,122,31,82,101,112,108,97,99,101,109,101,110,116,32,
- 102,111,114,32,111,115,46,112,97,116,104,46,106,111,105,110,
- 40,41,46,99,1,0,0,0,0,0,0,0,0,0,0,0,
- 2,0,0,0,5,0,0,0,83,0,0,0,115,26,0,0,
- 0,103,0,124,0,93,18,125,1,124,1,114,4,124,1,160,
- 0,116,1,161,1,145,2,113,4,83,0,114,5,0,0,0,
- 41,2,218,6,114,115,116,114,105,112,218,15,112,97,116,104,
- 95,115,101,112,97,114,97,116,111,114,115,41,2,218,2,46,
- 48,218,4,112,97,114,116,114,5,0,0,0,114,5,0,0,
- 0,114,8,0,0,0,218,10,60,108,105,115,116,99,111,109,
- 112,62,64,0,0,0,115,4,0,0,0,6,1,6,255,122,
- 30,95,112,97,116,104,95,106,111,105,110,46,60,108,111,99,
- 97,108,115,62,46,60,108,105,115,116,99,111,109,112,62,41,
- 2,218,8,112,97,116,104,95,115,101,112,218,4,106,111,105,
- 110,41,1,218,10,112,97,116,104,95,112,97,114,116,115,114,
- 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,10,
- 95,112,97,116,104,95,106,111,105,110,62,0,0,0,115,6,
- 0,0,0,0,2,10,1,2,255,114,38,0,0,0,99,1,
- 0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,5,
- 0,0,0,67,0,0,0,115,94,0,0,0,116,0,116,1,
- 131,1,100,1,107,2,114,36,124,0,160,2,116,3,161,1,
- 92,3,125,1,125,2,125,3,124,1,124,3,102,2,83,0,
- 116,4,124,0,131,1,68,0,93,40,125,4,124,4,116,1,
- 118,0,114,44,124,0,106,5,124,4,100,1,100,2,141,2,
- 92,2,125,1,125,3,124,1,124,3,102,2,2,0,1,0,
- 83,0,100,3,124,0,102,2,83,0,41,4,122,32,82,101,
- 112,108,97,99,101,109,101,110,116,32,102,111,114,32,111,115,
- 46,112,97,116,104,46,115,112,108,105,116,40,41,46,233,1,
- 0,0,0,41,1,90,8,109,97,120,115,112,108,105,116,218,
- 0,41,6,114,23,0,0,0,114,31,0,0,0,218,10,114,
- 112,97,114,116,105,116,105,111,110,114,35,0,0,0,218,8,
- 114,101,118,101,114,115,101,100,218,6,114,115,112,108,105,116,
- 41,5,218,4,112,97,116,104,90,5,102,114,111,110,116,218,
- 1,95,218,4,116,97,105,108,114,20,0,0,0,114,5,0,
- 0,0,114,5,0,0,0,114,8,0,0,0,218,11,95,112,
- 97,116,104,95,115,112,108,105,116,68,0,0,0,115,16,0,
- 0,0,0,2,12,1,16,1,8,1,12,1,8,1,18,1,
- 12,1,114,47,0,0,0,99,1,0,0,0,0,0,0,0,
- 0,0,0,0,1,0,0,0,3,0,0,0,67,0,0,0,
- 115,10,0,0,0,116,0,160,1,124,0,161,1,83,0,41,
- 1,122,126,83,116,97,116,32,116,104,101,32,112,97,116,104,
- 46,10,10,32,32,32,32,77,97,100,101,32,97,32,115,101,
- 112,97,114,97,116,101,32,102,117,110,99,116,105,111,110,32,
- 116,111,32,109,97,107,101,32,105,116,32,101,97,115,105,101,
- 114,32,116,111,32,111,118,101,114,114,105,100,101,32,105,110,
- 32,101,120,112,101,114,105,109,101,110,116,115,10,32,32,32,
- 32,40,101,46,103,46,32,99,97,99,104,101,32,115,116,97,
- 116,32,114,101,115,117,108,116,115,41,46,10,10,32,32,32,
- 32,41,2,114,4,0,0,0,90,4,115,116,97,116,169,1,
- 114,44,0,0,0,114,5,0,0,0,114,5,0,0,0,114,
- 8,0,0,0,218,10,95,112,97,116,104,95,115,116,97,116,
- 80,0,0,0,115,2,0,0,0,0,7,114,49,0,0,0,
- 99,2,0,0,0,0,0,0,0,0,0,0,0,3,0,0,
- 0,8,0,0,0,67,0,0,0,115,48,0,0,0,122,12,
- 116,0,124,0,131,1,125,2,87,0,110,20,4,0,116,1,
- 121,32,1,0,1,0,1,0,89,0,100,1,83,0,48,0,
- 124,2,106,2,100,2,64,0,124,1,107,2,83,0,41,3,
- 122,49,84,101,115,116,32,119,104,101,116,104,101,114,32,116,
- 104,101,32,112,97,116,104,32,105,115,32,116,104,101,32,115,
- 112,101,99,105,102,105,101,100,32,109,111,100,101,32,116,121,
- 112,101,46,70,105,0,240,0,0,41,3,114,49,0,0,0,
- 218,7,79,83,69,114,114,111,114,218,7,115,116,95,109,111,
- 100,101,41,3,114,44,0,0,0,218,4,109,111,100,101,90,
- 9,115,116,97,116,95,105,110,102,111,114,5,0,0,0,114,
- 5,0,0,0,114,8,0,0,0,218,18,95,112,97,116,104,
- 95,105,115,95,109,111,100,101,95,116,121,112,101,90,0,0,
- 0,115,10,0,0,0,0,2,2,1,12,1,12,1,8,1,
- 114,53,0,0,0,99,1,0,0,0,0,0,0,0,0,0,
- 0,0,1,0,0,0,3,0,0,0,67,0,0,0,115,10,
- 0,0,0,116,0,124,0,100,1,131,2,83,0,41,2,122,
- 31,82,101,112,108,97,99,101,109,101,110,116,32,102,111,114,
- 32,111,115,46,112,97,116,104,46,105,115,102,105,108,101,46,
- 105,0,128,0,0,41,1,114,53,0,0,0,114,48,0,0,
- 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,
- 218,12,95,112,97,116,104,95,105,115,102,105,108,101,99,0,
- 0,0,115,2,0,0,0,0,2,114,54,0,0,0,99,1,
- 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,3,
- 0,0,0,67,0,0,0,115,22,0,0,0,124,0,115,12,
- 116,0,160,1,161,0,125,0,116,2,124,0,100,1,131,2,
- 83,0,41,2,122,30,82,101,112,108,97,99,101,109,101,110,
- 116,32,102,111,114,32,111,115,46,112,97,116,104,46,105,115,
- 100,105,114,46,105,0,64,0,0,41,3,114,4,0,0,0,
- 218,6,103,101,116,99,119,100,114,53,0,0,0,114,48,0,
- 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,
- 0,218,11,95,112,97,116,104,95,105,115,100,105,114,104,0,
- 0,0,115,6,0,0,0,0,2,4,1,8,1,114,56,0,
+ 0,5,0,0,0,64,0,0,0,115,216,2,0,0,100,0,
+ 90,0,100,1,97,1,100,2,100,1,108,2,90,2,100,2,
+ 100,1,108,3,90,3,100,2,100,1,108,4,90,4,100,2,
+ 100,1,108,5,90,5,100,2,100,1,108,6,90,6,101,4,
+ 106,7,100,3,107,2,90,8,101,8,114,80,100,2,100,1,
+ 108,9,90,10,100,2,100,1,108,11,90,11,110,8,100,2,
+ 100,1,108,12,90,10,101,8,114,102,100,4,100,5,103,2,
+ 90,13,110,6,100,5,103,1,90,13,101,14,100,6,100,7,
+ 132,0,101,13,68,0,131,1,131,1,115,130,74,0,130,1,
+ 101,13,100,2,25,0,90,15,100,8,160,16,101,13,161,1,
+ 90,13,100,9,100,10,132,0,101,13,68,0,131,1,90,17,
+ 100,11,90,18,100,12,90,19,101,19,101,18,23,0,90,20,
+ 100,13,100,14,132,0,90,21,101,21,131,0,90,22,100,15,
+ 100,16,132,0,90,23,100,17,100,18,132,0,90,24,100,19,
+ 100,20,132,0,90,25,100,21,100,22,132,0,90,26,100,23,
+ 100,24,132,0,90,27,100,25,100,26,132,0,90,28,100,27,
+ 100,28,132,0,90,29,100,29,100,30,132,0,90,30,100,31,
+ 100,32,132,0,90,31,100,33,100,34,132,0,90,32,100,110,
+ 100,36,100,37,132,1,90,33,101,34,101,33,106,35,131,1,
+ 90,36,100,38,160,37,100,39,100,40,161,2,100,41,23,0,
+ 90,38,101,39,160,40,101,38,100,40,161,2,90,41,100,42,
+ 90,42,100,43,90,43,100,44,103,1,90,44,101,8,144,1,
+ 114,94,101,44,160,45,100,45,161,1,1,0,101,2,160,46,
+ 161,0,90,47,100,46,103,1,90,48,101,48,4,0,90,49,
+ 90,50,100,111,100,1,100,47,156,1,100,48,100,49,132,3,
+ 90,51,100,50,100,51,132,0,90,52,100,52,100,53,132,0,
+ 90,53,100,54,100,55,132,0,90,54,100,56,100,57,132,0,
+ 90,55,100,58,100,59,132,0,90,56,100,60,100,61,132,0,
+ 90,57,100,62,100,63,132,0,90,58,100,64,100,65,132,0,
+ 90,59,100,66,100,67,132,0,90,60,100,112,100,68,100,69,
+ 132,1,90,61,100,113,100,70,100,71,132,1,90,62,100,114,
+ 100,73,100,74,132,1,90,63,100,75,100,76,132,0,90,64,
+ 101,65,131,0,90,66,100,115,100,1,101,66,100,77,156,2,
+ 100,78,100,79,132,3,90,67,71,0,100,80,100,81,132,0,
+ 100,81,131,2,90,68,71,0,100,82,100,83,132,0,100,83,
+ 131,2,90,69,71,0,100,84,100,85,132,0,100,85,101,69,
+ 131,3,90,70,71,0,100,86,100,87,132,0,100,87,131,2,
+ 90,71,71,0,100,88,100,89,132,0,100,89,101,71,101,70,
+ 131,4,90,72,71,0,100,90,100,91,132,0,100,91,101,71,
+ 101,69,131,4,90,73,71,0,100,92,100,93,132,0,100,93,
+ 101,71,101,69,131,4,90,74,71,0,100,94,100,95,132,0,
+ 100,95,131,2,90,75,71,0,100,96,100,97,132,0,100,97,
+ 131,2,90,76,71,0,100,98,100,99,132,0,100,99,131,2,
+ 90,77,71,0,100,100,100,101,132,0,100,101,131,2,90,78,
+ 100,116,100,102,100,103,132,1,90,79,100,104,100,105,132,0,
+ 90,80,100,106,100,107,132,0,90,81,100,108,100,109,132,0,
+ 90,82,100,1,83,0,41,117,97,94,1,0,0,67,111,114,
+ 101,32,105,109,112,108,101,109,101,110,116,97,116,105,111,110,
+ 32,111,102,32,112,97,116,104,45,98,97,115,101,100,32,105,
+ 109,112,111,114,116,46,10,10,84,104,105,115,32,109,111,100,
+ 117,108,101,32,105,115,32,78,79,84,32,109,101,97,110,116,
+ 32,116,111,32,98,101,32,100,105,114,101,99,116,108,121,32,
+ 105,109,112,111,114,116,101,100,33,32,73,116,32,104,97,115,
+ 32,98,101,101,110,32,100,101,115,105,103,110,101,100,32,115,
+ 117,99,104,10,116,104,97,116,32,105,116,32,99,97,110,32,
+ 98,101,32,98,111,111,116,115,116,114,97,112,112,101,100,32,
+ 105,110,116,111,32,80,121,116,104,111,110,32,97,115,32,116,
+ 104,101,32,105,109,112,108,101,109,101,110,116,97,116,105,111,
+ 110,32,111,102,32,105,109,112,111,114,116,46,32,65,115,10,
+ 115,117,99,104,32,105,116,32,114,101,113,117,105,114,101,115,
+ 32,116,104,101,32,105,110,106,101,99,116,105,111,110,32,111,
+ 102,32,115,112,101,99,105,102,105,99,32,109,111,100,117,108,
+ 101,115,32,97,110,100,32,97,116,116,114,105,98,117,116,101,
+ 115,32,105,110,32,111,114,100,101,114,32,116,111,10,119,111,
+ 114,107,46,32,79,110,101,32,115,104,111,117,108,100,32,117,
+ 115,101,32,105,109,112,111,114,116,108,105,98,32,97,115,32,
+ 116,104,101,32,112,117,98,108,105,99,45,102,97,99,105,110,
+ 103,32,118,101,114,115,105,111,110,32,111,102,32,116,104,105,
+ 115,32,109,111,100,117,108,101,46,10,10,78,233,0,0,0,
+ 0,90,5,119,105,110,51,50,250,1,92,250,1,47,99,1,
+ 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,
+ 0,0,0,99,0,0,0,115,26,0,0,0,124,0,93,18,
+ 125,1,116,0,124,1,131,1,100,0,107,2,86,0,1,0,
+ 113,2,100,1,83,0,41,2,233,1,0,0,0,78,41,1,
+ 218,3,108,101,110,41,2,218,2,46,48,218,3,115,101,112,
+ 169,0,114,7,0,0,0,250,38,60,102,114,111,122,101,110,
+ 32,105,109,112,111,114,116,108,105,98,46,95,98,111,111,116,
+ 115,116,114,97,112,95,101,120,116,101,114,110,97,108,62,218,
+ 9,60,103,101,110,101,120,112,114,62,46,0,0,0,115,4,
+ 0,0,0,26,0,255,128,114,9,0,0,0,218,0,99,1,
+ 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,4,
+ 0,0,0,67,0,0,0,115,22,0,0,0,104,0,124,0,
+ 93,14,125,1,100,0,124,1,155,0,157,2,146,2,113,4,
+ 83,0,41,1,250,1,58,114,7,0,0,0,41,2,114,5,
+ 0,0,0,218,1,115,114,7,0,0,0,114,7,0,0,0,
+ 114,8,0,0,0,218,9,60,115,101,116,99,111,109,112,62,
+ 49,0,0,0,115,4,0,0,0,22,0,255,128,114,13,0,
+ 0,0,41,1,218,3,119,105,110,41,2,90,6,99,121,103,
+ 119,105,110,90,6,100,97,114,119,105,110,99,0,0,0,0,
+ 0,0,0,0,0,0,0,0,1,0,0,0,3,0,0,0,
+ 3,0,0,0,115,62,0,0,0,116,0,106,1,160,2,116,
+ 3,161,1,114,50,116,0,106,1,160,2,116,4,161,1,114,
+ 30,100,1,137,0,110,4,100,2,137,0,135,0,102,1,100,
+ 3,100,4,132,8,125,0,124,0,83,0,100,5,100,4,132,
+ 0,125,0,124,0,83,0,41,6,78,90,12,80,89,84,72,
+ 79,78,67,65,83,69,79,75,115,12,0,0,0,80,89,84,
+ 72,79,78,67,65,83,69,79,75,99,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,2,0,0,0,19,0,
+ 0,0,115,20,0,0,0,116,0,106,1,106,2,12,0,111,
+ 18,136,0,116,3,106,4,118,0,83,0,41,2,122,94,84,
+ 114,117,101,32,105,102,32,102,105,108,101,110,97,109,101,115,
+ 32,109,117,115,116,32,98,101,32,99,104,101,99,107,101,100,
+ 32,99,97,115,101,45,105,110,115,101,110,115,105,116,105,118,
+ 101,108,121,32,97,110,100,32,105,103,110,111,114,101,32,101,
+ 110,118,105,114,111,110,109,101,110,116,32,102,108,97,103,115,
+ 32,97,114,101,32,110,111,116,32,115,101,116,46,78,41,5,
+ 218,3,115,121,115,218,5,102,108,97,103,115,218,18,105,103,
+ 110,111,114,101,95,101,110,118,105,114,111,110,109,101,110,116,
+ 218,3,95,111,115,90,7,101,110,118,105,114,111,110,114,7,
+ 0,0,0,169,1,218,3,107,101,121,114,7,0,0,0,114,
+ 8,0,0,0,218,11,95,114,101,108,97,120,95,99,97,115,
+ 101,66,0,0,0,115,4,0,0,0,20,2,255,128,122,37,
+ 95,109,97,107,101,95,114,101,108,97,120,95,99,97,115,101,
+ 46,60,108,111,99,97,108,115,62,46,95,114,101,108,97,120,
+ 95,99,97,115,101,99,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,1,0,0,0,83,0,0,0,115,4,
+ 0,0,0,100,1,83,0,41,3,122,53,84,114,117,101,32,
+ 105,102,32,102,105,108,101,110,97,109,101,115,32,109,117,115,
+ 116,32,98,101,32,99,104,101,99,107,101,100,32,99,97,115,
+ 101,45,105,110,115,101,110,115,105,116,105,118,101,108,121,46,
+ 70,78,114,7,0,0,0,114,7,0,0,0,114,7,0,0,
+ 0,114,7,0,0,0,114,8,0,0,0,114,21,0,0,0,
+ 70,0,0,0,115,4,0,0,0,4,2,255,128,41,5,114,
+ 15,0,0,0,218,8,112,108,97,116,102,111,114,109,218,10,
+ 115,116,97,114,116,115,119,105,116,104,218,27,95,67,65,83,
+ 69,95,73,78,83,69,78,83,73,84,73,86,69,95,80,76,
+ 65,84,70,79,82,77,83,218,35,95,67,65,83,69,95,73,
+ 78,83,69,78,83,73,84,73,86,69,95,80,76,65,84,70,
+ 79,82,77,83,95,83,84,82,95,75,69,89,41,1,114,21,
+ 0,0,0,114,7,0,0,0,114,19,0,0,0,114,8,0,
+ 0,0,218,16,95,109,97,107,101,95,114,101,108,97,120,95,
+ 99,97,115,101,59,0,0,0,115,18,0,0,0,12,1,12,
+ 1,6,1,4,2,12,2,4,7,8,253,4,3,255,128,114,
+ 26,0,0,0,99,1,0,0,0,0,0,0,0,0,0,0,
+ 0,1,0,0,0,4,0,0,0,67,0,0,0,115,20,0,
+ 0,0,116,0,124,0,131,1,100,1,64,0,160,1,100,2,
+ 100,3,161,2,83,0,41,5,122,42,67,111,110,118,101,114,
+ 116,32,97,32,51,50,45,98,105,116,32,105,110,116,101,103,
+ 101,114,32,116,111,32,108,105,116,116,108,101,45,101,110,100,
+ 105,97,110,46,236,3,0,0,0,255,127,255,127,3,0,233,
+ 4,0,0,0,218,6,108,105,116,116,108,101,78,41,2,218,
+ 3,105,110,116,218,8,116,111,95,98,121,116,101,115,41,1,
+ 218,1,120,114,7,0,0,0,114,7,0,0,0,114,8,0,
+ 0,0,218,12,95,112,97,99,107,95,117,105,110,116,51,50,
+ 78,0,0,0,115,4,0,0,0,20,2,255,128,114,33,0,
0,0,99,1,0,0,0,0,0,0,0,0,0,0,0,1,
- 0,0,0,3,0,0,0,67,0,0,0,115,26,0,0,0,
- 124,0,160,0,116,1,161,1,112,24,124,0,100,1,100,2,
- 133,2,25,0,116,2,118,0,83,0,41,3,122,142,82,101,
- 112,108,97,99,101,109,101,110,116,32,102,111,114,32,111,115,
- 46,112,97,116,104,46,105,115,97,98,115,46,10,10,32,32,
- 32,32,67,111,110,115,105,100,101,114,115,32,97,32,87,105,
- 110,100,111,119,115,32,100,114,105,118,101,45,114,101,108,97,
- 116,105,118,101,32,112,97,116,104,32,40,110,111,32,100,114,
- 105,118,101,44,32,98,117,116,32,115,116,97,114,116,115,32,
- 119,105,116,104,32,115,108,97,115,104,41,32,116,111,10,32,
- 32,32,32,115,116,105,108,108,32,98,101,32,34,97,98,115,
- 111,108,117,116,101,34,46,10,32,32,32,32,114,39,0,0,
- 0,233,3,0,0,0,41,3,114,11,0,0,0,114,31,0,
- 0,0,218,20,95,112,97,116,104,115,101,112,115,95,119,105,
- 116,104,95,99,111,108,111,110,114,48,0,0,0,114,5,0,
- 0,0,114,5,0,0,0,114,8,0,0,0,218,11,95,112,
- 97,116,104,95,105,115,97,98,115,111,0,0,0,115,2,0,
- 0,0,0,6,114,59,0,0,0,233,182,1,0,0,99,3,
- 0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,11,
- 0,0,0,67,0,0,0,115,172,0,0,0,100,1,160,0,
- 124,0,116,1,124,0,131,1,161,2,125,3,116,2,160,3,
- 124,3,116,2,106,4,116,2,106,5,66,0,116,2,106,6,
- 66,0,124,2,100,2,64,0,161,3,125,4,122,70,116,7,
- 160,8,124,4,100,3,161,2,143,26,125,5,124,5,160,9,
- 124,1,161,1,1,0,87,0,100,4,4,0,4,0,131,3,
- 1,0,110,16,49,0,115,94,48,0,1,0,1,0,1,0,
- 89,0,1,0,116,2,160,10,124,3,124,0,161,2,1,0,
- 87,0,110,48,4,0,116,11,121,166,1,0,1,0,1,0,
- 122,14,116,2,160,12,124,3,161,1,1,0,87,0,130,0,
- 4,0,116,11,121,164,1,0,1,0,1,0,89,0,130,0,
- 48,0,48,0,100,4,83,0,41,5,122,162,66,101,115,116,
- 45,101,102,102,111,114,116,32,102,117,110,99,116,105,111,110,
- 32,116,111,32,119,114,105,116,101,32,100,97,116,97,32,116,
- 111,32,97,32,112,97,116,104,32,97,116,111,109,105,99,97,
- 108,108,121,46,10,32,32,32,32,66,101,32,112,114,101,112,
- 97,114,101,100,32,116,111,32,104,97,110,100,108,101,32,97,
- 32,70,105,108,101,69,120,105,115,116,115,69,114,114,111,114,
- 32,105,102,32,99,111,110,99,117,114,114,101,110,116,32,119,
- 114,105,116,105,110,103,32,111,102,32,116,104,101,10,32,32,
- 32,32,116,101,109,112,111,114,97,114,121,32,102,105,108,101,
- 32,105,115,32,97,116,116,101,109,112,116,101,100,46,250,5,
- 123,125,46,123,125,114,60,0,0,0,90,2,119,98,78,41,
- 13,218,6,102,111,114,109,97,116,218,2,105,100,114,4,0,
- 0,0,90,4,111,112,101,110,90,6,79,95,69,88,67,76,
- 90,7,79,95,67,82,69,65,84,90,8,79,95,87,82,79,
- 78,76,89,218,3,95,105,111,218,6,70,105,108,101,73,79,
- 218,5,119,114,105,116,101,218,7,114,101,112,108,97,99,101,
- 114,50,0,0,0,90,6,117,110,108,105,110,107,41,6,114,
- 44,0,0,0,114,26,0,0,0,114,52,0,0,0,90,8,
- 112,97,116,104,95,116,109,112,90,2,102,100,218,4,102,105,
- 108,101,114,5,0,0,0,114,5,0,0,0,114,8,0,0,
- 0,218,13,95,119,114,105,116,101,95,97,116,111,109,105,99,
- 120,0,0,0,115,28,0,0,0,0,5,16,1,6,1,22,
- 255,4,2,2,3,14,1,40,1,16,1,12,1,2,1,14,
- 1,12,1,6,1,114,69,0,0,0,105,102,13,0,0,114,
- 28,0,0,0,114,17,0,0,0,115,2,0,0,0,13,10,
- 90,11,95,95,112,121,99,97,99,104,101,95,95,122,4,111,
- 112,116,45,122,3,46,112,121,122,4,46,112,121,99,78,41,
- 1,218,12,111,112,116,105,109,105,122,97,116,105,111,110,99,
- 2,0,0,0,0,0,0,0,1,0,0,0,12,0,0,0,
- 5,0,0,0,67,0,0,0,115,88,1,0,0,124,1,100,
- 1,117,1,114,52,116,0,160,1,100,2,116,2,161,2,1,
- 0,124,2,100,1,117,1,114,40,100,3,125,3,116,3,124,
- 3,131,1,130,1,124,1,114,48,100,4,110,2,100,5,125,
- 2,116,4,160,5,124,0,161,1,125,0,116,6,124,0,131,
- 1,92,2,125,4,125,5,124,5,160,7,100,6,161,1,92,
- 3,125,6,125,7,125,8,116,8,106,9,106,10,125,9,124,
- 9,100,1,117,0,114,114,116,11,100,7,131,1,130,1,100,
- 4,160,12,124,6,114,126,124,6,110,2,124,8,124,7,124,
- 9,103,3,161,1,125,10,124,2,100,1,117,0,114,172,116,
- 8,106,13,106,14,100,8,107,2,114,164,100,4,125,2,110,
- 8,116,8,106,13,106,14,125,2,116,15,124,2,131,1,125,
- 2,124,2,100,4,107,3,114,224,124,2,160,16,161,0,115,
- 210,116,17,100,9,160,18,124,2,161,1,131,1,130,1,100,
- 10,160,18,124,10,116,19,124,2,161,3,125,10,124,10,116,
- 20,100,8,25,0,23,0,125,11,116,8,106,21,100,1,117,
- 1,144,1,114,76,116,22,124,4,131,1,144,1,115,16,116,
- 23,116,4,160,24,161,0,124,4,131,2,125,4,124,4,100,
- 5,25,0,100,11,107,2,144,1,114,56,124,4,100,8,25,
- 0,116,25,118,1,144,1,114,56,124,4,100,12,100,1,133,
- 2,25,0,125,4,116,23,116,8,106,21,124,4,160,26,116,
- 25,161,1,124,11,131,3,83,0,116,23,124,4,116,27,124,
- 11,131,3,83,0,41,13,97,254,2,0,0,71,105,118,101,
- 110,32,116,104,101,32,112,97,116,104,32,116,111,32,97,32,
- 46,112,121,32,102,105,108,101,44,32,114,101,116,117,114,110,
- 32,116,104,101,32,112,97,116,104,32,116,111,32,105,116,115,
- 32,46,112,121,99,32,102,105,108,101,46,10,10,32,32,32,
- 32,84,104,101,32,46,112,121,32,102,105,108,101,32,100,111,
- 101,115,32,110,111,116,32,110,101,101,100,32,116,111,32,101,
- 120,105,115,116,59,32,116,104,105,115,32,115,105,109,112,108,
- 121,32,114,101,116,117,114,110,115,32,116,104,101,32,112,97,
- 116,104,32,116,111,32,116,104,101,10,32,32,32,32,46,112,
- 121,99,32,102,105,108,101,32,99,97,108,99,117,108,97,116,
- 101,100,32,97,115,32,105,102,32,116,104,101,32,46,112,121,
- 32,102,105,108,101,32,119,101,114,101,32,105,109,112,111,114,
- 116,101,100,46,10,10,32,32,32,32,84,104,101,32,39,111,
- 112,116,105,109,105,122,97,116,105,111,110,39,32,112,97,114,
- 97,109,101,116,101,114,32,99,111,110,116,114,111,108,115,32,
- 116,104,101,32,112,114,101,115,117,109,101,100,32,111,112,116,
- 105,109,105,122,97,116,105,111,110,32,108,101,118,101,108,32,
- 111,102,10,32,32,32,32,116,104,101,32,98,121,116,101,99,
- 111,100,101,32,102,105,108,101,46,32,73,102,32,39,111,112,
- 116,105,109,105,122,97,116,105,111,110,39,32,105,115,32,110,
- 111,116,32,78,111,110,101,44,32,116,104,101,32,115,116,114,
- 105,110,103,32,114,101,112,114,101,115,101,110,116,97,116,105,
- 111,110,10,32,32,32,32,111,102,32,116,104,101,32,97,114,
- 103,117,109,101,110,116,32,105,115,32,116,97,107,101,110,32,
- 97,110,100,32,118,101,114,105,102,105,101,100,32,116,111,32,
- 98,101,32,97,108,112,104,97,110,117,109,101,114,105,99,32,
- 40,101,108,115,101,32,86,97,108,117,101,69,114,114,111,114,
- 10,32,32,32,32,105,115,32,114,97,105,115,101,100,41,46,
- 10,10,32,32,32,32,84,104,101,32,100,101,98,117,103,95,
- 111,118,101,114,114,105,100,101,32,112,97,114,97,109,101,116,
- 101,114,32,105,115,32,100,101,112,114,101,99,97,116,101,100,
- 46,32,73,102,32,100,101,98,117,103,95,111,118,101,114,114,
- 105,100,101,32,105,115,32,110,111,116,32,78,111,110,101,44,
- 10,32,32,32,32,97,32,84,114,117,101,32,118,97,108,117,
- 101,32,105,115,32,116,104,101,32,115,97,109,101,32,97,115,
- 32,115,101,116,116,105,110,103,32,39,111,112,116,105,109,105,
- 122,97,116,105,111,110,39,32,116,111,32,116,104,101,32,101,
- 109,112,116,121,32,115,116,114,105,110,103,10,32,32,32,32,
- 119,104,105,108,101,32,97,32,70,97,108,115,101,32,118,97,
- 108,117,101,32,105,115,32,101,113,117,105,118,97,108,101,110,
- 116,32,116,111,32,115,101,116,116,105,110,103,32,39,111,112,
- 116,105,109,105,122,97,116,105,111,110,39,32,116,111,32,39,
- 49,39,46,10,10,32,32,32,32,73,102,32,115,121,115,46,
- 105,109,112,108,101,109,101,110,116,97,116,105,111,110,46,99,
- 97,99,104,101,95,116,97,103,32,105,115,32,78,111,110,101,
- 32,116,104,101,110,32,78,111,116,73,109,112,108,101,109,101,
- 110,116,101,100,69,114,114,111,114,32,105,115,32,114,97,105,
- 115,101,100,46,10,10,32,32,32,32,78,122,70,116,104,101,
- 32,100,101,98,117,103,95,111,118,101,114,114,105,100,101,32,
- 112,97,114,97,109,101,116,101,114,32,105,115,32,100,101,112,
- 114,101,99,97,116,101,100,59,32,117,115,101,32,39,111,112,
- 116,105,109,105,122,97,116,105,111,110,39,32,105,110,115,116,
- 101,97,100,122,50,100,101,98,117,103,95,111,118,101,114,114,
- 105,100,101,32,111,114,32,111,112,116,105,109,105,122,97,116,
- 105,111,110,32,109,117,115,116,32,98,101,32,115,101,116,32,
- 116,111,32,78,111,110,101,114,40,0,0,0,114,39,0,0,
- 0,218,1,46,250,36,115,121,115,46,105,109,112,108,101,109,
- 101,110,116,97,116,105,111,110,46,99,97,99,104,101,95,116,
- 97,103,32,105,115,32,78,111,110,101,233,0,0,0,0,122,
- 24,123,33,114,125,32,105,115,32,110,111,116,32,97,108,112,
- 104,97,110,117,109,101,114,105,99,122,7,123,125,46,123,125,
- 123,125,250,1,58,114,28,0,0,0,41,28,218,9,95,119,
- 97,114,110,105,110,103,115,218,4,119,97,114,110,218,18,68,
- 101,112,114,101,99,97,116,105,111,110,87,97,114,110,105,110,
- 103,218,9,84,121,112,101,69,114,114,111,114,114,4,0,0,
- 0,218,6,102,115,112,97,116,104,114,47,0,0,0,114,41,
- 0,0,0,114,1,0,0,0,218,14,105,109,112,108,101,109,
- 101,110,116,97,116,105,111,110,218,9,99,97,99,104,101,95,
- 116,97,103,218,19,78,111,116,73,109,112,108,101,109,101,110,
- 116,101,100,69,114,114,111,114,114,36,0,0,0,114,2,0,
- 0,0,218,8,111,112,116,105,109,105,122,101,218,3,115,116,
- 114,218,7,105,115,97,108,110,117,109,218,10,86,97,108,117,
- 101,69,114,114,111,114,114,62,0,0,0,218,4,95,79,80,
- 84,218,17,66,89,84,69,67,79,68,69,95,83,85,70,70,
- 73,88,69,83,218,14,112,121,99,97,99,104,101,95,112,114,
- 101,102,105,120,114,59,0,0,0,114,38,0,0,0,114,55,
- 0,0,0,114,31,0,0,0,218,6,108,115,116,114,105,112,
- 218,8,95,80,89,67,65,67,72,69,41,12,114,44,0,0,
- 0,90,14,100,101,98,117,103,95,111,118,101,114,114,105,100,
- 101,114,70,0,0,0,218,7,109,101,115,115,97,103,101,218,
- 4,104,101,97,100,114,46,0,0,0,90,4,98,97,115,101,
- 218,3,115,101,112,218,4,114,101,115,116,90,3,116,97,103,
- 90,15,97,108,109,111,115,116,95,102,105,108,101,110,97,109,
- 101,218,8,102,105,108,101,110,97,109,101,114,5,0,0,0,
- 114,5,0,0,0,114,8,0,0,0,218,17,99,97,99,104,
- 101,95,102,114,111,109,95,115,111,117,114,99,101,46,1,0,
- 0,115,72,0,0,0,0,18,8,1,6,1,2,255,4,2,
- 8,1,4,1,8,1,12,1,10,1,12,1,16,1,8,1,
- 8,1,8,1,24,1,8,1,12,1,6,2,8,1,8,1,
- 8,1,8,1,14,1,14,1,12,1,12,9,10,1,14,5,
- 28,1,12,4,2,1,4,1,8,1,2,253,4,5,114,97,
+ 0,0,0,4,0,0,0,67,0,0,0,115,28,0,0,0,
+ 116,0,124,0,131,1,100,1,107,2,115,16,74,0,130,1,
+ 116,1,160,2,124,0,100,2,161,2,83,0,41,4,122,47,
+ 67,111,110,118,101,114,116,32,52,32,98,121,116,101,115,32,
+ 105,110,32,108,105,116,116,108,101,45,101,110,100,105,97,110,
+ 32,116,111,32,97,110,32,105,110,116,101,103,101,114,46,114,
+ 28,0,0,0,114,29,0,0,0,78,169,3,114,4,0,0,
+ 0,114,30,0,0,0,218,10,102,114,111,109,95,98,121,116,
+ 101,115,169,1,218,4,100,97,116,97,114,7,0,0,0,114,
+ 7,0,0,0,114,8,0,0,0,218,14,95,117,110,112,97,
+ 99,107,95,117,105,110,116,51,50,83,0,0,0,115,6,0,
+ 0,0,16,2,12,1,255,128,114,38,0,0,0,99,1,0,
+ 0,0,0,0,0,0,0,0,0,0,1,0,0,0,4,0,
+ 0,0,67,0,0,0,115,28,0,0,0,116,0,124,0,131,
+ 1,100,1,107,2,115,16,74,0,130,1,116,1,160,2,124,
+ 0,100,2,161,2,83,0,41,4,122,47,67,111,110,118,101,
+ 114,116,32,50,32,98,121,116,101,115,32,105,110,32,108,105,
+ 116,116,108,101,45,101,110,100,105,97,110,32,116,111,32,97,
+ 110,32,105,110,116,101,103,101,114,46,233,2,0,0,0,114,
+ 29,0,0,0,78,114,34,0,0,0,114,36,0,0,0,114,
+ 7,0,0,0,114,7,0,0,0,114,8,0,0,0,218,14,
+ 95,117,110,112,97,99,107,95,117,105,110,116,49,54,88,0,
+ 0,0,115,6,0,0,0,16,2,12,1,255,128,114,40,0,
+ 0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,1,
+ 0,0,0,4,0,0,0,71,0,0,0,115,20,0,0,0,
+ 116,0,160,1,100,1,100,2,132,0,124,0,68,0,131,1,
+ 161,1,83,0,41,4,122,31,82,101,112,108,97,99,101,109,
+ 101,110,116,32,102,111,114,32,111,115,46,112,97,116,104,46,
+ 106,111,105,110,40,41,46,99,1,0,0,0,0,0,0,0,
+ 0,0,0,0,2,0,0,0,5,0,0,0,83,0,0,0,
+ 115,26,0,0,0,103,0,124,0,93,18,125,1,124,1,114,
+ 4,124,1,160,0,116,1,161,1,145,2,113,4,83,0,114,
+ 7,0,0,0,41,2,218,6,114,115,116,114,105,112,218,15,
+ 112,97,116,104,95,115,101,112,97,114,97,116,111,114,115,41,
+ 2,114,5,0,0,0,218,4,112,97,114,116,114,7,0,0,
+ 0,114,7,0,0,0,114,8,0,0,0,218,10,60,108,105,
+ 115,116,99,111,109,112,62,96,0,0,0,115,8,0,0,0,
+ 6,0,6,1,14,255,255,128,122,30,95,112,97,116,104,95,
+ 106,111,105,110,46,60,108,111,99,97,108,115,62,46,60,108,
+ 105,115,116,99,111,109,112,62,78,41,2,218,8,112,97,116,
+ 104,95,115,101,112,218,4,106,111,105,110,41,1,218,10,112,
+ 97,116,104,95,112,97,114,116,115,114,7,0,0,0,114,7,
+ 0,0,0,114,8,0,0,0,218,10,95,112,97,116,104,95,
+ 106,111,105,110,94,0,0,0,115,8,0,0,0,10,2,2,
+ 1,8,255,255,128,114,48,0,0,0,99,1,0,0,0,0,
+ 0,0,0,0,0,0,0,5,0,0,0,5,0,0,0,67,
+ 0,0,0,115,96,0,0,0,116,0,116,1,131,1,100,1,
+ 107,2,114,36,124,0,160,2,116,3,161,1,92,3,125,1,
+ 125,2,125,3,124,1,124,3,102,2,83,0,116,4,124,0,
+ 131,1,68,0,93,42,125,4,124,4,116,1,118,0,114,86,
+ 124,0,106,5,124,4,100,1,100,2,141,2,92,2,125,1,
+ 125,3,124,1,124,3,102,2,2,0,1,0,83,0,113,44,
+ 100,3,124,0,102,2,83,0,41,5,122,32,82,101,112,108,
+ 97,99,101,109,101,110,116,32,102,111,114,32,111,115,46,112,
+ 97,116,104,46,115,112,108,105,116,40,41,46,114,3,0,0,
+ 0,41,1,90,8,109,97,120,115,112,108,105,116,114,10,0,
+ 0,0,78,41,6,114,4,0,0,0,114,42,0,0,0,218,
+ 10,114,112,97,114,116,105,116,105,111,110,114,45,0,0,0,
+ 218,8,114,101,118,101,114,115,101,100,218,6,114,115,112,108,
+ 105,116,41,5,218,4,112,97,116,104,90,5,102,114,111,110,
+ 116,218,1,95,218,4,116,97,105,108,114,32,0,0,0,114,
+ 7,0,0,0,114,7,0,0,0,114,8,0,0,0,218,11,
+ 95,112,97,116,104,95,115,112,108,105,116,100,0,0,0,115,
+ 20,0,0,0,12,2,16,1,8,1,12,1,8,1,18,1,
+ 12,1,2,128,8,1,255,128,114,55,0,0,0,99,1,0,
+ 0,0,0,0,0,0,0,0,0,0,1,0,0,0,3,0,
+ 0,0,67,0,0,0,115,10,0,0,0,116,0,160,1,124,
+ 0,161,1,83,0,41,2,122,126,83,116,97,116,32,116,104,
+ 101,32,112,97,116,104,46,10,10,32,32,32,32,77,97,100,
+ 101,32,97,32,115,101,112,97,114,97,116,101,32,102,117,110,
+ 99,116,105,111,110,32,116,111,32,109,97,107,101,32,105,116,
+ 32,101,97,115,105,101,114,32,116,111,32,111,118,101,114,114,
+ 105,100,101,32,105,110,32,101,120,112,101,114,105,109,101,110,
+ 116,115,10,32,32,32,32,40,101,46,103,46,32,99,97,99,
+ 104,101,32,115,116,97,116,32,114,101,115,117,108,116,115,41,
+ 46,10,10,32,32,32,32,78,41,2,114,18,0,0,0,90,
+ 4,115,116,97,116,169,1,114,52,0,0,0,114,7,0,0,
+ 0,114,7,0,0,0,114,8,0,0,0,218,10,95,112,97,
+ 116,104,95,115,116,97,116,112,0,0,0,115,4,0,0,0,
+ 10,7,255,128,114,57,0,0,0,99,2,0,0,0,0,0,
+ 0,0,0,0,0,0,3,0,0,0,8,0,0,0,67,0,
+ 0,0,115,48,0,0,0,122,12,116,0,124,0,131,1,125,
+ 2,87,0,110,18,4,0,116,1,121,46,1,0,1,0,1,
+ 0,89,0,100,1,83,0,124,2,106,2,100,2,64,0,124,
+ 1,107,2,83,0,119,0,41,4,122,49,84,101,115,116,32,
+ 119,104,101,116,104,101,114,32,116,104,101,32,112,97,116,104,
+ 32,105,115,32,116,104,101,32,115,112,101,99,105,102,105,101,
+ 100,32,109,111,100,101,32,116,121,112,101,46,70,105,0,240,
+ 0,0,78,41,3,114,57,0,0,0,218,7,79,83,69,114,
+ 114,111,114,218,7,115,116,95,109,111,100,101,41,3,114,52,
+ 0,0,0,218,4,109,111,100,101,90,9,115,116,97,116,95,
+ 105,110,102,111,114,7,0,0,0,114,7,0,0,0,114,8,
+ 0,0,0,218,18,95,112,97,116,104,95,105,115,95,109,111,
+ 100,101,95,116,121,112,101,122,0,0,0,115,14,0,0,0,
+ 2,2,12,1,12,1,6,1,14,1,2,254,255,128,114,61,
0,0,0,99,1,0,0,0,0,0,0,0,0,0,0,0,
- 10,0,0,0,5,0,0,0,67,0,0,0,115,46,1,0,
- 0,116,0,106,1,106,2,100,1,117,0,114,20,116,3,100,
- 2,131,1,130,1,116,4,160,5,124,0,161,1,125,0,116,
- 6,124,0,131,1,92,2,125,1,125,2,100,3,125,3,116,
- 0,106,7,100,1,117,1,114,102,116,0,106,7,160,8,116,
- 9,161,1,125,4,124,1,160,10,124,4,116,11,23,0,161,
- 1,114,102,124,1,116,12,124,4,131,1,100,1,133,2,25,
- 0,125,1,100,4,125,3,124,3,115,144,116,6,124,1,131,
- 1,92,2,125,1,125,5,124,5,116,13,107,3,114,144,116,
- 14,116,13,155,0,100,5,124,0,155,2,157,3,131,1,130,
- 1,124,2,160,15,100,6,161,1,125,6,124,6,100,7,118,
- 1,114,178,116,14,100,8,124,2,155,2,157,2,131,1,130,
- 1,110,92,124,6,100,9,107,2,144,1,114,14,124,2,160,
- 16,100,6,100,10,161,2,100,11,25,0,125,7,124,7,160,
- 10,116,17,161,1,115,228,116,14,100,12,116,17,155,2,157,
- 2,131,1,130,1,124,7,116,12,116,17,131,1,100,1,133,
- 2,25,0,125,8,124,8,160,18,161,0,144,1,115,14,116,
- 14,100,13,124,7,155,2,100,14,157,3,131,1,130,1,124,
- 2,160,19,100,6,161,1,100,15,25,0,125,9,116,20,124,
- 1,124,9,116,21,100,15,25,0,23,0,131,2,83,0,41,
- 16,97,110,1,0,0,71,105,118,101,110,32,116,104,101,32,
- 112,97,116,104,32,116,111,32,97,32,46,112,121,99,46,32,
- 102,105,108,101,44,32,114,101,116,117,114,110,32,116,104,101,
- 32,112,97,116,104,32,116,111,32,105,116,115,32,46,112,121,
- 32,102,105,108,101,46,10,10,32,32,32,32,84,104,101,32,
- 46,112,121,99,32,102,105,108,101,32,100,111,101,115,32,110,
- 111,116,32,110,101,101,100,32,116,111,32,101,120,105,115,116,
- 59,32,116,104,105,115,32,115,105,109,112,108,121,32,114,101,
- 116,117,114,110,115,32,116,104,101,32,112,97,116,104,32,116,
- 111,10,32,32,32,32,116,104,101,32,46,112,121,32,102,105,
- 108,101,32,99,97,108,99,117,108,97,116,101,100,32,116,111,
- 32,99,111,114,114,101,115,112,111,110,100,32,116,111,32,116,
- 104,101,32,46,112,121,99,32,102,105,108,101,46,32,32,73,
- 102,32,112,97,116,104,32,100,111,101,115,10,32,32,32,32,
- 110,111,116,32,99,111,110,102,111,114,109,32,116,111,32,80,
- 69,80,32,51,49,52,55,47,52,56,56,32,102,111,114,109,
- 97,116,44,32,86,97,108,117,101,69,114,114,111,114,32,119,
- 105,108,108,32,98,101,32,114,97,105,115,101,100,46,32,73,
- 102,10,32,32,32,32,115,121,115,46,105,109,112,108,101,109,
- 101,110,116,97,116,105,111,110,46,99,97,99,104,101,95,116,
- 97,103,32,105,115,32,78,111,110,101,32,116,104,101,110,32,
- 78,111,116,73,109,112,108,101,109,101,110,116,101,100,69,114,
- 114,111,114,32,105,115,32,114,97,105,115,101,100,46,10,10,
- 32,32,32,32,78,114,72,0,0,0,70,84,122,31,32,110,
- 111,116,32,98,111,116,116,111,109,45,108,101,118,101,108,32,
- 100,105,114,101,99,116,111,114,121,32,105,110,32,114,71,0,
- 0,0,62,2,0,0,0,114,28,0,0,0,114,57,0,0,
- 0,122,29,101,120,112,101,99,116,101,100,32,111,110,108,121,
- 32,50,32,111,114,32,51,32,100,111,116,115,32,105,110,32,
- 114,57,0,0,0,114,28,0,0,0,233,254,255,255,255,122,
- 53,111,112,116,105,109,105,122,97,116,105,111,110,32,112,111,
- 114,116,105,111,110,32,111,102,32,102,105,108,101,110,97,109,
- 101,32,100,111,101,115,32,110,111,116,32,115,116,97,114,116,
- 32,119,105,116,104,32,122,19,111,112,116,105,109,105,122,97,
- 116,105,111,110,32,108,101,118,101,108,32,122,29,32,105,115,
- 32,110,111,116,32,97,110,32,97,108,112,104,97,110,117,109,
- 101,114,105,99,32,118,97,108,117,101,114,73,0,0,0,41,
- 22,114,1,0,0,0,114,80,0,0,0,114,81,0,0,0,
- 114,82,0,0,0,114,4,0,0,0,114,79,0,0,0,114,
- 47,0,0,0,114,89,0,0,0,114,30,0,0,0,114,31,
- 0,0,0,114,11,0,0,0,114,35,0,0,0,114,23,0,
- 0,0,114,91,0,0,0,114,86,0,0,0,218,5,99,111,
- 117,110,116,114,43,0,0,0,114,87,0,0,0,114,85,0,
- 0,0,218,9,112,97,114,116,105,116,105,111,110,114,38,0,
- 0,0,218,15,83,79,85,82,67,69,95,83,85,70,70,73,
- 88,69,83,41,10,114,44,0,0,0,114,93,0,0,0,90,
- 16,112,121,99,97,99,104,101,95,102,105,108,101,110,97,109,
- 101,90,23,102,111,117,110,100,95,105,110,95,112,121,99,97,
- 99,104,101,95,112,114,101,102,105,120,90,13,115,116,114,105,
- 112,112,101,100,95,112,97,116,104,90,7,112,121,99,97,99,
- 104,101,90,9,100,111,116,95,99,111,117,110,116,114,70,0,
- 0,0,90,9,111,112,116,95,108,101,118,101,108,90,13,98,
- 97,115,101,95,102,105,108,101,110,97,109,101,114,5,0,0,
- 0,114,5,0,0,0,114,8,0,0,0,218,17,115,111,117,
- 114,99,101,95,102,114,111,109,95,99,97,99,104,101,117,1,
- 0,0,115,60,0,0,0,0,9,12,1,8,1,10,1,12,
- 1,4,1,10,1,12,1,14,1,16,1,4,1,4,1,12,
- 1,8,1,8,1,2,255,8,2,10,1,8,1,16,1,10,
- 1,16,1,10,1,4,1,2,255,8,2,16,1,10,1,16,
- 2,14,1,114,102,0,0,0,99,1,0,0,0,0,0,0,
- 0,0,0,0,0,5,0,0,0,9,0,0,0,67,0,0,
- 0,115,124,0,0,0,116,0,124,0,131,1,100,1,107,2,
- 114,16,100,2,83,0,124,0,160,1,100,3,161,1,92,3,
- 125,1,125,2,125,3,124,1,114,56,124,3,160,2,161,0,
- 100,4,100,5,133,2,25,0,100,6,107,3,114,60,124,0,
- 83,0,122,12,116,3,124,0,131,1,125,4,87,0,110,34,
- 4,0,116,4,116,5,102,2,121,106,1,0,1,0,1,0,
- 124,0,100,2,100,5,133,2,25,0,125,4,89,0,110,2,
- 48,0,116,6,124,4,131,1,114,120,124,4,83,0,124,0,
- 83,0,41,7,122,188,67,111,110,118,101,114,116,32,97,32,
- 98,121,116,101,99,111,100,101,32,102,105,108,101,32,112,97,
- 116,104,32,116,111,32,97,32,115,111,117,114,99,101,32,112,
- 97,116,104,32,40,105,102,32,112,111,115,115,105,98,108,101,
- 41,46,10,10,32,32,32,32,84,104,105,115,32,102,117,110,
- 99,116,105,111,110,32,101,120,105,115,116,115,32,112,117,114,
- 101,108,121,32,102,111,114,32,98,97,99,107,119,97,114,100,
- 115,45,99,111,109,112,97,116,105,98,105,108,105,116,121,32,
- 102,111,114,10,32,32,32,32,80,121,73,109,112,111,114,116,
- 95,69,120,101,99,67,111,100,101,77,111,100,117,108,101,87,
- 105,116,104,70,105,108,101,110,97,109,101,115,40,41,32,105,
- 110,32,116,104,101,32,67,32,65,80,73,46,10,10,32,32,
- 32,32,114,73,0,0,0,78,114,71,0,0,0,233,253,255,
- 255,255,233,255,255,255,255,90,2,112,121,41,7,114,23,0,
- 0,0,114,41,0,0,0,218,5,108,111,119,101,114,114,102,
- 0,0,0,114,82,0,0,0,114,86,0,0,0,114,54,0,
- 0,0,41,5,218,13,98,121,116,101,99,111,100,101,95,112,
- 97,116,104,114,95,0,0,0,114,45,0,0,0,90,9,101,
- 120,116,101,110,115,105,111,110,218,11,115,111,117,114,99,101,
- 95,112,97,116,104,114,5,0,0,0,114,5,0,0,0,114,
- 8,0,0,0,218,15,95,103,101,116,95,115,111,117,114,99,
- 101,102,105,108,101,157,1,0,0,115,20,0,0,0,0,7,
- 12,1,4,1,16,1,24,1,4,1,2,1,12,1,16,1,
- 18,1,114,108,0,0,0,99,1,0,0,0,0,0,0,0,
- 0,0,0,0,1,0,0,0,8,0,0,0,67,0,0,0,
- 115,70,0,0,0,124,0,160,0,116,1,116,2,131,1,161,
- 1,114,44,122,10,116,3,124,0,131,1,87,0,83,0,4,
- 0,116,4,121,42,1,0,1,0,1,0,89,0,110,24,48,
- 0,124,0,160,0,116,1,116,5,131,1,161,1,114,62,124,
- 0,83,0,100,0,83,0,100,0,83,0,169,1,78,41,6,
- 218,8,101,110,100,115,119,105,116,104,218,5,116,117,112,108,
- 101,114,101,0,0,0,114,97,0,0,0,114,82,0,0,0,
- 114,88,0,0,0,41,1,114,96,0,0,0,114,5,0,0,
- 0,114,5,0,0,0,114,8,0,0,0,218,11,95,103,101,
- 116,95,99,97,99,104,101,100,176,1,0,0,115,16,0,0,
- 0,0,1,14,1,2,1,10,1,12,1,6,1,14,1,4,
- 2,114,112,0,0,0,99,1,0,0,0,0,0,0,0,0,
+ 1,0,0,0,3,0,0,0,67,0,0,0,115,10,0,0,
+ 0,116,0,124,0,100,1,131,2,83,0,41,3,122,31,82,
+ 101,112,108,97,99,101,109,101,110,116,32,102,111,114,32,111,
+ 115,46,112,97,116,104,46,105,115,102,105,108,101,46,105,0,
+ 128,0,0,78,41,1,114,61,0,0,0,114,56,0,0,0,
+ 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,218,
+ 12,95,112,97,116,104,95,105,115,102,105,108,101,131,0,0,
+ 0,115,4,0,0,0,10,2,255,128,114,62,0,0,0,99,
+ 1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,
+ 3,0,0,0,67,0,0,0,115,22,0,0,0,124,0,115,
+ 12,116,0,160,1,161,0,125,0,116,2,124,0,100,1,131,
+ 2,83,0,41,3,122,30,82,101,112,108,97,99,101,109,101,
+ 110,116,32,102,111,114,32,111,115,46,112,97,116,104,46,105,
+ 115,100,105,114,46,105,0,64,0,0,78,41,3,114,18,0,
+ 0,0,218,6,103,101,116,99,119,100,114,61,0,0,0,114,
+ 56,0,0,0,114,7,0,0,0,114,7,0,0,0,114,8,
+ 0,0,0,218,11,95,112,97,116,104,95,105,115,100,105,114,
+ 136,0,0,0,115,8,0,0,0,4,2,8,1,10,1,255,
+ 128,114,64,0,0,0,99,1,0,0,0,0,0,0,0,0,
+ 0,0,0,1,0,0,0,3,0,0,0,67,0,0,0,115,
+ 26,0,0,0,124,0,160,0,116,1,161,1,112,24,124,0,
+ 100,1,100,2,133,2,25,0,116,2,118,0,83,0,41,4,
+ 122,142,82,101,112,108,97,99,101,109,101,110,116,32,102,111,
+ 114,32,111,115,46,112,97,116,104,46,105,115,97,98,115,46,
+ 10,10,32,32,32,32,67,111,110,115,105,100,101,114,115,32,
+ 97,32,87,105,110,100,111,119,115,32,100,114,105,118,101,45,
+ 114,101,108,97,116,105,118,101,32,112,97,116,104,32,40,110,
+ 111,32,100,114,105,118,101,44,32,98,117,116,32,115,116,97,
+ 114,116,115,32,119,105,116,104,32,115,108,97,115,104,41,32,
+ 116,111,10,32,32,32,32,115,116,105,108,108,32,98,101,32,
+ 34,97,98,115,111,108,117,116,101,34,46,10,32,32,32,32,
+ 114,3,0,0,0,233,3,0,0,0,78,41,3,114,23,0,
+ 0,0,114,42,0,0,0,218,20,95,112,97,116,104,115,101,
+ 112,115,95,119,105,116,104,95,99,111,108,111,110,114,56,0,
+ 0,0,114,7,0,0,0,114,7,0,0,0,114,8,0,0,
+ 0,218,11,95,112,97,116,104,95,105,115,97,98,115,143,0,
+ 0,0,115,4,0,0,0,26,6,255,128,114,67,0,0,0,
+ 233,182,1,0,0,99,3,0,0,0,0,0,0,0,0,0,
+ 0,0,6,0,0,0,11,0,0,0,67,0,0,0,115,174,
+ 0,0,0,100,1,160,0,124,0,116,1,124,0,131,1,161,
+ 2,125,3,116,2,160,3,124,3,116,2,106,4,116,2,106,
+ 5,66,0,116,2,106,6,66,0,124,2,100,2,64,0,161,
+ 3,125,4,122,72,116,7,160,8,124,4,100,3,161,2,143,
+ 26,125,5,124,5,160,9,124,1,161,1,1,0,87,0,100,
+ 4,4,0,4,0,131,3,1,0,110,16,49,0,115,94,119,
+ 1,1,0,1,0,1,0,89,0,1,0,116,2,160,10,124,
+ 3,124,0,161,2,1,0,87,0,100,4,83,0,4,0,116,
+ 11,121,172,1,0,1,0,1,0,122,14,116,2,160,12,124,
+ 3,161,1,1,0,87,0,130,0,4,0,116,11,121,166,1,
+ 0,1,0,1,0,89,0,130,0,119,0,100,4,83,0,119,
+ 0,41,5,122,162,66,101,115,116,45,101,102,102,111,114,116,
+ 32,102,117,110,99,116,105,111,110,32,116,111,32,119,114,105,
+ 116,101,32,100,97,116,97,32,116,111,32,97,32,112,97,116,
+ 104,32,97,116,111,109,105,99,97,108,108,121,46,10,32,32,
+ 32,32,66,101,32,112,114,101,112,97,114,101,100,32,116,111,
+ 32,104,97,110,100,108,101,32,97,32,70,105,108,101,69,120,
+ 105,115,116,115,69,114,114,111,114,32,105,102,32,99,111,110,
+ 99,117,114,114,101,110,116,32,119,114,105,116,105,110,103,32,
+ 111,102,32,116,104,101,10,32,32,32,32,116,101,109,112,111,
+ 114,97,114,121,32,102,105,108,101,32,105,115,32,97,116,116,
+ 101,109,112,116,101,100,46,250,5,123,125,46,123,125,114,68,
+ 0,0,0,90,2,119,98,78,41,13,218,6,102,111,114,109,
+ 97,116,218,2,105,100,114,18,0,0,0,90,4,111,112,101,
+ 110,90,6,79,95,69,88,67,76,90,7,79,95,67,82,69,
+ 65,84,90,8,79,95,87,82,79,78,76,89,218,3,95,105,
+ 111,218,6,70,105,108,101,73,79,218,5,119,114,105,116,101,
+ 218,7,114,101,112,108,97,99,101,114,58,0,0,0,90,6,
+ 117,110,108,105,110,107,41,6,114,52,0,0,0,114,37,0,
+ 0,0,114,60,0,0,0,90,8,112,97,116,104,95,116,109,
+ 112,90,2,102,100,218,4,102,105,108,101,114,7,0,0,0,
+ 114,7,0,0,0,114,8,0,0,0,218,13,95,119,114,105,
+ 116,101,95,97,116,111,109,105,99,152,0,0,0,115,38,0,
+ 0,0,16,5,6,1,22,1,4,255,2,2,14,3,40,1,
+ 18,1,12,1,2,1,12,1,2,3,12,254,2,1,2,1,
+ 2,254,4,252,2,1,255,128,114,77,0,0,0,105,105,13,
+ 0,0,114,39,0,0,0,114,29,0,0,0,115,2,0,0,
+ 0,13,10,90,11,95,95,112,121,99,97,99,104,101,95,95,
+ 122,4,111,112,116,45,122,3,46,112,121,122,4,46,112,121,
+ 119,122,4,46,112,121,99,41,1,218,12,111,112,116,105,109,
+ 105,122,97,116,105,111,110,99,2,0,0,0,0,0,0,0,
+ 1,0,0,0,12,0,0,0,5,0,0,0,67,0,0,0,
+ 115,88,1,0,0,124,1,100,1,117,1,114,52,116,0,160,
+ 1,100,2,116,2,161,2,1,0,124,2,100,1,117,1,114,
+ 40,100,3,125,3,116,3,124,3,131,1,130,1,124,1,114,
+ 48,100,4,110,2,100,5,125,2,116,4,160,5,124,0,161,
+ 1,125,0,116,6,124,0,131,1,92,2,125,4,125,5,124,
+ 5,160,7,100,6,161,1,92,3,125,6,125,7,125,8,116,
+ 8,106,9,106,10,125,9,124,9,100,1,117,0,114,114,116,
+ 11,100,7,131,1,130,1,100,4,160,12,124,6,114,126,124,
+ 6,110,2,124,8,124,7,124,9,103,3,161,1,125,10,124,
+ 2,100,1,117,0,114,172,116,8,106,13,106,14,100,8,107,
+ 2,114,164,100,4,125,2,110,8,116,8,106,13,106,14,125,
+ 2,116,15,124,2,131,1,125,2,124,2,100,4,107,3,114,
+ 224,124,2,160,16,161,0,115,210,116,17,100,9,160,18,124,
+ 2,161,1,131,1,130,1,100,10,160,18,124,10,116,19,124,
+ 2,161,3,125,10,124,10,116,20,100,8,25,0,23,0,125,
+ 11,116,8,106,21,100,1,117,1,144,1,114,76,116,22,124,
+ 4,131,1,144,1,115,16,116,23,116,4,160,24,161,0,124,
+ 4,131,2,125,4,124,4,100,5,25,0,100,11,107,2,144,
+ 1,114,56,124,4,100,8,25,0,116,25,118,1,144,1,114,
+ 56,124,4,100,12,100,1,133,2,25,0,125,4,116,23,116,
+ 8,106,21,124,4,160,26,116,25,161,1,124,11,131,3,83,
+ 0,116,23,124,4,116,27,124,11,131,3,83,0,41,13,97,
+ 254,2,0,0,71,105,118,101,110,32,116,104,101,32,112,97,
+ 116,104,32,116,111,32,97,32,46,112,121,32,102,105,108,101,
+ 44,32,114,101,116,117,114,110,32,116,104,101,32,112,97,116,
+ 104,32,116,111,32,105,116,115,32,46,112,121,99,32,102,105,
+ 108,101,46,10,10,32,32,32,32,84,104,101,32,46,112,121,
+ 32,102,105,108,101,32,100,111,101,115,32,110,111,116,32,110,
+ 101,101,100,32,116,111,32,101,120,105,115,116,59,32,116,104,
+ 105,115,32,115,105,109,112,108,121,32,114,101,116,117,114,110,
+ 115,32,116,104,101,32,112,97,116,104,32,116,111,32,116,104,
+ 101,10,32,32,32,32,46,112,121,99,32,102,105,108,101,32,
+ 99,97,108,99,117,108,97,116,101,100,32,97,115,32,105,102,
+ 32,116,104,101,32,46,112,121,32,102,105,108,101,32,119,101,
+ 114,101,32,105,109,112,111,114,116,101,100,46,10,10,32,32,
+ 32,32,84,104,101,32,39,111,112,116,105,109,105,122,97,116,
+ 105,111,110,39,32,112,97,114,97,109,101,116,101,114,32,99,
+ 111,110,116,114,111,108,115,32,116,104,101,32,112,114,101,115,
+ 117,109,101,100,32,111,112,116,105,109,105,122,97,116,105,111,
+ 110,32,108,101,118,101,108,32,111,102,10,32,32,32,32,116,
+ 104,101,32,98,121,116,101,99,111,100,101,32,102,105,108,101,
+ 46,32,73,102,32,39,111,112,116,105,109,105,122,97,116,105,
+ 111,110,39,32,105,115,32,110,111,116,32,78,111,110,101,44,
+ 32,116,104,101,32,115,116,114,105,110,103,32,114,101,112,114,
+ 101,115,101,110,116,97,116,105,111,110,10,32,32,32,32,111,
+ 102,32,116,104,101,32,97,114,103,117,109,101,110,116,32,105,
+ 115,32,116,97,107,101,110,32,97,110,100,32,118,101,114,105,
+ 102,105,101,100,32,116,111,32,98,101,32,97,108,112,104,97,
+ 110,117,109,101,114,105,99,32,40,101,108,115,101,32,86,97,
+ 108,117,101,69,114,114,111,114,10,32,32,32,32,105,115,32,
+ 114,97,105,115,101,100,41,46,10,10,32,32,32,32,84,104,
+ 101,32,100,101,98,117,103,95,111,118,101,114,114,105,100,101,
+ 32,112,97,114,97,109,101,116,101,114,32,105,115,32,100,101,
+ 112,114,101,99,97,116,101,100,46,32,73,102,32,100,101,98,
+ 117,103,95,111,118,101,114,114,105,100,101,32,105,115,32,110,
+ 111,116,32,78,111,110,101,44,10,32,32,32,32,97,32,84,
+ 114,117,101,32,118,97,108,117,101,32,105,115,32,116,104,101,
+ 32,115,97,109,101,32,97,115,32,115,101,116,116,105,110,103,
+ 32,39,111,112,116,105,109,105,122,97,116,105,111,110,39,32,
+ 116,111,32,116,104,101,32,101,109,112,116,121,32,115,116,114,
+ 105,110,103,10,32,32,32,32,119,104,105,108,101,32,97,32,
+ 70,97,108,115,101,32,118,97,108,117,101,32,105,115,32,101,
+ 113,117,105,118,97,108,101,110,116,32,116,111,32,115,101,116,
+ 116,105,110,103,32,39,111,112,116,105,109,105,122,97,116,105,
+ 111,110,39,32,116,111,32,39,49,39,46,10,10,32,32,32,
+ 32,73,102,32,115,121,115,46,105,109,112,108,101,109,101,110,
+ 116,97,116,105,111,110,46,99,97,99,104,101,95,116,97,103,
+ 32,105,115,32,78,111,110,101,32,116,104,101,110,32,78,111,
+ 116,73,109,112,108,101,109,101,110,116,101,100,69,114,114,111,
+ 114,32,105,115,32,114,97,105,115,101,100,46,10,10,32,32,
+ 32,32,78,122,70,116,104,101,32,100,101,98,117,103,95,111,
+ 118,101,114,114,105,100,101,32,112,97,114,97,109,101,116,101,
+ 114,32,105,115,32,100,101,112,114,101,99,97,116,101,100,59,
+ 32,117,115,101,32,39,111,112,116,105,109,105,122,97,116,105,
+ 111,110,39,32,105,110,115,116,101,97,100,122,50,100,101,98,
+ 117,103,95,111,118,101,114,114,105,100,101,32,111,114,32,111,
+ 112,116,105,109,105,122,97,116,105,111,110,32,109,117,115,116,
+ 32,98,101,32,115,101,116,32,116,111,32,78,111,110,101,114,
+ 10,0,0,0,114,3,0,0,0,218,1,46,250,36,115,121,
+ 115,46,105,109,112,108,101,109,101,110,116,97,116,105,111,110,
+ 46,99,97,99,104,101,95,116,97,103,32,105,115,32,78,111,
+ 110,101,114,0,0,0,0,122,24,123,33,114,125,32,105,115,
+ 32,110,111,116,32,97,108,112,104,97,110,117,109,101,114,105,
+ 99,122,7,123,125,46,123,125,123,125,114,11,0,0,0,114,
+ 39,0,0,0,41,28,218,9,95,119,97,114,110,105,110,103,
+ 115,218,4,119,97,114,110,218,18,68,101,112,114,101,99,97,
+ 116,105,111,110,87,97,114,110,105,110,103,218,9,84,121,112,
+ 101,69,114,114,111,114,114,18,0,0,0,218,6,102,115,112,
+ 97,116,104,114,55,0,0,0,114,49,0,0,0,114,15,0,
+ 0,0,218,14,105,109,112,108,101,109,101,110,116,97,116,105,
+ 111,110,218,9,99,97,99,104,101,95,116,97,103,218,19,78,
+ 111,116,73,109,112,108,101,109,101,110,116,101,100,69,114,114,
+ 111,114,114,46,0,0,0,114,16,0,0,0,218,8,111,112,
+ 116,105,109,105,122,101,218,3,115,116,114,218,7,105,115,97,
+ 108,110,117,109,218,10,86,97,108,117,101,69,114,114,111,114,
+ 114,70,0,0,0,218,4,95,79,80,84,218,17,66,89,84,
+ 69,67,79,68,69,95,83,85,70,70,73,88,69,83,218,14,
+ 112,121,99,97,99,104,101,95,112,114,101,102,105,120,114,67,
+ 0,0,0,114,48,0,0,0,114,63,0,0,0,114,42,0,
+ 0,0,218,6,108,115,116,114,105,112,218,8,95,80,89,67,
+ 65,67,72,69,41,12,114,52,0,0,0,90,14,100,101,98,
+ 117,103,95,111,118,101,114,114,105,100,101,114,78,0,0,0,
+ 218,7,109,101,115,115,97,103,101,218,4,104,101,97,100,114,
+ 54,0,0,0,90,4,98,97,115,101,114,6,0,0,0,218,
+ 4,114,101,115,116,90,3,116,97,103,90,15,97,108,109,111,
+ 115,116,95,102,105,108,101,110,97,109,101,218,8,102,105,108,
+ 101,110,97,109,101,114,7,0,0,0,114,7,0,0,0,114,
+ 8,0,0,0,218,17,99,97,99,104,101,95,102,114,111,109,
+ 95,115,111,117,114,99,101,85,1,0,0,115,74,0,0,0,
+ 8,18,6,1,2,1,4,255,8,2,4,1,8,1,12,1,
+ 10,1,12,1,16,1,8,1,8,1,8,1,24,1,8,1,
+ 12,1,6,1,8,2,8,1,8,1,8,1,14,1,14,1,
+ 12,1,12,1,10,9,14,1,28,5,12,1,2,4,4,1,
+ 8,1,2,1,4,253,12,5,255,128,114,102,0,0,0,99,
+ 1,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,
+ 5,0,0,0,67,0,0,0,115,44,1,0,0,116,0,106,
+ 1,106,2,100,1,117,0,114,20,116,3,100,2,131,1,130,
+ 1,116,4,160,5,124,0,161,1,125,0,116,6,124,0,131,
+ 1,92,2,125,1,125,2,100,3,125,3,116,0,106,7,100,
+ 1,117,1,114,102,116,0,106,7,160,8,116,9,161,1,125,
+ 4,124,1,160,10,124,4,116,11,23,0,161,1,114,102,124,
+ 1,116,12,124,4,131,1,100,1,133,2,25,0,125,1,100,
+ 4,125,3,124,3,115,144,116,6,124,1,131,1,92,2,125,
+ 1,125,5,124,5,116,13,107,3,114,144,116,14,116,13,155,
+ 0,100,5,124,0,155,2,157,3,131,1,130,1,124,2,160,
+ 15,100,6,161,1,125,6,124,6,100,7,118,1,114,176,116,
+ 14,100,8,124,2,155,2,157,2,131,1,130,1,124,6,100,
+ 9,107,2,144,1,114,12,124,2,160,16,100,6,100,10,161,
+ 2,100,11,25,0,125,7,124,7,160,10,116,17,161,1,115,
+ 226,116,14,100,12,116,17,155,2,157,2,131,1,130,1,124,
+ 7,116,12,116,17,131,1,100,1,133,2,25,0,125,8,124,
+ 8,160,18,161,0,144,1,115,12,116,14,100,13,124,7,155,
+ 2,100,14,157,3,131,1,130,1,124,2,160,19,100,6,161,
+ 1,100,15,25,0,125,9,116,20,124,1,124,9,116,21,100,
+ 15,25,0,23,0,131,2,83,0,41,16,97,110,1,0,0,
+ 71,105,118,101,110,32,116,104,101,32,112,97,116,104,32,116,
+ 111,32,97,32,46,112,121,99,46,32,102,105,108,101,44,32,
+ 114,101,116,117,114,110,32,116,104,101,32,112,97,116,104,32,
+ 116,111,32,105,116,115,32,46,112,121,32,102,105,108,101,46,
+ 10,10,32,32,32,32,84,104,101,32,46,112,121,99,32,102,
+ 105,108,101,32,100,111,101,115,32,110,111,116,32,110,101,101,
+ 100,32,116,111,32,101,120,105,115,116,59,32,116,104,105,115,
+ 32,115,105,109,112,108,121,32,114,101,116,117,114,110,115,32,
+ 116,104,101,32,112,97,116,104,32,116,111,10,32,32,32,32,
+ 116,104,101,32,46,112,121,32,102,105,108,101,32,99,97,108,
+ 99,117,108,97,116,101,100,32,116,111,32,99,111,114,114,101,
+ 115,112,111,110,100,32,116,111,32,116,104,101,32,46,112,121,
+ 99,32,102,105,108,101,46,32,32,73,102,32,112,97,116,104,
+ 32,100,111,101,115,10,32,32,32,32,110,111,116,32,99,111,
+ 110,102,111,114,109,32,116,111,32,80,69,80,32,51,49,52,
+ 55,47,52,56,56,32,102,111,114,109,97,116,44,32,86,97,
+ 108,117,101,69,114,114,111,114,32,119,105,108,108,32,98,101,
+ 32,114,97,105,115,101,100,46,32,73,102,10,32,32,32,32,
+ 115,121,115,46,105,109,112,108,101,109,101,110,116,97,116,105,
+ 111,110,46,99,97,99,104,101,95,116,97,103,32,105,115,32,
+ 78,111,110,101,32,116,104,101,110,32,78,111,116,73,109,112,
+ 108,101,109,101,110,116,101,100,69,114,114,111,114,32,105,115,
+ 32,114,97,105,115,101,100,46,10,10,32,32,32,32,78,114,
+ 80,0,0,0,70,84,122,31,32,110,111,116,32,98,111,116,
+ 116,111,109,45,108,101,118,101,108,32,100,105,114,101,99,116,
+ 111,114,121,32,105,110,32,114,79,0,0,0,62,2,0,0,
+ 0,114,39,0,0,0,114,65,0,0,0,122,29,101,120,112,
+ 101,99,116,101,100,32,111,110,108,121,32,50,32,111,114,32,
+ 51,32,100,111,116,115,32,105,110,32,114,65,0,0,0,114,
+ 39,0,0,0,233,254,255,255,255,122,53,111,112,116,105,109,
+ 105,122,97,116,105,111,110,32,112,111,114,116,105,111,110,32,
+ 111,102,32,102,105,108,101,110,97,109,101,32,100,111,101,115,
+ 32,110,111,116,32,115,116,97,114,116,32,119,105,116,104,32,
+ 122,19,111,112,116,105,109,105,122,97,116,105,111,110,32,108,
+ 101,118,101,108,32,122,29,32,105,115,32,110,111,116,32,97,
+ 110,32,97,108,112,104,97,110,117,109,101,114,105,99,32,118,
+ 97,108,117,101,114,0,0,0,0,41,22,114,15,0,0,0,
+ 114,86,0,0,0,114,87,0,0,0,114,88,0,0,0,114,
+ 18,0,0,0,114,85,0,0,0,114,55,0,0,0,114,95,
+ 0,0,0,114,41,0,0,0,114,42,0,0,0,114,23,0,
+ 0,0,114,45,0,0,0,114,4,0,0,0,114,97,0,0,
+ 0,114,92,0,0,0,218,5,99,111,117,110,116,114,51,0,
+ 0,0,114,93,0,0,0,114,91,0,0,0,218,9,112,97,
+ 114,116,105,116,105,111,110,114,48,0,0,0,218,15,83,79,
+ 85,82,67,69,95,83,85,70,70,73,88,69,83,41,10,114,
+ 52,0,0,0,114,99,0,0,0,90,16,112,121,99,97,99,
+ 104,101,95,102,105,108,101,110,97,109,101,90,23,102,111,117,
+ 110,100,95,105,110,95,112,121,99,97,99,104,101,95,112,114,
+ 101,102,105,120,90,13,115,116,114,105,112,112,101,100,95,112,
+ 97,116,104,90,7,112,121,99,97,99,104,101,90,9,100,111,
+ 116,95,99,111,117,110,116,114,78,0,0,0,90,9,111,112,
+ 116,95,108,101,118,101,108,90,13,98,97,115,101,95,102,105,
+ 108,101,110,97,109,101,114,7,0,0,0,114,7,0,0,0,
+ 114,8,0,0,0,218,17,115,111,117,114,99,101,95,102,114,
+ 111,109,95,99,97,99,104,101,156,1,0,0,115,62,0,0,
+ 0,12,9,8,1,10,1,12,1,4,1,10,1,12,1,14,
+ 1,16,1,4,1,4,1,12,1,8,1,8,1,2,1,8,
+ 255,10,2,8,1,14,1,10,1,16,1,10,1,4,1,2,
+ 1,8,255,16,2,10,1,16,1,14,2,18,1,255,128,114,
+ 107,0,0,0,99,1,0,0,0,0,0,0,0,0,0,0,
+ 0,5,0,0,0,9,0,0,0,67,0,0,0,115,122,0,
+ 0,0,116,0,124,0,131,1,100,1,107,2,114,16,100,2,
+ 83,0,124,0,160,1,100,3,161,1,92,3,125,1,125,2,
+ 125,3,124,1,114,56,124,3,160,2,161,0,100,4,100,5,
+ 133,2,25,0,100,6,107,3,114,60,124,0,83,0,122,12,
+ 116,3,124,0,131,1,125,4,87,0,110,30,4,0,116,4,
+ 116,5,102,2,121,120,1,0,1,0,1,0,124,0,100,2,
+ 100,5,133,2,25,0,125,4,89,0,116,6,124,4,131,1,
+ 114,116,124,4,83,0,124,0,83,0,119,0,41,7,122,188,
+ 67,111,110,118,101,114,116,32,97,32,98,121,116,101,99,111,
+ 100,101,32,102,105,108,101,32,112,97,116,104,32,116,111,32,
+ 97,32,115,111,117,114,99,101,32,112,97,116,104,32,40,105,
+ 102,32,112,111,115,115,105,98,108,101,41,46,10,10,32,32,
+ 32,32,84,104,105,115,32,102,117,110,99,116,105,111,110,32,
+ 101,120,105,115,116,115,32,112,117,114,101,108,121,32,102,111,
+ 114,32,98,97,99,107,119,97,114,100,115,45,99,111,109,112,
+ 97,116,105,98,105,108,105,116,121,32,102,111,114,10,32,32,
+ 32,32,80,121,73,109,112,111,114,116,95,69,120,101,99,67,
+ 111,100,101,77,111,100,117,108,101,87,105,116,104,70,105,108,
+ 101,110,97,109,101,115,40,41,32,105,110,32,116,104,101,32,
+ 67,32,65,80,73,46,10,10,32,32,32,32,114,0,0,0,
+ 0,78,114,79,0,0,0,233,253,255,255,255,233,255,255,255,
+ 255,90,2,112,121,41,7,114,4,0,0,0,114,49,0,0,
+ 0,218,5,108,111,119,101,114,114,107,0,0,0,114,88,0,
+ 0,0,114,92,0,0,0,114,62,0,0,0,41,5,218,13,
+ 98,121,116,101,99,111,100,101,95,112,97,116,104,114,100,0,
+ 0,0,114,53,0,0,0,90,9,101,120,116,101,110,115,105,
+ 111,110,218,11,115,111,117,114,99,101,95,112,97,116,104,114,
+ 7,0,0,0,114,7,0,0,0,114,8,0,0,0,218,15,
+ 95,103,101,116,95,115,111,117,114,99,101,102,105,108,101,196,
+ 1,0,0,115,24,0,0,0,12,7,4,1,16,1,24,1,
+ 4,1,2,1,12,1,16,1,14,1,16,1,2,254,255,128,
+ 114,113,0,0,0,99,1,0,0,0,0,0,0,0,0,0,
+ 0,0,1,0,0,0,8,0,0,0,67,0,0,0,115,68,
+ 0,0,0,124,0,160,0,116,1,116,2,131,1,161,1,114,
+ 44,122,10,116,3,124,0,131,1,87,0,83,0,4,0,116,
+ 4,121,66,1,0,1,0,1,0,89,0,100,0,83,0,124,
+ 0,160,0,116,1,116,5,131,1,161,1,114,62,124,0,83,
+ 0,100,0,83,0,119,0,169,1,78,41,6,218,8,101,110,
+ 100,115,119,105,116,104,218,5,116,117,112,108,101,114,106,0,
+ 0,0,114,102,0,0,0,114,88,0,0,0,114,94,0,0,
+ 0,41,1,114,101,0,0,0,114,7,0,0,0,114,7,0,
+ 0,0,114,8,0,0,0,218,11,95,103,101,116,95,99,97,
+ 99,104,101,100,215,1,0,0,115,20,0,0,0,14,1,2,
+ 1,10,1,12,1,6,1,14,1,4,1,4,2,2,251,255,
+ 128,114,117,0,0,0,99,1,0,0,0,0,0,0,0,0,
0,0,0,2,0,0,0,8,0,0,0,67,0,0,0,115,
- 50,0,0,0,122,14,116,0,124,0,131,1,106,1,125,1,
- 87,0,110,22,4,0,116,2,121,36,1,0,1,0,1,0,
- 100,1,125,1,89,0,110,2,48,0,124,1,100,2,79,0,
- 125,1,124,1,83,0,41,3,122,51,67,97,108,99,117,108,
- 97,116,101,32,116,104,101,32,109,111,100,101,32,112,101,114,
- 109,105,115,115,105,111,110,115,32,102,111,114,32,97,32,98,
- 121,116,101,99,111,100,101,32,102,105,108,101,46,114,60,0,
- 0,0,233,128,0,0,0,41,3,114,49,0,0,0,114,51,
- 0,0,0,114,50,0,0,0,41,2,114,44,0,0,0,114,
- 52,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,
- 0,0,0,218,10,95,99,97,108,99,95,109,111,100,101,188,
- 1,0,0,115,12,0,0,0,0,2,2,1,14,1,12,1,
- 10,3,8,1,114,114,0,0,0,99,1,0,0,0,0,0,
- 0,0,0,0,0,0,3,0,0,0,8,0,0,0,3,0,
- 0,0,115,66,0,0,0,100,6,135,0,102,1,100,2,100,
- 3,132,9,125,1,122,10,116,0,106,1,125,2,87,0,110,
- 26,4,0,116,2,121,50,1,0,1,0,1,0,100,4,100,
- 5,132,0,125,2,89,0,110,2,48,0,124,2,124,1,136,
- 0,131,2,1,0,124,1,83,0,41,7,122,252,68,101,99,
- 111,114,97,116,111,114,32,116,111,32,118,101,114,105,102,121,
- 32,116,104,97,116,32,116,104,101,32,109,111,100,117,108,101,
- 32,98,101,105,110,103,32,114,101,113,117,101,115,116,101,100,
- 32,109,97,116,99,104,101,115,32,116,104,101,32,111,110,101,
- 32,116,104,101,10,32,32,32,32,108,111,97,100,101,114,32,
- 99,97,110,32,104,97,110,100,108,101,46,10,10,32,32,32,
- 32,84,104,101,32,102,105,114,115,116,32,97,114,103,117,109,
- 101,110,116,32,40,115,101,108,102,41,32,109,117,115,116,32,
- 100,101,102,105,110,101,32,95,110,97,109,101,32,119,104,105,
- 99,104,32,116,104,101,32,115,101,99,111,110,100,32,97,114,
- 103,117,109,101,110,116,32,105,115,10,32,32,32,32,99,111,
- 109,112,97,114,101,100,32,97,103,97,105,110,115,116,46,32,
- 73,102,32,116,104,101,32,99,111,109,112,97,114,105,115,111,
- 110,32,102,97,105,108,115,32,116,104,101,110,32,73,109,112,
- 111,114,116,69,114,114,111,114,32,105,115,32,114,97,105,115,
- 101,100,46,10,10,32,32,32,32,78,99,2,0,0,0,0,
- 0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,31,
- 0,0,0,115,72,0,0,0,124,1,100,0,117,0,114,16,
- 124,0,106,0,125,1,110,32,124,0,106,0,124,1,107,3,
- 114,48,116,1,100,1,124,0,106,0,124,1,102,2,22,0,
- 124,1,100,2,141,2,130,1,136,0,124,0,124,1,103,2,
- 124,2,162,1,82,0,105,0,124,3,164,1,142,1,83,0,
- 41,3,78,122,30,108,111,97,100,101,114,32,102,111,114,32,
- 37,115,32,99,97,110,110,111,116,32,104,97,110,100,108,101,
- 32,37,115,169,1,218,4,110,97,109,101,41,2,114,116,0,
- 0,0,218,11,73,109,112,111,114,116,69,114,114,111,114,41,
- 4,218,4,115,101,108,102,114,116,0,0,0,218,4,97,114,
- 103,115,218,6,107,119,97,114,103,115,169,1,218,6,109,101,
- 116,104,111,100,114,5,0,0,0,114,8,0,0,0,218,19,
- 95,99,104,101,99,107,95,110,97,109,101,95,119,114,97,112,
- 112,101,114,208,1,0,0,115,18,0,0,0,0,1,8,1,
- 8,1,10,1,4,1,8,255,2,1,2,255,6,2,122,40,
- 95,99,104,101,99,107,95,110,97,109,101,46,60,108,111,99,
- 97,108,115,62,46,95,99,104,101,99,107,95,110,97,109,101,
- 95,119,114,97,112,112,101,114,99,2,0,0,0,0,0,0,
- 0,0,0,0,0,3,0,0,0,7,0,0,0,83,0,0,
- 0,115,56,0,0,0,100,1,68,0,93,32,125,2,116,0,
- 124,1,124,2,131,2,114,4,116,1,124,0,124,2,116,2,
- 124,1,124,2,131,2,131,3,1,0,113,4,124,0,106,3,
- 160,4,124,1,106,3,161,1,1,0,100,0,83,0,41,2,
- 78,41,4,218,10,95,95,109,111,100,117,108,101,95,95,218,
- 8,95,95,110,97,109,101,95,95,218,12,95,95,113,117,97,
- 108,110,97,109,101,95,95,218,7,95,95,100,111,99,95,95,
- 41,5,218,7,104,97,115,97,116,116,114,218,7,115,101,116,
- 97,116,116,114,218,7,103,101,116,97,116,116,114,218,8,95,
- 95,100,105,99,116,95,95,218,6,117,112,100,97,116,101,41,
- 3,90,3,110,101,119,90,3,111,108,100,114,67,0,0,0,
- 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,
- 5,95,119,114,97,112,219,1,0,0,115,8,0,0,0,0,
- 1,8,1,10,1,20,1,122,26,95,99,104,101,99,107,95,
- 110,97,109,101,46,60,108,111,99,97,108,115,62,46,95,119,
- 114,97,112,41,1,78,41,3,218,10,95,98,111,111,116,115,
- 116,114,97,112,114,133,0,0,0,218,9,78,97,109,101,69,
- 114,114,111,114,41,3,114,122,0,0,0,114,123,0,0,0,
- 114,133,0,0,0,114,5,0,0,0,114,121,0,0,0,114,
+ 48,0,0,0,122,14,116,0,124,0,131,1,106,1,125,1,
+ 87,0,110,18,4,0,116,2,121,46,1,0,1,0,1,0,
+ 100,1,125,1,89,0,124,1,100,2,79,0,125,1,124,1,
+ 83,0,119,0,41,4,122,51,67,97,108,99,117,108,97,116,
+ 101,32,116,104,101,32,109,111,100,101,32,112,101,114,109,105,
+ 115,115,105,111,110,115,32,102,111,114,32,97,32,98,121,116,
+ 101,99,111,100,101,32,102,105,108,101,46,114,68,0,0,0,
+ 233,128,0,0,0,78,41,3,114,57,0,0,0,114,59,0,
+ 0,0,114,58,0,0,0,41,2,114,52,0,0,0,114,60,
+ 0,0,0,114,7,0,0,0,114,7,0,0,0,114,8,0,
+ 0,0,218,10,95,99,97,108,99,95,109,111,100,101,227,1,
+ 0,0,115,16,0,0,0,2,2,14,1,12,1,6,1,8,
+ 3,4,1,2,251,255,128,114,119,0,0,0,99,1,0,0,
+ 0,0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,
+ 0,3,0,0,0,115,52,0,0,0,100,6,135,0,102,1,
+ 100,2,100,3,132,9,125,1,116,0,100,1,117,1,114,30,
+ 116,0,106,1,125,2,110,8,100,4,100,5,132,0,125,2,
+ 124,2,124,1,136,0,131,2,1,0,124,1,83,0,41,7,
+ 122,252,68,101,99,111,114,97,116,111,114,32,116,111,32,118,
+ 101,114,105,102,121,32,116,104,97,116,32,116,104,101,32,109,
+ 111,100,117,108,101,32,98,101,105,110,103,32,114,101,113,117,
+ 101,115,116,101,100,32,109,97,116,99,104,101,115,32,116,104,
+ 101,32,111,110,101,32,116,104,101,10,32,32,32,32,108,111,
+ 97,100,101,114,32,99,97,110,32,104,97,110,100,108,101,46,
+ 10,10,32,32,32,32,84,104,101,32,102,105,114,115,116,32,
+ 97,114,103,117,109,101,110,116,32,40,115,101,108,102,41,32,
+ 109,117,115,116,32,100,101,102,105,110,101,32,95,110,97,109,
+ 101,32,119,104,105,99,104,32,116,104,101,32,115,101,99,111,
+ 110,100,32,97,114,103,117,109,101,110,116,32,105,115,10,32,
+ 32,32,32,99,111,109,112,97,114,101,100,32,97,103,97,105,
+ 110,115,116,46,32,73,102,32,116,104,101,32,99,111,109,112,
+ 97,114,105,115,111,110,32,102,97,105,108,115,32,116,104,101,
+ 110,32,73,109,112,111,114,116,69,114,114,111,114,32,105,115,
+ 32,114,97,105,115,101,100,46,10,10,32,32,32,32,78,99,
+ 2,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,
+ 4,0,0,0,31,0,0,0,115,72,0,0,0,124,1,100,
+ 0,117,0,114,16,124,0,106,0,125,1,110,32,124,0,106,
+ 0,124,1,107,3,114,48,116,1,100,1,124,0,106,0,124,
+ 1,102,2,22,0,124,1,100,2,141,2,130,1,136,0,124,
+ 0,124,1,103,2,124,2,162,1,82,0,105,0,124,3,164,
+ 1,142,1,83,0,41,3,78,122,30,108,111,97,100,101,114,
+ 32,102,111,114,32,37,115,32,99,97,110,110,111,116,32,104,
+ 97,110,100,108,101,32,37,115,169,1,218,4,110,97,109,101,
+ 41,2,114,121,0,0,0,218,11,73,109,112,111,114,116,69,
+ 114,114,111,114,41,4,218,4,115,101,108,102,114,121,0,0,
+ 0,218,4,97,114,103,115,218,6,107,119,97,114,103,115,169,
+ 1,218,6,109,101,116,104,111,100,114,7,0,0,0,114,8,
+ 0,0,0,218,19,95,99,104,101,99,107,95,110,97,109,101,
+ 95,119,114,97,112,112,101,114,247,1,0,0,115,20,0,0,
+ 0,8,1,8,1,10,1,4,1,8,1,2,255,2,1,6,
+ 255,24,2,255,128,122,40,95,99,104,101,99,107,95,110,97,
+ 109,101,46,60,108,111,99,97,108,115,62,46,95,99,104,101,
+ 99,107,95,110,97,109,101,95,119,114,97,112,112,101,114,99,
+ 2,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,
+ 7,0,0,0,83,0,0,0,115,56,0,0,0,100,1,68,
+ 0,93,32,125,2,116,0,124,1,124,2,131,2,114,36,116,
+ 1,124,0,124,2,116,2,124,1,124,2,131,2,131,3,1,
+ 0,113,4,124,0,106,3,160,4,124,1,106,3,161,1,1,
+ 0,100,0,83,0,41,2,78,41,4,218,10,95,95,109,111,
+ 100,117,108,101,95,95,218,8,95,95,110,97,109,101,95,95,
+ 218,12,95,95,113,117,97,108,110,97,109,101,95,95,218,7,
+ 95,95,100,111,99,95,95,41,5,218,7,104,97,115,97,116,
+ 116,114,218,7,115,101,116,97,116,116,114,218,7,103,101,116,
+ 97,116,116,114,218,8,95,95,100,105,99,116,95,95,218,6,
+ 117,112,100,97,116,101,41,3,90,3,110,101,119,90,3,111,
+ 108,100,114,75,0,0,0,114,7,0,0,0,114,7,0,0,
+ 0,114,8,0,0,0,218,5,95,119,114,97,112,4,2,0,
+ 0,115,12,0,0,0,8,1,10,1,18,1,2,128,18,1,
+ 255,128,122,26,95,99,104,101,99,107,95,110,97,109,101,46,
+ 60,108,111,99,97,108,115,62,46,95,119,114,97,112,41,1,
+ 78,41,2,218,10,95,98,111,111,116,115,116,114,97,112,114,
+ 138,0,0,0,41,3,114,127,0,0,0,114,128,0,0,0,
+ 114,138,0,0,0,114,7,0,0,0,114,126,0,0,0,114,
8,0,0,0,218,11,95,99,104,101,99,107,95,110,97,109,
- 101,200,1,0,0,115,14,0,0,0,0,8,14,7,2,1,
- 10,1,12,2,14,5,10,1,114,136,0,0,0,99,2,0,
+ 101,239,1,0,0,115,14,0,0,0,14,8,8,10,8,1,
+ 8,2,10,6,4,1,255,128,114,140,0,0,0,99,2,0,
0,0,0,0,0,0,0,0,0,0,5,0,0,0,6,0,
0,0,67,0,0,0,115,60,0,0,0,124,0,160,0,124,
1,161,1,92,2,125,2,125,3,124,2,100,1,117,0,114,
@@ -628,112 +660,45 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = {
10,10,32,32,32,32,78,122,44,78,111,116,32,105,109,112,
111,114,116,105,110,103,32,100,105,114,101,99,116,111,114,121,
32,123,125,58,32,109,105,115,115,105,110,103,32,95,95,105,
- 110,105,116,95,95,114,73,0,0,0,41,6,218,11,102,105,
- 110,100,95,108,111,97,100,101,114,114,23,0,0,0,114,75,
- 0,0,0,114,76,0,0,0,114,62,0,0,0,218,13,73,
- 109,112,111,114,116,87,97,114,110,105,110,103,41,5,114,118,
+ 110,105,116,95,95,114,0,0,0,0,41,6,218,11,102,105,
+ 110,100,95,108,111,97,100,101,114,114,4,0,0,0,114,81,
+ 0,0,0,114,82,0,0,0,114,70,0,0,0,218,13,73,
+ 109,112,111,114,116,87,97,114,110,105,110,103,41,5,114,123,
0,0,0,218,8,102,117,108,108,110,97,109,101,218,6,108,
111,97,100,101,114,218,8,112,111,114,116,105,111,110,115,218,
- 3,109,115,103,114,5,0,0,0,114,5,0,0,0,114,8,
+ 3,109,115,103,114,7,0,0,0,114,7,0,0,0,114,8,
0,0,0,218,17,95,102,105,110,100,95,109,111,100,117,108,
- 101,95,115,104,105,109,228,1,0,0,115,10,0,0,0,0,
- 10,14,1,16,1,4,1,22,1,114,143,0,0,0,99,3,
- 0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,4,
- 0,0,0,67,0,0,0,115,166,0,0,0,124,0,100,1,
- 100,2,133,2,25,0,125,3,124,3,116,0,107,3,114,64,
- 100,3,124,1,155,2,100,4,124,3,155,2,157,4,125,4,
- 116,1,160,2,100,5,124,4,161,2,1,0,116,3,124,4,
- 102,1,105,0,124,2,164,1,142,1,130,1,116,4,124,0,
- 131,1,100,6,107,0,114,106,100,7,124,1,155,2,157,2,
- 125,4,116,1,160,2,100,5,124,4,161,2,1,0,116,5,
- 124,4,131,1,130,1,116,6,124,0,100,2,100,8,133,2,
- 25,0,131,1,125,5,124,5,100,9,64,0,114,162,100,10,
- 124,5,155,2,100,11,124,1,155,2,157,4,125,4,116,3,
- 124,4,102,1,105,0,124,2,164,1,142,1,130,1,124,5,
- 83,0,41,12,97,84,2,0,0,80,101,114,102,111,114,109,
- 32,98,97,115,105,99,32,118,97,108,105,100,105,116,121,32,
- 99,104,101,99,107,105,110,103,32,111,102,32,97,32,112,121,
- 99,32,104,101,97,100,101,114,32,97,110,100,32,114,101,116,
- 117,114,110,32,116,104,101,32,102,108,97,103,115,32,102,105,
- 101,108,100,44,10,32,32,32,32,119,104,105,99,104,32,100,
- 101,116,101,114,109,105,110,101,115,32,104,111,119,32,116,104,
- 101,32,112,121,99,32,115,104,111,117,108,100,32,98,101,32,
- 102,117,114,116,104,101,114,32,118,97,108,105,100,97,116,101,
- 100,32,97,103,97,105,110,115,116,32,116,104,101,32,115,111,
- 117,114,99,101,46,10,10,32,32,32,32,42,100,97,116,97,
- 42,32,105,115,32,116,104,101,32,99,111,110,116,101,110,116,
- 115,32,111,102,32,116,104,101,32,112,121,99,32,102,105,108,
- 101,46,32,40,79,110,108,121,32,116,104,101,32,102,105,114,
- 115,116,32,49,54,32,98,121,116,101,115,32,97,114,101,10,
- 32,32,32,32,114,101,113,117,105,114,101,100,44,32,116,104,
- 111,117,103,104,46,41,10,10,32,32,32,32,42,110,97,109,
- 101,42,32,105,115,32,116,104,101,32,110,97,109,101,32,111,
- 102,32,116,104,101,32,109,111,100,117,108,101,32,98,101,105,
- 110,103,32,105,109,112,111,114,116,101,100,46,32,73,116,32,
- 105,115,32,117,115,101,100,32,102,111,114,32,108,111,103,103,
- 105,110,103,46,10,10,32,32,32,32,42,101,120,99,95,100,
- 101,116,97,105,108,115,42,32,105,115,32,97,32,100,105,99,
- 116,105,111,110,97,114,121,32,112,97,115,115,101,100,32,116,
- 111,32,73,109,112,111,114,116,69,114,114,111,114,32,105,102,
- 32,105,116,32,114,97,105,115,101,100,32,102,111,114,10,32,
- 32,32,32,105,109,112,114,111,118,101,100,32,100,101,98,117,
- 103,103,105,110,103,46,10,10,32,32,32,32,73,109,112,111,
- 114,116,69,114,114,111,114,32,105,115,32,114,97,105,115,101,
- 100,32,119,104,101,110,32,116,104,101,32,109,97,103,105,99,
- 32,110,117,109,98,101,114,32,105,115,32,105,110,99,111,114,
- 114,101,99,116,32,111,114,32,119,104,101,110,32,116,104,101,
- 32,102,108,97,103,115,10,32,32,32,32,102,105,101,108,100,
- 32,105,115,32,105,110,118,97,108,105,100,46,32,69,79,70,
- 69,114,114,111,114,32,105,115,32,114,97,105,115,101,100,32,
- 119,104,101,110,32,116,104,101,32,100,97,116,97,32,105,115,
- 32,102,111,117,110,100,32,116,111,32,98,101,32,116,114,117,
- 110,99,97,116,101,100,46,10,10,32,32,32,32,78,114,16,
- 0,0,0,122,20,98,97,100,32,109,97,103,105,99,32,110,
- 117,109,98,101,114,32,105,110,32,122,2,58,32,250,2,123,
- 125,233,16,0,0,0,122,40,114,101,97,99,104,101,100,32,
- 69,79,70,32,119,104,105,108,101,32,114,101,97,100,105,110,
- 103,32,112,121,99,32,104,101,97,100,101,114,32,111,102,32,
- 233,8,0,0,0,233,252,255,255,255,122,14,105,110,118,97,
- 108,105,100,32,102,108,97,103,115,32,122,4,32,105,110,32,
- 41,7,218,12,77,65,71,73,67,95,78,85,77,66,69,82,
- 114,134,0,0,0,218,16,95,118,101,114,98,111,115,101,95,
- 109,101,115,115,97,103,101,114,117,0,0,0,114,23,0,0,
- 0,218,8,69,79,70,69,114,114,111,114,114,27,0,0,0,
- 41,6,114,26,0,0,0,114,116,0,0,0,218,11,101,120,
- 99,95,100,101,116,97,105,108,115,90,5,109,97,103,105,99,
- 114,92,0,0,0,114,2,0,0,0,114,5,0,0,0,114,
- 5,0,0,0,114,8,0,0,0,218,13,95,99,108,97,115,
- 115,105,102,121,95,112,121,99,245,1,0,0,115,28,0,0,
- 0,0,16,12,1,8,1,16,1,12,1,16,1,12,1,10,
- 1,12,1,8,1,16,2,8,1,16,1,16,1,114,152,0,
- 0,0,99,5,0,0,0,0,0,0,0,0,0,0,0,6,
- 0,0,0,4,0,0,0,67,0,0,0,115,120,0,0,0,
- 116,0,124,0,100,1,100,2,133,2,25,0,131,1,124,1,
- 100,3,64,0,107,3,114,62,100,4,124,3,155,2,157,2,
- 125,5,116,1,160,2,100,5,124,5,161,2,1,0,116,3,
- 124,5,102,1,105,0,124,4,164,1,142,1,130,1,124,2,
- 100,6,117,1,114,116,116,0,124,0,100,2,100,7,133,2,
- 25,0,131,1,124,2,100,3,64,0,107,3,114,116,116,3,
- 100,4,124,3,155,2,157,2,102,1,105,0,124,4,164,1,
- 142,1,130,1,100,6,83,0,41,8,97,7,2,0,0,86,
- 97,108,105,100,97,116,101,32,97,32,112,121,99,32,97,103,
- 97,105,110,115,116,32,116,104,101,32,115,111,117,114,99,101,
- 32,108,97,115,116,45,109,111,100,105,102,105,101,100,32,116,
- 105,109,101,46,10,10,32,32,32,32,42,100,97,116,97,42,
- 32,105,115,32,116,104,101,32,99,111,110,116,101,110,116,115,
- 32,111,102,32,116,104,101,32,112,121,99,32,102,105,108,101,
- 46,32,40,79,110,108,121,32,116,104,101,32,102,105,114,115,
- 116,32,49,54,32,98,121,116,101,115,32,97,114,101,10,32,
- 32,32,32,114,101,113,117,105,114,101,100,46,41,10,10,32,
- 32,32,32,42,115,111,117,114,99,101,95,109,116,105,109,101,
- 42,32,105,115,32,116,104,101,32,108,97,115,116,32,109,111,
- 100,105,102,105,101,100,32,116,105,109,101,115,116,97,109,112,
- 32,111,102,32,116,104,101,32,115,111,117,114,99,101,32,102,
- 105,108,101,46,10,10,32,32,32,32,42,115,111,117,114,99,
- 101,95,115,105,122,101,42,32,105,115,32,78,111,110,101,32,
- 111,114,32,116,104,101,32,115,105,122,101,32,111,102,32,116,
- 104,101,32,115,111,117,114,99,101,32,102,105,108,101,32,105,
- 110,32,98,121,116,101,115,46,10,10,32,32,32,32,42,110,
+ 101,95,115,104,105,109,14,2,0,0,115,12,0,0,0,14,
+ 10,16,1,4,1,22,1,4,1,255,128,114,147,0,0,0,
+ 99,3,0,0,0,0,0,0,0,0,0,0,0,6,0,0,
+ 0,4,0,0,0,67,0,0,0,115,166,0,0,0,124,0,
+ 100,1,100,2,133,2,25,0,125,3,124,3,116,0,107,3,
+ 114,64,100,3,124,1,155,2,100,4,124,3,155,2,157,4,
+ 125,4,116,1,160,2,100,5,124,4,161,2,1,0,116,3,
+ 124,4,102,1,105,0,124,2,164,1,142,1,130,1,116,4,
+ 124,0,131,1,100,6,107,0,114,106,100,7,124,1,155,2,
+ 157,2,125,4,116,1,160,2,100,5,124,4,161,2,1,0,
+ 116,5,124,4,131,1,130,1,116,6,124,0,100,2,100,8,
+ 133,2,25,0,131,1,125,5,124,5,100,9,64,0,114,162,
+ 100,10,124,5,155,2,100,11,124,1,155,2,157,4,125,4,
+ 116,3,124,4,102,1,105,0,124,2,164,1,142,1,130,1,
+ 124,5,83,0,41,12,97,84,2,0,0,80,101,114,102,111,
+ 114,109,32,98,97,115,105,99,32,118,97,108,105,100,105,116,
+ 121,32,99,104,101,99,107,105,110,103,32,111,102,32,97,32,
+ 112,121,99,32,104,101,97,100,101,114,32,97,110,100,32,114,
+ 101,116,117,114,110,32,116,104,101,32,102,108,97,103,115,32,
+ 102,105,101,108,100,44,10,32,32,32,32,119,104,105,99,104,
+ 32,100,101,116,101,114,109,105,110,101,115,32,104,111,119,32,
+ 116,104,101,32,112,121,99,32,115,104,111,117,108,100,32,98,
+ 101,32,102,117,114,116,104,101,114,32,118,97,108,105,100,97,
+ 116,101,100,32,97,103,97,105,110,115,116,32,116,104,101,32,
+ 115,111,117,114,99,101,46,10,10,32,32,32,32,42,100,97,
+ 116,97,42,32,105,115,32,116,104,101,32,99,111,110,116,101,
+ 110,116,115,32,111,102,32,116,104,101,32,112,121,99,32,102,
+ 105,108,101,46,32,40,79,110,108,121,32,116,104,101,32,102,
+ 105,114,115,116,32,49,54,32,98,121,116,101,115,32,97,114,
+ 101,10,32,32,32,32,114,101,113,117,105,114,101,100,44,32,
+ 116,104,111,117,103,104,46,41,10,10,32,32,32,32,42,110,
97,109,101,42,32,105,115,32,116,104,101,32,110,97,109,101,
32,111,102,32,116,104,101,32,109,111,100,117,108,101,32,98,
101,105,110,103,32,105,109,112,111,114,116,101,100,46,32,73,
@@ -744,334 +709,408 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = {
32,116,111,32,73,109,112,111,114,116,69,114,114,111,114,32,
105,102,32,105,116,32,114,97,105,115,101,100,32,102,111,114,
10,32,32,32,32,105,109,112,114,111,118,101,100,32,100,101,
- 98,117,103,103,105,110,103,46,10,10,32,32,32,32,65,110,
- 32,73,109,112,111,114,116,69,114,114,111,114,32,105,115,32,
- 114,97,105,115,101,100,32,105,102,32,116,104,101,32,98,121,
- 116,101,99,111,100,101,32,105,115,32,115,116,97,108,101,46,
- 10,10,32,32,32,32,114,146,0,0,0,233,12,0,0,0,
- 114,15,0,0,0,122,22,98,121,116,101,99,111,100,101,32,
- 105,115,32,115,116,97,108,101,32,102,111,114,32,114,144,0,
- 0,0,78,114,145,0,0,0,41,4,114,27,0,0,0,114,
- 134,0,0,0,114,149,0,0,0,114,117,0,0,0,41,6,
- 114,26,0,0,0,218,12,115,111,117,114,99,101,95,109,116,
- 105,109,101,218,11,115,111,117,114,99,101,95,115,105,122,101,
- 114,116,0,0,0,114,151,0,0,0,114,92,0,0,0,114,
- 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,23,
- 95,118,97,108,105,100,97,116,101,95,116,105,109,101,115,116,
- 97,109,112,95,112,121,99,22,2,0,0,115,16,0,0,0,
- 0,19,24,1,10,1,12,1,16,1,8,1,22,255,2,2,
- 114,156,0,0,0,99,4,0,0,0,0,0,0,0,0,0,
- 0,0,4,0,0,0,4,0,0,0,67,0,0,0,115,42,
- 0,0,0,124,0,100,1,100,2,133,2,25,0,124,1,107,
- 3,114,38,116,0,100,3,124,2,155,2,157,2,102,1,105,
- 0,124,3,164,1,142,1,130,1,100,4,83,0,41,5,97,
- 243,1,0,0,86,97,108,105,100,97,116,101,32,97,32,104,
- 97,115,104,45,98,97,115,101,100,32,112,121,99,32,98,121,
- 32,99,104,101,99,107,105,110,103,32,116,104,101,32,114,101,
- 97,108,32,115,111,117,114,99,101,32,104,97,115,104,32,97,
- 103,97,105,110,115,116,32,116,104,101,32,111,110,101,32,105,
- 110,10,32,32,32,32,116,104,101,32,112,121,99,32,104,101,
- 97,100,101,114,46,10,10,32,32,32,32,42,100,97,116,97,
- 42,32,105,115,32,116,104,101,32,99,111,110,116,101,110,116,
- 115,32,111,102,32,116,104,101,32,112,121,99,32,102,105,108,
- 101,46,32,40,79,110,108,121,32,116,104,101,32,102,105,114,
- 115,116,32,49,54,32,98,121,116,101,115,32,97,114,101,10,
- 32,32,32,32,114,101,113,117,105,114,101,100,46,41,10,10,
- 32,32,32,32,42,115,111,117,114,99,101,95,104,97,115,104,
- 42,32,105,115,32,116,104,101,32,105,109,112,111,114,116,108,
- 105,98,46,117,116,105,108,46,115,111,117,114,99,101,95,104,
- 97,115,104,40,41,32,111,102,32,116,104,101,32,115,111,117,
- 114,99,101,32,102,105,108,101,46,10,10,32,32,32,32,42,
- 110,97,109,101,42,32,105,115,32,116,104,101,32,110,97,109,
- 101,32,111,102,32,116,104,101,32,109,111,100,117,108,101,32,
- 98,101,105,110,103,32,105,109,112,111,114,116,101,100,46,32,
- 73,116,32,105,115,32,117,115,101,100,32,102,111,114,32,108,
- 111,103,103,105,110,103,46,10,10,32,32,32,32,42,101,120,
- 99,95,100,101,116,97,105,108,115,42,32,105,115,32,97,32,
- 100,105,99,116,105,111,110,97,114,121,32,112,97,115,115,101,
- 100,32,116,111,32,73,109,112,111,114,116,69,114,114,111,114,
- 32,105,102,32,105,116,32,114,97,105,115,101,100,32,102,111,
- 114,10,32,32,32,32,105,109,112,114,111,118,101,100,32,100,
- 101,98,117,103,103,105,110,103,46,10,10,32,32,32,32,65,
- 110,32,73,109,112,111,114,116,69,114,114,111,114,32,105,115,
- 32,114,97,105,115,101,100,32,105,102,32,116,104,101,32,98,
+ 98,117,103,103,105,110,103,46,10,10,32,32,32,32,73,109,
+ 112,111,114,116,69,114,114,111,114,32,105,115,32,114,97,105,
+ 115,101,100,32,119,104,101,110,32,116,104,101,32,109,97,103,
+ 105,99,32,110,117,109,98,101,114,32,105,115,32,105,110,99,
+ 111,114,114,101,99,116,32,111,114,32,119,104,101,110,32,116,
+ 104,101,32,102,108,97,103,115,10,32,32,32,32,102,105,101,
+ 108,100,32,105,115,32,105,110,118,97,108,105,100,46,32,69,
+ 79,70,69,114,114,111,114,32,105,115,32,114,97,105,115,101,
+ 100,32,119,104,101,110,32,116,104,101,32,100,97,116,97,32,
+ 105,115,32,102,111,117,110,100,32,116,111,32,98,101,32,116,
+ 114,117,110,99,97,116,101,100,46,10,10,32,32,32,32,78,
+ 114,28,0,0,0,122,20,98,97,100,32,109,97,103,105,99,
+ 32,110,117,109,98,101,114,32,105,110,32,122,2,58,32,250,
+ 2,123,125,233,16,0,0,0,122,40,114,101,97,99,104,101,
+ 100,32,69,79,70,32,119,104,105,108,101,32,114,101,97,100,
+ 105,110,103,32,112,121,99,32,104,101,97,100,101,114,32,111,
+ 102,32,233,8,0,0,0,233,252,255,255,255,122,14,105,110,
+ 118,97,108,105,100,32,102,108,97,103,115,32,122,4,32,105,
+ 110,32,41,7,218,12,77,65,71,73,67,95,78,85,77,66,
+ 69,82,114,139,0,0,0,218,16,95,118,101,114,98,111,115,
+ 101,95,109,101,115,115,97,103,101,114,122,0,0,0,114,4,
+ 0,0,0,218,8,69,79,70,69,114,114,111,114,114,38,0,
+ 0,0,41,6,114,37,0,0,0,114,121,0,0,0,218,11,
+ 101,120,99,95,100,101,116,97,105,108,115,90,5,109,97,103,
+ 105,99,114,98,0,0,0,114,16,0,0,0,114,7,0,0,
+ 0,114,7,0,0,0,114,8,0,0,0,218,13,95,99,108,
+ 97,115,115,105,102,121,95,112,121,99,31,2,0,0,115,30,
+ 0,0,0,12,16,8,1,16,1,12,1,16,1,12,1,10,
+ 1,12,1,8,1,16,1,8,2,16,1,16,1,4,1,255,
+ 128,114,156,0,0,0,99,5,0,0,0,0,0,0,0,0,
+ 0,0,0,6,0,0,0,4,0,0,0,67,0,0,0,115,
+ 124,0,0,0,116,0,124,0,100,1,100,2,133,2,25,0,
+ 131,1,124,1,100,3,64,0,107,3,114,62,100,4,124,3,
+ 155,2,157,2,125,5,116,1,160,2,100,5,124,5,161,2,
+ 1,0,116,3,124,5,102,1,105,0,124,4,164,1,142,1,
+ 130,1,124,2,100,6,117,1,114,120,116,0,124,0,100,2,
+ 100,7,133,2,25,0,131,1,124,2,100,3,64,0,107,3,
+ 114,116,116,3,100,4,124,3,155,2,157,2,102,1,105,0,
+ 124,4,164,1,142,1,130,1,100,6,83,0,100,6,83,0,
+ 41,8,97,7,2,0,0,86,97,108,105,100,97,116,101,32,
+ 97,32,112,121,99,32,97,103,97,105,110,115,116,32,116,104,
+ 101,32,115,111,117,114,99,101,32,108,97,115,116,45,109,111,
+ 100,105,102,105,101,100,32,116,105,109,101,46,10,10,32,32,
+ 32,32,42,100,97,116,97,42,32,105,115,32,116,104,101,32,
+ 99,111,110,116,101,110,116,115,32,111,102,32,116,104,101,32,
+ 112,121,99,32,102,105,108,101,46,32,40,79,110,108,121,32,
+ 116,104,101,32,102,105,114,115,116,32,49,54,32,98,121,116,
+ 101,115,32,97,114,101,10,32,32,32,32,114,101,113,117,105,
+ 114,101,100,46,41,10,10,32,32,32,32,42,115,111,117,114,
+ 99,101,95,109,116,105,109,101,42,32,105,115,32,116,104,101,
+ 32,108,97,115,116,32,109,111,100,105,102,105,101,100,32,116,
+ 105,109,101,115,116,97,109,112,32,111,102,32,116,104,101,32,
+ 115,111,117,114,99,101,32,102,105,108,101,46,10,10,32,32,
+ 32,32,42,115,111,117,114,99,101,95,115,105,122,101,42,32,
+ 105,115,32,78,111,110,101,32,111,114,32,116,104,101,32,115,
+ 105,122,101,32,111,102,32,116,104,101,32,115,111,117,114,99,
+ 101,32,102,105,108,101,32,105,110,32,98,121,116,101,115,46,
+ 10,10,32,32,32,32,42,110,97,109,101,42,32,105,115,32,
+ 116,104,101,32,110,97,109,101,32,111,102,32,116,104,101,32,
+ 109,111,100,117,108,101,32,98,101,105,110,103,32,105,109,112,
+ 111,114,116,101,100,46,32,73,116,32,105,115,32,117,115,101,
+ 100,32,102,111,114,32,108,111,103,103,105,110,103,46,10,10,
+ 32,32,32,32,42,101,120,99,95,100,101,116,97,105,108,115,
+ 42,32,105,115,32,97,32,100,105,99,116,105,111,110,97,114,
+ 121,32,112,97,115,115,101,100,32,116,111,32,73,109,112,111,
+ 114,116,69,114,114,111,114,32,105,102,32,105,116,32,114,97,
+ 105,115,101,100,32,102,111,114,10,32,32,32,32,105,109,112,
+ 114,111,118,101,100,32,100,101,98,117,103,103,105,110,103,46,
+ 10,10,32,32,32,32,65,110,32,73,109,112,111,114,116,69,
+ 114,114,111,114,32,105,115,32,114,97,105,115,101,100,32,105,
+ 102,32,116,104,101,32,98,121,116,101,99,111,100,101,32,105,
+ 115,32,115,116,97,108,101,46,10,10,32,32,32,32,114,150,
+ 0,0,0,233,12,0,0,0,114,27,0,0,0,122,22,98,
121,116,101,99,111,100,101,32,105,115,32,115,116,97,108,101,
- 46,10,10,32,32,32,32,114,146,0,0,0,114,145,0,0,
- 0,122,46,104,97,115,104,32,105,110,32,98,121,116,101,99,
- 111,100,101,32,100,111,101,115,110,39,116,32,109,97,116,99,
- 104,32,104,97,115,104,32,111,102,32,115,111,117,114,99,101,
- 32,78,41,1,114,117,0,0,0,41,4,114,26,0,0,0,
- 218,11,115,111,117,114,99,101,95,104,97,115,104,114,116,0,
- 0,0,114,151,0,0,0,114,5,0,0,0,114,5,0,0,
- 0,114,8,0,0,0,218,18,95,118,97,108,105,100,97,116,
- 101,95,104,97,115,104,95,112,121,99,50,2,0,0,115,12,
- 0,0,0,0,17,16,1,2,1,8,255,4,2,2,254,114,
- 158,0,0,0,99,4,0,0,0,0,0,0,0,0,0,0,
- 0,5,0,0,0,5,0,0,0,67,0,0,0,115,80,0,
+ 32,102,111,114,32,114,148,0,0,0,78,114,149,0,0,0,
+ 41,4,114,38,0,0,0,114,139,0,0,0,114,153,0,0,
+ 0,114,122,0,0,0,41,6,114,37,0,0,0,218,12,115,
+ 111,117,114,99,101,95,109,116,105,109,101,218,11,115,111,117,
+ 114,99,101,95,115,105,122,101,114,121,0,0,0,114,155,0,
+ 0,0,114,98,0,0,0,114,7,0,0,0,114,7,0,0,
+ 0,114,8,0,0,0,218,23,95,118,97,108,105,100,97,116,
+ 101,95,116,105,109,101,115,116,97,109,112,95,112,121,99,64,
+ 2,0,0,115,20,0,0,0,24,19,10,1,12,1,16,1,
+ 8,1,22,1,2,255,22,2,8,254,255,128,114,160,0,0,
+ 0,99,4,0,0,0,0,0,0,0,0,0,0,0,4,0,
+ 0,0,4,0,0,0,67,0,0,0,115,42,0,0,0,124,
+ 0,100,1,100,2,133,2,25,0,124,1,107,3,114,38,116,
+ 0,100,3,124,2,155,2,157,2,102,1,105,0,124,3,164,
+ 1,142,1,130,1,100,4,83,0,41,5,97,243,1,0,0,
+ 86,97,108,105,100,97,116,101,32,97,32,104,97,115,104,45,
+ 98,97,115,101,100,32,112,121,99,32,98,121,32,99,104,101,
+ 99,107,105,110,103,32,116,104,101,32,114,101,97,108,32,115,
+ 111,117,114,99,101,32,104,97,115,104,32,97,103,97,105,110,
+ 115,116,32,116,104,101,32,111,110,101,32,105,110,10,32,32,
+ 32,32,116,104,101,32,112,121,99,32,104,101,97,100,101,114,
+ 46,10,10,32,32,32,32,42,100,97,116,97,42,32,105,115,
+ 32,116,104,101,32,99,111,110,116,101,110,116,115,32,111,102,
+ 32,116,104,101,32,112,121,99,32,102,105,108,101,46,32,40,
+ 79,110,108,121,32,116,104,101,32,102,105,114,115,116,32,49,
+ 54,32,98,121,116,101,115,32,97,114,101,10,32,32,32,32,
+ 114,101,113,117,105,114,101,100,46,41,10,10,32,32,32,32,
+ 42,115,111,117,114,99,101,95,104,97,115,104,42,32,105,115,
+ 32,116,104,101,32,105,109,112,111,114,116,108,105,98,46,117,
+ 116,105,108,46,115,111,117,114,99,101,95,104,97,115,104,40,
+ 41,32,111,102,32,116,104,101,32,115,111,117,114,99,101,32,
+ 102,105,108,101,46,10,10,32,32,32,32,42,110,97,109,101,
+ 42,32,105,115,32,116,104,101,32,110,97,109,101,32,111,102,
+ 32,116,104,101,32,109,111,100,117,108,101,32,98,101,105,110,
+ 103,32,105,109,112,111,114,116,101,100,46,32,73,116,32,105,
+ 115,32,117,115,101,100,32,102,111,114,32,108,111,103,103,105,
+ 110,103,46,10,10,32,32,32,32,42,101,120,99,95,100,101,
+ 116,97,105,108,115,42,32,105,115,32,97,32,100,105,99,116,
+ 105,111,110,97,114,121,32,112,97,115,115,101,100,32,116,111,
+ 32,73,109,112,111,114,116,69,114,114,111,114,32,105,102,32,
+ 105,116,32,114,97,105,115,101,100,32,102,111,114,10,32,32,
+ 32,32,105,109,112,114,111,118,101,100,32,100,101,98,117,103,
+ 103,105,110,103,46,10,10,32,32,32,32,65,110,32,73,109,
+ 112,111,114,116,69,114,114,111,114,32,105,115,32,114,97,105,
+ 115,101,100,32,105,102,32,116,104,101,32,98,121,116,101,99,
+ 111,100,101,32,105,115,32,115,116,97,108,101,46,10,10,32,
+ 32,32,32,114,150,0,0,0,114,149,0,0,0,122,46,104,
+ 97,115,104,32,105,110,32,98,121,116,101,99,111,100,101,32,
+ 100,111,101,115,110,39,116,32,109,97,116,99,104,32,104,97,
+ 115,104,32,111,102,32,115,111,117,114,99,101,32,78,41,1,
+ 114,122,0,0,0,41,4,114,37,0,0,0,218,11,115,111,
+ 117,114,99,101,95,104,97,115,104,114,121,0,0,0,114,155,
+ 0,0,0,114,7,0,0,0,114,7,0,0,0,114,8,0,
+ 0,0,218,18,95,118,97,108,105,100,97,116,101,95,104,97,
+ 115,104,95,112,121,99,92,2,0,0,115,16,0,0,0,16,
+ 17,2,1,8,1,4,255,2,2,6,254,4,255,255,128,114,
+ 162,0,0,0,99,4,0,0,0,0,0,0,0,0,0,0,
+ 0,5,0,0,0,5,0,0,0,67,0,0,0,115,76,0,
0,0,116,0,160,1,124,0,161,1,125,4,116,2,124,4,
116,3,131,2,114,56,116,4,160,5,100,1,124,2,161,2,
1,0,124,3,100,2,117,1,114,52,116,6,160,7,124,4,
124,3,161,2,1,0,124,4,83,0,116,8,100,3,160,9,
- 124,2,161,1,124,1,124,2,100,4,141,3,130,1,100,2,
- 83,0,41,5,122,35,67,111,109,112,105,108,101,32,98,121,
- 116,101,99,111,100,101,32,97,115,32,102,111,117,110,100,32,
- 105,110,32,97,32,112,121,99,46,122,21,99,111,100,101,32,
- 111,98,106,101,99,116,32,102,114,111,109,32,123,33,114,125,
- 78,122,23,78,111,110,45,99,111,100,101,32,111,98,106,101,
- 99,116,32,105,110,32,123,33,114,125,169,2,114,116,0,0,
- 0,114,44,0,0,0,41,10,218,7,109,97,114,115,104,97,
- 108,90,5,108,111,97,100,115,218,10,105,115,105,110,115,116,
- 97,110,99,101,218,10,95,99,111,100,101,95,116,121,112,101,
- 114,134,0,0,0,114,149,0,0,0,218,4,95,105,109,112,
- 90,16,95,102,105,120,95,99,111,95,102,105,108,101,110,97,
- 109,101,114,117,0,0,0,114,62,0,0,0,41,5,114,26,
- 0,0,0,114,116,0,0,0,114,106,0,0,0,114,107,0,
- 0,0,218,4,99,111,100,101,114,5,0,0,0,114,5,0,
- 0,0,114,8,0,0,0,218,17,95,99,111,109,112,105,108,
- 101,95,98,121,116,101,99,111,100,101,74,2,0,0,115,18,
- 0,0,0,0,2,10,1,10,1,12,1,8,1,12,1,4,
- 2,10,1,4,255,114,165,0,0,0,114,73,0,0,0,99,
- 3,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,
- 5,0,0,0,67,0,0,0,115,70,0,0,0,116,0,116,
- 1,131,1,125,3,124,3,160,2,116,3,100,1,131,1,161,
- 1,1,0,124,3,160,2,116,3,124,1,131,1,161,1,1,
- 0,124,3,160,2,116,3,124,2,131,1,161,1,1,0,124,
- 3,160,2,116,4,160,5,124,0,161,1,161,1,1,0,124,
- 3,83,0,41,2,122,43,80,114,111,100,117,99,101,32,116,
- 104,101,32,100,97,116,97,32,102,111,114,32,97,32,116,105,
- 109,101,115,116,97,109,112,45,98,97,115,101,100,32,112,121,
- 99,46,114,73,0,0,0,41,6,218,9,98,121,116,101,97,
- 114,114,97,121,114,148,0,0,0,218,6,101,120,116,101,110,
- 100,114,21,0,0,0,114,160,0,0,0,218,5,100,117,109,
- 112,115,41,4,114,164,0,0,0,218,5,109,116,105,109,101,
- 114,155,0,0,0,114,26,0,0,0,114,5,0,0,0,114,
- 5,0,0,0,114,8,0,0,0,218,22,95,99,111,100,101,
- 95,116,111,95,116,105,109,101,115,116,97,109,112,95,112,121,
- 99,87,2,0,0,115,12,0,0,0,0,2,8,1,14,1,
- 14,1,14,1,16,1,114,170,0,0,0,84,99,3,0,0,
- 0,0,0,0,0,0,0,0,0,5,0,0,0,5,0,0,
- 0,67,0,0,0,115,80,0,0,0,116,0,116,1,131,1,
- 125,3,100,1,124,2,100,1,62,0,66,0,125,4,124,3,
- 160,2,116,3,124,4,131,1,161,1,1,0,116,4,124,1,
- 131,1,100,2,107,2,115,50,74,0,130,1,124,3,160,2,
- 124,1,161,1,1,0,124,3,160,2,116,5,160,6,124,0,
- 161,1,161,1,1,0,124,3,83,0,41,3,122,38,80,114,
- 111,100,117,99,101,32,116,104,101,32,100,97,116,97,32,102,
- 111,114,32,97,32,104,97,115,104,45,98,97,115,101,100,32,
- 112,121,99,46,114,39,0,0,0,114,146,0,0,0,41,7,
- 114,166,0,0,0,114,148,0,0,0,114,167,0,0,0,114,
- 21,0,0,0,114,23,0,0,0,114,160,0,0,0,114,168,
- 0,0,0,41,5,114,164,0,0,0,114,157,0,0,0,90,
- 7,99,104,101,99,107,101,100,114,26,0,0,0,114,2,0,
- 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,
- 0,218,17,95,99,111,100,101,95,116,111,95,104,97,115,104,
- 95,112,121,99,97,2,0,0,115,14,0,0,0,0,2,8,
- 1,12,1,14,1,16,1,10,1,16,1,114,171,0,0,0,
- 99,1,0,0,0,0,0,0,0,0,0,0,0,5,0,0,
- 0,6,0,0,0,67,0,0,0,115,62,0,0,0,100,1,
- 100,2,108,0,125,1,116,1,160,2,124,0,161,1,106,3,
- 125,2,124,1,160,4,124,2,161,1,125,3,116,1,160,5,
- 100,2,100,3,161,2,125,4,124,4,160,6,124,0,160,6,
- 124,3,100,1,25,0,161,1,161,1,83,0,41,4,122,121,
- 68,101,99,111,100,101,32,98,121,116,101,115,32,114,101,112,
- 114,101,115,101,110,116,105,110,103,32,115,111,117,114,99,101,
- 32,99,111,100,101,32,97,110,100,32,114,101,116,117,114,110,
- 32,116,104,101,32,115,116,114,105,110,103,46,10,10,32,32,
- 32,32,85,110,105,118,101,114,115,97,108,32,110,101,119,108,
- 105,110,101,32,115,117,112,112,111,114,116,32,105,115,32,117,
- 115,101,100,32,105,110,32,116,104,101,32,100,101,99,111,100,
- 105,110,103,46,10,32,32,32,32,114,73,0,0,0,78,84,
- 41,7,218,8,116,111,107,101,110,105,122,101,114,64,0,0,
- 0,90,7,66,121,116,101,115,73,79,90,8,114,101,97,100,
- 108,105,110,101,90,15,100,101,116,101,99,116,95,101,110,99,
- 111,100,105,110,103,90,25,73,110,99,114,101,109,101,110,116,
- 97,108,78,101,119,108,105,110,101,68,101,99,111,100,101,114,
- 218,6,100,101,99,111,100,101,41,5,218,12,115,111,117,114,
- 99,101,95,98,121,116,101,115,114,172,0,0,0,90,21,115,
- 111,117,114,99,101,95,98,121,116,101,115,95,114,101,97,100,
- 108,105,110,101,218,8,101,110,99,111,100,105,110,103,90,15,
- 110,101,119,108,105,110,101,95,100,101,99,111,100,101,114,114,
- 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,13,
- 100,101,99,111,100,101,95,115,111,117,114,99,101,108,2,0,
- 0,115,10,0,0,0,0,5,8,1,12,1,10,1,12,1,
- 114,176,0,0,0,169,2,114,140,0,0,0,218,26,115,117,
- 98,109,111,100,117,108,101,95,115,101,97,114,99,104,95,108,
- 111,99,97,116,105,111,110,115,99,2,0,0,0,0,0,0,
- 0,2,0,0,0,9,0,0,0,8,0,0,0,67,0,0,
- 0,115,10,1,0,0,124,1,100,1,117,0,114,56,100,2,
- 125,1,116,0,124,2,100,3,131,2,114,66,122,14,124,2,
- 160,1,124,0,161,1,125,1,87,0,110,28,4,0,116,2,
- 121,54,1,0,1,0,1,0,89,0,110,12,48,0,116,3,
- 160,4,124,1,161,1,125,1,116,5,106,6,124,0,124,2,
- 124,1,100,4,141,3,125,4,100,5,124,4,95,7,124,2,
- 100,1,117,0,114,150,116,8,131,0,68,0,93,42,92,2,
- 125,5,125,6,124,1,160,9,116,10,124,6,131,1,161,1,
- 114,102,124,5,124,0,124,1,131,2,125,2,124,2,124,4,
- 95,11,1,0,113,150,113,102,100,1,83,0,124,3,116,12,
- 117,0,114,214,116,0,124,2,100,6,131,2,114,220,122,14,
- 124,2,160,13,124,0,161,1,125,7,87,0,110,18,4,0,
- 116,2,121,200,1,0,1,0,1,0,89,0,110,20,48,0,
- 124,7,114,220,103,0,124,4,95,14,110,6,124,3,124,4,
- 95,14,124,4,106,14,103,0,107,2,144,1,114,6,124,1,
- 144,1,114,6,116,15,124,1,131,1,100,7,25,0,125,8,
- 124,4,106,14,160,16,124,8,161,1,1,0,124,4,83,0,
- 41,8,97,61,1,0,0,82,101,116,117,114,110,32,97,32,
- 109,111,100,117,108,101,32,115,112,101,99,32,98,97,115,101,
- 100,32,111,110,32,97,32,102,105,108,101,32,108,111,99,97,
- 116,105,111,110,46,10,10,32,32,32,32,84,111,32,105,110,
- 100,105,99,97,116,101,32,116,104,97,116,32,116,104,101,32,
- 109,111,100,117,108,101,32,105,115,32,97,32,112,97,99,107,
- 97,103,101,44,32,115,101,116,10,32,32,32,32,115,117,98,
- 109,111,100,117,108,101,95,115,101,97,114,99,104,95,108,111,
- 99,97,116,105,111,110,115,32,116,111,32,97,32,108,105,115,
- 116,32,111,102,32,100,105,114,101,99,116,111,114,121,32,112,
- 97,116,104,115,46,32,32,65,110,10,32,32,32,32,101,109,
- 112,116,121,32,108,105,115,116,32,105,115,32,115,117,102,102,
- 105,99,105,101,110,116,44,32,116,104,111,117,103,104,32,105,
- 116,115,32,110,111,116,32,111,116,104,101,114,119,105,115,101,
- 32,117,115,101,102,117,108,32,116,111,32,116,104,101,10,32,
- 32,32,32,105,109,112,111,114,116,32,115,121,115,116,101,109,
- 46,10,10,32,32,32,32,84,104,101,32,108,111,97,100,101,
- 114,32,109,117,115,116,32,116,97,107,101,32,97,32,115,112,
- 101,99,32,97,115,32,105,116,115,32,111,110,108,121,32,95,
- 95,105,110,105,116,95,95,40,41,32,97,114,103,46,10,10,
- 32,32,32,32,78,122,9,60,117,110,107,110,111,119,110,62,
- 218,12,103,101,116,95,102,105,108,101,110,97,109,101,169,1,
- 218,6,111,114,105,103,105,110,84,218,10,105,115,95,112,97,
- 99,107,97,103,101,114,73,0,0,0,41,17,114,128,0,0,
- 0,114,179,0,0,0,114,117,0,0,0,114,4,0,0,0,
- 114,79,0,0,0,114,134,0,0,0,218,10,77,111,100,117,
- 108,101,83,112,101,99,90,13,95,115,101,116,95,102,105,108,
- 101,97,116,116,114,218,27,95,103,101,116,95,115,117,112,112,
- 111,114,116,101,100,95,102,105,108,101,95,108,111,97,100,101,
- 114,115,114,110,0,0,0,114,111,0,0,0,114,140,0,0,
- 0,218,9,95,80,79,80,85,76,65,84,69,114,182,0,0,
- 0,114,178,0,0,0,114,47,0,0,0,218,6,97,112,112,
- 101,110,100,41,9,114,116,0,0,0,90,8,108,111,99,97,
- 116,105,111,110,114,140,0,0,0,114,178,0,0,0,218,4,
- 115,112,101,99,218,12,108,111,97,100,101,114,95,99,108,97,
- 115,115,218,8,115,117,102,102,105,120,101,115,114,182,0,0,
- 0,90,7,100,105,114,110,97,109,101,114,5,0,0,0,114,
- 5,0,0,0,114,8,0,0,0,218,23,115,112,101,99,95,
- 102,114,111,109,95,102,105,108,101,95,108,111,99,97,116,105,
- 111,110,125,2,0,0,115,62,0,0,0,0,12,8,4,4,
- 1,10,2,2,1,14,1,12,1,6,2,10,8,16,1,6,
- 3,8,1,14,1,14,1,10,1,6,1,6,2,4,3,8,
- 2,10,1,2,1,14,1,12,1,6,2,4,1,8,2,6,
- 1,12,1,6,1,12,1,12,2,114,190,0,0,0,99,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
- 0,0,0,64,0,0,0,115,80,0,0,0,101,0,90,1,
- 100,0,90,2,100,1,90,3,100,2,90,4,100,3,90,5,
- 100,4,90,6,101,7,100,5,100,6,132,0,131,1,90,8,
- 101,7,100,7,100,8,132,0,131,1,90,9,101,7,100,14,
- 100,10,100,11,132,1,131,1,90,10,101,7,100,15,100,12,
- 100,13,132,1,131,1,90,11,100,9,83,0,41,16,218,21,
+ 124,2,161,1,124,1,124,2,100,4,141,3,130,1,41,5,
+ 122,35,67,111,109,112,105,108,101,32,98,121,116,101,99,111,
+ 100,101,32,97,115,32,102,111,117,110,100,32,105,110,32,97,
+ 32,112,121,99,46,122,21,99,111,100,101,32,111,98,106,101,
+ 99,116,32,102,114,111,109,32,123,33,114,125,78,122,23,78,
+ 111,110,45,99,111,100,101,32,111,98,106,101,99,116,32,105,
+ 110,32,123,33,114,125,169,2,114,121,0,0,0,114,52,0,
+ 0,0,41,10,218,7,109,97,114,115,104,97,108,90,5,108,
+ 111,97,100,115,218,10,105,115,105,110,115,116,97,110,99,101,
+ 218,10,95,99,111,100,101,95,116,121,112,101,114,139,0,0,
+ 0,114,153,0,0,0,218,4,95,105,109,112,90,16,95,102,
+ 105,120,95,99,111,95,102,105,108,101,110,97,109,101,114,122,
+ 0,0,0,114,70,0,0,0,41,5,114,37,0,0,0,114,
+ 121,0,0,0,114,111,0,0,0,114,112,0,0,0,218,4,
+ 99,111,100,101,114,7,0,0,0,114,7,0,0,0,114,8,
+ 0,0,0,218,17,95,99,111,109,112,105,108,101,95,98,121,
+ 116,101,99,111,100,101,116,2,0,0,115,20,0,0,0,10,
+ 2,10,1,12,1,8,1,12,1,4,1,10,2,4,1,6,
+ 255,255,128,114,169,0,0,0,99,3,0,0,0,0,0,0,
+ 0,0,0,0,0,4,0,0,0,5,0,0,0,67,0,0,
+ 0,115,70,0,0,0,116,0,116,1,131,1,125,3,124,3,
+ 160,2,116,3,100,1,131,1,161,1,1,0,124,3,160,2,
+ 116,3,124,1,131,1,161,1,1,0,124,3,160,2,116,3,
+ 124,2,131,1,161,1,1,0,124,3,160,2,116,4,160,5,
+ 124,0,161,1,161,1,1,0,124,3,83,0,41,3,122,43,
+ 80,114,111,100,117,99,101,32,116,104,101,32,100,97,116,97,
+ 32,102,111,114,32,97,32,116,105,109,101,115,116,97,109,112,
+ 45,98,97,115,101,100,32,112,121,99,46,114,0,0,0,0,
+ 78,41,6,218,9,98,121,116,101,97,114,114,97,121,114,152,
+ 0,0,0,218,6,101,120,116,101,110,100,114,33,0,0,0,
+ 114,164,0,0,0,218,5,100,117,109,112,115,41,4,114,168,
+ 0,0,0,218,5,109,116,105,109,101,114,159,0,0,0,114,
+ 37,0,0,0,114,7,0,0,0,114,7,0,0,0,114,8,
+ 0,0,0,218,22,95,99,111,100,101,95,116,111,95,116,105,
+ 109,101,115,116,97,109,112,95,112,121,99,129,2,0,0,115,
+ 14,0,0,0,8,2,14,1,14,1,14,1,16,1,4,1,
+ 255,128,114,174,0,0,0,84,99,3,0,0,0,0,0,0,
+ 0,0,0,0,0,5,0,0,0,5,0,0,0,67,0,0,
+ 0,115,80,0,0,0,116,0,116,1,131,1,125,3,100,1,
+ 124,2,100,1,62,0,66,0,125,4,124,3,160,2,116,3,
+ 124,4,131,1,161,1,1,0,116,4,124,1,131,1,100,2,
+ 107,2,115,50,74,0,130,1,124,3,160,2,124,1,161,1,
+ 1,0,124,3,160,2,116,5,160,6,124,0,161,1,161,1,
+ 1,0,124,3,83,0,41,4,122,38,80,114,111,100,117,99,
+ 101,32,116,104,101,32,100,97,116,97,32,102,111,114,32,97,
+ 32,104,97,115,104,45,98,97,115,101,100,32,112,121,99,46,
+ 114,3,0,0,0,114,150,0,0,0,78,41,7,114,170,0,
+ 0,0,114,152,0,0,0,114,171,0,0,0,114,33,0,0,
+ 0,114,4,0,0,0,114,164,0,0,0,114,172,0,0,0,
+ 41,5,114,168,0,0,0,114,161,0,0,0,90,7,99,104,
+ 101,99,107,101,100,114,37,0,0,0,114,16,0,0,0,114,
+ 7,0,0,0,114,7,0,0,0,114,8,0,0,0,218,17,
+ 95,99,111,100,101,95,116,111,95,104,97,115,104,95,112,121,
+ 99,139,2,0,0,115,16,0,0,0,8,2,12,1,14,1,
+ 16,1,10,1,16,1,4,1,255,128,114,175,0,0,0,99,
+ 1,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,
+ 6,0,0,0,67,0,0,0,115,62,0,0,0,100,1,100,
+ 2,108,0,125,1,116,1,160,2,124,0,161,1,106,3,125,
+ 2,124,1,160,4,124,2,161,1,125,3,116,1,160,5,100,
+ 2,100,3,161,2,125,4,124,4,160,6,124,0,160,6,124,
+ 3,100,1,25,0,161,1,161,1,83,0,41,4,122,121,68,
+ 101,99,111,100,101,32,98,121,116,101,115,32,114,101,112,114,
+ 101,115,101,110,116,105,110,103,32,115,111,117,114,99,101,32,
+ 99,111,100,101,32,97,110,100,32,114,101,116,117,114,110,32,
+ 116,104,101,32,115,116,114,105,110,103,46,10,10,32,32,32,
+ 32,85,110,105,118,101,114,115,97,108,32,110,101,119,108,105,
+ 110,101,32,115,117,112,112,111,114,116,32,105,115,32,117,115,
+ 101,100,32,105,110,32,116,104,101,32,100,101,99,111,100,105,
+ 110,103,46,10,32,32,32,32,114,0,0,0,0,78,84,41,
+ 7,218,8,116,111,107,101,110,105,122,101,114,72,0,0,0,
+ 90,7,66,121,116,101,115,73,79,90,8,114,101,97,100,108,
+ 105,110,101,90,15,100,101,116,101,99,116,95,101,110,99,111,
+ 100,105,110,103,90,25,73,110,99,114,101,109,101,110,116,97,
+ 108,78,101,119,108,105,110,101,68,101,99,111,100,101,114,218,
+ 6,100,101,99,111,100,101,41,5,218,12,115,111,117,114,99,
+ 101,95,98,121,116,101,115,114,176,0,0,0,90,21,115,111,
+ 117,114,99,101,95,98,121,116,101,115,95,114,101,97,100,108,
+ 105,110,101,218,8,101,110,99,111,100,105,110,103,90,15,110,
+ 101,119,108,105,110,101,95,100,101,99,111,100,101,114,114,7,
+ 0,0,0,114,7,0,0,0,114,8,0,0,0,218,13,100,
+ 101,99,111,100,101,95,115,111,117,114,99,101,150,2,0,0,
+ 115,12,0,0,0,8,5,12,1,10,1,12,1,20,1,255,
+ 128,114,180,0,0,0,169,2,114,144,0,0,0,218,26,115,
+ 117,98,109,111,100,117,108,101,95,115,101,97,114,99,104,95,
+ 108,111,99,97,116,105,111,110,115,99,2,0,0,0,0,0,
+ 0,0,2,0,0,0,9,0,0,0,8,0,0,0,67,0,
+ 0,0,115,16,1,0,0,124,1,100,1,117,0,114,58,100,
+ 2,125,1,116,0,124,2,100,3,131,2,114,56,122,14,124,
+ 2,160,1,124,0,161,1,125,1,87,0,110,30,4,0,116,
+ 2,144,1,121,14,1,0,1,0,1,0,89,0,110,12,110,
+ 10,116,3,160,4,124,1,161,1,125,1,116,5,106,6,124,
+ 0,124,2,124,1,100,4,141,3,125,4,100,5,124,4,95,
+ 7,124,2,100,1,117,0,114,152,116,8,131,0,68,0,93,
+ 42,92,2,125,5,125,6,124,1,160,9,116,10,124,6,131,
+ 1,161,1,114,146,124,5,124,0,124,1,131,2,125,2,124,
+ 2,124,4,95,11,1,0,113,152,113,104,100,1,83,0,124,
+ 3,116,12,117,0,114,216,116,0,124,2,100,6,131,2,114,
+ 214,122,14,124,2,160,13,124,0,161,1,125,7,87,0,110,
+ 18,4,0,116,2,144,1,121,12,1,0,1,0,1,0,89,
+ 0,110,18,124,7,114,214,103,0,124,4,95,14,110,6,124,
+ 3,124,4,95,14,124,4,106,14,103,0,107,2,144,1,114,
+ 8,124,1,144,1,114,8,116,15,124,1,131,1,100,7,25,
+ 0,125,8,124,4,106,14,160,16,124,8,161,1,1,0,124,
+ 4,83,0,119,0,119,0,41,8,97,61,1,0,0,82,101,
+ 116,117,114,110,32,97,32,109,111,100,117,108,101,32,115,112,
+ 101,99,32,98,97,115,101,100,32,111,110,32,97,32,102,105,
+ 108,101,32,108,111,99,97,116,105,111,110,46,10,10,32,32,
+ 32,32,84,111,32,105,110,100,105,99,97,116,101,32,116,104,
+ 97,116,32,116,104,101,32,109,111,100,117,108,101,32,105,115,
+ 32,97,32,112,97,99,107,97,103,101,44,32,115,101,116,10,
+ 32,32,32,32,115,117,98,109,111,100,117,108,101,95,115,101,
+ 97,114,99,104,95,108,111,99,97,116,105,111,110,115,32,116,
+ 111,32,97,32,108,105,115,116,32,111,102,32,100,105,114,101,
+ 99,116,111,114,121,32,112,97,116,104,115,46,32,32,65,110,
+ 10,32,32,32,32,101,109,112,116,121,32,108,105,115,116,32,
+ 105,115,32,115,117,102,102,105,99,105,101,110,116,44,32,116,
+ 104,111,117,103,104,32,105,116,115,32,110,111,116,32,111,116,
+ 104,101,114,119,105,115,101,32,117,115,101,102,117,108,32,116,
+ 111,32,116,104,101,10,32,32,32,32,105,109,112,111,114,116,
+ 32,115,121,115,116,101,109,46,10,10,32,32,32,32,84,104,
+ 101,32,108,111,97,100,101,114,32,109,117,115,116,32,116,97,
+ 107,101,32,97,32,115,112,101,99,32,97,115,32,105,116,115,
+ 32,111,110,108,121,32,95,95,105,110,105,116,95,95,40,41,
+ 32,97,114,103,46,10,10,32,32,32,32,78,122,9,60,117,
+ 110,107,110,111,119,110,62,218,12,103,101,116,95,102,105,108,
+ 101,110,97,109,101,169,1,218,6,111,114,105,103,105,110,84,
+ 218,10,105,115,95,112,97,99,107,97,103,101,114,0,0,0,
+ 0,41,17,114,133,0,0,0,114,183,0,0,0,114,122,0,
+ 0,0,114,18,0,0,0,114,85,0,0,0,114,139,0,0,
+ 0,218,10,77,111,100,117,108,101,83,112,101,99,90,13,95,
+ 115,101,116,95,102,105,108,101,97,116,116,114,218,27,95,103,
+ 101,116,95,115,117,112,112,111,114,116,101,100,95,102,105,108,
+ 101,95,108,111,97,100,101,114,115,114,115,0,0,0,114,116,
+ 0,0,0,114,144,0,0,0,218,9,95,80,79,80,85,76,
+ 65,84,69,114,186,0,0,0,114,182,0,0,0,114,55,0,
+ 0,0,218,6,97,112,112,101,110,100,41,9,114,121,0,0,
+ 0,90,8,108,111,99,97,116,105,111,110,114,144,0,0,0,
+ 114,182,0,0,0,218,4,115,112,101,99,218,12,108,111,97,
+ 100,101,114,95,99,108,97,115,115,218,8,115,117,102,102,105,
+ 120,101,115,114,186,0,0,0,90,7,100,105,114,110,97,109,
+ 101,114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,
+ 218,23,115,112,101,99,95,102,114,111,109,95,102,105,108,101,
+ 95,108,111,99,97,116,105,111,110,167,2,0,0,115,74,0,
+ 0,0,8,12,4,4,10,1,2,2,14,1,14,1,4,1,
+ 2,128,10,2,16,8,6,1,8,3,14,1,14,1,10,1,
+ 6,1,4,1,2,128,4,2,8,3,10,2,2,1,14,1,
+ 14,1,2,1,2,3,4,255,8,1,6,2,12,1,6,1,
+ 12,1,12,1,4,2,2,244,2,226,255,128,114,194,0,0,
+ 0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,4,0,0,0,64,0,0,0,115,88,0,0,0,101,
+ 0,90,1,100,0,90,2,100,1,90,3,100,2,90,4,100,
+ 3,90,5,101,6,111,30,100,4,101,7,118,0,90,8,101,
+ 9,100,5,100,6,132,0,131,1,90,10,101,11,100,7,100,
+ 8,132,0,131,1,90,12,101,11,100,14,100,10,100,11,132,
+ 1,131,1,90,13,101,11,100,15,100,12,100,13,132,1,131,
+ 1,90,14,100,9,83,0,41,16,218,21,87,105,110,100,111,
+ 119,115,82,101,103,105,115,116,114,121,70,105,110,100,101,114,
+ 122,62,77,101,116,97,32,112,97,116,104,32,102,105,110,100,
+ 101,114,32,102,111,114,32,109,111,100,117,108,101,115,32,100,
+ 101,99,108,97,114,101,100,32,105,110,32,116,104,101,32,87,
+ 105,110,100,111,119,115,32,114,101,103,105,115,116,114,121,46,
+ 122,59,83,111,102,116,119,97,114,101,92,80,121,116,104,111,
+ 110,92,80,121,116,104,111,110,67,111,114,101,92,123,115,121,
+ 115,95,118,101,114,115,105,111,110,125,92,77,111,100,117,108,
+ 101,115,92,123,102,117,108,108,110,97,109,101,125,122,65,83,
+ 111,102,116,119,97,114,101,92,80,121,116,104,111,110,92,80,
+ 121,116,104,111,110,67,111,114,101,92,123,115,121,115,95,118,
+ 101,114,115,105,111,110,125,92,77,111,100,117,108,101,115,92,
+ 123,102,117,108,108,110,97,109,101,125,92,68,101,98,117,103,
+ 122,6,95,100,46,112,121,100,99,1,0,0,0,0,0,0,
+ 0,0,0,0,0,1,0,0,0,8,0,0,0,67,0,0,
+ 0,115,50,0,0,0,122,16,116,0,160,1,116,0,106,2,
+ 124,0,161,2,87,0,83,0,4,0,116,3,121,48,1,0,
+ 1,0,1,0,116,0,160,1,116,0,106,4,124,0,161,2,
+ 6,0,89,0,83,0,119,0,114,114,0,0,0,41,5,218,
+ 6,119,105,110,114,101,103,90,7,79,112,101,110,75,101,121,
+ 90,17,72,75,69,89,95,67,85,82,82,69,78,84,95,85,
+ 83,69,82,114,58,0,0,0,90,18,72,75,69,89,95,76,
+ 79,67,65,76,95,77,65,67,72,73,78,69,114,19,0,0,
+ 0,114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,
+ 218,14,95,111,112,101,110,95,114,101,103,105,115,116,114,121,
+ 247,2,0,0,115,12,0,0,0,2,2,16,1,12,1,18,
+ 1,2,255,255,128,122,36,87,105,110,100,111,119,115,82,101,
+ 103,105,115,116,114,121,70,105,110,100,101,114,46,95,111,112,
+ 101,110,95,114,101,103,105,115,116,114,121,99,2,0,0,0,
+ 0,0,0,0,0,0,0,0,6,0,0,0,8,0,0,0,
+ 67,0,0,0,115,130,0,0,0,124,0,106,0,114,14,124,
+ 0,106,1,125,2,110,6,124,0,106,2,125,2,124,2,106,
+ 3,124,1,100,1,116,4,106,5,100,0,100,2,133,2,25,
+ 0,22,0,100,3,141,2,125,3,122,60,124,0,160,6,124,
+ 3,161,1,143,28,125,4,116,7,160,8,124,4,100,4,161,
+ 2,125,5,87,0,100,0,4,0,4,0,131,3,1,0,110,
+ 16,49,0,115,94,119,1,1,0,1,0,1,0,89,0,1,
+ 0,87,0,124,5,83,0,4,0,116,9,121,128,1,0,1,
+ 0,1,0,89,0,100,0,83,0,119,0,41,5,78,122,5,
+ 37,100,46,37,100,114,39,0,0,0,41,2,114,143,0,0,
+ 0,90,11,115,121,115,95,118,101,114,115,105,111,110,114,10,
+ 0,0,0,41,10,218,11,68,69,66,85,71,95,66,85,73,
+ 76,68,218,18,82,69,71,73,83,84,82,89,95,75,69,89,
+ 95,68,69,66,85,71,218,12,82,69,71,73,83,84,82,89,
+ 95,75,69,89,114,70,0,0,0,114,15,0,0,0,218,12,
+ 118,101,114,115,105,111,110,95,105,110,102,111,114,197,0,0,
+ 0,114,196,0,0,0,90,10,81,117,101,114,121,86,97,108,
+ 117,101,114,58,0,0,0,41,6,218,3,99,108,115,114,143,
+ 0,0,0,90,12,114,101,103,105,115,116,114,121,95,107,101,
+ 121,114,20,0,0,0,90,4,104,107,101,121,218,8,102,105,
+ 108,101,112,97,116,104,114,7,0,0,0,114,7,0,0,0,
+ 114,8,0,0,0,218,16,95,115,101,97,114,99,104,95,114,
+ 101,103,105,115,116,114,121,254,2,0,0,115,28,0,0,0,
+ 6,2,8,1,6,2,6,1,16,1,6,255,2,2,12,1,
+ 44,1,4,3,12,254,6,1,2,255,255,128,122,38,87,105,
+ 110,100,111,119,115,82,101,103,105,115,116,114,121,70,105,110,
+ 100,101,114,46,95,115,101,97,114,99,104,95,114,101,103,105,
+ 115,116,114,121,78,99,4,0,0,0,0,0,0,0,0,0,
+ 0,0,8,0,0,0,8,0,0,0,67,0,0,0,115,120,
+ 0,0,0,124,0,160,0,124,1,161,1,125,4,124,4,100,
+ 0,117,0,114,22,100,0,83,0,122,12,116,1,124,4,131,
+ 1,1,0,87,0,110,18,4,0,116,2,121,118,1,0,1,
+ 0,1,0,89,0,100,0,83,0,116,3,131,0,68,0,93,
+ 52,92,2,125,5,125,6,124,4,160,4,116,5,124,6,131,
+ 1,161,1,114,112,116,6,106,7,124,1,124,5,124,1,124,
+ 4,131,2,124,4,100,1,141,3,125,7,124,7,2,0,1,
+ 0,83,0,113,60,100,0,83,0,119,0,41,2,78,114,184,
+ 0,0,0,41,8,114,204,0,0,0,114,57,0,0,0,114,
+ 58,0,0,0,114,188,0,0,0,114,115,0,0,0,114,116,
+ 0,0,0,114,139,0,0,0,218,16,115,112,101,99,95,102,
+ 114,111,109,95,108,111,97,100,101,114,41,8,114,202,0,0,
+ 0,114,143,0,0,0,114,52,0,0,0,218,6,116,97,114,
+ 103,101,116,114,203,0,0,0,114,144,0,0,0,114,193,0,
+ 0,0,114,191,0,0,0,114,7,0,0,0,114,7,0,0,
+ 0,114,8,0,0,0,218,9,102,105,110,100,95,115,112,101,
+ 99,13,3,0,0,115,36,0,0,0,10,2,8,1,4,1,
+ 2,1,12,1,12,1,6,1,14,1,14,1,6,1,8,1,
+ 2,1,6,254,8,3,2,128,4,251,2,254,255,128,122,31,
87,105,110,100,111,119,115,82,101,103,105,115,116,114,121,70,
- 105,110,100,101,114,122,62,77,101,116,97,32,112,97,116,104,
- 32,102,105,110,100,101,114,32,102,111,114,32,109,111,100,117,
- 108,101,115,32,100,101,99,108,97,114,101,100,32,105,110,32,
- 116,104,101,32,87,105,110,100,111,119,115,32,114,101,103,105,
- 115,116,114,121,46,122,59,83,111,102,116,119,97,114,101,92,
- 80,121,116,104,111,110,92,80,121,116,104,111,110,67,111,114,
- 101,92,123,115,121,115,95,118,101,114,115,105,111,110,125,92,
- 77,111,100,117,108,101,115,92,123,102,117,108,108,110,97,109,
- 101,125,122,65,83,111,102,116,119,97,114,101,92,80,121,116,
- 104,111,110,92,80,121,116,104,111,110,67,111,114,101,92,123,
- 115,121,115,95,118,101,114,115,105,111,110,125,92,77,111,100,
- 117,108,101,115,92,123,102,117,108,108,110,97,109,101,125,92,
- 68,101,98,117,103,70,99,2,0,0,0,0,0,0,0,0,
- 0,0,0,2,0,0,0,8,0,0,0,67,0,0,0,115,
- 50,0,0,0,122,16,116,0,160,1,116,0,106,2,124,1,
- 161,2,87,0,83,0,4,0,116,3,121,48,1,0,1,0,
- 1,0,116,0,160,1,116,0,106,4,124,1,161,2,6,0,
- 89,0,83,0,48,0,114,109,0,0,0,41,5,218,6,119,
- 105,110,114,101,103,90,7,79,112,101,110,75,101,121,90,17,
- 72,75,69,89,95,67,85,82,82,69,78,84,95,85,83,69,
- 82,114,50,0,0,0,90,18,72,75,69,89,95,76,79,67,
- 65,76,95,77,65,67,72,73,78,69,41,2,218,3,99,108,
- 115,114,7,0,0,0,114,5,0,0,0,114,5,0,0,0,
- 114,8,0,0,0,218,14,95,111,112,101,110,95,114,101,103,
- 105,115,116,114,121,205,2,0,0,115,8,0,0,0,0,2,
- 2,1,16,1,12,1,122,36,87,105,110,100,111,119,115,82,
- 101,103,105,115,116,114,121,70,105,110,100,101,114,46,95,111,
- 112,101,110,95,114,101,103,105,115,116,114,121,99,2,0,0,
- 0,0,0,0,0,0,0,0,0,6,0,0,0,8,0,0,
- 0,67,0,0,0,115,132,0,0,0,124,0,106,0,114,14,
- 124,0,106,1,125,2,110,6,124,0,106,2,125,2,124,2,
- 106,3,124,1,100,1,116,4,106,5,100,0,100,2,133,2,
- 25,0,22,0,100,3,141,2,125,3,122,58,124,0,160,6,
- 124,3,161,1,143,28,125,4,116,7,160,8,124,4,100,4,
- 161,2,125,5,87,0,100,0,4,0,4,0,131,3,1,0,
- 110,16,49,0,115,94,48,0,1,0,1,0,1,0,89,0,
- 1,0,87,0,110,20,4,0,116,9,121,126,1,0,1,0,
- 1,0,89,0,100,0,83,0,48,0,124,5,83,0,41,5,
- 78,122,5,37,100,46,37,100,114,28,0,0,0,41,2,114,
- 139,0,0,0,90,11,115,121,115,95,118,101,114,115,105,111,
- 110,114,40,0,0,0,41,10,218,11,68,69,66,85,71,95,
- 66,85,73,76,68,218,18,82,69,71,73,83,84,82,89,95,
- 75,69,89,95,68,69,66,85,71,218,12,82,69,71,73,83,
- 84,82,89,95,75,69,89,114,62,0,0,0,114,1,0,0,
- 0,218,12,118,101,114,115,105,111,110,95,105,110,102,111,114,
- 194,0,0,0,114,192,0,0,0,90,10,81,117,101,114,121,
- 86,97,108,117,101,114,50,0,0,0,41,6,114,193,0,0,
- 0,114,139,0,0,0,90,12,114,101,103,105,115,116,114,121,
- 95,107,101,121,114,7,0,0,0,90,4,104,107,101,121,218,
- 8,102,105,108,101,112,97,116,104,114,5,0,0,0,114,5,
- 0,0,0,114,8,0,0,0,218,16,95,115,101,97,114,99,
- 104,95,114,101,103,105,115,116,114,121,212,2,0,0,115,24,
- 0,0,0,0,2,6,1,8,2,6,1,6,1,16,255,6,
- 2,2,1,12,1,46,1,12,1,8,1,122,38,87,105,110,
- 100,111,119,115,82,101,103,105,115,116,114,121,70,105,110,100,
- 101,114,46,95,115,101,97,114,99,104,95,114,101,103,105,115,
- 116,114,121,78,99,4,0,0,0,0,0,0,0,0,0,0,
- 0,8,0,0,0,8,0,0,0,67,0,0,0,115,118,0,
- 0,0,124,0,160,0,124,1,161,1,125,4,124,4,100,0,
- 117,0,114,22,100,0,83,0,122,12,116,1,124,4,131,1,
- 1,0,87,0,110,20,4,0,116,2,121,54,1,0,1,0,
- 1,0,89,0,100,0,83,0,48,0,116,3,131,0,68,0,
- 93,50,92,2,125,5,125,6,124,4,160,4,116,5,124,6,
- 131,1,161,1,114,62,116,6,106,7,124,1,124,5,124,1,
- 124,4,131,2,124,4,100,1,141,3,125,7,124,7,2,0,
- 1,0,83,0,100,0,83,0,41,2,78,114,180,0,0,0,
- 41,8,114,200,0,0,0,114,49,0,0,0,114,50,0,0,
- 0,114,184,0,0,0,114,110,0,0,0,114,111,0,0,0,
- 114,134,0,0,0,218,16,115,112,101,99,95,102,114,111,109,
- 95,108,111,97,100,101,114,41,8,114,193,0,0,0,114,139,
- 0,0,0,114,44,0,0,0,218,6,116,97,114,103,101,116,
- 114,199,0,0,0,114,140,0,0,0,114,189,0,0,0,114,
- 187,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,
- 0,0,0,218,9,102,105,110,100,95,115,112,101,99,227,2,
- 0,0,115,28,0,0,0,0,2,10,1,8,1,4,1,2,
- 1,12,1,12,1,8,1,14,1,14,1,6,1,8,1,2,
- 254,6,3,122,31,87,105,110,100,111,119,115,82,101,103,105,
- 115,116,114,121,70,105,110,100,101,114,46,102,105,110,100,95,
- 115,112,101,99,99,3,0,0,0,0,0,0,0,0,0,0,
- 0,4,0,0,0,4,0,0,0,67,0,0,0,115,30,0,
- 0,0,124,0,160,0,124,1,124,2,161,2,125,3,124,3,
- 100,1,117,1,114,26,124,3,106,1,83,0,100,1,83,0,
- 41,2,122,108,70,105,110,100,32,109,111,100,117,108,101,32,
- 110,97,109,101,100,32,105,110,32,116,104,101,32,114,101,103,
- 105,115,116,114,121,46,10,10,32,32,32,32,32,32,32,32,
- 84,104,105,115,32,109,101,116,104,111,100,32,105,115,32,100,
- 101,112,114,101,99,97,116,101,100,46,32,32,85,115,101,32,
- 101,120,101,99,95,109,111,100,117,108,101,40,41,32,105,110,
- 115,116,101,97,100,46,10,10,32,32,32,32,32,32,32,32,
- 78,169,2,114,203,0,0,0,114,140,0,0,0,169,4,114,
- 193,0,0,0,114,139,0,0,0,114,44,0,0,0,114,187,
- 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,
- 0,0,218,11,102,105,110,100,95,109,111,100,117,108,101,243,
- 2,0,0,115,8,0,0,0,0,7,12,1,8,1,6,2,
- 122,33,87,105,110,100,111,119,115,82,101,103,105,115,116,114,
- 121,70,105,110,100,101,114,46,102,105,110,100,95,109,111,100,
- 117,108,101,41,2,78,78,41,1,78,41,12,114,125,0,0,
- 0,114,124,0,0,0,114,126,0,0,0,114,127,0,0,0,
- 114,197,0,0,0,114,196,0,0,0,114,195,0,0,0,218,
- 11,99,108,97,115,115,109,101,116,104,111,100,114,194,0,0,
- 0,114,200,0,0,0,114,203,0,0,0,114,206,0,0,0,
- 114,5,0,0,0,114,5,0,0,0,114,5,0,0,0,114,
- 8,0,0,0,114,191,0,0,0,193,2,0,0,115,28,0,
- 0,0,8,2,4,3,2,255,2,4,2,255,2,3,4,2,
- 2,1,10,6,2,1,10,14,2,1,12,15,2,1,114,191,
+ 105,110,100,101,114,46,102,105,110,100,95,115,112,101,99,99,
+ 3,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,
+ 4,0,0,0,67,0,0,0,115,30,0,0,0,124,0,160,
+ 0,124,1,124,2,161,2,125,3,124,3,100,1,117,1,114,
+ 26,124,3,106,1,83,0,100,1,83,0,41,2,122,108,70,
+ 105,110,100,32,109,111,100,117,108,101,32,110,97,109,101,100,
+ 32,105,110,32,116,104,101,32,114,101,103,105,115,116,114,121,
+ 46,10,10,32,32,32,32,32,32,32,32,84,104,105,115,32,
+ 109,101,116,104,111,100,32,105,115,32,100,101,112,114,101,99,
+ 97,116,101,100,46,32,32,85,115,101,32,101,120,101,99,95,
+ 109,111,100,117,108,101,40,41,32,105,110,115,116,101,97,100,
+ 46,10,10,32,32,32,32,32,32,32,32,78,169,2,114,207,
+ 0,0,0,114,144,0,0,0,169,4,114,202,0,0,0,114,
+ 143,0,0,0,114,52,0,0,0,114,191,0,0,0,114,7,
+ 0,0,0,114,7,0,0,0,114,8,0,0,0,218,11,102,
+ 105,110,100,95,109,111,100,117,108,101,29,3,0,0,115,10,
+ 0,0,0,12,7,8,1,6,1,4,2,255,128,122,33,87,
+ 105,110,100,111,119,115,82,101,103,105,115,116,114,121,70,105,
+ 110,100,101,114,46,102,105,110,100,95,109,111,100,117,108,101,
+ 41,2,78,78,41,1,78,41,15,114,130,0,0,0,114,129,
+ 0,0,0,114,131,0,0,0,114,132,0,0,0,114,200,0,
+ 0,0,114,199,0,0,0,218,11,95,77,83,95,87,73,78,
+ 68,79,87,83,218,18,69,88,84,69,78,83,73,79,78,95,
+ 83,85,70,70,73,88,69,83,114,198,0,0,0,218,12,115,
+ 116,97,116,105,99,109,101,116,104,111,100,114,197,0,0,0,
+ 218,11,99,108,97,115,115,109,101,116,104,111,100,114,204,0,
+ 0,0,114,207,0,0,0,114,210,0,0,0,114,7,0,0,
+ 0,114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,
+ 114,195,0,0,0,235,2,0,0,115,32,0,0,0,8,0,
+ 4,2,2,3,2,255,2,4,2,255,12,3,2,2,10,1,
+ 2,6,10,1,2,14,12,1,2,15,16,1,255,128,114,195,
0,0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,2,0,0,0,64,0,0,0,115,48,0,0,
0,101,0,90,1,100,0,90,2,100,1,90,3,100,2,100,
@@ -1089,7 +1128,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = {
1,100,1,25,0,125,2,124,2,160,2,100,2,100,1,161,
2,100,3,25,0,125,3,124,1,160,3,100,2,161,1,100,
4,25,0,125,4,124,3,100,5,107,2,111,62,124,4,100,
- 5,107,3,83,0,41,6,122,141,67,111,110,99,114,101,116,
+ 5,107,3,83,0,41,7,122,141,67,111,110,99,114,101,116,
101,32,105,109,112,108,101,109,101,110,116,97,116,105,111,110,
32,111,102,32,73,110,115,112,101,99,116,76,111,97,100,101,
114,46,105,115,95,112,97,99,107,97,103,101,32,98,121,32,
@@ -1098,822 +1137,831 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = {
117,114,110,101,100,32,98,121,32,103,101,116,95,102,105,108,
101,110,97,109,101,32,104,97,115,32,97,32,102,105,108,101,
110,97,109,101,32,111,102,32,39,95,95,105,110,105,116,95,
- 95,46,112,121,39,46,114,39,0,0,0,114,71,0,0,0,
- 114,73,0,0,0,114,28,0,0,0,218,8,95,95,105,110,
- 105,116,95,95,41,4,114,47,0,0,0,114,179,0,0,0,
- 114,43,0,0,0,114,41,0,0,0,41,5,114,118,0,0,
- 0,114,139,0,0,0,114,96,0,0,0,90,13,102,105,108,
- 101,110,97,109,101,95,98,97,115,101,90,9,116,97,105,108,
- 95,110,97,109,101,114,5,0,0,0,114,5,0,0,0,114,
- 8,0,0,0,114,182,0,0,0,6,3,0,0,115,8,0,
- 0,0,0,3,18,1,16,1,14,1,122,24,95,76,111,97,
- 100,101,114,66,97,115,105,99,115,46,105,115,95,112,97,99,
- 107,97,103,101,99,2,0,0,0,0,0,0,0,0,0,0,
- 0,2,0,0,0,1,0,0,0,67,0,0,0,115,4,0,
- 0,0,100,1,83,0,169,2,122,42,85,115,101,32,100,101,
- 102,97,117,108,116,32,115,101,109,97,110,116,105,99,115,32,
- 102,111,114,32,109,111,100,117,108,101,32,99,114,101,97,116,
- 105,111,110,46,78,114,5,0,0,0,169,2,114,118,0,0,
- 0,114,187,0,0,0,114,5,0,0,0,114,5,0,0,0,
- 114,8,0,0,0,218,13,99,114,101,97,116,101,95,109,111,
- 100,117,108,101,14,3,0,0,115,2,0,0,0,0,1,122,
- 27,95,76,111,97,100,101,114,66,97,115,105,99,115,46,99,
- 114,101,97,116,101,95,109,111,100,117,108,101,99,2,0,0,
- 0,0,0,0,0,0,0,0,0,3,0,0,0,5,0,0,
- 0,67,0,0,0,115,56,0,0,0,124,0,160,0,124,1,
- 106,1,161,1,125,2,124,2,100,1,117,0,114,36,116,2,
- 100,2,160,3,124,1,106,1,161,1,131,1,130,1,116,4,
- 160,5,116,6,124,2,124,1,106,7,161,3,1,0,100,1,
- 83,0,41,3,122,19,69,120,101,99,117,116,101,32,116,104,
- 101,32,109,111,100,117,108,101,46,78,122,52,99,97,110,110,
- 111,116,32,108,111,97,100,32,109,111,100,117,108,101,32,123,
- 33,114,125,32,119,104,101,110,32,103,101,116,95,99,111,100,
- 101,40,41,32,114,101,116,117,114,110,115,32,78,111,110,101,
- 41,8,218,8,103,101,116,95,99,111,100,101,114,125,0,0,
- 0,114,117,0,0,0,114,62,0,0,0,114,134,0,0,0,
- 218,25,95,99,97,108,108,95,119,105,116,104,95,102,114,97,
- 109,101,115,95,114,101,109,111,118,101,100,218,4,101,120,101,
- 99,114,131,0,0,0,41,3,114,118,0,0,0,218,6,109,
- 111,100,117,108,101,114,164,0,0,0,114,5,0,0,0,114,
- 5,0,0,0,114,8,0,0,0,218,11,101,120,101,99,95,
- 109,111,100,117,108,101,17,3,0,0,115,12,0,0,0,0,
- 2,12,1,8,1,6,1,4,255,6,2,122,25,95,76,111,
- 97,100,101,114,66,97,115,105,99,115,46,101,120,101,99,95,
- 109,111,100,117,108,101,99,2,0,0,0,0,0,0,0,0,
- 0,0,0,2,0,0,0,4,0,0,0,67,0,0,0,115,
- 12,0,0,0,116,0,160,1,124,0,124,1,161,2,83,0,
- 41,1,122,26,84,104,105,115,32,109,111,100,117,108,101,32,
- 105,115,32,100,101,112,114,101,99,97,116,101,100,46,41,2,
- 114,134,0,0,0,218,17,95,108,111,97,100,95,109,111,100,
- 117,108,101,95,115,104,105,109,169,2,114,118,0,0,0,114,
- 139,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,
- 0,0,0,218,11,108,111,97,100,95,109,111,100,117,108,101,
- 25,3,0,0,115,2,0,0,0,0,2,122,25,95,76,111,
- 97,100,101,114,66,97,115,105,99,115,46,108,111,97,100,95,
- 109,111,100,117,108,101,78,41,8,114,125,0,0,0,114,124,
- 0,0,0,114,126,0,0,0,114,127,0,0,0,114,182,0,
- 0,0,114,212,0,0,0,114,217,0,0,0,114,220,0,0,
- 0,114,5,0,0,0,114,5,0,0,0,114,5,0,0,0,
- 114,8,0,0,0,114,208,0,0,0,1,3,0,0,115,10,
- 0,0,0,8,2,4,3,8,8,8,3,8,8,114,208,0,
- 0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,3,0,0,0,64,0,0,0,115,74,0,0,0,
- 101,0,90,1,100,0,90,2,100,1,100,2,132,0,90,3,
- 100,3,100,4,132,0,90,4,100,5,100,6,132,0,90,5,
- 100,7,100,8,132,0,90,6,100,9,100,10,132,0,90,7,
- 100,11,100,12,156,1,100,13,100,14,132,2,90,8,100,15,
- 100,16,132,0,90,9,100,17,83,0,41,18,218,12,83,111,
- 117,114,99,101,76,111,97,100,101,114,99,2,0,0,0,0,
- 0,0,0,0,0,0,0,2,0,0,0,1,0,0,0,67,
- 0,0,0,115,8,0,0,0,116,0,130,1,100,1,83,0,
- 41,2,122,165,79,112,116,105,111,110,97,108,32,109,101,116,
- 104,111,100,32,116,104,97,116,32,114,101,116,117,114,110,115,
- 32,116,104,101,32,109,111,100,105,102,105,99,97,116,105,111,
- 110,32,116,105,109,101,32,40,97,110,32,105,110,116,41,32,
- 102,111,114,32,116,104,101,10,32,32,32,32,32,32,32,32,
- 115,112,101,99,105,102,105,101,100,32,112,97,116,104,32,40,
- 97,32,115,116,114,41,46,10,10,32,32,32,32,32,32,32,
- 32,82,97,105,115,101,115,32,79,83,69,114,114,111,114,32,
- 119,104,101,110,32,116,104,101,32,112,97,116,104,32,99,97,
- 110,110,111,116,32,98,101,32,104,97,110,100,108,101,100,46,
- 10,32,32,32,32,32,32,32,32,78,41,1,114,50,0,0,
- 0,169,2,114,118,0,0,0,114,44,0,0,0,114,5,0,
- 0,0,114,5,0,0,0,114,8,0,0,0,218,10,112,97,
- 116,104,95,109,116,105,109,101,32,3,0,0,115,2,0,0,
- 0,0,6,122,23,83,111,117,114,99,101,76,111,97,100,101,
- 114,46,112,97,116,104,95,109,116,105,109,101,99,2,0,0,
- 0,0,0,0,0,0,0,0,0,2,0,0,0,4,0,0,
- 0,67,0,0,0,115,14,0,0,0,100,1,124,0,160,0,
- 124,1,161,1,105,1,83,0,41,2,97,158,1,0,0,79,
- 112,116,105,111,110,97,108,32,109,101,116,104,111,100,32,114,
- 101,116,117,114,110,105,110,103,32,97,32,109,101,116,97,100,
- 97,116,97,32,100,105,99,116,32,102,111,114,32,116,104,101,
- 32,115,112,101,99,105,102,105,101,100,10,32,32,32,32,32,
- 32,32,32,112,97,116,104,32,40,97,32,115,116,114,41,46,
- 10,10,32,32,32,32,32,32,32,32,80,111,115,115,105,98,
- 108,101,32,107,101,121,115,58,10,32,32,32,32,32,32,32,
- 32,45,32,39,109,116,105,109,101,39,32,40,109,97,110,100,
- 97,116,111,114,121,41,32,105,115,32,116,104,101,32,110,117,
- 109,101,114,105,99,32,116,105,109,101,115,116,97,109,112,32,
- 111,102,32,108,97,115,116,32,115,111,117,114,99,101,10,32,
- 32,32,32,32,32,32,32,32,32,99,111,100,101,32,109,111,
- 100,105,102,105,99,97,116,105,111,110,59,10,32,32,32,32,
- 32,32,32,32,45,32,39,115,105,122,101,39,32,40,111,112,
- 116,105,111,110,97,108,41,32,105,115,32,116,104,101,32,115,
- 105,122,101,32,105,110,32,98,121,116,101,115,32,111,102,32,
- 116,104,101,32,115,111,117,114,99,101,32,99,111,100,101,46,
- 10,10,32,32,32,32,32,32,32,32,73,109,112,108,101,109,
- 101,110,116,105,110,103,32,116,104,105,115,32,109,101,116,104,
- 111,100,32,97,108,108,111,119,115,32,116,104,101,32,108,111,
- 97,100,101,114,32,116,111,32,114,101,97,100,32,98,121,116,
- 101,99,111,100,101,32,102,105,108,101,115,46,10,32,32,32,
- 32,32,32,32,32,82,97,105,115,101,115,32,79,83,69,114,
- 114,111,114,32,119,104,101,110,32,116,104,101,32,112,97,116,
- 104,32,99,97,110,110,111,116,32,98,101,32,104,97,110,100,
- 108,101,100,46,10,32,32,32,32,32,32,32,32,114,169,0,
- 0,0,41,1,114,223,0,0,0,114,222,0,0,0,114,5,
- 0,0,0,114,5,0,0,0,114,8,0,0,0,218,10,112,
- 97,116,104,95,115,116,97,116,115,40,3,0,0,115,2,0,
- 0,0,0,12,122,23,83,111,117,114,99,101,76,111,97,100,
- 101,114,46,112,97,116,104,95,115,116,97,116,115,99,4,0,
- 0,0,0,0,0,0,0,0,0,0,4,0,0,0,4,0,
- 0,0,67,0,0,0,115,12,0,0,0,124,0,160,0,124,
- 2,124,3,161,2,83,0,41,1,122,228,79,112,116,105,111,
- 110,97,108,32,109,101,116,104,111,100,32,119,104,105,99,104,
- 32,119,114,105,116,101,115,32,100,97,116,97,32,40,98,121,
- 116,101,115,41,32,116,111,32,97,32,102,105,108,101,32,112,
+ 95,46,112,121,39,46,114,3,0,0,0,114,79,0,0,0,
+ 114,0,0,0,0,114,39,0,0,0,218,8,95,95,105,110,
+ 105,116,95,95,78,41,4,114,55,0,0,0,114,183,0,0,
+ 0,114,51,0,0,0,114,49,0,0,0,41,5,114,123,0,
+ 0,0,114,143,0,0,0,114,101,0,0,0,90,13,102,105,
+ 108,101,110,97,109,101,95,98,97,115,101,90,9,116,97,105,
+ 108,95,110,97,109,101,114,7,0,0,0,114,7,0,0,0,
+ 114,8,0,0,0,114,186,0,0,0,48,3,0,0,115,10,
+ 0,0,0,18,3,16,1,14,1,16,1,255,128,122,24,95,
+ 76,111,97,100,101,114,66,97,115,105,99,115,46,105,115,95,
+ 112,97,99,107,97,103,101,99,2,0,0,0,0,0,0,0,
+ 0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,
+ 115,4,0,0,0,100,1,83,0,169,2,122,42,85,115,101,
+ 32,100,101,102,97,117,108,116,32,115,101,109,97,110,116,105,
+ 99,115,32,102,111,114,32,109,111,100,117,108,101,32,99,114,
+ 101,97,116,105,111,110,46,78,114,7,0,0,0,169,2,114,
+ 123,0,0,0,114,191,0,0,0,114,7,0,0,0,114,7,
+ 0,0,0,114,8,0,0,0,218,13,99,114,101,97,116,101,
+ 95,109,111,100,117,108,101,56,3,0,0,115,4,0,0,0,
+ 4,0,255,128,122,27,95,76,111,97,100,101,114,66,97,115,
+ 105,99,115,46,99,114,101,97,116,101,95,109,111,100,117,108,
+ 101,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0,
+ 0,0,5,0,0,0,67,0,0,0,115,56,0,0,0,124,
+ 0,160,0,124,1,106,1,161,1,125,2,124,2,100,1,117,
+ 0,114,36,116,2,100,2,160,3,124,1,106,1,161,1,131,
+ 1,130,1,116,4,160,5,116,6,124,2,124,1,106,7,161,
+ 3,1,0,100,1,83,0,41,3,122,19,69,120,101,99,117,
+ 116,101,32,116,104,101,32,109,111,100,117,108,101,46,78,122,
+ 52,99,97,110,110,111,116,32,108,111,97,100,32,109,111,100,
+ 117,108,101,32,123,33,114,125,32,119,104,101,110,32,103,101,
+ 116,95,99,111,100,101,40,41,32,114,101,116,117,114,110,115,
+ 32,78,111,110,101,41,8,218,8,103,101,116,95,99,111,100,
+ 101,114,130,0,0,0,114,122,0,0,0,114,70,0,0,0,
+ 114,139,0,0,0,218,25,95,99,97,108,108,95,119,105,116,
+ 104,95,102,114,97,109,101,115,95,114,101,109,111,118,101,100,
+ 218,4,101,120,101,99,114,136,0,0,0,41,3,114,123,0,
+ 0,0,218,6,109,111,100,117,108,101,114,168,0,0,0,114,
+ 7,0,0,0,114,7,0,0,0,114,8,0,0,0,218,11,
+ 101,120,101,99,95,109,111,100,117,108,101,59,3,0,0,115,
+ 14,0,0,0,12,2,8,1,6,1,4,1,6,255,20,2,
+ 255,128,122,25,95,76,111,97,100,101,114,66,97,115,105,99,
+ 115,46,101,120,101,99,95,109,111,100,117,108,101,99,2,0,
+ 0,0,0,0,0,0,0,0,0,0,2,0,0,0,4,0,
+ 0,0,67,0,0,0,115,12,0,0,0,116,0,160,1,124,
+ 0,124,1,161,2,83,0,41,2,122,26,84,104,105,115,32,
+ 109,101,116,104,111,100,32,105,115,32,100,101,112,114,101,99,
+ 97,116,101,100,46,78,41,2,114,139,0,0,0,218,17,95,
+ 108,111,97,100,95,109,111,100,117,108,101,95,115,104,105,109,
+ 169,2,114,123,0,0,0,114,143,0,0,0,114,7,0,0,
+ 0,114,7,0,0,0,114,8,0,0,0,218,11,108,111,97,
+ 100,95,109,111,100,117,108,101,67,3,0,0,115,4,0,0,
+ 0,12,3,255,128,122,25,95,76,111,97,100,101,114,66,97,
+ 115,105,99,115,46,108,111,97,100,95,109,111,100,117,108,101,
+ 78,41,8,114,130,0,0,0,114,129,0,0,0,114,131,0,
+ 0,0,114,132,0,0,0,114,186,0,0,0,114,219,0,0,
+ 0,114,224,0,0,0,114,227,0,0,0,114,7,0,0,0,
+ 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,114,
+ 215,0,0,0,43,3,0,0,115,14,0,0,0,8,0,4,
+ 2,8,3,8,8,8,3,12,8,255,128,114,215,0,0,0,
+ 99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,3,0,0,0,64,0,0,0,115,74,0,0,0,101,0,
+ 90,1,100,0,90,2,100,1,100,2,132,0,90,3,100,3,
+ 100,4,132,0,90,4,100,5,100,6,132,0,90,5,100,7,
+ 100,8,132,0,90,6,100,9,100,10,132,0,90,7,100,11,
+ 100,12,156,1,100,13,100,14,132,2,90,8,100,15,100,16,
+ 132,0,90,9,100,17,83,0,41,18,218,12,83,111,117,114,
+ 99,101,76,111,97,100,101,114,99,2,0,0,0,0,0,0,
+ 0,0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,
+ 0,115,4,0,0,0,116,0,130,1,41,2,122,165,79,112,
+ 116,105,111,110,97,108,32,109,101,116,104,111,100,32,116,104,
+ 97,116,32,114,101,116,117,114,110,115,32,116,104,101,32,109,
+ 111,100,105,102,105,99,97,116,105,111,110,32,116,105,109,101,
+ 32,40,97,110,32,105,110,116,41,32,102,111,114,32,116,104,
+ 101,10,32,32,32,32,32,32,32,32,115,112,101,99,105,102,
+ 105,101,100,32,112,97,116,104,32,40,97,32,115,116,114,41,
+ 46,10,10,32,32,32,32,32,32,32,32,82,97,105,115,101,
+ 115,32,79,83,69,114,114,111,114,32,119,104,101,110,32,116,
+ 104,101,32,112,97,116,104,32,99,97,110,110,111,116,32,98,
+ 101,32,104,97,110,100,108,101,100,46,10,32,32,32,32,32,
+ 32,32,32,78,41,1,114,58,0,0,0,169,2,114,123,0,
+ 0,0,114,52,0,0,0,114,7,0,0,0,114,7,0,0,
+ 0,114,8,0,0,0,218,10,112,97,116,104,95,109,116,105,
+ 109,101,75,3,0,0,115,4,0,0,0,4,6,255,128,122,
+ 23,83,111,117,114,99,101,76,111,97,100,101,114,46,112,97,
+ 116,104,95,109,116,105,109,101,99,2,0,0,0,0,0,0,
+ 0,0,0,0,0,2,0,0,0,4,0,0,0,67,0,0,
+ 0,115,14,0,0,0,100,1,124,0,160,0,124,1,161,1,
+ 105,1,83,0,41,3,97,158,1,0,0,79,112,116,105,111,
+ 110,97,108,32,109,101,116,104,111,100,32,114,101,116,117,114,
+ 110,105,110,103,32,97,32,109,101,116,97,100,97,116,97,32,
+ 100,105,99,116,32,102,111,114,32,116,104,101,32,115,112,101,
+ 99,105,102,105,101,100,10,32,32,32,32,32,32,32,32,112,
97,116,104,32,40,97,32,115,116,114,41,46,10,10,32,32,
+ 32,32,32,32,32,32,80,111,115,115,105,98,108,101,32,107,
+ 101,121,115,58,10,32,32,32,32,32,32,32,32,45,32,39,
+ 109,116,105,109,101,39,32,40,109,97,110,100,97,116,111,114,
+ 121,41,32,105,115,32,116,104,101,32,110,117,109,101,114,105,
+ 99,32,116,105,109,101,115,116,97,109,112,32,111,102,32,108,
+ 97,115,116,32,115,111,117,114,99,101,10,32,32,32,32,32,
+ 32,32,32,32,32,99,111,100,101,32,109,111,100,105,102,105,
+ 99,97,116,105,111,110,59,10,32,32,32,32,32,32,32,32,
+ 45,32,39,115,105,122,101,39,32,40,111,112,116,105,111,110,
+ 97,108,41,32,105,115,32,116,104,101,32,115,105,122,101,32,
+ 105,110,32,98,121,116,101,115,32,111,102,32,116,104,101,32,
+ 115,111,117,114,99,101,32,99,111,100,101,46,10,10,32,32,
32,32,32,32,32,32,73,109,112,108,101,109,101,110,116,105,
110,103,32,116,104,105,115,32,109,101,116,104,111,100,32,97,
- 108,108,111,119,115,32,102,111,114,32,116,104,101,32,119,114,
- 105,116,105,110,103,32,111,102,32,98,121,116,101,99,111,100,
- 101,32,102,105,108,101,115,46,10,10,32,32,32,32,32,32,
- 32,32,84,104,101,32,115,111,117,114,99,101,32,112,97,116,
- 104,32,105,115,32,110,101,101,100,101,100,32,105,110,32,111,
- 114,100,101,114,32,116,111,32,99,111,114,114,101,99,116,108,
- 121,32,116,114,97,110,115,102,101,114,32,112,101,114,109,105,
- 115,115,105,111,110,115,10,32,32,32,32,32,32,32,32,41,
- 1,218,8,115,101,116,95,100,97,116,97,41,4,114,118,0,
- 0,0,114,107,0,0,0,90,10,99,97,99,104,101,95,112,
- 97,116,104,114,26,0,0,0,114,5,0,0,0,114,5,0,
+ 108,108,111,119,115,32,116,104,101,32,108,111,97,100,101,114,
+ 32,116,111,32,114,101,97,100,32,98,121,116,101,99,111,100,
+ 101,32,102,105,108,101,115,46,10,32,32,32,32,32,32,32,
+ 32,82,97,105,115,101,115,32,79,83,69,114,114,111,114,32,
+ 119,104,101,110,32,116,104,101,32,112,97,116,104,32,99,97,
+ 110,110,111,116,32,98,101,32,104,97,110,100,108,101,100,46,
+ 10,32,32,32,32,32,32,32,32,114,173,0,0,0,78,41,
+ 1,114,230,0,0,0,114,229,0,0,0,114,7,0,0,0,
+ 114,7,0,0,0,114,8,0,0,0,218,10,112,97,116,104,
+ 95,115,116,97,116,115,83,3,0,0,115,4,0,0,0,14,
+ 12,255,128,122,23,83,111,117,114,99,101,76,111,97,100,101,
+ 114,46,112,97,116,104,95,115,116,97,116,115,99,4,0,0,
+ 0,0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,
+ 0,67,0,0,0,115,12,0,0,0,124,0,160,0,124,2,
+ 124,3,161,2,83,0,41,2,122,228,79,112,116,105,111,110,
+ 97,108,32,109,101,116,104,111,100,32,119,104,105,99,104,32,
+ 119,114,105,116,101,115,32,100,97,116,97,32,40,98,121,116,
+ 101,115,41,32,116,111,32,97,32,102,105,108,101,32,112,97,
+ 116,104,32,40,97,32,115,116,114,41,46,10,10,32,32,32,
+ 32,32,32,32,32,73,109,112,108,101,109,101,110,116,105,110,
+ 103,32,116,104,105,115,32,109,101,116,104,111,100,32,97,108,
+ 108,111,119,115,32,102,111,114,32,116,104,101,32,119,114,105,
+ 116,105,110,103,32,111,102,32,98,121,116,101,99,111,100,101,
+ 32,102,105,108,101,115,46,10,10,32,32,32,32,32,32,32,
+ 32,84,104,101,32,115,111,117,114,99,101,32,112,97,116,104,
+ 32,105,115,32,110,101,101,100,101,100,32,105,110,32,111,114,
+ 100,101,114,32,116,111,32,99,111,114,114,101,99,116,108,121,
+ 32,116,114,97,110,115,102,101,114,32,112,101,114,109,105,115,
+ 115,105,111,110,115,10,32,32,32,32,32,32,32,32,78,41,
+ 1,218,8,115,101,116,95,100,97,116,97,41,4,114,123,0,
+ 0,0,114,112,0,0,0,90,10,99,97,99,104,101,95,112,
+ 97,116,104,114,37,0,0,0,114,7,0,0,0,114,7,0,
0,0,114,8,0,0,0,218,15,95,99,97,99,104,101,95,
- 98,121,116,101,99,111,100,101,54,3,0,0,115,2,0,0,
- 0,0,8,122,28,83,111,117,114,99,101,76,111,97,100,101,
- 114,46,95,99,97,99,104,101,95,98,121,116,101,99,111,100,
- 101,99,3,0,0,0,0,0,0,0,0,0,0,0,3,0,
- 0,0,1,0,0,0,67,0,0,0,115,4,0,0,0,100,
- 1,83,0,41,2,122,150,79,112,116,105,111,110,97,108,32,
- 109,101,116,104,111,100,32,119,104,105,99,104,32,119,114,105,
- 116,101,115,32,100,97,116,97,32,40,98,121,116,101,115,41,
- 32,116,111,32,97,32,102,105,108,101,32,112,97,116,104,32,
- 40,97,32,115,116,114,41,46,10,10,32,32,32,32,32,32,
- 32,32,73,109,112,108,101,109,101,110,116,105,110,103,32,116,
- 104,105,115,32,109,101,116,104,111,100,32,97,108,108,111,119,
- 115,32,102,111,114,32,116,104,101,32,119,114,105,116,105,110,
- 103,32,111,102,32,98,121,116,101,99,111,100,101,32,102,105,
- 108,101,115,46,10,32,32,32,32,32,32,32,32,78,114,5,
- 0,0,0,41,3,114,118,0,0,0,114,44,0,0,0,114,
- 26,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,
- 0,0,0,114,225,0,0,0,64,3,0,0,115,2,0,0,
- 0,0,1,122,21,83,111,117,114,99,101,76,111,97,100,101,
- 114,46,115,101,116,95,100,97,116,97,99,2,0,0,0,0,
- 0,0,0,0,0,0,0,5,0,0,0,10,0,0,0,67,
- 0,0,0,115,84,0,0,0,124,0,160,0,124,1,161,1,
- 125,2,122,14,124,0,160,1,124,2,161,1,125,3,87,0,
- 110,50,4,0,116,2,121,74,1,0,125,4,1,0,122,26,
- 116,3,100,1,124,1,100,2,141,2,124,4,130,2,87,0,
- 89,0,100,3,125,4,126,4,110,10,100,3,125,4,126,4,
- 48,0,48,0,116,4,124,3,131,1,83,0,41,4,122,52,
- 67,111,110,99,114,101,116,101,32,105,109,112,108,101,109,101,
- 110,116,97,116,105,111,110,32,111,102,32,73,110,115,112,101,
- 99,116,76,111,97,100,101,114,46,103,101,116,95,115,111,117,
- 114,99,101,46,122,39,115,111,117,114,99,101,32,110,111,116,
- 32,97,118,97,105,108,97,98,108,101,32,116,104,114,111,117,
- 103,104,32,103,101,116,95,100,97,116,97,40,41,114,115,0,
- 0,0,78,41,5,114,179,0,0,0,218,8,103,101,116,95,
- 100,97,116,97,114,50,0,0,0,114,117,0,0,0,114,176,
- 0,0,0,41,5,114,118,0,0,0,114,139,0,0,0,114,
- 44,0,0,0,114,174,0,0,0,218,3,101,120,99,114,5,
- 0,0,0,114,5,0,0,0,114,8,0,0,0,218,10,103,
- 101,116,95,115,111,117,114,99,101,71,3,0,0,115,20,0,
- 0,0,0,2,10,1,2,1,14,1,14,1,4,1,2,255,
- 4,1,2,255,24,2,122,23,83,111,117,114,99,101,76,111,
- 97,100,101,114,46,103,101,116,95,115,111,117,114,99,101,114,
- 104,0,0,0,41,1,218,9,95,111,112,116,105,109,105,122,
- 101,99,3,0,0,0,0,0,0,0,1,0,0,0,4,0,
- 0,0,8,0,0,0,67,0,0,0,115,22,0,0,0,116,
- 0,106,1,116,2,124,1,124,2,100,1,100,2,124,3,100,
- 3,141,6,83,0,41,4,122,130,82,101,116,117,114,110,32,
- 116,104,101,32,99,111,100,101,32,111,98,106,101,99,116,32,
- 99,111,109,112,105,108,101,100,32,102,114,111,109,32,115,111,
- 117,114,99,101,46,10,10,32,32,32,32,32,32,32,32,84,
- 104,101,32,39,100,97,116,97,39,32,97,114,103,117,109,101,
- 110,116,32,99,97,110,32,98,101,32,97,110,121,32,111,98,
- 106,101,99,116,32,116,121,112,101,32,116,104,97,116,32,99,
- 111,109,112,105,108,101,40,41,32,115,117,112,112,111,114,116,
- 115,46,10,32,32,32,32,32,32,32,32,114,215,0,0,0,
- 84,41,2,218,12,100,111,110,116,95,105,110,104,101,114,105,
- 116,114,83,0,0,0,41,3,114,134,0,0,0,114,214,0,
- 0,0,218,7,99,111,109,112,105,108,101,41,4,114,118,0,
- 0,0,114,26,0,0,0,114,44,0,0,0,114,230,0,0,
- 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,
- 218,14,115,111,117,114,99,101,95,116,111,95,99,111,100,101,
- 81,3,0,0,115,6,0,0,0,0,5,12,1,4,255,122,
- 27,83,111,117,114,99,101,76,111,97,100,101,114,46,115,111,
- 117,114,99,101,95,116,111,95,99,111,100,101,99,2,0,0,
- 0,0,0,0,0,0,0,0,0,15,0,0,0,9,0,0,
- 0,67,0,0,0,115,24,2,0,0,124,0,160,0,124,1,
- 161,1,125,2,100,1,125,3,100,1,125,4,100,1,125,5,
- 100,2,125,6,100,3,125,7,122,12,116,1,124,2,131,1,
- 125,8,87,0,110,24,4,0,116,2,121,66,1,0,1,0,
- 1,0,100,1,125,8,89,0,144,1,110,42,48,0,122,14,
- 124,0,160,3,124,2,161,1,125,9,87,0,110,20,4,0,
- 116,4,121,102,1,0,1,0,1,0,89,0,144,1,110,6,
- 48,0,116,5,124,9,100,4,25,0,131,1,125,3,122,14,
- 124,0,160,6,124,8,161,1,125,10,87,0,110,18,4,0,
- 116,4,121,148,1,0,1,0,1,0,89,0,110,216,48,0,
- 124,1,124,8,100,5,156,2,125,11,122,148,116,7,124,10,
- 124,1,124,11,131,3,125,12,116,8,124,10,131,1,100,6,
- 100,1,133,2,25,0,125,13,124,12,100,7,64,0,100,8,
- 107,3,125,6,124,6,144,1,114,30,124,12,100,9,64,0,
- 100,8,107,3,125,7,116,9,106,10,100,10,107,3,144,1,
- 114,50,124,7,115,248,116,9,106,10,100,11,107,2,144,1,
- 114,50,124,0,160,6,124,2,161,1,125,4,116,9,160,11,
- 116,12,124,4,161,2,125,5,116,13,124,10,124,5,124,1,
- 124,11,131,4,1,0,110,20,116,14,124,10,124,3,124,9,
- 100,12,25,0,124,1,124,11,131,5,1,0,87,0,110,24,
- 4,0,116,15,116,16,102,2,144,1,121,76,1,0,1,0,
- 1,0,89,0,110,32,48,0,116,17,160,18,100,13,124,8,
- 124,2,161,3,1,0,116,19,124,13,124,1,124,8,124,2,
- 100,14,141,4,83,0,124,4,100,1,117,0,144,1,114,128,
- 124,0,160,6,124,2,161,1,125,4,124,0,160,20,124,4,
- 124,2,161,2,125,14,116,17,160,18,100,15,124,2,161,2,
- 1,0,116,21,106,22,144,2,115,20,124,8,100,1,117,1,
- 144,2,114,20,124,3,100,1,117,1,144,2,114,20,124,6,
- 144,1,114,220,124,5,100,1,117,0,144,1,114,206,116,9,
- 160,11,124,4,161,1,125,5,116,23,124,14,124,5,124,7,
- 131,3,125,10,110,16,116,24,124,14,124,3,116,25,124,4,
- 131,1,131,3,125,10,122,18,124,0,160,26,124,2,124,8,
- 124,10,161,3,1,0,87,0,110,20,4,0,116,2,144,2,
- 121,18,1,0,1,0,1,0,89,0,110,2,48,0,124,14,
- 83,0,41,16,122,190,67,111,110,99,114,101,116,101,32,105,
+ 98,121,116,101,99,111,100,101,97,3,0,0,115,4,0,0,
+ 0,12,8,255,128,122,28,83,111,117,114,99,101,76,111,97,
+ 100,101,114,46,95,99,97,99,104,101,95,98,121,116,101,99,
+ 111,100,101,99,3,0,0,0,0,0,0,0,0,0,0,0,
+ 3,0,0,0,1,0,0,0,67,0,0,0,115,4,0,0,
+ 0,100,1,83,0,41,2,122,150,79,112,116,105,111,110,97,
+ 108,32,109,101,116,104,111,100,32,119,104,105,99,104,32,119,
+ 114,105,116,101,115,32,100,97,116,97,32,40,98,121,116,101,
+ 115,41,32,116,111,32,97,32,102,105,108,101,32,112,97,116,
+ 104,32,40,97,32,115,116,114,41,46,10,10,32,32,32,32,
+ 32,32,32,32,73,109,112,108,101,109,101,110,116,105,110,103,
+ 32,116,104,105,115,32,109,101,116,104,111,100,32,97,108,108,
+ 111,119,115,32,102,111,114,32,116,104,101,32,119,114,105,116,
+ 105,110,103,32,111,102,32,98,121,116,101,99,111,100,101,32,
+ 102,105,108,101,115,46,10,32,32,32,32,32,32,32,32,78,
+ 114,7,0,0,0,41,3,114,123,0,0,0,114,52,0,0,
+ 0,114,37,0,0,0,114,7,0,0,0,114,7,0,0,0,
+ 114,8,0,0,0,114,232,0,0,0,107,3,0,0,115,4,
+ 0,0,0,4,0,255,128,122,21,83,111,117,114,99,101,76,
+ 111,97,100,101,114,46,115,101,116,95,100,97,116,97,99,2,
+ 0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,10,
+ 0,0,0,67,0,0,0,115,70,0,0,0,124,0,160,0,
+ 124,1,161,1,125,2,122,20,124,0,160,1,124,2,161,1,
+ 125,3,87,0,116,4,124,3,131,1,83,0,4,0,116,2,
+ 121,68,1,0,125,4,1,0,122,14,116,3,100,1,124,1,
+ 100,2,141,2,124,4,130,2,100,3,125,4,126,4,119,1,
+ 119,0,41,4,122,52,67,111,110,99,114,101,116,101,32,105,
109,112,108,101,109,101,110,116,97,116,105,111,110,32,111,102,
32,73,110,115,112,101,99,116,76,111,97,100,101,114,46,103,
- 101,116,95,99,111,100,101,46,10,10,32,32,32,32,32,32,
- 32,32,82,101,97,100,105,110,103,32,111,102,32,98,121,116,
- 101,99,111,100,101,32,114,101,113,117,105,114,101,115,32,112,
- 97,116,104,95,115,116,97,116,115,32,116,111,32,98,101,32,
- 105,109,112,108,101,109,101,110,116,101,100,46,32,84,111,32,
- 119,114,105,116,101,10,32,32,32,32,32,32,32,32,98,121,
- 116,101,99,111,100,101,44,32,115,101,116,95,100,97,116,97,
- 32,109,117,115,116,32,97,108,115,111,32,98,101,32,105,109,
- 112,108,101,109,101,110,116,101,100,46,10,10,32,32,32,32,
- 32,32,32,32,78,70,84,114,169,0,0,0,114,159,0,0,
- 0,114,145,0,0,0,114,39,0,0,0,114,73,0,0,0,
- 114,28,0,0,0,90,5,110,101,118,101,114,90,6,97,108,
- 119,97,121,115,218,4,115,105,122,101,122,13,123,125,32,109,
- 97,116,99,104,101,115,32,123,125,41,3,114,116,0,0,0,
- 114,106,0,0,0,114,107,0,0,0,122,19,99,111,100,101,
- 32,111,98,106,101,99,116,32,102,114,111,109,32,123,125,41,
- 27,114,179,0,0,0,114,97,0,0,0,114,82,0,0,0,
- 114,224,0,0,0,114,50,0,0,0,114,18,0,0,0,114,
- 227,0,0,0,114,152,0,0,0,218,10,109,101,109,111,114,
- 121,118,105,101,119,114,163,0,0,0,90,21,99,104,101,99,
- 107,95,104,97,115,104,95,98,97,115,101,100,95,112,121,99,
- 115,114,157,0,0,0,218,17,95,82,65,87,95,77,65,71,
- 73,67,95,78,85,77,66,69,82,114,158,0,0,0,114,156,
- 0,0,0,114,117,0,0,0,114,150,0,0,0,114,134,0,
- 0,0,114,149,0,0,0,114,165,0,0,0,114,233,0,0,
- 0,114,1,0,0,0,218,19,100,111,110,116,95,119,114,105,
- 116,101,95,98,121,116,101,99,111,100,101,114,171,0,0,0,
- 114,170,0,0,0,114,23,0,0,0,114,226,0,0,0,41,
- 15,114,118,0,0,0,114,139,0,0,0,114,107,0,0,0,
- 114,154,0,0,0,114,174,0,0,0,114,157,0,0,0,90,
- 10,104,97,115,104,95,98,97,115,101,100,90,12,99,104,101,
- 99,107,95,115,111,117,114,99,101,114,106,0,0,0,218,2,
- 115,116,114,26,0,0,0,114,151,0,0,0,114,2,0,0,
- 0,90,10,98,121,116,101,115,95,100,97,116,97,90,11,99,
- 111,100,101,95,111,98,106,101,99,116,114,5,0,0,0,114,
- 5,0,0,0,114,8,0,0,0,114,213,0,0,0,89,3,
- 0,0,115,152,0,0,0,0,7,10,1,4,1,4,1,4,
- 1,4,1,4,1,2,1,12,1,12,1,12,2,2,1,14,
- 1,12,1,8,2,12,1,2,1,14,1,12,1,6,3,2,
- 1,2,254,6,4,2,1,12,1,16,1,12,1,6,1,12,
- 1,12,1,2,255,2,2,8,254,4,3,10,1,4,1,2,
- 1,2,254,4,4,8,1,2,255,6,3,2,1,2,1,2,
- 1,6,1,2,1,2,251,8,7,18,1,6,2,8,1,2,
- 255,4,2,6,1,2,1,2,254,6,3,10,1,10,1,12,
- 1,12,1,18,1,6,255,4,2,6,1,10,1,10,1,14,
- 2,6,1,6,255,4,2,2,1,18,1,14,1,6,1,122,
- 21,83,111,117,114,99,101,76,111,97,100,101,114,46,103,101,
- 116,95,99,111,100,101,78,41,10,114,125,0,0,0,114,124,
- 0,0,0,114,126,0,0,0,114,223,0,0,0,114,224,0,
- 0,0,114,226,0,0,0,114,225,0,0,0,114,229,0,0,
- 0,114,233,0,0,0,114,213,0,0,0,114,5,0,0,0,
- 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,
- 221,0,0,0,30,3,0,0,115,14,0,0,0,8,2,8,
- 8,8,14,8,10,8,7,8,10,14,8,114,221,0,0,0,
- 99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,4,0,0,0,0,0,0,0,115,92,0,0,0,101,0,
- 90,1,100,0,90,2,100,1,90,3,100,2,100,3,132,0,
- 90,4,100,4,100,5,132,0,90,5,100,6,100,7,132,0,
- 90,6,101,7,135,0,102,1,100,8,100,9,132,8,131,1,
- 90,8,101,7,100,10,100,11,132,0,131,1,90,9,100,12,
- 100,13,132,0,90,10,101,7,100,14,100,15,132,0,131,1,
- 90,11,135,0,4,0,90,12,83,0,41,16,218,10,70,105,
- 108,101,76,111,97,100,101,114,122,103,66,97,115,101,32,102,
- 105,108,101,32,108,111,97,100,101,114,32,99,108,97,115,115,
- 32,119,104,105,99,104,32,105,109,112,108,101,109,101,110,116,
- 115,32,116,104,101,32,108,111,97,100,101,114,32,112,114,111,
- 116,111,99,111,108,32,109,101,116,104,111,100,115,32,116,104,
- 97,116,10,32,32,32,32,114,101,113,117,105,114,101,32,102,
- 105,108,101,32,115,121,115,116,101,109,32,117,115,97,103,101,
- 46,99,3,0,0,0,0,0,0,0,0,0,0,0,3,0,
- 0,0,2,0,0,0,67,0,0,0,115,16,0,0,0,124,
- 1,124,0,95,0,124,2,124,0,95,1,100,1,83,0,41,
- 2,122,75,67,97,99,104,101,32,116,104,101,32,109,111,100,
- 117,108,101,32,110,97,109,101,32,97,110,100,32,116,104,101,
- 32,112,97,116,104,32,116,111,32,116,104,101,32,102,105,108,
- 101,32,102,111,117,110,100,32,98,121,32,116,104,101,10,32,
- 32,32,32,32,32,32,32,102,105,110,100,101,114,46,78,114,
- 159,0,0,0,41,3,114,118,0,0,0,114,139,0,0,0,
- 114,44,0,0,0,114,5,0,0,0,114,5,0,0,0,114,
- 8,0,0,0,114,209,0,0,0,179,3,0,0,115,4,0,
- 0,0,0,3,6,1,122,19,70,105,108,101,76,111,97,100,
- 101,114,46,95,95,105,110,105,116,95,95,99,2,0,0,0,
- 0,0,0,0,0,0,0,0,2,0,0,0,2,0,0,0,
- 67,0,0,0,115,24,0,0,0,124,0,106,0,124,1,106,
- 0,107,2,111,22,124,0,106,1,124,1,106,1,107,2,83,
- 0,114,109,0,0,0,169,2,218,9,95,95,99,108,97,115,
- 115,95,95,114,131,0,0,0,169,2,114,118,0,0,0,90,
- 5,111,116,104,101,114,114,5,0,0,0,114,5,0,0,0,
- 114,8,0,0,0,218,6,95,95,101,113,95,95,185,3,0,
- 0,115,6,0,0,0,0,1,12,1,10,255,122,17,70,105,
- 108,101,76,111,97,100,101,114,46,95,95,101,113,95,95,99,
- 1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,
- 3,0,0,0,67,0,0,0,115,20,0,0,0,116,0,124,
- 0,106,1,131,1,116,0,124,0,106,2,131,1,65,0,83,
- 0,114,109,0,0,0,169,3,218,4,104,97,115,104,114,116,
- 0,0,0,114,44,0,0,0,169,1,114,118,0,0,0,114,
- 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,8,
- 95,95,104,97,115,104,95,95,189,3,0,0,115,2,0,0,
- 0,0,1,122,19,70,105,108,101,76,111,97,100,101,114,46,
- 95,95,104,97,115,104,95,95,99,2,0,0,0,0,0,0,
- 0,0,0,0,0,2,0,0,0,3,0,0,0,3,0,0,
- 0,115,16,0,0,0,116,0,116,1,124,0,131,2,160,2,
- 124,1,161,1,83,0,41,1,122,100,76,111,97,100,32,97,
- 32,109,111,100,117,108,101,32,102,114,111,109,32,97,32,102,
- 105,108,101,46,10,10,32,32,32,32,32,32,32,32,84,104,
- 105,115,32,109,101,116,104,111,100,32,105,115,32,100,101,112,
- 114,101,99,97,116,101,100,46,32,32,85,115,101,32,101,120,
- 101,99,95,109,111,100,117,108,101,40,41,32,105,110,115,116,
- 101,97,100,46,10,10,32,32,32,32,32,32,32,32,41,3,
- 218,5,115,117,112,101,114,114,239,0,0,0,114,220,0,0,
- 0,114,219,0,0,0,169,1,114,241,0,0,0,114,5,0,
- 0,0,114,8,0,0,0,114,220,0,0,0,192,3,0,0,
- 115,2,0,0,0,0,10,122,22,70,105,108,101,76,111,97,
- 100,101,114,46,108,111,97,100,95,109,111,100,117,108,101,99,
- 2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,
- 1,0,0,0,67,0,0,0,115,6,0,0,0,124,0,106,
- 0,83,0,169,1,122,58,82,101,116,117,114,110,32,116,104,
- 101,32,112,97,116,104,32,116,111,32,116,104,101,32,115,111,
- 117,114,99,101,32,102,105,108,101,32,97,115,32,102,111,117,
- 110,100,32,98,121,32,116,104,101,32,102,105,110,100,101,114,
- 46,114,48,0,0,0,114,219,0,0,0,114,5,0,0,0,
- 114,5,0,0,0,114,8,0,0,0,114,179,0,0,0,204,
- 3,0,0,115,2,0,0,0,0,3,122,23,70,105,108,101,
- 76,111,97,100,101,114,46,103,101,116,95,102,105,108,101,110,
- 97,109,101,99,2,0,0,0,0,0,0,0,0,0,0,0,
- 3,0,0,0,8,0,0,0,67,0,0,0,115,126,0,0,
- 0,116,0,124,0,116,1,116,2,102,2,131,2,114,70,116,
- 3,160,4,116,5,124,1,131,1,161,1,143,24,125,2,124,
- 2,160,6,161,0,87,0,2,0,100,1,4,0,4,0,131,
- 3,1,0,83,0,49,0,115,58,48,0,1,0,1,0,1,
- 0,89,0,1,0,110,52,116,3,160,7,124,1,100,2,161,
- 2,143,24,125,2,124,2,160,6,161,0,87,0,2,0,100,
- 1,4,0,4,0,131,3,1,0,83,0,49,0,115,112,48,
- 0,1,0,1,0,1,0,89,0,1,0,100,1,83,0,41,
- 3,122,39,82,101,116,117,114,110,32,116,104,101,32,100,97,
- 116,97,32,102,114,111,109,32,112,97,116,104,32,97,115,32,
- 114,97,119,32,98,121,116,101,115,46,78,218,1,114,41,8,
- 114,161,0,0,0,114,221,0,0,0,218,19,69,120,116,101,
- 110,115,105,111,110,70,105,108,101,76,111,97,100,101,114,114,
- 64,0,0,0,90,9,111,112,101,110,95,99,111,100,101,114,
- 84,0,0,0,90,4,114,101,97,100,114,65,0,0,0,41,
- 3,114,118,0,0,0,114,44,0,0,0,114,68,0,0,0,
- 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,
- 227,0,0,0,209,3,0,0,115,10,0,0,0,0,2,14,
- 1,16,1,40,2,14,1,122,19,70,105,108,101,76,111,97,
- 100,101,114,46,103,101,116,95,100,97,116,97,99,2,0,0,
+ 101,116,95,115,111,117,114,99,101,46,122,39,115,111,117,114,
+ 99,101,32,110,111,116,32,97,118,97,105,108,97,98,108,101,
+ 32,116,104,114,111,117,103,104,32,103,101,116,95,100,97,116,
+ 97,40,41,114,120,0,0,0,78,41,5,114,183,0,0,0,
+ 218,8,103,101,116,95,100,97,116,97,114,58,0,0,0,114,
+ 122,0,0,0,114,180,0,0,0,41,5,114,123,0,0,0,
+ 114,143,0,0,0,114,52,0,0,0,114,178,0,0,0,218,
+ 3,101,120,99,114,7,0,0,0,114,7,0,0,0,114,8,
+ 0,0,0,218,10,103,101,116,95,115,111,117,114,99,101,114,
+ 3,0,0,115,26,0,0,0,10,2,2,1,12,1,8,4,
+ 14,253,4,1,2,1,4,255,2,1,2,255,8,128,2,255,
+ 255,128,122,23,83,111,117,114,99,101,76,111,97,100,101,114,
+ 46,103,101,116,95,115,111,117,114,99,101,114,109,0,0,0,
+ 41,1,218,9,95,111,112,116,105,109,105,122,101,99,3,0,
+ 0,0,0,0,0,0,1,0,0,0,4,0,0,0,8,0,
+ 0,0,67,0,0,0,115,22,0,0,0,116,0,106,1,116,
+ 2,124,1,124,2,100,1,100,2,124,3,100,3,141,6,83,
+ 0,41,5,122,130,82,101,116,117,114,110,32,116,104,101,32,
+ 99,111,100,101,32,111,98,106,101,99,116,32,99,111,109,112,
+ 105,108,101,100,32,102,114,111,109,32,115,111,117,114,99,101,
+ 46,10,10,32,32,32,32,32,32,32,32,84,104,101,32,39,
+ 100,97,116,97,39,32,97,114,103,117,109,101,110,116,32,99,
+ 97,110,32,98,101,32,97,110,121,32,111,98,106,101,99,116,
+ 32,116,121,112,101,32,116,104,97,116,32,99,111,109,112,105,
+ 108,101,40,41,32,115,117,112,112,111,114,116,115,46,10,32,
+ 32,32,32,32,32,32,32,114,222,0,0,0,84,41,2,218,
+ 12,100,111,110,116,95,105,110,104,101,114,105,116,114,89,0,
+ 0,0,78,41,3,114,139,0,0,0,114,221,0,0,0,218,
+ 7,99,111,109,112,105,108,101,41,4,114,123,0,0,0,114,
+ 37,0,0,0,114,52,0,0,0,114,237,0,0,0,114,7,
+ 0,0,0,114,7,0,0,0,114,8,0,0,0,218,14,115,
+ 111,117,114,99,101,95,116,111,95,99,111,100,101,124,3,0,
+ 0,115,8,0,0,0,12,5,4,1,6,255,255,128,122,27,
+ 83,111,117,114,99,101,76,111,97,100,101,114,46,115,111,117,
+ 114,99,101,95,116,111,95,99,111,100,101,99,2,0,0,0,
+ 0,0,0,0,0,0,0,0,15,0,0,0,9,0,0,0,
+ 67,0,0,0,115,34,2,0,0,124,0,160,0,124,1,161,
+ 1,125,2,100,1,125,3,100,1,125,4,100,1,125,5,100,
+ 2,125,6,100,3,125,7,122,12,116,1,124,2,131,1,125,
+ 8,87,0,110,24,4,0,116,2,144,2,121,32,1,0,1,
+ 0,1,0,100,1,125,8,89,0,144,1,110,38,122,14,124,
+ 0,160,3,124,2,161,1,125,9,87,0,110,20,4,0,116,
+ 4,144,2,121,30,1,0,1,0,1,0,89,0,144,1,110,
+ 2,116,5,124,9,100,4,25,0,131,1,125,3,122,14,124,
+ 0,160,6,124,8,161,1,125,10,87,0,110,18,4,0,116,
+ 4,144,2,121,28,1,0,1,0,1,0,89,0,110,212,124,
+ 1,124,8,100,5,156,2,125,11,122,148,116,7,124,10,124,
+ 1,124,11,131,3,125,12,116,8,124,10,131,1,100,6,100,
+ 1,133,2,25,0,125,13,124,12,100,7,64,0,100,8,107,
+ 3,125,6,124,6,144,1,114,30,124,12,100,9,64,0,100,
+ 8,107,3,125,7,116,9,106,10,100,10,107,3,144,1,114,
+ 28,124,7,115,248,116,9,106,10,100,11,107,2,144,1,114,
+ 28,124,0,160,6,124,2,161,1,125,4,116,9,160,11,116,
+ 12,124,4,161,2,125,5,116,13,124,10,124,5,124,1,124,
+ 11,131,4,1,0,110,20,116,14,124,10,124,3,124,9,100,
+ 12,25,0,124,1,124,11,131,5,1,0,87,0,110,22,4,
+ 0,116,15,116,16,102,2,144,2,121,26,1,0,1,0,1,
+ 0,89,0,110,30,116,17,160,18,100,13,124,8,124,2,161,
+ 3,1,0,116,19,124,13,124,1,124,8,124,2,100,14,141,
+ 4,83,0,124,4,100,1,117,0,144,1,114,126,124,0,160,
+ 6,124,2,161,1,125,4,124,0,160,20,124,4,124,2,161,
+ 2,125,14,116,17,160,18,100,15,124,2,161,2,1,0,116,
+ 21,106,22,144,2,115,20,124,8,100,1,117,1,144,2,114,
+ 20,124,3,100,1,117,1,144,2,114,20,124,6,144,1,114,
+ 218,124,5,100,1,117,0,144,1,114,204,116,9,160,11,124,
+ 4,161,1,125,5,116,23,124,14,124,5,124,7,131,3,125,
+ 10,110,16,116,24,124,14,124,3,116,25,124,4,131,1,131,
+ 3,125,10,122,20,124,0,160,26,124,2,124,8,124,10,161,
+ 3,1,0,87,0,124,14,83,0,4,0,116,2,144,2,121,
+ 24,1,0,1,0,1,0,89,0,124,14,83,0,124,14,83,
+ 0,119,0,119,0,119,0,119,0,119,0,41,16,122,190,67,
+ 111,110,99,114,101,116,101,32,105,109,112,108,101,109,101,110,
+ 116,97,116,105,111,110,32,111,102,32,73,110,115,112,101,99,
+ 116,76,111,97,100,101,114,46,103,101,116,95,99,111,100,101,
+ 46,10,10,32,32,32,32,32,32,32,32,82,101,97,100,105,
+ 110,103,32,111,102,32,98,121,116,101,99,111,100,101,32,114,
+ 101,113,117,105,114,101,115,32,112,97,116,104,95,115,116,97,
+ 116,115,32,116,111,32,98,101,32,105,109,112,108,101,109,101,
+ 110,116,101,100,46,32,84,111,32,119,114,105,116,101,10,32,
+ 32,32,32,32,32,32,32,98,121,116,101,99,111,100,101,44,
+ 32,115,101,116,95,100,97,116,97,32,109,117,115,116,32,97,
+ 108,115,111,32,98,101,32,105,109,112,108,101,109,101,110,116,
+ 101,100,46,10,10,32,32,32,32,32,32,32,32,78,70,84,
+ 114,173,0,0,0,114,163,0,0,0,114,149,0,0,0,114,
+ 3,0,0,0,114,0,0,0,0,114,39,0,0,0,90,5,
+ 110,101,118,101,114,90,6,97,108,119,97,121,115,218,4,115,
+ 105,122,101,122,13,123,125,32,109,97,116,99,104,101,115,32,
+ 123,125,41,3,114,121,0,0,0,114,111,0,0,0,114,112,
+ 0,0,0,122,19,99,111,100,101,32,111,98,106,101,99,116,
+ 32,102,114,111,109,32,123,125,41,27,114,183,0,0,0,114,
+ 102,0,0,0,114,88,0,0,0,114,231,0,0,0,114,58,
+ 0,0,0,114,30,0,0,0,114,234,0,0,0,114,156,0,
+ 0,0,218,10,109,101,109,111,114,121,118,105,101,119,114,167,
+ 0,0,0,90,21,99,104,101,99,107,95,104,97,115,104,95,
+ 98,97,115,101,100,95,112,121,99,115,114,161,0,0,0,218,
+ 17,95,82,65,87,95,77,65,71,73,67,95,78,85,77,66,
+ 69,82,114,162,0,0,0,114,160,0,0,0,114,122,0,0,
+ 0,114,154,0,0,0,114,139,0,0,0,114,153,0,0,0,
+ 114,169,0,0,0,114,240,0,0,0,114,15,0,0,0,218,
+ 19,100,111,110,116,95,119,114,105,116,101,95,98,121,116,101,
+ 99,111,100,101,114,175,0,0,0,114,174,0,0,0,114,4,
+ 0,0,0,114,233,0,0,0,41,15,114,123,0,0,0,114,
+ 143,0,0,0,114,112,0,0,0,114,158,0,0,0,114,178,
+ 0,0,0,114,161,0,0,0,90,10,104,97,115,104,95,98,
+ 97,115,101,100,90,12,99,104,101,99,107,95,115,111,117,114,
+ 99,101,114,111,0,0,0,218,2,115,116,114,37,0,0,0,
+ 114,155,0,0,0,114,16,0,0,0,90,10,98,121,116,101,
+ 115,95,100,97,116,97,90,11,99,111,100,101,95,111,98,106,
+ 101,99,116,114,7,0,0,0,114,7,0,0,0,114,8,0,
+ 0,0,114,220,0,0,0,132,3,0,0,115,166,0,0,0,
+ 10,7,4,1,4,1,4,1,4,1,4,1,2,1,12,1,
+ 14,1,10,1,2,2,14,1,14,1,6,1,12,2,2,1,
+ 14,1,14,1,4,1,2,3,2,1,6,254,2,4,12,1,
+ 16,1,12,1,6,1,12,1,12,1,2,1,2,255,8,2,
+ 4,254,10,3,4,1,2,1,2,1,4,254,8,4,2,1,
+ 6,255,2,3,2,1,2,1,6,1,2,1,2,1,8,251,
+ 18,7,4,1,8,2,2,1,4,255,6,2,2,1,2,1,
+ 6,254,10,3,10,1,12,1,12,1,18,1,6,1,4,255,
+ 6,2,10,1,10,1,14,1,6,2,6,1,4,255,2,2,
+ 16,1,4,3,14,254,2,1,8,1,2,254,2,233,2,225,
+ 2,250,2,251,255,128,122,21,83,111,117,114,99,101,76,111,
+ 97,100,101,114,46,103,101,116,95,99,111,100,101,78,41,10,
+ 114,130,0,0,0,114,129,0,0,0,114,131,0,0,0,114,
+ 230,0,0,0,114,231,0,0,0,114,233,0,0,0,114,232,
+ 0,0,0,114,236,0,0,0,114,240,0,0,0,114,220,0,
+ 0,0,114,7,0,0,0,114,7,0,0,0,114,7,0,0,
+ 0,114,8,0,0,0,114,228,0,0,0,73,3,0,0,115,
+ 18,0,0,0,8,0,8,2,8,8,8,14,8,10,8,7,
+ 14,10,12,8,255,128,114,228,0,0,0,99,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,
+ 0,0,0,0,115,92,0,0,0,101,0,90,1,100,0,90,
+ 2,100,1,90,3,100,2,100,3,132,0,90,4,100,4,100,
+ 5,132,0,90,5,100,6,100,7,132,0,90,6,101,7,135,
+ 0,102,1,100,8,100,9,132,8,131,1,90,8,101,7,100,
+ 10,100,11,132,0,131,1,90,9,100,12,100,13,132,0,90,
+ 10,101,7,100,14,100,15,132,0,131,1,90,11,135,0,4,
+ 0,90,12,83,0,41,16,218,10,70,105,108,101,76,111,97,
+ 100,101,114,122,103,66,97,115,101,32,102,105,108,101,32,108,
+ 111,97,100,101,114,32,99,108,97,115,115,32,119,104,105,99,
+ 104,32,105,109,112,108,101,109,101,110,116,115,32,116,104,101,
+ 32,108,111,97,100,101,114,32,112,114,111,116,111,99,111,108,
+ 32,109,101,116,104,111,100,115,32,116,104,97,116,10,32,32,
+ 32,32,114,101,113,117,105,114,101,32,102,105,108,101,32,115,
+ 121,115,116,101,109,32,117,115,97,103,101,46,99,3,0,0,
0,0,0,0,0,0,0,0,0,3,0,0,0,2,0,0,
- 0,67,0,0,0,115,20,0,0,0,100,1,100,2,108,0,
- 109,1,125,2,1,0,124,2,124,0,131,1,83,0,41,3,
- 78,114,73,0,0,0,41,1,218,10,70,105,108,101,82,101,
- 97,100,101,114,41,2,90,17,105,109,112,111,114,116,108,105,
- 98,46,114,101,97,100,101,114,115,114,253,0,0,0,41,3,
- 114,118,0,0,0,114,216,0,0,0,114,253,0,0,0,114,
- 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,19,
- 103,101,116,95,114,101,115,111,117,114,99,101,95,114,101,97,
- 100,101,114,218,3,0,0,115,4,0,0,0,0,2,12,1,
- 122,30,70,105,108,101,76,111,97,100,101,114,46,103,101,116,
+ 0,67,0,0,0,115,16,0,0,0,124,1,124,0,95,0,
+ 124,2,124,0,95,1,100,1,83,0,41,2,122,75,67,97,
+ 99,104,101,32,116,104,101,32,109,111,100,117,108,101,32,110,
+ 97,109,101,32,97,110,100,32,116,104,101,32,112,97,116,104,
+ 32,116,111,32,116,104,101,32,102,105,108,101,32,102,111,117,
+ 110,100,32,98,121,32,116,104,101,10,32,32,32,32,32,32,
+ 32,32,102,105,110,100,101,114,46,78,114,163,0,0,0,41,
+ 3,114,123,0,0,0,114,143,0,0,0,114,52,0,0,0,
+ 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,114,
+ 216,0,0,0,222,3,0,0,115,6,0,0,0,6,3,10,
+ 1,255,128,122,19,70,105,108,101,76,111,97,100,101,114,46,
+ 95,95,105,110,105,116,95,95,99,2,0,0,0,0,0,0,
+ 0,0,0,0,0,2,0,0,0,2,0,0,0,67,0,0,
+ 0,115,24,0,0,0,124,0,106,0,124,1,106,0,107,2,
+ 111,22,124,0,106,1,124,1,106,1,107,2,83,0,114,114,
+ 0,0,0,169,2,218,9,95,95,99,108,97,115,115,95,95,
+ 114,136,0,0,0,169,2,114,123,0,0,0,90,5,111,116,
+ 104,101,114,114,7,0,0,0,114,7,0,0,0,114,8,0,
+ 0,0,218,6,95,95,101,113,95,95,228,3,0,0,115,8,
+ 0,0,0,12,1,10,1,2,255,255,128,122,17,70,105,108,
+ 101,76,111,97,100,101,114,46,95,95,101,113,95,95,99,1,
+ 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,3,
+ 0,0,0,67,0,0,0,115,20,0,0,0,116,0,124,0,
+ 106,1,131,1,116,0,124,0,106,2,131,1,65,0,83,0,
+ 114,114,0,0,0,169,3,218,4,104,97,115,104,114,121,0,
+ 0,0,114,52,0,0,0,169,1,114,123,0,0,0,114,7,
+ 0,0,0,114,7,0,0,0,114,8,0,0,0,218,8,95,
+ 95,104,97,115,104,95,95,232,3,0,0,115,4,0,0,0,
+ 20,1,255,128,122,19,70,105,108,101,76,111,97,100,101,114,
+ 46,95,95,104,97,115,104,95,95,99,2,0,0,0,0,0,
+ 0,0,0,0,0,0,2,0,0,0,3,0,0,0,3,0,
+ 0,0,115,16,0,0,0,116,0,116,1,124,0,131,2,160,
+ 2,124,1,161,1,83,0,41,2,122,100,76,111,97,100,32,
+ 97,32,109,111,100,117,108,101,32,102,114,111,109,32,97,32,
+ 102,105,108,101,46,10,10,32,32,32,32,32,32,32,32,84,
+ 104,105,115,32,109,101,116,104,111,100,32,105,115,32,100,101,
+ 112,114,101,99,97,116,101,100,46,32,32,85,115,101,32,101,
+ 120,101,99,95,109,111,100,117,108,101,40,41,32,105,110,115,
+ 116,101,97,100,46,10,10,32,32,32,32,32,32,32,32,78,
+ 41,3,218,5,115,117,112,101,114,114,246,0,0,0,114,227,
+ 0,0,0,114,226,0,0,0,169,1,114,248,0,0,0,114,
+ 7,0,0,0,114,8,0,0,0,114,227,0,0,0,235,3,
+ 0,0,115,4,0,0,0,16,10,255,128,122,22,70,105,108,
+ 101,76,111,97,100,101,114,46,108,111,97,100,95,109,111,100,
+ 117,108,101,99,2,0,0,0,0,0,0,0,0,0,0,0,
+ 2,0,0,0,1,0,0,0,67,0,0,0,115,6,0,0,
+ 0,124,0,106,0,83,0,169,2,122,58,82,101,116,117,114,
+ 110,32,116,104,101,32,112,97,116,104,32,116,111,32,116,104,
+ 101,32,115,111,117,114,99,101,32,102,105,108,101,32,97,115,
+ 32,102,111,117,110,100,32,98,121,32,116,104,101,32,102,105,
+ 110,100,101,114,46,78,114,56,0,0,0,114,226,0,0,0,
+ 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,114,
+ 183,0,0,0,247,3,0,0,115,4,0,0,0,6,3,255,
+ 128,122,23,70,105,108,101,76,111,97,100,101,114,46,103,101,
+ 116,95,102,105,108,101,110,97,109,101,99,2,0,0,0,0,
+ 0,0,0,0,0,0,0,3,0,0,0,8,0,0,0,67,
+ 0,0,0,115,128,0,0,0,116,0,124,0,116,1,116,2,
+ 102,2,131,2,114,72,116,3,160,4,116,5,124,1,131,1,
+ 161,1,143,24,125,2,124,2,160,6,161,0,87,0,2,0,
+ 100,1,4,0,4,0,131,3,1,0,83,0,49,0,115,58,
+ 119,1,1,0,1,0,1,0,89,0,1,0,100,1,83,0,
+ 116,3,160,7,124,1,100,2,161,2,143,24,125,2,124,2,
+ 160,6,161,0,87,0,2,0,100,1,4,0,4,0,131,3,
+ 1,0,83,0,49,0,115,114,119,1,1,0,1,0,1,0,
+ 89,0,1,0,100,1,83,0,41,3,122,39,82,101,116,117,
+ 114,110,32,116,104,101,32,100,97,116,97,32,102,114,111,109,
+ 32,112,97,116,104,32,97,115,32,114,97,119,32,98,121,116,
+ 101,115,46,78,218,1,114,41,8,114,165,0,0,0,114,228,
+ 0,0,0,218,19,69,120,116,101,110,115,105,111,110,70,105,
+ 108,101,76,111,97,100,101,114,114,72,0,0,0,90,9,111,
+ 112,101,110,95,99,111,100,101,114,90,0,0,0,90,4,114,
+ 101,97,100,114,73,0,0,0,41,3,114,123,0,0,0,114,
+ 52,0,0,0,114,76,0,0,0,114,7,0,0,0,114,7,
+ 0,0,0,114,8,0,0,0,114,234,0,0,0,252,3,0,
+ 0,115,14,0,0,0,14,2,16,1,42,1,14,2,38,1,
+ 4,128,255,128,122,19,70,105,108,101,76,111,97,100,101,114,
+ 46,103,101,116,95,100,97,116,97,99,2,0,0,0,0,0,
+ 0,0,0,0,0,0,3,0,0,0,2,0,0,0,67,0,
+ 0,0,115,20,0,0,0,100,1,100,2,108,0,109,1,125,
+ 2,1,0,124,2,124,0,131,1,83,0,41,3,78,114,0,
+ 0,0,0,41,1,218,10,70,105,108,101,82,101,97,100,101,
+ 114,41,2,90,17,105,109,112,111,114,116,108,105,98,46,114,
+ 101,97,100,101,114,115,114,4,1,0,0,41,3,114,123,0,
+ 0,0,114,223,0,0,0,114,4,1,0,0,114,7,0,0,
+ 0,114,7,0,0,0,114,8,0,0,0,218,19,103,101,116,
95,114,101,115,111,117,114,99,101,95,114,101,97,100,101,114,
- 41,13,114,125,0,0,0,114,124,0,0,0,114,126,0,0,
- 0,114,127,0,0,0,114,209,0,0,0,114,243,0,0,0,
- 114,247,0,0,0,114,136,0,0,0,114,220,0,0,0,114,
- 179,0,0,0,114,227,0,0,0,114,254,0,0,0,90,13,
- 95,95,99,108,97,115,115,99,101,108,108,95,95,114,5,0,
- 0,0,114,5,0,0,0,114,249,0,0,0,114,8,0,0,
- 0,114,239,0,0,0,174,3,0,0,115,22,0,0,0,8,
- 2,4,3,8,6,8,4,8,3,2,1,14,11,2,1,10,
- 4,8,9,2,1,114,239,0,0,0,99,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,64,
- 0,0,0,115,46,0,0,0,101,0,90,1,100,0,90,2,
- 100,1,90,3,100,2,100,3,132,0,90,4,100,4,100,5,
- 132,0,90,5,100,6,100,7,156,1,100,8,100,9,132,2,
- 90,6,100,10,83,0,41,11,218,16,83,111,117,114,99,101,
- 70,105,108,101,76,111,97,100,101,114,122,62,67,111,110,99,
- 114,101,116,101,32,105,109,112,108,101,109,101,110,116,97,116,
- 105,111,110,32,111,102,32,83,111,117,114,99,101,76,111,97,
- 100,101,114,32,117,115,105,110,103,32,116,104,101,32,102,105,
- 108,101,32,115,121,115,116,101,109,46,99,2,0,0,0,0,
- 0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,67,
- 0,0,0,115,22,0,0,0,116,0,124,1,131,1,125,2,
- 124,2,106,1,124,2,106,2,100,1,156,2,83,0,41,2,
- 122,33,82,101,116,117,114,110,32,116,104,101,32,109,101,116,
- 97,100,97,116,97,32,102,111,114,32,116,104,101,32,112,97,
- 116,104,46,41,2,114,169,0,0,0,114,234,0,0,0,41,
- 3,114,49,0,0,0,218,8,115,116,95,109,116,105,109,101,
- 90,7,115,116,95,115,105,122,101,41,3,114,118,0,0,0,
- 114,44,0,0,0,114,238,0,0,0,114,5,0,0,0,114,
- 5,0,0,0,114,8,0,0,0,114,224,0,0,0,228,3,
- 0,0,115,4,0,0,0,0,2,8,1,122,27,83,111,117,
- 114,99,101,70,105,108,101,76,111,97,100,101,114,46,112,97,
- 116,104,95,115,116,97,116,115,99,4,0,0,0,0,0,0,
- 0,0,0,0,0,5,0,0,0,5,0,0,0,67,0,0,
- 0,115,24,0,0,0,116,0,124,1,131,1,125,4,124,0,
- 106,1,124,2,124,3,124,4,100,1,141,3,83,0,41,2,
- 78,169,1,218,5,95,109,111,100,101,41,2,114,114,0,0,
- 0,114,225,0,0,0,41,5,114,118,0,0,0,114,107,0,
- 0,0,114,106,0,0,0,114,26,0,0,0,114,52,0,0,
- 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,
- 114,226,0,0,0,233,3,0,0,115,4,0,0,0,0,2,
- 8,1,122,32,83,111,117,114,99,101,70,105,108,101,76,111,
- 97,100,101,114,46,95,99,97,99,104,101,95,98,121,116,101,
- 99,111,100,101,114,60,0,0,0,114,1,1,0,0,99,3,
- 0,0,0,0,0,0,0,1,0,0,0,9,0,0,0,11,
- 0,0,0,67,0,0,0,115,248,0,0,0,116,0,124,1,
- 131,1,92,2,125,4,125,5,103,0,125,6,124,4,114,52,
- 116,1,124,4,131,1,115,52,116,0,124,4,131,1,92,2,
- 125,4,125,7,124,6,160,2,124,7,161,1,1,0,113,16,
- 116,3,124,6,131,1,68,0,93,102,125,7,116,4,124,4,
- 124,7,131,2,125,4,122,14,116,5,160,6,124,4,161,1,
- 1,0,87,0,113,60,4,0,116,7,121,110,1,0,1,0,
- 1,0,89,0,113,60,89,0,113,60,4,0,116,8,121,162,
+ 5,4,0,0,115,6,0,0,0,12,2,8,1,255,128,122,
+ 30,70,105,108,101,76,111,97,100,101,114,46,103,101,116,95,
+ 114,101,115,111,117,114,99,101,95,114,101,97,100,101,114,41,
+ 13,114,130,0,0,0,114,129,0,0,0,114,131,0,0,0,
+ 114,132,0,0,0,114,216,0,0,0,114,250,0,0,0,114,
+ 254,0,0,0,114,140,0,0,0,114,227,0,0,0,114,183,
+ 0,0,0,114,234,0,0,0,114,5,1,0,0,90,13,95,
+ 95,99,108,97,115,115,99,101,108,108,95,95,114,7,0,0,
+ 0,114,7,0,0,0,114,0,1,0,0,114,8,0,0,0,
+ 114,246,0,0,0,217,3,0,0,115,26,0,0,0,8,0,
+ 4,2,8,3,8,6,8,4,2,3,14,1,2,11,10,1,
+ 8,4,2,9,18,1,255,128,114,246,0,0,0,99,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,
+ 0,0,64,0,0,0,115,46,0,0,0,101,0,90,1,100,
+ 0,90,2,100,1,90,3,100,2,100,3,132,0,90,4,100,
+ 4,100,5,132,0,90,5,100,6,100,7,156,1,100,8,100,
+ 9,132,2,90,6,100,10,83,0,41,11,218,16,83,111,117,
+ 114,99,101,70,105,108,101,76,111,97,100,101,114,122,62,67,
+ 111,110,99,114,101,116,101,32,105,109,112,108,101,109,101,110,
+ 116,97,116,105,111,110,32,111,102,32,83,111,117,114,99,101,
+ 76,111,97,100,101,114,32,117,115,105,110,103,32,116,104,101,
+ 32,102,105,108,101,32,115,121,115,116,101,109,46,99,2,0,
+ 0,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0,
+ 0,0,67,0,0,0,115,22,0,0,0,116,0,124,1,131,
+ 1,125,2,124,2,106,1,124,2,106,2,100,1,156,2,83,
+ 0,41,3,122,33,82,101,116,117,114,110,32,116,104,101,32,
+ 109,101,116,97,100,97,116,97,32,102,111,114,32,116,104,101,
+ 32,112,97,116,104,46,41,2,114,173,0,0,0,114,241,0,
+ 0,0,78,41,3,114,57,0,0,0,218,8,115,116,95,109,
+ 116,105,109,101,90,7,115,116,95,115,105,122,101,41,3,114,
+ 123,0,0,0,114,52,0,0,0,114,245,0,0,0,114,7,
+ 0,0,0,114,7,0,0,0,114,8,0,0,0,114,231,0,
+ 0,0,15,4,0,0,115,6,0,0,0,8,2,14,1,255,
+ 128,122,27,83,111,117,114,99,101,70,105,108,101,76,111,97,
+ 100,101,114,46,112,97,116,104,95,115,116,97,116,115,99,4,
+ 0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,5,
+ 0,0,0,67,0,0,0,115,24,0,0,0,116,0,124,1,
+ 131,1,125,4,124,0,106,1,124,2,124,3,124,4,100,1,
+ 141,3,83,0,41,2,78,169,1,218,5,95,109,111,100,101,
+ 41,2,114,119,0,0,0,114,232,0,0,0,41,5,114,123,
+ 0,0,0,114,112,0,0,0,114,111,0,0,0,114,37,0,
+ 0,0,114,60,0,0,0,114,7,0,0,0,114,7,0,0,
+ 0,114,8,0,0,0,114,233,0,0,0,20,4,0,0,115,
+ 6,0,0,0,8,2,16,1,255,128,122,32,83,111,117,114,
+ 99,101,70,105,108,101,76,111,97,100,101,114,46,95,99,97,
+ 99,104,101,95,98,121,116,101,99,111,100,101,114,68,0,0,
+ 0,114,8,1,0,0,99,3,0,0,0,0,0,0,0,1,
+ 0,0,0,9,0,0,0,11,0,0,0,67,0,0,0,115,
+ 4,1,0,0,116,0,124,1,131,1,92,2,125,4,125,5,
+ 103,0,125,6,124,4,114,62,116,1,124,4,131,1,115,62,
+ 116,0,124,4,131,1,92,2,125,4,125,7,124,6,160,2,
+ 124,7,161,1,1,0,124,4,114,62,116,1,124,4,131,1,
+ 114,28,116,3,124,6,131,1,68,0,93,98,125,7,116,4,
+ 124,4,124,7,131,2,125,4,122,14,116,5,160,6,124,4,
+ 161,1,1,0,87,0,113,70,4,0,116,7,121,116,1,0,
+ 1,0,1,0,89,0,113,70,4,0,116,8,144,1,121,2,
1,0,125,8,1,0,122,30,116,9,160,10,100,1,124,4,
124,8,161,3,1,0,87,0,89,0,100,2,125,8,126,8,
- 1,0,100,2,83,0,100,2,125,8,126,8,48,0,48,0,
- 122,28,116,11,124,1,124,2,124,3,131,3,1,0,116,9,
- 160,10,100,3,124,1,161,2,1,0,87,0,110,50,4,0,
- 116,8,121,242,1,0,125,8,1,0,122,26,116,9,160,10,
+ 1,0,100,2,83,0,100,2,125,8,126,8,119,1,122,30,
+ 116,11,124,1,124,2,124,3,131,3,1,0,116,9,160,10,
+ 100,3,124,1,161,2,1,0,87,0,100,2,83,0,4,0,
+ 116,8,121,252,1,0,125,8,1,0,122,28,116,9,160,10,
100,1,124,1,124,8,161,3,1,0,87,0,89,0,100,2,
- 125,8,126,8,110,10,100,2,125,8,126,8,48,0,48,0,
- 100,2,83,0,41,4,122,27,87,114,105,116,101,32,98,121,
- 116,101,115,32,100,97,116,97,32,116,111,32,97,32,102,105,
- 108,101,46,122,27,99,111,117,108,100,32,110,111,116,32,99,
- 114,101,97,116,101,32,123,33,114,125,58,32,123,33,114,125,
- 78,122,12,99,114,101,97,116,101,100,32,123,33,114,125,41,
- 12,114,47,0,0,0,114,56,0,0,0,114,186,0,0,0,
- 114,42,0,0,0,114,38,0,0,0,114,4,0,0,0,90,
- 5,109,107,100,105,114,218,15,70,105,108,101,69,120,105,115,
- 116,115,69,114,114,111,114,114,50,0,0,0,114,134,0,0,
- 0,114,149,0,0,0,114,69,0,0,0,41,9,114,118,0,
- 0,0,114,44,0,0,0,114,26,0,0,0,114,2,1,0,
- 0,218,6,112,97,114,101,110,116,114,96,0,0,0,114,37,
- 0,0,0,114,33,0,0,0,114,228,0,0,0,114,5,0,
- 0,0,114,5,0,0,0,114,8,0,0,0,114,225,0,0,
- 0,238,3,0,0,115,46,0,0,0,0,2,12,1,4,2,
- 12,1,12,1,12,2,12,1,10,1,2,1,14,1,12,2,
- 8,1,14,3,6,1,4,255,4,2,26,1,2,1,12,1,
- 16,1,14,2,8,1,2,255,122,25,83,111,117,114,99,101,
- 70,105,108,101,76,111,97,100,101,114,46,115,101,116,95,100,
- 97,116,97,78,41,7,114,125,0,0,0,114,124,0,0,0,
- 114,126,0,0,0,114,127,0,0,0,114,224,0,0,0,114,
- 226,0,0,0,114,225,0,0,0,114,5,0,0,0,114,5,
- 0,0,0,114,5,0,0,0,114,8,0,0,0,114,255,0,
- 0,0,224,3,0,0,115,8,0,0,0,8,2,4,2,8,
- 5,8,5,114,255,0,0,0,99,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,2,0,0,0,64,0,0,
- 0,115,32,0,0,0,101,0,90,1,100,0,90,2,100,1,
- 90,3,100,2,100,3,132,0,90,4,100,4,100,5,132,0,
- 90,5,100,6,83,0,41,7,218,20,83,111,117,114,99,101,
- 108,101,115,115,70,105,108,101,76,111,97,100,101,114,122,45,
- 76,111,97,100,101,114,32,119,104,105,99,104,32,104,97,110,
- 100,108,101,115,32,115,111,117,114,99,101,108,101,115,115,32,
- 102,105,108,101,32,105,109,112,111,114,116,115,46,99,2,0,
- 0,0,0,0,0,0,0,0,0,0,5,0,0,0,5,0,
- 0,0,67,0,0,0,115,68,0,0,0,124,0,160,0,124,
- 1,161,1,125,2,124,0,160,1,124,2,161,1,125,3,124,
- 1,124,2,100,1,156,2,125,4,116,2,124,3,124,1,124,
- 4,131,3,1,0,116,3,116,4,124,3,131,1,100,2,100,
- 0,133,2,25,0,124,1,124,2,100,3,141,3,83,0,41,
- 4,78,114,159,0,0,0,114,145,0,0,0,41,2,114,116,
- 0,0,0,114,106,0,0,0,41,5,114,179,0,0,0,114,
- 227,0,0,0,114,152,0,0,0,114,165,0,0,0,114,235,
- 0,0,0,41,5,114,118,0,0,0,114,139,0,0,0,114,
- 44,0,0,0,114,26,0,0,0,114,151,0,0,0,114,5,
- 0,0,0,114,5,0,0,0,114,8,0,0,0,114,213,0,
- 0,0,17,4,0,0,115,22,0,0,0,0,1,10,1,10,
- 4,2,1,2,254,6,4,12,1,2,1,14,1,2,1,2,
- 253,122,29,83,111,117,114,99,101,108,101,115,115,70,105,108,
- 101,76,111,97,100,101,114,46,103,101,116,95,99,111,100,101,
- 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
- 0,1,0,0,0,67,0,0,0,115,4,0,0,0,100,1,
- 83,0,41,2,122,39,82,101,116,117,114,110,32,78,111,110,
- 101,32,97,115,32,116,104,101,114,101,32,105,115,32,110,111,
- 32,115,111,117,114,99,101,32,99,111,100,101,46,78,114,5,
- 0,0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,
- 0,0,114,8,0,0,0,114,229,0,0,0,33,4,0,0,
- 115,2,0,0,0,0,2,122,31,83,111,117,114,99,101,108,
- 101,115,115,70,105,108,101,76,111,97,100,101,114,46,103,101,
- 116,95,115,111,117,114,99,101,78,41,6,114,125,0,0,0,
- 114,124,0,0,0,114,126,0,0,0,114,127,0,0,0,114,
- 213,0,0,0,114,229,0,0,0,114,5,0,0,0,114,5,
- 0,0,0,114,5,0,0,0,114,8,0,0,0,114,5,1,
- 0,0,13,4,0,0,115,6,0,0,0,8,2,4,2,8,
- 16,114,5,1,0,0,99,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,3,0,0,0,64,0,0,0,115,
- 92,0,0,0,101,0,90,1,100,0,90,2,100,1,90,3,
- 100,2,100,3,132,0,90,4,100,4,100,5,132,0,90,5,
- 100,6,100,7,132,0,90,6,100,8,100,9,132,0,90,7,
- 100,10,100,11,132,0,90,8,100,12,100,13,132,0,90,9,
- 100,14,100,15,132,0,90,10,100,16,100,17,132,0,90,11,
- 101,12,100,18,100,19,132,0,131,1,90,13,100,20,83,0,
- 41,21,114,252,0,0,0,122,93,76,111,97,100,101,114,32,
- 102,111,114,32,101,120,116,101,110,115,105,111,110,32,109,111,
- 100,117,108,101,115,46,10,10,32,32,32,32,84,104,101,32,
- 99,111,110,115,116,114,117,99,116,111,114,32,105,115,32,100,
- 101,115,105,103,110,101,100,32,116,111,32,119,111,114,107,32,
- 119,105,116,104,32,70,105,108,101,70,105,110,100,101,114,46,
- 10,10,32,32,32,32,99,3,0,0,0,0,0,0,0,0,
- 0,0,0,3,0,0,0,2,0,0,0,67,0,0,0,115,
- 16,0,0,0,124,1,124,0,95,0,124,2,124,0,95,1,
- 100,0,83,0,114,109,0,0,0,114,159,0,0,0,41,3,
- 114,118,0,0,0,114,116,0,0,0,114,44,0,0,0,114,
- 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,209,
- 0,0,0,50,4,0,0,115,4,0,0,0,0,1,6,1,
+ 125,8,126,8,100,2,83,0,100,2,125,8,126,8,119,1,
+ 119,0,100,2,83,0,119,0,41,4,122,27,87,114,105,116,
+ 101,32,98,121,116,101,115,32,100,97,116,97,32,116,111,32,
+ 97,32,102,105,108,101,46,122,27,99,111,117,108,100,32,110,
+ 111,116,32,99,114,101,97,116,101,32,123,33,114,125,58,32,
+ 123,33,114,125,78,122,12,99,114,101,97,116,101,100,32,123,
+ 33,114,125,41,12,114,55,0,0,0,114,64,0,0,0,114,
+ 190,0,0,0,114,50,0,0,0,114,48,0,0,0,114,18,
+ 0,0,0,90,5,109,107,100,105,114,218,15,70,105,108,101,
+ 69,120,105,115,116,115,69,114,114,111,114,114,58,0,0,0,
+ 114,139,0,0,0,114,153,0,0,0,114,77,0,0,0,41,
+ 9,114,123,0,0,0,114,52,0,0,0,114,37,0,0,0,
+ 114,9,1,0,0,218,6,112,97,114,101,110,116,114,101,0,
+ 0,0,114,47,0,0,0,114,43,0,0,0,114,235,0,0,
+ 0,114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,
+ 114,232,0,0,0,25,4,0,0,115,60,0,0,0,12,2,
+ 4,1,12,2,12,1,10,1,12,254,12,4,10,1,2,1,
+ 14,1,12,1,4,2,16,1,6,3,4,1,4,255,16,2,
+ 8,128,2,1,12,1,18,1,14,1,8,2,2,1,18,255,
+ 8,128,2,254,4,255,2,248,255,128,122,25,83,111,117,114,
+ 99,101,70,105,108,101,76,111,97,100,101,114,46,115,101,116,
+ 95,100,97,116,97,78,41,7,114,130,0,0,0,114,129,0,
+ 0,0,114,131,0,0,0,114,132,0,0,0,114,231,0,0,
+ 0,114,233,0,0,0,114,232,0,0,0,114,7,0,0,0,
+ 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,114,
+ 6,1,0,0,11,4,0,0,115,12,0,0,0,8,0,4,
+ 2,8,2,8,5,18,5,255,128,114,6,1,0,0,99,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
+ 0,0,0,64,0,0,0,115,32,0,0,0,101,0,90,1,
+ 100,0,90,2,100,1,90,3,100,2,100,3,132,0,90,4,
+ 100,4,100,5,132,0,90,5,100,6,83,0,41,7,218,20,
+ 83,111,117,114,99,101,108,101,115,115,70,105,108,101,76,111,
+ 97,100,101,114,122,45,76,111,97,100,101,114,32,119,104,105,
+ 99,104,32,104,97,110,100,108,101,115,32,115,111,117,114,99,
+ 101,108,101,115,115,32,102,105,108,101,32,105,109,112,111,114,
+ 116,115,46,99,2,0,0,0,0,0,0,0,0,0,0,0,
+ 5,0,0,0,5,0,0,0,67,0,0,0,115,68,0,0,
+ 0,124,0,160,0,124,1,161,1,125,2,124,0,160,1,124,
+ 2,161,1,125,3,124,1,124,2,100,1,156,2,125,4,116,
+ 2,124,3,124,1,124,4,131,3,1,0,116,3,116,4,124,
+ 3,131,1,100,2,100,0,133,2,25,0,124,1,124,2,100,
+ 3,141,3,83,0,41,4,78,114,163,0,0,0,114,149,0,
+ 0,0,41,2,114,121,0,0,0,114,111,0,0,0,41,5,
+ 114,183,0,0,0,114,234,0,0,0,114,156,0,0,0,114,
+ 169,0,0,0,114,242,0,0,0,41,5,114,123,0,0,0,
+ 114,143,0,0,0,114,52,0,0,0,114,37,0,0,0,114,
+ 155,0,0,0,114,7,0,0,0,114,7,0,0,0,114,8,
+ 0,0,0,114,220,0,0,0,60,4,0,0,115,24,0,0,
+ 0,10,1,10,1,2,4,2,1,6,254,12,4,2,1,14,
+ 1,2,1,2,1,6,253,255,128,122,29,83,111,117,114,99,
+ 101,108,101,115,115,70,105,108,101,76,111,97,100,101,114,46,
+ 103,101,116,95,99,111,100,101,99,2,0,0,0,0,0,0,
+ 0,0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,
+ 0,115,4,0,0,0,100,1,83,0,41,2,122,39,82,101,
+ 116,117,114,110,32,78,111,110,101,32,97,115,32,116,104,101,
+ 114,101,32,105,115,32,110,111,32,115,111,117,114,99,101,32,
+ 99,111,100,101,46,78,114,7,0,0,0,114,226,0,0,0,
+ 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,114,
+ 236,0,0,0,76,4,0,0,115,4,0,0,0,4,2,255,
+ 128,122,31,83,111,117,114,99,101,108,101,115,115,70,105,108,
+ 101,76,111,97,100,101,114,46,103,101,116,95,115,111,117,114,
+ 99,101,78,41,6,114,130,0,0,0,114,129,0,0,0,114,
+ 131,0,0,0,114,132,0,0,0,114,220,0,0,0,114,236,
+ 0,0,0,114,7,0,0,0,114,7,0,0,0,114,7,0,
+ 0,0,114,8,0,0,0,114,12,1,0,0,56,4,0,0,
+ 115,10,0,0,0,8,0,4,2,8,2,12,16,255,128,114,
+ 12,1,0,0,99,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,3,0,0,0,64,0,0,0,115,92,0,
+ 0,0,101,0,90,1,100,0,90,2,100,1,90,3,100,2,
+ 100,3,132,0,90,4,100,4,100,5,132,0,90,5,100,6,
+ 100,7,132,0,90,6,100,8,100,9,132,0,90,7,100,10,
+ 100,11,132,0,90,8,100,12,100,13,132,0,90,9,100,14,
+ 100,15,132,0,90,10,100,16,100,17,132,0,90,11,101,12,
+ 100,18,100,19,132,0,131,1,90,13,100,20,83,0,41,21,
+ 114,3,1,0,0,122,93,76,111,97,100,101,114,32,102,111,
+ 114,32,101,120,116,101,110,115,105,111,110,32,109,111,100,117,
+ 108,101,115,46,10,10,32,32,32,32,84,104,101,32,99,111,
+ 110,115,116,114,117,99,116,111,114,32,105,115,32,100,101,115,
+ 105,103,110,101,100,32,116,111,32,119,111,114,107,32,119,105,
+ 116,104,32,70,105,108,101,70,105,110,100,101,114,46,10,10,
+ 32,32,32,32,99,3,0,0,0,0,0,0,0,0,0,0,
+ 0,3,0,0,0,2,0,0,0,67,0,0,0,115,16,0,
+ 0,0,124,1,124,0,95,0,124,2,124,0,95,1,100,0,
+ 83,0,114,114,0,0,0,114,163,0,0,0,41,3,114,123,
+ 0,0,0,114,121,0,0,0,114,52,0,0,0,114,7,0,
+ 0,0,114,7,0,0,0,114,8,0,0,0,114,216,0,0,
+ 0,89,4,0,0,115,6,0,0,0,6,1,10,1,255,128,
122,28,69,120,116,101,110,115,105,111,110,70,105,108,101,76,
111,97,100,101,114,46,95,95,105,110,105,116,95,95,99,2,
0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,2,
0,0,0,67,0,0,0,115,24,0,0,0,124,0,106,0,
124,1,106,0,107,2,111,22,124,0,106,1,124,1,106,1,
- 107,2,83,0,114,109,0,0,0,114,240,0,0,0,114,242,
- 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,
- 0,0,114,243,0,0,0,54,4,0,0,115,6,0,0,0,
- 0,1,12,1,10,255,122,26,69,120,116,101,110,115,105,111,
- 110,70,105,108,101,76,111,97,100,101,114,46,95,95,101,113,
- 95,95,99,1,0,0,0,0,0,0,0,0,0,0,0,1,
- 0,0,0,3,0,0,0,67,0,0,0,115,20,0,0,0,
- 116,0,124,0,106,1,131,1,116,0,124,0,106,2,131,1,
- 65,0,83,0,114,109,0,0,0,114,244,0,0,0,114,246,
- 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,
- 0,0,114,247,0,0,0,58,4,0,0,115,2,0,0,0,
- 0,1,122,28,69,120,116,101,110,115,105,111,110,70,105,108,
- 101,76,111,97,100,101,114,46,95,95,104,97,115,104,95,95,
- 99,2,0,0,0,0,0,0,0,0,0,0,0,3,0,0,
- 0,5,0,0,0,67,0,0,0,115,36,0,0,0,116,0,
- 160,1,116,2,106,3,124,1,161,2,125,2,116,0,160,4,
- 100,1,124,1,106,5,124,0,106,6,161,3,1,0,124,2,
- 83,0,41,2,122,38,67,114,101,97,116,101,32,97,110,32,
- 117,110,105,116,105,97,108,105,122,101,100,32,101,120,116,101,
- 110,115,105,111,110,32,109,111,100,117,108,101,122,38,101,120,
- 116,101,110,115,105,111,110,32,109,111,100,117,108,101,32,123,
- 33,114,125,32,108,111,97,100,101,100,32,102,114,111,109,32,
- 123,33,114,125,41,7,114,134,0,0,0,114,214,0,0,0,
- 114,163,0,0,0,90,14,99,114,101,97,116,101,95,100,121,
- 110,97,109,105,99,114,149,0,0,0,114,116,0,0,0,114,
- 44,0,0,0,41,3,114,118,0,0,0,114,187,0,0,0,
- 114,216,0,0,0,114,5,0,0,0,114,5,0,0,0,114,
- 8,0,0,0,114,212,0,0,0,61,4,0,0,115,14,0,
- 0,0,0,2,4,1,6,255,4,2,6,1,8,255,4,2,
- 122,33,69,120,116,101,110,115,105,111,110,70,105,108,101,76,
- 111,97,100,101,114,46,99,114,101,97,116,101,95,109,111,100,
- 117,108,101,99,2,0,0,0,0,0,0,0,0,0,0,0,
- 2,0,0,0,5,0,0,0,67,0,0,0,115,36,0,0,
- 0,116,0,160,1,116,2,106,3,124,1,161,2,1,0,116,
- 0,160,4,100,1,124,0,106,5,124,0,106,6,161,3,1,
- 0,100,2,83,0,41,3,122,30,73,110,105,116,105,97,108,
- 105,122,101,32,97,110,32,101,120,116,101,110,115,105,111,110,
- 32,109,111,100,117,108,101,122,40,101,120,116,101,110,115,105,
- 111,110,32,109,111,100,117,108,101,32,123,33,114,125,32,101,
- 120,101,99,117,116,101,100,32,102,114,111,109,32,123,33,114,
- 125,78,41,7,114,134,0,0,0,114,214,0,0,0,114,163,
- 0,0,0,90,12,101,120,101,99,95,100,121,110,97,109,105,
- 99,114,149,0,0,0,114,116,0,0,0,114,44,0,0,0,
- 169,2,114,118,0,0,0,114,216,0,0,0,114,5,0,0,
- 0,114,5,0,0,0,114,8,0,0,0,114,217,0,0,0,
- 69,4,0,0,115,8,0,0,0,0,2,14,1,6,1,8,
- 255,122,31,69,120,116,101,110,115,105,111,110,70,105,108,101,
- 76,111,97,100,101,114,46,101,120,101,99,95,109,111,100,117,
- 108,101,99,2,0,0,0,0,0,0,0,0,0,0,0,2,
- 0,0,0,4,0,0,0,3,0,0,0,115,36,0,0,0,
- 116,0,124,0,106,1,131,1,100,1,25,0,137,0,116,2,
- 135,0,102,1,100,2,100,3,132,8,116,3,68,0,131,1,
- 131,1,83,0,41,4,122,49,82,101,116,117,114,110,32,84,
- 114,117,101,32,105,102,32,116,104,101,32,101,120,116,101,110,
- 115,105,111,110,32,109,111,100,117,108,101,32,105,115,32,97,
- 32,112,97,99,107,97,103,101,46,114,39,0,0,0,99,1,
- 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,4,
- 0,0,0,51,0,0,0,115,26,0,0,0,124,0,93,18,
- 125,1,136,0,100,0,124,1,23,0,107,2,86,0,1,0,
- 113,2,100,1,83,0,41,2,114,209,0,0,0,78,114,5,
- 0,0,0,169,2,114,32,0,0,0,218,6,115,117,102,102,
- 105,120,169,1,90,9,102,105,108,101,95,110,97,109,101,114,
- 5,0,0,0,114,8,0,0,0,218,9,60,103,101,110,101,
- 120,112,114,62,78,4,0,0,115,4,0,0,0,4,1,2,
- 255,122,49,69,120,116,101,110,115,105,111,110,70,105,108,101,
- 76,111,97,100,101,114,46,105,115,95,112,97,99,107,97,103,
- 101,46,60,108,111,99,97,108,115,62,46,60,103,101,110,101,
- 120,112,114,62,41,4,114,47,0,0,0,114,44,0,0,0,
- 218,3,97,110,121,218,18,69,88,84,69,78,83,73,79,78,
- 95,83,85,70,70,73,88,69,83,114,219,0,0,0,114,5,
- 0,0,0,114,9,1,0,0,114,8,0,0,0,114,182,0,
- 0,0,75,4,0,0,115,8,0,0,0,0,2,14,1,12,
- 1,2,255,122,30,69,120,116,101,110,115,105,111,110,70,105,
- 108,101,76,111,97,100,101,114,46,105,115,95,112,97,99,107,
- 97,103,101,99,2,0,0,0,0,0,0,0,0,0,0,0,
- 2,0,0,0,1,0,0,0,67,0,0,0,115,4,0,0,
- 0,100,1,83,0,41,2,122,63,82,101,116,117,114,110,32,
- 78,111,110,101,32,97,115,32,97,110,32,101,120,116,101,110,
- 115,105,111,110,32,109,111,100,117,108,101,32,99,97,110,110,
- 111,116,32,99,114,101,97,116,101,32,97,32,99,111,100,101,
- 32,111,98,106,101,99,116,46,78,114,5,0,0,0,114,219,
- 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,
- 0,0,114,213,0,0,0,81,4,0,0,115,2,0,0,0,
- 0,2,122,28,69,120,116,101,110,115,105,111,110,70,105,108,
- 101,76,111,97,100,101,114,46,103,101,116,95,99,111,100,101,
- 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
- 0,1,0,0,0,67,0,0,0,115,4,0,0,0,100,1,
- 83,0,41,2,122,53,82,101,116,117,114,110,32,78,111,110,
- 101,32,97,115,32,101,120,116,101,110,115,105,111,110,32,109,
- 111,100,117,108,101,115,32,104,97,118,101,32,110,111,32,115,
- 111,117,114,99,101,32,99,111,100,101,46,78,114,5,0,0,
- 0,114,219,0,0,0,114,5,0,0,0,114,5,0,0,0,
- 114,8,0,0,0,114,229,0,0,0,85,4,0,0,115,2,
- 0,0,0,0,2,122,30,69,120,116,101,110,115,105,111,110,
- 70,105,108,101,76,111,97,100,101,114,46,103,101,116,95,115,
- 111,117,114,99,101,99,2,0,0,0,0,0,0,0,0,0,
- 0,0,2,0,0,0,1,0,0,0,67,0,0,0,115,6,
- 0,0,0,124,0,106,0,83,0,114,250,0,0,0,114,48,
- 0,0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,
- 0,0,114,8,0,0,0,114,179,0,0,0,89,4,0,0,
- 115,2,0,0,0,0,3,122,32,69,120,116,101,110,115,105,
- 111,110,70,105,108,101,76,111,97,100,101,114,46,103,101,116,
- 95,102,105,108,101,110,97,109,101,78,41,14,114,125,0,0,
- 0,114,124,0,0,0,114,126,0,0,0,114,127,0,0,0,
- 114,209,0,0,0,114,243,0,0,0,114,247,0,0,0,114,
- 212,0,0,0,114,217,0,0,0,114,182,0,0,0,114,213,
- 0,0,0,114,229,0,0,0,114,136,0,0,0,114,179,0,
- 0,0,114,5,0,0,0,114,5,0,0,0,114,5,0,0,
- 0,114,8,0,0,0,114,252,0,0,0,42,4,0,0,115,
- 22,0,0,0,8,2,4,6,8,4,8,4,8,3,8,8,
- 8,6,8,6,8,4,8,4,2,1,114,252,0,0,0,99,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 2,0,0,0,64,0,0,0,115,104,0,0,0,101,0,90,
- 1,100,0,90,2,100,1,90,3,100,2,100,3,132,0,90,
- 4,100,4,100,5,132,0,90,5,100,6,100,7,132,0,90,
- 6,100,8,100,9,132,0,90,7,100,10,100,11,132,0,90,
- 8,100,12,100,13,132,0,90,9,100,14,100,15,132,0,90,
- 10,100,16,100,17,132,0,90,11,100,18,100,19,132,0,90,
- 12,100,20,100,21,132,0,90,13,100,22,100,23,132,0,90,
- 14,100,24,83,0,41,25,218,14,95,78,97,109,101,115,112,
- 97,99,101,80,97,116,104,97,38,1,0,0,82,101,112,114,
- 101,115,101,110,116,115,32,97,32,110,97,109,101,115,112,97,
- 99,101,32,112,97,99,107,97,103,101,39,115,32,112,97,116,
- 104,46,32,32,73,116,32,117,115,101,115,32,116,104,101,32,
- 109,111,100,117,108,101,32,110,97,109,101,10,32,32,32,32,
- 116,111,32,102,105,110,100,32,105,116,115,32,112,97,114,101,
- 110,116,32,109,111,100,117,108,101,44,32,97,110,100,32,102,
- 114,111,109,32,116,104,101,114,101,32,105,116,32,108,111,111,
- 107,115,32,117,112,32,116,104,101,32,112,97,114,101,110,116,
- 39,115,10,32,32,32,32,95,95,112,97,116,104,95,95,46,
- 32,32,87,104,101,110,32,116,104,105,115,32,99,104,97,110,
- 103,101,115,44,32,116,104,101,32,109,111,100,117,108,101,39,
- 115,32,111,119,110,32,112,97,116,104,32,105,115,32,114,101,
- 99,111,109,112,117,116,101,100,44,10,32,32,32,32,117,115,
- 105,110,103,32,112,97,116,104,95,102,105,110,100,101,114,46,
- 32,32,70,111,114,32,116,111,112,45,108,101,118,101,108,32,
- 109,111,100,117,108,101,115,44,32,116,104,101,32,112,97,114,
- 101,110,116,32,109,111,100,117,108,101,39,115,32,112,97,116,
- 104,10,32,32,32,32,105,115,32,115,121,115,46,112,97,116,
- 104,46,99,4,0,0,0,0,0,0,0,0,0,0,0,4,
- 0,0,0,3,0,0,0,67,0,0,0,115,36,0,0,0,
- 124,1,124,0,95,0,124,2,124,0,95,1,116,2,124,0,
- 160,3,161,0,131,1,124,0,95,4,124,3,124,0,95,5,
- 100,0,83,0,114,109,0,0,0,41,6,218,5,95,110,97,
- 109,101,218,5,95,112,97,116,104,114,111,0,0,0,218,16,
- 95,103,101,116,95,112,97,114,101,110,116,95,112,97,116,104,
- 218,17,95,108,97,115,116,95,112,97,114,101,110,116,95,112,
- 97,116,104,218,12,95,112,97,116,104,95,102,105,110,100,101,
- 114,169,4,114,118,0,0,0,114,116,0,0,0,114,44,0,
- 0,0,90,11,112,97,116,104,95,102,105,110,100,101,114,114,
- 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,209,
- 0,0,0,102,4,0,0,115,8,0,0,0,0,1,6,1,
- 6,1,14,1,122,23,95,78,97,109,101,115,112,97,99,101,
- 80,97,116,104,46,95,95,105,110,105,116,95,95,99,1,0,
- 0,0,0,0,0,0,0,0,0,0,4,0,0,0,3,0,
- 0,0,67,0,0,0,115,38,0,0,0,124,0,106,0,160,
- 1,100,1,161,1,92,3,125,1,125,2,125,3,124,2,100,
- 2,107,2,114,30,100,3,83,0,124,1,100,4,102,2,83,
- 0,41,5,122,62,82,101,116,117,114,110,115,32,97,32,116,
- 117,112,108,101,32,111,102,32,40,112,97,114,101,110,116,45,
- 109,111,100,117,108,101,45,110,97,109,101,44,32,112,97,114,
- 101,110,116,45,112,97,116,104,45,97,116,116,114,45,110,97,
- 109,101,41,114,71,0,0,0,114,40,0,0,0,41,2,114,
- 1,0,0,0,114,44,0,0,0,90,8,95,95,112,97,116,
- 104,95,95,41,2,114,14,1,0,0,114,41,0,0,0,41,
- 4,114,118,0,0,0,114,4,1,0,0,218,3,100,111,116,
- 90,2,109,101,114,5,0,0,0,114,5,0,0,0,114,8,
- 0,0,0,218,23,95,102,105,110,100,95,112,97,114,101,110,
- 116,95,112,97,116,104,95,110,97,109,101,115,108,4,0,0,
- 115,8,0,0,0,0,2,18,1,8,2,4,3,122,38,95,
- 78,97,109,101,115,112,97,99,101,80,97,116,104,46,95,102,
- 105,110,100,95,112,97,114,101,110,116,95,112,97,116,104,95,
- 110,97,109,101,115,99,1,0,0,0,0,0,0,0,0,0,
- 0,0,3,0,0,0,3,0,0,0,67,0,0,0,115,28,
- 0,0,0,124,0,160,0,161,0,92,2,125,1,125,2,116,
- 1,116,2,106,3,124,1,25,0,124,2,131,2,83,0,114,
- 109,0,0,0,41,4,114,21,1,0,0,114,130,0,0,0,
- 114,1,0,0,0,218,7,109,111,100,117,108,101,115,41,3,
- 114,118,0,0,0,90,18,112,97,114,101,110,116,95,109,111,
- 100,117,108,101,95,110,97,109,101,90,14,112,97,116,104,95,
- 97,116,116,114,95,110,97,109,101,114,5,0,0,0,114,5,
- 0,0,0,114,8,0,0,0,114,16,1,0,0,118,4,0,
- 0,115,4,0,0,0,0,1,12,1,122,31,95,78,97,109,
- 101,115,112,97,99,101,80,97,116,104,46,95,103,101,116,95,
- 112,97,114,101,110,116,95,112,97,116,104,99,1,0,0,0,
- 0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,0,
- 67,0,0,0,115,80,0,0,0,116,0,124,0,160,1,161,
- 0,131,1,125,1,124,1,124,0,106,2,107,3,114,74,124,
- 0,160,3,124,0,106,4,124,1,161,2,125,2,124,2,100,
- 0,117,1,114,68,124,2,106,5,100,0,117,0,114,68,124,
- 2,106,6,114,68,124,2,106,6,124,0,95,7,124,1,124,
- 0,95,2,124,0,106,7,83,0,114,109,0,0,0,41,8,
- 114,111,0,0,0,114,16,1,0,0,114,17,1,0,0,114,
- 18,1,0,0,114,14,1,0,0,114,140,0,0,0,114,178,
- 0,0,0,114,15,1,0,0,41,3,114,118,0,0,0,90,
- 11,112,97,114,101,110,116,95,112,97,116,104,114,187,0,0,
- 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,
- 218,12,95,114,101,99,97,108,99,117,108,97,116,101,122,4,
- 0,0,115,16,0,0,0,0,2,12,1,10,1,14,3,18,
- 1,6,1,8,1,6,1,122,27,95,78,97,109,101,115,112,
- 97,99,101,80,97,116,104,46,95,114,101,99,97,108,99,117,
- 108,97,116,101,99,1,0,0,0,0,0,0,0,0,0,0,
- 0,1,0,0,0,3,0,0,0,67,0,0,0,115,12,0,
- 0,0,116,0,124,0,160,1,161,0,131,1,83,0,114,109,
- 0,0,0,41,2,218,4,105,116,101,114,114,23,1,0,0,
- 114,246,0,0,0,114,5,0,0,0,114,5,0,0,0,114,
- 8,0,0,0,218,8,95,95,105,116,101,114,95,95,135,4,
- 0,0,115,2,0,0,0,0,1,122,23,95,78,97,109,101,
+ 107,2,83,0,114,114,0,0,0,114,247,0,0,0,114,249,
+ 0,0,0,114,7,0,0,0,114,7,0,0,0,114,8,0,
+ 0,0,114,250,0,0,0,93,4,0,0,115,8,0,0,0,
+ 12,1,10,1,2,255,255,128,122,26,69,120,116,101,110,115,
+ 105,111,110,70,105,108,101,76,111,97,100,101,114,46,95,95,
+ 101,113,95,95,99,1,0,0,0,0,0,0,0,0,0,0,
+ 0,1,0,0,0,3,0,0,0,67,0,0,0,115,20,0,
+ 0,0,116,0,124,0,106,1,131,1,116,0,124,0,106,2,
+ 131,1,65,0,83,0,114,114,0,0,0,114,251,0,0,0,
+ 114,253,0,0,0,114,7,0,0,0,114,7,0,0,0,114,
+ 8,0,0,0,114,254,0,0,0,97,4,0,0,115,4,0,
+ 0,0,20,1,255,128,122,28,69,120,116,101,110,115,105,111,
+ 110,70,105,108,101,76,111,97,100,101,114,46,95,95,104,97,
+ 115,104,95,95,99,2,0,0,0,0,0,0,0,0,0,0,
+ 0,3,0,0,0,5,0,0,0,67,0,0,0,115,36,0,
+ 0,0,116,0,160,1,116,2,106,3,124,1,161,2,125,2,
+ 116,0,160,4,100,1,124,1,106,5,124,0,106,6,161,3,
+ 1,0,124,2,83,0,41,3,122,38,67,114,101,97,116,101,
+ 32,97,110,32,117,110,105,116,105,97,108,105,122,101,100,32,
+ 101,120,116,101,110,115,105,111,110,32,109,111,100,117,108,101,
+ 122,38,101,120,116,101,110,115,105,111,110,32,109,111,100,117,
+ 108,101,32,123,33,114,125,32,108,111,97,100,101,100,32,102,
+ 114,111,109,32,123,33,114,125,78,41,7,114,139,0,0,0,
+ 114,221,0,0,0,114,167,0,0,0,90,14,99,114,101,97,
+ 116,101,95,100,121,110,97,109,105,99,114,153,0,0,0,114,
+ 121,0,0,0,114,52,0,0,0,41,3,114,123,0,0,0,
+ 114,191,0,0,0,114,223,0,0,0,114,7,0,0,0,114,
+ 7,0,0,0,114,8,0,0,0,114,219,0,0,0,100,4,
+ 0,0,115,16,0,0,0,4,2,6,1,4,255,6,2,8,
+ 1,4,255,4,2,255,128,122,33,69,120,116,101,110,115,105,
+ 111,110,70,105,108,101,76,111,97,100,101,114,46,99,114,101,
+ 97,116,101,95,109,111,100,117,108,101,99,2,0,0,0,0,
+ 0,0,0,0,0,0,0,2,0,0,0,5,0,0,0,67,
+ 0,0,0,115,36,0,0,0,116,0,160,1,116,2,106,3,
+ 124,1,161,2,1,0,116,0,160,4,100,1,124,0,106,5,
+ 124,0,106,6,161,3,1,0,100,2,83,0,41,3,122,30,
+ 73,110,105,116,105,97,108,105,122,101,32,97,110,32,101,120,
+ 116,101,110,115,105,111,110,32,109,111,100,117,108,101,122,40,
+ 101,120,116,101,110,115,105,111,110,32,109,111,100,117,108,101,
+ 32,123,33,114,125,32,101,120,101,99,117,116,101,100,32,102,
+ 114,111,109,32,123,33,114,125,78,41,7,114,139,0,0,0,
+ 114,221,0,0,0,114,167,0,0,0,90,12,101,120,101,99,
+ 95,100,121,110,97,109,105,99,114,153,0,0,0,114,121,0,
+ 0,0,114,52,0,0,0,169,2,114,123,0,0,0,114,223,
+ 0,0,0,114,7,0,0,0,114,7,0,0,0,114,8,0,
+ 0,0,114,224,0,0,0,108,4,0,0,115,10,0,0,0,
+ 14,2,6,1,8,1,8,255,255,128,122,31,69,120,116,101,
+ 110,115,105,111,110,70,105,108,101,76,111,97,100,101,114,46,
+ 101,120,101,99,95,109,111,100,117,108,101,99,2,0,0,0,
+ 0,0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,
+ 3,0,0,0,115,36,0,0,0,116,0,124,0,106,1,131,
+ 1,100,1,25,0,137,0,116,2,135,0,102,1,100,2,100,
+ 3,132,8,116,3,68,0,131,1,131,1,83,0,41,5,122,
+ 49,82,101,116,117,114,110,32,84,114,117,101,32,105,102,32,
+ 116,104,101,32,101,120,116,101,110,115,105,111,110,32,109,111,
+ 100,117,108,101,32,105,115,32,97,32,112,97,99,107,97,103,
+ 101,46,114,3,0,0,0,99,1,0,0,0,0,0,0,0,
+ 0,0,0,0,2,0,0,0,4,0,0,0,51,0,0,0,
+ 115,26,0,0,0,124,0,93,18,125,1,136,0,100,0,124,
+ 1,23,0,107,2,86,0,1,0,113,2,100,1,83,0,41,
+ 2,114,216,0,0,0,78,114,7,0,0,0,169,2,114,5,
+ 0,0,0,218,6,115,117,102,102,105,120,169,1,90,9,102,
+ 105,108,101,95,110,97,109,101,114,7,0,0,0,114,8,0,
+ 0,0,114,9,0,0,0,117,4,0,0,115,8,0,0,0,
+ 4,0,2,1,20,255,255,128,122,49,69,120,116,101,110,115,
+ 105,111,110,70,105,108,101,76,111,97,100,101,114,46,105,115,
+ 95,112,97,99,107,97,103,101,46,60,108,111,99,97,108,115,
+ 62,46,60,103,101,110,101,120,112,114,62,78,41,4,114,55,
+ 0,0,0,114,52,0,0,0,218,3,97,110,121,114,212,0,
+ 0,0,114,226,0,0,0,114,7,0,0,0,114,16,1,0,
+ 0,114,8,0,0,0,114,186,0,0,0,114,4,0,0,115,
+ 10,0,0,0,14,2,12,1,2,1,8,255,255,128,122,30,
+ 69,120,116,101,110,115,105,111,110,70,105,108,101,76,111,97,
+ 100,101,114,46,105,115,95,112,97,99,107,97,103,101,99,2,
+ 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,1,
+ 0,0,0,67,0,0,0,115,4,0,0,0,100,1,83,0,
+ 41,2,122,63,82,101,116,117,114,110,32,78,111,110,101,32,
+ 97,115,32,97,110,32,101,120,116,101,110,115,105,111,110,32,
+ 109,111,100,117,108,101,32,99,97,110,110,111,116,32,99,114,
+ 101,97,116,101,32,97,32,99,111,100,101,32,111,98,106,101,
+ 99,116,46,78,114,7,0,0,0,114,226,0,0,0,114,7,
+ 0,0,0,114,7,0,0,0,114,8,0,0,0,114,220,0,
+ 0,0,120,4,0,0,115,4,0,0,0,4,2,255,128,122,
+ 28,69,120,116,101,110,115,105,111,110,70,105,108,101,76,111,
+ 97,100,101,114,46,103,101,116,95,99,111,100,101,99,2,0,
+ 0,0,0,0,0,0,0,0,0,0,2,0,0,0,1,0,
+ 0,0,67,0,0,0,115,4,0,0,0,100,1,83,0,41,
+ 2,122,53,82,101,116,117,114,110,32,78,111,110,101,32,97,
+ 115,32,101,120,116,101,110,115,105,111,110,32,109,111,100,117,
+ 108,101,115,32,104,97,118,101,32,110,111,32,115,111,117,114,
+ 99,101,32,99,111,100,101,46,78,114,7,0,0,0,114,226,
+ 0,0,0,114,7,0,0,0,114,7,0,0,0,114,8,0,
+ 0,0,114,236,0,0,0,124,4,0,0,115,4,0,0,0,
+ 4,2,255,128,122,30,69,120,116,101,110,115,105,111,110,70,
+ 105,108,101,76,111,97,100,101,114,46,103,101,116,95,115,111,
+ 117,114,99,101,99,2,0,0,0,0,0,0,0,0,0,0,
+ 0,2,0,0,0,1,0,0,0,67,0,0,0,115,6,0,
+ 0,0,124,0,106,0,83,0,114,1,1,0,0,114,56,0,
+ 0,0,114,226,0,0,0,114,7,0,0,0,114,7,0,0,
+ 0,114,8,0,0,0,114,183,0,0,0,128,4,0,0,115,
+ 4,0,0,0,6,3,255,128,122,32,69,120,116,101,110,115,
+ 105,111,110,70,105,108,101,76,111,97,100,101,114,46,103,101,
+ 116,95,102,105,108,101,110,97,109,101,78,41,14,114,130,0,
+ 0,0,114,129,0,0,0,114,131,0,0,0,114,132,0,0,
+ 0,114,216,0,0,0,114,250,0,0,0,114,254,0,0,0,
+ 114,219,0,0,0,114,224,0,0,0,114,186,0,0,0,114,
+ 220,0,0,0,114,236,0,0,0,114,140,0,0,0,114,183,
+ 0,0,0,114,7,0,0,0,114,7,0,0,0,114,7,0,
+ 0,0,114,8,0,0,0,114,3,1,0,0,81,4,0,0,
+ 115,26,0,0,0,8,0,4,2,8,6,8,4,8,4,8,
+ 3,8,8,8,6,8,6,8,4,2,4,14,1,255,128,114,
+ 3,1,0,0,99,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,2,0,0,0,64,0,0,0,115,104,0,
+ 0,0,101,0,90,1,100,0,90,2,100,1,90,3,100,2,
+ 100,3,132,0,90,4,100,4,100,5,132,0,90,5,100,6,
+ 100,7,132,0,90,6,100,8,100,9,132,0,90,7,100,10,
+ 100,11,132,0,90,8,100,12,100,13,132,0,90,9,100,14,
+ 100,15,132,0,90,10,100,16,100,17,132,0,90,11,100,18,
+ 100,19,132,0,90,12,100,20,100,21,132,0,90,13,100,22,
+ 100,23,132,0,90,14,100,24,83,0,41,25,218,14,95,78,
+ 97,109,101,115,112,97,99,101,80,97,116,104,97,38,1,0,
+ 0,82,101,112,114,101,115,101,110,116,115,32,97,32,110,97,
+ 109,101,115,112,97,99,101,32,112,97,99,107,97,103,101,39,
+ 115,32,112,97,116,104,46,32,32,73,116,32,117,115,101,115,
+ 32,116,104,101,32,109,111,100,117,108,101,32,110,97,109,101,
+ 10,32,32,32,32,116,111,32,102,105,110,100,32,105,116,115,
+ 32,112,97,114,101,110,116,32,109,111,100,117,108,101,44,32,
+ 97,110,100,32,102,114,111,109,32,116,104,101,114,101,32,105,
+ 116,32,108,111,111,107,115,32,117,112,32,116,104,101,32,112,
+ 97,114,101,110,116,39,115,10,32,32,32,32,95,95,112,97,
+ 116,104,95,95,46,32,32,87,104,101,110,32,116,104,105,115,
+ 32,99,104,97,110,103,101,115,44,32,116,104,101,32,109,111,
+ 100,117,108,101,39,115,32,111,119,110,32,112,97,116,104,32,
+ 105,115,32,114,101,99,111,109,112,117,116,101,100,44,10,32,
+ 32,32,32,117,115,105,110,103,32,112,97,116,104,95,102,105,
+ 110,100,101,114,46,32,32,70,111,114,32,116,111,112,45,108,
+ 101,118,101,108,32,109,111,100,117,108,101,115,44,32,116,104,
+ 101,32,112,97,114,101,110,116,32,109,111,100,117,108,101,39,
+ 115,32,112,97,116,104,10,32,32,32,32,105,115,32,115,121,
+ 115,46,112,97,116,104,46,99,4,0,0,0,0,0,0,0,
+ 0,0,0,0,4,0,0,0,3,0,0,0,67,0,0,0,
+ 115,36,0,0,0,124,1,124,0,95,0,124,2,124,0,95,
+ 1,116,2,124,0,160,3,161,0,131,1,124,0,95,4,124,
+ 3,124,0,95,5,100,0,83,0,114,114,0,0,0,41,6,
+ 218,5,95,110,97,109,101,218,5,95,112,97,116,104,114,116,
+ 0,0,0,218,16,95,103,101,116,95,112,97,114,101,110,116,
+ 95,112,97,116,104,218,17,95,108,97,115,116,95,112,97,114,
+ 101,110,116,95,112,97,116,104,218,12,95,112,97,116,104,95,
+ 102,105,110,100,101,114,169,4,114,123,0,0,0,114,121,0,
+ 0,0,114,52,0,0,0,90,11,112,97,116,104,95,102,105,
+ 110,100,101,114,114,7,0,0,0,114,7,0,0,0,114,8,
+ 0,0,0,114,216,0,0,0,141,4,0,0,115,10,0,0,
+ 0,6,1,6,1,14,1,10,1,255,128,122,23,95,78,97,
+ 109,101,115,112,97,99,101,80,97,116,104,46,95,95,105,110,
+ 105,116,95,95,99,1,0,0,0,0,0,0,0,0,0,0,
+ 0,4,0,0,0,3,0,0,0,67,0,0,0,115,38,0,
+ 0,0,124,0,106,0,160,1,100,1,161,1,92,3,125,1,
+ 125,2,125,3,124,2,100,2,107,2,114,30,100,3,83,0,
+ 124,1,100,4,102,2,83,0,41,6,122,62,82,101,116,117,
+ 114,110,115,32,97,32,116,117,112,108,101,32,111,102,32,40,
+ 112,97,114,101,110,116,45,109,111,100,117,108,101,45,110,97,
+ 109,101,44,32,112,97,114,101,110,116,45,112,97,116,104,45,
+ 97,116,116,114,45,110,97,109,101,41,114,79,0,0,0,114,
+ 10,0,0,0,41,2,114,15,0,0,0,114,52,0,0,0,
+ 90,8,95,95,112,97,116,104,95,95,78,41,2,114,19,1,
+ 0,0,114,49,0,0,0,41,4,114,123,0,0,0,114,11,
+ 1,0,0,218,3,100,111,116,90,2,109,101,114,7,0,0,
+ 0,114,7,0,0,0,114,8,0,0,0,218,23,95,102,105,
+ 110,100,95,112,97,114,101,110,116,95,112,97,116,104,95,110,
+ 97,109,101,115,147,4,0,0,115,10,0,0,0,18,2,8,
+ 1,4,2,8,3,255,128,122,38,95,78,97,109,101,115,112,
+ 97,99,101,80,97,116,104,46,95,102,105,110,100,95,112,97,
+ 114,101,110,116,95,112,97,116,104,95,110,97,109,101,115,99,
+ 1,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,
+ 3,0,0,0,67,0,0,0,115,28,0,0,0,124,0,160,
+ 0,161,0,92,2,125,1,125,2,116,1,116,2,106,3,124,
+ 1,25,0,124,2,131,2,83,0,114,114,0,0,0,41,4,
+ 114,26,1,0,0,114,135,0,0,0,114,15,0,0,0,218,
+ 7,109,111,100,117,108,101,115,41,3,114,123,0,0,0,90,
+ 18,112,97,114,101,110,116,95,109,111,100,117,108,101,95,110,
+ 97,109,101,90,14,112,97,116,104,95,97,116,116,114,95,110,
+ 97,109,101,114,7,0,0,0,114,7,0,0,0,114,8,0,
+ 0,0,114,21,1,0,0,157,4,0,0,115,6,0,0,0,
+ 12,1,16,1,255,128,122,31,95,78,97,109,101,115,112,97,
+ 99,101,80,97,116,104,46,95,103,101,116,95,112,97,114,101,
+ 110,116,95,112,97,116,104,99,1,0,0,0,0,0,0,0,
+ 0,0,0,0,3,0,0,0,4,0,0,0,67,0,0,0,
+ 115,80,0,0,0,116,0,124,0,160,1,161,0,131,1,125,
+ 1,124,1,124,0,106,2,107,3,114,74,124,0,160,3,124,
+ 0,106,4,124,1,161,2,125,2,124,2,100,0,117,1,114,
+ 68,124,2,106,5,100,0,117,0,114,68,124,2,106,6,114,
+ 68,124,2,106,6,124,0,95,7,124,1,124,0,95,2,124,
+ 0,106,7,83,0,114,114,0,0,0,41,8,114,116,0,0,
+ 0,114,21,1,0,0,114,22,1,0,0,114,23,1,0,0,
+ 114,19,1,0,0,114,144,0,0,0,114,182,0,0,0,114,
+ 20,1,0,0,41,3,114,123,0,0,0,90,11,112,97,114,
+ 101,110,116,95,112,97,116,104,114,191,0,0,0,114,7,0,
+ 0,0,114,7,0,0,0,114,8,0,0,0,218,12,95,114,
+ 101,99,97,108,99,117,108,97,116,101,161,4,0,0,115,18,
+ 0,0,0,12,2,10,1,14,1,18,3,6,1,8,1,6,
+ 1,6,1,255,128,122,27,95,78,97,109,101,115,112,97,99,
+ 101,80,97,116,104,46,95,114,101,99,97,108,99,117,108,97,
+ 116,101,99,1,0,0,0,0,0,0,0,0,0,0,0,1,
+ 0,0,0,3,0,0,0,67,0,0,0,115,12,0,0,0,
+ 116,0,124,0,160,1,161,0,131,1,83,0,114,114,0,0,
+ 0,41,2,218,4,105,116,101,114,114,28,1,0,0,114,253,
+ 0,0,0,114,7,0,0,0,114,7,0,0,0,114,8,0,
+ 0,0,218,8,95,95,105,116,101,114,95,95,174,4,0,0,
+ 115,4,0,0,0,12,1,255,128,122,23,95,78,97,109,101,
115,112,97,99,101,80,97,116,104,46,95,95,105,116,101,114,
95,95,99,2,0,0,0,0,0,0,0,0,0,0,0,2,
0,0,0,2,0,0,0,67,0,0,0,115,12,0,0,0,
- 124,0,160,0,161,0,124,1,25,0,83,0,114,109,0,0,
- 0,169,1,114,23,1,0,0,41,2,114,118,0,0,0,218,
- 5,105,110,100,101,120,114,5,0,0,0,114,5,0,0,0,
+ 124,0,160,0,161,0,124,1,25,0,83,0,114,114,0,0,
+ 0,169,1,114,28,1,0,0,41,2,114,123,0,0,0,218,
+ 5,105,110,100,101,120,114,7,0,0,0,114,7,0,0,0,
114,8,0,0,0,218,11,95,95,103,101,116,105,116,101,109,
- 95,95,138,4,0,0,115,2,0,0,0,0,1,122,26,95,
+ 95,95,177,4,0,0,115,4,0,0,0,12,1,255,128,122,
+ 26,95,78,97,109,101,115,112,97,99,101,80,97,116,104,46,
+ 95,95,103,101,116,105,116,101,109,95,95,99,3,0,0,0,
+ 0,0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,
+ 67,0,0,0,115,14,0,0,0,124,2,124,0,106,0,124,
+ 1,60,0,100,0,83,0,114,114,0,0,0,41,1,114,20,
+ 1,0,0,41,3,114,123,0,0,0,114,32,1,0,0,114,
+ 52,0,0,0,114,7,0,0,0,114,7,0,0,0,114,8,
+ 0,0,0,218,11,95,95,115,101,116,105,116,101,109,95,95,
+ 180,4,0,0,115,4,0,0,0,14,1,255,128,122,26,95,
78,97,109,101,115,112,97,99,101,80,97,116,104,46,95,95,
- 103,101,116,105,116,101,109,95,95,99,3,0,0,0,0,0,
- 0,0,0,0,0,0,3,0,0,0,3,0,0,0,67,0,
- 0,0,115,14,0,0,0,124,2,124,0,106,0,124,1,60,
- 0,100,0,83,0,114,109,0,0,0,41,1,114,15,1,0,
- 0,41,3,114,118,0,0,0,114,27,1,0,0,114,44,0,
- 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,
- 0,218,11,95,95,115,101,116,105,116,101,109,95,95,141,4,
- 0,0,115,2,0,0,0,0,1,122,26,95,78,97,109,101,
- 115,112,97,99,101,80,97,116,104,46,95,95,115,101,116,105,
- 116,101,109,95,95,99,1,0,0,0,0,0,0,0,0,0,
- 0,0,1,0,0,0,3,0,0,0,67,0,0,0,115,12,
- 0,0,0,116,0,124,0,160,1,161,0,131,1,83,0,114,
- 109,0,0,0,41,2,114,23,0,0,0,114,23,1,0,0,
- 114,246,0,0,0,114,5,0,0,0,114,5,0,0,0,114,
- 8,0,0,0,218,7,95,95,108,101,110,95,95,144,4,0,
- 0,115,2,0,0,0,0,1,122,22,95,78,97,109,101,115,
- 112,97,99,101,80,97,116,104,46,95,95,108,101,110,95,95,
- 99,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
- 0,3,0,0,0,67,0,0,0,115,12,0,0,0,100,1,
- 160,0,124,0,106,1,161,1,83,0,41,2,78,122,20,95,
- 78,97,109,101,115,112,97,99,101,80,97,116,104,40,123,33,
- 114,125,41,41,2,114,62,0,0,0,114,15,1,0,0,114,
- 246,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,
- 0,0,0,218,8,95,95,114,101,112,114,95,95,147,4,0,
- 0,115,2,0,0,0,0,1,122,23,95,78,97,109,101,115,
- 112,97,99,101,80,97,116,104,46,95,95,114,101,112,114,95,
+ 115,101,116,105,116,101,109,95,95,99,1,0,0,0,0,0,
+ 0,0,0,0,0,0,1,0,0,0,3,0,0,0,67,0,
+ 0,0,115,12,0,0,0,116,0,124,0,160,1,161,0,131,
+ 1,83,0,114,114,0,0,0,41,2,114,4,0,0,0,114,
+ 28,1,0,0,114,253,0,0,0,114,7,0,0,0,114,7,
+ 0,0,0,114,8,0,0,0,218,7,95,95,108,101,110,95,
+ 95,183,4,0,0,115,4,0,0,0,12,1,255,128,122,22,
+ 95,78,97,109,101,115,112,97,99,101,80,97,116,104,46,95,
+ 95,108,101,110,95,95,99,1,0,0,0,0,0,0,0,0,
+ 0,0,0,1,0,0,0,3,0,0,0,67,0,0,0,115,
+ 12,0,0,0,100,1,160,0,124,0,106,1,161,1,83,0,
+ 41,2,78,122,20,95,78,97,109,101,115,112,97,99,101,80,
+ 97,116,104,40,123,33,114,125,41,41,2,114,70,0,0,0,
+ 114,20,1,0,0,114,253,0,0,0,114,7,0,0,0,114,
+ 7,0,0,0,114,8,0,0,0,218,8,95,95,114,101,112,
+ 114,95,95,186,4,0,0,115,4,0,0,0,12,1,255,128,
+ 122,23,95,78,97,109,101,115,112,97,99,101,80,97,116,104,
+ 46,95,95,114,101,112,114,95,95,99,2,0,0,0,0,0,
+ 0,0,0,0,0,0,2,0,0,0,3,0,0,0,67,0,
+ 0,0,115,12,0,0,0,124,1,124,0,160,0,161,0,118,
+ 0,83,0,114,114,0,0,0,114,31,1,0,0,169,2,114,
+ 123,0,0,0,218,4,105,116,101,109,114,7,0,0,0,114,
+ 7,0,0,0,114,8,0,0,0,218,12,95,95,99,111,110,
+ 116,97,105,110,115,95,95,189,4,0,0,115,4,0,0,0,
+ 12,1,255,128,122,27,95,78,97,109,101,115,112,97,99,101,
+ 80,97,116,104,46,95,95,99,111,110,116,97,105,110,115,95,
95,99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,
- 0,0,3,0,0,0,67,0,0,0,115,12,0,0,0,124,
- 1,124,0,160,0,161,0,118,0,83,0,114,109,0,0,0,
- 114,26,1,0,0,169,2,114,118,0,0,0,218,4,105,116,
- 101,109,114,5,0,0,0,114,5,0,0,0,114,8,0,0,
- 0,218,12,95,95,99,111,110,116,97,105,110,115,95,95,150,
- 4,0,0,115,2,0,0,0,0,1,122,27,95,78,97,109,
- 101,115,112,97,99,101,80,97,116,104,46,95,95,99,111,110,
- 116,97,105,110,115,95,95,99,2,0,0,0,0,0,0,0,
- 0,0,0,0,2,0,0,0,3,0,0,0,67,0,0,0,
- 115,16,0,0,0,124,0,106,0,160,1,124,1,161,1,1,
- 0,100,0,83,0,114,109,0,0,0,41,2,114,15,1,0,
- 0,114,186,0,0,0,114,32,1,0,0,114,5,0,0,0,
- 114,5,0,0,0,114,8,0,0,0,114,186,0,0,0,153,
- 4,0,0,115,2,0,0,0,0,1,122,21,95,78,97,109,
- 101,115,112,97,99,101,80,97,116,104,46,97,112,112,101,110,
- 100,78,41,15,114,125,0,0,0,114,124,0,0,0,114,126,
- 0,0,0,114,127,0,0,0,114,209,0,0,0,114,21,1,
- 0,0,114,16,1,0,0,114,23,1,0,0,114,25,1,0,
- 0,114,28,1,0,0,114,29,1,0,0,114,30,1,0,0,
- 114,31,1,0,0,114,34,1,0,0,114,186,0,0,0,114,
- 5,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,
- 0,0,0,114,13,1,0,0,95,4,0,0,115,24,0,0,
- 0,8,1,4,6,8,6,8,10,8,4,8,13,8,3,8,
- 3,8,3,8,3,8,3,8,3,114,13,1,0,0,99,0,
+ 0,0,3,0,0,0,67,0,0,0,115,16,0,0,0,124,
+ 0,106,0,160,1,124,1,161,1,1,0,100,0,83,0,114,
+ 114,0,0,0,41,2,114,20,1,0,0,114,190,0,0,0,
+ 114,37,1,0,0,114,7,0,0,0,114,7,0,0,0,114,
+ 8,0,0,0,114,190,0,0,0,192,4,0,0,115,4,0,
+ 0,0,16,1,255,128,122,21,95,78,97,109,101,115,112,97,
+ 99,101,80,97,116,104,46,97,112,112,101,110,100,78,41,15,
+ 114,130,0,0,0,114,129,0,0,0,114,131,0,0,0,114,
+ 132,0,0,0,114,216,0,0,0,114,26,1,0,0,114,21,
+ 1,0,0,114,28,1,0,0,114,30,1,0,0,114,33,1,
+ 0,0,114,34,1,0,0,114,35,1,0,0,114,36,1,0,
+ 0,114,39,1,0,0,114,190,0,0,0,114,7,0,0,0,
+ 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,114,
+ 18,1,0,0,134,4,0,0,115,28,0,0,0,8,0,4,
+ 1,8,6,8,6,8,10,8,4,8,13,8,3,8,3,8,
+ 3,8,3,8,3,12,3,255,128,114,18,1,0,0,99,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,
0,0,0,64,0,0,0,115,80,0,0,0,101,0,90,1,
100,0,90,2,100,1,100,2,132,0,90,3,101,4,100,3,
@@ -1925,763 +1973,702 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = {
99,4,0,0,0,0,0,0,0,0,0,0,0,4,0,0,
0,4,0,0,0,67,0,0,0,115,18,0,0,0,116,0,
124,1,124,2,124,3,131,3,124,0,95,1,100,0,83,0,
- 114,109,0,0,0,41,2,114,13,1,0,0,114,15,1,0,
- 0,114,19,1,0,0,114,5,0,0,0,114,5,0,0,0,
- 114,8,0,0,0,114,209,0,0,0,159,4,0,0,115,2,
- 0,0,0,0,1,122,25,95,78,97,109,101,115,112,97,99,
- 101,76,111,97,100,101,114,46,95,95,105,110,105,116,95,95,
- 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
- 0,3,0,0,0,67,0,0,0,115,12,0,0,0,100,1,
- 160,0,124,1,106,1,161,1,83,0,41,2,122,115,82,101,
- 116,117,114,110,32,114,101,112,114,32,102,111,114,32,116,104,
- 101,32,109,111,100,117,108,101,46,10,10,32,32,32,32,32,
- 32,32,32,84,104,101,32,109,101,116,104,111,100,32,105,115,
- 32,100,101,112,114,101,99,97,116,101,100,46,32,32,84,104,
- 101,32,105,109,112,111,114,116,32,109,97,99,104,105,110,101,
- 114,121,32,100,111,101,115,32,116,104,101,32,106,111,98,32,
- 105,116,115,101,108,102,46,10,10,32,32,32,32,32,32,32,
- 32,122,25,60,109,111,100,117,108,101,32,123,33,114,125,32,
- 40,110,97,109,101,115,112,97,99,101,41,62,41,2,114,62,
- 0,0,0,114,125,0,0,0,41,2,114,193,0,0,0,114,
- 216,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,
- 0,0,0,218,11,109,111,100,117,108,101,95,114,101,112,114,
- 162,4,0,0,115,2,0,0,0,0,7,122,28,95,78,97,
+ 114,114,0,0,0,41,2,114,18,1,0,0,114,20,1,0,
+ 0,114,24,1,0,0,114,7,0,0,0,114,7,0,0,0,
+ 114,8,0,0,0,114,216,0,0,0,198,4,0,0,115,4,
+ 0,0,0,18,1,255,128,122,25,95,78,97,109,101,115,112,
+ 97,99,101,76,111,97,100,101,114,46,95,95,105,110,105,116,
+ 95,95,99,1,0,0,0,0,0,0,0,0,0,0,0,1,
+ 0,0,0,3,0,0,0,67,0,0,0,115,12,0,0,0,
+ 100,1,160,0,124,0,106,1,161,1,83,0,41,3,122,115,
+ 82,101,116,117,114,110,32,114,101,112,114,32,102,111,114,32,
+ 116,104,101,32,109,111,100,117,108,101,46,10,10,32,32,32,
+ 32,32,32,32,32,84,104,101,32,109,101,116,104,111,100,32,
+ 105,115,32,100,101,112,114,101,99,97,116,101,100,46,32,32,
+ 84,104,101,32,105,109,112,111,114,116,32,109,97,99,104,105,
+ 110,101,114,121,32,100,111,101,115,32,116,104,101,32,106,111,
+ 98,32,105,116,115,101,108,102,46,10,10,32,32,32,32,32,
+ 32,32,32,122,25,60,109,111,100,117,108,101,32,123,33,114,
+ 125,32,40,110,97,109,101,115,112,97,99,101,41,62,78,41,
+ 2,114,70,0,0,0,114,130,0,0,0,41,1,114,223,0,
+ 0,0,114,7,0,0,0,114,7,0,0,0,114,8,0,0,
+ 0,218,11,109,111,100,117,108,101,95,114,101,112,114,201,4,
+ 0,0,115,4,0,0,0,12,7,255,128,122,28,95,78,97,
109,101,115,112,97,99,101,76,111,97,100,101,114,46,109,111,
100,117,108,101,95,114,101,112,114,99,2,0,0,0,0,0,
0,0,0,0,0,0,2,0,0,0,1,0,0,0,67,0,
0,0,115,4,0,0,0,100,1,83,0,41,2,78,84,114,
- 5,0,0,0,114,219,0,0,0,114,5,0,0,0,114,5,
- 0,0,0,114,8,0,0,0,114,182,0,0,0,171,4,0,
- 0,115,2,0,0,0,0,1,122,27,95,78,97,109,101,115,
- 112,97,99,101,76,111,97,100,101,114,46,105,115,95,112,97,
- 99,107,97,103,101,99,2,0,0,0,0,0,0,0,0,0,
- 0,0,2,0,0,0,1,0,0,0,67,0,0,0,115,4,
- 0,0,0,100,1,83,0,41,2,78,114,40,0,0,0,114,
- 5,0,0,0,114,219,0,0,0,114,5,0,0,0,114,5,
- 0,0,0,114,8,0,0,0,114,229,0,0,0,174,4,0,
- 0,115,2,0,0,0,0,1,122,27,95,78,97,109,101,115,
- 112,97,99,101,76,111,97,100,101,114,46,103,101,116,95,115,
- 111,117,114,99,101,99,2,0,0,0,0,0,0,0,0,0,
- 0,0,2,0,0,0,6,0,0,0,67,0,0,0,115,16,
- 0,0,0,116,0,100,1,100,2,100,3,100,4,100,5,141,
- 4,83,0,41,6,78,114,40,0,0,0,122,8,60,115,116,
- 114,105,110,103,62,114,215,0,0,0,84,41,1,114,231,0,
- 0,0,41,1,114,232,0,0,0,114,219,0,0,0,114,5,
- 0,0,0,114,5,0,0,0,114,8,0,0,0,114,213,0,
- 0,0,177,4,0,0,115,2,0,0,0,0,1,122,25,95,
- 78,97,109,101,115,112,97,99,101,76,111,97,100,101,114,46,
- 103,101,116,95,99,111,100,101,99,2,0,0,0,0,0,0,
- 0,0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,
- 0,115,4,0,0,0,100,1,83,0,114,210,0,0,0,114,
- 5,0,0,0,114,211,0,0,0,114,5,0,0,0,114,5,
- 0,0,0,114,8,0,0,0,114,212,0,0,0,180,4,0,
- 0,115,2,0,0,0,0,1,122,30,95,78,97,109,101,115,
- 112,97,99,101,76,111,97,100,101,114,46,99,114,101,97,116,
- 101,95,109,111,100,117,108,101,99,2,0,0,0,0,0,0,
- 0,0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,
- 0,115,4,0,0,0,100,0,83,0,114,109,0,0,0,114,
- 5,0,0,0,114,6,1,0,0,114,5,0,0,0,114,5,
- 0,0,0,114,8,0,0,0,114,217,0,0,0,183,4,0,
- 0,115,2,0,0,0,0,1,122,28,95,78,97,109,101,115,
- 112,97,99,101,76,111,97,100,101,114,46,101,120,101,99,95,
- 109,111,100,117,108,101,99,2,0,0,0,0,0,0,0,0,
- 0,0,0,2,0,0,0,4,0,0,0,67,0,0,0,115,
- 26,0,0,0,116,0,160,1,100,1,124,0,106,2,161,2,
- 1,0,116,0,160,3,124,0,124,1,161,2,83,0,41,2,
- 122,98,76,111,97,100,32,97,32,110,97,109,101,115,112,97,
- 99,101,32,109,111,100,117,108,101,46,10,10,32,32,32,32,
- 32,32,32,32,84,104,105,115,32,109,101,116,104,111,100,32,
- 105,115,32,100,101,112,114,101,99,97,116,101,100,46,32,32,
- 85,115,101,32,101,120,101,99,95,109,111,100,117,108,101,40,
- 41,32,105,110,115,116,101,97,100,46,10,10,32,32,32,32,
- 32,32,32,32,122,38,110,97,109,101,115,112,97,99,101,32,
- 109,111,100,117,108,101,32,108,111,97,100,101,100,32,119,105,
- 116,104,32,112,97,116,104,32,123,33,114,125,41,4,114,134,
- 0,0,0,114,149,0,0,0,114,15,1,0,0,114,218,0,
- 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0,
- 0,114,8,0,0,0,114,220,0,0,0,186,4,0,0,115,
- 8,0,0,0,0,7,6,1,4,255,4,2,122,28,95,78,
- 97,109,101,115,112,97,99,101,76,111,97,100,101,114,46,108,
- 111,97,100,95,109,111,100,117,108,101,78,41,12,114,125,0,
- 0,0,114,124,0,0,0,114,126,0,0,0,114,209,0,0,
- 0,114,207,0,0,0,114,36,1,0,0,114,182,0,0,0,
- 114,229,0,0,0,114,213,0,0,0,114,212,0,0,0,114,
- 217,0,0,0,114,220,0,0,0,114,5,0,0,0,114,5,
- 0,0,0,114,5,0,0,0,114,8,0,0,0,114,35,1,
- 0,0,158,4,0,0,115,18,0,0,0,8,1,8,3,2,
- 1,10,8,8,3,8,3,8,3,8,3,8,3,114,35,1,
- 0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,4,0,0,0,64,0,0,0,115,118,0,0,0,
- 101,0,90,1,100,0,90,2,100,1,90,3,101,4,100,2,
- 100,3,132,0,131,1,90,5,101,4,100,4,100,5,132,0,
- 131,1,90,6,101,4,100,6,100,7,132,0,131,1,90,7,
- 101,4,100,8,100,9,132,0,131,1,90,8,101,4,100,19,
- 100,11,100,12,132,1,131,1,90,9,101,4,100,20,100,13,
- 100,14,132,1,131,1,90,10,101,4,100,21,100,15,100,16,
- 132,1,131,1,90,11,101,4,100,17,100,18,132,0,131,1,
- 90,12,100,10,83,0,41,22,218,10,80,97,116,104,70,105,
- 110,100,101,114,122,62,77,101,116,97,32,112,97,116,104,32,
- 102,105,110,100,101,114,32,102,111,114,32,115,121,115,46,112,
- 97,116,104,32,97,110,100,32,112,97,99,107,97,103,101,32,
- 95,95,112,97,116,104,95,95,32,97,116,116,114,105,98,117,
- 116,101,115,46,99,1,0,0,0,0,0,0,0,0,0,0,
- 0,3,0,0,0,4,0,0,0,67,0,0,0,115,64,0,
- 0,0,116,0,116,1,106,2,160,3,161,0,131,1,68,0,
- 93,44,92,2,125,1,125,2,124,2,100,1,117,0,114,40,
- 116,1,106,2,124,1,61,0,113,14,116,4,124,2,100,2,
- 131,2,114,14,124,2,160,5,161,0,1,0,113,14,100,1,
- 83,0,41,3,122,125,67,97,108,108,32,116,104,101,32,105,
- 110,118,97,108,105,100,97,116,101,95,99,97,99,104,101,115,
- 40,41,32,109,101,116,104,111,100,32,111,110,32,97,108,108,
- 32,112,97,116,104,32,101,110,116,114,121,32,102,105,110,100,
- 101,114,115,10,32,32,32,32,32,32,32,32,115,116,111,114,
- 101,100,32,105,110,32,115,121,115,46,112,97,116,104,95,105,
- 109,112,111,114,116,101,114,95,99,97,99,104,101,115,32,40,
- 119,104,101,114,101,32,105,109,112,108,101,109,101,110,116,101,
- 100,41,46,78,218,17,105,110,118,97,108,105,100,97,116,101,
- 95,99,97,99,104,101,115,41,6,218,4,108,105,115,116,114,
- 1,0,0,0,218,19,112,97,116,104,95,105,109,112,111,114,
- 116,101,114,95,99,97,99,104,101,218,5,105,116,101,109,115,
- 114,128,0,0,0,114,38,1,0,0,41,3,114,193,0,0,
- 0,114,116,0,0,0,218,6,102,105,110,100,101,114,114,5,
- 0,0,0,114,5,0,0,0,114,8,0,0,0,114,38,1,
- 0,0,204,4,0,0,115,10,0,0,0,0,4,22,1,8,
- 1,10,1,10,1,122,28,80,97,116,104,70,105,110,100,101,
- 114,46,105,110,118,97,108,105,100,97,116,101,95,99,97,99,
- 104,101,115,99,2,0,0,0,0,0,0,0,0,0,0,0,
- 3,0,0,0,9,0,0,0,67,0,0,0,115,80,0,0,
- 0,116,0,106,1,100,1,117,1,114,28,116,0,106,1,115,
- 28,116,2,160,3,100,2,116,4,161,2,1,0,116,0,106,
- 1,68,0,93,40,125,2,122,14,124,2,124,1,131,1,87,
- 0,2,0,1,0,83,0,4,0,116,5,121,74,1,0,1,
- 0,1,0,89,0,113,34,89,0,113,34,48,0,100,1,83,
- 0,41,3,122,46,83,101,97,114,99,104,32,115,121,115,46,
- 112,97,116,104,95,104,111,111,107,115,32,102,111,114,32,97,
- 32,102,105,110,100,101,114,32,102,111,114,32,39,112,97,116,
- 104,39,46,78,122,23,115,121,115,46,112,97,116,104,95,104,
- 111,111,107,115,32,105,115,32,101,109,112,116,121,41,6,114,
- 1,0,0,0,218,10,112,97,116,104,95,104,111,111,107,115,
- 114,75,0,0,0,114,76,0,0,0,114,138,0,0,0,114,
- 117,0,0,0,41,3,114,193,0,0,0,114,44,0,0,0,
- 90,4,104,111,111,107,114,5,0,0,0,114,5,0,0,0,
- 114,8,0,0,0,218,11,95,112,97,116,104,95,104,111,111,
- 107,115,214,4,0,0,115,16,0,0,0,0,3,16,1,12,
- 1,10,1,2,1,14,1,12,1,10,2,122,22,80,97,116,
- 104,70,105,110,100,101,114,46,95,112,97,116,104,95,104,111,
- 111,107,115,99,2,0,0,0,0,0,0,0,0,0,0,0,
- 3,0,0,0,8,0,0,0,67,0,0,0,115,100,0,0,
- 0,124,1,100,1,107,2,114,42,122,12,116,0,160,1,161,
- 0,125,1,87,0,110,20,4,0,116,2,121,40,1,0,1,
- 0,1,0,89,0,100,2,83,0,48,0,122,14,116,3,106,
- 4,124,1,25,0,125,2,87,0,110,38,4,0,116,5,121,
- 94,1,0,1,0,1,0,124,0,160,6,124,1,161,1,125,
- 2,124,2,116,3,106,4,124,1,60,0,89,0,110,2,48,
- 0,124,2,83,0,41,3,122,210,71,101,116,32,116,104,101,
- 32,102,105,110,100,101,114,32,102,111,114,32,116,104,101,32,
- 112,97,116,104,32,101,110,116,114,121,32,102,114,111,109,32,
- 115,121,115,46,112,97,116,104,95,105,109,112,111,114,116,101,
- 114,95,99,97,99,104,101,46,10,10,32,32,32,32,32,32,
- 32,32,73,102,32,116,104,101,32,112,97,116,104,32,101,110,
- 116,114,121,32,105,115,32,110,111,116,32,105,110,32,116,104,
- 101,32,99,97,99,104,101,44,32,102,105,110,100,32,116,104,
- 101,32,97,112,112,114,111,112,114,105,97,116,101,32,102,105,
- 110,100,101,114,10,32,32,32,32,32,32,32,32,97,110,100,
- 32,99,97,99,104,101,32,105,116,46,32,73,102,32,110,111,
- 32,102,105,110,100,101,114,32,105,115,32,97,118,97,105,108,
- 97,98,108,101,44,32,115,116,111,114,101,32,78,111,110,101,
- 46,10,10,32,32,32,32,32,32,32,32,114,40,0,0,0,
- 78,41,7,114,4,0,0,0,114,55,0,0,0,218,17,70,
- 105,108,101,78,111,116,70,111,117,110,100,69,114,114,111,114,
- 114,1,0,0,0,114,40,1,0,0,218,8,75,101,121,69,
- 114,114,111,114,114,44,1,0,0,41,3,114,193,0,0,0,
- 114,44,0,0,0,114,42,1,0,0,114,5,0,0,0,114,
- 5,0,0,0,114,8,0,0,0,218,20,95,112,97,116,104,
- 95,105,109,112,111,114,116,101,114,95,99,97,99,104,101,227,
- 4,0,0,115,22,0,0,0,0,8,8,1,2,1,12,1,
- 12,3,8,1,2,1,14,1,12,1,10,1,16,1,122,31,
- 80,97,116,104,70,105,110,100,101,114,46,95,112,97,116,104,
- 95,105,109,112,111,114,116,101,114,95,99,97,99,104,101,99,
- 3,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,
- 4,0,0,0,67,0,0,0,115,82,0,0,0,116,0,124,
- 2,100,1,131,2,114,26,124,2,160,1,124,1,161,1,92,
- 2,125,3,125,4,110,14,124,2,160,2,124,1,161,1,125,
- 3,103,0,125,4,124,3,100,0,117,1,114,60,116,3,160,
- 4,124,1,124,3,161,2,83,0,116,3,160,5,124,1,100,
- 0,161,2,125,5,124,4,124,5,95,6,124,5,83,0,41,
- 2,78,114,137,0,0,0,41,7,114,128,0,0,0,114,137,
- 0,0,0,114,206,0,0,0,114,134,0,0,0,114,201,0,
- 0,0,114,183,0,0,0,114,178,0,0,0,41,6,114,193,
- 0,0,0,114,139,0,0,0,114,42,1,0,0,114,140,0,
- 0,0,114,141,0,0,0,114,187,0,0,0,114,5,0,0,
- 0,114,5,0,0,0,114,8,0,0,0,218,16,95,108,101,
- 103,97,99,121,95,103,101,116,95,115,112,101,99,249,4,0,
- 0,115,18,0,0,0,0,4,10,1,16,2,10,1,4,1,
- 8,1,12,1,12,1,6,1,122,27,80,97,116,104,70,105,
- 110,100,101,114,46,95,108,101,103,97,99,121,95,103,101,116,
- 95,115,112,101,99,78,99,4,0,0,0,0,0,0,0,0,
- 0,0,0,9,0,0,0,5,0,0,0,67,0,0,0,115,
- 166,0,0,0,103,0,125,4,124,2,68,0,93,134,125,5,
- 116,0,124,5,116,1,116,2,102,2,131,2,115,28,113,8,
- 124,0,160,3,124,5,161,1,125,6,124,6,100,1,117,1,
- 114,8,116,4,124,6,100,2,131,2,114,70,124,6,160,5,
- 124,1,124,3,161,2,125,7,110,12,124,0,160,6,124,1,
- 124,6,161,2,125,7,124,7,100,1,117,0,114,92,113,8,
- 124,7,106,7,100,1,117,1,114,110,124,7,2,0,1,0,
- 83,0,124,7,106,8,125,8,124,8,100,1,117,0,114,132,
- 116,9,100,3,131,1,130,1,124,4,160,10,124,8,161,1,
- 1,0,113,8,116,11,160,12,124,1,100,1,161,2,125,7,
- 124,4,124,7,95,8,124,7,83,0,41,4,122,63,70,105,
- 110,100,32,116,104,101,32,108,111,97,100,101,114,32,111,114,
- 32,110,97,109,101,115,112,97,99,101,95,112,97,116,104,32,
- 102,111,114,32,116,104,105,115,32,109,111,100,117,108,101,47,
- 112,97,99,107,97,103,101,32,110,97,109,101,46,78,114,203,
- 0,0,0,122,19,115,112,101,99,32,109,105,115,115,105,110,
- 103,32,108,111,97,100,101,114,41,13,114,161,0,0,0,114,
- 84,0,0,0,218,5,98,121,116,101,115,114,47,1,0,0,
- 114,128,0,0,0,114,203,0,0,0,114,48,1,0,0,114,
- 140,0,0,0,114,178,0,0,0,114,117,0,0,0,114,167,
- 0,0,0,114,134,0,0,0,114,183,0,0,0,41,9,114,
- 193,0,0,0,114,139,0,0,0,114,44,0,0,0,114,202,
- 0,0,0,218,14,110,97,109,101,115,112,97,99,101,95,112,
- 97,116,104,90,5,101,110,116,114,121,114,42,1,0,0,114,
- 187,0,0,0,114,141,0,0,0,114,5,0,0,0,114,5,
- 0,0,0,114,8,0,0,0,218,9,95,103,101,116,95,115,
- 112,101,99,8,5,0,0,115,40,0,0,0,0,5,4,1,
- 8,1,14,1,2,1,10,1,8,1,10,1,14,2,12,1,
- 8,1,2,1,10,1,8,1,6,1,8,1,8,5,12,2,
- 12,1,6,1,122,20,80,97,116,104,70,105,110,100,101,114,
- 46,95,103,101,116,95,115,112,101,99,99,4,0,0,0,0,
- 0,0,0,0,0,0,0,6,0,0,0,5,0,0,0,67,
- 0,0,0,115,94,0,0,0,124,2,100,1,117,0,114,14,
- 116,0,106,1,125,2,124,0,160,2,124,1,124,2,124,3,
- 161,3,125,4,124,4,100,1,117,0,114,40,100,1,83,0,
- 124,4,106,3,100,1,117,0,114,90,124,4,106,4,125,5,
- 124,5,114,86,100,1,124,4,95,5,116,6,124,1,124,5,
- 124,0,106,2,131,3,124,4,95,4,124,4,83,0,100,1,
- 83,0,124,4,83,0,41,2,122,141,84,114,121,32,116,111,
- 32,102,105,110,100,32,97,32,115,112,101,99,32,102,111,114,
- 32,39,102,117,108,108,110,97,109,101,39,32,111,110,32,115,
- 121,115,46,112,97,116,104,32,111,114,32,39,112,97,116,104,
- 39,46,10,10,32,32,32,32,32,32,32,32,84,104,101,32,
- 115,101,97,114,99,104,32,105,115,32,98,97,115,101,100,32,
- 111,110,32,115,121,115,46,112,97,116,104,95,104,111,111,107,
- 115,32,97,110,100,32,115,121,115,46,112,97,116,104,95,105,
- 109,112,111,114,116,101,114,95,99,97,99,104,101,46,10,32,
- 32,32,32,32,32,32,32,78,41,7,114,1,0,0,0,114,
- 44,0,0,0,114,51,1,0,0,114,140,0,0,0,114,178,
- 0,0,0,114,181,0,0,0,114,13,1,0,0,41,6,114,
- 193,0,0,0,114,139,0,0,0,114,44,0,0,0,114,202,
- 0,0,0,114,187,0,0,0,114,50,1,0,0,114,5,0,
- 0,0,114,5,0,0,0,114,8,0,0,0,114,203,0,0,
- 0,40,5,0,0,115,26,0,0,0,0,6,8,1,6,1,
- 14,1,8,1,4,1,10,1,6,1,4,3,6,1,16,1,
- 4,2,4,2,122,20,80,97,116,104,70,105,110,100,101,114,
- 46,102,105,110,100,95,115,112,101,99,99,3,0,0,0,0,
- 0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,67,
- 0,0,0,115,30,0,0,0,124,0,160,0,124,1,124,2,
- 161,2,125,3,124,3,100,1,117,0,114,24,100,1,83,0,
- 124,3,106,1,83,0,41,2,122,170,102,105,110,100,32,116,
- 104,101,32,109,111,100,117,108,101,32,111,110,32,115,121,115,
- 46,112,97,116,104,32,111,114,32,39,112,97,116,104,39,32,
- 98,97,115,101,100,32,111,110,32,115,121,115,46,112,97,116,
- 104,95,104,111,111,107,115,32,97,110,100,10,32,32,32,32,
- 32,32,32,32,115,121,115,46,112,97,116,104,95,105,109,112,
- 111,114,116,101,114,95,99,97,99,104,101,46,10,10,32,32,
- 32,32,32,32,32,32,84,104,105,115,32,109,101,116,104,111,
- 100,32,105,115,32,100,101,112,114,101,99,97,116,101,100,46,
- 32,32,85,115,101,32,102,105,110,100,95,115,112,101,99,40,
- 41,32,105,110,115,116,101,97,100,46,10,10,32,32,32,32,
- 32,32,32,32,78,114,204,0,0,0,114,205,0,0,0,114,
- 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,206,
- 0,0,0,64,5,0,0,115,8,0,0,0,0,8,12,1,
- 8,1,4,1,122,22,80,97,116,104,70,105,110,100,101,114,
- 46,102,105,110,100,95,109,111,100,117,108,101,99,1,0,0,
- 0,0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,
- 0,79,0,0,0,115,28,0,0,0,100,1,100,2,108,0,
- 109,1,125,3,1,0,124,3,106,2,124,1,105,0,124,2,
- 164,1,142,1,83,0,41,3,97,32,1,0,0,10,32,32,
- 32,32,32,32,32,32,70,105,110,100,32,100,105,115,116,114,
- 105,98,117,116,105,111,110,115,46,10,10,32,32,32,32,32,
- 32,32,32,82,101,116,117,114,110,32,97,110,32,105,116,101,
- 114,97,98,108,101,32,111,102,32,97,108,108,32,68,105,115,
- 116,114,105,98,117,116,105,111,110,32,105,110,115,116,97,110,
- 99,101,115,32,99,97,112,97,98,108,101,32,111,102,10,32,
- 32,32,32,32,32,32,32,108,111,97,100,105,110,103,32,116,
- 104,101,32,109,101,116,97,100,97,116,97,32,102,111,114,32,
- 112,97,99,107,97,103,101,115,32,109,97,116,99,104,105,110,
- 103,32,96,96,99,111,110,116,101,120,116,46,110,97,109,101,
- 96,96,10,32,32,32,32,32,32,32,32,40,111,114,32,97,
- 108,108,32,110,97,109,101,115,32,105,102,32,96,96,78,111,
- 110,101,96,96,32,105,110,100,105,99,97,116,101,100,41,32,
- 97,108,111,110,103,32,116,104,101,32,112,97,116,104,115,32,
- 105,110,32,116,104,101,32,108,105,115,116,10,32,32,32,32,
- 32,32,32,32,111,102,32,100,105,114,101,99,116,111,114,105,
- 101,115,32,96,96,99,111,110,116,101,120,116,46,112,97,116,
- 104,96,96,46,10,32,32,32,32,32,32,32,32,114,73,0,
- 0,0,41,1,218,18,77,101,116,97,100,97,116,97,80,97,
- 116,104,70,105,110,100,101,114,41,3,90,18,105,109,112,111,
- 114,116,108,105,98,46,109,101,116,97,100,97,116,97,114,52,
- 1,0,0,218,18,102,105,110,100,95,100,105,115,116,114,105,
- 98,117,116,105,111,110,115,41,4,114,193,0,0,0,114,119,
- 0,0,0,114,120,0,0,0,114,52,1,0,0,114,5,0,
- 0,0,114,5,0,0,0,114,8,0,0,0,114,53,1,0,
- 0,77,5,0,0,115,4,0,0,0,0,10,12,1,122,29,
- 80,97,116,104,70,105,110,100,101,114,46,102,105,110,100,95,
- 100,105,115,116,114,105,98,117,116,105,111,110,115,41,1,78,
- 41,2,78,78,41,1,78,41,13,114,125,0,0,0,114,124,
- 0,0,0,114,126,0,0,0,114,127,0,0,0,114,207,0,
- 0,0,114,38,1,0,0,114,44,1,0,0,114,47,1,0,
- 0,114,48,1,0,0,114,51,1,0,0,114,203,0,0,0,
- 114,206,0,0,0,114,53,1,0,0,114,5,0,0,0,114,
- 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,37,
- 1,0,0,200,4,0,0,115,34,0,0,0,8,2,4,2,
- 2,1,10,9,2,1,10,12,2,1,10,21,2,1,10,14,
- 2,1,12,31,2,1,12,23,2,1,12,12,2,1,114,37,
+ 7,0,0,0,114,226,0,0,0,114,7,0,0,0,114,7,
+ 0,0,0,114,8,0,0,0,114,186,0,0,0,210,4,0,
+ 0,115,4,0,0,0,4,1,255,128,122,27,95,78,97,109,
+ 101,115,112,97,99,101,76,111,97,100,101,114,46,105,115,95,
+ 112,97,99,107,97,103,101,99,2,0,0,0,0,0,0,0,
+ 0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,
+ 115,4,0,0,0,100,1,83,0,41,2,78,114,10,0,0,
+ 0,114,7,0,0,0,114,226,0,0,0,114,7,0,0,0,
+ 114,7,0,0,0,114,8,0,0,0,114,236,0,0,0,213,
+ 4,0,0,115,4,0,0,0,4,1,255,128,122,27,95,78,
+ 97,109,101,115,112,97,99,101,76,111,97,100,101,114,46,103,
+ 101,116,95,115,111,117,114,99,101,99,2,0,0,0,0,0,
+ 0,0,0,0,0,0,2,0,0,0,6,0,0,0,67,0,
+ 0,0,115,16,0,0,0,116,0,100,1,100,2,100,3,100,
+ 4,100,5,141,4,83,0,41,6,78,114,10,0,0,0,122,
+ 8,60,115,116,114,105,110,103,62,114,222,0,0,0,84,41,
+ 1,114,238,0,0,0,41,1,114,239,0,0,0,114,226,0,
+ 0,0,114,7,0,0,0,114,7,0,0,0,114,8,0,0,
+ 0,114,220,0,0,0,216,4,0,0,115,4,0,0,0,16,
+ 1,255,128,122,25,95,78,97,109,101,115,112,97,99,101,76,
+ 111,97,100,101,114,46,103,101,116,95,99,111,100,101,99,2,
+ 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,1,
+ 0,0,0,67,0,0,0,115,4,0,0,0,100,1,83,0,
+ 114,217,0,0,0,114,7,0,0,0,114,218,0,0,0,114,
+ 7,0,0,0,114,7,0,0,0,114,8,0,0,0,114,219,
+ 0,0,0,219,4,0,0,115,4,0,0,0,4,0,255,128,
+ 122,30,95,78,97,109,101,115,112,97,99,101,76,111,97,100,
+ 101,114,46,99,114,101,97,116,101,95,109,111,100,117,108,101,
+ 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
+ 0,1,0,0,0,67,0,0,0,115,4,0,0,0,100,0,
+ 83,0,114,114,0,0,0,114,7,0,0,0,114,13,1,0,
+ 0,114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,
+ 114,224,0,0,0,222,4,0,0,115,4,0,0,0,4,1,
+ 255,128,122,28,95,78,97,109,101,115,112,97,99,101,76,111,
+ 97,100,101,114,46,101,120,101,99,95,109,111,100,117,108,101,
+ 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
+ 0,4,0,0,0,67,0,0,0,115,26,0,0,0,116,0,
+ 160,1,100,1,124,0,106,2,161,2,1,0,116,0,160,3,
+ 124,0,124,1,161,2,83,0,41,3,122,98,76,111,97,100,
+ 32,97,32,110,97,109,101,115,112,97,99,101,32,109,111,100,
+ 117,108,101,46,10,10,32,32,32,32,32,32,32,32,84,104,
+ 105,115,32,109,101,116,104,111,100,32,105,115,32,100,101,112,
+ 114,101,99,97,116,101,100,46,32,32,85,115,101,32,101,120,
+ 101,99,95,109,111,100,117,108,101,40,41,32,105,110,115,116,
+ 101,97,100,46,10,10,32,32,32,32,32,32,32,32,122,38,
+ 110,97,109,101,115,112,97,99,101,32,109,111,100,117,108,101,
+ 32,108,111,97,100,101,100,32,119,105,116,104,32,112,97,116,
+ 104,32,123,33,114,125,78,41,4,114,139,0,0,0,114,153,
+ 0,0,0,114,20,1,0,0,114,225,0,0,0,114,226,0,
+ 0,0,114,7,0,0,0,114,7,0,0,0,114,8,0,0,
+ 0,114,227,0,0,0,225,4,0,0,115,10,0,0,0,6,
+ 7,4,1,4,255,12,3,255,128,122,28,95,78,97,109,101,
+ 115,112,97,99,101,76,111,97,100,101,114,46,108,111,97,100,
+ 95,109,111,100,117,108,101,78,41,12,114,130,0,0,0,114,
+ 129,0,0,0,114,131,0,0,0,114,216,0,0,0,114,213,
+ 0,0,0,114,41,1,0,0,114,186,0,0,0,114,236,0,
+ 0,0,114,220,0,0,0,114,219,0,0,0,114,224,0,0,
+ 0,114,227,0,0,0,114,7,0,0,0,114,7,0,0,0,
+ 114,7,0,0,0,114,8,0,0,0,114,40,1,0,0,197,
+ 4,0,0,115,22,0,0,0,8,0,8,1,2,3,10,1,
+ 8,8,8,3,8,3,8,3,8,3,12,3,255,128,114,40,
1,0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,3,0,0,0,64,0,0,0,115,90,0,0,
- 0,101,0,90,1,100,0,90,2,100,1,90,3,100,2,100,
- 3,132,0,90,4,100,4,100,5,132,0,90,5,101,6,90,
- 7,100,6,100,7,132,0,90,8,100,8,100,9,132,0,90,
- 9,100,19,100,11,100,12,132,1,90,10,100,13,100,14,132,
- 0,90,11,101,12,100,15,100,16,132,0,131,1,90,13,100,
- 17,100,18,132,0,90,14,100,10,83,0,41,20,218,10,70,
- 105,108,101,70,105,110,100,101,114,122,172,70,105,108,101,45,
- 98,97,115,101,100,32,102,105,110,100,101,114,46,10,10,32,
- 32,32,32,73,110,116,101,114,97,99,116,105,111,110,115,32,
- 119,105,116,104,32,116,104,101,32,102,105,108,101,32,115,121,
- 115,116,101,109,32,97,114,101,32,99,97,99,104,101,100,32,
- 102,111,114,32,112,101,114,102,111,114,109,97,110,99,101,44,
- 32,98,101,105,110,103,10,32,32,32,32,114,101,102,114,101,
- 115,104,101,100,32,119,104,101,110,32,116,104,101,32,100,105,
- 114,101,99,116,111,114,121,32,116,104,101,32,102,105,110,100,
- 101,114,32,105,115,32,104,97,110,100,108,105,110,103,32,104,
- 97,115,32,98,101,101,110,32,109,111,100,105,102,105,101,100,
- 46,10,10,32,32,32,32,99,2,0,0,0,0,0,0,0,
- 0,0,0,0,5,0,0,0,6,0,0,0,7,0,0,0,
- 115,84,0,0,0,103,0,125,3,124,2,68,0,93,32,92,
- 2,137,0,125,4,124,3,160,0,135,0,102,1,100,1,100,
- 2,132,8,124,4,68,0,131,1,161,1,1,0,113,8,124,
- 3,124,0,95,1,124,1,112,54,100,3,124,0,95,2,100,
- 4,124,0,95,3,116,4,131,0,124,0,95,5,116,4,131,
- 0,124,0,95,6,100,5,83,0,41,6,122,154,73,110,105,
- 116,105,97,108,105,122,101,32,119,105,116,104,32,116,104,101,
- 32,112,97,116,104,32,116,111,32,115,101,97,114,99,104,32,
- 111,110,32,97,110,100,32,97,32,118,97,114,105,97,98,108,
- 101,32,110,117,109,98,101,114,32,111,102,10,32,32,32,32,
- 32,32,32,32,50,45,116,117,112,108,101,115,32,99,111,110,
- 116,97,105,110,105,110,103,32,116,104,101,32,108,111,97,100,
- 101,114,32,97,110,100,32,116,104,101,32,102,105,108,101,32,
- 115,117,102,102,105,120,101,115,32,116,104,101,32,108,111,97,
- 100,101,114,10,32,32,32,32,32,32,32,32,114,101,99,111,
- 103,110,105,122,101,115,46,99,1,0,0,0,0,0,0,0,
- 0,0,0,0,2,0,0,0,3,0,0,0,51,0,0,0,
- 115,22,0,0,0,124,0,93,14,125,1,124,1,136,0,102,
- 2,86,0,1,0,113,2,100,0,83,0,114,109,0,0,0,
- 114,5,0,0,0,114,7,1,0,0,169,1,114,140,0,0,
- 0,114,5,0,0,0,114,8,0,0,0,114,10,1,0,0,
- 106,5,0,0,243,0,0,0,0,122,38,70,105,108,101,70,
- 105,110,100,101,114,46,95,95,105,110,105,116,95,95,46,60,
- 108,111,99,97,108,115,62,46,60,103,101,110,101,120,112,114,
- 62,114,71,0,0,0,114,104,0,0,0,78,41,7,114,167,
- 0,0,0,218,8,95,108,111,97,100,101,114,115,114,44,0,
- 0,0,218,11,95,112,97,116,104,95,109,116,105,109,101,218,
- 3,115,101,116,218,11,95,112,97,116,104,95,99,97,99,104,
- 101,218,19,95,114,101,108,97,120,101,100,95,112,97,116,104,
- 95,99,97,99,104,101,41,5,114,118,0,0,0,114,44,0,
- 0,0,218,14,108,111,97,100,101,114,95,100,101,116,97,105,
- 108,115,90,7,108,111,97,100,101,114,115,114,189,0,0,0,
- 114,5,0,0,0,114,55,1,0,0,114,8,0,0,0,114,
- 209,0,0,0,100,5,0,0,115,16,0,0,0,0,4,4,
- 1,12,1,26,1,6,2,10,1,6,1,8,1,122,19,70,
- 105,108,101,70,105,110,100,101,114,46,95,95,105,110,105,116,
- 95,95,99,1,0,0,0,0,0,0,0,0,0,0,0,1,
- 0,0,0,2,0,0,0,67,0,0,0,115,10,0,0,0,
- 100,1,124,0,95,0,100,2,83,0,41,3,122,31,73,110,
- 118,97,108,105,100,97,116,101,32,116,104,101,32,100,105,114,
- 101,99,116,111,114,121,32,109,116,105,109,101,46,114,104,0,
- 0,0,78,41,1,114,58,1,0,0,114,246,0,0,0,114,
- 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,38,
- 1,0,0,114,5,0,0,115,2,0,0,0,0,2,122,28,
- 70,105,108,101,70,105,110,100,101,114,46,105,110,118,97,108,
- 105,100,97,116,101,95,99,97,99,104,101,115,99,2,0,0,
- 0,0,0,0,0,0,0,0,0,3,0,0,0,3,0,0,
- 0,67,0,0,0,115,42,0,0,0,124,0,160,0,124,1,
- 161,1,125,2,124,2,100,1,117,0,114,26,100,1,103,0,
- 102,2,83,0,124,2,106,1,124,2,106,2,112,38,103,0,
- 102,2,83,0,41,2,122,197,84,114,121,32,116,111,32,102,
- 105,110,100,32,97,32,108,111,97,100,101,114,32,102,111,114,
- 32,116,104,101,32,115,112,101,99,105,102,105,101,100,32,109,
- 111,100,117,108,101,44,32,111,114,32,116,104,101,32,110,97,
- 109,101,115,112,97,99,101,10,32,32,32,32,32,32,32,32,
- 112,97,99,107,97,103,101,32,112,111,114,116,105,111,110,115,
- 46,32,82,101,116,117,114,110,115,32,40,108,111,97,100,101,
- 114,44,32,108,105,115,116,45,111,102,45,112,111,114,116,105,
- 111,110,115,41,46,10,10,32,32,32,32,32,32,32,32,84,
- 104,105,115,32,109,101,116,104,111,100,32,105,115,32,100,101,
- 112,114,101,99,97,116,101,100,46,32,32,85,115,101,32,102,
- 105,110,100,95,115,112,101,99,40,41,32,105,110,115,116,101,
- 97,100,46,10,10,32,32,32,32,32,32,32,32,78,41,3,
- 114,203,0,0,0,114,140,0,0,0,114,178,0,0,0,41,
- 3,114,118,0,0,0,114,139,0,0,0,114,187,0,0,0,
- 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,
- 137,0,0,0,120,5,0,0,115,8,0,0,0,0,7,10,
- 1,8,1,8,1,122,22,70,105,108,101,70,105,110,100,101,
+ 0,0,0,0,4,0,0,0,64,0,0,0,115,118,0,0,
+ 0,101,0,90,1,100,0,90,2,100,1,90,3,101,4,100,
+ 2,100,3,132,0,131,1,90,5,101,4,100,4,100,5,132,
+ 0,131,1,90,6,101,7,100,6,100,7,132,0,131,1,90,
+ 8,101,7,100,8,100,9,132,0,131,1,90,9,101,7,100,
+ 19,100,11,100,12,132,1,131,1,90,10,101,7,100,20,100,
+ 13,100,14,132,1,131,1,90,11,101,7,100,21,100,15,100,
+ 16,132,1,131,1,90,12,101,4,100,17,100,18,132,0,131,
+ 1,90,13,100,10,83,0,41,22,218,10,80,97,116,104,70,
+ 105,110,100,101,114,122,62,77,101,116,97,32,112,97,116,104,
+ 32,102,105,110,100,101,114,32,102,111,114,32,115,121,115,46,
+ 112,97,116,104,32,97,110,100,32,112,97,99,107,97,103,101,
+ 32,95,95,112,97,116,104,95,95,32,97,116,116,114,105,98,
+ 117,116,101,115,46,99,0,0,0,0,0,0,0,0,0,0,
+ 0,0,2,0,0,0,4,0,0,0,67,0,0,0,115,64,
+ 0,0,0,116,0,116,1,106,2,160,3,161,0,131,1,68,
+ 0,93,44,92,2,125,0,125,1,124,1,100,1,117,0,114,
+ 40,116,1,106,2,124,0,61,0,113,14,116,4,124,1,100,
+ 2,131,2,114,58,124,1,160,5,161,0,1,0,113,14,100,
+ 1,83,0,41,3,122,125,67,97,108,108,32,116,104,101,32,
+ 105,110,118,97,108,105,100,97,116,101,95,99,97,99,104,101,
+ 115,40,41,32,109,101,116,104,111,100,32,111,110,32,97,108,
+ 108,32,112,97,116,104,32,101,110,116,114,121,32,102,105,110,
+ 100,101,114,115,10,32,32,32,32,32,32,32,32,115,116,111,
+ 114,101,100,32,105,110,32,115,121,115,46,112,97,116,104,95,
+ 105,109,112,111,114,116,101,114,95,99,97,99,104,101,115,32,
+ 40,119,104,101,114,101,32,105,109,112,108,101,109,101,110,116,
+ 101,100,41,46,78,218,17,105,110,118,97,108,105,100,97,116,
+ 101,95,99,97,99,104,101,115,41,6,218,4,108,105,115,116,
+ 114,15,0,0,0,218,19,112,97,116,104,95,105,109,112,111,
+ 114,116,101,114,95,99,97,99,104,101,218,5,105,116,101,109,
+ 115,114,133,0,0,0,114,43,1,0,0,41,2,114,121,0,
+ 0,0,218,6,102,105,110,100,101,114,114,7,0,0,0,114,
+ 7,0,0,0,114,8,0,0,0,114,43,1,0,0,244,4,
+ 0,0,115,16,0,0,0,22,4,8,1,10,1,10,1,8,
+ 1,2,128,4,252,255,128,122,28,80,97,116,104,70,105,110,
+ 100,101,114,46,105,110,118,97,108,105,100,97,116,101,95,99,
+ 97,99,104,101,115,99,1,0,0,0,0,0,0,0,0,0,
+ 0,0,2,0,0,0,9,0,0,0,67,0,0,0,115,76,
+ 0,0,0,116,0,106,1,100,1,117,1,114,28,116,0,106,
+ 1,115,28,116,2,160,3,100,2,116,4,161,2,1,0,116,
+ 0,106,1,68,0,93,34,125,1,122,14,124,1,124,0,131,
+ 1,87,0,2,0,1,0,83,0,4,0,116,5,121,74,1,
+ 0,1,0,1,0,89,0,113,34,100,1,83,0,119,0,41,
+ 3,122,46,83,101,97,114,99,104,32,115,121,115,46,112,97,
+ 116,104,95,104,111,111,107,115,32,102,111,114,32,97,32,102,
+ 105,110,100,101,114,32,102,111,114,32,39,112,97,116,104,39,
+ 46,78,122,23,115,121,115,46,112,97,116,104,95,104,111,111,
+ 107,115,32,105,115,32,101,109,112,116,121,41,6,114,15,0,
+ 0,0,218,10,112,97,116,104,95,104,111,111,107,115,114,81,
+ 0,0,0,114,82,0,0,0,114,142,0,0,0,114,122,0,
+ 0,0,41,2,114,52,0,0,0,90,4,104,111,111,107,114,
+ 7,0,0,0,114,7,0,0,0,114,8,0,0,0,218,11,
+ 95,112,97,116,104,95,104,111,111,107,115,254,4,0,0,115,
+ 20,0,0,0,16,3,12,1,10,1,2,1,14,1,12,1,
+ 4,1,4,2,2,253,255,128,122,22,80,97,116,104,70,105,
+ 110,100,101,114,46,95,112,97,116,104,95,104,111,111,107,115,
+ 99,2,0,0,0,0,0,0,0,0,0,0,0,3,0,0,
+ 0,8,0,0,0,67,0,0,0,115,100,0,0,0,124,1,
+ 100,1,107,2,114,40,122,12,116,0,160,1,161,0,125,1,
+ 87,0,110,18,4,0,116,2,121,98,1,0,1,0,1,0,
+ 89,0,100,2,83,0,122,16,116,3,106,4,124,1,25,0,
+ 125,2,87,0,124,2,83,0,4,0,116,5,121,96,1,0,
+ 1,0,1,0,124,0,160,6,124,1,161,1,125,2,124,2,
+ 116,3,106,4,124,1,60,0,89,0,124,2,83,0,119,0,
+ 119,0,41,3,122,210,71,101,116,32,116,104,101,32,102,105,
+ 110,100,101,114,32,102,111,114,32,116,104,101,32,112,97,116,
+ 104,32,101,110,116,114,121,32,102,114,111,109,32,115,121,115,
+ 46,112,97,116,104,95,105,109,112,111,114,116,101,114,95,99,
+ 97,99,104,101,46,10,10,32,32,32,32,32,32,32,32,73,
+ 102,32,116,104,101,32,112,97,116,104,32,101,110,116,114,121,
+ 32,105,115,32,110,111,116,32,105,110,32,116,104,101,32,99,
+ 97,99,104,101,44,32,102,105,110,100,32,116,104,101,32,97,
+ 112,112,114,111,112,114,105,97,116,101,32,102,105,110,100,101,
+ 114,10,32,32,32,32,32,32,32,32,97,110,100,32,99,97,
+ 99,104,101,32,105,116,46,32,73,102,32,110,111,32,102,105,
+ 110,100,101,114,32,105,115,32,97,118,97,105,108,97,98,108,
+ 101,44,32,115,116,111,114,101,32,78,111,110,101,46,10,10,
+ 32,32,32,32,32,32,32,32,114,10,0,0,0,78,41,7,
+ 114,18,0,0,0,114,63,0,0,0,218,17,70,105,108,101,
+ 78,111,116,70,111,117,110,100,69,114,114,111,114,114,15,0,
+ 0,0,114,45,1,0,0,218,8,75,101,121,69,114,114,111,
+ 114,114,49,1,0,0,41,3,114,202,0,0,0,114,52,0,
+ 0,0,114,47,1,0,0,114,7,0,0,0,114,7,0,0,
+ 0,114,8,0,0,0,218,20,95,112,97,116,104,95,105,109,
+ 112,111,114,116,101,114,95,99,97,99,104,101,11,5,0,0,
+ 115,30,0,0,0,8,8,2,1,12,1,12,1,6,3,2,
+ 1,12,1,4,4,12,253,10,1,12,1,4,1,2,253,2,
+ 250,255,128,122,31,80,97,116,104,70,105,110,100,101,114,46,
+ 95,112,97,116,104,95,105,109,112,111,114,116,101,114,95,99,
+ 97,99,104,101,99,3,0,0,0,0,0,0,0,0,0,0,
+ 0,6,0,0,0,4,0,0,0,67,0,0,0,115,82,0,
+ 0,0,116,0,124,2,100,1,131,2,114,26,124,2,160,1,
+ 124,1,161,1,92,2,125,3,125,4,110,14,124,2,160,2,
+ 124,1,161,1,125,3,103,0,125,4,124,3,100,0,117,1,
+ 114,60,116,3,160,4,124,1,124,3,161,2,83,0,116,3,
+ 160,5,124,1,100,0,161,2,125,5,124,4,124,5,95,6,
+ 124,5,83,0,41,2,78,114,141,0,0,0,41,7,114,133,
+ 0,0,0,114,141,0,0,0,114,210,0,0,0,114,139,0,
+ 0,0,114,205,0,0,0,114,187,0,0,0,114,182,0,0,
+ 0,41,6,114,202,0,0,0,114,143,0,0,0,114,47,1,
+ 0,0,114,144,0,0,0,114,145,0,0,0,114,191,0,0,
+ 0,114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,
+ 218,16,95,108,101,103,97,99,121,95,103,101,116,95,115,112,
+ 101,99,33,5,0,0,115,20,0,0,0,10,4,16,1,10,
+ 2,4,1,8,1,12,1,12,1,6,1,4,1,255,128,122,
+ 27,80,97,116,104,70,105,110,100,101,114,46,95,108,101,103,
+ 97,99,121,95,103,101,116,95,115,112,101,99,78,99,4,0,
+ 0,0,0,0,0,0,0,0,0,0,9,0,0,0,5,0,
+ 0,0,67,0,0,0,115,166,0,0,0,103,0,125,4,124,
+ 2,68,0,93,134,125,5,116,0,124,5,116,1,116,2,102,
+ 2,131,2,115,28,113,8,124,0,160,3,124,5,161,1,125,
+ 6,124,6,100,1,117,1,114,142,116,4,124,6,100,2,131,
+ 2,114,70,124,6,160,5,124,1,124,3,161,2,125,7,110,
+ 12,124,0,160,6,124,1,124,6,161,2,125,7,124,7,100,
+ 1,117,0,114,92,113,8,124,7,106,7,100,1,117,1,114,
+ 110,124,7,2,0,1,0,83,0,124,7,106,8,125,8,124,
+ 8,100,1,117,0,114,132,116,9,100,3,131,1,130,1,124,
+ 4,160,10,124,8,161,1,1,0,113,8,116,11,160,12,124,
+ 1,100,1,161,2,125,7,124,4,124,7,95,8,124,7,83,
+ 0,41,4,122,63,70,105,110,100,32,116,104,101,32,108,111,
+ 97,100,101,114,32,111,114,32,110,97,109,101,115,112,97,99,
+ 101,95,112,97,116,104,32,102,111,114,32,116,104,105,115,32,
+ 109,111,100,117,108,101,47,112,97,99,107,97,103,101,32,110,
+ 97,109,101,46,78,114,207,0,0,0,122,19,115,112,101,99,
+ 32,109,105,115,115,105,110,103,32,108,111,97,100,101,114,41,
+ 13,114,165,0,0,0,114,90,0,0,0,218,5,98,121,116,
+ 101,115,114,52,1,0,0,114,133,0,0,0,114,207,0,0,
+ 0,114,53,1,0,0,114,144,0,0,0,114,182,0,0,0,
+ 114,122,0,0,0,114,171,0,0,0,114,139,0,0,0,114,
+ 187,0,0,0,41,9,114,202,0,0,0,114,143,0,0,0,
+ 114,52,0,0,0,114,206,0,0,0,218,14,110,97,109,101,
+ 115,112,97,99,101,95,112,97,116,104,90,5,101,110,116,114,
+ 121,114,47,1,0,0,114,191,0,0,0,114,145,0,0,0,
+ 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,218,
+ 9,95,103,101,116,95,115,112,101,99,48,5,0,0,115,44,
+ 0,0,0,4,5,8,1,14,1,2,1,10,1,8,1,10,
+ 1,14,1,12,2,8,1,2,1,10,1,8,1,6,1,8,
+ 1,8,1,10,5,2,128,12,2,6,1,4,1,255,128,122,
+ 20,80,97,116,104,70,105,110,100,101,114,46,95,103,101,116,
+ 95,115,112,101,99,99,4,0,0,0,0,0,0,0,0,0,
+ 0,0,6,0,0,0,5,0,0,0,67,0,0,0,115,94,
+ 0,0,0,124,2,100,1,117,0,114,14,116,0,106,1,125,
+ 2,124,0,160,2,124,1,124,2,124,3,161,3,125,4,124,
+ 4,100,1,117,0,114,40,100,1,83,0,124,4,106,3,100,
+ 1,117,0,114,90,124,4,106,4,125,5,124,5,114,86,100,
+ 1,124,4,95,5,116,6,124,1,124,5,124,0,106,2,131,
+ 3,124,4,95,4,124,4,83,0,100,1,83,0,124,4,83,
+ 0,41,2,122,141,84,114,121,32,116,111,32,102,105,110,100,
+ 32,97,32,115,112,101,99,32,102,111,114,32,39,102,117,108,
+ 108,110,97,109,101,39,32,111,110,32,115,121,115,46,112,97,
+ 116,104,32,111,114,32,39,112,97,116,104,39,46,10,10,32,
+ 32,32,32,32,32,32,32,84,104,101,32,115,101,97,114,99,
+ 104,32,105,115,32,98,97,115,101,100,32,111,110,32,115,121,
+ 115,46,112,97,116,104,95,104,111,111,107,115,32,97,110,100,
+ 32,115,121,115,46,112,97,116,104,95,105,109,112,111,114,116,
+ 101,114,95,99,97,99,104,101,46,10,32,32,32,32,32,32,
+ 32,32,78,41,7,114,15,0,0,0,114,52,0,0,0,114,
+ 56,1,0,0,114,144,0,0,0,114,182,0,0,0,114,185,
+ 0,0,0,114,18,1,0,0,41,6,114,202,0,0,0,114,
+ 143,0,0,0,114,52,0,0,0,114,206,0,0,0,114,191,
+ 0,0,0,114,55,1,0,0,114,7,0,0,0,114,7,0,
+ 0,0,114,8,0,0,0,114,207,0,0,0,80,5,0,0,
+ 115,28,0,0,0,8,6,6,1,14,1,8,1,4,1,10,
+ 1,6,1,4,1,6,3,16,1,4,1,4,2,4,2,255,
+ 128,122,20,80,97,116,104,70,105,110,100,101,114,46,102,105,
+ 110,100,95,115,112,101,99,99,3,0,0,0,0,0,0,0,
+ 0,0,0,0,4,0,0,0,4,0,0,0,67,0,0,0,
+ 115,30,0,0,0,124,0,160,0,124,1,124,2,161,2,125,
+ 3,124,3,100,1,117,0,114,24,100,1,83,0,124,3,106,
+ 1,83,0,41,2,122,170,102,105,110,100,32,116,104,101,32,
+ 109,111,100,117,108,101,32,111,110,32,115,121,115,46,112,97,
+ 116,104,32,111,114,32,39,112,97,116,104,39,32,98,97,115,
+ 101,100,32,111,110,32,115,121,115,46,112,97,116,104,95,104,
+ 111,111,107,115,32,97,110,100,10,32,32,32,32,32,32,32,
+ 32,115,121,115,46,112,97,116,104,95,105,109,112,111,114,116,
+ 101,114,95,99,97,99,104,101,46,10,10,32,32,32,32,32,
+ 32,32,32,84,104,105,115,32,109,101,116,104,111,100,32,105,
+ 115,32,100,101,112,114,101,99,97,116,101,100,46,32,32,85,
+ 115,101,32,102,105,110,100,95,115,112,101,99,40,41,32,105,
+ 110,115,116,101,97,100,46,10,10,32,32,32,32,32,32,32,
+ 32,78,114,208,0,0,0,114,209,0,0,0,114,7,0,0,
+ 0,114,7,0,0,0,114,8,0,0,0,114,210,0,0,0,
+ 104,5,0,0,115,10,0,0,0,12,8,8,1,4,1,6,
+ 1,255,128,122,22,80,97,116,104,70,105,110,100,101,114,46,
+ 102,105,110,100,95,109,111,100,117,108,101,99,0,0,0,0,
+ 0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,0,
+ 79,0,0,0,115,28,0,0,0,100,1,100,2,108,0,109,
+ 1,125,2,1,0,124,2,106,2,124,0,105,0,124,1,164,
+ 1,142,1,83,0,41,4,97,32,1,0,0,10,32,32,32,
+ 32,32,32,32,32,70,105,110,100,32,100,105,115,116,114,105,
+ 98,117,116,105,111,110,115,46,10,10,32,32,32,32,32,32,
+ 32,32,82,101,116,117,114,110,32,97,110,32,105,116,101,114,
+ 97,98,108,101,32,111,102,32,97,108,108,32,68,105,115,116,
+ 114,105,98,117,116,105,111,110,32,105,110,115,116,97,110,99,
+ 101,115,32,99,97,112,97,98,108,101,32,111,102,10,32,32,
+ 32,32,32,32,32,32,108,111,97,100,105,110,103,32,116,104,
+ 101,32,109,101,116,97,100,97,116,97,32,102,111,114,32,112,
+ 97,99,107,97,103,101,115,32,109,97,116,99,104,105,110,103,
+ 32,96,96,99,111,110,116,101,120,116,46,110,97,109,101,96,
+ 96,10,32,32,32,32,32,32,32,32,40,111,114,32,97,108,
+ 108,32,110,97,109,101,115,32,105,102,32,96,96,78,111,110,
+ 101,96,96,32,105,110,100,105,99,97,116,101,100,41,32,97,
+ 108,111,110,103,32,116,104,101,32,112,97,116,104,115,32,105,
+ 110,32,116,104,101,32,108,105,115,116,10,32,32,32,32,32,
+ 32,32,32,111,102,32,100,105,114,101,99,116,111,114,105,101,
+ 115,32,96,96,99,111,110,116,101,120,116,46,112,97,116,104,
+ 96,96,46,10,32,32,32,32,32,32,32,32,114,0,0,0,
+ 0,41,1,218,18,77,101,116,97,100,97,116,97,80,97,116,
+ 104,70,105,110,100,101,114,78,41,3,90,18,105,109,112,111,
+ 114,116,108,105,98,46,109,101,116,97,100,97,116,97,114,57,
+ 1,0,0,218,18,102,105,110,100,95,100,105,115,116,114,105,
+ 98,117,116,105,111,110,115,41,3,114,124,0,0,0,114,125,
+ 0,0,0,114,57,1,0,0,114,7,0,0,0,114,7,0,
+ 0,0,114,8,0,0,0,114,58,1,0,0,117,5,0,0,
+ 115,6,0,0,0,12,10,16,1,255,128,122,29,80,97,116,
+ 104,70,105,110,100,101,114,46,102,105,110,100,95,100,105,115,
+ 116,114,105,98,117,116,105,111,110,115,41,1,78,41,2,78,
+ 78,41,1,78,41,14,114,130,0,0,0,114,129,0,0,0,
+ 114,131,0,0,0,114,132,0,0,0,114,213,0,0,0,114,
+ 43,1,0,0,114,49,1,0,0,114,214,0,0,0,114,52,
+ 1,0,0,114,53,1,0,0,114,56,1,0,0,114,207,0,
+ 0,0,114,210,0,0,0,114,58,1,0,0,114,7,0,0,
+ 0,114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,
+ 114,42,1,0,0,240,4,0,0,115,38,0,0,0,8,0,
+ 4,2,2,2,10,1,2,9,10,1,2,12,10,1,2,21,
+ 10,1,2,14,12,1,2,31,12,1,2,23,12,1,2,12,
+ 14,1,255,128,114,42,1,0,0,99,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,3,0,0,0,64,0,
+ 0,0,115,90,0,0,0,101,0,90,1,100,0,90,2,100,
+ 1,90,3,100,2,100,3,132,0,90,4,100,4,100,5,132,
+ 0,90,5,101,6,90,7,100,6,100,7,132,0,90,8,100,
+ 8,100,9,132,0,90,9,100,19,100,11,100,12,132,1,90,
+ 10,100,13,100,14,132,0,90,11,101,12,100,15,100,16,132,
+ 0,131,1,90,13,100,17,100,18,132,0,90,14,100,10,83,
+ 0,41,20,218,10,70,105,108,101,70,105,110,100,101,114,122,
+ 172,70,105,108,101,45,98,97,115,101,100,32,102,105,110,100,
+ 101,114,46,10,10,32,32,32,32,73,110,116,101,114,97,99,
+ 116,105,111,110,115,32,119,105,116,104,32,116,104,101,32,102,
+ 105,108,101,32,115,121,115,116,101,109,32,97,114,101,32,99,
+ 97,99,104,101,100,32,102,111,114,32,112,101,114,102,111,114,
+ 109,97,110,99,101,44,32,98,101,105,110,103,10,32,32,32,
+ 32,114,101,102,114,101,115,104,101,100,32,119,104,101,110,32,
+ 116,104,101,32,100,105,114,101,99,116,111,114,121,32,116,104,
+ 101,32,102,105,110,100,101,114,32,105,115,32,104,97,110,100,
+ 108,105,110,103,32,104,97,115,32,98,101,101,110,32,109,111,
+ 100,105,102,105,101,100,46,10,10,32,32,32,32,99,2,0,
+ 0,0,0,0,0,0,0,0,0,0,5,0,0,0,6,0,
+ 0,0,7,0,0,0,115,84,0,0,0,103,0,125,3,124,
+ 2,68,0,93,32,92,2,137,0,125,4,124,3,160,0,135,
+ 0,102,1,100,1,100,2,132,8,124,4,68,0,131,1,161,
+ 1,1,0,113,8,124,3,124,0,95,1,124,1,112,54,100,
+ 3,124,0,95,2,100,4,124,0,95,3,116,4,131,0,124,
+ 0,95,5,116,4,131,0,124,0,95,6,100,5,83,0,41,
+ 6,122,154,73,110,105,116,105,97,108,105,122,101,32,119,105,
+ 116,104,32,116,104,101,32,112,97,116,104,32,116,111,32,115,
+ 101,97,114,99,104,32,111,110,32,97,110,100,32,97,32,118,
+ 97,114,105,97,98,108,101,32,110,117,109,98,101,114,32,111,
+ 102,10,32,32,32,32,32,32,32,32,50,45,116,117,112,108,
+ 101,115,32,99,111,110,116,97,105,110,105,110,103,32,116,104,
+ 101,32,108,111,97,100,101,114,32,97,110,100,32,116,104,101,
+ 32,102,105,108,101,32,115,117,102,102,105,120,101,115,32,116,
+ 104,101,32,108,111,97,100,101,114,10,32,32,32,32,32,32,
+ 32,32,114,101,99,111,103,110,105,122,101,115,46,99,1,0,
+ 0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,0,
+ 0,0,51,0,0,0,115,22,0,0,0,124,0,93,14,125,
+ 1,124,1,136,0,102,2,86,0,1,0,113,2,100,0,83,
+ 0,114,114,0,0,0,114,7,0,0,0,114,14,1,0,0,
+ 169,1,114,144,0,0,0,114,7,0,0,0,114,8,0,0,
+ 0,114,9,0,0,0,146,5,0,0,115,4,0,0,0,22,
+ 0,255,128,122,38,70,105,108,101,70,105,110,100,101,114,46,
+ 95,95,105,110,105,116,95,95,46,60,108,111,99,97,108,115,
+ 62,46,60,103,101,110,101,120,112,114,62,114,79,0,0,0,
+ 114,109,0,0,0,78,41,7,114,171,0,0,0,218,8,95,
+ 108,111,97,100,101,114,115,114,52,0,0,0,218,11,95,112,
+ 97,116,104,95,109,116,105,109,101,218,3,115,101,116,218,11,
+ 95,112,97,116,104,95,99,97,99,104,101,218,19,95,114,101,
+ 108,97,120,101,100,95,112,97,116,104,95,99,97,99,104,101,
+ 41,5,114,123,0,0,0,114,52,0,0,0,218,14,108,111,
+ 97,100,101,114,95,100,101,116,97,105,108,115,90,7,108,111,
+ 97,100,101,114,115,114,193,0,0,0,114,7,0,0,0,114,
+ 60,1,0,0,114,8,0,0,0,114,216,0,0,0,140,5,
+ 0,0,115,18,0,0,0,4,4,12,1,26,1,6,1,10,
+ 2,6,1,8,1,12,1,255,128,122,19,70,105,108,101,70,
+ 105,110,100,101,114,46,95,95,105,110,105,116,95,95,99,1,
+ 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,
+ 0,0,0,67,0,0,0,115,10,0,0,0,100,1,124,0,
+ 95,0,100,2,83,0,41,3,122,31,73,110,118,97,108,105,
+ 100,97,116,101,32,116,104,101,32,100,105,114,101,99,116,111,
+ 114,121,32,109,116,105,109,101,46,114,109,0,0,0,78,41,
+ 1,114,62,1,0,0,114,253,0,0,0,114,7,0,0,0,
+ 114,7,0,0,0,114,8,0,0,0,114,43,1,0,0,154,
+ 5,0,0,115,4,0,0,0,10,2,255,128,122,28,70,105,
+ 108,101,70,105,110,100,101,114,46,105,110,118,97,108,105,100,
+ 97,116,101,95,99,97,99,104,101,115,99,2,0,0,0,0,
+ 0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,67,
+ 0,0,0,115,42,0,0,0,124,0,160,0,124,1,161,1,
+ 125,2,124,2,100,1,117,0,114,26,100,1,103,0,102,2,
+ 83,0,124,2,106,1,124,2,106,2,112,38,103,0,102,2,
+ 83,0,41,2,122,197,84,114,121,32,116,111,32,102,105,110,
+ 100,32,97,32,108,111,97,100,101,114,32,102,111,114,32,116,
+ 104,101,32,115,112,101,99,105,102,105,101,100,32,109,111,100,
+ 117,108,101,44,32,111,114,32,116,104,101,32,110,97,109,101,
+ 115,112,97,99,101,10,32,32,32,32,32,32,32,32,112,97,
+ 99,107,97,103,101,32,112,111,114,116,105,111,110,115,46,32,
+ 82,101,116,117,114,110,115,32,40,108,111,97,100,101,114,44,
+ 32,108,105,115,116,45,111,102,45,112,111,114,116,105,111,110,
+ 115,41,46,10,10,32,32,32,32,32,32,32,32,84,104,105,
+ 115,32,109,101,116,104,111,100,32,105,115,32,100,101,112,114,
+ 101,99,97,116,101,100,46,32,32,85,115,101,32,102,105,110,
+ 100,95,115,112,101,99,40,41,32,105,110,115,116,101,97,100,
+ 46,10,10,32,32,32,32,32,32,32,32,78,41,3,114,207,
+ 0,0,0,114,144,0,0,0,114,182,0,0,0,41,3,114,
+ 123,0,0,0,114,143,0,0,0,114,191,0,0,0,114,7,
+ 0,0,0,114,7,0,0,0,114,8,0,0,0,114,141,0,
+ 0,0,160,5,0,0,115,10,0,0,0,10,7,8,1,8,
+ 1,16,1,255,128,122,22,70,105,108,101,70,105,110,100,101,
114,46,102,105,110,100,95,108,111,97,100,101,114,99,6,0,
0,0,0,0,0,0,0,0,0,0,7,0,0,0,6,0,
0,0,67,0,0,0,115,26,0,0,0,124,1,124,2,124,
3,131,2,125,6,116,0,124,2,124,3,124,6,124,4,100,
- 1,141,4,83,0,41,2,78,114,177,0,0,0,41,1,114,
- 190,0,0,0,41,7,114,118,0,0,0,114,188,0,0,0,
- 114,139,0,0,0,114,44,0,0,0,90,4,115,109,115,108,
- 114,202,0,0,0,114,140,0,0,0,114,5,0,0,0,114,
- 5,0,0,0,114,8,0,0,0,114,51,1,0,0,132,5,
- 0,0,115,8,0,0,0,0,1,10,1,8,1,2,255,122,
- 20,70,105,108,101,70,105,110,100,101,114,46,95,103,101,116,
- 95,115,112,101,99,78,99,3,0,0,0,0,0,0,0,0,
- 0,0,0,14,0,0,0,8,0,0,0,67,0,0,0,115,
- 92,1,0,0,100,1,125,3,124,1,160,0,100,2,161,1,
- 100,3,25,0,125,4,122,24,116,1,124,0,106,2,112,34,
- 116,3,160,4,161,0,131,1,106,5,125,5,87,0,110,22,
- 4,0,116,6,121,64,1,0,1,0,1,0,100,4,125,5,
- 89,0,110,2,48,0,124,5,124,0,106,7,107,3,114,90,
+ 1,141,4,83,0,41,2,78,114,181,0,0,0,41,1,114,
+ 194,0,0,0,41,7,114,123,0,0,0,114,192,0,0,0,
+ 114,143,0,0,0,114,52,0,0,0,90,4,115,109,115,108,
+ 114,206,0,0,0,114,144,0,0,0,114,7,0,0,0,114,
+ 7,0,0,0,114,8,0,0,0,114,56,1,0,0,172,5,
+ 0,0,115,10,0,0,0,10,1,8,1,2,1,6,255,255,
+ 128,122,20,70,105,108,101,70,105,110,100,101,114,46,95,103,
+ 101,116,95,115,112,101,99,78,99,3,0,0,0,0,0,0,
+ 0,0,0,0,0,14,0,0,0,8,0,0,0,67,0,0,
+ 0,115,100,1,0,0,100,1,125,3,124,1,160,0,100,2,
+ 161,1,100,3,25,0,125,4,122,24,116,1,124,0,106,2,
+ 112,34,116,3,160,4,161,0,131,1,106,5,125,5,87,0,
+ 110,20,4,0,116,6,144,1,121,98,1,0,1,0,1,0,
+ 100,4,125,5,89,0,124,5,124,0,106,7,107,3,114,88,
124,0,160,8,161,0,1,0,124,5,124,0,95,7,116,9,
- 131,0,114,112,124,0,106,10,125,6,124,4,160,11,161,0,
+ 131,0,114,110,124,0,106,10,125,6,124,4,160,11,161,0,
125,7,110,10,124,0,106,12,125,6,124,4,125,7,124,7,
124,6,118,0,114,214,116,13,124,0,106,2,124,4,131,2,
- 125,8,124,0,106,14,68,0,93,56,92,2,125,9,125,10,
+ 125,8,124,0,106,14,68,0,93,58,92,2,125,9,125,10,
100,5,124,9,23,0,125,11,116,13,124,8,124,11,131,2,
- 125,12,116,15,124,12,131,1,114,148,124,0,160,16,124,10,
+ 125,12,116,15,124,12,131,1,114,204,124,0,160,16,124,10,
124,1,124,12,124,8,103,1,124,2,161,5,2,0,1,0,
- 83,0,116,17,124,8,131,1,125,3,124,0,106,14,68,0,
- 93,80,92,2,125,9,125,10,116,13,124,0,106,2,124,4,
- 124,9,23,0,131,2,125,12,116,18,106,19,100,6,124,12,
- 100,3,100,7,141,3,1,0,124,7,124,9,23,0,124,6,
- 118,0,114,220,116,15,124,12,131,1,114,220,124,0,160,16,
- 124,10,124,1,124,12,100,8,124,2,161,5,2,0,1,0,
- 83,0,124,3,144,1,114,88,116,18,160,19,100,9,124,8,
- 161,2,1,0,116,18,160,20,124,1,100,8,161,2,125,13,
- 124,8,103,1,124,13,95,21,124,13,83,0,100,8,83,0,
- 41,10,122,111,84,114,121,32,116,111,32,102,105,110,100,32,
- 97,32,115,112,101,99,32,102,111,114,32,116,104,101,32,115,
- 112,101,99,105,102,105,101,100,32,109,111,100,117,108,101,46,
- 10,10,32,32,32,32,32,32,32,32,82,101,116,117,114,110,
- 115,32,116,104,101,32,109,97,116,99,104,105,110,103,32,115,
- 112,101,99,44,32,111,114,32,78,111,110,101,32,105,102,32,
- 110,111,116,32,102,111,117,110,100,46,10,32,32,32,32,32,
- 32,32,32,70,114,71,0,0,0,114,28,0,0,0,114,104,
- 0,0,0,114,209,0,0,0,122,9,116,114,121,105,110,103,
- 32,123,125,41,1,90,9,118,101,114,98,111,115,105,116,121,
- 78,122,25,112,111,115,115,105,98,108,101,32,110,97,109,101,
- 115,112,97,99,101,32,102,111,114,32,123,125,41,22,114,41,
- 0,0,0,114,49,0,0,0,114,44,0,0,0,114,4,0,
- 0,0,114,55,0,0,0,114,0,1,0,0,114,50,0,0,
- 0,114,58,1,0,0,218,11,95,102,105,108,108,95,99,97,
- 99,104,101,114,9,0,0,0,114,61,1,0,0,114,105,0,
- 0,0,114,60,1,0,0,114,38,0,0,0,114,57,1,0,
- 0,114,54,0,0,0,114,51,1,0,0,114,56,0,0,0,
- 114,134,0,0,0,114,149,0,0,0,114,183,0,0,0,114,
- 178,0,0,0,41,14,114,118,0,0,0,114,139,0,0,0,
- 114,202,0,0,0,90,12,105,115,95,110,97,109,101,115,112,
- 97,99,101,90,11,116,97,105,108,95,109,111,100,117,108,101,
- 114,169,0,0,0,90,5,99,97,99,104,101,90,12,99,97,
- 99,104,101,95,109,111,100,117,108,101,90,9,98,97,115,101,
- 95,112,97,116,104,114,8,1,0,0,114,188,0,0,0,90,
- 13,105,110,105,116,95,102,105,108,101,110,97,109,101,90,9,
- 102,117,108,108,95,112,97,116,104,114,187,0,0,0,114,5,
- 0,0,0,114,5,0,0,0,114,8,0,0,0,114,203,0,
- 0,0,137,5,0,0,115,72,0,0,0,0,5,4,1,14,
- 1,2,1,24,1,12,1,10,1,10,1,8,1,6,2,6,
- 1,6,1,10,2,6,1,4,2,8,1,12,1,14,1,8,
- 1,10,1,8,1,24,4,8,2,14,1,16,1,16,1,12,
- 1,8,1,10,1,4,255,8,2,6,1,12,1,12,1,8,
- 1,4,1,122,20,70,105,108,101,70,105,110,100,101,114,46,
- 102,105,110,100,95,115,112,101,99,99,1,0,0,0,0,0,
- 0,0,0,0,0,0,9,0,0,0,10,0,0,0,67,0,
- 0,0,115,188,0,0,0,124,0,106,0,125,1,122,22,116,
- 1,160,2,124,1,112,22,116,1,160,3,161,0,161,1,125,
- 2,87,0,110,28,4,0,116,4,116,5,116,6,102,3,121,
- 56,1,0,1,0,1,0,103,0,125,2,89,0,110,2,48,
- 0,116,7,106,8,160,9,100,1,161,1,115,82,116,10,124,
- 2,131,1,124,0,95,11,110,74,116,10,131,0,125,3,124,
- 2,68,0,93,56,125,4,124,4,160,12,100,2,161,1,92,
- 3,125,5,125,6,125,7,124,6,114,134,100,3,160,13,124,
- 5,124,7,160,14,161,0,161,2,125,8,110,4,124,5,125,
- 8,124,3,160,15,124,8,161,1,1,0,113,92,124,3,124,
- 0,95,11,116,7,106,8,160,9,116,16,161,1,114,184,100,
- 4,100,5,132,0,124,2,68,0,131,1,124,0,95,17,100,
- 6,83,0,41,7,122,68,70,105,108,108,32,116,104,101,32,
- 99,97,99,104,101,32,111,102,32,112,111,116,101,110,116,105,
- 97,108,32,109,111,100,117,108,101,115,32,97,110,100,32,112,
- 97,99,107,97,103,101,115,32,102,111,114,32,116,104,105,115,
- 32,100,105,114,101,99,116,111,114,121,46,114,0,0,0,0,
- 114,71,0,0,0,114,61,0,0,0,99,1,0,0,0,0,
- 0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,83,
- 0,0,0,115,20,0,0,0,104,0,124,0,93,12,125,1,
- 124,1,160,0,161,0,146,2,113,4,83,0,114,5,0,0,
- 0,41,1,114,105,0,0,0,41,2,114,32,0,0,0,90,
- 2,102,110,114,5,0,0,0,114,5,0,0,0,114,8,0,
- 0,0,218,9,60,115,101,116,99,111,109,112,62,214,5,0,
- 0,114,56,1,0,0,122,41,70,105,108,101,70,105,110,100,
- 101,114,46,95,102,105,108,108,95,99,97,99,104,101,46,60,
- 108,111,99,97,108,115,62,46,60,115,101,116,99,111,109,112,
- 62,78,41,18,114,44,0,0,0,114,4,0,0,0,90,7,
- 108,105,115,116,100,105,114,114,55,0,0,0,114,45,1,0,
- 0,218,15,80,101,114,109,105,115,115,105,111,110,69,114,114,
- 111,114,218,18,78,111,116,65,68,105,114,101,99,116,111,114,
- 121,69,114,114,111,114,114,1,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,114,59,1,0,0,114,60,1,0,0,114,
- 100,0,0,0,114,62,0,0,0,114,105,0,0,0,218,3,
- 97,100,100,114,12,0,0,0,114,61,1,0,0,41,9,114,
- 118,0,0,0,114,44,0,0,0,90,8,99,111,110,116,101,
- 110,116,115,90,21,108,111,119,101,114,95,115,117,102,102,105,
- 120,95,99,111,110,116,101,110,116,115,114,33,1,0,0,114,
- 116,0,0,0,114,20,1,0,0,114,8,1,0,0,90,8,
- 110,101,119,95,110,97,109,101,114,5,0,0,0,114,5,0,
- 0,0,114,8,0,0,0,114,63,1,0,0,185,5,0,0,
- 115,34,0,0,0,0,2,6,1,2,1,22,1,18,3,10,
- 3,12,1,12,7,6,1,8,1,16,1,4,1,18,2,4,
- 1,12,1,6,1,12,1,122,22,70,105,108,101,70,105,110,
- 100,101,114,46,95,102,105,108,108,95,99,97,99,104,101,99,
- 1,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,
- 3,0,0,0,7,0,0,0,115,18,0,0,0,135,0,135,
- 1,102,2,100,1,100,2,132,8,125,2,124,2,83,0,41,
- 3,97,20,1,0,0,65,32,99,108,97,115,115,32,109,101,
- 116,104,111,100,32,119,104,105,99,104,32,114,101,116,117,114,
- 110,115,32,97,32,99,108,111,115,117,114,101,32,116,111,32,
- 117,115,101,32,111,110,32,115,121,115,46,112,97,116,104,95,
- 104,111,111,107,10,32,32,32,32,32,32,32,32,119,104,105,
- 99,104,32,119,105,108,108,32,114,101,116,117,114,110,32,97,
- 110,32,105,110,115,116,97,110,99,101,32,117,115,105,110,103,
- 32,116,104,101,32,115,112,101,99,105,102,105,101,100,32,108,
- 111,97,100,101,114,115,32,97,110,100,32,116,104,101,32,112,
- 97,116,104,10,32,32,32,32,32,32,32,32,99,97,108,108,
- 101,100,32,111,110,32,116,104,101,32,99,108,111,115,117,114,
- 101,46,10,10,32,32,32,32,32,32,32,32,73,102,32,116,
- 104,101,32,112,97,116,104,32,99,97,108,108,101,100,32,111,
- 110,32,116,104,101,32,99,108,111,115,117,114,101,32,105,115,
- 32,110,111,116,32,97,32,100,105,114,101,99,116,111,114,121,
- 44,32,73,109,112,111,114,116,69,114,114,111,114,32,105,115,
- 10,32,32,32,32,32,32,32,32,114,97,105,115,101,100,46,
- 10,10,32,32,32,32,32,32,32,32,99,1,0,0,0,0,
- 0,0,0,0,0,0,0,1,0,0,0,4,0,0,0,19,
- 0,0,0,115,36,0,0,0,116,0,124,0,131,1,115,20,
- 116,1,100,1,124,0,100,2,141,2,130,1,136,0,124,0,
- 103,1,136,1,162,1,82,0,142,0,83,0,41,3,122,45,
- 80,97,116,104,32,104,111,111,107,32,102,111,114,32,105,109,
- 112,111,114,116,108,105,98,46,109,97,99,104,105,110,101,114,
- 121,46,70,105,108,101,70,105,110,100,101,114,46,122,30,111,
- 110,108,121,32,100,105,114,101,99,116,111,114,105,101,115,32,
- 97,114,101,32,115,117,112,112,111,114,116,101,100,114,48,0,
- 0,0,41,2,114,56,0,0,0,114,117,0,0,0,114,48,
- 0,0,0,169,2,114,193,0,0,0,114,62,1,0,0,114,
- 5,0,0,0,114,8,0,0,0,218,24,112,97,116,104,95,
- 104,111,111,107,95,102,111,114,95,70,105,108,101,70,105,110,
- 100,101,114,226,5,0,0,115,6,0,0,0,0,2,8,1,
- 12,1,122,54,70,105,108,101,70,105,110,100,101,114,46,112,
- 97,116,104,95,104,111,111,107,46,60,108,111,99,97,108,115,
- 62,46,112,97,116,104,95,104,111,111,107,95,102,111,114,95,
- 70,105,108,101,70,105,110,100,101,114,114,5,0,0,0,41,
- 3,114,193,0,0,0,114,62,1,0,0,114,69,1,0,0,
- 114,5,0,0,0,114,68,1,0,0,114,8,0,0,0,218,
- 9,112,97,116,104,95,104,111,111,107,216,5,0,0,115,4,
- 0,0,0,0,10,14,6,122,20,70,105,108,101,70,105,110,
- 100,101,114,46,112,97,116,104,95,104,111,111,107,99,1,0,
- 0,0,0,0,0,0,0,0,0,0,1,0,0,0,3,0,
- 0,0,67,0,0,0,115,12,0,0,0,100,1,160,0,124,
- 0,106,1,161,1,83,0,41,2,78,122,16,70,105,108,101,
- 70,105,110,100,101,114,40,123,33,114,125,41,41,2,114,62,
- 0,0,0,114,44,0,0,0,114,246,0,0,0,114,5,0,
- 0,0,114,5,0,0,0,114,8,0,0,0,114,31,1,0,
- 0,234,5,0,0,115,2,0,0,0,0,1,122,19,70,105,
- 108,101,70,105,110,100,101,114,46,95,95,114,101,112,114,95,
- 95,41,1,78,41,15,114,125,0,0,0,114,124,0,0,0,
- 114,126,0,0,0,114,127,0,0,0,114,209,0,0,0,114,
- 38,1,0,0,114,143,0,0,0,114,206,0,0,0,114,137,
- 0,0,0,114,51,1,0,0,114,203,0,0,0,114,63,1,
- 0,0,114,207,0,0,0,114,70,1,0,0,114,31,1,0,
- 0,114,5,0,0,0,114,5,0,0,0,114,5,0,0,0,
- 114,8,0,0,0,114,54,1,0,0,91,5,0,0,115,22,
- 0,0,0,8,2,4,7,8,14,8,4,4,2,8,12,8,
- 5,10,48,8,31,2,1,10,17,114,54,1,0,0,99,4,
- 0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,8,
- 0,0,0,67,0,0,0,115,144,0,0,0,124,0,160,0,
- 100,1,161,1,125,4,124,0,160,0,100,2,161,1,125,5,
- 124,4,115,66,124,5,114,36,124,5,106,1,125,4,110,30,
- 124,2,124,3,107,2,114,56,116,2,124,1,124,2,131,2,
- 125,4,110,10,116,3,124,1,124,2,131,2,125,4,124,5,
- 115,84,116,4,124,1,124,2,124,4,100,3,141,3,125,5,
- 122,36,124,5,124,0,100,2,60,0,124,4,124,0,100,1,
- 60,0,124,2,124,0,100,4,60,0,124,3,124,0,100,5,
- 60,0,87,0,110,18,4,0,116,5,121,138,1,0,1,0,
- 1,0,89,0,110,2,48,0,100,0,83,0,41,6,78,218,
- 10,95,95,108,111,97,100,101,114,95,95,218,8,95,95,115,
- 112,101,99,95,95,114,55,1,0,0,90,8,95,95,102,105,
- 108,101,95,95,90,10,95,95,99,97,99,104,101,100,95,95,
- 41,6,218,3,103,101,116,114,140,0,0,0,114,5,1,0,
- 0,114,255,0,0,0,114,190,0,0,0,218,9,69,120,99,
- 101,112,116,105,111,110,41,6,90,2,110,115,114,116,0,0,
- 0,90,8,112,97,116,104,110,97,109,101,90,9,99,112,97,
- 116,104,110,97,109,101,114,140,0,0,0,114,187,0,0,0,
- 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,
- 14,95,102,105,120,95,117,112,95,109,111,100,117,108,101,240,
- 5,0,0,115,34,0,0,0,0,2,10,1,10,1,4,1,
- 4,1,8,1,8,1,12,2,10,1,4,1,14,1,2,1,
- 8,1,8,1,8,1,12,1,12,2,114,75,1,0,0,99,
- 0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,
- 3,0,0,0,67,0,0,0,115,38,0,0,0,116,0,116,
- 1,160,2,161,0,102,2,125,0,116,3,116,4,102,2,125,
- 1,116,5,116,6,102,2,125,2,124,0,124,1,124,2,103,
- 3,83,0,41,1,122,95,82,101,116,117,114,110,115,32,97,
- 32,108,105,115,116,32,111,102,32,102,105,108,101,45,98,97,
- 115,101,100,32,109,111,100,117,108,101,32,108,111,97,100,101,
- 114,115,46,10,10,32,32,32,32,69,97,99,104,32,105,116,
- 101,109,32,105,115,32,97,32,116,117,112,108,101,32,40,108,
- 111,97,100,101,114,44,32,115,117,102,102,105,120,101,115,41,
- 46,10,32,32,32,32,41,7,114,252,0,0,0,114,163,0,
- 0,0,218,18,101,120,116,101,110,115,105,111,110,95,115,117,
- 102,102,105,120,101,115,114,255,0,0,0,114,101,0,0,0,
- 114,5,1,0,0,114,88,0,0,0,41,3,90,10,101,120,
- 116,101,110,115,105,111,110,115,90,6,115,111,117,114,99,101,
- 90,8,98,121,116,101,99,111,100,101,114,5,0,0,0,114,
- 5,0,0,0,114,8,0,0,0,114,184,0,0,0,7,6,
- 0,0,115,8,0,0,0,0,5,12,1,8,1,8,1,114,
- 184,0,0,0,99,1,0,0,0,0,0,0,0,0,0,0,
- 0,10,0,0,0,9,0,0,0,67,0,0,0,115,130,1,
- 0,0,124,0,97,0,116,0,106,1,97,1,116,0,106,2,
- 97,2,116,1,106,3,116,4,25,0,125,1,100,1,100,2,
- 103,1,102,2,100,3,100,4,100,2,103,2,102,2,102,2,
- 125,2,124,2,68,0,93,106,92,2,125,3,125,4,116,5,
- 100,5,100,6,132,0,124,4,68,0,131,1,131,1,115,82,
- 74,0,130,1,124,4,100,7,25,0,125,5,124,3,116,1,
- 106,3,118,0,114,116,116,1,106,3,124,3,25,0,125,6,
- 1,0,113,168,113,52,122,20,116,0,160,6,124,3,161,1,
- 125,6,87,0,1,0,113,168,87,0,113,52,4,0,116,7,
- 121,158,1,0,1,0,1,0,89,0,113,52,89,0,113,52,
- 48,0,116,7,100,8,131,1,130,1,116,8,124,1,100,9,
- 124,6,131,3,1,0,116,8,124,1,100,10,124,5,131,3,
- 1,0,116,8,124,1,100,11,100,12,160,9,124,4,161,1,
- 131,3,1,0,116,8,124,1,100,13,100,14,100,15,132,0,
- 124,4,68,0,131,1,131,3,1,0,103,0,100,16,162,1,
- 125,7,124,3,100,3,107,2,144,1,114,4,124,7,160,10,
- 100,17,161,1,1,0,124,7,68,0,93,52,125,8,124,8,
- 116,1,106,3,118,1,144,1,114,36,116,0,160,6,124,8,
- 161,1,125,9,110,10,116,1,106,3,124,8,25,0,125,9,
- 116,8,124,1,124,8,124,9,131,3,1,0,144,1,113,8,
- 116,8,124,1,100,18,116,11,131,0,131,3,1,0,116,12,
- 160,13,116,2,160,14,161,0,161,1,1,0,124,3,100,3,
- 107,2,144,1,114,126,116,15,160,10,100,19,161,1,1,0,
- 100,20,116,12,118,0,144,1,114,126,100,21,116,16,95,17,
- 100,22,83,0,41,23,122,205,83,101,116,117,112,32,116,104,
- 101,32,112,97,116,104,45,98,97,115,101,100,32,105,109,112,
- 111,114,116,101,114,115,32,102,111,114,32,105,109,112,111,114,
- 116,108,105,98,32,98,121,32,105,109,112,111,114,116,105,110,
- 103,32,110,101,101,100,101,100,10,32,32,32,32,98,117,105,
- 108,116,45,105,110,32,109,111,100,117,108,101,115,32,97,110,
- 100,32,105,110,106,101,99,116,105,110,103,32,116,104,101,109,
- 32,105,110,116,111,32,116,104,101,32,103,108,111,98,97,108,
- 32,110,97,109,101,115,112,97,99,101,46,10,10,32,32,32,
- 32,79,116,104,101,114,32,99,111,109,112,111,110,101,110,116,
- 115,32,97,114,101,32,101,120,116,114,97,99,116,101,100,32,
- 102,114,111,109,32,116,104,101,32,99,111,114,101,32,98,111,
- 111,116,115,116,114,97,112,32,109,111,100,117,108,101,46,10,
- 10,32,32,32,32,90,5,112,111,115,105,120,250,1,47,90,
- 2,110,116,250,1,92,99,1,0,0,0,0,0,0,0,0,
- 0,0,0,2,0,0,0,3,0,0,0,115,0,0,0,115,
- 26,0,0,0,124,0,93,18,125,1,116,0,124,1,131,1,
- 100,0,107,2,86,0,1,0,113,2,100,1,83,0,41,2,
- 114,39,0,0,0,78,41,1,114,23,0,0,0,41,2,114,
- 32,0,0,0,114,94,0,0,0,114,5,0,0,0,114,5,
- 0,0,0,114,8,0,0,0,114,10,1,0,0,36,6,0,
- 0,114,56,1,0,0,122,25,95,115,101,116,117,112,46,60,
- 108,111,99,97,108,115,62,46,60,103,101,110,101,120,112,114,
- 62,114,73,0,0,0,122,30,105,109,112,111,114,116,108,105,
- 98,32,114,101,113,117,105,114,101,115,32,112,111,115,105,120,
- 32,111,114,32,110,116,114,4,0,0,0,114,35,0,0,0,
- 114,31,0,0,0,114,40,0,0,0,114,58,0,0,0,99,
- 1,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,
- 4,0,0,0,83,0,0,0,115,22,0,0,0,104,0,124,
- 0,93,14,125,1,100,0,124,1,155,0,157,2,146,2,113,
- 4,83,0,41,1,114,74,0,0,0,114,5,0,0,0,41,
- 2,114,32,0,0,0,218,1,115,114,5,0,0,0,114,5,
- 0,0,0,114,8,0,0,0,114,64,1,0,0,53,6,0,
- 0,114,56,1,0,0,122,25,95,115,101,116,117,112,46,60,
- 108,111,99,97,108,115,62,46,60,115,101,116,99,111,109,112,
- 62,41,3,114,64,0,0,0,114,75,0,0,0,114,160,0,
- 0,0,114,192,0,0,0,114,9,0,0,0,122,4,46,112,
- 121,119,122,6,95,100,46,112,121,100,84,78,41,18,114,134,
- 0,0,0,114,1,0,0,0,114,163,0,0,0,114,22,1,
- 0,0,114,125,0,0,0,218,3,97,108,108,90,18,95,98,
- 117,105,108,116,105,110,95,102,114,111,109,95,110,97,109,101,
- 114,117,0,0,0,114,129,0,0,0,114,36,0,0,0,114,
- 186,0,0,0,114,14,0,0,0,114,12,1,0,0,114,167,
- 0,0,0,114,76,1,0,0,114,101,0,0,0,114,191,0,
- 0,0,114,195,0,0,0,41,10,218,17,95,98,111,111,116,
- 115,116,114,97,112,95,109,111,100,117,108,101,90,11,115,101,
- 108,102,95,109,111,100,117,108,101,90,10,111,115,95,100,101,
- 116,97,105,108,115,90,10,98,117,105,108,116,105,110,95,111,
- 115,114,31,0,0,0,114,35,0,0,0,90,9,111,115,95,
- 109,111,100,117,108,101,90,13,98,117,105,108,116,105,110,95,
- 110,97,109,101,115,90,12,98,117,105,108,116,105,110,95,110,
- 97,109,101,90,14,98,117,105,108,116,105,110,95,109,111,100,
- 117,108,101,114,5,0,0,0,114,5,0,0,0,114,8,0,
- 0,0,218,6,95,115,101,116,117,112,18,6,0,0,115,70,
- 0,0,0,0,8,4,1,6,1,6,2,10,3,22,1,12,
- 2,22,1,8,1,10,1,10,1,6,2,2,1,10,1,10,
- 1,12,1,10,2,8,2,12,1,12,1,18,1,22,3,8,
- 1,10,1,10,1,8,1,12,1,12,2,10,1,16,3,14,
- 1,14,1,10,1,10,1,10,1,114,82,1,0,0,99,1,
+ 83,0,113,146,116,17,124,8,131,1,125,3,124,0,106,14,
+ 68,0,93,86,92,2,125,9,125,10,116,13,124,0,106,2,
+ 124,4,124,9,23,0,131,2,125,12,116,18,106,19,100,6,
+ 124,12,100,3,100,7,141,3,1,0,124,7,124,9,23,0,
+ 124,6,118,0,144,1,114,50,116,15,124,12,131,1,144,1,
+ 114,50,124,0,160,16,124,10,124,1,124,12,100,8,124,2,
+ 161,5,2,0,1,0,83,0,113,220,124,3,144,1,114,94,
+ 116,18,160,19,100,9,124,8,161,2,1,0,116,18,160,20,
+ 124,1,100,8,161,2,125,13,124,8,103,1,124,13,95,21,
+ 124,13,83,0,100,8,83,0,119,0,41,10,122,111,84,114,
+ 121,32,116,111,32,102,105,110,100,32,97,32,115,112,101,99,
+ 32,102,111,114,32,116,104,101,32,115,112,101,99,105,102,105,
+ 101,100,32,109,111,100,117,108,101,46,10,10,32,32,32,32,
+ 32,32,32,32,82,101,116,117,114,110,115,32,116,104,101,32,
+ 109,97,116,99,104,105,110,103,32,115,112,101,99,44,32,111,
+ 114,32,78,111,110,101,32,105,102,32,110,111,116,32,102,111,
+ 117,110,100,46,10,32,32,32,32,32,32,32,32,70,114,79,
+ 0,0,0,114,39,0,0,0,114,109,0,0,0,114,216,0,
+ 0,0,122,9,116,114,121,105,110,103,32,123,125,41,1,90,
+ 9,118,101,114,98,111,115,105,116,121,78,122,25,112,111,115,
+ 115,105,98,108,101,32,110,97,109,101,115,112,97,99,101,32,
+ 102,111,114,32,123,125,41,22,114,49,0,0,0,114,57,0,
+ 0,0,114,52,0,0,0,114,18,0,0,0,114,63,0,0,
+ 0,114,7,1,0,0,114,58,0,0,0,114,62,1,0,0,
+ 218,11,95,102,105,108,108,95,99,97,99,104,101,114,21,0,
+ 0,0,114,65,1,0,0,114,110,0,0,0,114,64,1,0,
+ 0,114,48,0,0,0,114,61,1,0,0,114,62,0,0,0,
+ 114,56,1,0,0,114,64,0,0,0,114,139,0,0,0,114,
+ 153,0,0,0,114,187,0,0,0,114,182,0,0,0,41,14,
+ 114,123,0,0,0,114,143,0,0,0,114,206,0,0,0,90,
+ 12,105,115,95,110,97,109,101,115,112,97,99,101,90,11,116,
+ 97,105,108,95,109,111,100,117,108,101,114,173,0,0,0,90,
+ 5,99,97,99,104,101,90,12,99,97,99,104,101,95,109,111,
+ 100,117,108,101,90,9,98,97,115,101,95,112,97,116,104,114,
+ 15,1,0,0,114,192,0,0,0,90,13,105,110,105,116,95,
+ 102,105,108,101,110,97,109,101,90,9,102,117,108,108,95,112,
+ 97,116,104,114,191,0,0,0,114,7,0,0,0,114,7,0,
+ 0,0,114,8,0,0,0,114,207,0,0,0,177,5,0,0,
+ 115,80,0,0,0,4,5,14,1,2,1,24,1,14,1,6,
+ 1,10,1,8,1,6,1,6,2,6,1,10,1,6,2,4,
+ 1,8,2,12,1,14,1,8,1,10,1,8,1,24,1,2,
+ 128,8,4,14,2,16,1,16,1,14,1,10,1,10,1,4,
+ 1,8,255,2,128,6,2,12,1,12,1,8,1,4,1,4,
+ 1,2,219,255,128,122,20,70,105,108,101,70,105,110,100,101,
+ 114,46,102,105,110,100,95,115,112,101,99,99,1,0,0,0,
+ 0,0,0,0,0,0,0,0,9,0,0,0,10,0,0,0,
+ 67,0,0,0,115,190,0,0,0,124,0,106,0,125,1,122,
+ 22,116,1,160,2,124,1,112,22,116,1,160,3,161,0,161,
+ 1,125,2,87,0,110,24,4,0,116,4,116,5,116,6,102,
+ 3,121,188,1,0,1,0,1,0,103,0,125,2,89,0,116,
+ 7,106,8,160,9,100,1,161,1,115,78,116,10,124,2,131,
+ 1,124,0,95,11,110,74,116,10,131,0,125,3,124,2,68,
+ 0,93,56,125,4,124,4,160,12,100,2,161,1,92,3,125,
+ 5,125,6,125,7,124,6,114,130,100,3,160,13,124,5,124,
+ 7,160,14,161,0,161,2,125,8,110,4,124,5,125,8,124,
+ 3,160,15,124,8,161,1,1,0,113,88,124,3,124,0,95,
+ 11,116,7,106,8,160,9,116,16,161,1,114,184,100,4,100,
+ 5,132,0,124,2,68,0,131,1,124,0,95,17,100,6,83,
+ 0,100,6,83,0,119,0,41,7,122,68,70,105,108,108,32,
+ 116,104,101,32,99,97,99,104,101,32,111,102,32,112,111,116,
+ 101,110,116,105,97,108,32,109,111,100,117,108,101,115,32,97,
+ 110,100,32,112,97,99,107,97,103,101,115,32,102,111,114,32,
+ 116,104,105,115,32,100,105,114,101,99,116,111,114,121,46,114,
+ 14,0,0,0,114,79,0,0,0,114,69,0,0,0,99,1,
0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,4,
- 0,0,0,67,0,0,0,115,50,0,0,0,116,0,124,0,
- 131,1,1,0,116,1,131,0,125,1,116,2,106,3,160,4,
- 116,5,106,6,124,1,142,0,103,1,161,1,1,0,116,2,
- 106,7,160,8,116,9,161,1,1,0,100,1,83,0,41,2,
- 122,41,73,110,115,116,97,108,108,32,116,104,101,32,112,97,
- 116,104,45,98,97,115,101,100,32,105,109,112,111,114,116,32,
- 99,111,109,112,111,110,101,110,116,115,46,78,41,10,114,82,
- 1,0,0,114,184,0,0,0,114,1,0,0,0,114,43,1,
- 0,0,114,167,0,0,0,114,54,1,0,0,114,70,1,0,
- 0,218,9,109,101,116,97,95,112,97,116,104,114,186,0,0,
- 0,114,37,1,0,0,41,2,114,81,1,0,0,90,17,115,
- 117,112,112,111,114,116,101,100,95,108,111,97,100,101,114,115,
- 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,
- 8,95,105,110,115,116,97,108,108,75,6,0,0,115,8,0,
- 0,0,0,2,8,1,6,1,20,1,114,84,1,0,0,41,
- 1,114,60,0,0,0,41,1,78,41,3,78,78,78,41,2,
- 114,73,0,0,0,114,73,0,0,0,41,1,84,41,1,78,
- 41,1,78,41,63,114,127,0,0,0,114,13,0,0,0,90,
- 37,95,67,65,83,69,95,73,78,83,69,78,83,73,84,73,
- 86,69,95,80,76,65,84,70,79,82,77,83,95,66,89,84,
- 69,83,95,75,69,89,114,12,0,0,0,114,14,0,0,0,
- 114,21,0,0,0,114,27,0,0,0,114,29,0,0,0,114,
- 38,0,0,0,114,47,0,0,0,114,49,0,0,0,114,53,
- 0,0,0,114,54,0,0,0,114,56,0,0,0,114,59,0,
- 0,0,114,69,0,0,0,218,4,116,121,112,101,218,8,95,
- 95,99,111,100,101,95,95,114,162,0,0,0,114,19,0,0,
- 0,114,148,0,0,0,114,18,0,0,0,114,24,0,0,0,
- 114,236,0,0,0,114,91,0,0,0,114,87,0,0,0,114,
- 101,0,0,0,114,88,0,0,0,90,23,68,69,66,85,71,
- 95,66,89,84,69,67,79,68,69,95,83,85,70,70,73,88,
- 69,83,90,27,79,80,84,73,77,73,90,69,68,95,66,89,
- 84,69,67,79,68,69,95,83,85,70,70,73,88,69,83,114,
- 97,0,0,0,114,102,0,0,0,114,108,0,0,0,114,112,
- 0,0,0,114,114,0,0,0,114,136,0,0,0,114,143,0,
- 0,0,114,152,0,0,0,114,156,0,0,0,114,158,0,0,
- 0,114,165,0,0,0,114,170,0,0,0,114,171,0,0,0,
- 114,176,0,0,0,218,6,111,98,106,101,99,116,114,185,0,
- 0,0,114,190,0,0,0,114,191,0,0,0,114,208,0,0,
- 0,114,221,0,0,0,114,239,0,0,0,114,255,0,0,0,
- 114,5,1,0,0,114,12,1,0,0,114,252,0,0,0,114,
- 13,1,0,0,114,35,1,0,0,114,37,1,0,0,114,54,
- 1,0,0,114,75,1,0,0,114,184,0,0,0,114,82,1,
- 0,0,114,84,1,0,0,114,5,0,0,0,114,5,0,0,
- 0,114,5,0,0,0,114,8,0,0,0,218,8,60,109,111,
- 100,117,108,101,62,1,0,0,0,115,126,0,0,0,4,22,
- 4,1,4,1,2,1,2,255,4,4,8,17,8,5,8,5,
- 8,6,8,6,8,12,8,10,8,9,8,5,8,7,8,9,
- 10,22,10,127,0,21,16,1,12,2,4,1,4,2,6,2,
- 6,2,8,2,16,71,8,40,8,19,8,12,8,12,8,28,
- 8,17,8,33,8,28,8,24,10,13,10,10,10,11,8,14,
- 6,3,4,1,2,255,12,68,14,64,14,29,16,127,0,17,
- 14,50,18,45,18,26,4,3,18,53,14,63,14,42,14,127,
- 0,20,14,127,0,22,10,23,8,11,8,57,
+ 0,0,0,83,0,0,0,115,20,0,0,0,104,0,124,0,
+ 93,12,125,1,124,1,160,0,161,0,146,2,113,4,83,0,
+ 114,7,0,0,0,41,1,114,110,0,0,0,41,2,114,5,
+ 0,0,0,90,2,102,110,114,7,0,0,0,114,7,0,0,
+ 0,114,8,0,0,0,114,13,0,0,0,254,5,0,0,115,
+ 4,0,0,0,20,0,255,128,122,41,70,105,108,101,70,105,
+ 110,100,101,114,46,95,102,105,108,108,95,99,97,99,104,101,
+ 46,60,108,111,99,97,108,115,62,46,60,115,101,116,99,111,
+ 109,112,62,78,41,18,114,52,0,0,0,114,18,0,0,0,
+ 90,7,108,105,115,116,100,105,114,114,63,0,0,0,114,50,
+ 1,0,0,218,15,80,101,114,109,105,115,115,105,111,110,69,
+ 114,114,111,114,218,18,78,111,116,65,68,105,114,101,99,116,
+ 111,114,121,69,114,114,111,114,114,15,0,0,0,114,22,0,
+ 0,0,114,23,0,0,0,114,63,1,0,0,114,64,1,0,
+ 0,114,105,0,0,0,114,70,0,0,0,114,110,0,0,0,
+ 218,3,97,100,100,114,24,0,0,0,114,65,1,0,0,41,
+ 9,114,123,0,0,0,114,52,0,0,0,90,8,99,111,110,
+ 116,101,110,116,115,90,21,108,111,119,101,114,95,115,117,102,
+ 102,105,120,95,99,111,110,116,101,110,116,115,114,38,1,0,
+ 0,114,121,0,0,0,114,25,1,0,0,114,15,1,0,0,
+ 90,8,110,101,119,95,110,97,109,101,114,7,0,0,0,114,
+ 7,0,0,0,114,8,0,0,0,114,67,1,0,0,225,5,
+ 0,0,115,40,0,0,0,6,2,2,1,22,1,18,1,6,
+ 3,12,3,12,1,6,7,8,1,16,1,4,1,18,1,4,
+ 2,12,1,6,1,12,1,20,1,4,255,2,233,255,128,122,
+ 22,70,105,108,101,70,105,110,100,101,114,46,95,102,105,108,
+ 108,95,99,97,99,104,101,99,1,0,0,0,0,0,0,0,
+ 0,0,0,0,3,0,0,0,3,0,0,0,7,0,0,0,
+ 115,18,0,0,0,135,0,135,1,102,2,100,1,100,2,132,
+ 8,125,2,124,2,83,0,41,4,97,20,1,0,0,65,32,
+ 99,108,97,115,115,32,109,101,116,104,111,100,32,119,104,105,
+ 99,104,32,114,101,116,117,114,110,115,32,97,32,99,108,111,
+ 115,117,114,101,32,116,111,32,117,115,101,32,111,110,32,115,
+ 121,115,46,112,97,116,104,95,104,111,111,107,10,32,32,32,
+ 32,32,32,32,32,119,104,105,99,104,32,119,105,108,108,32,
+ 114,101,116,117,114,110,32,97,110,32,105,110,115,116,97,110,
+ 99,101,32,117,115,105,110,103,32,116,104,101,32,115,112,101,
+ 99,105,102,105,101,100,32,108,111,97,100,101,114,115,32,97,
+ 110,100,32,116,104,101,32,112,97,116,104,10,32,32,32,32,
+ 32,32,32,32,99,97,108,108,101,100,32,111,110,32,116,104,
+ 101,32,99,108,111,115,117,114,101,46,10,10,32,32,32,32,
+ 32,32,32,32,73,102,32,116,104,101,32,112,97,116,104,32,
+ 99,97,108,108,101,100,32,111,110,32,116,104,101,32,99,108,
+ 111,115,117,114,101,32,105,115,32,110,111,116,32,97,32,100,
+ 105,114,101,99,116,111,114,121,44,32,73,109,112,111,114,116,
+ 69,114,114,111,114,32,105,115,10,32,32,32,32,32,32,32,
+ 32,114,97,105,115,101,100,46,10,10,32,32,32,32,32,32,
+ 32,32,99,1,0,0,0,0,0,0,0,0,0,0,0,1,
+ 0,0,0,4,0,0,0,19,0,0,0,115,36,0,0,0,
+ 116,0,124,0,131,1,115,20,116,1,100,1,124,0,100,2,
+ 141,2,130,1,136,0,124,0,103,1,136,1,162,1,82,0,
+ 142,0,83,0,41,4,122,45,80,97,116,104,32,104,111,111,
+ 107,32,102,111,114,32,105,109,112,111,114,116,108,105,98,46,
+ 109,97,99,104,105,110,101,114,121,46,70,105,108,101,70,105,
+ 110,100,101,114,46,122,30,111,110,108,121,32,100,105,114,101,
+ 99,116,111,114,105,101,115,32,97,114,101,32,115,117,112,112,
+ 111,114,116,101,100,114,56,0,0,0,78,41,2,114,64,0,
+ 0,0,114,122,0,0,0,114,56,0,0,0,169,2,114,202,
+ 0,0,0,114,66,1,0,0,114,7,0,0,0,114,8,0,
+ 0,0,218,24,112,97,116,104,95,104,111,111,107,95,102,111,
+ 114,95,70,105,108,101,70,105,110,100,101,114,10,6,0,0,
+ 115,8,0,0,0,8,2,12,1,16,1,255,128,122,54,70,
+ 105,108,101,70,105,110,100,101,114,46,112,97,116,104,95,104,
+ 111,111,107,46,60,108,111,99,97,108,115,62,46,112,97,116,
+ 104,95,104,111,111,107,95,102,111,114,95,70,105,108,101,70,
+ 105,110,100,101,114,78,114,7,0,0,0,41,3,114,202,0,
+ 0,0,114,66,1,0,0,114,72,1,0,0,114,7,0,0,
+ 0,114,71,1,0,0,114,8,0,0,0,218,9,112,97,116,
+ 104,95,104,111,111,107,0,6,0,0,115,6,0,0,0,14,
+ 10,4,6,255,128,122,20,70,105,108,101,70,105,110,100,101,
+ 114,46,112,97,116,104,95,104,111,111,107,99,1,0,0,0,
+ 0,0,0,0,0,0,0,0,1,0,0,0,3,0,0,0,
+ 67,0,0,0,115,12,0,0,0,100,1,160,0,124,0,106,
+ 1,161,1,83,0,41,2,78,122,16,70,105,108,101,70,105,
+ 110,100,101,114,40,123,33,114,125,41,41,2,114,70,0,0,
+ 0,114,52,0,0,0,114,253,0,0,0,114,7,0,0,0,
+ 114,7,0,0,0,114,8,0,0,0,114,36,1,0,0,18,
+ 6,0,0,115,4,0,0,0,12,1,255,128,122,19,70,105,
+ 108,101,70,105,110,100,101,114,46,95,95,114,101,112,114,95,
+ 95,41,1,78,41,15,114,130,0,0,0,114,129,0,0,0,
+ 114,131,0,0,0,114,132,0,0,0,114,216,0,0,0,114,
+ 43,1,0,0,114,147,0,0,0,114,210,0,0,0,114,141,
+ 0,0,0,114,56,1,0,0,114,207,0,0,0,114,67,1,
+ 0,0,114,214,0,0,0,114,73,1,0,0,114,36,1,0,
+ 0,114,7,0,0,0,114,7,0,0,0,114,7,0,0,0,
+ 114,8,0,0,0,114,59,1,0,0,131,5,0,0,115,26,
+ 0,0,0,8,0,4,2,8,7,8,14,4,4,8,2,8,
+ 12,10,5,8,48,2,31,10,1,12,17,255,128,114,59,1,
+ 0,0,99,4,0,0,0,0,0,0,0,0,0,0,0,6,
+ 0,0,0,8,0,0,0,67,0,0,0,115,148,0,0,0,
+ 124,0,160,0,100,1,161,1,125,4,124,0,160,0,100,2,
+ 161,1,125,5,124,4,115,66,124,5,114,36,124,5,106,1,
+ 125,4,110,30,124,2,124,3,107,2,114,56,116,2,124,1,
+ 124,2,131,2,125,4,110,10,116,3,124,1,124,2,131,2,
+ 125,4,124,5,115,84,116,4,124,1,124,2,124,4,100,3,
+ 141,3,125,5,122,38,124,5,124,0,100,2,60,0,124,4,
+ 124,0,100,1,60,0,124,2,124,0,100,4,60,0,124,3,
+ 124,0,100,5,60,0,87,0,100,0,83,0,4,0,116,5,
+ 121,142,1,0,1,0,1,0,89,0,100,0,83,0,119,0,
+ 100,0,83,0,41,6,78,218,10,95,95,108,111,97,100,101,
+ 114,95,95,218,8,95,95,115,112,101,99,95,95,114,60,1,
+ 0,0,90,8,95,95,102,105,108,101,95,95,90,10,95,95,
+ 99,97,99,104,101,100,95,95,41,6,218,3,103,101,116,114,
+ 144,0,0,0,114,12,1,0,0,114,6,1,0,0,114,194,
+ 0,0,0,218,9,69,120,99,101,112,116,105,111,110,41,6,
+ 90,2,110,115,114,121,0,0,0,90,8,112,97,116,104,110,
+ 97,109,101,90,9,99,112,97,116,104,110,97,109,101,114,144,
+ 0,0,0,114,191,0,0,0,114,7,0,0,0,114,7,0,
+ 0,0,114,8,0,0,0,218,14,95,102,105,120,95,117,112,
+ 95,109,111,100,117,108,101,24,6,0,0,115,40,0,0,0,
+ 10,2,10,1,4,1,4,1,8,1,8,1,12,1,10,2,
+ 4,1,14,1,2,1,8,1,8,1,8,1,14,1,12,1,
+ 6,2,2,254,4,255,255,128,114,78,1,0,0,99,0,0,
+ 0,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0,
+ 0,0,67,0,0,0,115,38,0,0,0,116,0,116,1,160,
+ 2,161,0,102,2,125,0,116,3,116,4,102,2,125,1,116,
+ 5,116,6,102,2,125,2,124,0,124,1,124,2,103,3,83,
+ 0,41,2,122,95,82,101,116,117,114,110,115,32,97,32,108,
+ 105,115,116,32,111,102,32,102,105,108,101,45,98,97,115,101,
+ 100,32,109,111,100,117,108,101,32,108,111,97,100,101,114,115,
+ 46,10,10,32,32,32,32,69,97,99,104,32,105,116,101,109,
+ 32,105,115,32,97,32,116,117,112,108,101,32,40,108,111,97,
+ 100,101,114,44,32,115,117,102,102,105,120,101,115,41,46,10,
+ 32,32,32,32,78,41,7,114,3,1,0,0,114,167,0,0,
+ 0,218,18,101,120,116,101,110,115,105,111,110,95,115,117,102,
+ 102,105,120,101,115,114,6,1,0,0,114,106,0,0,0,114,
+ 12,1,0,0,114,94,0,0,0,41,3,90,10,101,120,116,
+ 101,110,115,105,111,110,115,90,6,115,111,117,114,99,101,90,
+ 8,98,121,116,101,99,111,100,101,114,7,0,0,0,114,7,
+ 0,0,0,114,8,0,0,0,114,188,0,0,0,47,6,0,
+ 0,115,10,0,0,0,12,5,8,1,8,1,10,1,255,128,
+ 114,188,0,0,0,99,1,0,0,0,0,0,0,0,0,0,
+ 0,0,1,0,0,0,1,0,0,0,67,0,0,0,115,8,
+ 0,0,0,124,0,97,0,100,0,83,0,114,114,0,0,0,
+ 41,1,114,139,0,0,0,41,1,218,17,95,98,111,111,116,
+ 115,116,114,97,112,95,109,111,100,117,108,101,114,7,0,0,
+ 0,114,7,0,0,0,114,8,0,0,0,218,21,95,115,101,
+ 116,95,98,111,111,116,115,116,114,97,112,95,109,111,100,117,
+ 108,101,58,6,0,0,115,4,0,0,0,8,2,255,128,114,
+ 81,1,0,0,99,1,0,0,0,0,0,0,0,0,0,0,
+ 0,2,0,0,0,4,0,0,0,67,0,0,0,115,50,0,
+ 0,0,116,0,124,0,131,1,1,0,116,1,131,0,125,1,
+ 116,2,106,3,160,4,116,5,106,6,124,1,142,0,103,1,
+ 161,1,1,0,116,2,106,7,160,8,116,9,161,1,1,0,
+ 100,1,83,0,41,2,122,41,73,110,115,116,97,108,108,32,
+ 116,104,101,32,112,97,116,104,45,98,97,115,101,100,32,105,
+ 109,112,111,114,116,32,99,111,109,112,111,110,101,110,116,115,
+ 46,78,41,10,114,81,1,0,0,114,188,0,0,0,114,15,
+ 0,0,0,114,48,1,0,0,114,171,0,0,0,114,59,1,
+ 0,0,114,73,1,0,0,218,9,109,101,116,97,95,112,97,
+ 116,104,114,190,0,0,0,114,42,1,0,0,41,2,114,80,
+ 1,0,0,90,17,115,117,112,112,111,114,116,101,100,95,108,
+ 111,97,100,101,114,115,114,7,0,0,0,114,7,0,0,0,
+ 114,8,0,0,0,218,8,95,105,110,115,116,97,108,108,63,
+ 6,0,0,115,10,0,0,0,8,2,6,1,20,1,16,1,
+ 255,128,114,83,1,0,0,41,1,114,68,0,0,0,41,1,
+ 78,41,3,78,78,78,41,2,114,0,0,0,0,114,0,0,
+ 0,0,41,1,84,41,1,78,41,1,78,41,83,114,132,0,
+ 0,0,114,139,0,0,0,114,167,0,0,0,114,72,0,0,
+ 0,114,15,0,0,0,114,81,0,0,0,114,164,0,0,0,
+ 114,22,0,0,0,114,211,0,0,0,90,2,110,116,114,18,
+ 0,0,0,114,196,0,0,0,90,5,112,111,115,105,120,114,
+ 42,0,0,0,218,3,97,108,108,114,45,0,0,0,114,46,
+ 0,0,0,114,66,0,0,0,114,25,0,0,0,90,37,95,
+ 67,65,83,69,95,73,78,83,69,78,83,73,84,73,86,69,
+ 95,80,76,65,84,70,79,82,77,83,95,66,89,84,69,83,
+ 95,75,69,89,114,24,0,0,0,114,26,0,0,0,114,21,
+ 0,0,0,114,33,0,0,0,114,38,0,0,0,114,40,0,
+ 0,0,114,48,0,0,0,114,55,0,0,0,114,57,0,0,
+ 0,114,61,0,0,0,114,62,0,0,0,114,64,0,0,0,
+ 114,67,0,0,0,114,77,0,0,0,218,4,116,121,112,101,
+ 218,8,95,95,99,111,100,101,95,95,114,166,0,0,0,114,
+ 31,0,0,0,114,152,0,0,0,114,30,0,0,0,114,35,
+ 0,0,0,114,243,0,0,0,114,97,0,0,0,114,93,0,
+ 0,0,114,106,0,0,0,114,190,0,0,0,114,79,1,0,
+ 0,114,212,0,0,0,114,94,0,0,0,90,23,68,69,66,
+ 85,71,95,66,89,84,69,67,79,68,69,95,83,85,70,70,
+ 73,88,69,83,90,27,79,80,84,73,77,73,90,69,68,95,
+ 66,89,84,69,67,79,68,69,95,83,85,70,70,73,88,69,
+ 83,114,102,0,0,0,114,107,0,0,0,114,113,0,0,0,
+ 114,117,0,0,0,114,119,0,0,0,114,140,0,0,0,114,
+ 147,0,0,0,114,156,0,0,0,114,160,0,0,0,114,162,
+ 0,0,0,114,169,0,0,0,114,174,0,0,0,114,175,0,
+ 0,0,114,180,0,0,0,218,6,111,98,106,101,99,116,114,
+ 189,0,0,0,114,194,0,0,0,114,195,0,0,0,114,215,
+ 0,0,0,114,228,0,0,0,114,246,0,0,0,114,6,1,
+ 0,0,114,12,1,0,0,114,3,1,0,0,114,18,1,0,
+ 0,114,40,1,0,0,114,42,1,0,0,114,59,1,0,0,
+ 114,78,1,0,0,114,188,0,0,0,114,81,1,0,0,114,
+ 83,1,0,0,114,7,0,0,0,114,7,0,0,0,114,7,
+ 0,0,0,114,8,0,0,0,218,8,60,109,111,100,117,108,
+ 101,62,1,0,0,0,115,172,0,0,0,4,0,4,22,8,
+ 3,8,1,8,1,8,1,8,1,10,3,4,1,8,1,10,
+ 1,8,2,4,3,10,1,6,2,22,2,8,1,10,1,14,
+ 1,4,4,4,1,2,1,2,1,4,255,8,4,6,16,8,
+ 3,8,5,8,5,8,6,8,6,8,12,8,10,8,9,8,
+ 5,8,7,10,9,10,22,0,127,16,24,12,1,4,2,4,
+ 1,6,2,6,1,10,1,8,2,6,2,8,2,16,2,8,
+ 71,8,40,8,19,8,12,8,12,8,31,8,17,8,33,8,
+ 28,10,24,10,13,10,10,8,11,6,14,4,3,2,1,12,
+ 255,14,68,14,64,16,30,0,127,14,17,18,50,18,45,18,
+ 25,14,53,14,63,14,43,0,127,14,20,0,127,10,22,8,
+ 23,8,11,12,5,255,128,
};
diff --git a/Python/importlib_zipimport.h b/Python/importlib_zipimport.h
index a70d7d2fe7..79296d495b 100644
--- a/Python/importlib_zipimport.h
+++ b/Python/importlib_zipimport.h
@@ -1,813 +1,874 @@
/* Auto-generated by Programs/_freeze_importlib.c */
const unsigned char _Py_M__zipimport[] = {
99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,4,0,0,0,64,0,0,0,115,68,1,0,0,100,0,
+ 0,4,0,0,0,64,0,0,0,115,80,1,0,0,100,0,
90,0,100,1,100,2,108,1,90,2,100,1,100,3,108,1,
109,3,90,3,109,4,90,4,1,0,100,1,100,2,108,5,
90,6,100,1,100,2,108,7,90,7,100,1,100,2,108,8,
90,8,100,1,100,2,108,9,90,9,100,1,100,2,108,10,
- 90,10,100,1,100,2,108,11,90,11,100,4,100,5,103,2,
- 90,12,101,2,106,13,90,13,101,2,106,14,100,6,100,2,
- 133,2,25,0,90,15,71,0,100,7,100,4,132,0,100,4,
- 101,16,131,3,90,17,105,0,90,18,101,19,101,10,131,1,
- 90,20,100,8,90,21,100,9,90,22,100,10,90,23,71,0,
- 100,11,100,5,132,0,100,5,131,2,90,24,101,13,100,12,
- 23,0,100,13,100,13,102,3,101,13,100,14,23,0,100,15,
- 100,13,102,3,100,16,100,17,102,4,90,25,100,18,100,19,
- 132,0,90,26,100,20,100,21,132,0,90,27,100,22,100,23,
- 132,0,90,28,100,24,100,25,132,0,90,29,100,26,90,30,
- 100,15,97,31,100,27,100,28,132,0,90,32,100,29,100,30,
- 132,0,90,33,100,31,100,32,132,0,90,34,100,33,100,34,
- 132,0,90,35,101,19,101,35,106,36,131,1,90,37,100,35,
- 100,36,132,0,90,38,100,37,100,38,132,0,90,39,100,39,
- 100,40,132,0,90,40,100,41,100,42,132,0,90,41,100,43,
- 100,44,132,0,90,42,100,45,100,46,132,0,90,43,100,2,
- 83,0,41,47,97,80,2,0,0,122,105,112,105,109,112,111,
- 114,116,32,112,114,111,118,105,100,101,115,32,115,117,112,112,
- 111,114,116,32,102,111,114,32,105,109,112,111,114,116,105,110,
- 103,32,80,121,116,104,111,110,32,109,111,100,117,108,101,115,
- 32,102,114,111,109,32,90,105,112,32,97,114,99,104,105,118,
- 101,115,46,10,10,84,104,105,115,32,109,111,100,117,108,101,
- 32,101,120,112,111,114,116,115,32,116,104,114,101,101,32,111,
- 98,106,101,99,116,115,58,10,45,32,122,105,112,105,109,112,
- 111,114,116,101,114,58,32,97,32,99,108,97,115,115,59,32,
- 105,116,115,32,99,111,110,115,116,114,117,99,116,111,114,32,
- 116,97,107,101,115,32,97,32,112,97,116,104,32,116,111,32,
- 97,32,90,105,112,32,97,114,99,104,105,118,101,46,10,45,
- 32,90,105,112,73,109,112,111,114,116,69,114,114,111,114,58,
- 32,101,120,99,101,112,116,105,111,110,32,114,97,105,115,101,
- 100,32,98,121,32,122,105,112,105,109,112,111,114,116,101,114,
- 32,111,98,106,101,99,116,115,46,32,73,116,39,115,32,97,
- 10,32,32,115,117,98,99,108,97,115,115,32,111,102,32,73,
- 109,112,111,114,116,69,114,114,111,114,44,32,115,111,32,105,
- 116,32,99,97,110,32,98,101,32,99,97,117,103,104,116,32,
- 97,115,32,73,109,112,111,114,116,69,114,114,111,114,44,32,
- 116,111,111,46,10,45,32,95,122,105,112,95,100,105,114,101,
- 99,116,111,114,121,95,99,97,99,104,101,58,32,97,32,100,
- 105,99,116,44,32,109,97,112,112,105,110,103,32,97,114,99,
- 104,105,118,101,32,112,97,116,104,115,32,116,111,32,122,105,
- 112,32,100,105,114,101,99,116,111,114,121,10,32,32,105,110,
- 102,111,32,100,105,99,116,115,44,32,97,115,32,117,115,101,
- 100,32,105,110,32,122,105,112,105,109,112,111,114,116,101,114,
- 46,95,102,105,108,101,115,46,10,10,73,116,32,105,115,32,
- 117,115,117,97,108,108,121,32,110,111,116,32,110,101,101,100,
- 101,100,32,116,111,32,117,115,101,32,116,104,101,32,122,105,
- 112,105,109,112,111,114,116,32,109,111,100,117,108,101,32,101,
- 120,112,108,105,99,105,116,108,121,59,32,105,116,32,105,115,
- 10,117,115,101,100,32,98,121,32,116,104,101,32,98,117,105,
- 108,116,105,110,32,105,109,112,111,114,116,32,109,101,99,104,
- 97,110,105,115,109,32,102,111,114,32,115,121,115,46,112,97,
- 116,104,32,105,116,101,109,115,32,116,104,97,116,32,97,114,
- 101,32,112,97,116,104,115,10,116,111,32,90,105,112,32,97,
- 114,99,104,105,118,101,115,46,10,233,0,0,0,0,78,41,
- 2,218,14,95,117,110,112,97,99,107,95,117,105,110,116,49,
- 54,218,14,95,117,110,112,97,99,107,95,117,105,110,116,51,
- 50,218,14,90,105,112,73,109,112,111,114,116,69,114,114,111,
- 114,218,11,122,105,112,105,109,112,111,114,116,101,114,233,1,
- 0,0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,1,0,0,0,64,0,0,0,115,12,0,0,
- 0,101,0,90,1,100,0,90,2,100,1,83,0,41,2,114,
- 3,0,0,0,78,41,3,218,8,95,95,110,97,109,101,95,
- 95,218,10,95,95,109,111,100,117,108,101,95,95,218,12,95,
- 95,113,117,97,108,110,97,109,101,95,95,169,0,114,9,0,
- 0,0,114,9,0,0,0,250,18,60,102,114,111,122,101,110,
- 32,122,105,112,105,109,112,111,114,116,62,114,3,0,0,0,
- 33,0,0,0,115,2,0,0,0,8,1,233,22,0,0,0,
+ 90,10,100,1,100,2,108,11,90,11,100,1,100,2,108,12,
+ 90,12,100,4,100,5,103,2,90,13,101,2,106,14,90,14,
+ 101,2,106,15,100,6,100,2,133,2,25,0,90,16,71,0,
+ 100,7,100,4,132,0,100,4,101,17,131,3,90,18,105,0,
+ 90,19,101,20,101,10,131,1,90,21,100,8,90,22,100,9,
+ 90,23,100,10,90,24,71,0,100,11,100,5,132,0,100,5,
+ 101,2,106,25,131,3,90,26,101,14,100,12,23,0,100,13,
+ 100,13,102,3,101,14,100,14,23,0,100,15,100,13,102,3,
+ 100,16,100,17,102,4,90,27,100,18,100,19,132,0,90,28,
+ 100,20,100,21,132,0,90,29,100,22,100,23,132,0,90,30,
+ 100,24,100,25,132,0,90,31,100,26,90,32,100,15,97,33,
+ 100,27,100,28,132,0,90,34,100,29,100,30,132,0,90,35,
+ 100,31,100,32,132,0,90,36,100,33,100,34,132,0,90,37,
+ 101,20,101,37,106,38,131,1,90,39,100,35,100,36,132,0,
+ 90,40,100,37,100,38,132,0,90,41,100,39,100,40,132,0,
+ 90,42,100,41,100,42,132,0,90,43,100,43,100,44,132,0,
+ 90,44,100,45,100,46,132,0,90,45,100,2,83,0,41,47,
+ 97,80,2,0,0,122,105,112,105,109,112,111,114,116,32,112,
+ 114,111,118,105,100,101,115,32,115,117,112,112,111,114,116,32,
+ 102,111,114,32,105,109,112,111,114,116,105,110,103,32,80,121,
+ 116,104,111,110,32,109,111,100,117,108,101,115,32,102,114,111,
+ 109,32,90,105,112,32,97,114,99,104,105,118,101,115,46,10,
+ 10,84,104,105,115,32,109,111,100,117,108,101,32,101,120,112,
+ 111,114,116,115,32,116,104,114,101,101,32,111,98,106,101,99,
+ 116,115,58,10,45,32,122,105,112,105,109,112,111,114,116,101,
+ 114,58,32,97,32,99,108,97,115,115,59,32,105,116,115,32,
+ 99,111,110,115,116,114,117,99,116,111,114,32,116,97,107,101,
+ 115,32,97,32,112,97,116,104,32,116,111,32,97,32,90,105,
+ 112,32,97,114,99,104,105,118,101,46,10,45,32,90,105,112,
+ 73,109,112,111,114,116,69,114,114,111,114,58,32,101,120,99,
+ 101,112,116,105,111,110,32,114,97,105,115,101,100,32,98,121,
+ 32,122,105,112,105,109,112,111,114,116,101,114,32,111,98,106,
+ 101,99,116,115,46,32,73,116,39,115,32,97,10,32,32,115,
+ 117,98,99,108,97,115,115,32,111,102,32,73,109,112,111,114,
+ 116,69,114,114,111,114,44,32,115,111,32,105,116,32,99,97,
+ 110,32,98,101,32,99,97,117,103,104,116,32,97,115,32,73,
+ 109,112,111,114,116,69,114,114,111,114,44,32,116,111,111,46,
+ 10,45,32,95,122,105,112,95,100,105,114,101,99,116,111,114,
+ 121,95,99,97,99,104,101,58,32,97,32,100,105,99,116,44,
+ 32,109,97,112,112,105,110,103,32,97,114,99,104,105,118,101,
+ 32,112,97,116,104,115,32,116,111,32,122,105,112,32,100,105,
+ 114,101,99,116,111,114,121,10,32,32,105,110,102,111,32,100,
+ 105,99,116,115,44,32,97,115,32,117,115,101,100,32,105,110,
+ 32,122,105,112,105,109,112,111,114,116,101,114,46,95,102,105,
+ 108,101,115,46,10,10,73,116,32,105,115,32,117,115,117,97,
+ 108,108,121,32,110,111,116,32,110,101,101,100,101,100,32,116,
+ 111,32,117,115,101,32,116,104,101,32,122,105,112,105,109,112,
+ 111,114,116,32,109,111,100,117,108,101,32,101,120,112,108,105,
+ 99,105,116,108,121,59,32,105,116,32,105,115,10,117,115,101,
+ 100,32,98,121,32,116,104,101,32,98,117,105,108,116,105,110,
+ 32,105,109,112,111,114,116,32,109,101,99,104,97,110,105,115,
+ 109,32,102,111,114,32,115,121,115,46,112,97,116,104,32,105,
+ 116,101,109,115,32,116,104,97,116,32,97,114,101,32,112,97,
+ 116,104,115,10,116,111,32,90,105,112,32,97,114,99,104,105,
+ 118,101,115,46,10,233,0,0,0,0,78,41,2,218,14,95,
+ 117,110,112,97,99,107,95,117,105,110,116,49,54,218,14,95,
+ 117,110,112,97,99,107,95,117,105,110,116,51,50,218,14,90,
+ 105,112,73,109,112,111,114,116,69,114,114,111,114,218,11,122,
+ 105,112,105,109,112,111,114,116,101,114,233,1,0,0,0,99,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 1,0,0,0,64,0,0,0,115,12,0,0,0,101,0,90,
+ 1,100,0,90,2,100,1,83,0,41,2,114,3,0,0,0,
+ 78,41,3,218,8,95,95,110,97,109,101,95,95,218,10,95,
+ 95,109,111,100,117,108,101,95,95,218,12,95,95,113,117,97,
+ 108,110,97,109,101,95,95,169,0,114,9,0,0,0,114,9,
+ 0,0,0,250,18,60,102,114,111,122,101,110,32,122,105,112,
+ 105,109,112,111,114,116,62,114,3,0,0,0,34,0,0,0,
+ 115,6,0,0,0,8,0,4,1,255,128,233,22,0,0,0,
115,4,0,0,0,80,75,5,6,105,255,255,0,0,99,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,
- 0,0,0,64,0,0,0,115,108,0,0,0,101,0,90,1,
+ 0,0,0,64,0,0,0,115,118,0,0,0,101,0,90,1,
100,0,90,2,100,1,90,3,100,2,100,3,132,0,90,4,
- 100,25,100,5,100,6,132,1,90,5,100,26,100,7,100,8,
- 132,1,90,6,100,9,100,10,132,0,90,7,100,11,100,12,
- 132,0,90,8,100,13,100,14,132,0,90,9,100,15,100,16,
- 132,0,90,10,100,17,100,18,132,0,90,11,100,19,100,20,
- 132,0,90,12,100,21,100,22,132,0,90,13,100,23,100,24,
- 132,0,90,14,100,4,83,0,41,27,114,4,0,0,0,97,
- 255,1,0,0,122,105,112,105,109,112,111,114,116,101,114,40,
- 97,114,99,104,105,118,101,112,97,116,104,41,32,45,62,32,
- 122,105,112,105,109,112,111,114,116,101,114,32,111,98,106,101,
- 99,116,10,10,32,32,32,32,67,114,101,97,116,101,32,97,
- 32,110,101,119,32,122,105,112,105,109,112,111,114,116,101,114,
- 32,105,110,115,116,97,110,99,101,46,32,39,97,114,99,104,
- 105,118,101,112,97,116,104,39,32,109,117,115,116,32,98,101,
- 32,97,32,112,97,116,104,32,116,111,10,32,32,32,32,97,
- 32,122,105,112,102,105,108,101,44,32,111,114,32,116,111,32,
- 97,32,115,112,101,99,105,102,105,99,32,112,97,116,104,32,
- 105,110,115,105,100,101,32,97,32,122,105,112,102,105,108,101,
- 46,32,70,111,114,32,101,120,97,109,112,108,101,44,32,105,
- 116,32,99,97,110,32,98,101,10,32,32,32,32,39,47,116,
- 109,112,47,109,121,105,109,112,111,114,116,46,122,105,112,39,
- 44,32,111,114,32,39,47,116,109,112,47,109,121,105,109,112,
- 111,114,116,46,122,105,112,47,109,121,100,105,114,101,99,116,
- 111,114,121,39,44,32,105,102,32,109,121,100,105,114,101,99,
- 116,111,114,121,32,105,115,32,97,10,32,32,32,32,118,97,
- 108,105,100,32,100,105,114,101,99,116,111,114,121,32,105,110,
- 115,105,100,101,32,116,104,101,32,97,114,99,104,105,118,101,
- 46,10,10,32,32,32,32,39,90,105,112,73,109,112,111,114,
- 116,69,114,114,111,114,32,105,115,32,114,97,105,115,101,100,
- 32,105,102,32,39,97,114,99,104,105,118,101,112,97,116,104,
- 39,32,100,111,101,115,110,39,116,32,112,111,105,110,116,32,
- 116,111,32,97,32,118,97,108,105,100,32,90,105,112,10,32,
- 32,32,32,97,114,99,104,105,118,101,46,10,10,32,32,32,
- 32,84,104,101,32,39,97,114,99,104,105,118,101,39,32,97,
- 116,116,114,105,98,117,116,101,32,111,102,32,122,105,112,105,
- 109,112,111,114,116,101,114,32,111,98,106,101,99,116,115,32,
- 99,111,110,116,97,105,110,115,32,116,104,101,32,110,97,109,
- 101,32,111,102,32,116,104,101,10,32,32,32,32,122,105,112,
- 102,105,108,101,32,116,97,114,103,101,116,101,100,46,10,32,
- 32,32,32,99,2,0,0,0,0,0,0,0,0,0,0,0,
- 8,0,0,0,9,0,0,0,67,0,0,0,115,32,1,0,
- 0,116,0,124,1,116,1,131,2,115,28,100,1,100,0,108,
- 2,125,2,124,2,160,3,124,1,161,1,125,1,124,1,115,
- 44,116,4,100,2,124,1,100,3,141,2,130,1,116,5,114,
- 60,124,1,160,6,116,5,116,7,161,2,125,1,103,0,125,
- 3,122,14,116,8,160,9,124,1,161,1,125,4,87,0,110,
- 70,4,0,116,10,116,11,102,2,121,148,1,0,1,0,1,
- 0,116,8,160,12,124,1,161,1,92,2,125,5,125,6,124,
- 5,124,1,107,2,114,130,116,4,100,4,124,1,100,3,141,
- 2,130,1,124,5,125,1,124,3,160,13,124,6,161,1,1,
- 0,89,0,113,64,48,0,124,4,106,14,100,5,64,0,100,
- 6,107,3,114,180,116,4,100,4,124,1,100,3,141,2,130,
- 1,113,180,113,64,122,12,116,15,124,1,25,0,125,7,87,
- 0,110,34,4,0,116,16,121,226,1,0,1,0,1,0,116,
- 17,124,1,131,1,125,7,124,7,116,15,124,1,60,0,89,
- 0,110,2,48,0,124,7,124,0,95,18,124,1,124,0,95,
- 19,116,8,106,20,124,3,100,0,100,0,100,7,133,3,25,
- 0,142,0,124,0,95,21,124,0,106,21,144,1,114,28,124,
- 0,4,0,106,21,116,7,55,0,2,0,95,21,100,0,83,
- 0,41,8,78,114,0,0,0,0,122,21,97,114,99,104,105,
- 118,101,32,112,97,116,104,32,105,115,32,101,109,112,116,121,
- 169,1,218,4,112,97,116,104,122,14,110,111,116,32,97,32,
- 90,105,112,32,102,105,108,101,105,0,240,0,0,105,0,128,
- 0,0,233,255,255,255,255,41,22,218,10,105,115,105,110,115,
- 116,97,110,99,101,218,3,115,116,114,218,2,111,115,90,8,
- 102,115,100,101,99,111,100,101,114,3,0,0,0,218,12,97,
- 108,116,95,112,97,116,104,95,115,101,112,218,7,114,101,112,
- 108,97,99,101,218,8,112,97,116,104,95,115,101,112,218,19,
- 95,98,111,111,116,115,116,114,97,112,95,101,120,116,101,114,
- 110,97,108,90,10,95,112,97,116,104,95,115,116,97,116,218,
- 7,79,83,69,114,114,111,114,218,10,86,97,108,117,101,69,
- 114,114,111,114,90,11,95,112,97,116,104,95,115,112,108,105,
- 116,218,6,97,112,112,101,110,100,90,7,115,116,95,109,111,
- 100,101,218,20,95,122,105,112,95,100,105,114,101,99,116,111,
- 114,121,95,99,97,99,104,101,218,8,75,101,121,69,114,114,
- 111,114,218,15,95,114,101,97,100,95,100,105,114,101,99,116,
- 111,114,121,218,6,95,102,105,108,101,115,218,7,97,114,99,
- 104,105,118,101,218,10,95,112,97,116,104,95,106,111,105,110,
- 218,6,112,114,101,102,105,120,41,8,218,4,115,101,108,102,
- 114,13,0,0,0,114,17,0,0,0,114,31,0,0,0,90,
- 2,115,116,90,7,100,105,114,110,97,109,101,90,8,98,97,
- 115,101,110,97,109,101,218,5,102,105,108,101,115,114,9,0,
- 0,0,114,9,0,0,0,114,10,0,0,0,218,8,95,95,
- 105,110,105,116,95,95,63,0,0,0,115,58,0,0,0,0,
- 1,10,1,8,1,10,1,4,1,12,1,4,1,12,2,4,
- 2,2,1,14,1,16,3,14,1,8,1,12,1,4,1,16,
- 3,14,2,12,1,4,2,2,1,12,1,12,1,8,1,14,
- 1,6,1,6,2,22,1,8,1,122,20,122,105,112,105,109,
- 112,111,114,116,101,114,46,95,95,105,110,105,116,95,95,78,
- 99,3,0,0,0,0,0,0,0,0,0,0,0,5,0,0,
- 0,4,0,0,0,67,0,0,0,115,78,0,0,0,116,0,
- 124,0,124,1,131,2,125,3,124,3,100,1,117,1,114,26,
- 124,0,103,0,102,2,83,0,116,1,124,0,124,1,131,2,
- 125,4,116,2,124,0,124,4,131,2,114,70,100,1,124,0,
- 106,3,155,0,116,4,155,0,124,4,155,0,157,3,103,1,
- 102,2,83,0,100,1,103,0,102,2,83,0,41,2,97,239,
- 1,0,0,102,105,110,100,95,108,111,97,100,101,114,40,102,
- 117,108,108,110,97,109,101,44,32,112,97,116,104,61,78,111,
- 110,101,41,32,45,62,32,115,101,108,102,44,32,115,116,114,
- 32,111,114,32,78,111,110,101,46,10,10,32,32,32,32,32,
- 32,32,32,83,101,97,114,99,104,32,102,111,114,32,97,32,
- 109,111,100,117,108,101,32,115,112,101,99,105,102,105,101,100,
- 32,98,121,32,39,102,117,108,108,110,97,109,101,39,46,32,
- 39,102,117,108,108,110,97,109,101,39,32,109,117,115,116,32,
- 98,101,32,116,104,101,10,32,32,32,32,32,32,32,32,102,
- 117,108,108,121,32,113,117,97,108,105,102,105,101,100,32,40,
- 100,111,116,116,101,100,41,32,109,111,100,117,108,101,32,110,
- 97,109,101,46,32,73,116,32,114,101,116,117,114,110,115,32,
- 116,104,101,32,122,105,112,105,109,112,111,114,116,101,114,10,
- 32,32,32,32,32,32,32,32,105,110,115,116,97,110,99,101,
- 32,105,116,115,101,108,102,32,105,102,32,116,104,101,32,109,
- 111,100,117,108,101,32,119,97,115,32,102,111,117,110,100,44,
- 32,97,32,115,116,114,105,110,103,32,99,111,110,116,97,105,
- 110,105,110,103,32,116,104,101,10,32,32,32,32,32,32,32,
- 32,102,117,108,108,32,112,97,116,104,32,110,97,109,101,32,
- 105,102,32,105,116,39,115,32,112,111,115,115,105,98,108,121,
- 32,97,32,112,111,114,116,105,111,110,32,111,102,32,97,32,
- 110,97,109,101,115,112,97,99,101,32,112,97,99,107,97,103,
- 101,44,10,32,32,32,32,32,32,32,32,111,114,32,78,111,
- 110,101,32,111,116,104,101,114,119,105,115,101,46,32,84,104,
- 101,32,111,112,116,105,111,110,97,108,32,39,112,97,116,104,
- 39,32,97,114,103,117,109,101,110,116,32,105,115,32,105,103,
- 110,111,114,101,100,32,45,45,32,105,116,39,115,10,32,32,
- 32,32,32,32,32,32,116,104,101,114,101,32,102,111,114,32,
- 99,111,109,112,97,116,105,98,105,108,105,116,121,32,119,105,
- 116,104,32,116,104,101,32,105,109,112,111,114,116,101,114,32,
- 112,114,111,116,111,99,111,108,46,10,32,32,32,32,32,32,
- 32,32,78,41,5,218,16,95,103,101,116,95,109,111,100,117,
- 108,101,95,105,110,102,111,218,16,95,103,101,116,95,109,111,
- 100,117,108,101,95,112,97,116,104,218,7,95,105,115,95,100,
- 105,114,114,29,0,0,0,114,20,0,0,0,41,5,114,32,
- 0,0,0,218,8,102,117,108,108,110,97,109,101,114,13,0,
- 0,0,218,2,109,105,218,7,109,111,100,112,97,116,104,114,
- 9,0,0,0,114,9,0,0,0,114,10,0,0,0,218,11,
- 102,105,110,100,95,108,111,97,100,101,114,109,0,0,0,115,
- 14,0,0,0,0,10,10,1,8,2,8,7,10,1,10,4,
- 24,2,122,23,122,105,112,105,109,112,111,114,116,101,114,46,
- 102,105,110,100,95,108,111,97,100,101,114,99,3,0,0,0,
- 0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,0,
- 67,0,0,0,115,16,0,0,0,124,0,160,0,124,1,124,
- 2,161,2,100,1,25,0,83,0,41,2,97,139,1,0,0,
- 102,105,110,100,95,109,111,100,117,108,101,40,102,117,108,108,
- 110,97,109,101,44,32,112,97,116,104,61,78,111,110,101,41,
- 32,45,62,32,115,101,108,102,32,111,114,32,78,111,110,101,
- 46,10,10,32,32,32,32,32,32,32,32,83,101,97,114,99,
- 104,32,102,111,114,32,97,32,109,111,100,117,108,101,32,115,
- 112,101,99,105,102,105,101,100,32,98,121,32,39,102,117,108,
- 108,110,97,109,101,39,46,32,39,102,117,108,108,110,97,109,
- 101,39,32,109,117,115,116,32,98,101,32,116,104,101,10,32,
- 32,32,32,32,32,32,32,102,117,108,108,121,32,113,117,97,
- 108,105,102,105,101,100,32,40,100,111,116,116,101,100,41,32,
- 109,111,100,117,108,101,32,110,97,109,101,46,32,73,116,32,
- 114,101,116,117,114,110,115,32,116,104,101,32,122,105,112,105,
- 109,112,111,114,116,101,114,10,32,32,32,32,32,32,32,32,
- 105,110,115,116,97,110,99,101,32,105,116,115,101,108,102,32,
- 105,102,32,116,104,101,32,109,111,100,117,108,101,32,119,97,
- 115,32,102,111,117,110,100,44,32,111,114,32,78,111,110,101,
- 32,105,102,32,105,116,32,119,97,115,110,39,116,46,10,32,
- 32,32,32,32,32,32,32,84,104,101,32,111,112,116,105,111,
- 110,97,108,32,39,112,97,116,104,39,32,97,114,103,117,109,
- 101,110,116,32,105,115,32,105,103,110,111,114,101,100,32,45,
- 45,32,105,116,39,115,32,116,104,101,114,101,32,102,111,114,
- 32,99,111,109,112,97,116,105,98,105,108,105,116,121,10,32,
- 32,32,32,32,32,32,32,119,105,116,104,32,116,104,101,32,
- 105,109,112,111,114,116,101,114,32,112,114,111,116,111,99,111,
- 108,46,10,32,32,32,32,32,32,32,32,114,0,0,0,0,
- 41,1,114,41,0,0,0,41,3,114,32,0,0,0,114,38,
- 0,0,0,114,13,0,0,0,114,9,0,0,0,114,9,0,
- 0,0,114,10,0,0,0,218,11,102,105,110,100,95,109,111,
- 100,117,108,101,141,0,0,0,115,2,0,0,0,0,9,122,
- 23,122,105,112,105,109,112,111,114,116,101,114,46,102,105,110,
- 100,95,109,111,100,117,108,101,99,2,0,0,0,0,0,0,
- 0,0,0,0,0,5,0,0,0,3,0,0,0,67,0,0,
- 0,115,20,0,0,0,116,0,124,0,124,1,131,2,92,3,
- 125,2,125,3,125,4,124,2,83,0,41,1,122,163,103,101,
- 116,95,99,111,100,101,40,102,117,108,108,110,97,109,101,41,
- 32,45,62,32,99,111,100,101,32,111,98,106,101,99,116,46,
- 10,10,32,32,32,32,32,32,32,32,82,101,116,117,114,110,
- 32,116,104,101,32,99,111,100,101,32,111,98,106,101,99,116,
- 32,102,111,114,32,116,104,101,32,115,112,101,99,105,102,105,
- 101,100,32,109,111,100,117,108,101,46,32,82,97,105,115,101,
- 32,90,105,112,73,109,112,111,114,116,69,114,114,111,114,10,
- 32,32,32,32,32,32,32,32,105,102,32,116,104,101,32,109,
- 111,100,117,108,101,32,99,111,117,108,100,110,39,116,32,98,
- 101,32,102,111,117,110,100,46,10,32,32,32,32,32,32,32,
- 32,169,1,218,16,95,103,101,116,95,109,111,100,117,108,101,
- 95,99,111,100,101,169,5,114,32,0,0,0,114,38,0,0,
- 0,218,4,99,111,100,101,218,9,105,115,112,97,99,107,97,
- 103,101,114,40,0,0,0,114,9,0,0,0,114,9,0,0,
- 0,114,10,0,0,0,218,8,103,101,116,95,99,111,100,101,
- 153,0,0,0,115,4,0,0,0,0,6,16,1,122,20,122,
- 105,112,105,109,112,111,114,116,101,114,46,103,101,116,95,99,
- 111,100,101,99,2,0,0,0,0,0,0,0,0,0,0,0,
- 4,0,0,0,8,0,0,0,67,0,0,0,115,116,0,0,
- 0,116,0,114,16,124,1,160,1,116,0,116,2,161,2,125,
- 1,124,1,125,2,124,1,160,3,124,0,106,4,116,2,23,
- 0,161,1,114,58,124,1,116,5,124,0,106,4,116,2,23,
- 0,131,1,100,1,133,2,25,0,125,2,122,14,124,0,106,
- 6,124,2,25,0,125,3,87,0,110,30,4,0,116,7,121,
- 102,1,0,1,0,1,0,116,8,100,2,100,3,124,2,131,
- 3,130,1,89,0,110,2,48,0,116,9,124,0,106,4,124,
- 3,131,2,83,0,41,4,122,154,103,101,116,95,100,97,116,
- 97,40,112,97,116,104,110,97,109,101,41,32,45,62,32,115,
- 116,114,105,110,103,32,119,105,116,104,32,102,105,108,101,32,
- 100,97,116,97,46,10,10,32,32,32,32,32,32,32,32,82,
- 101,116,117,114,110,32,116,104,101,32,100,97,116,97,32,97,
- 115,115,111,99,105,97,116,101,100,32,119,105,116,104,32,39,
- 112,97,116,104,110,97,109,101,39,46,32,82,97,105,115,101,
- 32,79,83,69,114,114,111,114,32,105,102,10,32,32,32,32,
- 32,32,32,32,116,104,101,32,102,105,108,101,32,119,97,115,
- 110,39,116,32,102,111,117,110,100,46,10,32,32,32,32,32,
- 32,32,32,78,114,0,0,0,0,218,0,41,10,114,18,0,
- 0,0,114,19,0,0,0,114,20,0,0,0,218,10,115,116,
- 97,114,116,115,119,105,116,104,114,29,0,0,0,218,3,108,
- 101,110,114,28,0,0,0,114,26,0,0,0,114,22,0,0,
- 0,218,9,95,103,101,116,95,100,97,116,97,41,4,114,32,
- 0,0,0,218,8,112,97,116,104,110,97,109,101,90,3,107,
- 101,121,218,9,116,111,99,95,101,110,116,114,121,114,9,0,
- 0,0,114,9,0,0,0,114,10,0,0,0,218,8,103,101,
- 116,95,100,97,116,97,163,0,0,0,115,20,0,0,0,0,
- 6,4,1,12,2,4,1,16,1,22,2,2,1,14,1,12,
- 1,18,1,122,20,122,105,112,105,109,112,111,114,116,101,114,
- 46,103,101,116,95,100,97,116,97,99,2,0,0,0,0,0,
- 0,0,0,0,0,0,5,0,0,0,3,0,0,0,67,0,
- 0,0,115,20,0,0,0,116,0,124,0,124,1,131,2,92,
- 3,125,2,125,3,125,4,124,4,83,0,41,1,122,106,103,
- 101,116,95,102,105,108,101,110,97,109,101,40,102,117,108,108,
- 110,97,109,101,41,32,45,62,32,102,105,108,101,110,97,109,
- 101,32,115,116,114,105,110,103,46,10,10,32,32,32,32,32,
- 32,32,32,82,101,116,117,114,110,32,116,104,101,32,102,105,
- 108,101,110,97,109,101,32,102,111,114,32,116,104,101,32,115,
- 112,101,99,105,102,105,101,100,32,109,111,100,117,108,101,46,
- 10,32,32,32,32,32,32,32,32,114,43,0,0,0,114,45,
- 0,0,0,114,9,0,0,0,114,9,0,0,0,114,10,0,
- 0,0,218,12,103,101,116,95,102,105,108,101,110,97,109,101,
- 184,0,0,0,115,4,0,0,0,0,7,16,1,122,24,122,
- 105,112,105,109,112,111,114,116,101,114,46,103,101,116,95,102,
- 105,108,101,110,97,109,101,99,2,0,0,0,0,0,0,0,
- 0,0,0,0,6,0,0,0,8,0,0,0,67,0,0,0,
- 115,126,0,0,0,116,0,124,0,124,1,131,2,125,2,124,
- 2,100,1,117,0,114,36,116,1,100,2,124,1,155,2,157,
- 2,124,1,100,3,141,2,130,1,116,2,124,0,124,1,131,
- 2,125,3,124,2,114,64,116,3,160,4,124,3,100,4,161,
- 2,125,4,110,10,124,3,155,0,100,5,157,2,125,4,122,
- 14,124,0,106,5,124,4,25,0,125,5,87,0,110,20,4,
- 0,116,6,121,108,1,0,1,0,1,0,89,0,100,1,83,
- 0,48,0,116,7,124,0,106,8,124,5,131,2,160,9,161,
- 0,83,0,41,6,122,253,103,101,116,95,115,111,117,114,99,
- 101,40,102,117,108,108,110,97,109,101,41,32,45,62,32,115,
- 111,117,114,99,101,32,115,116,114,105,110,103,46,10,10,32,
+ 100,27,100,5,100,6,132,1,90,5,100,28,100,7,100,8,
+ 132,1,90,6,100,29,100,9,100,10,132,1,90,7,100,11,
+ 100,12,132,0,90,8,100,13,100,14,132,0,90,9,100,15,
+ 100,16,132,0,90,10,100,17,100,18,132,0,90,11,100,19,
+ 100,20,132,0,90,12,100,21,100,22,132,0,90,13,100,23,
+ 100,24,132,0,90,14,100,25,100,26,132,0,90,15,100,4,
+ 83,0,41,30,114,4,0,0,0,97,255,1,0,0,122,105,
+ 112,105,109,112,111,114,116,101,114,40,97,114,99,104,105,118,
+ 101,112,97,116,104,41,32,45,62,32,122,105,112,105,109,112,
+ 111,114,116,101,114,32,111,98,106,101,99,116,10,10,32,32,
+ 32,32,67,114,101,97,116,101,32,97,32,110,101,119,32,122,
+ 105,112,105,109,112,111,114,116,101,114,32,105,110,115,116,97,
+ 110,99,101,46,32,39,97,114,99,104,105,118,101,112,97,116,
+ 104,39,32,109,117,115,116,32,98,101,32,97,32,112,97,116,
+ 104,32,116,111,10,32,32,32,32,97,32,122,105,112,102,105,
+ 108,101,44,32,111,114,32,116,111,32,97,32,115,112,101,99,
+ 105,102,105,99,32,112,97,116,104,32,105,110,115,105,100,101,
+ 32,97,32,122,105,112,102,105,108,101,46,32,70,111,114,32,
+ 101,120,97,109,112,108,101,44,32,105,116,32,99,97,110,32,
+ 98,101,10,32,32,32,32,39,47,116,109,112,47,109,121,105,
+ 109,112,111,114,116,46,122,105,112,39,44,32,111,114,32,39,
+ 47,116,109,112,47,109,121,105,109,112,111,114,116,46,122,105,
+ 112,47,109,121,100,105,114,101,99,116,111,114,121,39,44,32,
+ 105,102,32,109,121,100,105,114,101,99,116,111,114,121,32,105,
+ 115,32,97,10,32,32,32,32,118,97,108,105,100,32,100,105,
+ 114,101,99,116,111,114,121,32,105,110,115,105,100,101,32,116,
+ 104,101,32,97,114,99,104,105,118,101,46,10,10,32,32,32,
+ 32,39,90,105,112,73,109,112,111,114,116,69,114,114,111,114,
+ 32,105,115,32,114,97,105,115,101,100,32,105,102,32,39,97,
+ 114,99,104,105,118,101,112,97,116,104,39,32,100,111,101,115,
+ 110,39,116,32,112,111,105,110,116,32,116,111,32,97,32,118,
+ 97,108,105,100,32,90,105,112,10,32,32,32,32,97,114,99,
+ 104,105,118,101,46,10,10,32,32,32,32,84,104,101,32,39,
+ 97,114,99,104,105,118,101,39,32,97,116,116,114,105,98,117,
+ 116,101,32,111,102,32,122,105,112,105,109,112,111,114,116,101,
+ 114,32,111,98,106,101,99,116,115,32,99,111,110,116,97,105,
+ 110,115,32,116,104,101,32,110,97,109,101,32,111,102,32,116,
+ 104,101,10,32,32,32,32,122,105,112,102,105,108,101,32,116,
+ 97,114,103,101,116,101,100,46,10,32,32,32,32,99,2,0,
+ 0,0,0,0,0,0,0,0,0,0,8,0,0,0,9,0,
+ 0,0,67,0,0,0,115,40,1,0,0,116,0,124,1,116,
+ 1,131,2,115,28,100,1,100,0,108,2,125,2,124,2,160,
+ 3,124,1,161,1,125,1,124,1,115,44,116,4,100,2,124,
+ 1,100,3,141,2,130,1,116,5,114,60,124,1,160,6,116,
+ 5,116,7,161,2,125,1,103,0,125,3,9,0,122,14,116,
+ 8,160,9,124,1,161,1,125,4,87,0,110,70,4,0,116,
+ 10,116,11,102,2,144,1,121,38,1,0,1,0,1,0,116,
+ 8,160,12,124,1,161,1,92,2,125,5,125,6,124,5,124,
+ 1,107,2,114,134,116,4,100,5,124,1,100,3,141,2,130,
+ 1,124,5,125,1,124,3,160,13,124,6,161,1,1,0,89,
+ 0,110,28,124,4,106,14,100,6,64,0,100,7,107,3,114,
+ 178,116,4,100,5,124,1,100,3,141,2,130,1,113,182,113,
+ 66,122,12,116,15,124,1,25,0,125,7,87,0,110,32,4,
+ 0,116,16,144,1,121,36,1,0,1,0,1,0,116,17,124,
+ 1,131,1,125,7,124,7,116,15,124,1,60,0,89,0,124,
+ 7,124,0,95,18,124,1,124,0,95,19,116,8,106,20,124,
+ 3,100,0,100,0,100,8,133,3,25,0,142,0,124,0,95,
+ 21,124,0,106,21,144,1,114,32,124,0,4,0,106,21,116,
+ 7,55,0,2,0,95,21,100,0,83,0,100,0,83,0,119,
+ 0,119,0,41,9,78,114,0,0,0,0,122,21,97,114,99,
+ 104,105,118,101,32,112,97,116,104,32,105,115,32,101,109,112,
+ 116,121,169,1,218,4,112,97,116,104,84,122,14,110,111,116,
+ 32,97,32,90,105,112,32,102,105,108,101,105,0,240,0,0,
+ 105,0,128,0,0,233,255,255,255,255,41,22,218,10,105,115,
+ 105,110,115,116,97,110,99,101,218,3,115,116,114,218,2,111,
+ 115,90,8,102,115,100,101,99,111,100,101,114,3,0,0,0,
+ 218,12,97,108,116,95,112,97,116,104,95,115,101,112,218,7,
+ 114,101,112,108,97,99,101,218,8,112,97,116,104,95,115,101,
+ 112,218,19,95,98,111,111,116,115,116,114,97,112,95,101,120,
+ 116,101,114,110,97,108,90,10,95,112,97,116,104,95,115,116,
+ 97,116,218,7,79,83,69,114,114,111,114,218,10,86,97,108,
+ 117,101,69,114,114,111,114,90,11,95,112,97,116,104,95,115,
+ 112,108,105,116,218,6,97,112,112,101,110,100,90,7,115,116,
+ 95,109,111,100,101,218,20,95,122,105,112,95,100,105,114,101,
+ 99,116,111,114,121,95,99,97,99,104,101,218,8,75,101,121,
+ 69,114,114,111,114,218,15,95,114,101,97,100,95,100,105,114,
+ 101,99,116,111,114,121,218,6,95,102,105,108,101,115,218,7,
+ 97,114,99,104,105,118,101,218,10,95,112,97,116,104,95,106,
+ 111,105,110,218,6,112,114,101,102,105,120,41,8,218,4,115,
+ 101,108,102,114,13,0,0,0,114,17,0,0,0,114,31,0,
+ 0,0,90,2,115,116,90,7,100,105,114,110,97,109,101,90,
+ 8,98,97,115,101,110,97,109,101,218,5,102,105,108,101,115,
+ 114,9,0,0,0,114,9,0,0,0,114,10,0,0,0,218,
+ 8,95,95,105,110,105,116,95,95,64,0,0,0,115,70,0,
+ 0,0,10,1,8,1,10,1,4,1,12,1,4,1,12,1,
+ 4,2,2,1,2,1,14,1,18,1,14,3,8,1,12,1,
+ 4,1,14,1,14,3,12,2,2,1,2,240,2,18,12,1,
+ 14,1,8,1,10,1,6,1,6,1,22,2,8,1,18,1,
+ 4,255,2,249,2,239,255,128,122,20,122,105,112,105,109,112,
+ 111,114,116,101,114,46,95,95,105,110,105,116,95,95,78,99,
+ 3,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,
+ 4,0,0,0,67,0,0,0,115,78,0,0,0,116,0,124,
+ 0,124,1,131,2,125,3,124,3,100,1,117,1,114,26,124,
+ 0,103,0,102,2,83,0,116,1,124,0,124,1,131,2,125,
+ 4,116,2,124,0,124,4,131,2,114,70,100,1,124,0,106,
+ 3,155,0,116,4,155,0,124,4,155,0,157,3,103,1,102,
+ 2,83,0,100,1,103,0,102,2,83,0,41,2,97,47,2,
+ 0,0,102,105,110,100,95,108,111,97,100,101,114,40,102,117,
+ 108,108,110,97,109,101,44,32,112,97,116,104,61,78,111,110,
+ 101,41,32,45,62,32,115,101,108,102,44,32,115,116,114,32,
+ 111,114,32,78,111,110,101,46,10,10,32,32,32,32,32,32,
+ 32,32,83,101,97,114,99,104,32,102,111,114,32,97,32,109,
+ 111,100,117,108,101,32,115,112,101,99,105,102,105,101,100,32,
+ 98,121,32,39,102,117,108,108,110,97,109,101,39,46,32,39,
+ 102,117,108,108,110,97,109,101,39,32,109,117,115,116,32,98,
+ 101,32,116,104,101,10,32,32,32,32,32,32,32,32,102,117,
+ 108,108,121,32,113,117,97,108,105,102,105,101,100,32,40,100,
+ 111,116,116,101,100,41,32,109,111,100,117,108,101,32,110,97,
+ 109,101,46,32,73,116,32,114,101,116,117,114,110,115,32,116,
+ 104,101,32,122,105,112,105,109,112,111,114,116,101,114,10,32,
+ 32,32,32,32,32,32,32,105,110,115,116,97,110,99,101,32,
+ 105,116,115,101,108,102,32,105,102,32,116,104,101,32,109,111,
+ 100,117,108,101,32,119,97,115,32,102,111,117,110,100,44,32,
+ 97,32,115,116,114,105,110,103,32,99,111,110,116,97,105,110,
+ 105,110,103,32,116,104,101,10,32,32,32,32,32,32,32,32,
+ 102,117,108,108,32,112,97,116,104,32,110,97,109,101,32,105,
+ 102,32,105,116,39,115,32,112,111,115,115,105,98,108,121,32,
+ 97,32,112,111,114,116,105,111,110,32,111,102,32,97,32,110,
+ 97,109,101,115,112,97,99,101,32,112,97,99,107,97,103,101,
+ 44,10,32,32,32,32,32,32,32,32,111,114,32,78,111,110,
+ 101,32,111,116,104,101,114,119,105,115,101,46,32,84,104,101,
+ 32,111,112,116,105,111,110,97,108,32,39,112,97,116,104,39,
+ 32,97,114,103,117,109,101,110,116,32,105,115,32,105,103,110,
+ 111,114,101,100,32,45,45,32,105,116,39,115,10,32,32,32,
+ 32,32,32,32,32,116,104,101,114,101,32,102,111,114,32,99,
+ 111,109,112,97,116,105,98,105,108,105,116,121,32,119,105,116,
+ 104,32,116,104,101,32,105,109,112,111,114,116,101,114,32,112,
+ 114,111,116,111,99,111,108,46,10,10,32,32,32,32,32,32,
+ 32,32,68,101,112,114,101,99,97,116,101,100,32,115,105,110,
+ 99,101,32,80,121,116,104,111,110,32,51,46,49,48,46,32,
+ 85,115,101,32,102,105,110,100,95,115,112,101,99,40,41,32,
+ 105,110,115,116,101,97,100,46,10,32,32,32,32,32,32,32,
+ 32,78,41,5,218,16,95,103,101,116,95,109,111,100,117,108,
+ 101,95,105,110,102,111,218,16,95,103,101,116,95,109,111,100,
+ 117,108,101,95,112,97,116,104,218,7,95,105,115,95,100,105,
+ 114,114,29,0,0,0,114,20,0,0,0,41,5,114,32,0,
+ 0,0,218,8,102,117,108,108,110,97,109,101,114,13,0,0,
+ 0,218,2,109,105,218,7,109,111,100,112,97,116,104,114,9,
+ 0,0,0,114,9,0,0,0,114,10,0,0,0,218,11,102,
+ 105,110,100,95,108,111,97,100,101,114,110,0,0,0,115,16,
+ 0,0,0,10,12,8,1,8,2,10,7,10,1,24,4,8,
+ 2,255,128,122,23,122,105,112,105,109,112,111,114,116,101,114,
+ 46,102,105,110,100,95,108,111,97,100,101,114,99,3,0,0,
+ 0,0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,
+ 0,67,0,0,0,115,16,0,0,0,124,0,160,0,124,1,
+ 124,2,161,2,100,1,25,0,83,0,41,3,97,203,1,0,
+ 0,102,105,110,100,95,109,111,100,117,108,101,40,102,117,108,
+ 108,110,97,109,101,44,32,112,97,116,104,61,78,111,110,101,
+ 41,32,45,62,32,115,101,108,102,32,111,114,32,78,111,110,
+ 101,46,10,10,32,32,32,32,32,32,32,32,83,101,97,114,
+ 99,104,32,102,111,114,32,97,32,109,111,100,117,108,101,32,
+ 115,112,101,99,105,102,105,101,100,32,98,121,32,39,102,117,
+ 108,108,110,97,109,101,39,46,32,39,102,117,108,108,110,97,
+ 109,101,39,32,109,117,115,116,32,98,101,32,116,104,101,10,
+ 32,32,32,32,32,32,32,32,102,117,108,108,121,32,113,117,
+ 97,108,105,102,105,101,100,32,40,100,111,116,116,101,100,41,
+ 32,109,111,100,117,108,101,32,110,97,109,101,46,32,73,116,
+ 32,114,101,116,117,114,110,115,32,116,104,101,32,122,105,112,
+ 105,109,112,111,114,116,101,114,10,32,32,32,32,32,32,32,
+ 32,105,110,115,116,97,110,99,101,32,105,116,115,101,108,102,
+ 32,105,102,32,116,104,101,32,109,111,100,117,108,101,32,119,
+ 97,115,32,102,111,117,110,100,44,32,111,114,32,78,111,110,
+ 101,32,105,102,32,105,116,32,119,97,115,110,39,116,46,10,
+ 32,32,32,32,32,32,32,32,84,104,101,32,111,112,116,105,
+ 111,110,97,108,32,39,112,97,116,104,39,32,97,114,103,117,
+ 109,101,110,116,32,105,115,32,105,103,110,111,114,101,100,32,
+ 45,45,32,105,116,39,115,32,116,104,101,114,101,32,102,111,
+ 114,32,99,111,109,112,97,116,105,98,105,108,105,116,121,10,
+ 32,32,32,32,32,32,32,32,119,105,116,104,32,116,104,101,
+ 32,105,109,112,111,114,116,101,114,32,112,114,111,116,111,99,
+ 111,108,46,10,10,32,32,32,32,32,32,32,32,68,101,112,
+ 114,101,99,97,116,101,100,32,115,105,110,99,101,32,80,121,
+ 116,104,111,110,32,51,46,49,48,46,32,85,115,101,32,102,
+ 105,110,100,95,115,112,101,99,40,41,32,105,110,115,116,101,
+ 97,100,46,10,32,32,32,32,32,32,32,32,114,0,0,0,
+ 0,78,41,1,114,41,0,0,0,41,3,114,32,0,0,0,
+ 114,38,0,0,0,114,13,0,0,0,114,9,0,0,0,114,
+ 9,0,0,0,114,10,0,0,0,218,11,102,105,110,100,95,
+ 109,111,100,117,108,101,144,0,0,0,115,4,0,0,0,16,
+ 11,255,128,122,23,122,105,112,105,109,112,111,114,116,101,114,
+ 46,102,105,110,100,95,109,111,100,117,108,101,99,3,0,0,
+ 0,0,0,0,0,0,0,0,0,7,0,0,0,5,0,0,
+ 0,67,0,0,0,115,108,0,0,0,116,0,124,0,124,1,
+ 131,2,125,3,124,3,100,1,117,1,114,34,116,1,106,2,
+ 124,1,124,0,124,3,100,2,141,3,83,0,116,3,124,0,
+ 124,1,131,2,125,4,116,4,124,0,124,4,131,2,114,104,
+ 124,0,106,5,155,0,116,6,155,0,124,4,155,0,157,3,
+ 125,5,116,1,106,7,124,1,100,1,100,3,100,4,141,3,
+ 125,6,124,6,106,8,160,9,124,5,161,1,1,0,124,6,
+ 83,0,100,1,83,0,41,5,122,107,67,114,101,97,116,101,
+ 32,97,32,77,111,100,117,108,101,83,112,101,99,32,102,111,
+ 114,32,116,104,101,32,115,112,101,99,105,102,105,101,100,32,
+ 109,111,100,117,108,101,46,10,10,32,32,32,32,32,32,32,
+ 32,82,101,116,117,114,110,115,32,78,111,110,101,32,105,102,
+ 32,116,104,101,32,109,111,100,117,108,101,32,99,97,110,110,
+ 111,116,32,98,101,32,102,111,117,110,100,46,10,32,32,32,
+ 32,32,32,32,32,78,41,1,218,10,105,115,95,112,97,99,
+ 107,97,103,101,84,41,3,218,4,110,97,109,101,90,6,108,
+ 111,97,100,101,114,114,43,0,0,0,41,10,114,35,0,0,
+ 0,218,10,95,98,111,111,116,115,116,114,97,112,90,16,115,
+ 112,101,99,95,102,114,111,109,95,108,111,97,100,101,114,114,
+ 36,0,0,0,114,37,0,0,0,114,29,0,0,0,114,20,
+ 0,0,0,90,10,77,111,100,117,108,101,83,112,101,99,90,
+ 26,115,117,98,109,111,100,117,108,101,95,115,101,97,114,99,
+ 104,95,108,111,99,97,116,105,111,110,115,114,24,0,0,0,
+ 41,7,114,32,0,0,0,114,38,0,0,0,90,6,116,97,
+ 114,103,101,116,90,11,109,111,100,117,108,101,95,105,110,102,
+ 111,114,40,0,0,0,114,13,0,0,0,90,4,115,112,101,
+ 99,114,9,0,0,0,114,9,0,0,0,114,10,0,0,0,
+ 218,9,102,105,110,100,95,115,112,101,99,157,0,0,0,115,
+ 26,0,0,0,10,5,8,1,16,1,10,7,10,1,18,4,
+ 8,1,2,1,6,255,12,2,4,1,4,2,255,128,122,21,
+ 122,105,112,105,109,112,111,114,116,101,114,46,102,105,110,100,
+ 95,115,112,101,99,99,2,0,0,0,0,0,0,0,0,0,
+ 0,0,5,0,0,0,3,0,0,0,67,0,0,0,115,20,
+ 0,0,0,116,0,124,0,124,1,131,2,92,3,125,2,125,
+ 3,125,4,124,2,83,0,41,2,122,166,103,101,116,95,99,
+ 111,100,101,40,102,117,108,108,110,97,109,101,41,32,45,62,
+ 32,99,111,100,101,32,111,98,106,101,99,116,46,10,10,32,
32,32,32,32,32,32,32,82,101,116,117,114,110,32,116,104,
- 101,32,115,111,117,114,99,101,32,99,111,100,101,32,102,111,
+ 101,32,99,111,100,101,32,111,98,106,101,99,116,32,102,111,
114,32,116,104,101,32,115,112,101,99,105,102,105,101,100,32,
109,111,100,117,108,101,46,32,82,97,105,115,101,32,90,105,
112,73,109,112,111,114,116,69,114,114,111,114,10,32,32,32,
32,32,32,32,32,105,102,32,116,104,101,32,109,111,100,117,
- 108,101,32,99,111,117,108,100,110,39,116,32,98,101,32,102,
- 111,117,110,100,44,32,114,101,116,117,114,110,32,78,111,110,
- 101,32,105,102,32,116,104,101,32,97,114,99,104,105,118,101,
- 32,100,111,101,115,10,32,32,32,32,32,32,32,32,99,111,
- 110,116,97,105,110,32,116,104,101,32,109,111,100,117,108,101,
- 44,32,98,117,116,32,104,97,115,32,110,111,32,115,111,117,
- 114,99,101,32,102,111,114,32,105,116,46,10,32,32,32,32,
- 32,32,32,32,78,250,18,99,97,110,39,116,32,102,105,110,
- 100,32,109,111,100,117,108,101,32,169,1,218,4,110,97,109,
- 101,250,11,95,95,105,110,105,116,95,95,46,112,121,250,3,
+ 108,101,32,99,111,117,108,100,110,39,116,32,98,101,32,105,
+ 109,112,111,114,116,101,100,46,10,32,32,32,32,32,32,32,
+ 32,78,169,1,218,16,95,103,101,116,95,109,111,100,117,108,
+ 101,95,99,111,100,101,169,5,114,32,0,0,0,114,38,0,
+ 0,0,218,4,99,111,100,101,218,9,105,115,112,97,99,107,
+ 97,103,101,114,40,0,0,0,114,9,0,0,0,114,9,0,
+ 0,0,114,10,0,0,0,218,8,103,101,116,95,99,111,100,
+ 101,184,0,0,0,115,6,0,0,0,16,6,4,1,255,128,
+ 122,20,122,105,112,105,109,112,111,114,116,101,114,46,103,101,
+ 116,95,99,111,100,101,99,2,0,0,0,0,0,0,0,0,
+ 0,0,0,4,0,0,0,8,0,0,0,67,0,0,0,115,
+ 112,0,0,0,116,0,114,16,124,1,160,1,116,0,116,2,
+ 161,2,125,1,124,1,125,2,124,1,160,3,124,0,106,4,
+ 116,2,23,0,161,1,114,58,124,1,116,5,124,0,106,4,
+ 116,2,23,0,131,1,100,1,133,2,25,0,125,2,122,14,
+ 124,0,106,6,124,2,25,0,125,3,87,0,110,24,4,0,
+ 116,7,121,110,1,0,1,0,1,0,116,8,100,2,100,3,
+ 124,2,131,3,130,1,116,9,124,0,106,4,124,3,131,2,
+ 83,0,119,0,41,4,122,154,103,101,116,95,100,97,116,97,
+ 40,112,97,116,104,110,97,109,101,41,32,45,62,32,115,116,
+ 114,105,110,103,32,119,105,116,104,32,102,105,108,101,32,100,
+ 97,116,97,46,10,10,32,32,32,32,32,32,32,32,82,101,
+ 116,117,114,110,32,116,104,101,32,100,97,116,97,32,97,115,
+ 115,111,99,105,97,116,101,100,32,119,105,116,104,32,39,112,
+ 97,116,104,110,97,109,101,39,46,32,82,97,105,115,101,32,
+ 79,83,69,114,114,111,114,32,105,102,10,32,32,32,32,32,
+ 32,32,32,116,104,101,32,102,105,108,101,32,119,97,115,110,
+ 39,116,32,102,111,117,110,100,46,10,32,32,32,32,32,32,
+ 32,32,78,114,0,0,0,0,218,0,41,10,114,18,0,0,
+ 0,114,19,0,0,0,114,20,0,0,0,218,10,115,116,97,
+ 114,116,115,119,105,116,104,114,29,0,0,0,218,3,108,101,
+ 110,114,28,0,0,0,114,26,0,0,0,114,22,0,0,0,
+ 218,9,95,103,101,116,95,100,97,116,97,41,4,114,32,0,
+ 0,0,218,8,112,97,116,104,110,97,109,101,90,3,107,101,
+ 121,218,9,116,111,99,95,101,110,116,114,121,114,9,0,0,
+ 0,114,9,0,0,0,114,10,0,0,0,218,8,103,101,116,
+ 95,100,97,116,97,194,0,0,0,115,24,0,0,0,4,6,
+ 12,1,4,2,16,1,22,1,2,2,14,1,12,1,12,1,
+ 12,1,2,254,255,128,122,20,122,105,112,105,109,112,111,114,
+ 116,101,114,46,103,101,116,95,100,97,116,97,99,2,0,0,
+ 0,0,0,0,0,0,0,0,0,5,0,0,0,3,0,0,
+ 0,67,0,0,0,115,20,0,0,0,116,0,124,0,124,1,
+ 131,2,92,3,125,2,125,3,125,4,124,4,83,0,41,2,
+ 122,165,103,101,116,95,102,105,108,101,110,97,109,101,40,102,
+ 117,108,108,110,97,109,101,41,32,45,62,32,102,105,108,101,
+ 110,97,109,101,32,115,116,114,105,110,103,46,10,10,32,32,
+ 32,32,32,32,32,32,82,101,116,117,114,110,32,116,104,101,
+ 32,102,105,108,101,110,97,109,101,32,102,111,114,32,116,104,
+ 101,32,115,112,101,99,105,102,105,101,100,32,109,111,100,117,
+ 108,101,32,111,114,32,114,97,105,115,101,32,90,105,112,73,
+ 109,112,111,114,116,69,114,114,111,114,10,32,32,32,32,32,
+ 32,32,32,105,102,32,105,116,32,99,111,117,108,100,110,39,
+ 116,32,98,101,32,105,109,112,111,114,116,101,100,46,10,32,
+ 32,32,32,32,32,32,32,78,114,47,0,0,0,114,49,0,
+ 0,0,114,9,0,0,0,114,9,0,0,0,114,10,0,0,
+ 0,218,12,103,101,116,95,102,105,108,101,110,97,109,101,215,
+ 0,0,0,115,6,0,0,0,16,8,4,1,255,128,122,24,
+ 122,105,112,105,109,112,111,114,116,101,114,46,103,101,116,95,
+ 102,105,108,101,110,97,109,101,99,2,0,0,0,0,0,0,
+ 0,0,0,0,0,6,0,0,0,8,0,0,0,67,0,0,
+ 0,115,126,0,0,0,116,0,124,0,124,1,131,2,125,2,
+ 124,2,100,1,117,0,114,36,116,1,100,2,124,1,155,2,
+ 157,2,124,1,100,3,141,2,130,1,116,2,124,0,124,1,
+ 131,2,125,3,124,2,114,64,116,3,160,4,124,3,100,4,
+ 161,2,125,4,110,10,124,3,155,0,100,5,157,2,125,4,
+ 122,14,124,0,106,5,124,4,25,0,125,5,87,0,110,18,
+ 4,0,116,6,121,124,1,0,1,0,1,0,89,0,100,1,
+ 83,0,116,7,124,0,106,8,124,5,131,2,160,9,161,0,
+ 83,0,119,0,41,6,122,253,103,101,116,95,115,111,117,114,
+ 99,101,40,102,117,108,108,110,97,109,101,41,32,45,62,32,
+ 115,111,117,114,99,101,32,115,116,114,105,110,103,46,10,10,
+ 32,32,32,32,32,32,32,32,82,101,116,117,114,110,32,116,
+ 104,101,32,115,111,117,114,99,101,32,99,111,100,101,32,102,
+ 111,114,32,116,104,101,32,115,112,101,99,105,102,105,101,100,
+ 32,109,111,100,117,108,101,46,32,82,97,105,115,101,32,90,
+ 105,112,73,109,112,111,114,116,69,114,114,111,114,10,32,32,
+ 32,32,32,32,32,32,105,102,32,116,104,101,32,109,111,100,
+ 117,108,101,32,99,111,117,108,100,110,39,116,32,98,101,32,
+ 102,111,117,110,100,44,32,114,101,116,117,114,110,32,78,111,
+ 110,101,32,105,102,32,116,104,101,32,97,114,99,104,105,118,
+ 101,32,100,111,101,115,10,32,32,32,32,32,32,32,32,99,
+ 111,110,116,97,105,110,32,116,104,101,32,109,111,100,117,108,
+ 101,44,32,98,117,116,32,104,97,115,32,110,111,32,115,111,
+ 117,114,99,101,32,102,111,114,32,105,116,46,10,32,32,32,
+ 32,32,32,32,32,78,250,18,99,97,110,39,116,32,102,105,
+ 110,100,32,109,111,100,117,108,101,32,169,1,114,44,0,0,
+ 0,250,11,95,95,105,110,105,116,95,95,46,112,121,250,3,
46,112,121,41,10,114,35,0,0,0,114,3,0,0,0,114,
36,0,0,0,114,21,0,0,0,114,30,0,0,0,114,28,
- 0,0,0,114,26,0,0,0,114,52,0,0,0,114,29,0,
+ 0,0,0,114,26,0,0,0,114,56,0,0,0,114,29,0,
0,0,218,6,100,101,99,111,100,101,41,6,114,32,0,0,
0,114,38,0,0,0,114,39,0,0,0,114,13,0,0,0,
- 218,8,102,117,108,108,112,97,116,104,114,54,0,0,0,114,
+ 218,8,102,117,108,108,112,97,116,104,114,58,0,0,0,114,
9,0,0,0,114,9,0,0,0,114,10,0,0,0,218,10,
- 103,101,116,95,115,111,117,114,99,101,195,0,0,0,115,24,
- 0,0,0,0,7,10,1,8,1,18,2,10,1,4,1,14,
- 2,10,2,2,1,14,1,12,2,8,1,122,22,122,105,112,
- 105,109,112,111,114,116,101,114,46,103,101,116,95,115,111,117,
- 114,99,101,99,2,0,0,0,0,0,0,0,0,0,0,0,
- 3,0,0,0,4,0,0,0,67,0,0,0,115,40,0,0,
- 0,116,0,124,0,124,1,131,2,125,2,124,2,100,1,117,
- 0,114,36,116,1,100,2,124,1,155,2,157,2,124,1,100,
- 3,141,2,130,1,124,2,83,0,41,4,122,171,105,115,95,
- 112,97,99,107,97,103,101,40,102,117,108,108,110,97,109,101,
- 41,32,45,62,32,98,111,111,108,46,10,10,32,32,32,32,
- 32,32,32,32,82,101,116,117,114,110,32,84,114,117,101,32,
- 105,102,32,116,104,101,32,109,111,100,117,108,101,32,115,112,
- 101,99,105,102,105,101,100,32,98,121,32,102,117,108,108,110,
- 97,109,101,32,105,115,32,97,32,112,97,99,107,97,103,101,
- 46,10,32,32,32,32,32,32,32,32,82,97,105,115,101,32,
- 90,105,112,73,109,112,111,114,116,69,114,114,111,114,32,105,
- 102,32,116,104,101,32,109,111,100,117,108,101,32,99,111,117,
- 108,100,110,39,116,32,98,101,32,102,111,117,110,100,46,10,
- 32,32,32,32,32,32,32,32,78,114,57,0,0,0,114,58,
- 0,0,0,41,2,114,35,0,0,0,114,3,0,0,0,41,
- 3,114,32,0,0,0,114,38,0,0,0,114,39,0,0,0,
- 114,9,0,0,0,114,9,0,0,0,114,10,0,0,0,218,
- 10,105,115,95,112,97,99,107,97,103,101,221,0,0,0,115,
- 8,0,0,0,0,6,10,1,8,1,18,1,122,22,122,105,
- 112,105,109,112,111,114,116,101,114,46,105,115,95,112,97,99,
- 107,97,103,101,99,2,0,0,0,0,0,0,0,0,0,0,
- 0,8,0,0,0,8,0,0,0,67,0,0,0,115,246,0,
- 0,0,116,0,124,0,124,1,131,2,92,3,125,2,125,3,
- 125,4,116,1,106,2,160,3,124,1,161,1,125,5,124,5,
- 100,1,117,0,115,46,116,4,124,5,116,5,131,2,115,64,
- 116,5,124,1,131,1,125,5,124,5,116,1,106,2,124,1,
- 60,0,124,0,124,5,95,6,122,84,124,3,114,108,116,7,
- 124,0,124,1,131,2,125,6,116,8,160,9,124,0,106,10,
- 124,6,161,2,125,7,124,7,103,1,124,5,95,11,116,12,
- 124,5,100,2,131,2,115,124,116,13,124,5,95,13,116,8,
- 160,14,124,5,106,15,124,1,124,4,161,3,1,0,116,16,
- 124,2,124,5,106,15,131,2,1,0,87,0,110,22,1,0,
- 1,0,1,0,116,1,106,2,124,1,61,0,130,0,89,0,
- 110,2,48,0,122,14,116,1,106,2,124,1,25,0,125,5,
- 87,0,110,34,4,0,116,17,121,226,1,0,1,0,1,0,
- 116,18,100,3,124,1,155,2,100,4,157,3,131,1,130,1,
- 89,0,110,2,48,0,116,19,160,20,100,5,124,1,124,4,
- 161,3,1,0,124,5,83,0,41,6,122,245,108,111,97,100,
- 95,109,111,100,117,108,101,40,102,117,108,108,110,97,109,101,
- 41,32,45,62,32,109,111,100,117,108,101,46,10,10,32,32,
- 32,32,32,32,32,32,76,111,97,100,32,116,104,101,32,109,
- 111,100,117,108,101,32,115,112,101,99,105,102,105,101,100,32,
- 98,121,32,39,102,117,108,108,110,97,109,101,39,46,32,39,
- 102,117,108,108,110,97,109,101,39,32,109,117,115,116,32,98,
- 101,32,116,104,101,10,32,32,32,32,32,32,32,32,102,117,
- 108,108,121,32,113,117,97,108,105,102,105,101,100,32,40,100,
- 111,116,116,101,100,41,32,109,111,100,117,108,101,32,110,97,
- 109,101,46,32,73,116,32,114,101,116,117,114,110,115,32,116,
- 104,101,32,105,109,112,111,114,116,101,100,10,32,32,32,32,
- 32,32,32,32,109,111,100,117,108,101,44,32,111,114,32,114,
- 97,105,115,101,115,32,90,105,112,73,109,112,111,114,116,69,
- 114,114,111,114,32,105,102,32,105,116,32,119,97,115,110,39,
- 116,32,102,111,117,110,100,46,10,32,32,32,32,32,32,32,
- 32,78,218,12,95,95,98,117,105,108,116,105,110,115,95,95,
- 122,14,76,111,97,100,101,100,32,109,111,100,117,108,101,32,
- 122,25,32,110,111,116,32,102,111,117,110,100,32,105,110,32,
- 115,121,115,46,109,111,100,117,108,101,115,122,30,105,109,112,
- 111,114,116,32,123,125,32,35,32,108,111,97,100,101,100,32,
- 102,114,111,109,32,90,105,112,32,123,125,41,21,114,44,0,
- 0,0,218,3,115,121,115,218,7,109,111,100,117,108,101,115,
- 218,3,103,101,116,114,15,0,0,0,218,12,95,109,111,100,
- 117,108,101,95,116,121,112,101,218,10,95,95,108,111,97,100,
- 101,114,95,95,114,36,0,0,0,114,21,0,0,0,114,30,
- 0,0,0,114,29,0,0,0,90,8,95,95,112,97,116,104,
- 95,95,218,7,104,97,115,97,116,116,114,114,66,0,0,0,
- 90,14,95,102,105,120,95,117,112,95,109,111,100,117,108,101,
- 218,8,95,95,100,105,99,116,95,95,218,4,101,120,101,99,
- 114,26,0,0,0,218,11,73,109,112,111,114,116,69,114,114,
- 111,114,218,10,95,98,111,111,116,115,116,114,97,112,218,16,
- 95,118,101,114,98,111,115,101,95,109,101,115,115,97,103,101,
- 41,8,114,32,0,0,0,114,38,0,0,0,114,46,0,0,
- 0,114,47,0,0,0,114,40,0,0,0,90,3,109,111,100,
- 114,13,0,0,0,114,63,0,0,0,114,9,0,0,0,114,
- 9,0,0,0,114,10,0,0,0,218,11,108,111,97,100,95,
- 109,111,100,117,108,101,234,0,0,0,115,48,0,0,0,0,
- 7,16,1,12,1,18,1,8,1,10,1,6,2,2,1,4,
- 3,10,1,14,1,8,2,10,1,6,1,16,1,16,1,6,
- 1,8,1,8,2,2,1,14,1,12,1,22,1,14,1,122,
- 23,122,105,112,105,109,112,111,114,116,101,114,46,108,111,97,
- 100,95,109,111,100,117,108,101,99,2,0,0,0,0,0,0,
- 0,0,0,0,0,3,0,0,0,8,0,0,0,67,0,0,
- 0,115,64,0,0,0,122,20,124,0,160,0,124,1,161,1,
- 115,18,87,0,100,1,83,0,87,0,110,20,4,0,116,1,
- 121,40,1,0,1,0,1,0,89,0,100,1,83,0,48,0,
+ 103,101,116,95,115,111,117,114,99,101,227,0,0,0,115,28,
+ 0,0,0,10,7,8,1,18,1,10,2,4,1,14,1,10,
+ 2,2,2,14,1,12,1,6,2,16,1,2,253,255,128,122,
+ 22,122,105,112,105,109,112,111,114,116,101,114,46,103,101,116,
+ 95,115,111,117,114,99,101,99,2,0,0,0,0,0,0,0,
+ 0,0,0,0,3,0,0,0,4,0,0,0,67,0,0,0,
+ 115,40,0,0,0,116,0,124,0,124,1,131,2,125,2,124,
+ 2,100,1,117,0,114,36,116,1,100,2,124,1,155,2,157,
+ 2,124,1,100,3,141,2,130,1,124,2,83,0,41,4,122,
+ 171,105,115,95,112,97,99,107,97,103,101,40,102,117,108,108,
+ 110,97,109,101,41,32,45,62,32,98,111,111,108,46,10,10,
+ 32,32,32,32,32,32,32,32,82,101,116,117,114,110,32,84,
+ 114,117,101,32,105,102,32,116,104,101,32,109,111,100,117,108,
+ 101,32,115,112,101,99,105,102,105,101,100,32,98,121,32,102,
+ 117,108,108,110,97,109,101,32,105,115,32,97,32,112,97,99,
+ 107,97,103,101,46,10,32,32,32,32,32,32,32,32,82,97,
+ 105,115,101,32,90,105,112,73,109,112,111,114,116,69,114,114,
+ 111,114,32,105,102,32,116,104,101,32,109,111,100,117,108,101,
+ 32,99,111,117,108,100,110,39,116,32,98,101,32,102,111,117,
+ 110,100,46,10,32,32,32,32,32,32,32,32,78,114,61,0,
+ 0,0,114,62,0,0,0,41,2,114,35,0,0,0,114,3,
+ 0,0,0,41,3,114,32,0,0,0,114,38,0,0,0,114,
+ 39,0,0,0,114,9,0,0,0,114,9,0,0,0,114,10,
+ 0,0,0,114,43,0,0,0,253,0,0,0,115,10,0,0,
+ 0,10,6,8,1,18,1,4,1,255,128,122,22,122,105,112,
+ 105,109,112,111,114,116,101,114,46,105,115,95,112,97,99,107,
+ 97,103,101,99,2,0,0,0,0,0,0,0,0,0,0,0,
+ 9,0,0,0,8,0,0,0,67,0,0,0,115,252,0,0,
+ 0,100,1,125,2,116,0,160,1,124,2,116,2,161,2,1,
+ 0,116,3,124,0,124,1,131,2,92,3,125,3,125,4,125,
+ 5,116,4,106,5,160,6,124,1,161,1,125,6,124,6,100,
+ 2,117,0,115,62,116,7,124,6,116,8,131,2,115,80,116,
+ 8,124,1,131,1,125,6,124,6,116,4,106,5,124,1,60,
+ 0,124,0,124,6,95,9,122,84,124,4,114,124,116,10,124,
+ 0,124,1,131,2,125,7,116,11,160,12,124,0,106,13,124,
+ 7,161,2,125,8,124,8,103,1,124,6,95,14,116,15,124,
+ 6,100,3,131,2,115,140,116,16,124,6,95,16,116,11,160,
+ 17,124,6,106,18,124,1,124,5,161,3,1,0,116,19,124,
+ 3,124,6,106,18,131,2,1,0,87,0,110,16,1,0,1,
+ 0,1,0,116,4,106,5,124,1,61,0,130,0,122,14,116,
+ 4,106,5,124,1,25,0,125,6,87,0,110,28,4,0,116,
+ 20,121,250,1,0,1,0,1,0,116,21,100,4,124,1,155,
+ 2,100,5,157,3,131,1,130,1,116,22,160,23,100,6,124,
+ 1,124,5,161,3,1,0,124,6,83,0,119,0,41,7,97,
+ 64,1,0,0,108,111,97,100,95,109,111,100,117,108,101,40,
+ 102,117,108,108,110,97,109,101,41,32,45,62,32,109,111,100,
+ 117,108,101,46,10,10,32,32,32,32,32,32,32,32,76,111,
+ 97,100,32,116,104,101,32,109,111,100,117,108,101,32,115,112,
+ 101,99,105,102,105,101,100,32,98,121,32,39,102,117,108,108,
+ 110,97,109,101,39,46,32,39,102,117,108,108,110,97,109,101,
+ 39,32,109,117,115,116,32,98,101,32,116,104,101,10,32,32,
+ 32,32,32,32,32,32,102,117,108,108,121,32,113,117,97,108,
+ 105,102,105,101,100,32,40,100,111,116,116,101,100,41,32,109,
+ 111,100,117,108,101,32,110,97,109,101,46,32,73,116,32,114,
+ 101,116,117,114,110,115,32,116,104,101,32,105,109,112,111,114,
+ 116,101,100,10,32,32,32,32,32,32,32,32,109,111,100,117,
+ 108,101,44,32,111,114,32,114,97,105,115,101,115,32,90,105,
+ 112,73,109,112,111,114,116,69,114,114,111,114,32,105,102,32,
+ 105,116,32,99,111,117,108,100,32,110,111,116,32,98,101,32,
+ 105,109,112,111,114,116,101,100,46,10,10,32,32,32,32,32,
+ 32,32,32,68,101,112,114,101,99,97,116,101,100,32,115,105,
+ 110,99,101,32,80,121,116,104,111,110,32,51,46,49,48,46,
+ 32,85,115,101,32,101,120,101,99,95,109,111,100,117,108,101,
+ 40,41,32,105,110,115,116,101,97,100,46,10,32,32,32,32,
+ 32,32,32,32,122,114,122,105,112,105,109,112,111,114,116,46,
+ 122,105,112,105,109,112,111,114,116,101,114,46,108,111,97,100,
+ 95,109,111,100,117,108,101,40,41,32,105,115,32,100,101,112,
+ 114,101,99,97,116,101,100,32,97,110,100,32,115,108,97,116,
+ 101,100,32,102,111,114,32,114,101,109,111,118,97,108,32,105,
+ 110,32,80,121,116,104,111,110,32,51,46,49,50,59,32,117,
+ 115,101,32,101,120,101,99,95,109,111,100,117,108,101,40,41,
+ 32,105,110,115,116,101,97,100,78,218,12,95,95,98,117,105,
+ 108,116,105,110,115,95,95,122,14,76,111,97,100,101,100,32,
+ 109,111,100,117,108,101,32,122,25,32,110,111,116,32,102,111,
+ 117,110,100,32,105,110,32,115,121,115,46,109,111,100,117,108,
+ 101,115,122,30,105,109,112,111,114,116,32,123,125,32,35,32,
+ 108,111,97,100,101,100,32,102,114,111,109,32,90,105,112,32,
+ 123,125,41,24,218,9,95,119,97,114,110,105,110,103,115,90,
+ 4,119,97,114,110,218,18,68,101,112,114,101,99,97,116,105,
+ 111,110,87,97,114,110,105,110,103,114,48,0,0,0,218,3,
+ 115,121,115,218,7,109,111,100,117,108,101,115,218,3,103,101,
+ 116,114,15,0,0,0,218,12,95,109,111,100,117,108,101,95,
+ 116,121,112,101,218,10,95,95,108,111,97,100,101,114,95,95,
+ 114,36,0,0,0,114,21,0,0,0,114,30,0,0,0,114,
+ 29,0,0,0,90,8,95,95,112,97,116,104,95,95,218,7,
+ 104,97,115,97,116,116,114,114,68,0,0,0,90,14,95,102,
+ 105,120,95,117,112,95,109,111,100,117,108,101,218,8,95,95,
+ 100,105,99,116,95,95,218,4,101,120,101,99,114,26,0,0,
+ 0,218,11,73,109,112,111,114,116,69,114,114,111,114,114,45,
+ 0,0,0,218,16,95,118,101,114,98,111,115,101,95,109,101,
+ 115,115,97,103,101,41,9,114,32,0,0,0,114,38,0,0,
+ 0,218,3,109,115,103,114,50,0,0,0,114,51,0,0,0,
+ 114,40,0,0,0,90,3,109,111,100,114,13,0,0,0,114,
+ 66,0,0,0,114,9,0,0,0,114,9,0,0,0,114,10,
+ 0,0,0,218,11,108,111,97,100,95,109,111,100,117,108,101,
+ 10,1,0,0,115,56,0,0,0,4,9,12,2,16,1,12,
+ 1,18,1,8,1,10,1,6,1,2,2,4,1,10,3,14,
+ 1,8,1,10,2,6,1,16,1,16,1,6,1,8,1,2,
+ 1,2,2,14,1,12,1,16,1,14,1,4,1,2,253,255,
+ 128,122,23,122,105,112,105,109,112,111,114,116,101,114,46,108,
+ 111,97,100,95,109,111,100,117,108,101,99,2,0,0,0,0,
+ 0,0,0,0,0,0,0,3,0,0,0,8,0,0,0,67,
+ 0,0,0,115,64,0,0,0,122,20,124,0,160,0,124,1,
+ 161,1,115,18,87,0,100,1,83,0,87,0,110,18,4,0,
+ 116,1,121,62,1,0,1,0,1,0,89,0,100,1,83,0,
100,2,100,3,108,2,109,3,125,2,1,0,124,2,124,0,
- 124,1,131,2,83,0,41,4,122,204,82,101,116,117,114,110,
- 32,116,104,101,32,82,101,115,111,117,114,99,101,82,101,97,
- 100,101,114,32,102,111,114,32,97,32,112,97,99,107,97,103,
- 101,32,105,110,32,97,32,122,105,112,32,102,105,108,101,46,
- 10,10,32,32,32,32,32,32,32,32,73,102,32,39,102,117,
- 108,108,110,97,109,101,39,32,105,115,32,97,32,112,97,99,
- 107,97,103,101,32,119,105,116,104,105,110,32,116,104,101,32,
- 122,105,112,32,102,105,108,101,44,32,114,101,116,117,114,110,
- 32,116,104,101,10,32,32,32,32,32,32,32,32,39,82,101,
- 115,111,117,114,99,101,82,101,97,100,101,114,39,32,111,98,
- 106,101,99,116,32,102,111,114,32,116,104,101,32,112,97,99,
- 107,97,103,101,46,32,32,79,116,104,101,114,119,105,115,101,
- 32,114,101,116,117,114,110,32,78,111,110,101,46,10,32,32,
- 32,32,32,32,32,32,78,114,0,0,0,0,41,1,218,9,
- 90,105,112,82,101,97,100,101,114,41,4,114,65,0,0,0,
- 114,3,0,0,0,90,17,105,109,112,111,114,116,108,105,98,
- 46,114,101,97,100,101,114,115,114,79,0,0,0,41,3,114,
- 32,0,0,0,114,38,0,0,0,114,79,0,0,0,114,9,
- 0,0,0,114,9,0,0,0,114,10,0,0,0,218,19,103,
- 101,116,95,114,101,115,111,117,114,99,101,95,114,101,97,100,
- 101,114,16,1,0,0,115,14,0,0,0,0,6,2,1,10,
- 1,10,1,12,1,8,1,12,1,122,31,122,105,112,105,109,
- 112,111,114,116,101,114,46,103,101,116,95,114,101,115,111,117,
- 114,99,101,95,114,101,97,100,101,114,99,1,0,0,0,0,
- 0,0,0,0,0,0,0,1,0,0,0,5,0,0,0,67,
- 0,0,0,115,24,0,0,0,100,1,124,0,106,0,155,0,
- 116,1,155,0,124,0,106,2,155,0,100,2,157,5,83,0,
- 41,3,78,122,21,60,122,105,112,105,109,112,111,114,116,101,
- 114,32,111,98,106,101,99,116,32,34,122,2,34,62,41,3,
- 114,29,0,0,0,114,20,0,0,0,114,31,0,0,0,41,
- 1,114,32,0,0,0,114,9,0,0,0,114,9,0,0,0,
- 114,10,0,0,0,218,8,95,95,114,101,112,114,95,95,31,
- 1,0,0,115,2,0,0,0,0,1,122,20,122,105,112,105,
- 109,112,111,114,116,101,114,46,95,95,114,101,112,114,95,95,
- 41,1,78,41,1,78,41,15,114,6,0,0,0,114,7,0,
- 0,0,114,8,0,0,0,218,7,95,95,100,111,99,95,95,
- 114,34,0,0,0,114,41,0,0,0,114,42,0,0,0,114,
- 48,0,0,0,114,55,0,0,0,114,56,0,0,0,114,64,
- 0,0,0,114,65,0,0,0,114,78,0,0,0,114,80,0,
- 0,0,114,81,0,0,0,114,9,0,0,0,114,9,0,0,
+ 124,1,131,2,83,0,119,0,41,4,122,204,82,101,116,117,
+ 114,110,32,116,104,101,32,82,101,115,111,117,114,99,101,82,
+ 101,97,100,101,114,32,102,111,114,32,97,32,112,97,99,107,
+ 97,103,101,32,105,110,32,97,32,122,105,112,32,102,105,108,
+ 101,46,10,10,32,32,32,32,32,32,32,32,73,102,32,39,
+ 102,117,108,108,110,97,109,101,39,32,105,115,32,97,32,112,
+ 97,99,107,97,103,101,32,119,105,116,104,105,110,32,116,104,
+ 101,32,122,105,112,32,102,105,108,101,44,32,114,101,116,117,
+ 114,110,32,116,104,101,10,32,32,32,32,32,32,32,32,39,
+ 82,101,115,111,117,114,99,101,82,101,97,100,101,114,39,32,
+ 111,98,106,101,99,116,32,102,111,114,32,116,104,101,32,112,
+ 97,99,107,97,103,101,46,32,32,79,116,104,101,114,119,105,
+ 115,101,32,114,101,116,117,114,110,32,78,111,110,101,46,10,
+ 32,32,32,32,32,32,32,32,78,114,0,0,0,0,41,1,
+ 218,9,90,105,112,82,101,97,100,101,114,41,4,114,43,0,
+ 0,0,114,3,0,0,0,90,17,105,109,112,111,114,116,108,
+ 105,98,46,114,101,97,100,101,114,115,114,83,0,0,0,41,
+ 3,114,32,0,0,0,114,38,0,0,0,114,83,0,0,0,
+ 114,9,0,0,0,114,9,0,0,0,114,10,0,0,0,218,
+ 19,103,101,116,95,114,101,115,111,117,114,99,101,95,114,101,
+ 97,100,101,114,53,1,0,0,115,18,0,0,0,2,6,10,
+ 1,10,1,12,1,6,1,12,1,10,1,2,253,255,128,122,
+ 31,122,105,112,105,109,112,111,114,116,101,114,46,103,101,116,
+ 95,114,101,115,111,117,114,99,101,95,114,101,97,100,101,114,
+ 99,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
+ 0,5,0,0,0,67,0,0,0,115,24,0,0,0,100,1,
+ 124,0,106,0,155,0,116,1,155,0,124,0,106,2,155,0,
+ 100,2,157,5,83,0,41,3,78,122,21,60,122,105,112,105,
+ 109,112,111,114,116,101,114,32,111,98,106,101,99,116,32,34,
+ 122,2,34,62,41,3,114,29,0,0,0,114,20,0,0,0,
+ 114,31,0,0,0,41,1,114,32,0,0,0,114,9,0,0,
+ 0,114,9,0,0,0,114,10,0,0,0,218,8,95,95,114,
+ 101,112,114,95,95,68,1,0,0,115,4,0,0,0,24,1,
+ 255,128,122,20,122,105,112,105,109,112,111,114,116,101,114,46,
+ 95,95,114,101,112,114,95,95,41,1,78,41,1,78,41,1,
+ 78,41,16,114,6,0,0,0,114,7,0,0,0,114,8,0,
+ 0,0,218,7,95,95,100,111,99,95,95,114,34,0,0,0,
+ 114,41,0,0,0,114,42,0,0,0,114,46,0,0,0,114,
+ 52,0,0,0,114,59,0,0,0,114,60,0,0,0,114,67,
+ 0,0,0,114,43,0,0,0,114,82,0,0,0,114,84,0,
+ 0,0,114,85,0,0,0,114,9,0,0,0,114,9,0,0,
0,114,9,0,0,0,114,10,0,0,0,114,4,0,0,0,
- 45,0,0,0,115,24,0,0,0,8,1,4,17,8,46,10,
- 32,10,12,8,10,8,21,8,11,8,26,8,13,8,38,8,
- 15,122,12,95,95,105,110,105,116,95,95,46,112,121,99,84,
- 114,60,0,0,0,70,41,3,122,4,46,112,121,99,84,70,
- 41,3,114,61,0,0,0,70,70,99,2,0,0,0,0,0,
- 0,0,0,0,0,0,2,0,0,0,4,0,0,0,67,0,
- 0,0,115,20,0,0,0,124,0,106,0,124,1,160,1,100,
- 1,161,1,100,2,25,0,23,0,83,0,41,3,78,218,1,
- 46,233,2,0,0,0,41,2,114,31,0,0,0,218,10,114,
- 112,97,114,116,105,116,105,111,110,41,2,114,32,0,0,0,
- 114,38,0,0,0,114,9,0,0,0,114,9,0,0,0,114,
- 10,0,0,0,114,36,0,0,0,49,1,0,0,115,2,0,
- 0,0,0,1,114,36,0,0,0,99,2,0,0,0,0,0,
- 0,0,0,0,0,0,3,0,0,0,2,0,0,0,67,0,
- 0,0,115,18,0,0,0,124,1,116,0,23,0,125,2,124,
- 2,124,0,106,1,118,0,83,0,169,1,78,41,2,114,20,
- 0,0,0,114,28,0,0,0,41,3,114,32,0,0,0,114,
- 13,0,0,0,90,7,100,105,114,112,97,116,104,114,9,0,
- 0,0,114,9,0,0,0,114,10,0,0,0,114,37,0,0,
- 0,53,1,0,0,115,4,0,0,0,0,4,8,2,114,37,
- 0,0,0,99,2,0,0,0,0,0,0,0,0,0,0,0,
- 7,0,0,0,4,0,0,0,67,0,0,0,115,54,0,0,
- 0,116,0,124,0,124,1,131,2,125,2,116,1,68,0,93,
- 34,92,3,125,3,125,4,125,5,124,2,124,3,23,0,125,
- 6,124,6,124,0,106,2,118,0,114,14,124,5,2,0,1,
- 0,83,0,100,0,83,0,114,86,0,0,0,41,3,114,36,
- 0,0,0,218,16,95,122,105,112,95,115,101,97,114,99,104,
- 111,114,100,101,114,114,28,0,0,0,41,7,114,32,0,0,
- 0,114,38,0,0,0,114,13,0,0,0,218,6,115,117,102,
- 102,105,120,218,10,105,115,98,121,116,101,99,111,100,101,114,
- 47,0,0,0,114,63,0,0,0,114,9,0,0,0,114,9,
- 0,0,0,114,10,0,0,0,114,35,0,0,0,62,1,0,
- 0,115,12,0,0,0,0,1,10,1,14,1,8,1,10,1,
- 8,1,114,35,0,0,0,99,1,0,0,0,0,0,0,0,
+ 46,0,0,0,115,30,0,0,0,8,0,4,1,8,17,10,
+ 46,10,34,10,13,8,27,8,10,8,21,8,12,8,26,8,
+ 13,8,43,12,15,255,128,122,12,95,95,105,110,105,116,95,
+ 95,46,112,121,99,84,114,63,0,0,0,70,41,3,122,4,
+ 46,112,121,99,84,70,41,3,114,64,0,0,0,70,70,99,
+ 2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,
+ 4,0,0,0,67,0,0,0,115,20,0,0,0,124,0,106,
+ 0,124,1,160,1,100,1,161,1,100,2,25,0,23,0,83,
+ 0,41,3,78,218,1,46,233,2,0,0,0,41,2,114,31,
+ 0,0,0,218,10,114,112,97,114,116,105,116,105,111,110,41,
+ 2,114,32,0,0,0,114,38,0,0,0,114,9,0,0,0,
+ 114,9,0,0,0,114,10,0,0,0,114,36,0,0,0,86,
+ 1,0,0,115,4,0,0,0,20,1,255,128,114,36,0,0,
+ 0,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0,
+ 0,0,2,0,0,0,67,0,0,0,115,18,0,0,0,124,
+ 1,116,0,23,0,125,2,124,2,124,0,106,1,118,0,83,
+ 0,169,1,78,41,2,114,20,0,0,0,114,28,0,0,0,
+ 41,3,114,32,0,0,0,114,13,0,0,0,90,7,100,105,
+ 114,112,97,116,104,114,9,0,0,0,114,9,0,0,0,114,
+ 10,0,0,0,114,37,0,0,0,90,1,0,0,115,6,0,
+ 0,0,8,4,10,2,255,128,114,37,0,0,0,99,2,0,
+ 0,0,0,0,0,0,0,0,0,0,7,0,0,0,4,0,
+ 0,0,67,0,0,0,115,56,0,0,0,116,0,124,0,124,
+ 1,131,2,125,2,116,1,68,0,93,36,92,3,125,3,125,
+ 4,125,5,124,2,124,3,23,0,125,6,124,6,124,0,106,
+ 2,118,0,114,50,124,5,2,0,1,0,83,0,113,14,100,
+ 0,83,0,114,90,0,0,0,41,3,114,36,0,0,0,218,
+ 16,95,122,105,112,95,115,101,97,114,99,104,111,114,100,101,
+ 114,114,28,0,0,0,41,7,114,32,0,0,0,114,38,0,
+ 0,0,114,13,0,0,0,218,6,115,117,102,102,105,120,218,
+ 10,105,115,98,121,116,101,99,111,100,101,114,51,0,0,0,
+ 114,66,0,0,0,114,9,0,0,0,114,9,0,0,0,114,
+ 10,0,0,0,114,35,0,0,0,99,1,0,0,115,16,0,
+ 0,0,10,1,14,1,8,1,10,1,8,1,2,128,4,1,
+ 255,128,114,35,0,0,0,99,1,0,0,0,0,0,0,0,
0,0,0,0,26,0,0,0,9,0,0,0,67,0,0,0,
- 115,2,5,0,0,122,14,116,0,160,1,124,0,161,1,125,
- 1,87,0,110,36,4,0,116,2,121,50,1,0,1,0,1,
- 0,116,3,100,1,124,0,155,2,157,2,124,0,100,2,141,
- 2,130,1,89,0,110,2,48,0,124,1,144,4,143,164,1,
- 0,122,36,124,1,160,4,116,5,11,0,100,3,161,2,1,
- 0,124,1,160,6,161,0,125,2,124,1,160,7,116,5,161,
- 1,125,3,87,0,110,36,4,0,116,2,121,132,1,0,1,
- 0,1,0,116,3,100,4,124,0,155,2,157,2,124,0,100,
- 2,141,2,130,1,89,0,110,2,48,0,116,8,124,3,131,
- 1,116,5,107,3,114,164,116,3,100,4,124,0,155,2,157,
- 2,124,0,100,2,141,2,130,1,124,3,100,0,100,5,133,
- 2,25,0,116,9,107,3,144,1,114,170,122,24,124,1,160,
- 4,100,6,100,3,161,2,1,0,124,1,160,6,161,0,125,
- 4,87,0,110,36,4,0,116,2,121,242,1,0,1,0,1,
- 0,116,3,100,4,124,0,155,2,157,2,124,0,100,2,141,
- 2,130,1,89,0,110,2,48,0,116,10,124,4,116,11,24,
- 0,116,5,24,0,100,6,131,2,125,5,122,22,124,1,160,
- 4,124,5,161,1,1,0,124,1,160,7,161,0,125,6,87,
- 0,110,38,4,0,116,2,144,1,121,66,1,0,1,0,1,
+ 115,236,4,0,0,122,14,116,0,160,1,124,0,161,1,125,
+ 1,87,0,110,32,4,0,116,2,144,4,121,234,1,0,1,
+ 0,1,0,116,3,100,1,124,0,155,2,157,2,124,0,100,
+ 2,141,2,130,1,124,1,144,4,143,130,1,0,122,36,124,
+ 1,160,4,116,5,11,0,100,3,161,2,1,0,124,1,160,
+ 6,161,0,125,2,124,1,160,7,116,5,161,1,125,3,87,
+ 0,110,32,4,0,116,2,144,4,121,232,1,0,1,0,1,
0,116,3,100,4,124,0,155,2,157,2,124,0,100,2,141,
- 2,130,1,89,0,110,2,48,0,124,6,160,12,116,9,161,
- 1,125,7,124,7,100,6,107,0,144,1,114,106,116,3,100,
- 7,124,0,155,2,157,2,124,0,100,2,141,2,130,1,124,
- 6,124,7,124,7,116,5,23,0,133,2,25,0,125,3,116,
- 8,124,3,131,1,116,5,107,3,144,1,114,154,116,3,100,
- 8,124,0,155,2,157,2,124,0,100,2,141,2,130,1,124,
- 4,116,8,124,6,131,1,24,0,124,7,23,0,125,2,116,
- 13,124,3,100,9,100,10,133,2,25,0,131,1,125,8,116,
- 13,124,3,100,10,100,11,133,2,25,0,131,1,125,9,124,
- 2,124,8,107,0,144,1,114,230,116,3,100,12,124,0,155,
- 2,157,2,124,0,100,2,141,2,130,1,124,2,124,9,107,
- 0,144,2,114,2,116,3,100,13,124,0,155,2,157,2,124,
- 0,100,2,141,2,130,1,124,2,124,8,56,0,125,2,124,
- 2,124,9,24,0,125,10,124,10,100,6,107,0,144,2,114,
- 46,116,3,100,14,124,0,155,2,157,2,124,0,100,2,141,
- 2,130,1,105,0,125,11,100,6,125,12,122,14,124,1,160,
- 4,124,2,161,1,1,0,87,0,110,38,4,0,116,2,144,
- 2,121,106,1,0,1,0,1,0,116,3,100,4,124,0,155,
- 2,157,2,124,0,100,2,141,2,130,1,89,0,110,2,48,
- 0,124,1,160,7,100,15,161,1,125,3,116,8,124,3,131,
- 1,100,5,107,0,144,2,114,140,116,14,100,16,131,1,130,
- 1,124,3,100,0,100,5,133,2,25,0,100,17,107,3,144,
- 2,114,162,144,4,113,208,116,8,124,3,131,1,100,15,107,
- 3,144,2,114,184,116,14,100,16,131,1,130,1,116,15,124,
- 3,100,18,100,19,133,2,25,0,131,1,125,13,116,15,124,
- 3,100,19,100,9,133,2,25,0,131,1,125,14,116,15,124,
- 3,100,9,100,20,133,2,25,0,131,1,125,15,116,15,124,
- 3,100,20,100,10,133,2,25,0,131,1,125,16,116,13,124,
- 3,100,10,100,11,133,2,25,0,131,1,125,17,116,13,124,
- 3,100,11,100,21,133,2,25,0,131,1,125,18,116,13,124,
- 3,100,21,100,22,133,2,25,0,131,1,125,4,116,15,124,
- 3,100,22,100,23,133,2,25,0,131,1,125,19,116,15,124,
- 3,100,23,100,24,133,2,25,0,131,1,125,20,116,15,124,
- 3,100,24,100,25,133,2,25,0,131,1,125,21,116,13,124,
- 3,100,26,100,15,133,2,25,0,131,1,125,22,124,19,124,
- 20,23,0,124,21,23,0,125,8,124,22,124,9,107,4,144,
- 3,114,144,116,3,100,27,124,0,155,2,157,2,124,0,100,
- 2,141,2,130,1,124,22,124,10,55,0,125,22,122,14,124,
- 1,160,7,124,19,161,1,125,23,87,0,110,38,4,0,116,
- 2,144,3,121,204,1,0,1,0,1,0,116,3,100,4,124,
- 0,155,2,157,2,124,0,100,2,141,2,130,1,89,0,110,
- 2,48,0,116,8,124,23,131,1,124,19,107,3,144,3,114,
- 238,116,3,100,4,124,0,155,2,157,2,124,0,100,2,141,
- 2,130,1,122,50,116,8,124,1,160,7,124,8,124,19,24,
- 0,161,1,131,1,124,8,124,19,24,0,107,3,144,4,114,
- 30,116,3,100,4,124,0,155,2,157,2,124,0,100,2,141,
- 2,130,1,87,0,110,38,4,0,116,2,144,4,121,70,1,
+ 2,130,1,116,8,124,3,131,1,116,5,107,3,114,156,116,
+ 3,100,4,124,0,155,2,157,2,124,0,100,2,141,2,130,
+ 1,124,3,100,0,100,5,133,2,25,0,116,9,107,3,144,
+ 1,114,152,122,24,124,1,160,4,100,6,100,3,161,2,1,
+ 0,124,1,160,6,161,0,125,4,87,0,110,32,4,0,116,
+ 2,144,4,121,230,1,0,1,0,1,0,116,3,100,4,124,
+ 0,155,2,157,2,124,0,100,2,141,2,130,1,116,10,124,
+ 4,116,11,24,0,116,5,24,0,100,6,131,2,125,5,122,
+ 22,124,1,160,4,124,5,161,1,1,0,124,1,160,7,161,
+ 0,125,6,87,0,110,32,4,0,116,2,144,4,121,228,1,
0,1,0,1,0,116,3,100,4,124,0,155,2,157,2,124,
- 0,100,2,141,2,130,1,89,0,110,2,48,0,124,13,100,
- 28,64,0,144,4,114,92,124,23,160,16,161,0,125,23,110,
- 52,122,14,124,23,160,16,100,29,161,1,125,23,87,0,110,
- 36,4,0,116,17,144,4,121,142,1,0,1,0,1,0,124,
- 23,160,16,100,30,161,1,160,18,116,19,161,1,125,23,89,
- 0,110,2,48,0,124,23,160,20,100,31,116,21,161,2,125,
- 23,116,22,160,23,124,0,124,23,161,2,125,24,124,24,124,
- 14,124,18,124,4,124,22,124,15,124,16,124,17,102,8,125,
- 25,124,25,124,11,124,23,60,0,124,12,100,32,55,0,125,
- 12,144,2,113,108,87,0,100,0,4,0,4,0,131,3,1,
- 0,110,18,49,0,144,4,115,230,48,0,1,0,1,0,1,
- 0,89,0,1,0,116,24,160,25,100,33,124,12,124,0,161,
- 3,1,0,124,11,83,0,41,34,78,122,21,99,97,110,39,
- 116,32,111,112,101,110,32,90,105,112,32,102,105,108,101,58,
- 32,114,12,0,0,0,114,84,0,0,0,250,21,99,97,110,
- 39,116,32,114,101,97,100,32,90,105,112,32,102,105,108,101,
- 58,32,233,4,0,0,0,114,0,0,0,0,122,16,110,111,
- 116,32,97,32,90,105,112,32,102,105,108,101,58,32,122,18,
- 99,111,114,114,117,112,116,32,90,105,112,32,102,105,108,101,
- 58,32,233,12,0,0,0,233,16,0,0,0,233,20,0,0,
- 0,122,28,98,97,100,32,99,101,110,116,114,97,108,32,100,
- 105,114,101,99,116,111,114,121,32,115,105,122,101,58,32,122,
- 30,98,97,100,32,99,101,110,116,114,97,108,32,100,105,114,
- 101,99,116,111,114,121,32,111,102,102,115,101,116,58,32,122,
- 38,98,97,100,32,99,101,110,116,114,97,108,32,100,105,114,
- 101,99,116,111,114,121,32,115,105,122,101,32,111,114,32,111,
- 102,102,115,101,116,58,32,233,46,0,0,0,250,27,69,79,
- 70,32,114,101,97,100,32,119,104,101,114,101,32,110,111,116,
- 32,101,120,112,101,99,116,101,100,115,4,0,0,0,80,75,
- 1,2,233,8,0,0,0,233,10,0,0,0,233,14,0,0,
- 0,233,24,0,0,0,233,28,0,0,0,233,30,0,0,0,
- 233,32,0,0,0,233,34,0,0,0,233,42,0,0,0,122,
- 25,98,97,100,32,108,111,99,97,108,32,104,101,97,100,101,
- 114,32,111,102,102,115,101,116,58,32,105,0,8,0,0,218,
- 5,97,115,99,105,105,90,6,108,97,116,105,110,49,250,1,
- 47,114,5,0,0,0,122,33,122,105,112,105,109,112,111,114,
- 116,58,32,102,111,117,110,100,32,123,125,32,110,97,109,101,
- 115,32,105,110,32,123,33,114,125,41,26,218,3,95,105,111,
- 218,9,111,112,101,110,95,99,111,100,101,114,22,0,0,0,
- 114,3,0,0,0,218,4,115,101,101,107,218,20,69,78,68,
- 95,67,69,78,84,82,65,76,95,68,73,82,95,83,73,90,
- 69,90,4,116,101,108,108,218,4,114,101,97,100,114,51,0,
- 0,0,218,18,83,84,82,73,78,71,95,69,78,68,95,65,
- 82,67,72,73,86,69,218,3,109,97,120,218,15,77,65,88,
- 95,67,79,77,77,69,78,84,95,76,69,78,218,5,114,102,
- 105,110,100,114,2,0,0,0,218,8,69,79,70,69,114,114,
- 111,114,114,1,0,0,0,114,62,0,0,0,218,18,85,110,
- 105,99,111,100,101,68,101,99,111,100,101,69,114,114,111,114,
- 218,9,116,114,97,110,115,108,97,116,101,218,11,99,112,52,
- 51,55,95,116,97,98,108,101,114,19,0,0,0,114,20,0,
- 0,0,114,21,0,0,0,114,30,0,0,0,114,76,0,0,
- 0,114,77,0,0,0,41,26,114,29,0,0,0,218,2,102,
- 112,90,15,104,101,97,100,101,114,95,112,111,115,105,116,105,
- 111,110,218,6,98,117,102,102,101,114,218,9,102,105,108,101,
- 95,115,105,122,101,90,17,109,97,120,95,99,111,109,109,101,
- 110,116,95,115,116,97,114,116,218,4,100,97,116,97,90,3,
- 112,111,115,218,11,104,101,97,100,101,114,95,115,105,122,101,
- 90,13,104,101,97,100,101,114,95,111,102,102,115,101,116,90,
- 10,97,114,99,95,111,102,102,115,101,116,114,33,0,0,0,
- 218,5,99,111,117,110,116,218,5,102,108,97,103,115,218,8,
- 99,111,109,112,114,101,115,115,218,4,116,105,109,101,218,4,
- 100,97,116,101,218,3,99,114,99,218,9,100,97,116,97,95,
- 115,105,122,101,218,9,110,97,109,101,95,115,105,122,101,218,
- 10,101,120,116,114,97,95,115,105,122,101,90,12,99,111,109,
- 109,101,110,116,95,115,105,122,101,218,11,102,105,108,101,95,
- 111,102,102,115,101,116,114,59,0,0,0,114,13,0,0,0,
- 218,1,116,114,9,0,0,0,114,9,0,0,0,114,10,0,
- 0,0,114,27,0,0,0,93,1,0,0,115,212,0,0,0,
- 0,1,2,1,14,1,12,1,24,2,8,1,2,1,14,1,
- 8,1,14,1,12,1,24,1,12,1,18,1,18,3,2,1,
- 12,1,12,1,12,1,10,1,2,255,12,2,8,1,2,255,
- 2,1,2,255,4,2,2,1,10,1,12,1,14,1,10,1,
- 2,255,12,2,10,1,10,1,10,1,2,255,6,2,16,1,
- 14,1,10,1,2,255,6,2,16,2,16,1,16,1,10,1,
- 18,1,10,1,18,1,8,1,8,1,10,1,18,2,4,2,
- 4,1,2,1,14,1,14,1,24,2,10,1,14,1,8,2,
- 18,1,4,1,14,1,8,1,16,1,16,1,16,1,16,1,
- 16,1,16,1,16,1,16,1,16,1,16,1,16,1,12,1,
- 10,1,18,1,8,2,2,1,14,1,14,1,24,1,14,1,
- 18,4,2,1,28,1,22,1,14,1,24,2,10,2,10,3,
- 2,1,14,1,14,1,22,2,12,1,12,1,20,1,8,1,
- 44,1,14,1,114,27,0,0,0,117,190,1,0,0,0,1,
- 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,
- 18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,
- 34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,
- 50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,
- 66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,
- 82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,
- 98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,
- 114,115,116,117,118,119,120,121,122,123,124,125,126,127,195,135,
- 195,188,195,169,195,162,195,164,195,160,195,165,195,167,195,170,
- 195,171,195,168,195,175,195,174,195,172,195,132,195,133,195,137,
- 195,166,195,134,195,180,195,182,195,178,195,187,195,185,195,191,
- 195,150,195,156,194,162,194,163,194,165,226,130,167,198,146,195,
- 161,195,173,195,179,195,186,195,177,195,145,194,170,194,186,194,
- 191,226,140,144,194,172,194,189,194,188,194,161,194,171,194,187,
- 226,150,145,226,150,146,226,150,147,226,148,130,226,148,164,226,
- 149,161,226,149,162,226,149,150,226,149,149,226,149,163,226,149,
- 145,226,149,151,226,149,157,226,149,156,226,149,155,226,148,144,
- 226,148,148,226,148,180,226,148,172,226,148,156,226,148,128,226,
- 148,188,226,149,158,226,149,159,226,149,154,226,149,148,226,149,
- 169,226,149,166,226,149,160,226,149,144,226,149,172,226,149,167,
- 226,149,168,226,149,164,226,149,165,226,149,153,226,149,152,226,
- 149,146,226,149,147,226,149,171,226,149,170,226,148,152,226,148,
- 140,226,150,136,226,150,132,226,150,140,226,150,144,226,150,128,
- 206,177,195,159,206,147,207,128,206,163,207,131,194,181,207,132,
- 206,166,206,152,206,169,206,180,226,136,158,207,134,206,181,226,
- 136,169,226,137,161,194,177,226,137,165,226,137,164,226,140,160,
- 226,140,161,195,183,226,137,136,194,176,226,136,153,194,183,226,
- 136,154,226,129,191,194,178,226,150,160,194,160,99,0,0,0,
- 0,0,0,0,0,0,0,0,0,1,0,0,0,8,0,0,
- 0,67,0,0,0,115,110,0,0,0,116,0,114,22,116,1,
- 160,2,100,1,161,1,1,0,116,3,100,2,131,1,130,1,
- 100,3,97,0,122,62,122,16,100,4,100,5,108,4,109,5,
- 125,0,1,0,87,0,110,36,4,0,116,6,121,80,1,0,
- 1,0,1,0,116,1,160,2,100,1,161,1,1,0,116,3,
- 100,2,131,1,130,1,89,0,110,2,48,0,87,0,100,6,
- 97,0,110,6,100,6,97,0,48,0,116,1,160,2,100,7,
- 161,1,1,0,124,0,83,0,41,8,78,122,27,122,105,112,
- 105,109,112,111,114,116,58,32,122,108,105,98,32,85,78,65,
- 86,65,73,76,65,66,76,69,250,41,99,97,110,39,116,32,
- 100,101,99,111,109,112,114,101,115,115,32,100,97,116,97,59,
- 32,122,108,105,98,32,110,111,116,32,97,118,97,105,108,97,
- 98,108,101,84,114,0,0,0,0,169,1,218,10,100,101,99,
- 111,109,112,114,101,115,115,70,122,25,122,105,112,105,109,112,
- 111,114,116,58,32,122,108,105,98,32,97,118,97,105,108,97,
- 98,108,101,41,7,218,15,95,105,109,112,111,114,116,105,110,
- 103,95,122,108,105,98,114,76,0,0,0,114,77,0,0,0,
- 114,3,0,0,0,90,4,122,108,105,98,114,139,0,0,0,
- 218,9,69,120,99,101,112,116,105,111,110,114,138,0,0,0,
- 114,9,0,0,0,114,9,0,0,0,114,10,0,0,0,218,
- 20,95,103,101,116,95,100,101,99,111,109,112,114,101,115,115,
- 95,102,117,110,99,251,1,0,0,115,24,0,0,0,0,2,
- 4,3,10,1,8,2,4,1,4,1,16,1,12,1,10,1,
- 16,2,12,2,10,1,114,142,0,0,0,99,2,0,0,0,
- 0,0,0,0,0,0,0,0,17,0,0,0,9,0,0,0,
- 67,0,0,0,115,144,1,0,0,124,1,92,8,125,2,125,
- 3,125,4,125,5,125,6,125,7,125,8,125,9,124,4,100,
- 1,107,0,114,36,116,0,100,2,131,1,130,1,116,1,160,
- 2,124,0,161,1,144,1,143,14,125,10,122,14,124,10,160,
- 3,124,6,161,1,1,0,87,0,110,36,4,0,116,4,121,
- 100,1,0,1,0,1,0,116,0,100,3,124,0,155,2,157,
- 2,124,0,100,4,141,2,130,1,89,0,110,2,48,0,124,
- 10,160,5,100,5,161,1,125,11,116,6,124,11,131,1,100,
- 5,107,3,114,132,116,7,100,6,131,1,130,1,124,11,100,
- 0,100,7,133,2,25,0,100,8,107,3,114,166,116,0,100,
- 9,124,0,155,2,157,2,124,0,100,4,141,2,130,1,116,
- 8,124,11,100,10,100,11,133,2,25,0,131,1,125,12,116,
- 8,124,11,100,11,100,5,133,2,25,0,131,1,125,13,100,
- 5,124,12,23,0,124,13,23,0,125,14,124,6,124,14,55,
- 0,125,6,122,14,124,10,160,3,124,6,161,1,1,0,87,
- 0,110,38,4,0,116,4,144,1,121,14,1,0,1,0,1,
- 0,116,0,100,3,124,0,155,2,157,2,124,0,100,4,141,
- 2,130,1,89,0,110,2,48,0,124,10,160,5,124,4,161,
- 1,125,15,116,6,124,15,131,1,124,4,107,3,144,1,114,
- 48,116,4,100,12,131,1,130,1,87,0,100,0,4,0,4,
- 0,131,3,1,0,110,18,49,0,144,1,115,70,48,0,1,
- 0,1,0,1,0,89,0,1,0,124,3,100,1,107,2,144,
- 1,114,94,124,15,83,0,122,10,116,9,131,0,125,16,87,
- 0,110,28,4,0,116,10,144,1,121,132,1,0,1,0,1,
- 0,116,0,100,13,131,1,130,1,89,0,110,2,48,0,124,
- 16,124,15,100,14,131,2,83,0,41,15,78,114,0,0,0,
- 0,122,18,110,101,103,97,116,105,118,101,32,100,97,116,97,
- 32,115,105,122,101,114,90,0,0,0,114,12,0,0,0,114,
- 102,0,0,0,114,96,0,0,0,114,91,0,0,0,115,4,
- 0,0,0,80,75,3,4,122,23,98,97,100,32,108,111,99,
- 97,108,32,102,105,108,101,32,104,101,97,100,101,114,58,32,
- 233,26,0,0,0,114,101,0,0,0,122,26,122,105,112,105,
- 109,112,111,114,116,58,32,99,97,110,39,116,32,114,101,97,
- 100,32,100,97,116,97,114,137,0,0,0,105,241,255,255,255,
- 41,11,114,3,0,0,0,114,108,0,0,0,114,109,0,0,
- 0,114,110,0,0,0,114,22,0,0,0,114,112,0,0,0,
- 114,51,0,0,0,114,117,0,0,0,114,1,0,0,0,114,
- 142,0,0,0,114,141,0,0,0,41,17,114,29,0,0,0,
- 114,54,0,0,0,90,8,100,97,116,97,112,97,116,104,114,
- 128,0,0,0,114,132,0,0,0,114,123,0,0,0,114,135,
- 0,0,0,114,129,0,0,0,114,130,0,0,0,114,131,0,
- 0,0,114,121,0,0,0,114,122,0,0,0,114,133,0,0,
- 0,114,134,0,0,0,114,125,0,0,0,90,8,114,97,119,
- 95,100,97,116,97,114,139,0,0,0,114,9,0,0,0,114,
- 9,0,0,0,114,10,0,0,0,114,52,0,0,0,16,2,
- 0,0,115,62,0,0,0,0,1,20,1,8,1,8,2,14,
- 2,2,1,14,1,12,1,24,1,10,1,12,1,8,2,16,
- 2,18,2,16,1,16,1,12,1,8,1,2,1,14,1,14,
- 1,24,1,10,1,14,1,40,2,10,2,4,3,2,1,10,
- 1,14,1,14,1,114,52,0,0,0,99,2,0,0,0,0,
- 0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,67,
- 0,0,0,115,16,0,0,0,116,0,124,0,124,1,24,0,
- 131,1,100,1,107,1,83,0,41,2,78,114,5,0,0,0,
- 41,1,218,3,97,98,115,41,2,90,2,116,49,90,2,116,
- 50,114,9,0,0,0,114,9,0,0,0,114,10,0,0,0,
- 218,9,95,101,113,95,109,116,105,109,101,62,2,0,0,115,
- 2,0,0,0,0,2,114,145,0,0,0,99,5,0,0,0,
- 0,0,0,0,0,0,0,0,14,0,0,0,8,0,0,0,
- 67,0,0,0,115,60,1,0,0,124,3,124,2,100,1,156,
- 2,125,5,122,18,116,0,160,1,124,4,124,3,124,5,161,
- 3,125,6,87,0,110,20,4,0,116,2,121,48,1,0,1,
- 0,1,0,89,0,100,0,83,0,48,0,124,6,100,2,64,
- 0,100,3,107,3,125,7,124,7,114,182,124,6,100,4,64,
- 0,100,3,107,3,125,8,116,3,106,4,100,5,107,3,144,
- 1,114,10,124,8,115,106,116,3,106,4,100,6,107,2,144,
- 1,114,10,116,5,124,0,124,2,131,2,125,9,124,9,100,
- 0,117,1,144,1,114,10,116,3,160,6,116,0,106,7,124,
- 9,161,2,125,10,122,20,116,0,160,8,124,4,124,10,124,
- 3,124,5,161,4,1,0,87,0,110,104,4,0,116,2,121,
- 180,1,0,1,0,1,0,89,0,100,0,83,0,48,0,116,
- 9,124,0,124,2,131,2,92,2,125,11,125,12,124,11,144,
- 1,114,10,116,10,116,11,124,4,100,7,100,8,133,2,25,
- 0,131,1,124,11,131,2,114,246,116,11,124,4,100,8,100,
- 9,133,2,25,0,131,1,124,12,107,3,144,1,114,10,116,
- 12,160,13,100,10,124,3,155,2,157,2,161,1,1,0,100,
- 0,83,0,116,14,160,15,124,4,100,9,100,0,133,2,25,
- 0,161,1,125,13,116,16,124,13,116,17,131,2,144,1,115,
- 56,116,18,100,11,124,1,155,2,100,12,157,3,131,1,130,
- 1,124,13,83,0,41,13,78,41,2,114,59,0,0,0,114,
- 13,0,0,0,114,5,0,0,0,114,0,0,0,0,114,84,
- 0,0,0,90,5,110,101,118,101,114,90,6,97,108,119,97,
- 121,115,114,97,0,0,0,114,92,0,0,0,114,93,0,0,
- 0,122,22,98,121,116,101,99,111,100,101,32,105,115,32,115,
- 116,97,108,101,32,102,111,114,32,122,16,99,111,109,112,105,
- 108,101,100,32,109,111,100,117,108,101,32,122,21,32,105,115,
- 32,110,111,116,32,97,32,99,111,100,101,32,111,98,106,101,
- 99,116,41,19,114,21,0,0,0,90,13,95,99,108,97,115,
- 115,105,102,121,95,112,121,99,114,75,0,0,0,218,4,95,
+ 0,100,2,141,2,130,1,124,6,160,12,116,9,161,1,125,
+ 7,124,7,100,6,107,0,144,1,114,88,116,3,100,7,124,
+ 0,155,2,157,2,124,0,100,2,141,2,130,1,124,6,124,
+ 7,124,7,116,5,23,0,133,2,25,0,125,3,116,8,124,
+ 3,131,1,116,5,107,3,144,1,114,136,116,3,100,8,124,
+ 0,155,2,157,2,124,0,100,2,141,2,130,1,124,4,116,
+ 8,124,6,131,1,24,0,124,7,23,0,125,2,116,13,124,
+ 3,100,9,100,10,133,2,25,0,131,1,125,8,116,13,124,
+ 3,100,10,100,11,133,2,25,0,131,1,125,9,124,2,124,
+ 8,107,0,144,1,114,212,116,3,100,12,124,0,155,2,157,
+ 2,124,0,100,2,141,2,130,1,124,2,124,9,107,0,144,
+ 1,114,240,116,3,100,13,124,0,155,2,157,2,124,0,100,
+ 2,141,2,130,1,124,2,124,8,56,0,125,2,124,2,124,
+ 9,24,0,125,10,124,10,100,6,107,0,144,2,114,28,116,
+ 3,100,14,124,0,155,2,157,2,124,0,100,2,141,2,130,
+ 1,105,0,125,11,100,6,125,12,122,14,124,1,160,4,124,
+ 2,161,1,1,0,87,0,110,32,4,0,116,2,144,4,121,
+ 226,1,0,1,0,1,0,116,3,100,4,124,0,155,2,157,
+ 2,124,0,100,2,141,2,130,1,9,0,124,1,160,7,100,
+ 16,161,1,125,3,116,8,124,3,131,1,100,5,107,0,144,
+ 2,114,118,116,14,100,17,131,1,130,1,124,3,100,0,100,
+ 5,133,2,25,0,100,18,107,3,144,2,114,140,144,4,113,
+ 170,116,8,124,3,131,1,100,16,107,3,144,2,114,162,116,
+ 14,100,17,131,1,130,1,116,15,124,3,100,19,100,20,133,
+ 2,25,0,131,1,125,13,116,15,124,3,100,20,100,9,133,
+ 2,25,0,131,1,125,14,116,15,124,3,100,9,100,21,133,
+ 2,25,0,131,1,125,15,116,15,124,3,100,21,100,10,133,
+ 2,25,0,131,1,125,16,116,13,124,3,100,10,100,11,133,
+ 2,25,0,131,1,125,17,116,13,124,3,100,11,100,22,133,
+ 2,25,0,131,1,125,18,116,13,124,3,100,22,100,23,133,
+ 2,25,0,131,1,125,4,116,15,124,3,100,23,100,24,133,
+ 2,25,0,131,1,125,19,116,15,124,3,100,24,100,25,133,
+ 2,25,0,131,1,125,20,116,15,124,3,100,25,100,26,133,
+ 2,25,0,131,1,125,21,116,13,124,3,100,27,100,16,133,
+ 2,25,0,131,1,125,22,124,19,124,20,23,0,124,21,23,
+ 0,125,8,124,22,124,9,107,4,144,3,114,122,116,3,100,
+ 28,124,0,155,2,157,2,124,0,100,2,141,2,130,1,124,
+ 22,124,10,55,0,125,22,122,14,124,1,160,7,124,19,161,
+ 1,125,23,87,0,110,32,4,0,116,2,144,4,121,224,1,
+ 0,1,0,1,0,116,3,100,4,124,0,155,2,157,2,124,
+ 0,100,2,141,2,130,1,116,8,124,23,131,1,124,19,107,
+ 3,144,3,114,210,116,3,100,4,124,0,155,2,157,2,124,
+ 0,100,2,141,2,130,1,122,50,116,8,124,1,160,7,124,
+ 8,124,19,24,0,161,1,131,1,124,8,124,19,24,0,107,
+ 3,144,4,114,2,116,3,100,4,124,0,155,2,157,2,124,
+ 0,100,2,141,2,130,1,87,0,110,32,4,0,116,2,144,
+ 4,121,222,1,0,1,0,1,0,116,3,100,4,124,0,155,
+ 2,157,2,124,0,100,2,141,2,130,1,124,13,100,29,64,
+ 0,144,4,114,58,124,23,160,16,161,0,125,23,110,48,122,
+ 14,124,23,160,16,100,30,161,1,125,23,87,0,110,32,4,
+ 0,116,17,144,4,121,220,1,0,1,0,1,0,124,23,160,
+ 16,100,31,161,1,160,18,116,19,161,1,125,23,89,0,124,
+ 23,160,20,100,32,116,21,161,2,125,23,116,22,160,23,124,
+ 0,124,23,161,2,125,24,124,24,124,14,124,18,124,4,124,
+ 22,124,15,124,16,124,17,102,8,125,25,124,25,124,11,124,
+ 23,60,0,124,12,100,33,55,0,125,12,144,2,113,86,87,
+ 0,100,0,4,0,4,0,131,3,1,0,110,18,49,0,144,
+ 4,115,192,119,1,1,0,1,0,1,0,89,0,1,0,116,
+ 24,160,25,100,34,124,12,124,0,161,3,1,0,124,11,83,
+ 0,119,0,119,0,119,0,119,0,119,0,119,0,119,0,119,
+ 0,41,35,78,122,21,99,97,110,39,116,32,111,112,101,110,
+ 32,90,105,112,32,102,105,108,101,58,32,114,12,0,0,0,
+ 114,88,0,0,0,250,21,99,97,110,39,116,32,114,101,97,
+ 100,32,90,105,112,32,102,105,108,101,58,32,233,4,0,0,
+ 0,114,0,0,0,0,122,16,110,111,116,32,97,32,90,105,
+ 112,32,102,105,108,101,58,32,122,18,99,111,114,114,117,112,
+ 116,32,90,105,112,32,102,105,108,101,58,32,233,12,0,0,
+ 0,233,16,0,0,0,233,20,0,0,0,122,28,98,97,100,
+ 32,99,101,110,116,114,97,108,32,100,105,114,101,99,116,111,
+ 114,121,32,115,105,122,101,58,32,122,30,98,97,100,32,99,
+ 101,110,116,114,97,108,32,100,105,114,101,99,116,111,114,121,
+ 32,111,102,102,115,101,116,58,32,122,38,98,97,100,32,99,
+ 101,110,116,114,97,108,32,100,105,114,101,99,116,111,114,121,
+ 32,115,105,122,101,32,111,114,32,111,102,102,115,101,116,58,
+ 32,84,233,46,0,0,0,250,27,69,79,70,32,114,101,97,
+ 100,32,119,104,101,114,101,32,110,111,116,32,101,120,112,101,
+ 99,116,101,100,115,4,0,0,0,80,75,1,2,233,8,0,
+ 0,0,233,10,0,0,0,233,14,0,0,0,233,24,0,0,
+ 0,233,28,0,0,0,233,30,0,0,0,233,32,0,0,0,
+ 233,34,0,0,0,233,42,0,0,0,122,25,98,97,100,32,
+ 108,111,99,97,108,32,104,101,97,100,101,114,32,111,102,102,
+ 115,101,116,58,32,105,0,8,0,0,218,5,97,115,99,105,
+ 105,90,6,108,97,116,105,110,49,250,1,47,114,5,0,0,
+ 0,122,33,122,105,112,105,109,112,111,114,116,58,32,102,111,
+ 117,110,100,32,123,125,32,110,97,109,101,115,32,105,110,32,
+ 123,33,114,125,41,26,218,3,95,105,111,218,9,111,112,101,
+ 110,95,99,111,100,101,114,22,0,0,0,114,3,0,0,0,
+ 218,4,115,101,101,107,218,20,69,78,68,95,67,69,78,84,
+ 82,65,76,95,68,73,82,95,83,73,90,69,90,4,116,101,
+ 108,108,218,4,114,101,97,100,114,55,0,0,0,218,18,83,
+ 84,82,73,78,71,95,69,78,68,95,65,82,67,72,73,86,
+ 69,218,3,109,97,120,218,15,77,65,88,95,67,79,77,77,
+ 69,78,84,95,76,69,78,218,5,114,102,105,110,100,114,2,
+ 0,0,0,218,8,69,79,70,69,114,114,111,114,114,1,0,
+ 0,0,114,65,0,0,0,218,18,85,110,105,99,111,100,101,
+ 68,101,99,111,100,101,69,114,114,111,114,218,9,116,114,97,
+ 110,115,108,97,116,101,218,11,99,112,52,51,55,95,116,97,
+ 98,108,101,114,19,0,0,0,114,20,0,0,0,114,21,0,
+ 0,0,114,30,0,0,0,114,45,0,0,0,114,80,0,0,
+ 0,41,26,114,29,0,0,0,218,2,102,112,90,15,104,101,
+ 97,100,101,114,95,112,111,115,105,116,105,111,110,218,6,98,
+ 117,102,102,101,114,218,9,102,105,108,101,95,115,105,122,101,
+ 90,17,109,97,120,95,99,111,109,109,101,110,116,95,115,116,
+ 97,114,116,218,4,100,97,116,97,90,3,112,111,115,218,11,
+ 104,101,97,100,101,114,95,115,105,122,101,90,13,104,101,97,
+ 100,101,114,95,111,102,102,115,101,116,90,10,97,114,99,95,
+ 111,102,102,115,101,116,114,33,0,0,0,218,5,99,111,117,
+ 110,116,218,5,102,108,97,103,115,218,8,99,111,109,112,114,
+ 101,115,115,218,4,116,105,109,101,218,4,100,97,116,101,218,
+ 3,99,114,99,218,9,100,97,116,97,95,115,105,122,101,218,
+ 9,110,97,109,101,95,115,105,122,101,218,10,101,120,116,114,
+ 97,95,115,105,122,101,90,12,99,111,109,109,101,110,116,95,
+ 115,105,122,101,218,11,102,105,108,101,95,111,102,102,115,101,
+ 116,114,44,0,0,0,114,13,0,0,0,218,1,116,114,9,
+ 0,0,0,114,9,0,0,0,114,10,0,0,0,114,27,0,
+ 0,0,130,1,0,0,115,234,0,0,0,2,1,14,1,14,
+ 1,18,1,8,2,2,1,14,1,8,1,14,1,14,1,18,
+ 1,12,1,18,1,18,1,2,3,12,1,12,1,14,1,10,
+ 1,2,1,6,255,8,2,2,1,2,255,2,1,4,255,2,
+ 2,10,1,12,1,14,1,10,1,2,1,6,255,10,2,10,
+ 1,10,1,2,1,6,255,16,2,14,1,10,1,2,1,6,
+ 255,16,2,16,2,16,1,10,1,18,1,10,1,18,1,8,
+ 1,8,1,10,1,18,1,4,2,4,2,2,1,14,1,14,
+ 1,18,1,2,1,10,1,14,1,8,1,18,2,4,1,14,
+ 1,8,1,16,1,16,1,16,1,16,1,16,1,16,1,16,
+ 1,16,1,16,1,16,1,16,1,12,1,10,1,18,1,8,
+ 1,2,2,14,1,14,1,18,1,14,1,18,1,2,4,28,
+ 1,22,1,14,1,18,1,10,2,10,2,2,3,14,1,14,
+ 1,18,1,12,2,12,1,20,1,8,1,8,1,36,202,14,
+ 55,4,1,2,247,2,246,2,246,2,227,2,227,2,248,2,
+ 246,2,248,255,128,114,27,0,0,0,117,190,1,0,0,0,
+ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
+ 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,
+ 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
+ 49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,
+ 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,
+ 81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,
+ 97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,
+ 113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,195,
+ 135,195,188,195,169,195,162,195,164,195,160,195,165,195,167,195,
+ 170,195,171,195,168,195,175,195,174,195,172,195,132,195,133,195,
+ 137,195,166,195,134,195,180,195,182,195,178,195,187,195,185,195,
+ 191,195,150,195,156,194,162,194,163,194,165,226,130,167,198,146,
+ 195,161,195,173,195,179,195,186,195,177,195,145,194,170,194,186,
+ 194,191,226,140,144,194,172,194,189,194,188,194,161,194,171,194,
+ 187,226,150,145,226,150,146,226,150,147,226,148,130,226,148,164,
+ 226,149,161,226,149,162,226,149,150,226,149,149,226,149,163,226,
+ 149,145,226,149,151,226,149,157,226,149,156,226,149,155,226,148,
+ 144,226,148,148,226,148,180,226,148,172,226,148,156,226,148,128,
+ 226,148,188,226,149,158,226,149,159,226,149,154,226,149,148,226,
+ 149,169,226,149,166,226,149,160,226,149,144,226,149,172,226,149,
+ 167,226,149,168,226,149,164,226,149,165,226,149,153,226,149,152,
+ 226,149,146,226,149,147,226,149,171,226,149,170,226,148,152,226,
+ 148,140,226,150,136,226,150,132,226,150,140,226,150,144,226,150,
+ 128,206,177,195,159,206,147,207,128,206,163,207,131,194,181,207,
+ 132,206,166,206,152,206,169,206,180,226,136,158,207,134,206,181,
+ 226,136,169,226,137,161,194,177,226,137,165,226,137,164,226,140,
+ 160,226,140,161,195,183,226,137,136,194,176,226,136,153,194,183,
+ 226,136,154,226,129,191,194,178,226,150,160,194,160,99,0,0,
+ 0,0,0,0,0,0,0,0,0,0,1,0,0,0,8,0,
+ 0,0,67,0,0,0,115,106,0,0,0,116,0,114,22,116,
+ 1,160,2,100,1,161,1,1,0,116,3,100,2,131,1,130,
+ 1,100,3,97,0,122,56,122,16,100,4,100,5,108,4,109,
+ 5,125,0,1,0,87,0,110,30,4,0,116,6,121,104,1,
+ 0,1,0,1,0,116,1,160,2,100,1,161,1,1,0,116,
+ 3,100,2,131,1,130,1,87,0,100,6,97,0,110,6,100,
+ 6,97,0,119,0,116,1,160,2,100,7,161,1,1,0,124,
+ 0,83,0,119,0,41,8,78,122,27,122,105,112,105,109,112,
+ 111,114,116,58,32,122,108,105,98,32,85,78,65,86,65,73,
+ 76,65,66,76,69,250,41,99,97,110,39,116,32,100,101,99,
+ 111,109,112,114,101,115,115,32,100,97,116,97,59,32,122,108,
+ 105,98,32,110,111,116,32,97,118,97,105,108,97,98,108,101,
+ 84,114,0,0,0,0,169,1,218,10,100,101,99,111,109,112,
+ 114,101,115,115,70,122,25,122,105,112,105,109,112,111,114,116,
+ 58,32,122,108,105,98,32,97,118,97,105,108,97,98,108,101,
+ 41,7,218,15,95,105,109,112,111,114,116,105,110,103,95,122,
+ 108,105,98,114,45,0,0,0,114,80,0,0,0,114,3,0,
+ 0,0,90,4,122,108,105,98,114,143,0,0,0,218,9,69,
+ 120,99,101,112,116,105,111,110,114,142,0,0,0,114,9,0,
+ 0,0,114,9,0,0,0,114,10,0,0,0,218,20,95,103,
+ 101,116,95,100,101,99,111,109,112,114,101,115,115,95,102,117,
+ 110,99,32,2,0,0,115,30,0,0,0,4,2,10,3,8,
+ 1,4,2,4,1,16,1,12,1,10,1,8,1,2,128,12,
+ 2,10,2,4,1,2,249,255,128,114,146,0,0,0,99,2,
+ 0,0,0,0,0,0,0,0,0,0,0,17,0,0,0,9,
+ 0,0,0,67,0,0,0,115,134,1,0,0,124,1,92,8,
+ 125,2,125,3,125,4,125,5,125,6,125,7,125,8,125,9,
+ 124,4,100,1,107,0,114,36,116,0,100,2,131,1,130,1,
+ 116,1,160,2,124,0,161,1,144,1,143,4,125,10,122,14,
+ 124,10,160,3,124,6,161,1,1,0,87,0,110,32,4,0,
+ 116,4,144,1,121,132,1,0,1,0,1,0,116,0,100,3,
+ 124,0,155,2,157,2,124,0,100,4,141,2,130,1,124,10,
+ 160,5,100,5,161,1,125,11,116,6,124,11,131,1,100,5,
+ 107,3,114,128,116,7,100,6,131,1,130,1,124,11,100,0,
+ 100,7,133,2,25,0,100,8,107,3,114,162,116,0,100,9,
+ 124,0,155,2,157,2,124,0,100,4,141,2,130,1,116,8,
+ 124,11,100,10,100,11,133,2,25,0,131,1,125,12,116,8,
+ 124,11,100,11,100,5,133,2,25,0,131,1,125,13,100,5,
+ 124,12,23,0,124,13,23,0,125,14,124,6,124,14,55,0,
+ 125,6,122,14,124,10,160,3,124,6,161,1,1,0,87,0,
+ 110,32,4,0,116,4,144,1,121,130,1,0,1,0,1,0,
+ 116,0,100,3,124,0,155,2,157,2,124,0,100,4,141,2,
+ 130,1,124,10,160,5,124,4,161,1,125,15,116,6,124,15,
+ 131,1,124,4,107,3,144,1,114,38,116,4,100,12,131,1,
+ 130,1,87,0,100,0,4,0,4,0,131,3,1,0,110,18,
+ 49,0,144,1,115,60,119,1,1,0,1,0,1,0,89,0,
+ 1,0,124,3,100,1,107,2,144,1,114,84,124,15,83,0,
+ 122,10,116,9,131,0,125,16,87,0,110,22,4,0,116,10,
+ 144,1,121,128,1,0,1,0,1,0,116,0,100,13,131,1,
+ 130,1,124,16,124,15,100,14,131,2,83,0,119,0,119,0,
+ 119,0,41,15,78,114,0,0,0,0,122,18,110,101,103,97,
+ 116,105,118,101,32,100,97,116,97,32,115,105,122,101,114,94,
+ 0,0,0,114,12,0,0,0,114,106,0,0,0,114,100,0,
+ 0,0,114,95,0,0,0,115,4,0,0,0,80,75,3,4,
+ 122,23,98,97,100,32,108,111,99,97,108,32,102,105,108,101,
+ 32,104,101,97,100,101,114,58,32,233,26,0,0,0,114,105,
+ 0,0,0,122,26,122,105,112,105,109,112,111,114,116,58,32,
+ 99,97,110,39,116,32,114,101,97,100,32,100,97,116,97,114,
+ 141,0,0,0,105,241,255,255,255,41,11,114,3,0,0,0,
+ 114,112,0,0,0,114,113,0,0,0,114,114,0,0,0,114,
+ 22,0,0,0,114,116,0,0,0,114,55,0,0,0,114,121,
+ 0,0,0,114,1,0,0,0,114,146,0,0,0,114,145,0,
+ 0,0,41,17,114,29,0,0,0,114,58,0,0,0,90,8,
+ 100,97,116,97,112,97,116,104,114,132,0,0,0,114,136,0,
+ 0,0,114,127,0,0,0,114,139,0,0,0,114,133,0,0,
+ 0,114,134,0,0,0,114,135,0,0,0,114,125,0,0,0,
+ 114,126,0,0,0,114,137,0,0,0,114,138,0,0,0,114,
+ 129,0,0,0,90,8,114,97,119,95,100,97,116,97,114,143,
+ 0,0,0,114,9,0,0,0,114,9,0,0,0,114,10,0,
+ 0,0,114,56,0,0,0,53,2,0,0,115,70,0,0,0,
+ 20,1,8,1,8,1,14,2,2,2,14,1,14,1,18,1,
+ 10,1,12,1,8,1,16,2,18,2,16,2,16,1,12,1,
+ 8,1,2,1,14,1,14,1,18,1,10,1,14,1,40,1,
+ 10,2,4,2,2,3,10,1,14,1,8,1,10,1,2,254,
+ 2,243,2,240,255,128,114,56,0,0,0,99,2,0,0,0,
+ 0,0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,
+ 67,0,0,0,115,16,0,0,0,116,0,124,0,124,1,24,
+ 0,131,1,100,1,107,1,83,0,41,2,78,114,5,0,0,
+ 0,41,1,218,3,97,98,115,41,2,90,2,116,49,90,2,
+ 116,50,114,9,0,0,0,114,9,0,0,0,114,10,0,0,
+ 0,218,9,95,101,113,95,109,116,105,109,101,99,2,0,0,
+ 115,4,0,0,0,16,2,255,128,114,149,0,0,0,99,5,
+ 0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,6,
+ 0,0,0,67,0,0,0,115,254,0,0,0,124,3,124,2,
+ 100,1,156,2,125,5,116,0,160,1,124,4,124,3,124,5,
+ 161,3,125,6,124,6,100,2,64,0,100,3,107,3,125,7,
+ 124,7,114,126,124,6,100,4,64,0,100,3,107,3,125,8,
+ 116,2,106,3,100,5,107,3,114,124,124,8,115,76,116,2,
+ 106,3,100,6,107,2,114,124,116,4,124,0,124,2,131,2,
+ 125,9,124,9,100,0,117,1,114,124,116,2,160,5,116,0,
+ 106,6,124,9,161,2,125,10,116,0,160,7,124,4,124,10,
+ 124,3,124,5,161,4,1,0,110,80,116,8,124,0,124,2,
+ 131,2,92,2,125,11,125,12,124,11,114,206,116,9,116,10,
+ 124,4,100,7,100,8,133,2,25,0,131,1,124,11,131,2,
+ 114,186,116,10,124,4,100,8,100,9,133,2,25,0,131,1,
+ 124,12,107,3,114,206,116,11,160,12,100,10,124,3,155,2,
+ 157,2,161,1,1,0,100,0,83,0,116,13,160,14,124,4,
+ 100,9,100,0,133,2,25,0,161,1,125,13,116,15,124,13,
+ 116,16,131,2,115,250,116,17,100,11,124,1,155,2,100,12,
+ 157,3,131,1,130,1,124,13,83,0,41,13,78,41,2,114,
+ 44,0,0,0,114,13,0,0,0,114,5,0,0,0,114,0,
+ 0,0,0,114,88,0,0,0,90,5,110,101,118,101,114,90,
+ 6,97,108,119,97,121,115,114,101,0,0,0,114,96,0,0,
+ 0,114,97,0,0,0,122,22,98,121,116,101,99,111,100,101,
+ 32,105,115,32,115,116,97,108,101,32,102,111,114,32,122,16,
+ 99,111,109,112,105,108,101,100,32,109,111,100,117,108,101,32,
+ 122,21,32,105,115,32,110,111,116,32,97,32,99,111,100,101,
+ 32,111,98,106,101,99,116,41,18,114,21,0,0,0,90,13,
+ 95,99,108,97,115,115,105,102,121,95,112,121,99,218,4,95,
105,109,112,90,21,99,104,101,99,107,95,104,97,115,104,95,
98,97,115,101,100,95,112,121,99,115,218,15,95,103,101,116,
95,112,121,99,95,115,111,117,114,99,101,218,11,115,111,117,
@@ -815,146 +876,158 @@ const unsigned char _Py_M__zipimport[] = {
65,71,73,67,95,78,85,77,66,69,82,90,18,95,118,97,
108,105,100,97,116,101,95,104,97,115,104,95,112,121,99,218,
29,95,103,101,116,95,109,116,105,109,101,95,97,110,100,95,
- 115,105,122,101,95,111,102,95,115,111,117,114,99,101,114,145,
- 0,0,0,114,2,0,0,0,114,76,0,0,0,114,77,0,
+ 115,105,122,101,95,111,102,95,115,111,117,114,99,101,114,149,
+ 0,0,0,114,2,0,0,0,114,45,0,0,0,114,80,0,
0,0,218,7,109,97,114,115,104,97,108,90,5,108,111,97,
100,115,114,15,0,0,0,218,10,95,99,111,100,101,95,116,
121,112,101,218,9,84,121,112,101,69,114,114,111,114,41,14,
- 114,32,0,0,0,114,53,0,0,0,114,63,0,0,0,114,
- 38,0,0,0,114,124,0,0,0,90,11,101,120,99,95,100,
- 101,116,97,105,108,115,114,127,0,0,0,90,10,104,97,115,
+ 114,32,0,0,0,114,57,0,0,0,114,66,0,0,0,114,
+ 38,0,0,0,114,128,0,0,0,90,11,101,120,99,95,100,
+ 101,116,97,105,108,115,114,131,0,0,0,90,10,104,97,115,
104,95,98,97,115,101,100,90,12,99,104,101,99,107,95,115,
111,117,114,99,101,90,12,115,111,117,114,99,101,95,98,121,
- 116,101,115,114,148,0,0,0,90,12,115,111,117,114,99,101,
+ 116,101,115,114,152,0,0,0,90,12,115,111,117,114,99,101,
95,109,116,105,109,101,90,11,115,111,117,114,99,101,95,115,
- 105,122,101,114,46,0,0,0,114,9,0,0,0,114,9,0,
+ 105,122,101,114,50,0,0,0,114,9,0,0,0,114,9,0,
0,0,114,10,0,0,0,218,15,95,117,110,109,97,114,115,
- 104,97,108,95,99,111,100,101,72,2,0,0,115,82,0,0,
- 0,0,2,2,1,2,254,6,5,2,1,18,1,12,1,8,
- 2,12,1,4,1,12,1,12,1,2,255,2,1,8,255,4,
- 2,10,1,10,1,4,1,4,1,2,254,4,5,2,1,4,
- 1,8,255,8,2,12,1,8,3,8,255,6,3,6,3,22,
- 1,18,255,4,2,4,1,8,255,4,2,4,2,18,1,12,
- 1,16,1,114,153,0,0,0,99,1,0,0,0,0,0,0,
- 0,0,0,0,0,1,0,0,0,4,0,0,0,67,0,0,
- 0,115,28,0,0,0,124,0,160,0,100,1,100,2,161,2,
- 125,0,124,0,160,0,100,3,100,2,161,2,125,0,124,0,
- 83,0,41,4,78,115,2,0,0,0,13,10,243,1,0,0,
- 0,10,243,1,0,0,0,13,41,1,114,19,0,0,0,41,
- 1,218,6,115,111,117,114,99,101,114,9,0,0,0,114,9,
- 0,0,0,114,10,0,0,0,218,23,95,110,111,114,109,97,
- 108,105,122,101,95,108,105,110,101,95,101,110,100,105,110,103,
- 115,123,2,0,0,115,6,0,0,0,0,1,12,1,12,1,
- 114,157,0,0,0,99,2,0,0,0,0,0,0,0,0,0,
- 0,0,2,0,0,0,6,0,0,0,67,0,0,0,115,24,
- 0,0,0,116,0,124,1,131,1,125,1,116,1,124,1,124,
- 0,100,1,100,2,100,3,141,4,83,0,41,4,78,114,74,
- 0,0,0,84,41,1,90,12,100,111,110,116,95,105,110,104,
- 101,114,105,116,41,2,114,157,0,0,0,218,7,99,111,109,
- 112,105,108,101,41,2,114,53,0,0,0,114,156,0,0,0,
- 114,9,0,0,0,114,9,0,0,0,114,10,0,0,0,218,
- 15,95,99,111,109,112,105,108,101,95,115,111,117,114,99,101,
- 130,2,0,0,115,4,0,0,0,0,1,8,1,114,159,0,
- 0,0,99,2,0,0,0,0,0,0,0,0,0,0,0,2,
- 0,0,0,11,0,0,0,67,0,0,0,115,68,0,0,0,
- 116,0,160,1,124,0,100,1,63,0,100,2,23,0,124,0,
- 100,3,63,0,100,4,64,0,124,0,100,5,64,0,124,1,
- 100,6,63,0,124,1,100,3,63,0,100,7,64,0,124,1,
- 100,5,64,0,100,8,20,0,100,9,100,9,100,9,102,9,
- 161,1,83,0,41,10,78,233,9,0,0,0,105,188,7,0,
- 0,233,5,0,0,0,233,15,0,0,0,233,31,0,0,0,
- 233,11,0,0,0,233,63,0,0,0,114,84,0,0,0,114,
- 14,0,0,0,41,2,114,129,0,0,0,90,6,109,107,116,
- 105,109,101,41,2,218,1,100,114,136,0,0,0,114,9,0,
- 0,0,114,9,0,0,0,114,10,0,0,0,218,14,95,112,
- 97,114,115,101,95,100,111,115,116,105,109,101,136,2,0,0,
- 115,18,0,0,0,0,1,4,1,10,1,10,1,6,1,6,
- 1,10,1,10,1,6,249,114,167,0,0,0,99,2,0,0,
- 0,0,0,0,0,0,0,0,0,6,0,0,0,10,0,0,
- 0,67,0,0,0,115,110,0,0,0,122,82,124,1,100,1,
- 100,0,133,2,25,0,100,2,118,0,115,22,74,0,130,1,
- 124,1,100,0,100,1,133,2,25,0,125,1,124,0,106,0,
- 124,1,25,0,125,2,124,2,100,3,25,0,125,3,124,2,
- 100,4,25,0,125,4,124,2,100,5,25,0,125,5,116,1,
- 124,4,124,3,131,2,124,5,102,2,87,0,83,0,4,0,
- 116,2,116,3,116,4,102,3,121,108,1,0,1,0,1,0,
- 89,0,100,6,83,0,48,0,41,7,78,114,14,0,0,0,
- 169,2,218,1,99,218,1,111,114,161,0,0,0,233,6,0,
- 0,0,233,3,0,0,0,41,2,114,0,0,0,0,114,0,
- 0,0,0,41,5,114,28,0,0,0,114,167,0,0,0,114,
- 26,0,0,0,218,10,73,110,100,101,120,69,114,114,111,114,
- 114,152,0,0,0,41,6,114,32,0,0,0,114,13,0,0,
- 0,114,54,0,0,0,114,129,0,0,0,114,130,0,0,0,
- 90,17,117,110,99,111,109,112,114,101,115,115,101,100,95,115,
- 105,122,101,114,9,0,0,0,114,9,0,0,0,114,10,0,
- 0,0,114,149,0,0,0,149,2,0,0,115,20,0,0,0,
- 0,1,2,2,20,1,12,1,10,3,8,1,8,1,8,1,
- 16,1,18,1,114,149,0,0,0,99,2,0,0,0,0,0,
+ 104,97,108,95,99,111,100,101,107,2,0,0,115,72,0,0,
+ 0,2,2,2,1,6,254,14,5,12,2,4,1,12,1,10,
+ 1,2,1,2,255,8,1,2,255,10,2,8,1,4,1,4,
+ 1,2,1,4,254,4,5,8,1,6,255,8,4,6,255,4,
+ 3,22,3,18,1,2,255,4,2,8,1,4,255,4,2,18,
+ 2,10,1,16,1,4,1,255,128,114,157,0,0,0,99,1,
+ 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,4,
+ 0,0,0,67,0,0,0,115,28,0,0,0,124,0,160,0,
+ 100,1,100,2,161,2,125,0,124,0,160,0,100,3,100,2,
+ 161,2,125,0,124,0,83,0,41,4,78,115,2,0,0,0,
+ 13,10,243,1,0,0,0,10,243,1,0,0,0,13,41,1,
+ 114,19,0,0,0,41,1,218,6,115,111,117,114,99,101,114,
+ 9,0,0,0,114,9,0,0,0,114,10,0,0,0,218,23,
+ 95,110,111,114,109,97,108,105,122,101,95,108,105,110,101,95,
+ 101,110,100,105,110,103,115,152,2,0,0,115,8,0,0,0,
+ 12,1,12,1,4,1,255,128,114,161,0,0,0,99,2,0,
+ 0,0,0,0,0,0,0,0,0,0,2,0,0,0,6,0,
+ 0,0,67,0,0,0,115,24,0,0,0,116,0,124,1,131,
+ 1,125,1,116,1,124,1,124,0,100,1,100,2,100,3,141,
+ 4,83,0,41,4,78,114,78,0,0,0,84,41,1,90,12,
+ 100,111,110,116,95,105,110,104,101,114,105,116,41,2,114,161,
+ 0,0,0,218,7,99,111,109,112,105,108,101,41,2,114,57,
+ 0,0,0,114,160,0,0,0,114,9,0,0,0,114,9,0,
+ 0,0,114,10,0,0,0,218,15,95,99,111,109,112,105,108,
+ 101,95,115,111,117,114,99,101,159,2,0,0,115,6,0,0,
+ 0,8,1,16,1,255,128,114,163,0,0,0,99,2,0,0,
+ 0,0,0,0,0,0,0,0,0,2,0,0,0,11,0,0,
+ 0,67,0,0,0,115,68,0,0,0,116,0,160,1,124,0,
+ 100,1,63,0,100,2,23,0,124,0,100,3,63,0,100,4,
+ 64,0,124,0,100,5,64,0,124,1,100,6,63,0,124,1,
+ 100,3,63,0,100,7,64,0,124,1,100,5,64,0,100,8,
+ 20,0,100,9,100,9,100,9,102,9,161,1,83,0,41,10,
+ 78,233,9,0,0,0,105,188,7,0,0,233,5,0,0,0,
+ 233,15,0,0,0,233,31,0,0,0,233,11,0,0,0,233,
+ 63,0,0,0,114,88,0,0,0,114,14,0,0,0,41,2,
+ 114,133,0,0,0,90,6,109,107,116,105,109,101,41,2,218,
+ 1,100,114,140,0,0,0,114,9,0,0,0,114,9,0,0,
+ 0,114,10,0,0,0,218,14,95,112,97,114,115,101,95,100,
+ 111,115,116,105,109,101,165,2,0,0,115,20,0,0,0,4,
+ 1,10,1,10,1,6,1,6,1,10,1,10,1,6,1,6,
+ 249,255,128,114,171,0,0,0,99,2,0,0,0,0,0,0,
+ 0,0,0,0,0,6,0,0,0,10,0,0,0,67,0,0,
+ 0,115,110,0,0,0,122,82,124,1,100,1,100,0,133,2,
+ 25,0,100,2,118,0,115,22,74,0,130,1,124,1,100,0,
+ 100,1,133,2,25,0,125,1,124,0,106,0,124,1,25,0,
+ 125,2,124,2,100,3,25,0,125,3,124,2,100,4,25,0,
+ 125,4,124,2,100,5,25,0,125,5,116,1,124,4,124,3,
+ 131,2,124,5,102,2,87,0,83,0,4,0,116,2,116,3,
+ 116,4,102,3,121,108,1,0,1,0,1,0,89,0,100,6,
+ 83,0,119,0,41,7,78,114,14,0,0,0,169,2,218,1,
+ 99,218,1,111,114,165,0,0,0,233,6,0,0,0,233,3,
+ 0,0,0,41,2,114,0,0,0,0,114,0,0,0,0,41,
+ 5,114,28,0,0,0,114,171,0,0,0,114,26,0,0,0,
+ 218,10,73,110,100,101,120,69,114,114,111,114,114,156,0,0,
+ 0,41,6,114,32,0,0,0,114,13,0,0,0,114,58,0,
+ 0,0,114,133,0,0,0,114,134,0,0,0,90,17,117,110,
+ 99,111,109,112,114,101,115,115,101,100,95,115,105,122,101,114,
+ 9,0,0,0,114,9,0,0,0,114,10,0,0,0,114,153,
+ 0,0,0,178,2,0,0,115,24,0,0,0,2,1,20,2,
+ 12,1,10,1,8,3,8,1,8,1,16,1,18,1,6,1,
+ 2,255,255,128,114,153,0,0,0,99,2,0,0,0,0,0,
0,0,0,0,0,0,3,0,0,0,8,0,0,0,67,0,
0,0,115,80,0,0,0,124,1,100,1,100,0,133,2,25,
0,100,2,118,0,115,20,74,0,130,1,124,1,100,0,100,
1,133,2,25,0,125,1,122,14,124,0,106,0,124,1,25,
- 0,125,2,87,0,110,20,4,0,116,1,121,66,1,0,1,
- 0,1,0,89,0,100,0,83,0,48,0,116,2,124,0,106,
- 3,124,2,131,2,83,0,41,3,78,114,14,0,0,0,114,
- 168,0,0,0,41,4,114,28,0,0,0,114,26,0,0,0,
- 114,52,0,0,0,114,29,0,0,0,41,3,114,32,0,0,
- 0,114,13,0,0,0,114,54,0,0,0,114,9,0,0,0,
- 114,9,0,0,0,114,10,0,0,0,114,147,0,0,0,168,
- 2,0,0,115,14,0,0,0,0,2,20,1,12,2,2,1,
- 14,1,12,1,8,2,114,147,0,0,0,99,2,0,0,0,
- 0,0,0,0,0,0,0,0,11,0,0,0,9,0,0,0,
- 67,0,0,0,115,194,0,0,0,116,0,124,0,124,1,131,
- 2,125,2,116,1,68,0,93,156,92,3,125,3,125,4,125,
- 5,124,2,124,3,23,0,125,6,116,2,106,3,100,1,124,
- 0,106,4,116,5,124,6,100,2,100,3,141,5,1,0,122,
- 14,124,0,106,6,124,6,25,0,125,7,87,0,110,18,4,
- 0,116,7,121,86,1,0,1,0,1,0,89,0,113,14,48,
- 0,124,7,100,4,25,0,125,8,116,8,124,0,106,4,124,
- 7,131,2,125,9,124,4,114,130,116,9,124,0,124,8,124,
- 6,124,1,124,9,131,5,125,10,110,10,116,10,124,8,124,
- 9,131,2,125,10,124,10,100,0,117,0,114,150,113,14,124,
- 7,100,4,25,0,125,8,124,10,124,5,124,8,102,3,2,
- 0,1,0,83,0,116,11,100,5,124,1,155,2,157,2,124,
- 1,100,6,141,2,130,1,100,0,83,0,41,7,78,122,13,
- 116,114,121,105,110,103,32,123,125,123,125,123,125,114,84,0,
- 0,0,41,1,90,9,118,101,114,98,111,115,105,116,121,114,
- 0,0,0,0,114,57,0,0,0,114,58,0,0,0,41,12,
- 114,36,0,0,0,114,87,0,0,0,114,76,0,0,0,114,
- 77,0,0,0,114,29,0,0,0,114,20,0,0,0,114,28,
- 0,0,0,114,26,0,0,0,114,52,0,0,0,114,153,0,
- 0,0,114,159,0,0,0,114,3,0,0,0,41,11,114,32,
- 0,0,0,114,38,0,0,0,114,13,0,0,0,114,88,0,
- 0,0,114,89,0,0,0,114,47,0,0,0,114,63,0,0,
- 0,114,54,0,0,0,114,40,0,0,0,114,124,0,0,0,
- 114,46,0,0,0,114,9,0,0,0,114,9,0,0,0,114,
- 10,0,0,0,114,44,0,0,0,183,2,0,0,115,36,0,
- 0,0,0,1,10,1,14,1,8,1,22,1,2,1,14,1,
- 12,1,6,2,8,1,12,1,4,1,18,2,10,1,8,3,
- 2,1,8,1,14,2,114,44,0,0,0,41,44,114,82,0,
- 0,0,90,26,95,102,114,111,122,101,110,95,105,109,112,111,
- 114,116,108,105,98,95,101,120,116,101,114,110,97,108,114,21,
- 0,0,0,114,1,0,0,0,114,2,0,0,0,90,17,95,
- 102,114,111,122,101,110,95,105,109,112,111,114,116,108,105,98,
- 114,76,0,0,0,114,146,0,0,0,114,108,0,0,0,114,
- 150,0,0,0,114,67,0,0,0,114,129,0,0,0,90,7,
- 95,95,97,108,108,95,95,114,20,0,0,0,90,15,112,97,
- 116,104,95,115,101,112,97,114,97,116,111,114,115,114,18,0,
- 0,0,114,75,0,0,0,114,3,0,0,0,114,25,0,0,
- 0,218,4,116,121,112,101,114,70,0,0,0,114,111,0,0,
- 0,114,113,0,0,0,114,115,0,0,0,114,4,0,0,0,
- 114,87,0,0,0,114,36,0,0,0,114,37,0,0,0,114,
- 35,0,0,0,114,27,0,0,0,114,120,0,0,0,114,140,
- 0,0,0,114,142,0,0,0,114,52,0,0,0,114,145,0,
- 0,0,114,153,0,0,0,218,8,95,95,99,111,100,101,95,
- 95,114,151,0,0,0,114,157,0,0,0,114,159,0,0,0,
- 114,167,0,0,0,114,149,0,0,0,114,147,0,0,0,114,
- 44,0,0,0,114,9,0,0,0,114,9,0,0,0,114,9,
- 0,0,0,114,10,0,0,0,218,8,60,109,111,100,117,108,
- 101,62,1,0,0,0,115,84,0,0,0,4,16,8,1,16,
- 1,8,1,8,1,8,1,8,1,8,1,8,2,8,3,6,
- 1,14,3,16,4,4,2,8,2,4,1,4,1,4,2,14,
- 127,0,125,12,1,12,1,2,1,2,252,4,9,8,4,8,
- 9,8,31,8,126,2,254,2,29,4,5,8,21,8,46,8,
- 10,8,46,10,5,8,7,8,6,8,13,8,19,8,15,
+ 0,125,2,87,0,110,18,4,0,116,1,121,78,1,0,1,
+ 0,1,0,89,0,100,0,83,0,116,2,124,0,106,3,124,
+ 2,131,2,83,0,119,0,41,3,78,114,14,0,0,0,114,
+ 172,0,0,0,41,4,114,28,0,0,0,114,26,0,0,0,
+ 114,56,0,0,0,114,29,0,0,0,41,3,114,32,0,0,
+ 0,114,13,0,0,0,114,58,0,0,0,114,9,0,0,0,
+ 114,9,0,0,0,114,10,0,0,0,114,151,0,0,0,197,
+ 2,0,0,115,18,0,0,0,20,2,12,1,2,2,14,1,
+ 12,1,6,1,12,2,2,253,255,128,114,151,0,0,0,99,
+ 2,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,
+ 11,0,0,0,67,0,0,0,115,18,1,0,0,116,0,124,
+ 0,124,1,131,2,125,2,100,0,125,3,116,1,68,0,93,
+ 204,92,3,125,4,125,5,125,6,124,2,124,4,23,0,125,
+ 7,116,2,106,3,100,1,124,0,106,4,116,5,124,7,100,
+ 2,100,3,141,5,1,0,122,14,124,0,106,6,124,7,25,
+ 0,125,8,87,0,110,18,4,0,116,7,144,1,121,16,1,
+ 0,1,0,1,0,89,0,113,18,124,8,100,4,25,0,125,
+ 9,116,8,124,0,106,4,124,8,131,2,125,10,100,0,125,
+ 11,124,5,114,182,122,20,116,9,124,0,124,9,124,7,124,
+ 1,124,10,131,5,125,11,87,0,110,50,4,0,116,10,144,
+ 1,121,14,1,0,125,12,1,0,122,16,124,12,125,3,87,
+ 0,89,0,100,0,125,12,126,12,110,18,100,0,125,12,126,
+ 12,119,1,116,11,124,9,124,10,131,2,125,11,124,11,100,
+ 0,117,0,114,202,113,18,124,8,100,4,25,0,125,9,124,
+ 11,124,6,124,9,102,3,2,0,1,0,83,0,124,3,114,
+ 252,100,5,124,3,155,0,157,2,125,13,116,12,124,13,124,
+ 1,100,6,141,2,124,3,130,2,116,12,100,7,124,1,155,
+ 2,157,2,124,1,100,6,141,2,130,1,119,0,119,0,41,
+ 8,78,122,13,116,114,121,105,110,103,32,123,125,123,125,123,
+ 125,114,88,0,0,0,41,1,90,9,118,101,114,98,111,115,
+ 105,116,121,114,0,0,0,0,122,20,109,111,100,117,108,101,
+ 32,108,111,97,100,32,102,97,105,108,101,100,58,32,114,62,
+ 0,0,0,114,61,0,0,0,41,13,114,36,0,0,0,114,
+ 91,0,0,0,114,45,0,0,0,114,80,0,0,0,114,29,
+ 0,0,0,114,20,0,0,0,114,28,0,0,0,114,26,0,
+ 0,0,114,56,0,0,0,114,157,0,0,0,114,79,0,0,
+ 0,114,163,0,0,0,114,3,0,0,0,41,14,114,32,0,
+ 0,0,114,38,0,0,0,114,13,0,0,0,90,12,105,109,
+ 112,111,114,116,95,101,114,114,111,114,114,92,0,0,0,114,
+ 93,0,0,0,114,51,0,0,0,114,66,0,0,0,114,58,
+ 0,0,0,114,40,0,0,0,114,128,0,0,0,114,50,0,
+ 0,0,90,3,101,120,99,114,81,0,0,0,114,9,0,0,
+ 0,114,9,0,0,0,114,10,0,0,0,114,48,0,0,0,
+ 212,2,0,0,115,60,0,0,0,10,1,4,1,14,1,8,
+ 1,22,1,2,1,14,1,14,1,4,1,8,2,12,1,4,
+ 1,4,1,2,1,20,1,16,1,16,1,8,128,10,2,8,
+ 1,2,3,8,1,14,1,4,2,10,1,14,1,18,2,2,
+ 241,2,247,255,128,114,48,0,0,0,41,46,114,86,0,0,
+ 0,90,26,95,102,114,111,122,101,110,95,105,109,112,111,114,
+ 116,108,105,98,95,101,120,116,101,114,110,97,108,114,21,0,
+ 0,0,114,1,0,0,0,114,2,0,0,0,90,17,95,102,
+ 114,111,122,101,110,95,105,109,112,111,114,116,108,105,98,114,
+ 45,0,0,0,114,150,0,0,0,114,112,0,0,0,114,154,
+ 0,0,0,114,71,0,0,0,114,133,0,0,0,114,69,0,
+ 0,0,90,7,95,95,97,108,108,95,95,114,20,0,0,0,
+ 90,15,112,97,116,104,95,115,101,112,97,114,97,116,111,114,
+ 115,114,18,0,0,0,114,79,0,0,0,114,3,0,0,0,
+ 114,25,0,0,0,218,4,116,121,112,101,114,74,0,0,0,
+ 114,115,0,0,0,114,117,0,0,0,114,119,0,0,0,90,
+ 13,95,76,111,97,100,101,114,66,97,115,105,99,115,114,4,
+ 0,0,0,114,91,0,0,0,114,36,0,0,0,114,37,0,
+ 0,0,114,35,0,0,0,114,27,0,0,0,114,124,0,0,
+ 0,114,144,0,0,0,114,146,0,0,0,114,56,0,0,0,
+ 114,149,0,0,0,114,157,0,0,0,218,8,95,95,99,111,
+ 100,101,95,95,114,155,0,0,0,114,161,0,0,0,114,163,
+ 0,0,0,114,171,0,0,0,114,153,0,0,0,114,151,0,
+ 0,0,114,48,0,0,0,114,9,0,0,0,114,9,0,0,
+ 0,114,9,0,0,0,114,10,0,0,0,218,8,60,109,111,
+ 100,117,108,101,62,1,0,0,0,115,92,0,0,0,4,0,
+ 8,16,16,1,8,1,8,1,8,1,8,1,8,1,8,1,
+ 8,1,8,2,6,3,14,1,16,3,4,4,8,2,4,2,
+ 4,1,4,1,18,2,0,127,0,127,12,34,12,1,2,1,
+ 2,1,4,252,8,9,8,4,8,9,8,31,2,126,2,254,
+ 4,29,8,5,8,21,8,46,8,8,10,40,8,5,8,7,
+ 8,6,8,13,8,19,12,15,255,128,
};
diff --git a/Python/initconfig.c b/Python/initconfig.c
index 7bb28ed01f..62087fb420 100644
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -38,7 +38,8 @@ Options and arguments (and corresponding environment variables):\n\
and comparing bytes/bytearray with str. (-bb: issue errors)\n\
-B : don't write .pyc files on import; also PYTHONDONTWRITEBYTECODE=x\n\
-c cmd : program passed in as string (terminates option list)\n\
--d : debug output from parser; also PYTHONDEBUG=x\n\
+-d : turn on parser debugging output (for experts only, only works on\n\
+ debug builds); also PYTHONDEBUG=x\n\
-E : ignore PYTHON* environment variables (such as PYTHONPATH)\n\
-h : print this help message and exit (also --help)\n\
";
@@ -242,8 +243,9 @@ PyStatus PyStatus_Ok(void)
PyStatus PyStatus_Error(const char *err_msg)
{
+ assert(err_msg != NULL);
return (PyStatus){._type = _PyStatus_TYPE_ERROR,
- .err_msg = err_msg};
+ .err_msg = err_msg};
}
PyStatus PyStatus_NoMemory(void)
@@ -262,6 +264,23 @@ int PyStatus_IsExit(PyStatus status)
int PyStatus_Exception(PyStatus status)
{ return _PyStatus_EXCEPTION(status); }
+PyObject*
+_PyErr_SetFromPyStatus(PyStatus status)
+{
+ if (!_PyStatus_IS_ERROR(status)) {
+ PyErr_Format(PyExc_SystemError,
+ "%s() expects an error PyStatus",
+ _PyStatus_GET_FUNC());
+ }
+ else if (status.func) {
+ PyErr_Format(PyExc_ValueError, "%s: %s", status.func, status.err_msg);
+ }
+ else {
+ PyErr_Format(PyExc_ValueError, "%s", status.err_msg);
+ }
+ return NULL;
+}
+
/* --- PyWideStringList ------------------------------------------------ */
@@ -559,6 +578,65 @@ Py_GetArgcArgv(int *argc, wchar_t ***argv)
? _PyStatus_ERR("cannot decode " NAME) \
: _PyStatus_NO_MEMORY())
+#define MAX_HASH_SEED 4294967295UL
+
+
+#ifndef NDEBUG
+static int
+config_check_consistency(const PyConfig *config)
+{
+ /* Check config consistency */
+ assert(config->isolated >= 0);
+ assert(config->use_environment >= 0);
+ assert(config->dev_mode >= 0);
+ assert(config->install_signal_handlers >= 0);
+ assert(config->use_hash_seed >= 0);
+ assert(config->hash_seed <= MAX_HASH_SEED);
+ assert(config->faulthandler >= 0);
+ assert(config->tracemalloc >= 0);
+ assert(config->import_time >= 0);
+ assert(config->show_ref_count >= 0);
+ assert(config->dump_refs >= 0);
+ assert(config->malloc_stats >= 0);
+ assert(config->site_import >= 0);
+ assert(config->bytes_warning >= 0);
+ assert(config->inspect >= 0);
+ assert(config->interactive >= 0);
+ assert(config->optimization_level >= 0);
+ assert(config->parser_debug >= 0);
+ assert(config->write_bytecode >= 0);
+ assert(config->verbose >= 0);
+ assert(config->quiet >= 0);
+ assert(config->user_site_directory >= 0);
+ assert(config->parse_argv >= 0);
+ assert(config->configure_c_stdio >= 0);
+ assert(config->buffered_stdio >= 0);
+ assert(config->program_name != NULL);
+ assert(_PyWideStringList_CheckConsistency(&config->orig_argv));
+ assert(_PyWideStringList_CheckConsistency(&config->argv));
+ /* sys.argv must be non-empty: empty argv is replaced with [''] */
+ assert(config->argv.length >= 1);
+ assert(_PyWideStringList_CheckConsistency(&config->xoptions));
+ assert(_PyWideStringList_CheckConsistency(&config->warnoptions));
+ assert(_PyWideStringList_CheckConsistency(&config->module_search_paths));
+ assert(config->module_search_paths_set >= 0);
+ assert(config->platlibdir != NULL);
+ assert(config->filesystem_encoding != NULL);
+ assert(config->filesystem_errors != NULL);
+ assert(config->stdio_encoding != NULL);
+ assert(config->stdio_errors != NULL);
+#ifdef MS_WINDOWS
+ assert(config->legacy_windows_stdio >= 0);
+#endif
+ /* -c and -m options are exclusive */
+ assert(!(config->run_command != NULL && config->run_module != NULL));
+ assert(config->check_hash_pycs_mode != NULL);
+ assert(config->_install_importlib >= 0);
+ assert(config->pathconfig_warnings >= 0);
+ return 1;
+}
+#endif
+
/* Free memory allocated in config, but don't clear all attributes */
void
@@ -862,8 +940,8 @@ _PyConfig_Copy(PyConfig *config, const PyConfig *config2)
}
-static PyObject *
-config_as_dict(const PyConfig *config)
+PyObject *
+_PyConfig_AsDict(const PyConfig *config)
{
PyObject *dict = PyDict_New();
if (dict == NULL) {
@@ -918,6 +996,7 @@ config_as_dict(const PyConfig *config)
SET_ITEM_WSTRLIST(warnoptions);
SET_ITEM_WSTR(pythonpath_env);
SET_ITEM_WSTR(home);
+ SET_ITEM_INT(module_search_paths_set);
SET_ITEM_WSTRLIST(module_search_paths);
SET_ITEM_WSTR(executable);
SET_ITEM_WSTR(base_executable);
@@ -969,6 +1048,279 @@ fail:
}
+static PyObject*
+config_dict_get(PyObject *dict, const char *name)
+{
+ PyObject *item = _PyDict_GetItemStringWithError(dict, name);
+ if (item == NULL && !PyErr_Occurred()) {
+ PyErr_Format(PyExc_ValueError, "missing config key: %s", name);
+ return NULL;
+ }
+ return item;
+}
+
+
+static void
+config_dict_invalid_value(const char *name)
+{
+ PyErr_Format(PyExc_ValueError, "invalid config value: %s", name);
+}
+
+
+static void
+config_dict_invalid_type(const char *name)
+{
+ PyErr_Format(PyExc_TypeError, "invalid config type: %s", name);
+}
+
+
+static int
+config_dict_get_int(PyObject *dict, const char *name, int *result)
+{
+ PyObject *item = config_dict_get(dict, name);
+ if (item == NULL) {
+ return -1;
+ }
+ int value = _PyLong_AsInt(item);
+ if (value == -1 && PyErr_Occurred()) {
+ if (PyErr_ExceptionMatches(PyExc_TypeError)) {
+ config_dict_invalid_type(name);
+ }
+ else if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
+ config_dict_invalid_value(name);
+ }
+ return -1;
+ }
+ *result = value;
+ return 0;
+}
+
+
+static int
+config_dict_get_ulong(PyObject *dict, const char *name, unsigned long *result)
+{
+ PyObject *item = config_dict_get(dict, name);
+ if (item == NULL) {
+ return -1;
+ }
+ unsigned long value = PyLong_AsUnsignedLong(item);
+ if (value == (unsigned long)-1 && PyErr_Occurred()) {
+ if (PyErr_ExceptionMatches(PyExc_TypeError)) {
+ config_dict_invalid_type(name);
+ }
+ else if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
+ config_dict_invalid_value(name);
+ }
+ return -1;
+ }
+ *result = value;
+ return 0;
+}
+
+
+static int
+config_dict_get_wstr(PyObject *dict, const char *name, PyConfig *config,
+ wchar_t **result)
+{
+ PyObject *item = config_dict_get(dict, name);
+ if (item == NULL) {
+ return -1;
+ }
+ PyStatus status;
+ if (item == Py_None) {
+ status = PyConfig_SetString(config, result, NULL);
+ }
+ else if (!PyUnicode_Check(item)) {
+ config_dict_invalid_type(name);
+ return -1;
+ }
+ else {
+ wchar_t *wstr = PyUnicode_AsWideCharString(item, NULL);
+ if (wstr == NULL) {
+ return -1;
+ }
+ status = PyConfig_SetString(config, result, wstr);
+ PyMem_Free(wstr);
+ }
+ if (_PyStatus_EXCEPTION(status)) {
+ PyErr_NoMemory();
+ return -1;
+ }
+ return 0;
+}
+
+
+static int
+config_dict_get_wstrlist(PyObject *dict, const char *name, PyConfig *config,
+ PyWideStringList *result)
+{
+ PyObject *list = config_dict_get(dict, name);
+ if (list == NULL) {
+ return -1;
+ }
+
+ if (!PyList_CheckExact(list)) {
+ config_dict_invalid_type(name);
+ return -1;
+ }
+
+ PyWideStringList wstrlist = _PyWideStringList_INIT;
+ for (Py_ssize_t i=0; i < PyList_GET_SIZE(list); i++) {
+ PyObject *item = PyList_GET_ITEM(list, i);
+
+ if (item == Py_None) {
+ config_dict_invalid_value(name);
+ goto error;
+ }
+ else if (!PyUnicode_Check(item)) {
+ config_dict_invalid_type(name);
+ goto error;
+ }
+ wchar_t *wstr = PyUnicode_AsWideCharString(item, NULL);
+ if (wstr == NULL) {
+ goto error;
+ }
+ PyStatus status = PyWideStringList_Append(&wstrlist, wstr);
+ PyMem_Free(wstr);
+ if (_PyStatus_EXCEPTION(status)) {
+ PyErr_NoMemory();
+ goto error;
+ }
+ }
+
+ if (_PyWideStringList_Copy(result, &wstrlist) < 0) {
+ PyErr_NoMemory();
+ goto error;
+ }
+ _PyWideStringList_Clear(&wstrlist);
+ return 0;
+
+error:
+ _PyWideStringList_Clear(&wstrlist);
+ return -1;
+}
+
+
+int
+_PyConfig_FromDict(PyConfig *config, PyObject *dict)
+{
+ if (!PyDict_Check(dict)) {
+ PyErr_SetString(PyExc_TypeError, "dict expected");
+ return -1;
+ }
+
+#define CHECK_VALUE(NAME, TEST) \
+ if (!(TEST)) { \
+ config_dict_invalid_value(NAME); \
+ return -1; \
+ }
+#define GET_UINT(KEY) \
+ do { \
+ if (config_dict_get_int(dict, #KEY, &config->KEY) < 0) { \
+ return -1; \
+ } \
+ CHECK_VALUE(#KEY, config->KEY >= 0); \
+ } while (0)
+#define GET_WSTR(KEY) \
+ do { \
+ if (config_dict_get_wstr(dict, #KEY, config, &config->KEY) < 0) { \
+ return -1; \
+ } \
+ CHECK_VALUE(#KEY, config->KEY != NULL); \
+ } while (0)
+#define GET_WSTR_OPT(KEY) \
+ do { \
+ if (config_dict_get_wstr(dict, #KEY, config, &config->KEY) < 0) { \
+ return -1; \
+ } \
+ } while (0)
+#define GET_WSTRLIST(KEY) \
+ do { \
+ if (config_dict_get_wstrlist(dict, #KEY, config, &config->KEY) < 0) { \
+ return -1; \
+ } \
+ } while (0)
+
+ GET_UINT(_config_init);
+ CHECK_VALUE("_config_init",
+ config->_config_init == _PyConfig_INIT_COMPAT
+ || config->_config_init == _PyConfig_INIT_PYTHON
+ || config->_config_init == _PyConfig_INIT_ISOLATED);
+ GET_UINT(isolated);
+ GET_UINT(use_environment);
+ GET_UINT(dev_mode);
+ GET_UINT(install_signal_handlers);
+ GET_UINT(use_hash_seed);
+ if (config_dict_get_ulong(dict, "hash_seed", &config->hash_seed) < 0) {
+ return -1;
+ }
+ CHECK_VALUE("hash_seed", config->hash_seed <= MAX_HASH_SEED);
+ GET_UINT(faulthandler);
+ GET_UINT(tracemalloc);
+ GET_UINT(import_time);
+ GET_UINT(show_ref_count);
+ GET_UINT(dump_refs);
+ GET_UINT(malloc_stats);
+ GET_WSTR(filesystem_encoding);
+ GET_WSTR(filesystem_errors);
+ GET_WSTR_OPT(pycache_prefix);
+ GET_UINT(parse_argv);
+ GET_WSTRLIST(orig_argv);
+ GET_WSTRLIST(argv);
+ GET_WSTRLIST(xoptions);
+ GET_WSTRLIST(warnoptions);
+ GET_UINT(site_import);
+ GET_UINT(bytes_warning);
+ GET_UINT(inspect);
+ GET_UINT(interactive);
+ GET_UINT(optimization_level);
+ GET_UINT(parser_debug);
+ GET_UINT(write_bytecode);
+ GET_UINT(verbose);
+ GET_UINT(quiet);
+ GET_UINT(user_site_directory);
+ GET_UINT(configure_c_stdio);
+ GET_UINT(buffered_stdio);
+ GET_WSTR(stdio_encoding);
+ GET_WSTR(stdio_errors);
+#ifdef MS_WINDOWS
+ GET_UINT(legacy_windows_stdio);
+#endif
+ GET_WSTR(check_hash_pycs_mode);
+
+ GET_UINT(pathconfig_warnings);
+ GET_WSTR(program_name);
+ GET_WSTR_OPT(pythonpath_env);
+ GET_WSTR_OPT(home);
+ GET_WSTR(platlibdir);
+
+ // Path configuration output
+ GET_UINT(module_search_paths_set);
+ GET_WSTRLIST(module_search_paths);
+ GET_WSTR_OPT(executable);
+ GET_WSTR_OPT(base_executable);
+ GET_WSTR_OPT(prefix);
+ GET_WSTR_OPT(base_prefix);
+ GET_WSTR_OPT(exec_prefix);
+ GET_WSTR_OPT(base_exec_prefix);
+
+ GET_UINT(skip_source_first_line);
+ GET_WSTR_OPT(run_command);
+ GET_WSTR_OPT(run_module);
+ GET_WSTR_OPT(run_filename);
+
+ GET_UINT(_install_importlib);
+ GET_UINT(_init_main);
+ GET_UINT(_isolated_interpreter);
+
+#undef CHECK_VALUE
+#undef GET_UINT
+#undef GET_WSTR
+#undef GET_WSTR_OPT
+ return 0;
+}
+
+
static const char*
config_get_env(const PyConfig *config, const char *name)
{
@@ -1236,7 +1588,6 @@ config_init_home(PyConfig *config)
L"PYTHONHOME", "PYTHONHOME");
}
-
static PyStatus
config_init_hash_seed(PyConfig *config)
{
@@ -1250,7 +1601,7 @@ config_init_hash_seed(PyConfig *config)
errno = 0;
seed = strtoul(seed_text, (char **)&endptr, 10);
if (*endptr != '\0'
- || seed > 4294967295UL
+ || seed > MAX_HASH_SEED
|| (errno == ERANGE && seed == ULONG_MAX))
{
return _PyStatus_ERR("PYTHONHASHSEED must be \"random\" "
@@ -1515,8 +1866,8 @@ config_init_stdio_encoding(PyConfig *config,
{
PyStatus status;
- /* If Py_SetStandardStreamEncoding() have been called, use these
- parameters. */
+ /* If Py_SetStandardStreamEncoding() has been called, use its
+ arguments if they are not NULL. */
if (config->stdio_encoding == NULL && _Py_StandardStreamEncoding != NULL) {
status = CONFIG_SET_BYTES_STR(config, &config->stdio_encoding,
_Py_StandardStreamEncoding,
@@ -1535,6 +1886,7 @@ config_init_stdio_encoding(PyConfig *config,
}
}
+ // Exit if encoding and errors are defined
if (config->stdio_encoding != NULL && config->stdio_errors != NULL) {
return _PyStatus_OK();
}
@@ -1634,12 +1986,12 @@ config_get_fs_encoding(PyConfig *config, const PyPreConfig *preconfig,
if (preconfig->utf8_mode) {
return PyConfig_SetString(config, fs_encoding, L"utf-8");
}
- else if (_Py_GetForceASCII()) {
+
+ if (_Py_GetForceASCII()) {
return PyConfig_SetString(config, fs_encoding, L"ascii");
}
- else {
- return config_get_locale_encoding(config, preconfig, fs_encoding);
- }
+
+ return config_get_locale_encoding(config, preconfig, fs_encoding);
#endif // !MS_WINDOWS
}
@@ -1679,7 +2031,7 @@ config_init_fs_encoding(PyConfig *config, const PyPreConfig *preconfig)
static PyStatus
-config_read(PyConfig *config)
+config_read(PyConfig *config, int compute_path_config)
{
PyStatus status;
const PyPreConfig *preconfig = &_PyRuntime.preconfig;
@@ -1724,7 +2076,7 @@ config_read(PyConfig *config)
}
if (config->_install_importlib) {
- status = _PyConfig_InitPathConfig(config);
+ status = _PyConfig_InitPathConfig(config, compute_path_config);
if (_PyStatus_EXCEPTION(status)) {
return status;
}
@@ -1779,6 +2131,11 @@ config_read(PyConfig *config)
config->configure_c_stdio = 1;
}
+ // Only parse arguments once.
+ if (config->parse_argv == 1) {
+ config->parse_argv = 2;
+ }
+
return _PyStatus_OK();
}
@@ -2269,7 +2626,7 @@ core_read_precmdline(PyConfig *config, _PyPreCmdline *precmdline)
{
PyStatus status;
- if (config->parse_argv) {
+ if (config->parse_argv == 1) {
if (_PyWideStringList_Copy(&precmdline->argv, &config->argv) < 0) {
return _PyStatus_NO_MEMORY();
}
@@ -2347,7 +2704,7 @@ config_read_cmdline(PyConfig *config)
}
}
- if (config->parse_argv) {
+ if (config->parse_argv == 1) {
Py_ssize_t opt_index;
status = config_parse_cmdline(config, &cmdline_warnoptions, &opt_index);
if (_PyStatus_EXCEPTION(status)) {
@@ -2465,7 +2822,7 @@ PyConfig_SetWideStringList(PyConfig *config, PyWideStringList *list,
The only side effects are to modify config and to call _Py_SetArgcArgv(). */
PyStatus
-PyConfig_Read(PyConfig *config)
+_PyConfig_Read(PyConfig *config, int compute_path_config)
{
PyStatus status;
@@ -2508,63 +2865,12 @@ PyConfig_Read(PyConfig *config)
goto done;
}
- status = config_read(config);
+ status = config_read(config, compute_path_config);
if (_PyStatus_EXCEPTION(status)) {
goto done;
}
- /* Check config consistency */
- assert(config->isolated >= 0);
- assert(config->use_environment >= 0);
- assert(config->dev_mode >= 0);
- assert(config->install_signal_handlers >= 0);
- assert(config->use_hash_seed >= 0);
- assert(config->faulthandler >= 0);
- assert(config->tracemalloc >= 0);
- assert(config->site_import >= 0);
- assert(config->bytes_warning >= 0);
- assert(config->inspect >= 0);
- assert(config->interactive >= 0);
- assert(config->optimization_level >= 0);
- assert(config->parser_debug >= 0);
- assert(config->write_bytecode >= 0);
- assert(config->verbose >= 0);
- assert(config->quiet >= 0);
- assert(config->user_site_directory >= 0);
- assert(config->parse_argv >= 0);
- assert(config->configure_c_stdio >= 0);
- assert(config->buffered_stdio >= 0);
- assert(config->program_name != NULL);
- assert(_PyWideStringList_CheckConsistency(&config->argv));
- /* sys.argv must be non-empty: empty argv is replaced with [''] */
- assert(config->argv.length >= 1);
- assert(_PyWideStringList_CheckConsistency(&config->xoptions));
- assert(_PyWideStringList_CheckConsistency(&config->warnoptions));
- assert(_PyWideStringList_CheckConsistency(&config->module_search_paths));
- if (config->_install_importlib) {
- assert(config->module_search_paths_set != 0);
- /* don't check config->module_search_paths */
- assert(config->executable != NULL);
- assert(config->base_executable != NULL);
- assert(config->prefix != NULL);
- assert(config->base_prefix != NULL);
- assert(config->exec_prefix != NULL);
- assert(config->base_exec_prefix != NULL);
- }
- assert(config->platlibdir != NULL);
- assert(config->filesystem_encoding != NULL);
- assert(config->filesystem_errors != NULL);
- assert(config->stdio_encoding != NULL);
- assert(config->stdio_errors != NULL);
-#ifdef MS_WINDOWS
- assert(config->legacy_windows_stdio >= 0);
-#endif
- /* -c and -m options are exclusive */
- assert(!(config->run_command != NULL && config->run_module != NULL));
- assert(config->check_hash_pycs_mode != NULL);
- assert(config->_install_importlib >= 0);
- assert(config->pathconfig_warnings >= 0);
- assert(_PyWideStringList_CheckConsistency(&config->orig_argv));
+ assert(config_check_consistency(config));
status = _PyStatus_OK();
@@ -2574,6 +2880,13 @@ done:
}
+PyStatus
+PyConfig_Read(PyConfig *config)
+{
+ return _PyConfig_Read(config, 1);
+}
+
+
PyObject*
_Py_GetConfigsAsDict(void)
{
@@ -2609,7 +2922,7 @@ _Py_GetConfigsAsDict(void)
/* core config */
const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp);
- dict = config_as_dict(config);
+ dict = _PyConfig_AsDict(config);
if (dict == NULL) {
goto error;
}
diff --git a/Python/marshal.c b/Python/marshal.c
index 91a0f8acb1..fa4ec9eb60 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -524,7 +524,7 @@ w_complex_object(PyObject *v, char flag, WFILE *p)
w_object(co->co_filename, p);
w_object(co->co_name, p);
w_long(co->co_firstlineno, p);
- w_object(co->co_lnotab, p);
+ w_object(co->co_linetable, p);
}
else if (PyObject_CheckBuffer(v)) {
/* Write unknown bytes-like objects as a bytes object */
@@ -638,7 +638,7 @@ r_string(Py_ssize_t n, RFILE *p)
return res;
}
if (p->buf == NULL) {
- p->buf = PyMem_MALLOC(n);
+ p->buf = PyMem_Malloc(n);
if (p->buf == NULL) {
PyErr_NoMemory();
return NULL;
@@ -646,7 +646,7 @@ r_string(Py_ssize_t n, RFILE *p)
p->buf_size = n;
}
else if (p->buf_size < n) {
- char *tmp = PyMem_REALLOC(p->buf, n);
+ char *tmp = PyMem_Realloc(p->buf, n);
if (tmp == NULL) {
PyErr_NoMemory();
return NULL;
@@ -1312,7 +1312,7 @@ r_object(RFILE *p)
PyObject *filename = NULL;
PyObject *name = NULL;
int firstlineno;
- PyObject *lnotab = NULL;
+ PyObject *linetable = NULL;
idx = r_ref_reserve(flag, p);
if (idx < 0)
@@ -1367,8 +1367,8 @@ r_object(RFILE *p)
firstlineno = (int)r_long(p);
if (firstlineno == -1 && PyErr_Occurred())
break;
- lnotab = r_object(p);
- if (lnotab == NULL)
+ linetable = r_object(p);
+ if (linetable == NULL)
goto code_error;
if (PySys_Audit("code.__new__", "OOOiiiiii",
@@ -1382,7 +1382,7 @@ r_object(RFILE *p)
nlocals, stacksize, flags,
code, consts, names, varnames,
freevars, cellvars, filename, name,
- firstlineno, lnotab);
+ firstlineno, linetable);
v = r_ref_insert(v, idx, flag, p);
code_error:
@@ -1394,7 +1394,7 @@ r_object(RFILE *p)
Py_XDECREF(cellvars);
Py_XDECREF(filename);
Py_XDECREF(name);
- Py_XDECREF(lnotab);
+ Py_XDECREF(linetable);
}
retval = v;
break;
@@ -1453,7 +1453,7 @@ PyMarshal_ReadShortFromFile(FILE *fp)
rf.buf = NULL;
res = r_short(&rf);
if (rf.buf != NULL)
- PyMem_FREE(rf.buf);
+ PyMem_Free(rf.buf);
return res;
}
@@ -1468,7 +1468,7 @@ PyMarshal_ReadLongFromFile(FILE *fp)
rf.buf = NULL;
res = r_long(&rf);
if (rf.buf != NULL)
- PyMem_FREE(rf.buf);
+ PyMem_Free(rf.buf);
return res;
}
@@ -1501,11 +1501,11 @@ PyMarshal_ReadLastObjectFromFile(FILE *fp)
off_t filesize;
filesize = getfilesize(fp);
if (filesize > 0 && filesize <= REASONABLE_FILE_LIMIT) {
- char* pBuf = (char *)PyMem_MALLOC(filesize);
+ char* pBuf = (char *)PyMem_Malloc(filesize);
if (pBuf != NULL) {
size_t n = fread(pBuf, 1, (size_t)filesize, fp);
PyObject* v = PyMarshal_ReadObjectFromString(pBuf, n);
- PyMem_FREE(pBuf);
+ PyMem_Free(pBuf);
return v;
}
@@ -1534,7 +1534,7 @@ PyMarshal_ReadObjectFromFile(FILE *fp)
result = r_object(&rf);
Py_DECREF(rf.refs);
if (rf.buf != NULL)
- PyMem_FREE(rf.buf);
+ PyMem_Free(rf.buf);
return result;
}
@@ -1555,7 +1555,7 @@ PyMarshal_ReadObjectFromString(const char *str, Py_ssize_t len)
result = r_object(&rf);
Py_DECREF(rf.refs);
if (rf.buf != NULL)
- PyMem_FREE(rf.buf);
+ PyMem_Free(rf.buf);
return result;
}
@@ -1684,7 +1684,7 @@ marshal_load(PyObject *module, PyObject *file)
result = read_object(&rf);
Py_DECREF(rf.refs);
if (rf.buf != NULL)
- PyMem_FREE(rf.buf);
+ PyMem_Free(rf.buf);
} else
result = NULL;
}
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 2dabcf3834..8655daa1fc 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -634,56 +634,70 @@ va_build_stack(PyObject **small_stack, Py_ssize_t small_stack_len,
int
-PyModule_AddObject(PyObject *m, const char *name, PyObject *o)
+PyModule_AddObjectRef(PyObject *mod, const char *name, PyObject *value)
{
- PyObject *dict;
- if (!PyModule_Check(m)) {
+ if (!PyModule_Check(mod)) {
PyErr_SetString(PyExc_TypeError,
- "PyModule_AddObject() needs module as first arg");
+ "PyModule_AddObjectRef() first argument "
+ "must be a module");
return -1;
}
- if (!o) {
- if (!PyErr_Occurred())
- PyErr_SetString(PyExc_TypeError,
- "PyModule_AddObject() needs non-NULL value");
+ if (!value) {
+ if (!PyErr_Occurred()) {
+ PyErr_SetString(PyExc_SystemError,
+ "PyModule_AddObjectRef() must be called "
+ "with an exception raised if value is NULL");
+ }
return -1;
}
- dict = PyModule_GetDict(m);
+ PyObject *dict = PyModule_GetDict(mod);
if (dict == NULL) {
/* Internal error -- modules must have a dict! */
PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
- PyModule_GetName(m));
+ PyModule_GetName(mod));
return -1;
}
- if (PyDict_SetItemString(dict, name, o))
+
+ if (PyDict_SetItemString(dict, name, value)) {
return -1;
- Py_DECREF(o);
+ }
return 0;
}
+
+int
+PyModule_AddObject(PyObject *mod, const char *name, PyObject *value)
+{
+ int res = PyModule_AddObjectRef(mod, name, value);
+ if (res == 0) {
+ Py_DECREF(value);
+ }
+ return res;
+}
+
int
PyModule_AddIntConstant(PyObject *m, const char *name, long value)
{
- PyObject *o = PyLong_FromLong(value);
- if (!o)
+ PyObject *obj = PyLong_FromLong(value);
+ if (!obj) {
return -1;
- if (PyModule_AddObject(m, name, o) == 0)
- return 0;
- Py_DECREF(o);
- return -1;
+ }
+ int res = PyModule_AddObjectRef(m, name, obj);
+ Py_DECREF(obj);
+ return res;
}
int
PyModule_AddStringConstant(PyObject *m, const char *name, const char *value)
{
- PyObject *o = PyUnicode_FromString(value);
- if (!o)
+ PyObject *obj = PyUnicode_FromString(value);
+ if (!obj) {
return -1;
- if (PyModule_AddObject(m, name, o) == 0)
- return 0;
- Py_DECREF(o);
- return -1;
+ }
+ int res = PyModule_AddObjectRef(m, name, obj);
+ Py_DECREF(obj);
+ return res;
}
int
@@ -696,11 +710,5 @@ PyModule_AddType(PyObject *module, PyTypeObject *type)
const char *name = _PyType_Name(type);
assert(name != NULL);
- Py_INCREF(type);
- if (PyModule_AddObject(module, name, (PyObject *)type) < 0) {
- Py_DECREF(type);
- return -1;
- }
-
- return 0;
+ return PyModule_AddObjectRef(module, name, (PyObject *)type);
}
diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h
index 538fdbe3e0..8495871e21 100644
--- a/Python/opcode_targets.h
+++ b/Python/opcode_targets.h
@@ -47,7 +47,7 @@ static void *opcode_targets[256] = {
&&_unknown_opcode,
&&_unknown_opcode,
&&_unknown_opcode,
- &&TARGET_RERAISE,
+ &&_unknown_opcode,
&&TARGET_WITH_EXCEPT_START,
&&TARGET_GET_AITER,
&&TARGET_GET_ANEXT,
@@ -118,7 +118,7 @@ static void *opcode_targets[256] = {
&&TARGET_LOAD_GLOBAL,
&&TARGET_IS_OP,
&&TARGET_CONTAINS_OP,
- &&_unknown_opcode,
+ &&TARGET_RERAISE,
&&_unknown_opcode,
&&TARGET_JUMP_IF_NOT_EXC_MATCH,
&&TARGET_SETUP_FINALLY,
diff --git a/Python/pathconfig.c b/Python/pathconfig.c
index 12a684a66b..470aba75be 100644
--- a/Python/pathconfig.c
+++ b/Python/pathconfig.c
@@ -332,7 +332,8 @@ config_init_module_search_paths(PyConfig *config, _PyPathConfig *pathconfig)
- _PyPathConfig_Calculate()
*/
static PyStatus
-pathconfig_calculate(_PyPathConfig *pathconfig, const PyConfig *config)
+pathconfig_init(_PyPathConfig *pathconfig, const PyConfig *config,
+ int compute_path_config)
{
PyStatus status;
@@ -349,12 +350,9 @@ pathconfig_calculate(_PyPathConfig *pathconfig, const PyConfig *config)
goto done;
}
- if (_Py_path_config.module_search_path == NULL) {
+ if (compute_path_config) {
status = _PyPathConfig_Calculate(pathconfig, config);
}
- else {
- /* Py_SetPath() has been called: avoid _PyPathConfig_Calculate() */
- }
done:
PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
@@ -363,17 +361,19 @@ done:
static PyStatus
-config_calculate_pathconfig(PyConfig *config)
+config_init_pathconfig(PyConfig *config, int compute_path_config)
{
_PyPathConfig pathconfig = _PyPathConfig_INIT;
PyStatus status;
- status = pathconfig_calculate(&pathconfig, config);
+ status = pathconfig_init(&pathconfig, config, compute_path_config);
if (_PyStatus_EXCEPTION(status)) {
goto done;
}
- if (!config->module_search_paths_set) {
+ if (!config->module_search_paths_set
+ && pathconfig.module_search_path != NULL)
+ {
status = config_init_module_search_paths(config, &pathconfig);
if (_PyStatus_EXCEPTION(status)) {
goto done;
@@ -381,7 +381,7 @@ config_calculate_pathconfig(PyConfig *config)
}
#define COPY_ATTR(PATH_ATTR, CONFIG_ATTR) \
- if (config->CONFIG_ATTR == NULL) { \
+ if (config->CONFIG_ATTR == NULL && pathconfig.PATH_ATTR != NULL) { \
if (copy_wstr(&config->CONFIG_ATTR, pathconfig.PATH_ATTR) < 0) { \
goto no_memory; \
} \
@@ -427,7 +427,7 @@ done:
PyStatus
-_PyConfig_InitPathConfig(PyConfig *config)
+_PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
{
/* Do we need to calculate the path? */
if (!config->module_search_paths_set
@@ -435,26 +435,26 @@ _PyConfig_InitPathConfig(PyConfig *config)
|| config->prefix == NULL
|| config->exec_prefix == NULL)
{
- PyStatus status = config_calculate_pathconfig(config);
+ PyStatus status = config_init_pathconfig(config, compute_path_config);
if (_PyStatus_EXCEPTION(status)) {
return status;
}
}
- if (config->base_prefix == NULL) {
+ if (config->base_prefix == NULL && config->prefix != NULL) {
if (copy_wstr(&config->base_prefix, config->prefix) < 0) {
return _PyStatus_NO_MEMORY();
}
}
- if (config->base_exec_prefix == NULL) {
+ if (config->base_exec_prefix == NULL && config->exec_prefix != NULL) {
if (copy_wstr(&config->base_exec_prefix,
config->exec_prefix) < 0) {
return _PyStatus_NO_MEMORY();
}
}
- if (config->base_executable == NULL) {
+ if (config->base_executable == NULL && config->executable != NULL) {
if (copy_wstr(&config->base_executable,
config->executable) < 0) {
return _PyStatus_NO_MEMORY();
@@ -465,53 +465,6 @@ _PyConfig_InitPathConfig(PyConfig *config)
}
-static PyStatus
-pathconfig_global_read(_PyPathConfig *pathconfig)
-{
- PyConfig config;
- _PyConfig_InitCompatConfig(&config);
-
- /* Call _PyConfig_InitPathConfig() */
- PyStatus status = PyConfig_Read(&config);
- if (_PyStatus_EXCEPTION(status)) {
- goto done;
- }
-
- status = pathconfig_set_from_config(pathconfig, &config);
-
-done:
- PyConfig_Clear(&config);
- return status;
-}
-
-
-static void
-pathconfig_global_init(void)
-{
- PyStatus status;
-
- if (_Py_path_config.module_search_path == NULL) {
- status = pathconfig_global_read(&_Py_path_config);
- if (_PyStatus_EXCEPTION(status)) {
- Py_ExitStatusException(status);
- }
- }
- else {
- /* Global configuration already initialized */
- }
-
- assert(_Py_path_config.program_full_path != NULL);
- assert(_Py_path_config.prefix != NULL);
- assert(_Py_path_config.exec_prefix != NULL);
- assert(_Py_path_config.module_search_path != NULL);
- assert(_Py_path_config.program_name != NULL);
- /* home can be NULL */
-#ifdef MS_WINDOWS
- assert(_Py_path_config.base_executable != NULL);
-#endif
-}
-
-
/* External interface */
static void _Py_NO_RETURN
@@ -531,23 +484,17 @@ Py_SetPath(const wchar_t *path)
PyMemAllocatorEx old_alloc;
_PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
- /* Getting the program full path calls pathconfig_global_init() */
- wchar_t *program_full_path = _PyMem_RawWcsdup(Py_GetProgramFullPath());
-
- PyMem_RawFree(_Py_path_config.program_full_path);
PyMem_RawFree(_Py_path_config.prefix);
PyMem_RawFree(_Py_path_config.exec_prefix);
PyMem_RawFree(_Py_path_config.module_search_path);
- _Py_path_config.program_full_path = program_full_path;
_Py_path_config.prefix = _PyMem_RawWcsdup(L"");
_Py_path_config.exec_prefix = _PyMem_RawWcsdup(L"");
_Py_path_config.module_search_path = _PyMem_RawWcsdup(path);
PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
- if (_Py_path_config.program_full_path == NULL
- || _Py_path_config.prefix == NULL
+ if (_Py_path_config.prefix == NULL
|| _Py_path_config.exec_prefix == NULL
|| _Py_path_config.module_search_path == NULL)
{
@@ -621,7 +568,6 @@ _Py_SetProgramFullPath(const wchar_t *program_full_path)
wchar_t *
Py_GetPath(void)
{
- pathconfig_global_init();
return _Py_path_config.module_search_path;
}
@@ -629,7 +575,6 @@ Py_GetPath(void)
wchar_t *
Py_GetPrefix(void)
{
- pathconfig_global_init();
return _Py_path_config.prefix;
}
@@ -637,7 +582,6 @@ Py_GetPrefix(void)
wchar_t *
Py_GetExecPrefix(void)
{
- pathconfig_global_init();
return _Py_path_config.exec_prefix;
}
@@ -645,7 +589,6 @@ Py_GetExecPrefix(void)
wchar_t *
Py_GetProgramFullPath(void)
{
- pathconfig_global_init();
return _Py_path_config.program_full_path;
}
@@ -653,7 +596,6 @@ Py_GetProgramFullPath(void)
wchar_t*
Py_GetPythonHome(void)
{
- pathconfig_global_init();
return _Py_path_config.home;
}
@@ -661,7 +603,6 @@ Py_GetPythonHome(void)
wchar_t *
Py_GetProgramName(void)
{
- pathconfig_global_init();
return _Py_path_config.program_name;
}
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index ff58c1b915..9828dffad5 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -8,6 +8,7 @@
#include "pycore_ceval.h" // _PyEval_FiniGIL()
#include "pycore_context.h" // _PyContext_Init()
#include "pycore_fileutils.h" // _Py_ResetForceASCII()
+#include "pycore_import.h" // _PyImport_BootstrapImp()
#include "pycore_initconfig.h" // _PyStatus_OK()
#include "pycore_object.h" // _PyDebug_PrintTotalRefs()
#include "pycore_pathconfig.h" // _PyConfig_WritePathConfig()
@@ -54,8 +55,6 @@ static PyStatus add_main_module(PyInterpreterState *interp);
static PyStatus init_import_site(void);
static PyStatus init_set_builtins_open(void);
static PyStatus init_sys_streams(PyThreadState *tstate);
-static PyStatus init_signals(PyThreadState *tstate);
-static void call_py_exitfuncs(PyThreadState *tstate);
static void wait_for_thread_shutdown(PyThreadState *tstate);
static void call_ll_exitfuncs(_PyRuntimeState *runtime);
@@ -97,14 +96,6 @@ _Py_IsFinalizing(void)
int (*_PyOS_mystrnicmp_hack)(const char *, const char *, Py_ssize_t) = \
PyOS_mystrnicmp; /* Python/pystrcmp.o */
-/* PyModule_GetWarningsModule is no longer necessary as of 2.6
-since _warnings is builtin. This API should not be used. */
-PyObject *
-PyModule_GetWarningsModule(void)
-{
- return PyImport_ImportModule("warnings");
-}
-
/* APIs to access the initialization flags
*
@@ -135,59 +126,54 @@ Py_IsInitialized(void)
having the lock, but you cannot use multiple threads.)
*/
-
-static PyStatus
+static int
init_importlib(PyThreadState *tstate, PyObject *sysmod)
{
- PyObject *importlib;
- PyObject *impmod;
- PyObject *value;
+ assert(!_PyErr_Occurred(tstate));
+
PyInterpreterState *interp = tstate->interp;
int verbose = _PyInterpreterState_GetConfig(interp)->verbose;
- /* Import _importlib through its frozen version, _frozen_importlib. */
- if (PyImport_ImportFrozenModule("_frozen_importlib") <= 0) {
- return _PyStatus_ERR("can't import _frozen_importlib");
- }
- else if (verbose) {
+ // Import _importlib through its frozen version, _frozen_importlib.
+ if (verbose) {
PySys_FormatStderr("import _frozen_importlib # frozen\n");
}
- importlib = PyImport_AddModule("_frozen_importlib");
+ if (PyImport_ImportFrozenModule("_frozen_importlib") <= 0) {
+ return -1;
+ }
+ PyObject *importlib = PyImport_AddModule("_frozen_importlib"); // borrowed
if (importlib == NULL) {
- return _PyStatus_ERR("couldn't get _frozen_importlib from sys.modules");
+ return -1;
}
- interp->importlib = importlib;
- Py_INCREF(interp->importlib);
-
- interp->import_func = _PyDict_GetItemStringWithError(interp->builtins, "__import__");
- if (interp->import_func == NULL)
- return _PyStatus_ERR("__import__ not found");
- Py_INCREF(interp->import_func);
+ interp->importlib = Py_NewRef(importlib);
- /* Import the _imp module */
- impmod = PyInit__imp();
- if (impmod == NULL) {
- return _PyStatus_ERR("can't import _imp");
- }
- else if (verbose) {
+ // Import the _imp module
+ if (verbose) {
PySys_FormatStderr("import _imp # builtin\n");
}
- if (_PyImport_SetModuleString("_imp", impmod) < 0) {
- return _PyStatus_ERR("can't save _imp to sys.modules");
+ PyObject *imp_mod = _PyImport_BootstrapImp(tstate);
+ if (imp_mod == NULL) {
+ return -1;
+ }
+ if (_PyImport_SetModuleString("_imp", imp_mod) < 0) {
+ Py_DECREF(imp_mod);
+ return -1;
}
- /* Install importlib as the implementation of import */
- value = PyObject_CallMethod(importlib, "_install", "OO", sysmod, impmod);
+ // Install importlib as the implementation of import
+ PyObject *value = PyObject_CallMethod(importlib, "_install",
+ "OO", sysmod, imp_mod);
+ Py_DECREF(imp_mod);
if (value == NULL) {
- _PyErr_Print(tstate);
- return _PyStatus_ERR("importlib install failed");
+ return -1;
}
Py_DECREF(value);
- Py_DECREF(impmod);
- return _PyStatus_OK();
+ assert(!_PyErr_Occurred(tstate));
+ return 0;
}
+
static PyStatus
init_importlib_external(PyThreadState *tstate)
{
@@ -428,6 +414,69 @@ _Py_SetLocaleFromEnv(int category)
}
+static int
+interpreter_update_config(PyThreadState *tstate, int only_update_path_config)
+{
+ const PyConfig *config = &tstate->interp->config;
+
+ if (!only_update_path_config) {
+ PyStatus status = _PyConfig_Write(config, tstate->interp->runtime);
+ if (_PyStatus_EXCEPTION(status)) {
+ _PyErr_SetFromPyStatus(status);
+ return -1;
+ }
+ }
+
+ if (_Py_IsMainInterpreter(tstate)) {
+ PyStatus status = _PyConfig_WritePathConfig(config);
+ if (_PyStatus_EXCEPTION(status)) {
+ _PyErr_SetFromPyStatus(status);
+ return -1;
+ }
+ }
+
+ // Update the sys module for the new configuration
+ if (_PySys_UpdateConfig(tstate) < 0) {
+ return -1;
+ }
+ return 0;
+}
+
+
+int
+_PyInterpreterState_SetConfig(const PyConfig *src_config)
+{
+ PyThreadState *tstate = PyThreadState_Get();
+ int res = -1;
+
+ PyConfig config;
+ PyConfig_InitPythonConfig(&config);
+ PyStatus status = _PyConfig_Copy(&config, src_config);
+ if (_PyStatus_EXCEPTION(status)) {
+ _PyErr_SetFromPyStatus(status);
+ goto done;
+ }
+
+ status = PyConfig_Read(&config);
+ if (_PyStatus_EXCEPTION(status)) {
+ _PyErr_SetFromPyStatus(status);
+ goto done;
+ }
+
+ status = _PyConfig_Copy(&tstate->interp->config, &config);
+ if (_PyStatus_EXCEPTION(status)) {
+ _PyErr_SetFromPyStatus(status);
+ goto done;
+ }
+
+ res = interpreter_update_config(tstate, 0);
+
+done:
+ PyConfig_Clear(&config);
+ return res;
+}
+
+
/* Global initializations. Can be undone by Py_Finalize(). Don't
call this twice without an intervening Py_Finalize() call.
@@ -462,7 +511,7 @@ pyinit_core_reconfigure(_PyRuntimeState *runtime,
return status;
}
- status = _PyInterpreterState_SetConfig(interp, config);
+ status = _PyConfig_Copy(&interp->config, config);
if (_PyStatus_EXCEPTION(status)) {
return status;
}
@@ -550,7 +599,7 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
return _PyStatus_ERR("can't make main interpreter");
}
- PyStatus status = _PyInterpreterState_SetConfig(interp, config);
+ PyStatus status = _PyConfig_Copy(&interp->config, config);
if (_PyStatus_EXCEPTION(status)) {
return status;
}
@@ -637,6 +686,15 @@ pycore_init_types(PyThreadState *tstate)
}
}
+ if (_PyWarnings_InitState(tstate) < 0) {
+ return _PyStatus_ERR("can't initialize warnings");
+ }
+
+ status = _PyAtExit_Init(tstate);
+ if (_PyStatus_EXCEPTION(status)) {
+ return status;
+ }
+
return _PyStatus_OK();
}
@@ -674,6 +732,14 @@ pycore_init_builtins(PyThreadState *tstate)
}
Py_DECREF(bimod);
+ // Get the __import__ function
+ PyObject *import_func = _PyDict_GetItemStringWithError(interp->builtins,
+ "__import__");
+ if (import_func == NULL) {
+ goto error;
+ }
+ interp->import_func = Py_NewRef(import_func);
+
assert(!_PyErr_Occurred(tstate));
return _PyStatus_OK();
@@ -685,44 +751,6 @@ error:
static PyStatus
-pycore_init_import_warnings(PyThreadState *tstate, PyObject *sysmod)
-{
- assert(!_PyErr_Occurred(tstate));
-
- PyStatus status = _PyImportHooks_Init(tstate);
- if (_PyStatus_EXCEPTION(status)) {
- return status;
- }
-
- /* Initialize _warnings. */
- status = _PyWarnings_InitState(tstate);
- if (_PyStatus_EXCEPTION(status)) {
- return status;
- }
-
- const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp);
- if (config->_install_importlib) {
- if (_Py_IsMainInterpreter(tstate)) {
- status = _PyConfig_WritePathConfig(config);
- if (_PyStatus_EXCEPTION(status)) {
- return status;
- }
- }
-
- /* This call sets up builtin and frozen import support */
- status = init_importlib(tstate, sysmod);
- if (_PyStatus_EXCEPTION(status)) {
- return status;
- }
- }
-
- assert(!_PyErr_Occurred(tstate));
-
- return _PyStatus_OK();
-}
-
-
-static PyStatus
pycore_interp_init(PyThreadState *tstate)
{
PyStatus status;
@@ -743,7 +771,13 @@ pycore_interp_init(PyThreadState *tstate)
goto done;
}
- status = pycore_init_import_warnings(tstate, sysmod);
+ const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp);
+ if (config->_install_importlib) {
+ /* This call sets up builtin and frozen import support */
+ if (init_importlib(tstate, sysmod) < 0) {
+ return _PyStatus_ERR("failed to initialize importlib");
+ }
+ }
done:
/* sys.modules['sys'] contains a strong reference to the module */
@@ -917,14 +951,16 @@ pyinit_core(_PyRuntimeState *runtime,
}
PyConfig config;
- _PyConfig_InitCompatConfig(&config);
+ PyConfig_InitPythonConfig(&config);
status = _PyConfig_Copy(&config, src_config);
if (_PyStatus_EXCEPTION(status)) {
goto done;
}
- status = PyConfig_Read(&config);
+ // Read the configuration, but don't compute the path configuration
+ // (it is computed in the main init).
+ status = _PyConfig_Read(&config, 0);
if (_PyStatus_EXCEPTION(status)) {
goto done;
}
@@ -949,19 +985,10 @@ done:
configuration. Example of bpo-34008: Py_Main() called after
Py_Initialize(). */
static PyStatus
-_Py_ReconfigureMainInterpreter(PyThreadState *tstate)
+pyinit_main_reconfigure(PyThreadState *tstate)
{
- const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp);
-
- PyObject *argv = _PyWideStringList_AsList(&config->argv);
- if (argv == NULL) {
- return _PyStatus_NO_MEMORY(); \
- }
-
- int res = PyDict_SetItemString(tstate->interp->sysdict, "argv", argv);
- Py_DECREF(argv);
- if (res < 0) {
- return _PyStatus_ERR("fail to set sys.argv");
+ if (interpreter_update_config(tstate, 0) < 0) {
+ return _PyStatus_ERR("fail to reconfigure Python");
}
return _PyStatus_OK();
}
@@ -989,14 +1016,14 @@ init_interp_main(PyThreadState *tstate)
return _PyStatus_OK();
}
- if (is_main_interp) {
- if (_PyTime_Init() < 0) {
- return _PyStatus_ERR("can't initialize time");
- }
+ // Compute the path configuration
+ status = _PyConfig_InitPathConfig(&interp->config, 1);
+ if (_PyStatus_EXCEPTION(status)) {
+ return status;
}
- if (_PySys_InitMain(tstate) < 0) {
- return _PyStatus_ERR("can't finish initializing sys");
+ if (interpreter_update_config(tstate, 1) < 0) {
+ return _PyStatus_ERR("failed to update the Python config");
}
status = init_importlib_external(tstate);
@@ -1018,11 +1045,8 @@ init_interp_main(PyThreadState *tstate)
}
if (is_main_interp) {
- if (config->install_signal_handlers) {
- status = init_signals(tstate);
- if (_PyStatus_EXCEPTION(status)) {
- return status;
- }
+ if (_PySignal_Init(config->install_signal_handlers) < 0) {
+ return _PyStatus_ERR("can't initialize signals");
}
if (_PyTraceMalloc_Init(config->tracemalloc) < 0) {
@@ -1100,7 +1124,7 @@ pyinit_main(PyThreadState *tstate)
}
if (interp->runtime->initialized) {
- return _Py_ReconfigureMainInterpreter(tstate);
+ return pyinit_main_reconfigure(tstate);
}
PyStatus status = init_interp_main(tstate);
@@ -1112,19 +1136,6 @@ pyinit_main(PyThreadState *tstate)
PyStatus
-_Py_InitializeMain(void)
-{
- PyStatus status = _PyRuntime_Initialize();
- if (_PyStatus_EXCEPTION(status)) {
- return status;
- }
- _PyRuntimeState *runtime = &_PyRuntime;
- PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
- return pyinit_main(tstate);
-}
-
-
-PyStatus
Py_InitializeFromConfig(const PyConfig *config)
{
if (config == NULL) {
@@ -1191,6 +1202,19 @@ Py_Initialize(void)
}
+PyStatus
+_Py_InitializeMain(void)
+{
+ PyStatus status = _PyRuntime_Initialize();
+ if (_PyStatus_EXCEPTION(status)) {
+ return status;
+ }
+ _PyRuntimeState *runtime = &_PyRuntime;
+ PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
+ return pyinit_main(tstate);
+}
+
+
static void
finalize_modules_delete_special(PyThreadState *tstate, int verbose)
{
@@ -1545,16 +1569,13 @@ flush_std_files(void)
static void
finalize_interp_types(PyThreadState *tstate)
{
- // The _ast module state is shared by all interpreters.
- // The state must only be cleared by the main interpreter.
- if (_Py_IsMainInterpreter(tstate)) {
- _PyAST_Fini(tstate);
- }
-
_PyExc_Fini(tstate);
_PyFrame_Fini(tstate);
_PyAsyncGen_Fini(tstate);
_PyContext_Fini(tstate);
+ _PyType_Fini(tstate);
+ // Call _PyUnicode_ClearInterned() before _PyDict_Fini() since it uses
+ // a dict internally.
_PyUnicode_ClearInterned(tstate);
_PyDict_Fini(tstate);
@@ -1591,8 +1612,6 @@ finalize_interp_clear(PyThreadState *tstate)
_Py_ClearFileSystemEncoding();
}
- _PyWarnings_Fini(tstate->interp);
-
finalize_interp_types(tstate);
}
@@ -1627,7 +1646,6 @@ Py_FinalizeEx(void)
/* Get current thread state and interpreter pointer */
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
- PyInterpreterState *interp = tstate->interp;
// Wrap up existing "threading"-module-created, non-daemon threads.
wait_for_thread_shutdown(tstate);
@@ -1645,18 +1663,18 @@ Py_FinalizeEx(void)
* the threads created via Threading.
*/
- call_py_exitfuncs(tstate);
+ _PyAtExit_Call(tstate);
/* Copy the core config, PyInterpreterState_Delete() free
the core config memory */
#ifdef Py_REF_DEBUG
- int show_ref_count = interp->config.show_ref_count;
+ int show_ref_count = tstate->interp->config.show_ref_count;
#endif
#ifdef Py_TRACE_REFS
- int dump_refs = interp->config.dump_refs;
+ int dump_refs = tstate->interp->config.dump_refs;
#endif
#ifdef WITH_PYMALLOC
- int malloc_stats = interp->config.malloc_stats;
+ int malloc_stats = tstate->interp->config.malloc_stats;
#endif
/* Remaining daemon threads will automatically exit
@@ -1681,7 +1699,7 @@ Py_FinalizeEx(void)
}
/* Disable signal handling */
- PyOS_FiniInterrupts();
+ _PySignal_Fini();
/* Collect garbage. This may call finalizers; it's nice to call these
* before all modules are destroyed.
@@ -1734,9 +1752,6 @@ Py_FinalizeEx(void)
/* Destroy the database used by _PyImport_{Fixup,Find}Extension */
_PyImport_Fini();
- /* Cleanup typeobject.c's internal caches. */
- _PyType_Fini();
-
/* unload faulthandler module */
_PyFaulthandler_Fini();
@@ -1852,7 +1867,8 @@ new_interpreter(PyThreadState **tstate_p, int isolated_subinterpreter)
config = _PyInterpreterState_GetConfig(main_interp);
}
- status = _PyInterpreterState_SetConfig(interp, config);
+
+ status = _PyConfig_Copy(&interp->config, config);
if (_PyStatus_EXCEPTION(status)) {
goto error;
}
@@ -1935,7 +1951,7 @@ Py_EndInterpreter(PyThreadState *tstate)
// Wrap up existing "threading"-module-created, non-daemon threads.
wait_for_thread_shutdown(tstate);
- call_py_exitfuncs(tstate);
+ _PyAtExit_Call(tstate);
if (tstate != interp->tstate_head || tstate->next != NULL) {
Py_FatalError("not the last thread");
@@ -2621,30 +2637,6 @@ Py_ExitStatusException(PyStatus status)
}
}
-/* Clean up and exit */
-
-/* For the atexit module. */
-void _Py_PyAtExit(void (*func)(PyObject *), PyObject *module)
-{
- PyInterpreterState *is = _PyInterpreterState_GET();
-
- /* Guard against API misuse (see bpo-17852) */
- assert(is->pyexitfunc == NULL || is->pyexitfunc == func);
-
- is->pyexitfunc = func;
- is->pyexitmodule = module;
-}
-
-static void
-call_py_exitfuncs(PyThreadState *tstate)
-{
- PyInterpreterState *interp = tstate->interp;
- if (interp->pyexitfunc == NULL)
- return;
-
- (*interp->pyexitfunc)(interp->pyexitmodule);
- _PyErr_Clear(tstate);
-}
/* Wait until threading._shutdown completes, provided
the threading module was imported in the first place.
@@ -2708,48 +2700,6 @@ Py_Exit(int sts)
exit(sts);
}
-static PyStatus
-init_signals(PyThreadState *tstate)
-{
-#ifdef SIGPIPE
- PyOS_setsig(SIGPIPE, SIG_IGN);
-#endif
-#ifdef SIGXFZ
- PyOS_setsig(SIGXFZ, SIG_IGN);
-#endif
-#ifdef SIGXFSZ
- PyOS_setsig(SIGXFSZ, SIG_IGN);
-#endif
- PyOS_InitInterrupts(); /* May imply init_signals() */
- if (_PyErr_Occurred(tstate)) {
- return _PyStatus_ERR("can't import signal");
- }
- return _PyStatus_OK();
-}
-
-
-/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL.
- *
- * All of the code in this function must only use async-signal-safe functions,
- * listed at `man 7 signal` or
- * http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html.
- *
- * If this function is updated, update also _posix_spawn() of subprocess.py.
- */
-void
-_Py_RestoreSignals(void)
-{
-#ifdef SIGPIPE
- PyOS_setsig(SIGPIPE, SIG_DFL);
-#endif
-#ifdef SIGXFZ
- PyOS_setsig(SIGXFZ, SIG_DFL);
-#endif
-#ifdef SIGXFSZ
- PyOS_setsig(SIGXFSZ, SIG_DFL);
-#endif
-}
-
/*
* The file descriptor fd is considered ``interactive'' if either
@@ -2770,6 +2720,21 @@ Py_FdIsInteractive(FILE *fp, const char *filename)
}
+int
+_Py_FdIsInteractive(FILE *fp, PyObject *filename)
+{
+ if (isatty((int)fileno(fp))) {
+ return 1;
+ }
+ if (!Py_InteractiveFlag) {
+ return 0;
+ }
+ return (filename == NULL) ||
+ (PyUnicode_CompareWithASCIIString(filename, "<stdin>") == 0) ||
+ (PyUnicode_CompareWithASCIIString(filename, "???") == 0);
+}
+
+
/* Wrappers around sigaction() or signal(). */
PyOS_sighandler_t
diff --git a/Python/pystate.c b/Python/pystate.c
index e37cbd5a65..c791b23999 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -4,6 +4,7 @@
#include "Python.h"
#include "pycore_ceval.h"
#include "pycore_initconfig.h"
+#include "pycore_object.h" // _PyType_InitCache()
#include "pycore_pyerrors.h"
#include "pycore_pylifecycle.h"
#include "pycore_pymem.h" // _PyMem_SetDefaultAllocator()
@@ -73,18 +74,24 @@ _PyRuntimeState_Init_impl(_PyRuntimeState *runtime)
runtime->interpreters.mutex = PyThread_allocate_lock();
if (runtime->interpreters.mutex == NULL) {
- return _PyStatus_ERR("Can't initialize threads for interpreter");
+ return _PyStatus_NO_MEMORY();
}
runtime->interpreters.next_id = -1;
runtime->xidregistry.mutex = PyThread_allocate_lock();
if (runtime->xidregistry.mutex == NULL) {
- return _PyStatus_ERR("Can't initialize threads for cross-interpreter data registry");
+ return _PyStatus_NO_MEMORY();
}
// Set it to the ID of the main thread of the main interpreter.
runtime->main_thread = PyThread_get_thread_ident();
+ runtime->unicode_ids.lock = PyThread_allocate_lock();
+ if (runtime->unicode_ids.lock == NULL) {
+ return _PyStatus_NO_MEMORY();
+ }
+ runtime->unicode_ids.next_index = 0;
+
return _PyStatus_OK();
}
@@ -108,17 +115,17 @@ _PyRuntimeState_Fini(_PyRuntimeState *runtime)
/* Force the allocator used by _PyRuntimeState_Init(). */
PyMemAllocatorEx old_alloc;
_PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
-
- if (runtime->interpreters.mutex != NULL) {
- PyThread_free_lock(runtime->interpreters.mutex);
- runtime->interpreters.mutex = NULL;
+#define FREE_LOCK(LOCK) \
+ if (LOCK != NULL) { \
+ PyThread_free_lock(LOCK); \
+ LOCK = NULL; \
}
- if (runtime->xidregistry.mutex != NULL) {
- PyThread_free_lock(runtime->xidregistry.mutex);
- runtime->xidregistry.mutex = NULL;
- }
+ FREE_LOCK(runtime->interpreters.mutex);
+ FREE_LOCK(runtime->xidregistry.mutex);
+ FREE_LOCK(runtime->unicode_ids.lock);
+#undef FREE_LOCK
PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
}
@@ -139,12 +146,14 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime)
int reinit_interp = _PyThread_at_fork_reinit(&runtime->interpreters.mutex);
int reinit_main_id = _PyThread_at_fork_reinit(&runtime->interpreters.main->id_mutex);
int reinit_xidregistry = _PyThread_at_fork_reinit(&runtime->xidregistry.mutex);
+ int reinit_unicode_ids = _PyThread_at_fork_reinit(&runtime->unicode_ids.lock);
PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
if (reinit_interp < 0
|| reinit_main_id < 0
- || reinit_xidregistry < 0)
+ || reinit_xidregistry < 0
+ || reinit_unicode_ids < 0)
{
return _PyStatus_ERR("Failed to reinitialize runtime locks");
@@ -215,6 +224,7 @@ PyInterpreterState_New(void)
_PyGC_InitState(&interp->gc);
PyConfig_InitPythonConfig(&interp->config);
+ _PyType_InitCache(interp);
interp->eval_frame = _PyEval_EvalFrameDefault;
#ifdef HAVE_DLOPEN
@@ -300,13 +310,17 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
Py_CLEAR(interp->after_forkers_parent);
Py_CLEAR(interp->after_forkers_child);
#endif
- if (_PyRuntimeState_GetFinalizing(runtime) == NULL) {
- _PyWarnings_Fini(interp);
- }
+
+ _PyAST_Fini(interp);
+ _PyWarnings_Fini(interp);
+ _PyAtExit_Fini(interp);
+
+ // All Python types must be destroyed before the last GC collection. Python
+ // types create a reference cycle to themselves in their in their
+ // PyTypeObject.tp_mro member (the tuple contains the type).
/* Last garbage collection on this interpreter */
_PyGC_CollectNoFail(tstate);
-
_PyGC_Fini(tstate);
/* We don't clear sysdict and builtins until the end of this function.
@@ -602,7 +616,7 @@ new_threadstate(PyInterpreterState *interp, int init)
tstate->frame = NULL;
tstate->recursion_depth = 0;
- tstate->overflowed = 0;
+ tstate->recursion_headroom = 0;
tstate->stackcheck_counter = 0;
tstate->tracing = 0;
tstate->use_tracing = 0;
@@ -775,7 +789,7 @@ PyState_RemoveModule(struct PyModuleDef* def)
return PyList_SetItem(interp->modules_by_index, index, Py_None);
}
-/* Used by PyImport_Cleanup() */
+// Used by finalize_modules()
void
_PyInterpreterState_ClearModules(PyInterpreterState *interp)
{
@@ -1917,11 +1931,17 @@ _PyInterpreterState_GetConfig(PyInterpreterState *interp)
}
-PyStatus
-_PyInterpreterState_SetConfig(PyInterpreterState *interp,
- const PyConfig *config)
+int
+_PyInterpreterState_GetConfigCopy(PyConfig *config)
{
- return _PyConfig_Copy(&interp->config, config);
+ PyInterpreterState *interp = PyInterpreterState_Get();
+
+ PyStatus status = _PyConfig_Copy(config, &interp->config);
+ if (PyStatus_Exception(status)) {
+ _PyErr_SetFromPyStatus(status);
+ return -1;
+ }
+ return 0;
}
diff --git a/Python/pystrtod.c b/Python/pystrtod.c
index 1c8202c776..9145d4eba1 100644
--- a/Python/pystrtod.c
+++ b/Python/pystrtod.c
@@ -255,7 +255,7 @@ _PyOS_ascii_strtod(const char *nptr, char **endptr)
char *copy, *c;
/* Create a copy of the input, with the '.' converted to the
locale-specific decimal point */
- copy = (char *)PyMem_MALLOC(end - digits_pos +
+ copy = (char *)PyMem_Malloc(end - digits_pos +
1 + decimal_point_len);
if (copy == NULL) {
*endptr = (char *)nptr;
@@ -286,7 +286,7 @@ _PyOS_ascii_strtod(const char *nptr, char **endptr)
(fail_pos - copy);
}
- PyMem_FREE(copy);
+ PyMem_Free(copy);
}
else {
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index bd49c40e97..dacf1a6471 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -59,48 +59,77 @@ extern "C" {
static void flush_io(void);
static PyObject *run_mod(mod_ty, PyObject *, PyObject *, PyObject *,
PyCompilerFlags *, PyArena *);
-static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *,
+static PyObject *run_pyc_file(FILE *, PyObject *, PyObject *,
PyCompilerFlags *);
static int PyRun_InteractiveOneObjectEx(FILE *, PyObject *, PyCompilerFlags *);
+static PyObject* pyrun_file(FILE *fp, PyObject *filename, int start,
+ PyObject *globals, PyObject *locals, int closeit,
+ PyCompilerFlags *flags);
+
-/* Parse input from a file and execute it */
int
-PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit,
+_PyRun_AnyFileObject(FILE *fp, PyObject *filename, int closeit,
PyCompilerFlags *flags)
{
- if (filename == NULL)
- filename = "???";
- if (Py_FdIsInteractive(fp, filename)) {
- int err = PyRun_InteractiveLoopFlags(fp, filename, flags);
- if (closeit)
+ int decref_filename = 0;
+ if (filename == NULL) {
+ filename = PyUnicode_FromString("???");
+ if (filename == NULL) {
+ PyErr_Print();
+ return -1;
+ }
+ decref_filename = 1;
+ }
+
+ int res;
+ if (_Py_FdIsInteractive(fp, filename)) {
+ res = _PyRun_InteractiveLoopObject(fp, filename, flags);
+ if (closeit) {
fclose(fp);
- return err;
+ }
+ }
+ else {
+ res = _PyRun_SimpleFileObject(fp, filename, closeit, flags);
+ }
+
+ if (decref_filename) {
+ Py_DECREF(filename);
}
- else
- return PyRun_SimpleFileExFlags(fp, filename, closeit, flags);
+ return res;
}
+
+/* Parse input from a file and execute it */
int
-PyRun_InteractiveLoopFlags(FILE *fp, const char *filename_str, PyCompilerFlags *flags)
+PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit,
+ PyCompilerFlags *flags)
{
- PyObject *filename, *v;
- int ret, err;
- PyCompilerFlags local_flags = _PyCompilerFlags_INIT;
- int nomem_count = 0;
-#ifdef Py_REF_DEBUG
- int show_ref_count = _Py_GetConfig()->show_ref_count;
-#endif
-
- filename = PyUnicode_DecodeFSDefault(filename_str);
- if (filename == NULL) {
- PyErr_Print();
- return -1;
+ PyObject *filename_obj;
+ if (filename != NULL) {
+ filename_obj = PyUnicode_DecodeFSDefault(filename);
+ if (filename_obj == NULL) {
+ PyErr_Print();
+ return -1;
+ }
+ }
+ else {
+ filename_obj = NULL;
}
+ int res = _PyRun_AnyFileObject(fp, filename_obj, closeit, flags);
+ Py_XDECREF(filename_obj);
+ return res;
+}
+
+int
+_PyRun_InteractiveLoopObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags)
+{
+ PyCompilerFlags local_flags = _PyCompilerFlags_INIT;
if (flags == NULL) {
flags = &local_flags;
}
- v = _PySys_GetObjectId(&PyId_ps1);
+
+ PyObject *v = _PySys_GetObjectId(&PyId_ps1);
if (v == NULL) {
_PySys_SetObjectId(&PyId_ps1, v = PyUnicode_FromString(">>> "));
Py_XDECREF(v);
@@ -110,7 +139,13 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename_str, PyCompilerFlags *
_PySys_SetObjectId(&PyId_ps2, v = PyUnicode_FromString("... "));
Py_XDECREF(v);
}
- err = 0;
+
+#ifdef Py_REF_DEBUG
+ int show_ref_count = _Py_GetConfig()->show_ref_count;
+#endif
+ int err = 0;
+ int ret;
+ int nomem_count = 0;
do {
ret = PyRun_InteractiveOneObjectEx(fp, filename, flags);
if (ret == -1 && PyErr_Occurred()) {
@@ -137,10 +172,26 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename_str, PyCompilerFlags *
}
#endif
} while (ret != E_EOF);
- Py_DECREF(filename);
return err;
}
+
+int
+PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
+{
+ PyObject *filename_obj = PyUnicode_DecodeFSDefault(filename);
+ if (filename_obj == NULL) {
+ PyErr_Print();
+ return -1;
+ }
+
+ int err = _PyRun_InteractiveLoopObject(fp, filename_obj, flags);
+ Py_DECREF(filename_obj);
+ return err;
+
+}
+
+
/* A PyRun_InteractiveOneObject() auxiliary function that does not print the
* error on failure. */
static int
@@ -269,82 +320,89 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename_str, PyCompilerFlags *f
the file type, and, if we may close it, at the first few bytes. */
static int
-maybe_pyc_file(FILE *fp, const char* filename, const char* ext, int closeit)
+maybe_pyc_file(FILE *fp, PyObject *filename, int closeit)
{
- if (strcmp(ext, ".pyc") == 0)
+ PyObject *ext = PyUnicode_FromString(".pyc");
+ if (ext == NULL) {
+ return -1;
+ }
+ Py_ssize_t endswith = PyUnicode_Tailmatch(filename, ext, 0, PY_SSIZE_T_MAX, +1);
+ Py_DECREF(ext);
+ if (endswith) {
return 1;
+ }
/* Only look into the file if we are allowed to close it, since
it then should also be seekable. */
- if (closeit) {
- /* Read only two bytes of the magic. If the file was opened in
- text mode, the bytes 3 and 4 of the magic (\r\n) might not
- be read as they are on disk. */
- unsigned int halfmagic = PyImport_GetMagicNumber() & 0xFFFF;
- unsigned char buf[2];
- /* Mess: In case of -x, the stream is NOT at its start now,
- and ungetc() was used to push back the first newline,
- which makes the current stream position formally undefined,
- and a x-platform nightmare.
- Unfortunately, we have no direct way to know whether -x
- was specified. So we use a terrible hack: if the current
- stream position is not 0, we assume -x was specified, and
- give up. Bug 132850 on SourceForge spells out the
- hopelessness of trying anything else (fseek and ftell
- don't work predictably x-platform for text-mode files).
- */
- int ispyc = 0;
- if (ftell(fp) == 0) {
- if (fread(buf, 1, 2, fp) == 2 &&
- ((unsigned int)buf[1]<<8 | buf[0]) == halfmagic)
- ispyc = 1;
- rewind(fp);
- }
- return ispyc;
+ if (!closeit) {
+ return 0;
}
- return 0;
+
+ /* Read only two bytes of the magic. If the file was opened in
+ text mode, the bytes 3 and 4 of the magic (\r\n) might not
+ be read as they are on disk. */
+ unsigned int halfmagic = PyImport_GetMagicNumber() & 0xFFFF;
+ unsigned char buf[2];
+ /* Mess: In case of -x, the stream is NOT at its start now,
+ and ungetc() was used to push back the first newline,
+ which makes the current stream position formally undefined,
+ and a x-platform nightmare.
+ Unfortunately, we have no direct way to know whether -x
+ was specified. So we use a terrible hack: if the current
+ stream position is not 0, we assume -x was specified, and
+ give up. Bug 132850 on SourceForge spells out the
+ hopelessness of trying anything else (fseek and ftell
+ don't work predictably x-platform for text-mode files).
+ */
+ int ispyc = 0;
+ if (ftell(fp) == 0) {
+ if (fread(buf, 1, 2, fp) == 2 &&
+ ((unsigned int)buf[1]<<8 | buf[0]) == halfmagic)
+ ispyc = 1;
+ rewind(fp);
+ }
+ return ispyc;
}
+
static int
-set_main_loader(PyObject *d, const char *filename, const char *loader_name)
+set_main_loader(PyObject *d, PyObject *filename, const char *loader_name)
{
- PyObject *filename_obj, *bootstrap, *loader_type = NULL, *loader;
- int result = 0;
-
- filename_obj = PyUnicode_DecodeFSDefault(filename);
- if (filename_obj == NULL)
- return -1;
PyInterpreterState *interp = _PyInterpreterState_GET();
- bootstrap = PyObject_GetAttrString(interp->importlib,
- "_bootstrap_external");
- if (bootstrap != NULL) {
- loader_type = PyObject_GetAttrString(bootstrap, loader_name);
- Py_DECREF(bootstrap);
+ PyObject *bootstrap = PyObject_GetAttrString(interp->importlib,
+ "_bootstrap_external");
+ if (bootstrap == NULL) {
+ return -1;
}
+
+ PyObject *loader_type = PyObject_GetAttrString(bootstrap, loader_name);
+ Py_DECREF(bootstrap);
if (loader_type == NULL) {
- Py_DECREF(filename_obj);
return -1;
}
- loader = PyObject_CallFunction(loader_type, "sN", "__main__", filename_obj);
+
+ PyObject *loader = PyObject_CallFunction(loader_type,
+ "sO", "__main__", filename);
Py_DECREF(loader_type);
if (loader == NULL) {
return -1;
}
+
if (PyDict_SetItemString(d, "__loader__", loader) < 0) {
- result = -1;
+ Py_DECREF(loader);
+ return -1;
}
Py_DECREF(loader);
- return result;
+ return 0;
}
+
int
-PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
+_PyRun_SimpleFileObject(FILE *fp, PyObject *filename, int closeit,
PyCompilerFlags *flags)
{
PyObject *m, *d, *v;
- const char *ext;
int set_file_name = 0, ret = -1;
- size_t len;
m = PyImport_AddModule("__main__");
if (m == NULL)
@@ -355,29 +413,29 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
if (PyErr_Occurred()) {
goto done;
}
- PyObject *f;
- f = PyUnicode_DecodeFSDefault(filename);
- if (f == NULL)
- goto done;
- if (PyDict_SetItemString(d, "__file__", f) < 0) {
- Py_DECREF(f);
+ if (PyDict_SetItemString(d, "__file__", filename) < 0) {
goto done;
}
if (PyDict_SetItemString(d, "__cached__", Py_None) < 0) {
- Py_DECREF(f);
goto done;
}
set_file_name = 1;
- Py_DECREF(f);
}
- len = strlen(filename);
- ext = filename + len - (len > 4 ? 4 : 0);
- if (maybe_pyc_file(fp, filename, ext, closeit)) {
+
+ int pyc = maybe_pyc_file(fp, filename, closeit);
+ if (pyc < 0) {
+ goto done;
+ }
+
+ if (pyc) {
FILE *pyc_fp;
/* Try to run a pyc file. First, re-open in binary */
- if (closeit)
+ if (closeit) {
fclose(fp);
- if ((pyc_fp = _Py_fopen(filename, "rb")) == NULL) {
+ }
+
+ pyc_fp = _Py_fopen_obj(filename, "rb");
+ if (pyc_fp == NULL) {
fprintf(stderr, "python: Can't reopen .pyc file\n");
goto done;
}
@@ -388,17 +446,17 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
fclose(pyc_fp);
goto done;
}
- v = run_pyc_file(pyc_fp, filename, d, d, flags);
+ v = run_pyc_file(pyc_fp, d, d, flags);
} else {
/* When running from stdin, leave __main__.__loader__ alone */
- if (strcmp(filename, "<stdin>") != 0 &&
+ if (PyUnicode_CompareWithASCIIString(filename, "<stdin>") != 0 &&
set_main_loader(d, filename, "SourceFileLoader") < 0) {
fprintf(stderr, "python: failed to set __main__.__loader__\n");
ret = -1;
goto done;
}
- v = PyRun_FileExFlags(fp, filename, Py_file_input, d, d,
- closeit, flags);
+ v = pyrun_file(fp, filename, Py_file_input, d, d,
+ closeit, flags);
}
flush_io();
if (v == NULL) {
@@ -421,6 +479,21 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
return ret;
}
+
+int
+PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
+ PyCompilerFlags *flags)
+{
+ PyObject *filename_obj = PyUnicode_DecodeFSDefault(filename);
+ if (filename_obj == NULL) {
+ return -1;
+ }
+ int res = _PyRun_SimpleFileObject(fp, filename_obj, closeit, flags);
+ Py_DECREF(filename_obj);
+ return res;
+}
+
+
int
PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)
{
@@ -1039,40 +1112,54 @@ PyRun_StringFlags(const char *str, int start, PyObject *globals,
return ret;
}
-PyObject *
-PyRun_FileExFlags(FILE *fp, const char *filename_str, int start, PyObject *globals,
- PyObject *locals, int closeit, PyCompilerFlags *flags)
-{
- PyObject *ret = NULL;
- mod_ty mod;
- PyArena *arena = NULL;
- PyObject *filename;
-
- filename = PyUnicode_DecodeFSDefault(filename_str);
- if (filename == NULL)
- goto exit;
- arena = PyArena_New();
- if (arena == NULL)
- goto exit;
+static PyObject *
+pyrun_file(FILE *fp, PyObject *filename, int start, PyObject *globals,
+ PyObject *locals, int closeit, PyCompilerFlags *flags)
+{
+ PyArena *arena = PyArena_New();
+ if (arena == NULL) {
+ return NULL;
+ }
+ mod_ty mod;
mod = PyParser_ASTFromFileObject(fp, filename, NULL, start, NULL, NULL,
flags, NULL, arena);
- if (closeit)
+ if (closeit) {
fclose(fp);
- if (mod == NULL) {
- goto exit;
}
- ret = run_mod(mod, filename, globals, locals, flags, arena);
-exit:
- Py_XDECREF(filename);
- if (arena != NULL)
- PyArena_Free(arena);
+ PyObject *ret;
+ if (mod != NULL) {
+ ret = run_mod(mod, filename, globals, locals, flags, arena);
+ }
+ else {
+ ret = NULL;
+ }
+ PyArena_Free(arena);
+
return ret;
}
+
+PyObject *
+PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals,
+ PyObject *locals, int closeit, PyCompilerFlags *flags)
+{
+ PyObject *filename_obj = PyUnicode_DecodeFSDefault(filename);
+ if (filename_obj == NULL) {
+ return NULL;
+ }
+
+ PyObject *res = pyrun_file(fp, filename_obj, start, globals,
+ locals, closeit, flags);
+ Py_DECREF(filename_obj);
+ return res;
+
+}
+
+
static void
flush_io(void)
{
@@ -1155,8 +1242,8 @@ run_mod(mod_ty mod, PyObject *filename, PyObject *globals, PyObject *locals,
}
static PyObject *
-run_pyc_file(FILE *fp, const char *filename, PyObject *globals,
- PyObject *locals, PyCompilerFlags *flags)
+run_pyc_file(FILE *fp, PyObject *globals, PyObject *locals,
+ PyCompilerFlags *flags)
{
PyThreadState *tstate = _PyThreadState_GET();
PyCodeObject *co;
@@ -1235,14 +1322,6 @@ Py_CompileStringExFlags(const char *str, const char *filename_str, int start,
return co;
}
-/* For use in Py_LIMITED_API */
-#undef Py_CompileString
-PyObject *
-PyCompileString(const char *str, const char *filename, int start)
-{
- return Py_CompileStringFlags(str, filename, start, NULL);
-}
-
const char *
_Py_SourceAsString(PyObject *cmd, const char *funcname, const char *what, PyCompilerFlags *cf, PyObject **cmd_copy)
{
@@ -1371,6 +1450,109 @@ PyOS_CheckStack(void)
#endif /* USE_STACKCHECK */
+/* Deprecated C API functions still provided for binary compatibility */
+
+#undef PyRun_AnyFile
+PyAPI_FUNC(int)
+PyRun_AnyFile(FILE *fp, const char *name)
+{
+ return PyRun_AnyFileExFlags(fp, name, 0, NULL);
+}
+
+#undef PyRun_AnyFileEx
+PyAPI_FUNC(int)
+PyRun_AnyFileEx(FILE *fp, const char *name, int closeit)
+{
+ return PyRun_AnyFileExFlags(fp, name, closeit, NULL);
+}
+
+#undef PyRun_AnyFileFlags
+PyAPI_FUNC(int)
+PyRun_AnyFileFlags(FILE *fp, const char *name, PyCompilerFlags *flags)
+{
+ return PyRun_AnyFileExFlags(fp, name, 0, flags);
+}
+
+#undef PyRun_File
+PyAPI_FUNC(PyObject *)
+PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l)
+{
+ return PyRun_FileExFlags(fp, p, s, g, l, 0, NULL);
+}
+
+#undef PyRun_FileEx
+PyAPI_FUNC(PyObject *)
+PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c)
+{
+ return PyRun_FileExFlags(fp, p, s, g, l, c, NULL);
+}
+
+#undef PyRun_FileFlags
+PyAPI_FUNC(PyObject *)
+PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l,
+ PyCompilerFlags *flags)
+{
+ return PyRun_FileExFlags(fp, p, s, g, l, 0, flags);
+}
+
+#undef PyRun_SimpleFile
+PyAPI_FUNC(int)
+PyRun_SimpleFile(FILE *f, const char *p)
+{
+ return PyRun_SimpleFileExFlags(f, p, 0, NULL);
+}
+
+#undef PyRun_SimpleFileEx
+PyAPI_FUNC(int)
+PyRun_SimpleFileEx(FILE *f, const char *p, int c)
+{
+ return PyRun_SimpleFileExFlags(f, p, c, NULL);
+}
+
+
+#undef PyRun_String
+PyAPI_FUNC(PyObject *)
+PyRun_String(const char *str, int s, PyObject *g, PyObject *l)
+{
+ return PyRun_StringFlags(str, s, g, l, NULL);
+}
+
+#undef PyRun_SimpleString
+PyAPI_FUNC(int)
+PyRun_SimpleString(const char *s)
+{
+ return PyRun_SimpleStringFlags(s, NULL);
+}
+
+#undef Py_CompileString
+PyAPI_FUNC(PyObject *)
+Py_CompileString(const char *str, const char *p, int s)
+{
+ return Py_CompileStringExFlags(str, p, s, NULL, -1);
+}
+
+#undef Py_CompileStringFlags
+PyAPI_FUNC(PyObject *)
+Py_CompileStringFlags(const char *str, const char *p, int s,
+ PyCompilerFlags *flags)
+{
+ return Py_CompileStringExFlags(str, p, s, flags, -1);
+}
+
+#undef PyRun_InteractiveOne
+PyAPI_FUNC(int)
+PyRun_InteractiveOne(FILE *f, const char *p)
+{
+ return PyRun_InteractiveOneFlags(f, p, NULL);
+}
+
+#undef PyRun_InteractiveLoop
+PyAPI_FUNC(int)
+PyRun_InteractiveLoop(FILE *f, const char *p)
+{
+ return PyRun_InteractiveLoopFlags(f, p, NULL);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/Python/pytime.c b/Python/pytime.c
index b121b432f4..1ef99aee74 100644
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -5,6 +5,12 @@
#if defined(__APPLE__)
#include <mach/mach_time.h> /* mach_absolute_time(), mach_timebase_info() */
+
+#if defined(__APPLE__) && defined(__has_builtin)
+# if __has_builtin(__builtin_available)
+# define HAVE_CLOCK_GETTIME_RUNTIME __builtin_available(macOS 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *)
+# endif
+#endif
#endif
#define _PyTime_check_mul_overflow(a, b) \
@@ -298,8 +304,8 @@ pytime_fromtimespec(_PyTime_t *tp, struct timespec *ts, int raise)
if (_PyTime_check_mul_overflow(t, SEC_TO_NS)) {
if (raise) {
_PyTime_overflow();
+ res = -1;
}
- res = -1;
t = (t > 0) ? _PyTime_MAX : _PyTime_MIN;
}
else {
@@ -312,8 +318,8 @@ pytime_fromtimespec(_PyTime_t *tp, struct timespec *ts, int raise)
if (t > _PyTime_MAX - nsec) {
if (raise) {
_PyTime_overflow();
+ res = -1;
}
- res = -1;
t = _PyTime_MAX;
}
else {
@@ -344,8 +350,8 @@ pytime_fromtimeval(_PyTime_t *tp, struct timeval *tv, int raise)
if (_PyTime_check_mul_overflow(t, SEC_TO_NS)) {
if (raise) {
_PyTime_overflow();
+ res = -1;
}
- res = -1;
t = (t > 0) ? _PyTime_MAX : _PyTime_MIN;
}
else {
@@ -358,8 +364,8 @@ pytime_fromtimeval(_PyTime_t *tp, struct timeval *tv, int raise)
if (t > _PyTime_MAX - usec) {
if (raise) {
_PyTime_overflow();
+ res = -1;
}
- res = -1;
t = _PyTime_MAX;
}
else {
@@ -650,7 +656,7 @@ _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts)
#endif
static int
-pygettimeofday(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
+py_get_system_clock(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
{
#ifdef MS_WINDOWS
FILETIME system_time;
@@ -683,15 +689,22 @@ pygettimeofday(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
#else /* MS_WINDOWS */
int err;
-#ifdef HAVE_CLOCK_GETTIME
+#if defined(HAVE_CLOCK_GETTIME)
struct timespec ts;
-#else
+#endif
+
+#if !defined(HAVE_CLOCK_GETTIME) || defined(__APPLE__)
struct timeval tv;
#endif
assert(info == NULL || raise);
#ifdef HAVE_CLOCK_GETTIME
+
+#ifdef HAVE_CLOCK_GETTIME_RUNTIME
+ if (HAVE_CLOCK_GETTIME_RUNTIME) {
+#endif
+
err = clock_gettime(CLOCK_REALTIME, &ts);
if (err) {
if (raise) {
@@ -715,7 +728,14 @@ pygettimeofday(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
info->resolution = 1e-9;
}
}
-#else /* HAVE_CLOCK_GETTIME */
+
+#ifdef HAVE_CLOCK_GETTIME_RUNTIME
+ } else {
+#endif
+
+#endif
+
+#if !defined(HAVE_CLOCK_GETTIME) || defined(HAVE_CLOCK_GETTIME_RUNTIME)
/* test gettimeofday() */
err = gettimeofday(&tv, (struct timezone *)NULL);
@@ -735,6 +755,11 @@ pygettimeofday(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
info->monotonic = 0;
info->adjustable = 1;
}
+
+#if defined(HAVE_CLOCK_GETTIME_RUNTIME) && defined(HAVE_CLOCK_GETTIME)
+ } /* end of availibity block */
+#endif
+
#endif /* !HAVE_CLOCK_GETTIME */
#endif /* !MS_WINDOWS */
return 0;
@@ -744,9 +769,10 @@ _PyTime_t
_PyTime_GetSystemClock(void)
{
_PyTime_t t;
- if (pygettimeofday(&t, NULL, 0) < 0) {
- /* should not happen, _PyTime_Init() checked the clock at startup */
- Py_FatalError("pygettimeofday() failed");
+ if (py_get_system_clock(&t, NULL, 0) < 0) {
+ // If clock_gettime(CLOCK_REALTIME) or gettimeofday() fails:
+ // silently ignore the failure and return 0.
+ t = 0;
}
return t;
}
@@ -754,11 +780,61 @@ _PyTime_GetSystemClock(void)
int
_PyTime_GetSystemClockWithInfo(_PyTime_t *t, _Py_clock_info_t *info)
{
- return pygettimeofday(t, info, 1);
+ return py_get_system_clock(t, info, 1);
}
+#if __APPLE__
static int
-pymonotonic(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
+py_mach_timebase_info(_PyTime_t *pnumer, _PyTime_t *pdenom, int raise)
+{
+ static mach_timebase_info_data_t timebase;
+ /* According to the Technical Q&A QA1398, mach_timebase_info() cannot
+ fail: https://developer.apple.com/library/mac/#qa/qa1398/ */
+ (void)mach_timebase_info(&timebase);
+
+ /* Sanity check: should never occur in practice */
+ if (timebase.numer < 1 || timebase.denom < 1) {
+ if (raise) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "invalid mach_timebase_info");
+ }
+ return -1;
+ }
+
+ /* Check that timebase.numer and timebase.denom can be casted to
+ _PyTime_t. In practice, timebase uses uint32_t, so casting cannot
+ overflow. At the end, only make sure that the type is uint32_t
+ (_PyTime_t is 64-bit long). */
+ Py_BUILD_ASSERT(sizeof(timebase.numer) < sizeof(_PyTime_t));
+ Py_BUILD_ASSERT(sizeof(timebase.denom) < sizeof(_PyTime_t));
+
+ /* Make sure that (ticks * timebase.numer) cannot overflow in
+ _PyTime_MulDiv(), with ticks < timebase.denom.
+
+ Known time bases:
+
+ * always (1, 1) on Intel
+ * (1000000000, 33333335) or (1000000000, 25000000) on PowerPC
+
+ None of these time bases can overflow with 64-bit _PyTime_t, but
+ check for overflow, just in case. */
+ if ((_PyTime_t)timebase.numer > _PyTime_MAX / (_PyTime_t)timebase.denom) {
+ if (raise) {
+ PyErr_SetString(PyExc_OverflowError,
+ "mach_timebase_info is too large");
+ }
+ return -1;
+ }
+
+ *pnumer = (_PyTime_t)timebase.numer;
+ *pdenom = (_PyTime_t)timebase.denom;
+ return 0;
+}
+#endif
+
+
+static int
+py_get_monotonic_clock(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
{
#if defined(MS_WINDOWS)
ULONGLONG ticks;
@@ -775,10 +851,12 @@ pymonotonic(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
_PyTime_overflow();
return -1;
}
- /* Hello, time traveler! */
- Py_FatalError("pymonotonic: integer overflow");
+ // Truncate to _PyTime_MAX silently.
+ *tp = _PyTime_MAX;
+ }
+ else {
+ *tp = t * MS_TO_NS;
}
- *tp = t * MS_TO_NS;
if (info) {
DWORD timeAdjustment, timeIncrement;
@@ -796,62 +874,23 @@ pymonotonic(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
}
#elif defined(__APPLE__)
- static mach_timebase_info_data_t timebase;
- static uint64_t t0 = 0;
- uint64_t ticks;
-
- if (timebase.denom == 0) {
- /* According to the Technical Q&A QA1398, mach_timebase_info() cannot
- fail: https://developer.apple.com/library/mac/#qa/qa1398/ */
- (void)mach_timebase_info(&timebase);
-
- /* Sanity check: should never occur in practice */
- if (timebase.numer < 1 || timebase.denom < 1) {
- PyErr_SetString(PyExc_RuntimeError,
- "invalid mach_timebase_info");
+ static _PyTime_t timebase_numer = 0;
+ static _PyTime_t timebase_denom = 0;
+ if (timebase_denom == 0) {
+ if (py_mach_timebase_info(&timebase_numer, &timebase_denom, raise) < 0) {
return -1;
}
-
- /* Check that timebase.numer and timebase.denom can be casted to
- _PyTime_t. In practice, timebase uses uint32_t, so casting cannot
- overflow. At the end, only make sure that the type is uint32_t
- (_PyTime_t is 64-bit long). */
- assert(sizeof(timebase.numer) < sizeof(_PyTime_t));
- assert(sizeof(timebase.denom) < sizeof(_PyTime_t));
-
- /* Make sure that (ticks * timebase.numer) cannot overflow in
- _PyTime_MulDiv(), with ticks < timebase.denom.
-
- Known time bases:
-
- * always (1, 1) on Intel
- * (1000000000, 33333335) or (1000000000, 25000000) on PowerPC
-
- None of these time bases can overflow with 64-bit _PyTime_t, but
- check for overflow, just in case. */
- if ((_PyTime_t)timebase.numer > _PyTime_MAX / (_PyTime_t)timebase.denom) {
- PyErr_SetString(PyExc_OverflowError,
- "mach_timebase_info is too large");
- return -1;
- }
-
- t0 = mach_absolute_time();
}
if (info) {
info->implementation = "mach_absolute_time()";
- info->resolution = (double)timebase.numer / (double)timebase.denom * 1e-9;
+ info->resolution = (double)timebase_numer / (double)timebase_denom * 1e-9;
info->monotonic = 1;
info->adjustable = 0;
}
- ticks = mach_absolute_time();
- /* Use a "time zero" to reduce precision loss when converting time
- to floatting point number, as in time.monotonic(). */
- ticks -= t0;
- *tp = _PyTime_MulDiv(ticks,
- (_PyTime_t)timebase.numer,
- (_PyTime_t)timebase.denom);
+ uint64_t ticks = mach_absolute_time();
+ *tp = _PyTime_MulDiv((_PyTime_t)ticks, timebase_numer, timebase_denom);
#elif defined(__hpux)
hrtime_t time;
@@ -915,10 +954,10 @@ _PyTime_t
_PyTime_GetMonotonicClock(void)
{
_PyTime_t t;
- if (pymonotonic(&t, NULL, 0) < 0) {
- /* should not happen, _PyTime_Init() checked that monotonic clock at
- startup */
- Py_FatalError("pymonotonic() failed");
+ if (py_get_monotonic_clock(&t, NULL, 0) < 0) {
+ // If mach_timebase_info(), clock_gettime() or gethrtime() fails:
+ // silently ignore the failure and return 0.
+ t = 0;
}
return t;
}
@@ -926,56 +965,69 @@ _PyTime_GetMonotonicClock(void)
int
_PyTime_GetMonotonicClockWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
{
- return pymonotonic(tp, info, 1);
+ return py_get_monotonic_clock(tp, info, 1);
}
#ifdef MS_WINDOWS
static int
-win_perf_counter(_PyTime_t *tp, _Py_clock_info_t *info)
+win_perf_counter_frequency(LONGLONG *pfrequency, int raise)
{
- static LONGLONG frequency = 0;
- static LONGLONG t0 = 0;
- LARGE_INTEGER now;
- LONGLONG ticksll;
- _PyTime_t ticks;
+ LONGLONG frequency;
- if (frequency == 0) {
- LARGE_INTEGER freq;
- if (!QueryPerformanceFrequency(&freq)) {
+ LARGE_INTEGER freq;
+ if (!QueryPerformanceFrequency(&freq)) {
+ if (raise) {
PyErr_SetFromWindowsErr(0);
- return -1;
}
- frequency = freq.QuadPart;
+ return -1;
+ }
+ frequency = freq.QuadPart;
- /* Sanity check: should never occur in practice */
- if (frequency < 1) {
+ /* Sanity check: should never occur in practice */
+ if (frequency < 1) {
+ if (raise) {
PyErr_SetString(PyExc_RuntimeError,
"invalid QueryPerformanceFrequency");
- return -1;
}
+ return -1;
+ }
- /* Check that frequency can be casted to _PyTime_t.
+ /* Check that frequency can be casted to _PyTime_t.
- Make also sure that (ticks * SEC_TO_NS) cannot overflow in
- _PyTime_MulDiv(), with ticks < frequency.
+ Make also sure that (ticks * SEC_TO_NS) cannot overflow in
+ _PyTime_MulDiv(), with ticks < frequency.
- Known QueryPerformanceFrequency() values:
+ Known QueryPerformanceFrequency() values:
- * 10,000,000 (10 MHz): 100 ns resolution
- * 3,579,545 Hz (3.6 MHz): 279 ns resolution
+ * 10,000,000 (10 MHz): 100 ns resolution
+ * 3,579,545 Hz (3.6 MHz): 279 ns resolution
- None of these frequencies can overflow with 64-bit _PyTime_t, but
- check for overflow, just in case. */
- if (frequency > _PyTime_MAX
- || frequency > (LONGLONG)_PyTime_MAX / (LONGLONG)SEC_TO_NS) {
+ None of these frequencies can overflow with 64-bit _PyTime_t, but
+ check for overflow, just in case. */
+ if (frequency > _PyTime_MAX
+ || frequency > (LONGLONG)_PyTime_MAX / (LONGLONG)SEC_TO_NS)
+ {
+ if (raise) {
PyErr_SetString(PyExc_OverflowError,
"QueryPerformanceFrequency is too large");
- return -1;
}
+ return -1;
+ }
- QueryPerformanceCounter(&now);
- t0 = now.QuadPart;
+ *pfrequency = frequency;
+ return 0;
+}
+
+
+static int
+py_get_win_perf_counter(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
+{
+ static LONGLONG frequency = 0;
+ if (frequency == 0) {
+ if (win_perf_counter_frequency(&frequency, raise) < 0) {
+ return -1;
+ }
}
if (info) {
@@ -985,15 +1037,13 @@ win_perf_counter(_PyTime_t *tp, _Py_clock_info_t *info)
info->adjustable = 0;
}
+ LARGE_INTEGER now;
QueryPerformanceCounter(&now);
- ticksll = now.QuadPart;
-
- /* Use a "time zero" to reduce precision loss when converting time
- to floatting point number, as in time.perf_counter(). */
- ticksll -= t0;
+ LONGLONG ticksll = now.QuadPart;
/* Make sure that casting LONGLONG to _PyTime_t cannot overflow,
both types are signed */
+ _PyTime_t ticks;
Py_BUILD_ASSERT(sizeof(ticksll) <= sizeof(ticks));
ticks = (_PyTime_t)ticksll;
@@ -1007,7 +1057,7 @@ int
_PyTime_GetPerfCounterWithInfo(_PyTime_t *t, _Py_clock_info_t *info)
{
#ifdef MS_WINDOWS
- return win_perf_counter(t, info);
+ return py_get_win_perf_counter(t, info, 1);
#else
return _PyTime_GetMonotonicClockWithInfo(t, info);
#endif
@@ -1018,33 +1068,22 @@ _PyTime_t
_PyTime_GetPerfCounter(void)
{
_PyTime_t t;
- if (_PyTime_GetPerfCounterWithInfo(&t, NULL)) {
- Py_FatalError("_PyTime_GetPerfCounterWithInfo() failed");
+ int res;
+#ifdef MS_WINDOWS
+ res = py_get_win_perf_counter(&t, NULL, 0);
+#else
+ res = py_get_monotonic_clock(&t, NULL, 0);
+#endif
+ if (res < 0) {
+ // If win_perf_counter_frequency() or py_get_monotonic_clock() fails:
+ // silently ignore the failure and return 0.
+ t = 0;
}
return t;
}
int
-_PyTime_Init(void)
-{
- /* check that time.time(), time.monotonic() and time.perf_counter() clocks
- are working properly to not have to check for exceptions at runtime. If
- a clock works once, it cannot fail in next calls. */
- _PyTime_t t;
- if (_PyTime_GetSystemClockWithInfo(&t, NULL) < 0) {
- return -1;
- }
- if (_PyTime_GetMonotonicClockWithInfo(&t, NULL) < 0) {
- return -1;
- }
- if (_PyTime_GetPerfCounterWithInfo(&t, NULL) < 0) {
- return -1;
- }
- return 0;
-}
-
-int
_PyTime_localtime(time_t t, struct tm *tm)
{
#ifdef MS_WINDOWS
diff --git a/Python/symtable.c b/Python/symtable.c
index 0464cd898b..cce1b1b5f3 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -128,7 +128,7 @@ ste_dealloc(PySTEntryObject *ste)
Py_XDECREF(ste->ste_varnames);
Py_XDECREF(ste->ste_children);
Py_XDECREF(ste->ste_directives);
- PyObject_Del(ste);
+ PyObject_Free(ste);
}
#define OFF(x) offsetof(PySTEntryObject, x)
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 945e639ca5..720532eade 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -84,17 +84,24 @@ _PySys_GetObjectId(_Py_Identifier *key)
return sys_get_object_id(tstate, key);
}
+static PyObject *
+_PySys_GetObject(PyThreadState *tstate, const char *name)
+{
+ PyObject *sysdict = tstate->interp->sysdict;
+ if (sysdict == NULL) {
+ return NULL;
+ }
+ return _PyDict_GetItemStringWithError(sysdict, name);
+}
+
PyObject *
PySys_GetObject(const char *name)
{
PyThreadState *tstate = _PyThreadState_GET();
- PyObject *sd = tstate->interp->sysdict;
- if (sd == NULL) {
- return NULL;
- }
+
PyObject *exc_type, *exc_value, *exc_tb;
_PyErr_Fetch(tstate, &exc_type, &exc_value, &exc_tb);
- PyObject *value = _PyDict_GetItemStringWithError(sd, name);
+ PyObject *value = _PySys_GetObject(tstate, name);
/* XXX Suppress a new exception if it was raised and restore
* the old one. */
_PyErr_Restore(tstate, exc_type, exc_value, exc_tb);
@@ -1174,7 +1181,6 @@ static PyObject *
sys_setrecursionlimit_impl(PyObject *module, int new_limit)
/*[clinic end generated code: output=35e1c64754800ace input=b0f7a23393924af3]*/
{
- int mark;
PyThreadState *tstate = _PyThreadState_GET();
if (new_limit < 1) {
@@ -1192,8 +1198,7 @@ sys_setrecursionlimit_impl(PyObject *module, int new_limit)
Reject too low new limit if the current recursion depth is higher than
the new low-water mark. Otherwise it may not be possible anymore to
reset the overflowed flag to 0. */
- mark = _Py_RecursionLimitLowerWaterMark(new_limit);
- if (tstate->recursion_depth >= mark) {
+ if (tstate->recursion_depth >= new_limit) {
_PyErr_Format(tstate, PyExc_RecursionError,
"cannot set the recursion limit to %i at "
"the recursion depth %i: the limit is too low",
@@ -1902,12 +1907,12 @@ sys__debugmallocstats_impl(PyObject *module)
}
#ifdef Py_TRACE_REFS
-/* Defined in objects.c because it uses static globals if that file */
+/* Defined in objects.c because it uses static globals in that file */
extern PyObject *_Py_GetObjects(PyObject *, PyObject *);
#endif
#ifdef DYNAMIC_EXECUTION_PROFILE
-/* Defined in ceval.c because it uses static globals if that file */
+/* Defined in ceval.c because it uses static globals in that file */
extern PyObject *_Py_GetDXProfile(PyObject *, PyObject *);
#endif
@@ -2464,8 +2469,6 @@ static PyStructSequence_Field flags_fields[] = {
{"no_site", "-S"},
{"ignore_environment", "-E"},
{"verbose", "-v"},
- /* {"unbuffered", "-u"}, */
- /* {"skip_first", "-x"}, */
{"bytes_warning", "-b"},
{"quiet", "-q"},
{"hash_randomization", "-R"},
@@ -2482,21 +2485,27 @@ static PyStructSequence_Desc flags_desc = {
15
};
-static PyObject*
-make_flags(PyThreadState *tstate)
+static int
+set_flags_from_config(PyObject *flags, PyThreadState *tstate)
{
PyInterpreterState *interp = tstate->interp;
const PyPreConfig *preconfig = &interp->runtime->preconfig;
const PyConfig *config = _PyInterpreterState_GetConfig(interp);
- PyObject *seq = PyStructSequence_New(&FlagsType);
- if (seq == NULL) {
- return NULL;
- }
-
- int pos = 0;
-#define SetFlag(flag) \
- PyStructSequence_SET_ITEM(seq, pos++, PyLong_FromLong(flag))
+ // _PySys_UpdateConfig() modifies sys.flags in-place:
+ // Py_XDECREF() is needed in this case.
+ Py_ssize_t pos = 0;
+#define SetFlagObj(expr) \
+ do { \
+ PyObject *value = (expr); \
+ if (value == NULL) { \
+ return -1; \
+ } \
+ Py_XDECREF(PyStructSequence_GET_ITEM(flags, pos)); \
+ PyStructSequence_SET_ITEM(flags, pos, value); \
+ pos++; \
+ } while (0)
+#define SetFlag(expr) SetFlagObj(PyLong_FromLong(expr))
SetFlag(config->parser_debug);
SetFlag(config->inspect);
@@ -2507,23 +2516,34 @@ make_flags(PyThreadState *tstate)
SetFlag(!config->site_import);
SetFlag(!config->use_environment);
SetFlag(config->verbose);
- /* SetFlag(saw_unbuffered_flag); */
- /* SetFlag(skipfirstline); */
SetFlag(config->bytes_warning);
SetFlag(config->quiet);
SetFlag(config->use_hash_seed == 0 || config->hash_seed != 0);
SetFlag(config->isolated);
- PyStructSequence_SET_ITEM(seq, pos++, PyBool_FromLong(config->dev_mode));
+ SetFlagObj(PyBool_FromLong(config->dev_mode));
SetFlag(preconfig->utf8_mode);
+#undef SetFlagObj
#undef SetFlag
+ return 0;
+}
- if (_PyErr_Occurred(tstate)) {
- Py_DECREF(seq);
+
+static PyObject*
+make_flags(PyThreadState *tstate)
+{
+ PyObject *flags = PyStructSequence_New(&FlagsType);
+ if (flags == NULL) {
return NULL;
}
- return seq;
+
+ if (set_flags_from_config(flags, tstate) < 0) {
+ Py_DECREF(flags);
+ return NULL;
+ }
+ return flags;
}
+
PyDoc_STRVAR(version_info__doc__,
"sys.version_info\n\
\n\
@@ -2767,14 +2787,23 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
/* implementation */
SET_SYS("implementation", make_impl_info(version_info));
- /* flags */
+ // sys.flags: updated in-place later by _PySys_UpdateConfig()
if (FlagsType.tp_name == 0) {
if (PyStructSequence_InitType2(&FlagsType, &flags_desc) < 0) {
goto type_init_failed;
}
}
- /* Set flags to their default values (updated by _PySys_InitMain()) */
SET_SYS("flags", make_flags(tstate));
+ /* prevent user from creating new instances */
+ FlagsType.tp_init = NULL;
+ FlagsType.tp_new = NULL;
+ res = PyDict_DelItemString(FlagsType.tp_dict, "__new__");
+ if (res < 0) {
+ if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
+ goto err_occurred;
+ }
+ _PyErr_Clear(tstate);
+ }
#if defined(MS_WINDOWS)
/* getwindowsversion */
@@ -2810,6 +2839,11 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
}
}
+ /* adding sys.path_hooks and sys.path_importer_cache */
+ SET_SYS("meta_path", PyList_New(0));
+ SET_SYS("path_importer_cache", PyDict_New());
+ SET_SYS("path_hooks", PyList_New(0));
+
if (_PyErr_Occurred(tstate)) {
goto err_occurred;
}
@@ -2876,8 +2910,10 @@ sys_create_xoptions_dict(const PyConfig *config)
}
+// Update sys attributes for a new PyConfig configuration.
+// This function also adds attributes that _PySys_InitCore() didn't add.
int
-_PySys_InitMain(PyThreadState *tstate)
+_PySys_UpdateConfig(PyThreadState *tstate)
{
PyObject *sysdict = tstate->interp->sysdict;
const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp);
@@ -2889,15 +2925,22 @@ _PySys_InitMain(PyThreadState *tstate)
#define SET_SYS_FROM_WSTR(KEY, VALUE) \
SET_SYS(KEY, PyUnicode_FromWideChar(VALUE, -1));
- COPY_LIST("path", config->module_search_paths);
+#define COPY_WSTR(SYS_ATTR, WSTR) \
+ if (WSTR != NULL) { \
+ SET_SYS_FROM_WSTR(SYS_ATTR, WSTR); \
+ }
+
+ if (config->module_search_paths_set) {
+ COPY_LIST("path", config->module_search_paths);
+ }
- SET_SYS_FROM_WSTR("executable", config->executable);
- SET_SYS_FROM_WSTR("_base_executable", config->base_executable);
- SET_SYS_FROM_WSTR("prefix", config->prefix);
- SET_SYS_FROM_WSTR("base_prefix", config->base_prefix);
- SET_SYS_FROM_WSTR("exec_prefix", config->exec_prefix);
- SET_SYS_FROM_WSTR("base_exec_prefix", config->base_exec_prefix);
- SET_SYS_FROM_WSTR("platlibdir", config->platlibdir);
+ COPY_WSTR("executable", config->executable);
+ COPY_WSTR("_base_executable", config->base_executable);
+ COPY_WSTR("prefix", config->prefix);
+ COPY_WSTR("base_prefix", config->base_prefix);
+ COPY_WSTR("exec_prefix", config->exec_prefix);
+ COPY_WSTR("base_exec_prefix", config->base_exec_prefix);
+ COPY_WSTR("platlibdir", config->platlibdir);
if (config->pycache_prefix != NULL) {
SET_SYS_FROM_WSTR("pycache_prefix", config->pycache_prefix);
@@ -2911,31 +2954,20 @@ _PySys_InitMain(PyThreadState *tstate)
SET_SYS("_xoptions", sys_create_xoptions_dict(config));
-#undef COPY_LIST
#undef SET_SYS_FROM_WSTR
+#undef COPY_LIST
+#undef COPY_WSTR
-
- /* Set flags to their final values */
- SET_SYS("flags", make_flags(tstate));
- /* prevent user from creating new instances */
- FlagsType.tp_init = NULL;
- FlagsType.tp_new = NULL;
- res = PyDict_DelItemString(FlagsType.tp_dict, "__new__");
- if (res < 0) {
- if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
- return res;
- }
- _PyErr_Clear(tstate);
+ // sys.flags
+ PyObject *flags = _PySys_GetObject(tstate, "flags"); // borrowed ref
+ if (flags == NULL) {
+ return -1;
}
-
- SET_SYS("dont_write_bytecode", PyBool_FromLong(!config->write_bytecode));
-
- if (get_warnoptions(tstate) == NULL) {
+ if (set_flags_from_config(flags, tstate) < 0) {
return -1;
}
- if (get_xoptions(tstate) == NULL)
- return -1;
+ SET_SYS("dont_write_bytecode", PyBool_FromLong(!config->write_bytecode));
if (_PyErr_Occurred(tstate)) {
goto err_occurred;
@@ -2977,8 +3009,8 @@ error:
}
-/* Create sys module without all attributes: _PySys_InitMain() should be called
- later to add remaining attributes. */
+/* Create sys module without all attributes.
+ _PySys_UpdateConfig() should be called later to add remaining attributes. */
PyStatus
_PySys_Create(PyThreadState *tstate, PyObject **sysmod_p)
{
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index e6910b3083..ec7d737518 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -62,6 +62,10 @@
# define THREAD_STACK_SIZE 0x800000
# endif
#endif
+#if defined(__VXWORKS__) && defined(THREAD_STACK_SIZE) && THREAD_STACK_SIZE == 0
+#undef THREAD_STACK_SIZE
+#define THREAD_STACK_SIZE 0x100000
+#endif
/* for safety, ensure a viable minimum stacksize */
#define THREAD_STACK_MIN 0x8000 /* 32 KiB */
#else /* !_POSIX_THREAD_ATTR_STACKSIZE */
diff --git a/Python/traceback.c b/Python/traceback.c
index 99b63af11f..b82cfd3665 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -419,12 +419,12 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
Py_DECREF(io);
Py_DECREF(binary);
- PyMem_FREE(found_encoding);
+ PyMem_Free(found_encoding);
return 0;
}
fob = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "Os", binary, encoding);
Py_DECREF(io);
- PyMem_FREE(found_encoding);
+ PyMem_Free(found_encoding);
if (fob == NULL) {
PyErr_Clear();
@@ -622,7 +622,8 @@ PyTraceBack_Print(PyObject *v, PyObject *f)
return err;
}
-/* Reverse a string. For example, "abcd" becomes "dcba".
+/* Format an integer in range [0; 0xffffffff] to decimal and write it
+ into the file fd.
This function is signal safe. */
diff --git a/README.rst b/README.rst
index 33ccfc01d9..51d60d5da6 100644
--- a/README.rst
+++ b/README.rst
@@ -1,4 +1,4 @@
-This is Python version 3.10.0 alpha 1
+This is Python version 3.10.0 alpha 3
=====================================
.. image:: https://travis-ci.com/python/cpython.svg?branch=master
diff --git a/Tools/c-analyzer/c_analyzer/__main__.py b/Tools/c-analyzer/c_analyzer/__main__.py
index 4cff1d4efb..24fc6cd182 100644
--- a/Tools/c-analyzer/c_analyzer/__main__.py
+++ b/Tools/c-analyzer/c_analyzer/__main__.py
@@ -5,6 +5,7 @@ import os.path
import re
import sys
+from c_common import fsutil
from c_common.logging import VERBOSITY, Printer
from c_common.scriptutil import (
add_verbosity_cli,
@@ -262,7 +263,7 @@ FORMATS = {
def add_output_cli(parser, *, default='summary'):
parser.add_argument('--format', dest='fmt', default=default, choices=tuple(FORMATS))
- def process_args(args):
+ def process_args(args, *, argv=None):
pass
return process_args
@@ -279,7 +280,7 @@ def _cli_check(parser, checks=None, **kwargs):
process_checks = add_checks_cli(parser)
elif len(checks) == 1 and type(checks) is not dict and re.match(r'^<.*>$', checks[0]):
check = checks[0][1:-1]
- def process_checks(args):
+ def process_checks(args, *, argv=None):
args.checks = [check]
else:
process_checks = add_checks_cli(parser, checks=checks)
@@ -298,9 +299,9 @@ def cmd_check(filenames, *,
checks=None,
ignored=None,
fmt=None,
- relroot=None,
failfast=False,
iter_filenames=None,
+ relroot=fsutil.USE_CWD,
track_progress=None,
verbosity=VERBOSITY,
_analyze=_analyze,
@@ -317,14 +318,14 @@ def cmd_check(filenames, *,
(handle_failure, handle_after, div
) = _get_check_handlers(fmt, printer, verbosity)
- filenames = filter_filenames(filenames, iter_filenames)
+ filenames, relroot = fsutil.fix_filenames(filenames, relroot=relroot)
+ filenames = filter_filenames(filenames, iter_filenames, relroot)
if track_progress:
filenames = track_progress(filenames)
logger.info('analyzing files...')
analyzed = _analyze(filenames, **kwargs)
- if relroot:
- analyzed.fix_filenames(relroot)
+ analyzed.fix_filenames(relroot, normalize=False)
decls = filter_forward(analyzed, markpublic=True)
logger.info('checking analysis results...')
@@ -374,6 +375,7 @@ def _cli_analyze(parser, **kwargs):
def cmd_analyze(filenames, *,
fmt=None,
iter_filenames=None,
+ relroot=fsutil.USE_CWD,
track_progress=None,
verbosity=None,
_analyze=_analyze,
@@ -387,12 +389,14 @@ def cmd_analyze(filenames, *,
except KeyError:
raise ValueError(f'unsupported fmt {fmt!r}')
- filenames = filter_filenames(filenames, iter_filenames)
+ filenames, relroot = fsutil.fix_filenames(filenames, relroot=relroot)
+ filenames = filter_filenames(filenames, iter_filenames, relroot)
if track_progress:
filenames = track_progress(filenames)
logger.info('analyzing files...')
analyzed = _analyze(filenames, **kwargs)
+ analyzed.fix_filenames(relroot, normalize=False)
decls = filter_forward(analyzed, markpublic=True)
for line in do_fmt(decls):
@@ -424,9 +428,9 @@ def _cli_data(parser, filenames=None, known=None):
if known is None:
sub.add_argument('--known', required=True)
- def process_args(args):
+ def process_args(args, *, argv):
if args.datacmd == 'dump':
- process_progress(args)
+ process_progress(args, argv)
return process_args
@@ -434,7 +438,7 @@ def cmd_data(datacmd, filenames, known=None, *,
_analyze=_analyze,
formats=FORMATS,
extracolumns=None,
- relroot=None,
+ relroot=fsutil.USE_CWD,
track_progress=None,
**kwargs
):
@@ -447,9 +451,11 @@ def cmd_data(datacmd, filenames, known=None, *,
for line in do_fmt(known):
print(line)
elif datacmd == 'dump':
+ filenames, relroot = fsutil.fix_filenames(filenames, relroot=relroot)
if track_progress:
filenames = track_progress(filenames)
analyzed = _analyze(filenames, **kwargs)
+ analyzed.fix_filenames(relroot, normalize=False)
if known is None or usestdout:
outfile = io.StringIO()
_datafiles.write_known(analyzed, outfile, extracolumns,
@@ -509,6 +515,7 @@ def parse_args(argv=sys.argv[1:], prog=sys.argv[0], *, subset=None):
verbosity, traceback_cm = process_args_by_key(
args,
+ argv,
processors[cmd],
['verbosity', 'traceback_cm'],
)
diff --git a/Tools/c-analyzer/c_analyzer/datafiles.py b/Tools/c-analyzer/c_analyzer/datafiles.py
index d37a4eefe3..d5db3bd3ed 100644
--- a/Tools/c-analyzer/c_analyzer/datafiles.py
+++ b/Tools/c-analyzer/c_analyzer/datafiles.py
@@ -1,3 +1,6 @@
+import os.path
+
+from c_common import fsutil
import c_common.tables as _tables
import c_parser.info as _info
import c_parser.match as _match
@@ -13,31 +16,10 @@ EXTRA_COLUMNS = [
]
-def analyze_known(known, *,
- analyze_resolved=None,
- handle_unresolved=True,
- ):
- knowntypes = knowntypespecs = {}
- collated = _match.group_by_kinds(known)
- types = {decl: None for decl in collated['type']}
- typespecs = _analyze.get_typespecs(types)
- def analyze_decl(decl):
- return _analyze.analyze_decl(
- decl,
- typespecs,
- knowntypespecs,
- types,
- knowntypes,
- analyze_resolved=analyze_resolved,
- )
- _analyze.analyze_type_decls(types, analyze_decl, handle_unresolved)
- return types, typespecs
-
-
def get_known(known, extracolumns=None, *,
analyze_resolved=None,
handle_unresolved=True,
- relroot=None,
+ relroot=fsutil.USE_CWD,
):
if isinstance(known, str):
known = read_known(known, extracolumns, relroot)
@@ -48,7 +30,7 @@ def get_known(known, extracolumns=None, *,
)
-def read_known(infile, extracolumns=None, relroot=None):
+def read_known(infile, extracolumns=None, relroot=fsutil.USE_CWD):
extracolumns = EXTRA_COLUMNS + (
list(extracolumns) if extracolumns else []
)
@@ -58,8 +40,29 @@ def read_known(infile, extracolumns=None, relroot=None):
return known
+def analyze_known(known, *,
+ analyze_resolved=None,
+ handle_unresolved=True,
+ ):
+ knowntypes = knowntypespecs = {}
+ collated = _match.group_by_kinds(known)
+ types = {decl: None for decl in collated['type']}
+ typespecs = _analyze.get_typespecs(types)
+ def analyze_decl(decl):
+ return _analyze.analyze_decl(
+ decl,
+ typespecs,
+ knowntypespecs,
+ types,
+ knowntypes,
+ analyze_resolved=analyze_resolved,
+ )
+ _analyze.analyze_type_decls(types, analyze_decl, handle_unresolved)
+ return types, typespecs
+
+
def write_known(rows, outfile, extracolumns=None, *,
- relroot=None,
+ relroot=fsutil.USE_CWD,
backup=True,
):
extracolumns = EXTRA_COLUMNS + (
@@ -86,22 +89,34 @@ IGNORED_COLUMNS = [
IGNORED_HEADER = '\t'.join(IGNORED_COLUMNS)
-def read_ignored(infile):
- return dict(_iter_ignored(infile))
+def read_ignored(infile, relroot=fsutil.USE_CWD):
+ return dict(_iter_ignored(infile, relroot))
-def _iter_ignored(infile):
+def _iter_ignored(infile, relroot):
+ if relroot and relroot is not fsutil.USE_CWD:
+ relroot = os.path.abspath(relroot)
+ bogus = {_tables.EMPTY, _tables.UNKNOWN}
for row in _tables.read_table(infile, IGNORED_HEADER, sep='\t'):
*varidinfo, reason = row
+ if _tables.EMPTY in varidinfo or _tables.UNKNOWN in varidinfo:
+ varidinfo = tuple(None if v in bogus else v
+ for v in varidinfo)
+ if reason in bogus:
+ reason = None
varid = _info.DeclID.from_row(varidinfo)
+ varid = varid.fix_filename(relroot, formatted=False, fixroot=False)
yield varid, reason
-def write_ignored(variables, outfile):
+def write_ignored(variables, outfile, relroot=fsutil.USE_CWD):
raise NotImplementedError
+ if relroot and relroot is not fsutil.USE_CWD:
+ relroot = os.path.abspath(relroot)
reason = '???'
#if not isinstance(varid, DeclID):
# varid = getattr(varid, 'parsed', varid).id
+ decls = (d.fix_filename(relroot, fixroot=False) for d in decls)
_tables.write_table(
outfile,
IGNORED_HEADER,
diff --git a/Tools/c-analyzer/c_analyzer/info.py b/Tools/c-analyzer/c_analyzer/info.py
index be9281502d..b75918e5e7 100644
--- a/Tools/c-analyzer/c_analyzer/info.py
+++ b/Tools/c-analyzer/c_analyzer/info.py
@@ -1,5 +1,7 @@
from collections import namedtuple
+import os.path
+from c_common import fsutil
from c_common.clsutil import classonly
import c_common.misc as _misc
from c_parser.info import (
@@ -223,8 +225,9 @@ class Analyzed:
else:
return UNKNOWN not in self.typedecl
- def fix_filename(self, relroot):
- self.item.fix_filename(relroot)
+ def fix_filename(self, relroot=fsutil.USE_CWD, **kwargs):
+ self.item.fix_filename(relroot, **kwargs)
+ return self
def as_rowdata(self, columns=None):
# XXX finsih!
@@ -309,9 +312,11 @@ class Analysis:
else:
return self._analyzed[key]
- def fix_filenames(self, relroot):
+ def fix_filenames(self, relroot=fsutil.USE_CWD, **kwargs):
+ if relroot and relroot is not fsutil.USE_CWD:
+ relroot = os.path.abspath(relroot)
for item in self._analyzed:
- item.fix_filename(relroot)
+ item.fix_filename(relroot, fixroot=False, **kwargs)
def _add_result(self, info, resolved):
analyzed = type(self).build_item(info, resolved)
diff --git a/Tools/c-analyzer/c_common/fsutil.py b/Tools/c-analyzer/c_common/fsutil.py
index 56023f3352..120a140288 100644
--- a/Tools/c-analyzer/c_common/fsutil.py
+++ b/Tools/c-analyzer/c_common/fsutil.py
@@ -8,6 +8,9 @@ import stat
from .iterutil import iter_many
+USE_CWD = object()
+
+
C_SOURCE_SUFFIXES = ('.c', '.h')
@@ -30,6 +33,78 @@ def create_backup(old, backup=None):
##################################
+# filenames
+
+def fix_filename(filename, relroot=USE_CWD, *,
+ fixroot=True,
+ _badprefix=f'..{os.path.sep}',
+ ):
+ """Return a normalized, absolute-path copy of the given filename."""
+ if not relroot or relroot is USE_CWD:
+ return os.path.abspath(filename)
+ if fixroot:
+ relroot = os.path.abspath(relroot)
+ return _fix_filename(filename, relroot)
+
+
+def _fix_filename(filename, relroot, *,
+ _badprefix=f'..{os.path.sep}',
+ ):
+ orig = filename
+
+ # First we normalize.
+ filename = os.path.normpath(filename)
+ if filename.startswith(_badprefix):
+ raise ValueError(f'bad filename {orig!r} (resolves beyond relative root')
+
+ # Now make sure it is absolute (relative to relroot).
+ if not os.path.isabs(filename):
+ filename = os.path.join(relroot, filename)
+ else:
+ relpath = os.path.relpath(filename, relroot)
+ if os.path.join(relroot, relpath) != filename:
+ raise ValueError(f'expected {relroot!r} as lroot, got {orig!r}')
+
+ return filename
+
+
+def fix_filenames(filenames, relroot=USE_CWD):
+ if not relroot or relroot is USE_CWD:
+ filenames = (os.path.abspath(v) for v in filenames)
+ else:
+ relroot = os.path.abspath(relroot)
+ filenames = (_fix_filename(v, relroot) for v in filenames)
+ return filenames, relroot
+
+
+def format_filename(filename, relroot=USE_CWD, *,
+ fixroot=True,
+ normalize=True,
+ _badprefix=f'..{os.path.sep}',
+ ):
+ """Return a consistent relative-path representation of the filename."""
+ orig = filename
+ if normalize:
+ filename = os.path.normpath(filename)
+ if relroot is None:
+ # Otherwise leave it as-is.
+ return filename
+ elif relroot is USE_CWD:
+ # Make it relative to CWD.
+ filename = os.path.relpath(filename)
+ else:
+ # Make it relative to "relroot".
+ if fixroot:
+ relroot = os.path.abspath(relroot)
+ elif not relroot:
+ raise ValueError('missing relroot')
+ filename = os.path.relpath(filename, relroot)
+ if filename.startswith(_badprefix):
+ raise ValueError(f'bad filename {orig!r} (resolves beyond relative root')
+ return filename
+
+
+##################################
# find files
def match_glob(filename, pattern):
@@ -54,34 +129,29 @@ def match_glob(filename, pattern):
return fnmatch.fnmatch(filename, pattern.replace('**/', '', 1))
-def iter_filenames(filenames, *,
- start=None,
- include=None,
- exclude=None,
- ):
+def process_filenames(filenames, *,
+ start=None,
+ include=None,
+ exclude=None,
+ relroot=USE_CWD,
+ ):
+ if relroot and relroot is not USE_CWD:
+ relroot = os.path.abspath(relroot)
+ if start:
+ start = fix_filename(start, relroot, fixroot=False)
+ if include:
+ include = set(fix_filename(v, relroot, fixroot=False)
+ for v in include)
+ if exclude:
+ exclude = set(fix_filename(v, relroot, fixroot=False)
+ for v in exclude)
+
onempty = Exception('no filenames provided')
for filename, solo in iter_many(filenames, onempty):
+ filename = fix_filename(filename, relroot, fixroot=False)
+ relfile = format_filename(filename, relroot, fixroot=False, normalize=False)
check, start = _get_check(filename, start, include, exclude)
- yield filename, check, solo
-# filenames = iter(filenames or ())
-# try:
-# first = next(filenames)
-# except StopIteration:
-# raise Exception('no filenames provided')
-# try:
-# second = next(filenames)
-# except StopIteration:
-# check, _ = _get_check(first, start, include, exclude)
-# yield first, check, False
-# return
-#
-# check, start = _get_check(first, start, include, exclude)
-# yield first, check, True
-# check, start = _get_check(second, start, include, exclude)
-# yield second, check, True
-# for filename in filenames:
-# check, start = _get_check(filename, start, include, exclude)
-# yield filename, check, True
+ yield filename, relfile, check, solo
def expand_filenames(filenames):
diff --git a/Tools/c-analyzer/c_common/scriptutil.py b/Tools/c-analyzer/c_common/scriptutil.py
index 222059015d..ce69af2b6b 100644
--- a/Tools/c-analyzer/c_common/scriptutil.py
+++ b/Tools/c-analyzer/c_common/scriptutil.py
@@ -192,7 +192,7 @@ def add_verbosity_cli(parser):
parser.add_argument('-q', '--quiet', action='count', default=0)
parser.add_argument('-v', '--verbose', action='count', default=0)
- def process_args(args):
+ def process_args(args, *, argv=None):
ns = vars(args)
key = 'verbosity'
if key in ns:
@@ -208,7 +208,7 @@ def add_traceback_cli(parser):
parser.add_argument('--no-traceback', '--no-tb', dest='traceback',
action='store_const', const=False)
- def process_args(args):
+ def process_args(args, *, argv=None):
ns = vars(args)
key = 'traceback_cm'
if key in ns:
@@ -262,7 +262,7 @@ def add_sepval_cli(parser, opt, dest, choices, *, sep=',', **kwargs):
#kwargs.setdefault('metavar', opt.upper())
parser.add_argument(opt, dest=dest, action='append', **kwargs)
- def process_args(args):
+ def process_args(args, *, argv=None):
ns = vars(args)
# XXX Use normalize_selection()?
@@ -293,7 +293,7 @@ def add_file_filtering_cli(parser, *, excluded=None):
excluded = tuple(excluded or ())
- def process_args(args):
+ def process_args(args, *, argv=None):
ns = vars(args)
key = 'iter_filenames'
if key in ns:
@@ -307,7 +307,9 @@ def add_file_filtering_cli(parser, *, excluded=None):
exclude=tuple(_parse_files(_exclude)),
# We use the default for "show_header"
)
- ns[key] = (lambda files: fsutil.iter_filenames(files, **kwargs))
+ def process_filenames(filenames, relroot=None):
+ return fsutil.process_filenames(filenames, relroot=relroot, **kwargs)
+ ns[key] = process_filenames
return process_args
@@ -321,7 +323,7 @@ def add_progress_cli(parser, *, threshold=VERBOSITY, **kwargs):
parser.add_argument('--no-progress', dest='track_progress', action='store_false')
parser.set_defaults(track_progress=True)
- def process_args(args):
+ def process_args(args, *, argv=None):
if args.track_progress:
ns = vars(args)
verbosity = ns.get('verbosity', VERBOSITY)
@@ -337,7 +339,7 @@ def add_failure_filtering_cli(parser, pool, *, default=False):
metavar=f'"{{all|{"|".join(sorted(pool))}}},..."')
parser.add_argument('--no-fail', dest='fail', action='store_const', const=())
- def process_args(args):
+ def process_args(args, *, argv=None):
ns = vars(args)
fail = ns.pop('fail')
@@ -369,7 +371,7 @@ def add_failure_filtering_cli(parser, pool, *, default=False):
def add_kind_filtering_cli(parser, *, default=None):
parser.add_argument('--kinds', action='append')
- def process_args(args):
+ def process_args(args, *, argv=None):
ns = vars(args)
kinds = []
@@ -484,18 +486,18 @@ def _flatten_processors(processors):
yield from _flatten_processors(proc)
-def process_args(args, processors, *, keys=None):
+def process_args(args, argv, processors, *, keys=None):
processors = _flatten_processors(processors)
ns = vars(args)
extracted = {}
if keys is None:
for process_args in processors:
- for key in process_args(args):
+ for key in process_args(args, argv=argv):
extracted[key] = ns.pop(key)
else:
remainder = set(keys)
for process_args in processors:
- hanging = process_args(args)
+ hanging = process_args(args, argv=argv)
if isinstance(hanging, str):
hanging = [hanging]
for key in hanging or ():
@@ -508,8 +510,8 @@ def process_args(args, processors, *, keys=None):
return extracted
-def process_args_by_key(args, processors, keys):
- extracted = process_args(args, processors, keys=keys)
+def process_args_by_key(args, argv, processors, keys):
+ extracted = process_args(args, argv, processors, keys=keys)
return [extracted[key] for key in keys]
@@ -529,42 +531,46 @@ def set_command(name, add_cli):
##################################
# main() helpers
-def filter_filenames(filenames, iter_filenames=None):
- for filename, check, _ in _iter_filenames(filenames, iter_filenames):
+def filter_filenames(filenames, process_filenames=None, relroot=fsutil.USE_CWD):
+ # We expect each filename to be a normalized, absolute path.
+ for filename, _, check, _ in _iter_filenames(filenames, process_filenames, relroot):
if (reason := check()):
logger.debug(f'{filename}: {reason}')
continue
yield filename
-def main_for_filenames(filenames, iter_filenames=None):
- for filename, check, show in _iter_filenames(filenames, iter_filenames):
+def main_for_filenames(filenames, process_filenames=None, relroot=fsutil.USE_CWD):
+ filenames, relroot = fsutil.fix_filenames(filenames, relroot=relroot)
+ for filename, relfile, check, show in _iter_filenames(filenames, process_filenames, relroot):
if show:
print()
+ print(relfile)
print('-------------------------------------------')
- print(filename)
if (reason := check()):
print(reason)
continue
- yield filename
+ yield filename, relfile
-def _iter_filenames(filenames, iter_files):
- if iter_files is None:
- iter_files = fsutil.iter_filenames
- yield from iter_files(filenames)
+def _iter_filenames(filenames, process, relroot):
+ if process is None:
+ yield from fsutil.process_filenames(filenames, relroot=relroot)
return
onempty = Exception('no filenames provided')
- items = iter_files(filenames)
+ items = process(filenames, relroot=relroot)
items, peeked = iterutil.peek_and_iter(items)
if not items:
raise onempty
if isinstance(peeked, str):
+ if relroot and relroot is not fsutil.USE_CWD:
+ relroot = os.path.abspath(relroot)
check = (lambda: True)
for filename, ismany in iterutil.iter_many(items, onempty):
- yield filename, check, ismany
- elif len(peeked) == 3:
+ relfile = fsutil.format_filename(filename, relroot, fixroot=False)
+ yield filename, relfile, check, ismany
+ elif len(peeked) == 4:
yield from items
else:
raise NotImplementedError
diff --git a/Tools/c-analyzer/c_common/tables.py b/Tools/c-analyzer/c_common/tables.py
index 70a230a90b..85b5019257 100644
--- a/Tools/c-analyzer/c_common/tables.py
+++ b/Tools/c-analyzer/c_common/tables.py
@@ -1,4 +1,6 @@
import csv
+import re
+import textwrap
from . import NOT_SET, strutil, fsutil
@@ -26,13 +28,14 @@ def fix_row(row, **markers):
unknown = parse_markers(markers.pop('unknown', ('???',)))
row = (val if val else None for val in row)
if not empty:
- if not unknown:
- return row
- return (UNKNOWN if val in unknown else val for val in row)
+ if unknown:
+ row = (UNKNOWN if val in unknown else val for val in row)
elif not unknown:
- return (EMPTY if val in empty else val for val in row)
- return (EMPTY if val in empty else (UNKNOWN if val in unknown else val)
- for val in row)
+ row = (EMPTY if val in empty else val for val in row)
+ else:
+ row = (EMPTY if val in empty else (UNKNOWN if val in unknown else val)
+ for val in row)
+ return tuple(row)
def _fix_read_default(row):
@@ -211,3 +214,177 @@ def _normalize_table_file_props(header, sep):
else:
sep = None
return header, sep
+
+
+##################################
+# stdout tables
+
+WIDTH = 20
+
+
+def resolve_columns(specs):
+ if isinstance(specs, str):
+ specs = specs.replace(',', ' ').strip().split()
+ return _resolve_colspecs(specs)
+
+
+def build_table(specs, *, sep=' ', defaultwidth=None):
+ columns = resolve_columns(specs)
+ return _build_table(columns, sep=sep, defaultwidth=defaultwidth)
+
+
+_COLSPEC_RE = re.compile(textwrap.dedent(r'''
+ ^
+ (?:
+ [[]
+ (
+ (?: [^\s\]] [^\]]* )?
+ [^\s\]]
+ ) # <label>
+ []]
+ )?
+ ( \w+ ) # <field>
+ (?:
+ (?:
+ :
+ ( [<^>] ) # <align>
+ ( \d+ ) # <width1>
+ )
+ |
+ (?:
+ (?:
+ :
+ ( \d+ ) # <width2>
+ )?
+ (?:
+ :
+ ( .*? ) # <fmt>
+ )?
+ )
+ )?
+ $
+'''), re.VERBOSE)
+
+
+def _parse_fmt(fmt):
+ if fmt.startswith(tuple('<^>')):
+ align = fmt[0]
+ width = fmt[1:]
+ if width.isdigit():
+ return int(width), align
+ return None, None
+
+
+def _parse_colspec(raw):
+ m = _COLSPEC_RE.match(raw)
+ if not m:
+ return None
+ label, field, align, width1, width2, fmt = m.groups()
+ if not label:
+ label = field
+ if width1:
+ width = None
+ fmt = f'{align}{width1}'
+ elif width2:
+ width = int(width2)
+ if fmt:
+ _width, _ = _parse_fmt(fmt)
+ if _width == width:
+ width = None
+ else:
+ width = None
+ return field, label, width, fmt
+
+
+def _normalize_colspec(spec):
+ if len(spec) == 1:
+ raw, = spec
+ return _resolve_column(raw)
+
+ if len(spec) == 4:
+ label, field, width, fmt = spec
+ if width:
+ fmt = f'{width}:{fmt}' if fmt else width
+ elif len(raw) == 3:
+ label, field, fmt = spec
+ if not field:
+ label, field = None, label
+ elif not isinstance(field, str) or not field.isidentifier():
+ fmt = f'{field}:{fmt}' if fmt else field
+ label, field = None, label
+ elif len(raw) == 2:
+ label = None
+ field, fmt = raw
+ if not field:
+ field, fmt = fmt, None
+ elif not field.isidentifier() or fmt.isidentifier():
+ label, field = field, fmt
+ else:
+ raise NotImplementedError
+
+ fmt = f':{fmt}' if fmt else ''
+ if label:
+ return _parse_colspec(f'[{label}]{field}{fmt}')
+ else:
+ return _parse_colspec(f'{field}{fmt}')
+
+
+def _resolve_colspec(raw):
+ if isinstance(raw, str):
+ spec = _parse_colspec(raw)
+ else:
+ spec = _normalize_colspec(raw)
+ if spec is None:
+ raise ValueError(f'unsupported column spec {raw!r}')
+ return spec
+
+
+def _resolve_colspecs(columns):
+ parsed = []
+ for raw in columns:
+ column = _resolve_colspec(raw)
+ parsed.append(column)
+ return parsed
+
+
+def _resolve_width(spec, defaultwidth):
+ _, label, width, fmt = spec
+ if width:
+ if not isinstance(width, int):
+ raise NotImplementedError
+ return width
+ elif width and fmt:
+ width, _ = _parse_fmt(fmt)
+ if width:
+ return width
+
+ if not defaultwidth:
+ return WIDTH
+ elif not hasattr(defaultwidth, 'get'):
+ return defaultwidth or WIDTH
+
+ defaultwidths = defaultwidth
+ defaultwidth = defaultwidths.get(None) or WIDTH
+ return defaultwidths.get(label) or defaultwidth
+
+
+def _build_table(columns, *, sep=' ', defaultwidth=None):
+ header = []
+ div = []
+ rowfmt = []
+ for spec in columns:
+ label, field, _, colfmt = spec
+ width = _resolve_width(spec, defaultwidth)
+ if colfmt:
+ colfmt = f':{colfmt}'
+ else:
+ colfmt = f':{width}'
+
+ header.append(f' {{:^{width}}} '.format(label))
+ div.append('-' * (width + 2))
+ rowfmt.append(f' {{{field}{colfmt}}} ')
+ return (
+ sep.join(header),
+ sep.join(div),
+ sep.join(rowfmt),
+ )
diff --git a/Tools/c-analyzer/c_parser/__main__.py b/Tools/c-analyzer/c_parser/__main__.py
index 1752a703f6..78f47a1808 100644
--- a/Tools/c-analyzer/c_parser/__main__.py
+++ b/Tools/c-analyzer/c_parser/__main__.py
@@ -2,6 +2,7 @@ import logging
import os.path
import sys
+from c_common import fsutil
from c_common.scriptutil import (
CLIArgSpec as Arg,
add_verbosity_cli,
@@ -64,8 +65,9 @@ def fmt_raw(filename, item, *, showfwd=None):
def fmt_summary(filename, item, *, showfwd=None):
- if item.filename and item.filename != os.path.join('.', filename):
+ if item.filename != filename:
yield f'> {item.filename}'
+
if showfwd is None:
LINE = ' {lno:>5} {kind:10} {funcname:40} {fwd:1} {name:40} {data}'
else:
@@ -147,7 +149,7 @@ def add_output_cli(parser):
parser.add_argument('--showfwd', action='store_true', default=None)
parser.add_argument('--no-showfwd', dest='showfwd', action='store_false', default=None)
- def process_args(args):
+ def process_args(args, *, argv=None):
pass
return process_args
@@ -172,6 +174,7 @@ def cmd_parse(filenames, *,
fmt='summary',
showfwd=None,
iter_filenames=None,
+ relroot=None,
**kwargs
):
if 'get_file_preprocessor' not in kwargs:
@@ -180,9 +183,10 @@ def cmd_parse(filenames, *,
do_fmt = FORMATS[fmt]
except KeyError:
raise ValueError(f'unsupported fmt {fmt!r}')
- for filename in main_for_filenames(filenames, iter_filenames):
+ for filename, relfile in main_for_filenames(filenames, iter_filenames, relroot):
for item in _iter_parsed(filename, **kwargs):
- for line in do_fmt(filename, item, showfwd=showfwd):
+ item = item.fix_filename(relroot, fixroot=False, normalize=False)
+ for line in do_fmt(relfile, item, showfwd=showfwd):
print(line)
@@ -239,6 +243,7 @@ def parse_args(argv=sys.argv[1:], prog=sys.argv[0], *, subset='parse'):
verbosity, traceback_cm = process_args_by_key(
args,
+ argv,
processors[cmd],
['verbosity', 'traceback_cm'],
)
diff --git a/Tools/c-analyzer/c_parser/datafiles.py b/Tools/c-analyzer/c_parser/datafiles.py
index cdd69b1f9b..f053056619 100644
--- a/Tools/c-analyzer/c_parser/datafiles.py
+++ b/Tools/c-analyzer/c_parser/datafiles.py
@@ -1,5 +1,6 @@
import os.path
+from c_common import fsutil
import c_common.tables as _tables
import c_parser.info as _info
@@ -81,21 +82,27 @@ def _get_format_handlers(group, fmt):
# tsv
-def iter_decls_tsv(infile, extracolumns=None, relroot=None):
- for info, extra in _iter_decls_tsv(infile, extracolumns, relroot):
+def iter_decls_tsv(infile, extracolumns=None, relroot=fsutil.USE_CWD):
+ if relroot and relroot is not fsutil.USE_CWD:
+ relroot = os.path.abspath(relroot)
+ for info, extra in _iter_decls_tsv(infile, extracolumns):
decl = _info.Declaration.from_row(info)
+ decl = decl.fix_filename(relroot, formatted=False, fixroot=False)
yield decl, extra
def write_decls_tsv(decls, outfile, extracolumns=None, *,
- relroot=None,
+ relroot=fsutil.USE_CWD,
**kwargs
):
+ if relroot and relroot is not fsutil.USE_CWD:
+ relroot = os.path.abspath(relroot)
+ decls = (d.fix_filename(relroot, fixroot=False) for d in decls)
# XXX Move the row rendering here.
- _write_decls_tsv(decls, outfile, extracolumns, relroot, kwargs)
+ _write_decls_tsv(decls, outfile, extracolumns, kwargs)
-def _iter_decls_tsv(infile, extracolumns=None, relroot=None):
+def _iter_decls_tsv(infile, extracolumns=None):
columns = _get_columns('decls', extracolumns)
for row in _tables.read_table(infile, columns, sep='\t'):
if extracolumns:
@@ -104,15 +111,13 @@ def _iter_decls_tsv(infile, extracolumns=None, relroot=None):
else:
declinfo = row
extra = None
- if relroot:
- # XXX Use something like tables.fix_row() here.
- declinfo = [None if v == '-' else v
- for v in declinfo]
- declinfo[0] = os.path.join(relroot, declinfo[0])
+ # XXX Use something like tables.fix_row() here.
+ declinfo = [None if v == '-' else v
+ for v in declinfo]
yield declinfo, extra
-def _write_decls_tsv(decls, outfile, extracolumns, relroot,kwargs):
+def _write_decls_tsv(decls, outfile, extracolumns, kwargs):
columns = _get_columns('decls', extracolumns)
if extracolumns:
def render_decl(decl):
@@ -121,7 +126,7 @@ def _write_decls_tsv(decls, outfile, extracolumns, relroot,kwargs):
else:
extra = ()
extra += ('???',) * (len(extraColumns) - len(extra))
- *row, declaration = _render_known_row(decl, relroot)
+ *row, declaration = _render_known_row(decl)
row += extra + (declaration,)
return row
else:
@@ -129,13 +134,13 @@ def _write_decls_tsv(decls, outfile, extracolumns, relroot,kwargs):
_tables.write_table(
outfile,
header='\t'.join(columns),
- rows=(render_decl(d, relroot) for d in decls),
+ rows=(render_decl(d) for d in decls),
sep='\t',
**kwargs
)
-def _render_known_decl(decl, relroot, *,
+def _render_known_decl(decl, *,
# These match BASE_COLUMNS + END_COLUMNS[group].
_columns = 'filename parent name kind data'.split(),
):
@@ -143,8 +148,6 @@ def _render_known_decl(decl, relroot, *,
# e.g. Analyzed
decl = decl.decl
rowdata = decl.render_rowdata(_columns)
- if relroot:
- rowdata['filename'] = os.path.relpath(rowdata['filename'], relroot)
return [rowdata[c] or '-' for c in _columns]
# XXX
#return _tables.fix_row(rowdata[c] for c in columns)
diff --git a/Tools/c-analyzer/c_parser/info.py b/Tools/c-analyzer/c_parser/info.py
index 798a45d2e0..98ff511cfe 100644
--- a/Tools/c-analyzer/c_parser/info.py
+++ b/Tools/c-analyzer/c_parser/info.py
@@ -3,6 +3,7 @@ import enum
import os.path
import re
+from c_common import fsutil
from c_common.clsutil import classonly
import c_common.misc as _misc
import c_common.strutil as _strutil
@@ -148,6 +149,16 @@ def get_kind_group(item):
#############################
# low-level
+def _fix_filename(filename, relroot, *,
+ formatted=True,
+ **kwargs):
+ if formatted:
+ fix = fsutil.format_filename
+ else:
+ fix = fsutil.fix_filename
+ return fix(filename, relroot=relroot, **kwargs)
+
+
class FileInfo(namedtuple('FileInfo', 'filename lno')):
@classmethod
def from_raw(cls, raw):
@@ -165,8 +176,10 @@ class FileInfo(namedtuple('FileInfo', 'filename lno')):
def __str__(self):
return self.filename
- def fix_filename(self, relroot):
- filename = os.path.relpath(self.filename, relroot)
+ def fix_filename(self, relroot=fsutil.USE_CWD, **kwargs):
+ filename = _fix_filename(self.filename, relroot, **kwargs)
+ if filename == self.filename:
+ return self
return self._replace(filename=filename)
@@ -194,6 +207,16 @@ class DeclID(namedtuple('DeclID', 'filename funcname name')):
row = _tables.fix_row(row, **markers)
return cls(*row)
+ # We have to provde _make() becaose we implemented __new__().
+
+ @classmethod
+ def _make(cls, iterable):
+ try:
+ return cls(*iterable)
+ except Exception:
+ super()._make(iterable)
+ raise # re-raise
+
def __new__(cls, filename, funcname, name):
self = super().__new__(
cls,
@@ -221,6 +244,12 @@ class DeclID(namedtuple('DeclID', 'filename funcname name')):
return NotImplemented
return self._compare > other
+ def fix_filename(self, relroot=fsutil.USE_CWD, **kwargs):
+ filename = _fix_filename(self.filename, relroot, **kwargs)
+ if filename == self.filename:
+ return self
+ return self._replace(filename=filename)
+
class ParsedItem(namedtuple('ParsedItem', 'file kind parent name data')):
@@ -290,6 +319,12 @@ class ParsedItem(namedtuple('ParsedItem', 'file kind parent name data')):
else:
return self.parent.name
+ def fix_filename(self, relroot=fsutil.USE_CWD, **kwargs):
+ fixed = self.file.fix_filename(relroot, **kwargs)
+ if fixed == self.file:
+ return self
+ return self._replace(file=fixed)
+
def as_row(self, columns=None):
if not columns:
columns = self._fields
@@ -591,9 +626,10 @@ class HighlevelParsedItem:
)
return self._parsed
- def fix_filename(self, relroot):
+ def fix_filename(self, relroot=fsutil.USE_CWD, **kwargs):
if self.file:
- self.file = self.file.fix_filename(relroot)
+ self.file = self.file.fix_filename(relroot, **kwargs)
+ return self
def as_rowdata(self, columns=None):
columns, datacolumns, colnames = self._parse_columns(columns)
diff --git a/Tools/c-analyzer/c_parser/preprocessor/__main__.py b/Tools/c-analyzer/c_parser/preprocessor/__main__.py
index a6054307c2..bfc61949a7 100644
--- a/Tools/c-analyzer/c_parser/preprocessor/__main__.py
+++ b/Tools/c-analyzer/c_parser/preprocessor/__main__.py
@@ -40,10 +40,10 @@ def add_common_cli(parser, *, get_preprocessor=_get_preprocessor):
parser.add_argument('--same', action='append')
process_fail_arg = add_failure_filtering_cli(parser, FAIL)
- def process_args(args):
+ def process_args(args, *, argv):
ns = vars(args)
- process_fail_arg(args)
+ process_fail_arg(args, argv)
ignore_exc = ns.pop('ignore_exc')
# We later pass ignore_exc to _get_preprocessor().
@@ -174,6 +174,7 @@ def parse_args(argv=sys.argv[1:], prog=sys.argv[0], *,
verbosity, traceback_cm = process_args_by_key(
args,
+ argv,
processors[cmd],
['verbosity', 'traceback_cm'],
)
diff --git a/Tools/c-analyzer/check-c-globals.py b/Tools/c-analyzer/check-c-globals.py
index 3fe2bdcae1..b1364a612b 100644
--- a/Tools/c-analyzer/check-c-globals.py
+++ b/Tools/c-analyzer/check-c-globals.py
@@ -22,6 +22,7 @@ def parse_args():
cmd = 'check'
verbosity, traceback_cm = process_args_by_key(
args,
+ argv,
processors,
['verbosity', 'traceback_cm'],
)
diff --git a/Tools/c-analyzer/cpython/__main__.py b/Tools/c-analyzer/cpython/__main__.py
index 23ce29776c..a11b687214 100644
--- a/Tools/c-analyzer/cpython/__main__.py
+++ b/Tools/c-analyzer/cpython/__main__.py
@@ -3,11 +3,14 @@ import sys
from c_common.fsutil import expand_filenames, iter_files_by_suffix
from c_common.scriptutil import (
+ VERBOSITY,
add_verbosity_cli,
add_traceback_cli,
add_commands_cli,
add_kind_filtering_cli,
add_files_cli,
+ add_progress_cli,
+ main_for_filenames,
process_args_by_key,
configure_logger,
get_prog,
@@ -17,7 +20,7 @@ import c_parser.__main__ as c_parser
import c_analyzer.__main__ as c_analyzer
import c_analyzer as _c_analyzer
from c_analyzer.info import UNKNOWN
-from . import _analyzer, _parser, REPO_ROOT
+from . import _analyzer, _capi, _files, _parser, REPO_ROOT
logger = logging.getLogger(__name__)
@@ -25,9 +28,9 @@ logger = logging.getLogger(__name__)
def _resolve_filenames(filenames):
if filenames:
- resolved = (_parser.resolve_filename(f) for f in filenames)
+ resolved = (_files.resolve_filename(f) for f in filenames)
else:
- resolved = _parser.iter_filenames()
+ resolved = _files.iter_filenames()
return resolved
@@ -105,7 +108,11 @@ def cmd_parse(filenames=None, **kwargs):
filenames = _resolve_filenames(filenames)
if 'get_file_preprocessor' not in kwargs:
kwargs['get_file_preprocessor'] = _parser.get_preprocessor()
- c_parser.cmd_parse(filenames, **kwargs)
+ c_parser.cmd_parse(
+ filenames,
+ relroot=REPO_ROOT,
+ **kwargs
+ )
def _cli_check(parser, **kwargs):
@@ -131,6 +138,7 @@ def cmd_analyze(filenames=None, **kwargs):
kwargs['get_file_preprocessor'] = _parser.get_preprocessor(log_err=print)
c_analyzer.cmd_analyze(
filenames,
+ relroot=REPO_ROOT,
_analyze=_analyzer.analyze,
formats=formats,
**kwargs
@@ -199,6 +207,121 @@ def cmd_data(datacmd, **kwargs):
)
+def _cli_capi(parser):
+ parser.add_argument('--levels', action='append', metavar='LEVEL[,...]')
+ parser.add_argument(f'--public', dest='levels',
+ action='append_const', const='public')
+ parser.add_argument(f'--no-public', dest='levels',
+ action='append_const', const='no-public')
+ for level in _capi.LEVELS:
+ parser.add_argument(f'--{level}', dest='levels',
+ action='append_const', const=level)
+ def process_levels(args, *, argv=None):
+ levels = []
+ for raw in args.levels or ():
+ for level in raw.replace(',', ' ').strip().split():
+ if level == 'public':
+ levels.append('stable')
+ levels.append('cpython')
+ elif level == 'no-public':
+ levels.append('private')
+ levels.append('internal')
+ elif level in _capi.LEVELS:
+ levels.append(level)
+ else:
+ parser.error(f'expected LEVEL to be one of {sorted(_capi.LEVELS)}, got {level!r}')
+ args.levels = set(levels)
+
+ parser.add_argument('--kinds', action='append', metavar='KIND[,...]')
+ for kind in _capi.KINDS:
+ parser.add_argument(f'--{kind}', dest='kinds',
+ action='append_const', const=kind)
+ def process_kinds(args, *, argv=None):
+ kinds = []
+ for raw in args.kinds or ():
+ for kind in raw.replace(',', ' ').strip().split():
+ if kind in _capi.KINDS:
+ kinds.append(kind)
+ else:
+ parser.error(f'expected KIND to be one of {sorted(_capi.KINDS)}, got {kind!r}')
+ args.kinds = set(kinds)
+
+ parser.add_argument('--group-by', dest='groupby',
+ choices=['level', 'kind'])
+
+ parser.add_argument('--format', default='table')
+ parser.add_argument('--summary', dest='format',
+ action='store_const', const='summary')
+ def process_format(args, *, argv=None):
+ orig = args.format
+ args.format = _capi.resolve_format(args.format)
+ if isinstance(args.format, str):
+ if args.format not in _capi._FORMATS:
+ parser.error(f'unsupported format {orig!r}')
+
+ parser.add_argument('--show-empty', dest='showempty', action='store_true')
+ parser.add_argument('--no-show-empty', dest='showempty', action='store_false')
+ parser.set_defaults(showempty=None)
+
+ # XXX Add --sort-by, --sort and --no-sort.
+
+ parser.add_argument('--ignore', dest='ignored', action='append')
+ def process_ignored(args, *, argv=None):
+ ignored = []
+ for raw in args.ignored or ():
+ ignored.extend(raw.replace(',', ' ').strip().split())
+ args.ignored = ignored or None
+
+ parser.add_argument('filenames', nargs='*', metavar='FILENAME')
+ process_progress = add_progress_cli(parser)
+
+ return [
+ process_levels,
+ process_kinds,
+ process_format,
+ process_ignored,
+ process_progress,
+ ]
+
+
+def cmd_capi(filenames=None, *,
+ levels=None,
+ kinds=None,
+ groupby='kind',
+ format='table',
+ showempty=None,
+ ignored=None,
+ track_progress=None,
+ verbosity=VERBOSITY,
+ **kwargs
+ ):
+ render = _capi.get_renderer(format)
+
+ filenames = _files.iter_header_files(filenames, levels=levels)
+ #filenames = (file for file, _ in main_for_filenames(filenames))
+ if track_progress:
+ filenames = track_progress(filenames)
+ items = _capi.iter_capi(filenames)
+ if levels:
+ items = (item for item in items if item.level in levels)
+ if kinds:
+ items = (item for item in items if item.kind in kinds)
+
+ filter = _capi.resolve_filter(ignored)
+ if filter:
+ items = (item for item in items if filter(item, log=lambda msg: logger.log(1, msg)))
+
+ lines = render(
+ items,
+ groupby=groupby,
+ showempty=showempty,
+ verbose=verbosity > VERBOSITY,
+ )
+ print()
+ for line in lines:
+ print(line)
+
+
# We do not define any other cmd_*() handlers here,
# favoring those defined elsewhere.
@@ -223,6 +346,11 @@ COMMANDS = {
[_cli_data],
cmd_data,
),
+ 'capi': (
+ 'inspect the C-API',
+ [_cli_capi],
+ cmd_capi,
+ ),
}
@@ -258,6 +386,7 @@ def parse_args(argv=sys.argv[1:], prog=None, *, subset=None):
verbosity, traceback_cm = process_args_by_key(
args,
+ argv,
processors[cmd],
['verbosity', 'traceback_cm'],
)
diff --git a/Tools/c-analyzer/cpython/_analyzer.py b/Tools/c-analyzer/cpython/_analyzer.py
index 978831d1fd..09904236cd 100644
--- a/Tools/c-analyzer/cpython/_analyzer.py
+++ b/Tools/c-analyzer/cpython/_analyzer.py
@@ -84,13 +84,13 @@ def write_known():
def read_ignored():
if not _IGNORED:
- _IGNORED.update(_datafiles.read_ignored(IGNORED_FILE))
+ _IGNORED.update(_datafiles.read_ignored(IGNORED_FILE, relroot=REPO_ROOT))
return dict(_IGNORED)
def write_ignored():
raise NotImplementedError
- datafiles.write_ignored(variables, IGNORED_FILE)
+ _datafiles.write_ignored(variables, IGNORED_FILE, relroot=REPO_ROOT)
def analyze(filenames, *,
diff --git a/Tools/c-analyzer/cpython/_capi.py b/Tools/c-analyzer/cpython/_capi.py
new file mode 100644
index 0000000000..df8159a8cc
--- /dev/null
+++ b/Tools/c-analyzer/cpython/_capi.py
@@ -0,0 +1,665 @@
+from collections import namedtuple
+import logging
+import os
+import os.path
+import re
+import textwrap
+
+from c_common.tables import build_table, resolve_columns
+from c_parser.parser._regexes import _ind
+from ._files import iter_header_files, resolve_filename
+from . import REPO_ROOT
+
+
+logger = logging.getLogger(__name__)
+
+
+INCLUDE_ROOT = os.path.join(REPO_ROOT, 'Include')
+INCLUDE_CPYTHON = os.path.join(INCLUDE_ROOT, 'cpython')
+INCLUDE_INTERNAL = os.path.join(INCLUDE_ROOT, 'internal')
+
+_MAYBE_NESTED_PARENS = textwrap.dedent(r'''
+ (?:
+ (?: [^(]* [(] [^()]* [)] )* [^(]*
+ )
+''')
+
+CAPI_FUNC = textwrap.dedent(rf'''
+ (?:
+ ^
+ \s*
+ PyAPI_FUNC \s*
+ [(]
+ {_ind(_MAYBE_NESTED_PARENS, 2)}
+ [)] \s*
+ (\w+) # <func>
+ \s* [(]
+ )
+''')
+CAPI_DATA = textwrap.dedent(rf'''
+ (?:
+ ^
+ \s*
+ PyAPI_DATA \s*
+ [(]
+ {_ind(_MAYBE_NESTED_PARENS, 2)}
+ [)] \s*
+ (\w+) # <data>
+ \b [^(]
+ )
+''')
+CAPI_INLINE = textwrap.dedent(r'''
+ (?:
+ ^
+ \s*
+ static \s+ inline \s+
+ .*?
+ \s+
+ ( \w+ ) # <inline>
+ \s* [(]
+ )
+''')
+CAPI_MACRO = textwrap.dedent(r'''
+ (?:
+ (\w+) # <macro>
+ [(]
+ )
+''')
+CAPI_CONSTANT = textwrap.dedent(r'''
+ (?:
+ (\w+) # <constant>
+ \s+ [^(]
+ )
+''')
+CAPI_DEFINE = textwrap.dedent(rf'''
+ (?:
+ ^
+ \s* [#] \s* define \s+
+ (?:
+ {_ind(CAPI_MACRO, 3)}
+ |
+ {_ind(CAPI_CONSTANT, 3)}
+ |
+ (?:
+ # ignored
+ \w+ # <defined_name>
+ \s*
+ $
+ )
+ )
+ )
+''')
+CAPI_RE = re.compile(textwrap.dedent(rf'''
+ (?:
+ {_ind(CAPI_FUNC, 2)}
+ |
+ {_ind(CAPI_DATA, 2)}
+ |
+ {_ind(CAPI_INLINE, 2)}
+ |
+ {_ind(CAPI_DEFINE, 2)}
+ )
+'''), re.VERBOSE)
+
+KINDS = [
+ 'func',
+ 'data',
+ 'inline',
+ 'macro',
+ 'constant',
+]
+
+
+def _parse_line(line, prev=None):
+ last = line
+ if prev:
+ if not prev.endswith(os.linesep):
+ prev += os.linesep
+ line = prev + line
+ m = CAPI_RE.match(line)
+ if not m:
+ if not prev and line.startswith('static inline '):
+ return line # the new "prev"
+ #if 'PyAPI_' in line or '#define ' in line or ' define ' in line:
+ # print(line)
+ return None
+ results = zip(KINDS, m.groups())
+ for kind, name in results:
+ if name:
+ clean = last.split('//')[0].rstrip()
+ if clean.endswith('*/'):
+ clean = clean.split('/*')[0].rstrip()
+
+ if kind == 'macro' or kind == 'constant':
+ if not clean.endswith('\\'):
+ return name, kind
+ elif kind == 'inline':
+ if clean.endswith('}'):
+ if not prev or clean == '}':
+ return name, kind
+ elif kind == 'func' or kind == 'data':
+ if clean.endswith(';'):
+ return name, kind
+ else:
+ # This should not be reached.
+ raise NotImplementedError
+ return line # the new "prev"
+ # It was a plain #define.
+ return None
+
+
+LEVELS = [
+ 'stable',
+ 'cpython',
+ 'private',
+ 'internal',
+]
+
+def _get_level(filename, name, *,
+ _cpython=INCLUDE_CPYTHON + os.path.sep,
+ _internal=INCLUDE_INTERNAL + os.path.sep,
+ ):
+ if filename.startswith(_internal):
+ return 'internal'
+ elif name.startswith('_'):
+ return 'private'
+ elif os.path.dirname(filename) == INCLUDE_ROOT:
+ return 'stable'
+ elif filename.startswith(_cpython):
+ return 'cpython'
+ else:
+ raise NotImplementedError
+ #return '???'
+
+
+GROUPINGS = {
+ 'kind': KINDS,
+ 'level': LEVELS,
+}
+
+
+class CAPIItem(namedtuple('CAPIItem', 'file lno name kind level')):
+
+ @classmethod
+ def from_line(cls, line, filename, lno, prev=None):
+ parsed = _parse_line(line, prev)
+ if not parsed:
+ return None, None
+ if isinstance(parsed, str):
+ # incomplete
+ return None, parsed
+ name, kind = parsed
+ level = _get_level(filename, name)
+ self = cls(filename, lno, name, kind, level)
+ if prev:
+ self._text = (prev + line).rstrip().splitlines()
+ else:
+ self._text = [line.rstrip()]
+ return self, None
+
+ @property
+ def relfile(self):
+ return self.file[len(REPO_ROOT) + 1:]
+
+ @property
+ def text(self):
+ try:
+ return self._text
+ except AttributeError:
+ # XXX Actually ready the text from disk?.
+ self._text = []
+ if self.kind == 'data':
+ self._text = [
+ f'PyAPI_DATA(...) {self.name}',
+ ]
+ elif self.kind == 'func':
+ self._text = [
+ f'PyAPI_FUNC(...) {self.name}(...);',
+ ]
+ elif self.kind == 'inline':
+ self._text = [
+ f'static inline {self.name}(...);',
+ ]
+ elif self.kind == 'macro':
+ self._text = [
+ f'#define {self.name}(...) \\',
+ f' ...',
+ ]
+ elif self.kind == 'constant':
+ self._text = [
+ f'#define {self.name} ...',
+ ]
+ else:
+ raise NotImplementedError
+
+ return self._text
+
+
+def _parse_groupby(raw):
+ if not raw:
+ raw = 'kind'
+
+ if isinstance(raw, str):
+ groupby = raw.replace(',', ' ').strip().split()
+ else:
+ raise NotImplementedError
+
+ if not all(v in GROUPINGS for v in groupby):
+ raise ValueError(f'invalid groupby value {raw!r}')
+ return groupby
+
+
+def _resolve_full_groupby(groupby):
+ if isinstance(groupby, str):
+ groupby = [groupby]
+ groupings = []
+ for grouping in groupby + list(GROUPINGS):
+ if grouping not in groupings:
+ groupings.append(grouping)
+ return groupings
+
+
+def summarize(items, *, groupby='kind', includeempty=True, minimize=None):
+ if minimize is None:
+ if includeempty is None:
+ minimize = True
+ includeempty = False
+ else:
+ minimize = includeempty
+ elif includeempty is None:
+ includeempty = minimize
+ elif minimize and includeempty:
+ raise ValueError(f'cannot minimize and includeempty at the same time')
+
+ groupby = _parse_groupby(groupby)[0]
+ _outer, _inner = _resolve_full_groupby(groupby)
+ outers = GROUPINGS[_outer]
+ inners = GROUPINGS[_inner]
+
+ summary = {
+ 'totals': {
+ 'all': 0,
+ 'subs': {o: 0 for o in outers},
+ 'bygroup': {o: {i: 0 for i in inners}
+ for o in outers},
+ },
+ }
+
+ for item in items:
+ outer = getattr(item, _outer)
+ inner = getattr(item, _inner)
+ # Update totals.
+ summary['totals']['all'] += 1
+ summary['totals']['subs'][outer] += 1
+ summary['totals']['bygroup'][outer][inner] += 1
+
+ if not includeempty:
+ subtotals = summary['totals']['subs']
+ bygroup = summary['totals']['bygroup']
+ for outer in outers:
+ if subtotals[outer] == 0:
+ del subtotals[outer]
+ del bygroup[outer]
+ continue
+
+ for inner in inners:
+ if bygroup[outer][inner] == 0:
+ del bygroup[outer][inner]
+ if minimize:
+ if len(bygroup[outer]) == 1:
+ del bygroup[outer]
+
+ return summary
+
+
+def _parse_capi(lines, filename):
+ if isinstance(lines, str):
+ lines = lines.splitlines()
+ prev = None
+ for lno, line in enumerate(lines, 1):
+ parsed, prev = CAPIItem.from_line(line, filename, lno, prev)
+ if parsed:
+ yield parsed
+ if prev:
+ parsed, prev = CAPIItem.from_line('', filename, lno, prev)
+ if parsed:
+ yield parsed
+ if prev:
+ print('incomplete match:')
+ print(filename)
+ print(prev)
+ raise Exception
+
+
+def iter_capi(filenames=None):
+ for filename in iter_header_files(filenames):
+ with open(filename) as infile:
+ for item in _parse_capi(infile, filename):
+ yield item
+
+
+def resolve_filter(ignored):
+ if not ignored:
+ return None
+ ignored = set(_resolve_ignored(ignored))
+ def filter(item, *, log=None):
+ if item.name not in ignored:
+ return True
+ if log is not None:
+ log(f'ignored {item.name!r}')
+ return False
+ return filter
+
+
+def _resolve_ignored(ignored):
+ if isinstance(ignored, str):
+ ignored = [ignored]
+ for raw in ignored:
+ if isinstance(raw, str):
+ if raw.startswith('|'):
+ yield raw[1:]
+ elif raw.startswith('<') and raw.endswith('>'):
+ filename = raw[1:-1]
+ try:
+ infile = open(filename)
+ except Exception as exc:
+ logger.error(f'ignore file failed: {exc}')
+ continue
+ logger.log(1, f'reading ignored names from {filename!r}')
+ with infile:
+ for line in infile:
+ if not line:
+ continue
+ if line[0].isspace():
+ continue
+ line = line.partition('#')[0].rstrip()
+ if line:
+ # XXX Recurse?
+ yield line
+ else:
+ raw = raw.strip()
+ if raw:
+ yield raw
+ else:
+ raise NotImplementedError
+
+
+def _collate(items, groupby, includeempty):
+ groupby = _parse_groupby(groupby)[0]
+ maxfilename = maxname = maxkind = maxlevel = 0
+
+ collated = {}
+ groups = GROUPINGS[groupby]
+ for group in groups:
+ collated[group] = []
+
+ for item in items:
+ key = getattr(item, groupby)
+ collated[key].append(item)
+ maxfilename = max(len(item.relfile), maxfilename)
+ maxname = max(len(item.name), maxname)
+ maxkind = max(len(item.kind), maxkind)
+ maxlevel = max(len(item.level), maxlevel)
+ if not includeempty:
+ for group in groups:
+ if not collated[group]:
+ del collated[group]
+ maxextra = {
+ 'kind': maxkind,
+ 'level': maxlevel,
+ }
+ return collated, groupby, maxfilename, maxname, maxextra
+
+
+def _get_sortkey(sort, _groupby, _columns):
+ if sort is True or sort is None:
+ # For now:
+ def sortkey(item):
+ return (
+ item.level == 'private',
+ LEVELS.index(item.level),
+ KINDS.index(item.kind),
+ os.path.dirname(item.file),
+ os.path.basename(item.file),
+ item.name,
+ )
+ return sortkey
+
+ sortfields = 'not-private level kind dirname basename name'.split()
+ elif isinstance(sort, str):
+ sortfields = sort.replace(',', ' ').strip().split()
+ elif callable(sort):
+ return sort
+ else:
+ raise NotImplementedError
+
+ # XXX Build a sortkey func from sortfields.
+ raise NotImplementedError
+
+
+##################################
+# CLI rendering
+
+_MARKERS = {
+ 'level': {
+ 'S': 'stable',
+ 'C': 'cpython',
+ 'P': 'private',
+ 'I': 'internal',
+ },
+ 'kind': {
+ 'F': 'func',
+ 'D': 'data',
+ 'I': 'inline',
+ 'M': 'macro',
+ 'C': 'constant',
+ },
+}
+
+
+def resolve_format(format):
+ if not format:
+ return 'table'
+ elif isinstance(format, str) and format in _FORMATS:
+ return format
+ else:
+ return resolve_columns(format)
+
+
+def get_renderer(format):
+ format = resolve_format(format)
+ if isinstance(format, str):
+ try:
+ return _FORMATS[format]
+ except KeyError:
+ raise ValueError(f'unsupported format {format!r}')
+ else:
+ def render(items, **kwargs):
+ return render_table(items, columns=format, **kwargs)
+ return render
+
+
+def render_table(items, *,
+ columns=None,
+ groupby='kind',
+ sort=True,
+ showempty=False,
+ verbose=False,
+ ):
+ if groupby is None:
+ groupby = 'kind'
+ if showempty is None:
+ showempty = False
+
+ if groupby:
+ (collated, groupby, maxfilename, maxname, maxextra,
+ ) = _collate(items, groupby, showempty)
+ for grouping in GROUPINGS:
+ maxextra[grouping] = max(len(g) for g in GROUPINGS[grouping])
+
+ _, extra = _resolve_full_groupby(groupby)
+ extras = [extra]
+ markers = {extra: _MARKERS[extra]}
+
+ groups = GROUPINGS[groupby]
+ else:
+ # XXX Support no grouping?
+ raise NotImplementedError
+
+ if columns:
+ def get_extra(item):
+ return {extra: getattr(item, extra)
+ for extra in ('kind', 'level')}
+ else:
+ if verbose:
+ extracols = [f'{extra}:{maxextra[extra]}'
+ for extra in extras]
+ def get_extra(item):
+ return {extra: getattr(item, extra)
+ for extra in extras}
+ elif len(extras) == 1:
+ extra, = extras
+ extracols = [f'{m}:1' for m in markers[extra]]
+ def get_extra(item):
+ return {m: m if getattr(item, extra) == markers[extra][m] else ''
+ for m in markers[extra]}
+ else:
+ raise NotImplementedError
+ #extracols = [[f'{m}:1' for m in markers[extra]]
+ # for extra in extras]
+ #def get_extra(item):
+ # values = {}
+ # for extra in extras:
+ # cur = markers[extra]
+ # for m in cur:
+ # values[m] = m if getattr(item, m) == cur[m] else ''
+ # return values
+ columns = [
+ f'filename:{maxfilename}',
+ f'name:{maxname}',
+ *extracols,
+ ]
+ header, div, fmt = build_table(columns)
+
+ if sort:
+ sortkey = _get_sortkey(sort, groupby, columns)
+
+ total = 0
+ for group, grouped in collated.items():
+ if not showempty and group not in collated:
+ continue
+ yield ''
+ yield f' === {group} ==='
+ yield ''
+ yield header
+ yield div
+ if grouped:
+ if sort:
+ grouped = sorted(grouped, key=sortkey)
+ for item in grouped:
+ yield fmt.format(
+ filename=item.relfile,
+ name=item.name,
+ **get_extra(item),
+ )
+ yield div
+ subtotal = len(grouped)
+ yield f' sub-total: {subtotal}'
+ total += subtotal
+ yield ''
+ yield f'total: {total}'
+
+
+def render_full(items, *,
+ groupby='kind',
+ sort=None,
+ showempty=None,
+ verbose=False,
+ ):
+ if groupby is None:
+ groupby = 'kind'
+ if showempty is None:
+ showempty = False
+
+ if sort:
+ sortkey = _get_sortkey(sort, groupby, None)
+
+ if groupby:
+ collated, groupby, _, _, _ = _collate(items, groupby, showempty)
+ for group, grouped in collated.items():
+ yield '#' * 25
+ yield f'# {group} ({len(grouped)})'
+ yield '#' * 25
+ yield ''
+ if not grouped:
+ continue
+ if sort:
+ grouped = sorted(grouped, key=sortkey)
+ for item in grouped:
+ yield from _render_item_full(item, groupby, verbose)
+ yield ''
+ else:
+ if sort:
+ items = sorted(items, key=sortkey)
+ for item in items:
+ yield from _render_item_full(item, None, verbose)
+ yield ''
+
+
+def _render_item_full(item, groupby, verbose):
+ yield item.name
+ yield f' {"filename:":10} {item.relfile}'
+ for extra in ('kind', 'level'):
+ #if groupby != extra:
+ yield f' {extra+":":10} {getattr(item, extra)}'
+ if verbose:
+ print(' ---------------------------------------')
+ for lno, line in enumerate(item.text, item.lno):
+ print(f' | {lno:3} {line}')
+ print(' ---------------------------------------')
+
+
+def render_summary(items, *,
+ groupby='kind',
+ sort=None,
+ showempty=None,
+ verbose=False,
+ ):
+ if groupby is None:
+ groupby = 'kind'
+ summary = summarize(
+ items,
+ groupby=groupby,
+ includeempty=showempty,
+ minimize=None if showempty else not verbose,
+ )
+
+ subtotals = summary['totals']['subs']
+ bygroup = summary['totals']['bygroup']
+ lastempty = False
+ for outer, subtotal in subtotals.items():
+ if bygroup:
+ subtotal = f'({subtotal})'
+ yield f'{outer + ":":20} {subtotal:>8}'
+ else:
+ yield f'{outer + ":":10} {subtotal:>8}'
+ if outer in bygroup:
+ for inner, count in bygroup[outer].items():
+ yield f' {inner + ":":9} {count}'
+ lastempty = False
+ else:
+ lastempty = True
+
+ total = f'*{summary["totals"]["all"]}*'
+ label = '*total*:'
+ if bygroup:
+ yield f'{label:20} {total:>8}'
+ else:
+ yield f'{label:10} {total:>9}'
+
+
+_FORMATS = {
+ 'table': render_table,
+ 'full': render_full,
+ 'summary': render_summary,
+}
diff --git a/Tools/c-analyzer/cpython/_files.py b/Tools/c-analyzer/cpython/_files.py
new file mode 100644
index 0000000000..3e39788097
--- /dev/null
+++ b/Tools/c-analyzer/cpython/_files.py
@@ -0,0 +1,69 @@
+import os.path
+
+from c_common.fsutil import expand_filenames, iter_files_by_suffix
+from . import REPO_ROOT, INCLUDE_DIRS, SOURCE_DIRS
+
+
+GLOBS = [
+ 'Include/*.h',
+ 'Include/internal/*.h',
+ 'Modules/**/*.h',
+ 'Modules/**/*.c',
+ 'Objects/**/*.h',
+ 'Objects/**/*.c',
+ 'Python/**/*.h',
+ 'Parser/**/*.c',
+ 'Python/**/*.h',
+ 'Parser/**/*.c',
+]
+LEVEL_GLOBS = {
+ 'stable': 'Include/*.h',
+ 'cpython': 'Include/cpython/*.h',
+ 'internal': 'Include/internal/*.h',
+}
+
+
+def resolve_filename(filename):
+ orig = filename
+ filename = os.path.normcase(os.path.normpath(filename))
+ if os.path.isabs(filename):
+ if os.path.relpath(filename, REPO_ROOT).startswith('.'):
+ raise Exception(f'{orig!r} is outside the repo ({REPO_ROOT})')
+ return filename
+ else:
+ return os.path.join(REPO_ROOT, filename)
+
+
+def iter_filenames(*, search=False):
+ if search:
+ yield from iter_files_by_suffix(INCLUDE_DIRS, ('.h',))
+ yield from iter_files_by_suffix(SOURCE_DIRS, ('.c',))
+ else:
+ globs = (os.path.join(REPO_ROOT, file) for file in GLOBS)
+ yield from expand_filenames(globs)
+
+
+def iter_header_files(filenames=None, *, levels=None):
+ if not filenames:
+ if levels:
+ levels = set(levels)
+ if 'private' in levels:
+ levels.add('stable')
+ levels.add('cpython')
+ for level, glob in LEVEL_GLOBS.items():
+ if level in levels:
+ yield from expand_filenames([glob])
+ else:
+ yield from iter_files_by_suffix(INCLUDE_DIRS, ('.h',))
+ return
+
+ for filename in filenames:
+ orig = filename
+ filename = resolve_filename(filename)
+ if filename.endswith(os.path.sep):
+ yield from iter_files_by_suffix(INCLUDE_DIRS, ('.h',))
+ elif filename.endswith('.h'):
+ yield filename
+ else:
+ # XXX Log it and continue instead?
+ raise ValueError(f'expected .h file, got {orig!r}')
diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py
index 7c8c296665..ef06a9fcb6 100644
--- a/Tools/c-analyzer/cpython/_parser.py
+++ b/Tools/c-analyzer/cpython/_parser.py
@@ -1,7 +1,6 @@
import os.path
import re
-from c_common.fsutil import expand_filenames, iter_files_by_suffix
from c_parser.preprocessor import (
get_preprocessor as _get_preprocessor,
)
@@ -9,7 +8,7 @@ from c_parser import (
parse_file as _parse_file,
parse_files as _parse_files,
)
-from . import REPO_ROOT, INCLUDE_DIRS, SOURCE_DIRS
+from . import REPO_ROOT
GLOB_ALL = '**/*'
@@ -43,19 +42,6 @@ def clean_lines(text):
@end=sh@
'''
-GLOBS = [
- 'Include/*.h',
- 'Include/internal/*.h',
- 'Modules/**/*.h',
- 'Modules/**/*.c',
- 'Objects/**/*.h',
- 'Objects/**/*.c',
- 'Python/**/*.h',
- 'Parser/**/*.c',
- 'Python/**/*.h',
- 'Parser/**/*.c',
-]
-
EXCLUDED = clean_lines('''
# @begin=conf@
@@ -162,6 +148,12 @@ Modules/_datetimemodule.c Py_BUILD_CORE 1
Modules/_ctypes/cfield.c Py_BUILD_CORE 1
Modules/_heapqmodule.c Py_BUILD_CORE 1
Modules/_posixsubprocess.c Py_BUILD_CORE 1
+Modules/_sre.c Py_BUILD_CORE 1
+Modules/_collectionsmodule.c Py_BUILD_CORE 1
+Modules/_zoneinfo.c Py_BUILD_CORE 1
+Modules/unicodedata.c Py_BUILD_CORE 1
+Modules/_cursesmodule.c Py_BUILD_CORE 1
+Modules/_ctypes/_ctypes.c Py_BUILD_CORE 1
Objects/stringlib/codecs.h Py_BUILD_CORE 1
Python/ceval_gil.h Py_BUILD_CORE 1
Python/condvar.h Py_BUILD_CORE 1
@@ -274,26 +266,6 @@ SAME = [
]
-def resolve_filename(filename):
- orig = filename
- filename = os.path.normcase(os.path.normpath(filename))
- if os.path.isabs(filename):
- if os.path.relpath(filename, REPO_ROOT).startswith('.'):
- raise Exception(f'{orig!r} is outside the repo ({REPO_ROOT})')
- return filename
- else:
- return os.path.join(REPO_ROOT, filename)
-
-
-def iter_filenames(*, search=False):
- if search:
- yield from iter_files_by_suffix(INCLUDE_DIRS, ('.h',))
- yield from iter_files_by_suffix(SOURCE_DIRS, ('.c',))
- else:
- globs = (os.path.join(REPO_ROOT, file) for file in GLOBS)
- yield from expand_filenames(globs)
-
-
def get_preprocessor(*,
file_macros=None,
file_incldirs=None,
diff --git a/Tools/c-analyzer/cpython/ignored.tsv b/Tools/c-analyzer/cpython/ignored.tsv
index 2c456db063..e5d9378207 100644
--- a/Tools/c-analyzer/cpython/ignored.tsv
+++ b/Tools/c-analyzer/cpython/ignored.tsv
@@ -1,2 +1,2938 @@
filename funcname name reason
#??? - somevar ???
+
+# XXX The analyzer should have ignored these (forward/extern references):
+Include/py_curses.h - PyCurses_API -
+Include/pydecimal.h - _decimal_api -
+Modules/_blake2/blake2module.c - blake2b_type_spec -
+Modules/_blake2/blake2module.c - blake2s_type_spec -
+Modules/_io/fileio.c - _Py_open_cloexec_works -
+Modules/_io/_iomodule.h - PyIOBase_Type -
+Modules/_io/_iomodule.h - PyRawIOBase_Type -
+Modules/_io/_iomodule.h - PyBufferedIOBase_Type -
+Modules/_io/_iomodule.h - PyTextIOBase_Type -
+Modules/_io/_iomodule.h - PyFileIO_Type -
+Modules/_io/_iomodule.h - PyBytesIO_Type -
+Modules/_io/_iomodule.h - PyStringIO_Type -
+Modules/_io/_iomodule.h - PyBufferedReader_Type -
+Modules/_io/_iomodule.h - PyBufferedWriter_Type -
+Modules/_io/_iomodule.h - PyBufferedRWPair_Type -
+Modules/_io/_iomodule.h - PyBufferedRandom_Type -
+Modules/_io/_iomodule.h - PyTextIOWrapper_Type -
+Modules/_io/_iomodule.h - PyIncrementalNewlineDecoder_Type -
+Modules/_io/_iomodule.h - _PyBytesIOBuffer_Type -
+Modules/_io/_iomodule.h - _PyIO_str_close -
+Modules/_io/_iomodule.h - _PyIO_str_closed -
+Modules/_io/_iomodule.h - _PyIO_str_decode -
+Modules/_io/_iomodule.h - _PyIO_str_encode -
+Modules/_io/_iomodule.h - _PyIO_str_fileno -
+Modules/_io/_iomodule.h - _PyIO_str_flush -
+Modules/_io/_iomodule.h - _PyIO_str_getstate -
+Modules/_io/_iomodule.h - _PyIO_str_isatty -
+Modules/_io/_iomodule.h - _PyIO_str_newlines -
+Modules/_io/_iomodule.h - _PyIO_str_nl -
+Modules/_io/_iomodule.h - _PyIO_str_peek -
+Modules/_io/_iomodule.h - _PyIO_str_read -
+Modules/_io/_iomodule.h - _PyIO_str_read1 -
+Modules/_io/_iomodule.h - _PyIO_str_readable -
+Modules/_io/_iomodule.h - _PyIO_str_readall -
+Modules/_io/_iomodule.h - _PyIO_str_readinto -
+Modules/_io/_iomodule.h - _PyIO_str_readline -
+Modules/_io/_iomodule.h - _PyIO_str_reset -
+Modules/_io/_iomodule.h - _PyIO_str_seek -
+Modules/_io/_iomodule.h - _PyIO_str_seekable -
+Modules/_io/_iomodule.h - _PyIO_str_setstate -
+Modules/_io/_iomodule.h - _PyIO_str_tell -
+Modules/_io/_iomodule.h - _PyIO_str_truncate -
+Modules/_io/_iomodule.h - _PyIO_str_writable -
+Modules/_io/_iomodule.h - _PyIO_str_write -
+Modules/_io/_iomodule.h - _PyIO_empty_str -
+Modules/_io/_iomodule.h - _PyIO_empty_bytes -
+Modules/_multiprocessing/multiprocessing.h - _PyMp_SemLockType -
+Modules/_sqlite/cache.h - pysqlite_NodeType -
+Modules/_sqlite/cache.h - pysqlite_CacheType -
+Modules/_sqlite/cursor.h - pysqlite_CursorType -
+Modules/_sqlite/row.h - pysqlite_RowType -
+Modules/_sqlite/prepare_protocol.h - pysqlite_PrepareProtocolType -
+Modules/_sqlite/statement.h - pysqlite_StatementType -
+Modules/_sqlite/connection.h - pysqlite_ConnectionType -
+Modules/_sqlite/module.c - pysqlite_Error -
+Modules/_sqlite/module.c - pysqlite_Warning -
+Modules/_sqlite/module.c - pysqlite_InterfaceError -
+Modules/_sqlite/module.c - pysqlite_DatabaseError -
+Modules/_sqlite/module.c - pysqlite_InternalError -
+Modules/_sqlite/module.c - pysqlite_OperationalError -
+Modules/_sqlite/module.c - pysqlite_ProgrammingError -
+Modules/_sqlite/module.c - pysqlite_IntegrityError -
+Modules/_sqlite/module.c - pysqlite_DataError -
+Modules/_sqlite/module.c - pysqlite_NotSupportedError -
+Modules/_sqlite/module.c - _pysqlite_converters -
+Modules/_sqlite/module.c - _pysqlite_enable_callback_tracebacks -
+Modules/_sqlite/module.c - pysqlite_BaseTypeAdapted -
+Modules/_testcapimodule.c - _PyBytesIOBuffer_Type -
+Modules/posixmodule.c - _Py_open_cloexec_works -
+Python/importdl.h - _PyImport_DynLoadFiletab -
+
+
+##################################
+# test code
+# []
+
+Modules/_ctypes/_ctypes_test.c - _ctypes_test_slots -
+Modules/_ctypes/_ctypes_test.c - module_methods -
+Modules/_ctypes/_ctypes_test.c - my_spams -
+Modules/_ctypes/_ctypes_test.c - my_eggs -
+Modules/_ctypes/_ctypes_test.c - an_integer -
+Modules/_ctypes/_ctypes_test.c - _xxx_lib -
+Modules/_ctypes/_ctypes_test.c - left -
+Modules/_ctypes/_ctypes_test.c - top -
+Modules/_ctypes/_ctypes_test.c - right -
+Modules/_ctypes/_ctypes_test.c - bottom -
+Modules/_ctypes/_ctypes_test.c - _ctypes_testmodule -
+Modules/_ctypes/_ctypes_test.c - last_tfrsuv_arg -
+Modules/_ctypes/_ctypes_test.c - last_tf_arg_s -
+Modules/_ctypes/_ctypes_test.c - last_tf_arg_u -
+Modules/_testbuffer.c - simple_format -
+Modules/_testbuffer.c - static_mem -
+Modules/_testbuffer.c - static_shape -
+Modules/_testbuffer.c - static_strides -
+Modules/_testbuffer.c - NDArray_Type -
+Modules/_testbuffer.c - StaticArray_Type -
+Modules/_testbuffer.c ndarray_init kwlist -
+Modules/_testbuffer.c ndarray_push kwlist -
+Modules/_testbuffer.c staticarray_init kwlist -
+Modules/_testbuffer.c - ndarray_methods -
+Modules/_testbuffer.c - _testbuffer_functions -
+Modules/_testbuffer.c - ndarray_getset -
+Modules/_testbuffer.c - ndarray_as_buffer -
+Modules/_testbuffer.c - staticarray_as_buffer -
+Modules/_testbuffer.c - ndarray_as_sequence -
+Modules/_testbuffer.c - ndarray_as_mapping -
+Modules/_testbuffer.c - structmodule -
+Modules/_testbuffer.c - _testbuffermodule -
+Modules/_testbuffer.c - Struct -
+Modules/_testbuffer.c - calcsize -
+Modules/_testbuffer.c - simple_fmt -
+Modules/_testbuffer.c - static_buffer -
+Modules/_testbuffer.c ndarray_memoryview_from_buffer format -
+Modules/_testbuffer.c ndarray_memoryview_from_buffer shape -
+Modules/_testbuffer.c ndarray_memoryview_from_buffer strides -
+Modules/_testbuffer.c ndarray_memoryview_from_buffer suboffsets -
+Modules/_testbuffer.c ndarray_memoryview_from_buffer info -
+Modules/_testbuffer.c - infobuf -
+Modules/_testcapimodule.c - TestError -
+Modules/_testcapimodule.c test_capsule buffer -
+Modules/_testcapimodule.c - decimal_initialized -
+Modules/_testcapimodule.c - thread_done -
+Modules/_testcapimodule.c - capsule_error -
+Modules/_testcapimodule.c - capsule_destructor_call_count -
+Modules/_testcapimodule.c - str1 -
+Modules/_testcapimodule.c - str2 -
+Modules/_testcapimodule.c - test_run_counter -
+Modules/_testcapimodule.c - FmHook -
+Modules/_testcapimodule.c - FmData -
+Modules/_testcapimodule.c - _testcapimodule -
+Modules/_testcapimodule.c - _HashInheritanceTester_Type -
+Modules/_testcapimodule.c - test_structmembersType -
+Modules/_testcapimodule.c - matmulType -
+Modules/_testcapimodule.c - ipowType -
+Modules/_testcapimodule.c - awaitType -
+Modules/_testcapimodule.c - PyRecursingInfinitelyError_Type -
+Modules/_testcapimodule.c - MyList_Type -
+Modules/_testcapimodule.c - GenericAlias_Type -
+Modules/_testcapimodule.c - Generic_Type -
+Modules/_testcapimodule.c - MethodDescriptorBase_Type -
+Modules/_testcapimodule.c - MethodDescriptorDerived_Type -
+Modules/_testcapimodule.c - MethodDescriptorNopGet_Type -
+Modules/_testcapimodule.c - MethodDescriptor2_Type -
+Modules/_testcapimodule.c - MethInstance_Type -
+Modules/_testcapimodule.c - MethClass_Type -
+Modules/_testcapimodule.c - MethStatic_Type -
+Modules/_testcapimodule.c - ContainerNoGC_type -
+Modules/_testcapimodule.c slot_tp_del PyId___tp_del__ -
+Modules/_testcapimodule.c raise_SIGINT_then_send_None PyId_send -
+Modules/_testcapimodule.c - HeapDocCType_spec -
+Modules/_testcapimodule.c - HeapGcCType_spec -
+Modules/_testcapimodule.c - HeapCType_spec -
+Modules/_testcapimodule.c - HeapCTypeSubclass_spec -
+Modules/_testcapimodule.c - HeapCTypeWithBuffer_spec -
+Modules/_testcapimodule.c - HeapCTypeSubclassWithFinalizer_spec -
+Modules/_testcapimodule.c - HeapCTypeWithDict_spec -
+Modules/_testcapimodule.c - HeapCTypeWithNegativeDict_spec -
+Modules/_testcapimodule.c - HeapCTypeWithWeakref_spec -
+Modules/_testcapimodule.c - HeapCTypeSetattr_spec -
+Modules/_testcapimodule.c - capsule_name -
+Modules/_testcapimodule.c - capsule_pointer -
+Modules/_testcapimodule.c - capsule_context -
+Modules/_testcapimodule.c - x -
+Modules/_testcapimodule.c getargs_keyword_only keywords -
+Modules/_testcapimodule.c getargs_keywords keywords -
+Modules/_testcapimodule.c getargs_positional_only_and_keywords keywords -
+Modules/_testcapimodule.c make_exception_with_doc kwlist -
+Modules/_testcapimodule.c test_empty_argparse kwlist -
+Modules/_testcapimodule.c test_structmembers_new keywords -
+Modules/_testcapimodule.c - ml -
+Modules/_testcapimodule.c - TestMethods -
+Modules/_testcapimodule.c - generic_alias_methods -
+Modules/_testcapimodule.c - generic_methods -
+Modules/_testcapimodule.c - meth_instance_methods -
+Modules/_testcapimodule.c - meth_class_methods -
+Modules/_testcapimodule.c - meth_static_methods -
+Modules/_testcapimodule.c - test_members -
+Modules/_testcapimodule.c - heapctype_members -
+Modules/_testcapimodule.c - heapctypesubclass_members -
+Modules/_testcapimodule.c - heapctypewithdict_members -
+Modules/_testcapimodule.c - heapctypewithnegativedict_members -
+Modules/_testcapimodule.c - heapctypewithweakref_members -
+Modules/_testcapimodule.c - heapctypesetattr_members -
+Modules/_testcapimodule.c - ContainerNoGC_members -
+Modules/_testcapimodule.c - matmulType_as_number -
+Modules/_testcapimodule.c - ipowType_as_number -
+Modules/_testcapimodule.c - awaitType_as_async -
+Modules/_testcapimodule.c - heapctypewithdict_getsetlist -
+Modules/_testcapimodule.c - HeapDocCType_slots -
+Modules/_testcapimodule.c - HeapGcCType_slots -
+Modules/_testcapimodule.c - HeapCType_slots -
+Modules/_testcapimodule.c - HeapCTypeSubclass_slots -
+Modules/_testcapimodule.c - HeapCTypeWithBuffer_slots -
+Modules/_testcapimodule.c - HeapCTypeSubclassWithFinalizer_slots -
+Modules/_testcapimodule.c - HeapCTypeWithDict_slots -
+Modules/_testcapimodule.c - HeapCTypeWithNegativeDict_slots -
+Modules/_testcapimodule.c - HeapCTypeWithWeakref_slots -
+Modules/_testcapimodule.c - HeapCTypeSetattr_slots -
+Modules/_testimportmultiple.c - _foomodule -
+Modules/_testimportmultiple.c - _barmodule -
+Modules/_testimportmultiple.c - _testimportmultiple -
+Modules/_testinternalcapi.c - _testcapimodule -
+Modules/_testinternalcapi.c - TestMethods -
+Modules/_testmultiphase.c - slots_create_nonmodule -
+Modules/_testmultiphase.c - def_nonmodule -
+Modules/_testmultiphase.c - main_def -
+Modules/_testmultiphase.c - def_nonmodule_with_methods -
+Modules/_testmultiphase.c - def_nonascii_latin -
+Modules/_testmultiphase.c - def_nonascii_kana -
+Modules/_testmultiphase.c - null_slots_def -
+Modules/_testmultiphase.c - def_bad_large -
+Modules/_testmultiphase.c - def_bad_negative -
+Modules/_testmultiphase.c - def_create_int_with_state -
+Modules/_testmultiphase.c - def_negative_size -
+Modules/_testmultiphase.c - uninitialized_def -
+Modules/_testmultiphase.c - def_create_null -
+Modules/_testmultiphase.c - def_create_raise -
+Modules/_testmultiphase.c - def_create_unreported_exception -
+Modules/_testmultiphase.c - def_nonmodule_with_exec_slots -
+Modules/_testmultiphase.c - def_exec_err -
+Modules/_testmultiphase.c - def_exec_raise -
+Modules/_testmultiphase.c - def_exec_unreported_exception -
+Modules/_testmultiphase.c - def_meth_state_access -
+Modules/_testmultiphase.c - imp_dummy_def -
+Modules/_testmultiphase.c - Example_Type_slots -
+Modules/_testmultiphase.c - StateAccessType_Type_slots -
+Modules/_testmultiphase.c - Str_Type_slots -
+Modules/_testmultiphase.c - main_slots -
+Modules/_testmultiphase.c - slots_create_nonmodule -
+Modules/_testmultiphase.c - slots_bad_large -
+Modules/_testmultiphase.c - slots_bad_negative -
+Modules/_testmultiphase.c - slots_create_null -
+Modules/_testmultiphase.c - slots_create_raise -
+Modules/_testmultiphase.c - slots_create_unreported_exception -
+Modules/_testmultiphase.c - slots_nonmodule_with_exec_slots -
+Modules/_testmultiphase.c - slots_exec_err -
+Modules/_testmultiphase.c - slots_exec_raise -
+Modules/_testmultiphase.c - slots_exec_unreported_exception -
+Modules/_testmultiphase.c - meth_state_access_slots -
+Modules/_testmultiphase.c - Example_methods -
+Modules/_testmultiphase.c - StateAccessType_methods -
+Modules/_testmultiphase.c - testexport_methods -
+Modules/_testmultiphase.c - nonmodule_methods -
+Modules/_testmultiphase.c - Example_Type_spec -
+Modules/_testmultiphase.c - StateAccessType_spec -
+Modules/_testmultiphase.c - Str_Type_spec -
+Modules/_xxtestfuzz/_xxtestfuzz.c - module_methods -
+Modules/_xxtestfuzz/_xxtestfuzz.c - _fuzzmodule -
+Modules/_xxtestfuzz/fuzzer.c - csv_module -
+Modules/_xxtestfuzz/fuzzer.c - regex_patterns -
+Modules/_xxtestfuzz/fuzzer.c - struct_unpack_method -
+Modules/_xxtestfuzz/fuzzer.c - struct_error -
+Modules/_xxtestfuzz/fuzzer.c - json_loads_method -
+Modules/_xxtestfuzz/fuzzer.c - sre_compile_method -
+Modules/_xxtestfuzz/fuzzer.c - sre_error_exception -
+Modules/_xxtestfuzz/fuzzer.c - compiled_patterns -
+Modules/_xxtestfuzz/fuzzer.c - csv_error -
+Modules/_xxtestfuzz/fuzzer.c - SRE_FLAG_DEBUG -
+Modules/_xxtestfuzz/fuzzer.c LLVMFuzzerTestOneInput STRUCT_UNPACK_INITIALIZED -
+Modules/_xxtestfuzz/fuzzer.c LLVMFuzzerTestOneInput JSON_LOADS_INITIALIZED -
+Modules/_xxtestfuzz/fuzzer.c LLVMFuzzerTestOneInput SRE_COMPILE_INITIALIZED -
+Modules/_xxtestfuzz/fuzzer.c LLVMFuzzerTestOneInput SRE_MATCH_INITIALIZED -
+Modules/_xxtestfuzz/fuzzer.c LLVMFuzzerTestOneInput CSV_READER_INITIALIZED -
+
+
+##################################
+# temporary whitelist - should be const
+
+# These are all variables that we will be making non-global.
+
+#-----------------------
+# keywords for PyArg_ParseTupleAndKeywords()
+# "static char *name[]" -> "static const char * const name[]"
+# []
+
+Modules/cjkcodecs/multibytecodec.c - incnewkwarglist -
+Modules/cjkcodecs/multibytecodec.c - streamkwarglist -
+Modules/_csv.c - dialect_kws -
+Modules/_datetimemodule.c date_fromisocalendar keywords -
+Modules/_datetimemodule.c - date_kws -
+Modules/_datetimemodule.c date_strftime keywords -
+Modules/_datetimemodule.c datetime_astimezone keywords -
+Modules/_datetimemodule.c datetime_combine keywords -
+Modules/_datetimemodule.c datetime_fromtimestamp keywords -
+Modules/_datetimemodule.c datetime_isoformat keywords -
+Modules/_datetimemodule.c - datetime_kws -
+Modules/_datetimemodule.c delta_new keywords -
+Modules/_datetimemodule.c time_isoformat keywords -
+Modules/_datetimemodule.c - time_kws -
+Modules/_datetimemodule.c time_strftime keywords -
+Modules/_datetimemodule.c - timezone_kws -
+Modules/_decimal/_decimal.c context_init kwlist -
+Modules/_decimal/_decimal.c ctxmanager_new kwlist -
+Modules/_decimal/_decimal.c ctx_mpd_qpow kwlist -
+Modules/_decimal/_decimal.c dec_mpd_class kwlist -
+Modules/_decimal/_decimal.c dec_mpd_compare_total kwlist -
+Modules/_decimal/_decimal.c dec_mpd_compare_total_mag kwlist -
+Modules/_decimal/_decimal.c dec_mpd_isnormal kwlist -
+Modules/_decimal/_decimal.c dec_mpd_issubnormal kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qand kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qcompare kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qcompare_signal kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qcopy_sign kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qexp kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qfma kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qinvert kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qln kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qlog10 kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qlogb kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qmax kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qmax_mag kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qmin kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qmin_mag kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qnext_minus kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qnext_plus kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qnext_toward kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qor kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qquantize kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qreduce kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qrem_near kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qrotate kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qscaleb kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qshift kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qsqrt kwlist -
+Modules/_decimal/_decimal.c dec_mpd_qxor kwlist -
+Modules/_decimal/_decimal.c dec_mpd_same_quantum kwlist -
+Modules/_decimal/_decimal.c dec_mpd_to_eng kwlist -
+Modules/_decimal/_decimal.c dec_new kwlist -
+Modules/_decimal/_decimal.c PyDec_ToIntegralExact kwlist -
+Modules/_decimal/_decimal.c PyDec_ToIntegralValue kwlist -
+Modules/_elementtree.c element_setstate_from_Python kwlist -
+Modules/faulthandler.c faulthandler_dump_traceback_later kwlist -
+Modules/faulthandler.c faulthandler_dump_traceback_py kwlist -
+Modules/faulthandler.c faulthandler_py_enable kwlist -
+Modules/faulthandler.c faulthandler_register_py kwlist -
+Modules/_functoolsmodule.c functools_cmp_to_key kwargs -
+Modules/_functoolsmodule.c keyobject_call kwargs -
+Modules/_functoolsmodule.c lru_cache_new keywords -
+Modules/itertoolsmodule.c repeat_new kwargs -
+Modules/_json.c encoder_call kwlist -
+Modules/_json.c encoder_new kwlist -
+Modules/_json.c scanner_call kwlist -
+Modules/_json.c scanner_new kwlist -
+Modules/_lsprof.c profiler_enable kwlist -
+Modules/_lsprof.c profiler_init kwlist -
+Modules/_lzmamodule.c Compressor_init arg_names -
+Modules/_lzmamodule.c parse_filter_spec_bcj optnames -
+Modules/_lzmamodule.c parse_filter_spec_delta optnames -
+Modules/_lzmamodule.c parse_filter_spec_lzma optnames -
+Modules/mmapmodule.c new_mmap_object keywords -
+Modules/nismodule.c nis_cat kwlist -
+Modules/nismodule.c nis_maps kwlist -
+Modules/nismodule.c nis_match kwlist -
+Modules/signalmodule.c signal_set_wakeup_fd kwlist -
+Modules/socketmodule.c sock_initobj keywords -
+Modules/socketmodule.c sock_recvfrom_into kwlist -
+Modules/socketmodule.c sock_recv_into kwlist -
+Modules/socketmodule.c sock_sendmsg_afalg keywords -
+Modules/socketmodule.c socket_getaddrinfo kwnames -
+Modules/_sqlite/connection.c pysqlite_connection_backup keywords -
+Modules/_sqlite/connection.c pysqlite_connection_create_aggregate kwlist -
+Modules/_sqlite/connection.c pysqlite_connection_create_function kwlist -
+Modules/_sqlite/connection.c pysqlite_connection_cursor kwlist -
+Modules/_sqlite/connection.c pysqlite_connection_init kwlist -
+Modules/_sqlite/connection.c pysqlite_connection_set_authorizer kwlist -
+Modules/_sqlite/connection.c pysqlite_connection_set_progress_handler kwlist -
+Modules/_sqlite/connection.c pysqlite_connection_set_trace_callback kwlist -
+Modules/_sqlite/cursor.c pysqlite_cursor_fetchmany kwlist -
+Modules/_sqlite/module.c module_complete kwlist -
+Modules/_sqlite/module.c module_connect kwlist -
+Modules/_sqlite/module.c module_enable_shared_cache kwlist -
+Modules/syslogmodule.c syslog_openlog keywords -
+Modules/_xxsubinterpretersmodule.c channel_close kwlist -
+Modules/_xxsubinterpretersmodule.c channel_destroy kwlist -
+Modules/_xxsubinterpretersmodule.c channelid_new kwlist -
+Modules/_xxsubinterpretersmodule.c channel_list_interpreters kwlist -
+Modules/_xxsubinterpretersmodule.c channel_recv kwlist -
+Modules/_xxsubinterpretersmodule.c channel_release kwlist -
+Modules/_xxsubinterpretersmodule.c channel_send kwlist -
+Modules/_xxsubinterpretersmodule.c interp_create kwlist -
+Modules/_xxsubinterpretersmodule.c interp_destroy kwlist -
+Modules/_xxsubinterpretersmodule.c interp_is_running kwlist -
+Modules/_xxsubinterpretersmodule.c interp_run_string kwlist -
+Modules/_xxsubinterpretersmodule.c object_is_shareable kwlist -
+Modules/_zoneinfo.c zoneinfo_clear_cache kwlist -
+Modules/_zoneinfo.c zoneinfo_from_file kwlist -
+Modules/_zoneinfo.c zoneinfo_new kwlist -
+Modules/_zoneinfo.c zoneinfo_no_cache kwlist -
+Objects/exceptions.c ImportError_init kwlist -
+Objects/interpreteridobject.c interpid_new kwlist -
+Objects/weakrefobject.c weakref_call kwlist -
+
+#-----------------------
+# PyModuleDef_Slot
+# []
+
+Modules/_abc.c - _abcmodule_slots -
+Modules/arraymodule.c - arrayslots -
+Modules/atexitmodule.c - atexit_slots -
+Modules/audioop.c - audioop_slots -
+Modules/binascii.c - binascii_slots -
+Modules/_blake2/blake2module.c - _blake2_slots -
+Modules/cmathmodule.c - cmath_slots -
+Modules/_codecsmodule.c - _codecs_slots -
+Modules/_cryptmodule.c - _crypt_slots -
+Modules/_curses_panel.c - _curses_slots -
+Modules/_dbmmodule.c - _dbmmodule_slots -
+Modules/errnomodule.c - errno_slots -
+Modules/faulthandler.c - faulthandler_slots -
+Modules/fcntlmodule.c - fcntl_slots -
+Modules/_gdbmmodule.c - _gdbm_module_slots -
+Modules/_hashopenssl.c - hashlib_slots -
+Modules/_json.c - _json_slots -
+Modules/_lsprof.c - _lsprofslots -
+Modules/_lzmamodule.c - lzma_slots -
+Modules/mathmodule.c - math_slots -
+Modules/md5module.c - _md5_slots -
+Modules/mmapmodule.c - mmap_slots -
+Modules/_multiprocessing/multiprocessing.c - multiprocessing_slots -
+Modules/nismodule.c - nis_slots -
+Modules/overlapped.c - overlapped_slots -
+Modules/posixmodule.c - posixmodile_slots -
+Modules/_scproxy.c - _scproxy_slots -
+Modules/sha1module.c - _sha1_slots -
+Modules/sha256module.c - _sha256_slots -
+Modules/_sha3/sha3module.c - _sha3_slots -
+Modules/sha512module.c - _sha512_slots -
+Modules/_stat.c - stat_slots -
+Modules/syslogmodule.c - syslog_slots -
+Modules/termios.c - termios_slots -
+Modules/unicodedata.c - unicodedata_slots -
+Modules/_uuidmodule.c - uuid_slots -
+Modules/_winapi.c - winapi_slots -
+Modules/xxlimited.c - xx_slots -
+Modules/zlibmodule.c - zlib_slots -
+Modules/_zoneinfo.c - zoneinfomodule_slots -
+Python/marshal.c - marshalmodule_slots -
+Python/Python-ast.c - astmodule_slots -
+Modules/_bz2module.c - _bz2_slots -
+Modules/_collectionsmodule.c - collections_slots -
+Modules/_contextvarsmodule.c - _contextvars_slots -
+Modules/_functoolsmodule.c - _functools_slots -
+Modules/_heapqmodule.c - heapq_slots -
+Modules/itertoolsmodule.c - itertoolsmodule_slots -
+Modules/_localemodule.c - _locale_slots -
+Modules/_operator.c - operator_slots -
+Modules/resource.c - resource_slots -
+Modules/_statisticsmodule.c - _statisticsmodule_slots -
+Modules/timemodule.c - time_slots -
+Modules/_weakref.c - weakref_slots -
+Modules/xxmodule.c - xx_slots -
+Modules/xxsubtype.c - xxsubtype_slots -
+
+#-----------------------
+# PyMethodDef and PyMethodDef[], for static types and modules
+# []
+
+Modules/_abc.c - _destroy_def -
+Modules/_abc.c - _abcmodule_methods -
+Modules/arraymodule.c - array_methods -
+Modules/arraymodule.c - arrayiter_methods -
+Modules/arraymodule.c - a_methods -
+Modules/_asynciomodule.c - FutureType_methods -
+Modules/_asynciomodule.c - FutureIter_methods -
+Modules/_asynciomodule.c - TaskType_methods -
+Modules/_asynciomodule.c - asyncio_methods -
+Modules/_asynciomodule.c - TaskWakeupDef -
+Modules/atexitmodule.c - atexit_methods -
+Modules/audioop.c - audioop_methods -
+Modules/binascii.c - binascii_module_methods -
+Modules/_bisectmodule.c - bisect_methods -
+Modules/_blake2/blake2b_impl.c - py_blake2b_methods -
+Modules/_blake2/blake2module.c - blake2mod_functions -
+Modules/_blake2/blake2s_impl.c - py_blake2s_methods -
+Modules/_bz2module.c - BZ2Compressor_methods -
+Modules/_bz2module.c - BZ2Decompressor_methods -
+Modules/cjkcodecs/multibytecodec.c - multibytecodec_methods -
+Modules/cjkcodecs/multibytecodec.c - mbiencoder_methods -
+Modules/cjkcodecs/multibytecodec.c - mbidecoder_methods -
+Modules/cjkcodecs/multibytecodec.c - mbstreamreader_methods -
+Modules/cjkcodecs/multibytecodec.c - mbstreamwriter_methods -
+Modules/cjkcodecs/multibytecodec.c - __methods -
+Modules/cmathmodule.c - cmath_methods -
+Modules/_codecsmodule.c - _codecs_functions -
+Modules/_collectionsmodule.c - deque_methods -
+Modules/_collectionsmodule.c - dequeiter_methods -
+Modules/_collectionsmodule.c - defdict_methods -
+Modules/_collectionsmodule.c - tuplegetter_methods -
+Modules/_collectionsmodule.c - collections_methods -
+Modules/_contextvarsmodule.c - _contextvars_methods -
+Modules/_cryptmodule.c - crypt_methods -
+Modules/_csv.c - Reader_methods -
+Modules/_csv.c - Writer_methods -
+Modules/_csv.c - csv_methods -
+Modules/_ctypes/callproc.c - _ctypes_module_methods -
+Modules/_ctypes/_ctypes.c - CDataType_methods -
+Modules/_ctypes/_ctypes.c - PyCPointerType_methods -
+Modules/_ctypes/_ctypes.c - c_void_p_method -
+Modules/_ctypes/_ctypes.c - c_char_p_method -
+Modules/_ctypes/_ctypes.c - c_wchar_p_method -
+Modules/_ctypes/_ctypes.c - PyCSimpleType_methods -
+Modules/_ctypes/_ctypes.c - PyCData_methods -
+Modules/_ctypes/_ctypes.c - Array_methods -
+Modules/_ctypes/_ctypes.c - Simple_methods -
+Modules/_ctypes/stgdict.c - PyCStgDict_methods -
+Modules/_cursesmodule.c - PyCursesWindow_Methods -
+Modules/_cursesmodule.c - PyCurses_methods -
+Modules/_curses_panel.c - PyCursesPanel_Methods -
+Modules/_curses_panel.c - PyCurses_methods -
+Modules/_datetimemodule.c - delta_methods -
+Modules/_datetimemodule.c - iso_calendar_date_methods -
+Modules/_datetimemodule.c - date_methods -
+Modules/_datetimemodule.c - tzinfo_methods -
+Modules/_datetimemodule.c - timezone_methods -
+Modules/_datetimemodule.c - time_methods -
+Modules/_datetimemodule.c - datetime_methods -
+Modules/_datetimemodule.c - module_methods -
+Modules/_dbmmodule.c - dbm_methods -
+Modules/_dbmmodule.c - dbmmodule_methods -
+Modules/_decimal/_decimal.c - signaldict_methods -
+Modules/_decimal/_decimal.c - ctxmanager_methods -
+Modules/_decimal/_decimal.c - dec_methods -
+Modules/_decimal/_decimal.c - context_methods -
+Modules/_decimal/_decimal.c - _decimal_methods -
+Modules/_elementtree.c - element_methods -
+Modules/_elementtree.c - treebuilder_methods -
+Modules/_elementtree.c - xmlparser_methods -
+Modules/_elementtree.c - _functions -
+Modules/errnomodule.c - errno_methods -
+Modules/faulthandler.c - module_methods -
+Modules/fcntlmodule.c - fcntl_methods -
+Modules/_functoolsmodule.c - partial_methods -
+Modules/_functoolsmodule.c - lru_cache_methods -
+Modules/_functoolsmodule.c - _functools_methods -
+Modules/gcmodule.c - GcMethods -
+Modules/_gdbmmodule.c - gdbm_methods -
+Modules/_gdbmmodule.c - _gdbm_module_methods -
+Modules/grpmodule.c - grp_methods -
+Modules/_hashopenssl.c - EVP_methods -
+Modules/_hashopenssl.c - EVPXOF_methods -
+Modules/_hashopenssl.c - HMAC_methods -
+Modules/_hashopenssl.c - EVP_functions -
+Modules/_heapqmodule.c - heapq_methods -
+Modules/_io/bufferedio.c - bufferediobase_methods -
+Modules/_io/bufferedio.c - bufferedreader_methods -
+Modules/_io/bufferedio.c - bufferedwriter_methods -
+Modules/_io/bufferedio.c - bufferedrwpair_methods -
+Modules/_io/bufferedio.c - bufferedrandom_methods -
+Modules/_io/bytesio.c - bytesio_methods -
+Modules/_io/fileio.c - fileio_methods -
+Modules/_io/iobase.c - iobase_methods -
+Modules/_io/iobase.c - rawiobase_methods -
+Modules/_io/_iomodule.c - module_methods -
+Modules/_io/stringio.c - stringio_methods -
+Modules/_io/textio.c - textiobase_methods -
+Modules/_io/textio.c - incrementalnewlinedecoder_methods -
+Modules/_io/textio.c - textiowrapper_methods -
+Modules/_io/winconsoleio.c - winconsoleio_methods -
+Modules/itertoolsmodule.c - groupby_methods -
+Modules/itertoolsmodule.c - _grouper_methods -
+Modules/itertoolsmodule.c - teedataobject_methods -
+Modules/itertoolsmodule.c - tee_methods -
+Modules/itertoolsmodule.c - cycle_methods -
+Modules/itertoolsmodule.c - dropwhile_methods -
+Modules/itertoolsmodule.c - takewhile_reduce_methods -
+Modules/itertoolsmodule.c - islice_methods -
+Modules/itertoolsmodule.c - starmap_methods -
+Modules/itertoolsmodule.c - chain_methods -
+Modules/itertoolsmodule.c - product_methods -
+Modules/itertoolsmodule.c - combinations_methods -
+Modules/itertoolsmodule.c - cwr_methods -
+Modules/itertoolsmodule.c - permuations_methods -
+Modules/itertoolsmodule.c - accumulate_methods -
+Modules/itertoolsmodule.c - compress_methods -
+Modules/itertoolsmodule.c - filterfalse_methods -
+Modules/itertoolsmodule.c - count_methods -
+Modules/itertoolsmodule.c - repeat_methods -
+Modules/itertoolsmodule.c - zip_longest_methods -
+Modules/itertoolsmodule.c - module_methods -
+Modules/_json.c - speedups_methods -
+Modules/_localemodule.c - PyLocale_Methods -
+Modules/_lsprof.c - profiler_methods -
+Modules/_lsprof.c - moduleMethods -
+Modules/_lzmamodule.c - Compressor_methods -
+Modules/_lzmamodule.c - Decompressor_methods -
+Modules/_lzmamodule.c - lzma_methods -
+Modules/mathmodule.c - math_methods -
+Modules/md5module.c - MD5_methods -
+Modules/md5module.c - MD5_functions -
+Modules/mmapmodule.c - mmap_object_methods -
+Modules/_multiprocessing/multiprocessing.c - module_methods -
+Modules/_multiprocessing/posixshmem.c - module_methods -
+Modules/_multiprocessing/semaphore.c - semlock_methods -
+Modules/nismodule.c - nis_methods -
+Modules/_opcode.c - opcode_functions -
+Modules/_operator.c - operator_methods -
+Modules/_operator.c - itemgetter_methods -
+Modules/_operator.c - attrgetter_methods -
+Modules/_operator.c - methodcaller_methods -
+Modules/ossaudiodev.c - oss_methods -
+Modules/ossaudiodev.c - oss_mixer_methods -
+Modules/ossaudiodev.c - ossaudiodev_methods -
+Modules/overlapped.c - Overlapped_methods -
+Modules/overlapped.c - overlapped_functions -
+Modules/_pickle.c - Pickler_methods -
+Modules/_pickle.c - picklerproxy_methods -
+Modules/_pickle.c - Unpickler_methods -
+Modules/_pickle.c - unpicklerproxy_methods -
+Modules/_pickle.c - pickle_methods -
+Modules/posixmodule.c - DirEntry_methods -
+Modules/posixmodule.c - ScandirIterator_methods -
+Modules/posixmodule.c - posix_methods -
+Modules/_posixsubprocess.c - module_methods -
+Modules/pwdmodule.c - pwd_methods -
+Modules/pyexpat.c - xmlparse_methods -
+Modules/pyexpat.c - pyexpat_methods -
+Modules/_queuemodule.c - simplequeue_methods -
+Modules/_randommodule.c - random_methods -
+Modules/readline.c - readline_methods -
+Modules/resource.c - resource_methods -
+Modules/_scproxy.c - mod_methods -
+Modules/selectmodule.c - poll_methods -
+Modules/selectmodule.c - devpoll_methods -
+Modules/selectmodule.c - pyepoll_methods -
+Modules/selectmodule.c - kqueue_queue_methods -
+Modules/selectmodule.c - select_methods -
+Modules/sha1module.c - SHA1_methods -
+Modules/sha1module.c - SHA1_functions -
+Modules/sha256module.c - SHA_methods -
+Modules/sha256module.c - SHA_functions -
+Modules/_sha3/sha3module.c - SHA3_methods -
+Modules/_sha3/sha3module.c - SHAKE_methods -
+Modules/sha512module.c - SHA_methods -
+Modules/sha512module.c - SHA_functions -
+Modules/signalmodule.c - signal_methods -
+Modules/socketmodule.c - sock_methods -
+Modules/socketmodule.c - socket_methods -
+Modules/spwdmodule.c - spwd_methods -
+Modules/_sqlite/cache.c - cache_methods -
+Modules/_sqlite/connection.c - connection_methods -
+Modules/_sqlite/cursor.c - cursor_methods -
+Modules/_sqlite/module.c - module_methods -
+Modules/_sqlite/row.c - row_methods -
+Modules/_sre.c - pattern_methods -
+Modules/_sre.c - match_methods -
+Modules/_sre.c - scanner_methods -
+Modules/_sre.c - _functions -
+Modules/_ssl.c - PySSLMethods -
+Modules/_ssl.c - context_methods -
+Modules/_ssl.c - memory_bio_methods -
+Modules/_ssl.c - PySSL_methods -
+Modules/_stat.c - stat_methods -
+Modules/_statisticsmodule.c - statistics_methods -
+Modules/_struct.c - unpackiter_methods -
+Modules/_struct.c - s_methods -
+Modules/_struct.c - module_functions -
+Modules/symtablemodule.c - symtable_methods -
+Modules/syslogmodule.c - syslog_methods -
+Modules/termios.c - termios_methods -
+Modules/_threadmodule.c - lock_methods -
+Modules/_threadmodule.c - rlock_methods -
+Modules/_threadmodule.c local_new wr_callback_def -
+Modules/_threadmodule.c - thread_methods -
+Modules/timemodule.c - time_methods -
+Modules/_tkinter.c - Tktt_methods -
+Modules/_tkinter.c - Tkapp_methods -
+Modules/_tkinter.c - moduleMethods -
+Modules/_tracemalloc.c - module_methods -
+Modules/unicodedata.c - unicodedata_functions -
+Modules/_uuidmodule.c - uuid_methods -
+Modules/_weakref.c - weakref_functions -
+Modules/_winapi.c - overlapped_methods -
+Modules/_winapi.c - winapi_functions -
+Modules/xxlimited.c - Xxo_methods -
+Modules/xxlimited.c - xx_methods -
+Modules/xxmodule.c - Xxo_methods -
+Modules/xxmodule.c - xx_methods -
+Modules/_xxsubinterpretersmodule.c - module_functions -
+Modules/xxsubtype.c - spamlist_methods -
+Modules/xxsubtype.c - spamdict_methods -
+Modules/xxsubtype.c - xxsubtype_functions -
+Modules/zlibmodule.c - comp_methods -
+Modules/zlibmodule.c - Decomp_methods -
+Modules/zlibmodule.c - zlib_methods -
+Modules/_zoneinfo.c - zoneinfo_methods -
+Modules/_zoneinfo.c - module_methods -
+Modules/cjkcodecs/cjkcodecs.h - __methods -
+Objects/bytearrayobject.c - bytearray_methods -
+Objects/bytearrayobject.c - bytearrayiter_methods -
+Objects/bytesobject.c - bytes_methods -
+Objects/bytesobject.c - striter_methods -
+Objects/classobject.c - method_methods -
+Objects/codeobject.c - code_methods -
+Objects/complexobject.c - complex_methods -
+Objects/descrobject.c - descr_methods -
+Objects/descrobject.c - mappingproxy_methods -
+Objects/descrobject.c - wrapper_methods -
+Objects/descrobject.c - property_methods -
+Objects/dictobject.c - mapp_methods -
+Objects/dictobject.c - dictiter_methods -
+Objects/dictobject.c - dictkeys_methods -
+Objects/dictobject.c - dictitems_methods -
+Objects/dictobject.c - dictvalues_methods -
+Objects/enumobject.c - enum_methods -
+Objects/enumobject.c - reversediter_methods -
+Objects/exceptions.c - BaseException_methods -
+Objects/exceptions.c - ImportError_methods -
+Objects/exceptions.c - OSError_methods -
+Objects/fileobject.c - stdprinter_methods -
+Objects/floatobject.c - float_methods -
+Objects/frameobject.c - frame_methods -
+Objects/genericaliasobject.c - ga_methods -
+Objects/genobject.c - gen_methods -
+Objects/genobject.c - coro_methods -
+Objects/genobject.c - coro_wrapper_methods -
+Objects/genobject.c - async_gen_methods -
+Objects/genobject.c - async_gen_asend_methods -
+Objects/genobject.c - async_gen_athrow_methods -
+Objects/iterobject.c - seqiter_methods -
+Objects/iterobject.c - calliter_methods -
+Objects/listobject.c - list_methods -
+Objects/listobject.c - listiter_methods -
+Objects/listobject.c - listreviter_methods -
+Objects/longobject.c - long_methods -
+Objects/memoryobject.c - memory_methods -
+Objects/methodobject.c - meth_methods -
+Objects/moduleobject.c - module_methods -
+Objects/namespaceobject.c - namespace_methods -
+Objects/object.c - notimplemented_methods -
+Objects/odictobject.c - odict_methods -
+Objects/odictobject.c - odictiter_methods -
+Objects/odictobject.c - odictkeys_methods -
+Objects/odictobject.c - odictitems_methods -
+Objects/odictobject.c - odictvalues_methods -
+Objects/picklebufobject.c - picklebuf_methods -
+Objects/rangeobject.c - range_methods -
+Objects/rangeobject.c - rangeiter_methods -
+Objects/rangeobject.c - longrangeiter_methods -
+Objects/setobject.c - setiter_methods -
+Objects/setobject.c - set_methods -
+Objects/setobject.c - frozenset_methods -
+Objects/sliceobject.c - ellipsis_methods -
+Objects/sliceobject.c - slice_methods -
+Objects/structseq.c - structseq_methods -
+Objects/tupleobject.c - tuple_methods -
+Objects/tupleobject.c - tupleiter_methods -
+Objects/typeobject.c - type_methods -
+Objects/typeobject.c - object_methods -
+Objects/typeobject.c - tp_new_methoddef -
+Objects/unicodeobject.c - encoding_map_methods -
+Objects/unicodeobject.c - unicode_methods -
+Objects/unicodeobject.c - unicodeiter_methods -
+Objects/unicodeobject.c - _string_methods -
+Objects/unionobject.c - union_methods -
+Objects/weakrefobject.c - weakref_methods -
+Objects/weakrefobject.c - proxy_methods -
+Objects/stringlib/unicode_format.h - formatteriter_methods -
+Objects/stringlib/unicode_format.h - fieldnameiter_methods -
+Python/bltinmodule.c - filter_methods -
+Python/bltinmodule.c - map_methods -
+Python/bltinmodule.c - zip_methods -
+Python/bltinmodule.c - builtin_methods -
+Python/context.c - PyContext_methods -
+Python/context.c - PyContextVar_methods -
+Python/context.c - PyContextTokenType_methods -
+Python/hamt.c - PyHamt_methods -
+Python/import.c - imp_methods -
+Python/marshal.c - marshal_methods -
+Python/Python-ast.c - ast_type_methods -
+Python/sysmodule.c - sys_methods -
+Python/traceback.c - tb_methods -
+Python/_warnings.c - warnings_functions -
+
+#-----------------------
+# PyMemberDef[], for static types and strucseq
+# []
+
+Modules/_bz2module.c - BZ2Decompressor_members -
+Modules/cjkcodecs/multibytecodec.c - mbstreamreader_members -
+Modules/cjkcodecs/multibytecodec.c - mbstreamwriter_members -
+Modules/_collectionsmodule.c - defdict_members -
+Modules/_collectionsmodule.c - tuplegetter_members -
+Modules/_csv.c - Dialect_memberlist -
+Modules/_csv.c - Reader_memberlist -
+Modules/_csv.c - Writer_memberlist -
+Modules/_ctypes/callproc.c - PyCArgType_members -
+Modules/_ctypes/_ctypes.c - PyCData_members -
+Modules/_datetimemodule.c - delta_members -
+Modules/_elementtree.c - xmlparser_members -
+Modules/_functoolsmodule.c - partial_memberlist -
+Modules/_functoolsmodule.c - keyobject_members -
+Modules/_io/bufferedio.c - bufferedreader_members -
+Modules/_io/bufferedio.c - bufferedwriter_members -
+Modules/_io/bufferedio.c - bufferedrandom_members -
+Modules/_io/fileio.c - fileio_members -
+Modules/_io/textio.c - textiowrapper_members -
+Modules/_io/winconsoleio.c - winconsoleio_members -
+Modules/_json.c - scanner_members -
+Modules/_json.c - encoder_members -
+Modules/_lzmamodule.c - Decompressor_members -
+Modules/_multiprocessing/semaphore.c - semlock_members -
+Modules/ossaudiodev.c - oss_members -
+Modules/overlapped.c - Overlapped_members -
+Modules/_pickle.c - Pickler_members -
+Modules/posixmodule.c - DirEntry_members -
+Modules/pyexpat.c - xmlparse_members -
+Modules/selectmodule.c - kqueue_event_members -
+Modules/sha256module.c - SHA_members -
+Modules/sha512module.c - SHA_members -
+Modules/socketmodule.c - sock_memberlist -
+Modules/_sqlite/connection.c - connection_members -
+Modules/_sqlite/cursor.c - cursor_members -
+Modules/_sqlite/statement.c - stmt_members -
+Modules/_sre.c - pattern_members -
+Modules/_sre.c - match_members -
+Modules/_sre.c - scanner_members -
+Modules/_struct.c - s_members -
+Modules/unicodedata.c - DB_members -
+Modules/_winapi.c - overlapped_members -
+Modules/xxsubtype.c - spamdict_members -
+Modules/zlibmodule.c - Decomp_members -
+Modules/_zoneinfo.c - zoneinfo_members -
+Objects/classobject.c - method_memberlist -
+Objects/classobject.c - instancemethod_memberlist -
+Objects/codeobject.c - code_memberlist -
+Objects/complexobject.c - complex_members -
+Objects/descrobject.c - descr_members -
+Objects/descrobject.c - wrapper_members -
+Objects/descrobject.c - property_members -
+Objects/exceptions.c - BaseException_members -
+Objects/exceptions.c - StopIteration_members -
+Objects/exceptions.c - SystemExit_members -
+Objects/exceptions.c - ImportError_members -
+Objects/exceptions.c - OSError_members -
+Objects/exceptions.c - SyntaxError_members -
+Objects/exceptions.c - UnicodeError_members -
+Objects/frameobject.c - frame_memberlist -
+Objects/funcobject.c - func_memberlist -
+Objects/funcobject.c - cm_memberlist -
+Objects/funcobject.c - sm_memberlist -
+Objects/genericaliasobject.c - ga_members -
+Objects/genobject.c - gen_memberlist -
+Objects/genobject.c - coro_memberlist -
+Objects/genobject.c - async_gen_memberlist -
+Objects/methodobject.c - meth_members -
+Objects/moduleobject.c - module_members -
+Objects/namespaceobject.c - namespace_members -
+Objects/rangeobject.c - range_members -
+Objects/sliceobject.c - slice_members -
+Objects/typeobject.c - type_members -
+Objects/typeobject.c - super_members -
+Objects/unionobject.c - union_members -
+Objects/weakrefobject.c - weakref_members -
+Python/context.c - PyContextVar_members -
+Python/Python-ast.c - ast_type_members -
+Python/symtable.c - ste_memberlist -
+Python/traceback.c - tb_memberlist -
+
+#-----------------------
+# for static types
+# []
+
+# PyNumberMethods []
+Modules/_collectionsmodule.c - deque_as_number -
+Modules/_collectionsmodule.c - defdict_as_number -
+Modules/_ctypes/_ctypes.c - PyCFuncPtr_as_number -
+Modules/_ctypes/_ctypes.c - Simple_as_number -
+Modules/_ctypes/_ctypes.c - Pointer_as_number -
+Modules/_datetimemodule.c - delta_as_number -
+Modules/_datetimemodule.c - date_as_number -
+Modules/_datetimemodule.c - datetime_as_number -
+Modules/_decimal/_decimal.c - dec_number_methods -
+Modules/_xxsubinterpretersmodule.c - channelid_as_number -
+Objects/boolobject.c - bool_as_number -
+Objects/bytearrayobject.c - bytearray_as_number -
+Objects/bytesobject.c - bytes_as_number -
+Objects/complexobject.c - complex_as_number -
+Objects/descrobject.c - mappingproxy_as_number -
+Objects/dictobject.c - dict_as_number -
+Objects/dictobject.c - dictviews_as_number -
+Objects/floatobject.c - float_as_number -
+Objects/interpreteridobject.c - interpid_as_number -
+Objects/longobject.c - long_as_number -
+Objects/object.c - none_as_number -
+Objects/object.c - notimplemented_as_number -
+Objects/odictobject.c - odict_as_number -
+Objects/rangeobject.c - range_as_number -
+Objects/setobject.c - set_as_number -
+Objects/setobject.c - frozenset_as_number -
+Objects/typeobject.c - type_as_number -
+Objects/unicodeobject.c - unicode_as_number -
+Objects/unionobject.c - union_as_number -
+Objects/weakrefobject.c - proxy_as_number -
+
+# PySequenceMethods []
+Modules/arraymodule.c - array_as_sequence -
+Modules/_collectionsmodule.c - deque_as_sequence -
+Modules/_ctypes/_ctypes.c - CDataType_as_sequence -
+Modules/_ctypes/_ctypes.c - Array_as_sequence -
+Modules/_ctypes/_ctypes.c - Pointer_as_sequence -
+Modules/_elementtree.c - element_as_sequence -
+Modules/mmapmodule.c - mmap_as_sequence -
+Objects/bytearrayobject.c - bytearray_as_sequence -
+Objects/bytesobject.c - bytes_as_sequence -
+Objects/descrobject.c - mappingproxy_as_sequence -
+Objects/dictobject.c - dict_as_sequence -
+Objects/dictobject.c - dictkeys_as_sequence -
+Objects/dictobject.c - dictitems_as_sequence -
+Objects/dictobject.c - dictvalues_as_sequence -
+Objects/listobject.c - list_as_sequence -
+Objects/memoryobject.c - memory_as_sequence -
+Objects/rangeobject.c - range_as_sequence -
+Objects/setobject.c - set_as_sequence -
+Objects/tupleobject.c - tuple_as_sequence -
+Objects/unicodeobject.c - unicode_as_sequence -
+Objects/weakrefobject.c - proxy_as_sequence -
+Python/context.c - PyContext_as_sequence -
+Python/hamt.c - PyHamt_as_sequence -
+
+# PyMappingMethods []
+Modules/arraymodule.c - array_as_mapping -
+Modules/_ctypes/_ctypes.c - Array_as_mapping -
+Modules/_ctypes/_ctypes.c - Pointer_as_mapping -
+Modules/_decimal/_decimal.c - signaldict_as_mapping -
+Modules/_elementtree.c - element_as_mapping -
+Modules/mmapmodule.c - mmap_as_mapping -
+Modules/_sre.c - match_as_mapping -
+Objects/bytearrayobject.c - bytearray_as_mapping -
+Objects/bytesobject.c - bytes_as_mapping -
+Objects/descrobject.c - mappingproxy_as_mapping -
+Objects/dictobject.c - dict_as_mapping -
+Objects/genericaliasobject.c - ga_as_mapping -
+Objects/listobject.c - list_as_mapping -
+Objects/memoryobject.c - memory_as_mapping -
+Objects/odictobject.c - odict_as_mapping -
+Objects/rangeobject.c - range_as_mapping -
+Objects/tupleobject.c - tuple_as_mapping -
+Objects/unicodeobject.c - unicode_as_mapping -
+Objects/weakrefobject.c - proxy_as_mapping -
+Python/context.c - PyContext_as_mapping -
+Python/hamt.c - PyHamtIterator_as_mapping -
+Python/hamt.c - PyHamt_as_mapping -
+
+# PyAsyncMethods []
+Modules/_asynciomodule.c - FutureType_as_async -
+Objects/genobject.c - coro_as_async -
+Objects/genobject.c - async_gen_as_async -
+Objects/genobject.c - async_gen_asend_as_async -
+Objects/genobject.c - async_gen_athrow_as_async -
+
+# PyBufferProcs []
+Modules/arraymodule.c - array_as_buffer -
+Modules/_ctypes/_ctypes.c - PyCData_as_buffer -
+Modules/_io/bytesio.c - bytesiobuf_as_buffer -
+Modules/mmapmodule.c - mmap_as_buffer -
+Objects/bytearrayobject.c - bytearray_as_buffer -
+Objects/bytesobject.c - bytes_as_buffer -
+Objects/memoryobject.c - memory_as_buffer -
+Objects/picklebufobject.c - picklebuf_as_buffer -
+
+# PyGetSetDef []
+Modules/arraymodule.c - array_getsets -
+Modules/_asynciomodule.c - FutureType_getsetlist -
+Modules/_asynciomodule.c - TaskStepMethWrapper_getsetlist -
+Modules/_asynciomodule.c - TaskType_getsetlist -
+Modules/_blake2/blake2b_impl.c - py_blake2b_getsetters -
+Modules/_blake2/blake2s_impl.c - py_blake2s_getsetters -
+Modules/cjkcodecs/multibytecodec.c - codecctx_getsets -
+Modules/_collectionsmodule.c - deque_getset -
+Modules/_csv.c - Dialect_getsetlist -
+Modules/_ctypes/cfield.c - PyCField_getset -
+Modules/_ctypes/_ctypes.c - CharArray_getsets -
+Modules/_ctypes/_ctypes.c - WCharArray_getsets -
+Modules/_ctypes/_ctypes.c - PyCFuncPtr_getsets -
+Modules/_ctypes/_ctypes.c - Simple_getsets -
+Modules/_ctypes/_ctypes.c - Pointer_getsets -
+Modules/_cursesmodule.c - PyCursesWindow_getsets -
+Modules/_datetimemodule.c - date_getset -
+Modules/_datetimemodule.c - iso_calendar_date_getset -
+Modules/_datetimemodule.c - time_getset -
+Modules/_datetimemodule.c - datetime_getset -
+Modules/_decimal/_decimal.c - context_getsets -
+Modules/_decimal/_decimal.c - dec_getsets -
+Modules/_elementtree.c - xmlparser_getsetlist -
+Modules/_elementtree.c - element_getsetlist -
+Modules/_functoolsmodule.c - partial_getsetlist -
+Modules/_functoolsmodule.c - lru_cache_getsetlist -
+Modules/_hashopenssl.c - EVP_getseters -
+Modules/_hashopenssl.c - EVPXOF_getseters -
+Modules/_hashopenssl.c - HMAC_getset -
+Modules/_io/bufferedio.c - bufferedreader_getset -
+Modules/_io/bufferedio.c - bufferedwriter_getset -
+Modules/_io/bufferedio.c - bufferedrwpair_getset -
+Modules/_io/bufferedio.c - bufferedrandom_getset -
+Modules/_io/bytesio.c - bytesio_getsetlist -
+Modules/_io/fileio.c - fileio_getsetlist -
+Modules/_io/iobase.c - iobase_getset -
+Modules/_io/stringio.c - stringio_getset -
+Modules/_io/textio.c - textiobase_getset -
+Modules/_io/textio.c - incrementalnewlinedecoder_getset -
+Modules/_io/textio.c - textiowrapper_getset -
+Modules/_io/winconsoleio.c - winconsoleio_getsetlist -
+Modules/md5module.c - MD5_getseters -
+Modules/mmapmodule.c - mmap_object_getset -
+Modules/ossaudiodev.c - oss_getsetlist -
+Modules/overlapped.c - Overlapped_getsets -
+Modules/_pickle.c - Pickler_getsets -
+Modules/_pickle.c - Unpickler_getsets -
+Modules/pyexpat.c - xmlparse_getsetlist -
+Modules/selectmodule.c - devpoll_getsetlist -
+Modules/selectmodule.c - pyepoll_getsetlist -
+Modules/selectmodule.c - kqueue_queue_getsetlist -
+Modules/sha1module.c - SHA1_getseters -
+Modules/sha256module.c - SHA_getseters -
+Modules/_sha3/sha3module.c - SHA3_getseters -
+Modules/sha512module.c - SHA_getseters -
+Modules/socketmodule.c - sock_getsetlist -
+Modules/_sqlite/connection.c - connection_getset -
+Modules/_sre.c - pattern_getset -
+Modules/_sre.c - match_getset -
+Modules/_ssl.c - ssl_getsetlist -
+Modules/_ssl.c - context_getsetlist -
+Modules/_ssl.c - memory_bio_getsetlist -
+Modules/_ssl.c - PySSLSession_getsetlist -
+Modules/_struct.c - s_getsetlist -
+Modules/_tkinter.c - PyTclObject_getsetlist -
+Modules/_xxsubinterpretersmodule.c - channelid_getsets -
+Modules/xxsubtype.c - spamlist_getsets -
+Objects/cellobject.c - cell_getsetlist -
+Objects/classobject.c - method_getset -
+Objects/classobject.c - instancemethod_getset -
+Objects/descrobject.c - method_getset -
+Objects/descrobject.c - member_getset -
+Objects/descrobject.c - getset_getset -
+Objects/descrobject.c - wrapperdescr_getset -
+Objects/descrobject.c - wrapper_getsets -
+Objects/descrobject.c - property_getsetlist -
+Objects/dictobject.c - dictview_getset -
+Objects/exceptions.c - BaseException_getset -
+Objects/exceptions.c - OSError_getset -
+Objects/fileobject.c - stdprinter_getsetlist -
+Objects/floatobject.c - float_getset -
+Objects/frameobject.c - frame_getsetlist -
+Objects/funcobject.c - func_getsetlist -
+Objects/funcobject.c - cm_getsetlist -
+Objects/funcobject.c - sm_getsetlist -
+Objects/genericaliasobject.c - ga_properties -
+Objects/genobject.c - gen_getsetlist -
+Objects/genobject.c - coro_getsetlist -
+Objects/genobject.c - async_gen_getsetlist -
+Objects/longobject.c - long_getset -
+Objects/memoryobject.c - memory_getsetlist -
+Objects/methodobject.c - meth_getsets -
+Objects/odictobject.c - odict_getset -
+Objects/typeobject.c - type_getsets -
+Objects/typeobject.c - subtype_getsets_full -
+Objects/typeobject.c - subtype_getsets_dict_only -
+Objects/typeobject.c - subtype_getsets_weakref_only -
+Objects/typeobject.c - object_getsets -
+Python/context.c - PyContextTokenType_getsetlist -
+Python/Python-ast.c - ast_type_getsets -
+Python/traceback.c - tb_getsetters -
+
+#-----------------------
+# for heap types
+# []
+
+# PyType_Slot []
+Modules/_abc.c - _abc_data_type_spec_slots -
+Modules/_blake2/blake2b_impl.c - blake2b_type_slots -
+Modules/_blake2/blake2s_impl.c - blake2s_type_slots -
+Modules/_bz2module.c - bz2_compressor_type_slots -
+Modules/_bz2module.c - bz2_decompressor_type_slots -
+Modules/_curses_panel.c - PyCursesPanel_Type_slots -
+Modules/_dbmmodule.c - dbmtype_spec_slots -
+Modules/_gdbmmodule.c - gdbmtype_spec_slots -
+Modules/_hashopenssl.c - EVPtype_slots -
+Modules/_hashopenssl.c - EVPXOFtype_slots -
+Modules/_hashopenssl.c - HMACtype_slots -
+Modules/_json.c - PyScannerType_slots -
+Modules/_json.c - PyEncoderType_slots -
+Modules/_lsprof.c - _lsprof_profiler_type_spec_slots -
+Modules/_lzmamodule.c - lzma_compressor_type_slots -
+Modules/_lzmamodule.c - lzma_decompressor_type_slots -
+Modules/md5module.c - md5_type_slots -
+Modules/_operator.c - itemgetter_type_slots -
+Modules/_operator.c - attrgetter_type_slots -
+Modules/_operator.c - methodcaller_type_slots -
+Modules/overlapped.c - overlapped_type_slots -
+Modules/posixmodule.c - DirEntryType_slots -
+Modules/posixmodule.c - ScandirIteratorType_slots -
+Modules/_randommodule.c - Random_Type_slots -
+Modules/selectmodule.c - devpoll_Type_slots -
+Modules/selectmodule.c - kqueue_event_Type_slots -
+Modules/selectmodule.c - poll_Type_slots -
+Modules/selectmodule.c - pyEpoll_Type_slots -
+Modules/selectmodule.c - kqueue_queue_Type_slots -
+Modules/sha1module.c - sha1_type_slots -
+Modules/sha256module.c - sha256_types_slots -
+Modules/_sha3/sha3module.c - sha3_224_slots -
+Modules/_sha3/sha3module.c - sha3_256_slots -
+Modules/_sha3/sha3module.c - sha3_384_slots -
+Modules/_sha3/sha3module.c - sha3_512_slots -
+Modules/_sha3/sha3module.c - SHAKE128slots -
+Modules/_sha3/sha3module.c - SHAKE256slots -
+Modules/_sha3/sha3module.c - type_slots_obj -
+Modules/sha512module.c - sha512_sha384_type_slots -
+Modules/sha512module.c - sha512_sha512_type_slots -
+Modules/_sqlite/cache.c - pysqlite_NodeType_slots -
+Modules/_sqlite/cache.c - pysqlite_CacheType_slots -
+Modules/_sqlite/connection.c - connection_slots -
+Modules/_sqlite/cursor.c - cursor_slots -
+Modules/_sqlite/prepare_protocol.c - type_slots -
+Modules/_sqlite/row.c - row_slots -
+Modules/_sqlite/statement.c - stmt_slots -
+Modules/_ssl.c - sslerror_type_slots -
+Modules/_struct.c - unpackiter_type_slots -
+Modules/_struct.c - PyStructType_slots -
+Modules/_tkinter.c - PyTclObject_Type_slots -
+Modules/_tkinter.c - Tktt_Type_slots -
+Modules/_tkinter.c - Tkapp_Type_slots -
+Modules/unicodedata.c - ucd_type_slots -
+Modules/_winapi.c - winapi_overlapped_type_slots -
+Modules/xxlimited.c - Xxo_Type_slots -
+Modules/xxlimited.c - Str_Type_slots -
+Modules/xxlimited.c - Null_Type_slots -
+Modules/zlibmodule.c - Comptype_slots -
+Modules/zlibmodule.c - Decomptype_slots -
+Python/Python-ast.c - AST_type_slots -
+
+# PyType_Spec []
+Modules/_abc.c - _abc_data_type_spec -
+Modules/_blake2/blake2b_impl.c - blake2b_type_spec -
+Modules/_blake2/blake2s_impl.c - blake2s_type_spec -
+Modules/_bz2module.c - bz2_compressor_type_spec -
+Modules/_bz2module.c - bz2_decompressor_type_spec -
+Modules/_curses_panel.c - PyCursesPanel_Type_spec -
+Modules/_dbmmodule.c - dbmtype_spec -
+Modules/_gdbmmodule.c - gdbmtype_spec -
+Modules/_hashopenssl.c - EVPtype_spec -
+Modules/_hashopenssl.c - EVPXOFtype_spec -
+Modules/_hashopenssl.c - HMACtype_spec -
+Modules/_json.c - PyScannerType_spec -
+Modules/_json.c - PyEncoderType_spec -
+Modules/_lsprof.c - _lsprof_profiler_type_spec -
+Modules/_lzmamodule.c - lzma_compressor_type_spec -
+Modules/_lzmamodule.c - lzma_decompressor_type_spec -
+Modules/_operator.c - itemgetter_type_spec -
+Modules/_operator.c - attrgetter_type_spec -
+Modules/_operator.c - methodcaller_type_spec -
+Modules/_randommodule.c - Random_Type_spec -
+Modules/_sha3/sha3module.c - sha3_224_spec -
+Modules/_sha3/sha3module.c - sha3_256_spec -
+Modules/_sha3/sha3module.c - sha3_384_spec -
+Modules/_sha3/sha3module.c - sha3_512_spec -
+Modules/_sha3/sha3module.c - SHAKE128_spec -
+Modules/_sha3/sha3module.c - SHAKE256_spec -
+Modules/_sha3/sha3module.c - type_spec_obj -
+Modules/_sqlite/cache.c - pysqlite_NodeType_spec -
+Modules/_sqlite/cache.c - pysqlite_CacheType_spec -
+Modules/_sqlite/connection.c - connection_spec -
+Modules/_sqlite/cursor.c - cursor_spec -
+Modules/_sqlite/prepare_protocol.c - type_spec -
+Modules/_sqlite/row.c - row_spec -
+Modules/_sqlite/statement.c - stmt_spec -
+Modules/_ssl.c - sslerror_type_spec -
+Modules/_struct.c - unpackiter_type_spec -
+Modules/_struct.c - PyStructType_spec -
+Modules/_tkinter.c - PyTclObject_Type_spec -
+Modules/_tkinter.c - Tktt_Type_spec -
+Modules/_tkinter.c - Tkapp_Type_spec -
+Modules/_winapi.c - winapi_overlapped_type_spec -
+Modules/_zoneinfo.c - DAYS_IN_MONTH -
+Modules/_zoneinfo.c - DAYS_BEFORE_MONTH -
+Modules/md5module.c - md5_type_spec -
+Modules/overlapped.c - overlapped_type_spec -
+Modules/posixmodule.c - DirEntryType_spec -
+Modules/posixmodule.c - ScandirIteratorType_spec -
+Modules/selectmodule.c - devpoll_Type_spec -
+Modules/selectmodule.c - kqueue_event_Type_spec -
+Modules/selectmodule.c - poll_Type_spec -
+Modules/selectmodule.c - pyEpoll_Type_spec -
+Modules/selectmodule.c - kqueue_queue_Type_spec -
+Modules/sha1module.c - sha1_type_spec -
+Modules/sha256module.c - sha224_type_spec -
+Modules/sha256module.c - sha256_type_spec -
+Modules/sha512module.c - sha512_sha384_type_spec -
+Modules/sha512module.c - sha512_sha512_type_spec -
+Modules/unicodedata.c - ucd_type_spec -
+Modules/xxlimited.c - Xxo_Type_spec -
+Modules/xxlimited.c - Str_Type_spec -
+Modules/xxlimited.c - Null_Type_spec -
+Modules/zlibmodule.c - Comptype_spec -
+Modules/zlibmodule.c - Decomptype_spec -
+Python/Python-ast.c - AST_type_spec -
+
+#-----------------------
+# for structseq
+# []
+
+# PyStructSequence_Field[] []
+Modules/_cursesmodule.c - ncurses_version_fields -
+Modules/grpmodule.c - struct_group_type_fields -
+Modules/_lsprof.c - profiler_entry_fields -
+Modules/_lsprof.c - profiler_subentry_fields -
+Modules/posixmodule.c - stat_result_fields -
+Modules/posixmodule.c - statvfs_result_fields -
+Modules/posixmodule.c - waitid_result_fields -
+Modules/posixmodule.c - uname_result_fields -
+Modules/posixmodule.c - sched_param_fields -
+Modules/posixmodule.c - times_result_fields -
+Modules/posixmodule.c - TerminalSize_fields -
+Modules/pwdmodule.c - struct_pwd_type_fields -
+Modules/resource.c - struct_rusage_fields -
+Modules/signalmodule.c - struct_siginfo_fields -
+Modules/spwdmodule.c - struct_spwd_type_fields -
+Modules/_threadmodule.c - ExceptHookArgs_fields -
+Modules/timemodule.c - struct_time_type_fields -
+Objects/floatobject.c - floatinfo_fields -
+Objects/longobject.c - int_info_fields -
+Python/errors.c - UnraisableHookArgs_fields -
+Python/sysmodule.c - asyncgen_hooks_fields -
+Python/sysmodule.c - hash_info_fields -
+Python/sysmodule.c - windows_version_fields -
+Python/sysmodule.c - flags_fields -
+Python/sysmodule.c - version_info_fields -
+Python/thread.c - threadinfo_fields -
+
+# PyStructSequence_Desc []
+Modules/_cursesmodule.c - ncurses_version_desc -
+Modules/grpmodule.c - struct_group_type_desc -
+Modules/_lsprof.c - profiler_entry_desc -
+Modules/_lsprof.c - profiler_subentry_desc -
+Modules/posixmodule.c - stat_result_desc -
+Modules/posixmodule.c - statvfs_result_desc -
+Modules/posixmodule.c - waitid_result_desc -
+Modules/posixmodule.c - uname_result_desc -
+Modules/posixmodule.c - sched_param_desc -
+Modules/posixmodule.c - times_result_desc -
+Modules/posixmodule.c - TerminalSize_desc -
+Modules/pwdmodule.c - struct_pwd_type_desc -
+Modules/resource.c - struct_rusage_desc -
+Modules/signalmodule.c - struct_siginfo_desc -
+Modules/spwdmodule.c - struct_spwd_type_desc -
+Modules/_threadmodule.c - ExceptHookArgs_desc -
+Modules/timemodule.c - struct_time_type_desc -
+Objects/floatobject.c - floatinfo_desc -
+Objects/longobject.c - int_info_desc -
+Python/errors.c - UnraisableHookArgs_desc -
+Python/sysmodule.c - asyncgen_hooks_desc -
+Python/sysmodule.c - hash_info_desc -
+Python/sysmodule.c - windows_version_desc -
+Python/sysmodule.c - flags_desc -
+Python/sysmodule.c - version_info_desc -
+Python/thread.c - threadinfo_desc -
+
+#-----------------------
+# _PyArg_Parser
+# []
+
+Modules/clinic/md5module.c.h MD5Type_copy _parser -
+Modules/clinic/md5module.c.h _md5_md5 _parser -
+Modules/clinic/_dbmmodule.c.h _dbm_dbm_keys _parser -
+Modules/clinic/_dbmmodule.c.h _dbm_dbm_get _parser -
+Modules/clinic/_dbmmodule.c.h _dbm_dbm_setdefault _parser -
+Modules/clinic/posixmodule.c.h os_stat _parser -
+Modules/clinic/posixmodule.c.h os_lstat _parser -
+Modules/clinic/posixmodule.c.h os_access _parser -
+Modules/clinic/posixmodule.c.h os_chdir _parser -
+Modules/clinic/posixmodule.c.h os_chmod _parser -
+Modules/clinic/posixmodule.c.h os_listdir _parser -
+Modules/clinic/posixmodule.c.h os_mkdir _parser -
+Modules/clinic/posixmodule.c.h os_rename _parser -
+Modules/clinic/posixmodule.c.h os_replace _parser -
+Modules/clinic/posixmodule.c.h os_rmdir _parser -
+Modules/clinic/posixmodule.c.h os_unlink _parser -
+Modules/clinic/posixmodule.c.h os_remove _parser -
+Modules/clinic/posixmodule.c.h os_utime _parser -
+Modules/clinic/posixmodule.c.h os__exit _parser -
+Modules/clinic/posixmodule.c.h os_open _parser -
+Modules/clinic/posixmodule.c.h os_close _parser -
+Modules/clinic/posixmodule.c.h os_dup2 _parser -
+Modules/clinic/posixmodule.c.h os_fstat _parser -
+Modules/clinic/posixmodule.c.h os_device_encoding _parser -
+Modules/clinic/posixmodule.c.h os_DirEntry_is_symlink _parser -
+Modules/clinic/posixmodule.c.h os_DirEntry_stat _parser -
+Modules/clinic/posixmodule.c.h os_DirEntry_is_dir _parser -
+Modules/clinic/posixmodule.c.h os_DirEntry_is_file _parser -
+Modules/clinic/posixmodule.c.h os_scandir _parser -
+Modules/clinic/posixmodule.c.h os_fspath _parser -
+Modules/clinic/cmathmodule.c.h cmath_isclose _parser -
+Modules/clinic/sha256module.c.h SHA256Type_copy _parser -
+Modules/clinic/sha256module.c.h _sha256_sha256 _parser -
+Modules/clinic/sha256module.c.h _sha256_sha224 _parser -
+Modules/clinic/_hashopenssl.c.h EVP_new _parser -
+Modules/clinic/_hashopenssl.c.h _hashlib_openssl_md5 _parser -
+Modules/clinic/_hashopenssl.c.h _hashlib_openssl_sha1 _parser -
+Modules/clinic/_hashopenssl.c.h _hashlib_openssl_sha224 _parser -
+Modules/clinic/_hashopenssl.c.h _hashlib_openssl_sha256 _parser -
+Modules/clinic/_hashopenssl.c.h _hashlib_openssl_sha384 _parser -
+Modules/clinic/_hashopenssl.c.h _hashlib_openssl_sha512 _parser -
+Modules/clinic/_hashopenssl.c.h pbkdf2_hmac _parser -
+Modules/clinic/_hashopenssl.c.h _hashlib_hmac_singleshot _parser -
+Modules/clinic/_hashopenssl.c.h _hashlib_hmac_new _parser -
+Modules/clinic/_hashopenssl.c.h _hashlib_HMAC_update _parser -
+Modules/clinic/_ssl.c.h _ssl__SSLSocket_get_channel_binding _parser -
+Modules/clinic/_ssl.c.h _ssl__SSLContext_load_cert_chain _parser -
+Modules/clinic/_ssl.c.h _ssl__SSLContext_load_verify_locations _parser -
+Modules/clinic/_ssl.c.h _ssl__SSLContext__wrap_socket _parser -
+Modules/clinic/_ssl.c.h _ssl__SSLContext__wrap_bio _parser -
+Modules/clinic/_ssl.c.h _ssl__SSLContext_get_ca_certs _parser -
+Modules/clinic/_ssl.c.h _ssl_txt2obj _parser -
+Modules/clinic/_queuemodule.c.h _queue_SimpleQueue_put _parser -
+Modules/clinic/_queuemodule.c.h _queue_SimpleQueue_put_nowait _parser -
+Modules/clinic/_queuemodule.c.h _queue_SimpleQueue_get _parser -
+Modules/clinic/_lsprof.c.h _lsprof_Profiler_getstats _parser -
+Modules/clinic/_datetimemodule.c.h iso_calendar_date_new _parser -
+Modules/clinic/_datetimemodule.c.h datetime_datetime_now _parser -
+Modules/clinic/_opcode.c.h _opcode_stack_effect _parser -
+Modules/clinic/_lzmamodule.c.h _lzma_LZMADecompressor_decompress _parser -
+Modules/clinic/_lzmamodule.c.h _lzma_LZMADecompressor___init__ _parser -
+Modules/clinic/pyexpat.c.h pyexpat_ParserCreate _parser -
+Modules/clinic/mathmodule.c.h math_isclose _parser -
+Modules/clinic/mathmodule.c.h math_prod _parser -
+Modules/clinic/_curses_panel.c.h _curses_panel_panel_bottom _parser -
+Modules/clinic/_curses_panel.c.h _curses_panel_panel_hide _parser -
+Modules/clinic/_curses_panel.c.h _curses_panel_panel_show _parser -
+Modules/clinic/_curses_panel.c.h _curses_panel_panel_top _parser -
+Modules/clinic/_curses_panel.c.h _curses_panel_panel_move _parser -
+Modules/clinic/_curses_panel.c.h _curses_panel_panel_replace _parser -
+Modules/clinic/_curses_panel.c.h _curses_panel_panel_set_userptr _parser -
+Modules/clinic/_curses_panel.c.h _curses_panel_panel_userptr _parser -
+Modules/clinic/_elementtree.c.h _elementtree_Element_find _parser -
+Modules/clinic/_elementtree.c.h _elementtree_Element_findtext _parser -
+Modules/clinic/_elementtree.c.h _elementtree_Element_findall _parser -
+Modules/clinic/_elementtree.c.h _elementtree_Element_iterfind _parser -
+Modules/clinic/_elementtree.c.h _elementtree_Element_get _parser -
+Modules/clinic/_elementtree.c.h _elementtree_Element_iter _parser -
+Modules/clinic/_elementtree.c.h _elementtree_TreeBuilder___init__ _parser -
+Modules/clinic/_elementtree.c.h _elementtree_XMLParser___init__ _parser -
+Modules/clinic/_asynciomodule.c.h _asyncio_Future___init__ _parser -
+Modules/clinic/_asynciomodule.c.h _asyncio_Future_add_done_callback _parser -
+Modules/clinic/_asynciomodule.c.h _asyncio_Future_cancel _parser -
+Modules/clinic/_asynciomodule.c.h _asyncio_Task___init__ _parser -
+Modules/clinic/_asynciomodule.c.h _asyncio_Task_cancel _parser -
+Modules/clinic/_asynciomodule.c.h _asyncio_Task_get_stack _parser -
+Modules/clinic/_asynciomodule.c.h _asyncio_Task_print_stack _parser -
+Modules/clinic/_asynciomodule.c.h _asyncio__register_task _parser -
+Modules/clinic/_asynciomodule.c.h _asyncio__unregister_task _parser -
+Modules/clinic/_asynciomodule.c.h _asyncio__enter_task _parser -
+Modules/clinic/_asynciomodule.c.h _asyncio__leave_task _parser -
+Modules/clinic/gcmodule.c.h gc_collect _parser -
+Modules/clinic/gcmodule.c.h gc_get_objects _parser -
+Modules/clinic/grpmodule.c.h grp_getgrgid _parser -
+Modules/clinic/grpmodule.c.h grp_getgrnam _parser -
+Modules/clinic/_pickle.c.h _pickle_Pickler___init__ _parser -
+Modules/clinic/_pickle.c.h _pickle_Unpickler___init__ _parser -
+Modules/clinic/_pickle.c.h _pickle_dump _parser -
+Modules/clinic/_pickle.c.h _pickle_dumps _parser -
+Modules/clinic/_pickle.c.h _pickle_load _parser -
+Modules/clinic/_pickle.c.h _pickle_loads _parser -
+Modules/clinic/_struct.c.h Struct___init__ _parser -
+Modules/clinic/_struct.c.h Struct_unpack_from _parser -
+Modules/clinic/_struct.c.h unpack_from _parser -
+Modules/clinic/_testmultiphase.c.h _testmultiphase_StateAccessType_get_defining_module _parser -
+Modules/clinic/_testmultiphase.c.h _testmultiphase_StateAccessType_increment_count_clinic _parser -
+Modules/clinic/_testmultiphase.c.h _testmultiphase_StateAccessType_get_count _parser -
+Modules/clinic/_gdbmmodule.c.h _gdbm_gdbm_keys _parser -
+Modules/clinic/_gdbmmodule.c.h _gdbm_gdbm_firstkey _parser -
+Modules/clinic/_gdbmmodule.c.h _gdbm_gdbm_nextkey _parser -
+Modules/clinic/_gdbmmodule.c.h _gdbm_gdbm_reorganize _parser -
+Modules/clinic/_gdbmmodule.c.h _gdbm_gdbm_sync _parser -
+Modules/clinic/_sre.c.h _sre_SRE_Pattern_match _parser -
+Modules/clinic/_sre.c.h _sre_SRE_Pattern_fullmatch _parser -
+Modules/clinic/_sre.c.h _sre_SRE_Pattern_search _parser -
+Modules/clinic/_sre.c.h _sre_SRE_Pattern_findall _parser -
+Modules/clinic/_sre.c.h _sre_SRE_Pattern_finditer _parser -
+Modules/clinic/_sre.c.h _sre_SRE_Pattern_scanner _parser -
+Modules/clinic/_sre.c.h _sre_SRE_Pattern_split _parser -
+Modules/clinic/_sre.c.h _sre_SRE_Pattern_sub _parser -
+Modules/clinic/_sre.c.h _sre_SRE_Pattern_subn _parser -
+Modules/clinic/_sre.c.h _sre_compile _parser -
+Modules/clinic/_sre.c.h _sre_SRE_Match_expand _parser -
+Modules/clinic/_sre.c.h _sre_SRE_Match_groups _parser -
+Modules/clinic/_sre.c.h _sre_SRE_Match_groupdict _parser -
+Modules/clinic/overlapped.c.h _overlapped_Overlapped _parser -
+Modules/clinic/_bisectmodule.c.h _bisect_bisect_right _parser -
+Modules/clinic/_bisectmodule.c.h _bisect_insort_right _parser -
+Modules/clinic/_bisectmodule.c.h _bisect_bisect_left _parser -
+Modules/clinic/_bisectmodule.c.h _bisect_insort_left _parser -
+Modules/clinic/zlibmodule.c.h zlib_compress _parser -
+Modules/clinic/zlibmodule.c.h zlib_decompress _parser -
+Modules/clinic/zlibmodule.c.h zlib_compressobj _parser -
+Modules/clinic/zlibmodule.c.h zlib_decompressobj _parser -
+Modules/clinic/zlibmodule.c.h zlib_Compress_compress _parser -
+Modules/clinic/zlibmodule.c.h zlib_Decompress_decompress _parser -
+Modules/clinic/zlibmodule.c.h zlib_Compress_flush _parser -
+Modules/clinic/zlibmodule.c.h zlib_Decompress_flush _parser -
+Modules/clinic/sha512module.c.h SHA512Type_copy _parser -
+Modules/clinic/sha512module.c.h _sha512_sha512 _parser -
+Modules/clinic/sha512module.c.h _sha512_sha384 _parser -
+Modules/clinic/_bz2module.c.h _bz2_BZ2Decompressor_decompress _parser -
+Modules/clinic/sha1module.c.h SHA1Type_copy _parser -
+Modules/clinic/sha1module.c.h _sha1_sha1 _parser -
+Modules/clinic/_winapi.c.h _winapi_ConnectNamedPipe _parser -
+Modules/clinic/_winapi.c.h _winapi_ReadFile _parser -
+Modules/clinic/_winapi.c.h _winapi_WriteFile _parser -
+Modules/clinic/_winapi.c.h _winapi_GetFileType _parser -
+Modules/clinic/_codecsmodule.c.h _codecs_encode _parser -
+Modules/clinic/_codecsmodule.c.h _codecs_decode _parser -
+Modules/clinic/_cursesmodule.c.h _curses_setupterm _parser -
+Modules/clinic/itertoolsmodule.c.h itertools_groupby _parser -
+Modules/clinic/itertoolsmodule.c.h itertools_combinations _parser -
+Modules/clinic/itertoolsmodule.c.h itertools_combinations_with_replacement _parser -
+Modules/clinic/itertoolsmodule.c.h itertools_permutations _parser -
+Modules/clinic/itertoolsmodule.c.h itertools_accumulate _parser -
+Modules/clinic/itertoolsmodule.c.h itertools_compress _parser -
+Modules/clinic/itertoolsmodule.c.h itertools_count _parser -
+Modules/clinic/binascii.c.h binascii_b2a_uu _parser -
+Modules/clinic/binascii.c.h binascii_b2a_base64 _parser -
+Modules/clinic/binascii.c.h binascii_b2a_hex _parser -
+Modules/clinic/binascii.c.h binascii_hexlify _parser -
+Modules/clinic/binascii.c.h binascii_a2b_qp _parser -
+Modules/clinic/binascii.c.h binascii_b2a_qp _parser -
+Objects/clinic/enumobject.c.h enum_new _parser -
+Objects/clinic/bytearrayobject.c.h bytearray___init__ _parser -
+Objects/clinic/bytearrayobject.c.h bytearray_translate _parser -
+Objects/clinic/bytearrayobject.c.h bytearray_split _parser -
+Objects/clinic/bytearrayobject.c.h bytearray_rsplit _parser -
+Objects/clinic/bytearrayobject.c.h bytearray_decode _parser -
+Objects/clinic/bytearrayobject.c.h bytearray_splitlines _parser -
+Objects/clinic/bytearrayobject.c.h bytearray_hex _parser -
+Objects/clinic/descrobject.c.h mappingproxy_new _parser -
+Objects/clinic/descrobject.c.h property_init _parser -
+Objects/clinic/longobject.c.h long_new _parser -
+Objects/clinic/longobject.c.h int_to_bytes _parser -
+Objects/clinic/longobject.c.h int_from_bytes _parser -
+Objects/clinic/moduleobject.c.h module___init__ _parser -
+Objects/clinic/structseq.c.h structseq_new _parser -
+Objects/clinic/memoryobject.c.h memoryview _parser -
+Objects/clinic/memoryobject.c.h memoryview_cast _parser -
+Objects/clinic/memoryobject.c.h memoryview_tobytes _parser -
+Objects/clinic/memoryobject.c.h memoryview_hex _parser -
+Objects/clinic/listobject.c.h list_sort _parser -
+Objects/clinic/odictobject.c.h OrderedDict_fromkeys _parser -
+Objects/clinic/odictobject.c.h OrderedDict_setdefault _parser -
+Objects/clinic/odictobject.c.h OrderedDict_pop _parser -
+Objects/clinic/odictobject.c.h OrderedDict_popitem _parser -
+Objects/clinic/odictobject.c.h OrderedDict_move_to_end _parser -
+Objects/clinic/complexobject.c.h complex_new _parser -
+Objects/clinic/unicodeobject.c.h unicode_encode _parser -
+Objects/clinic/unicodeobject.c.h unicode_expandtabs _parser -
+Objects/clinic/unicodeobject.c.h unicode_split _parser -
+Objects/clinic/unicodeobject.c.h unicode_rsplit _parser -
+Objects/clinic/unicodeobject.c.h unicode_splitlines _parser -
+Objects/clinic/unicodeobject.c.h unicode_new _parser -
+Objects/clinic/bytesobject.c.h bytes_split _parser -
+Objects/clinic/bytesobject.c.h bytes_rsplit _parser -
+Objects/clinic/bytesobject.c.h bytes_translate _parser -
+Objects/clinic/bytesobject.c.h bytes_decode _parser -
+Objects/clinic/bytesobject.c.h bytes_splitlines _parser -
+Objects/clinic/bytesobject.c.h bytes_hex _parser -
+Objects/clinic/bytesobject.c.h bytes_new _parser -
+Objects/clinic/funcobject.c.h func_new _parser -
+Objects/clinic/codeobject.c.h code_replace _parser -
+Python/clinic/traceback.c.h tb_new _parser -
+Python/clinic/bltinmodule.c.h builtin_compile _parser -
+Python/clinic/bltinmodule.c.h builtin_pow _parser -
+Python/clinic/bltinmodule.c.h builtin_round _parser -
+Python/clinic/bltinmodule.c.h builtin_sum _parser -
+Python/clinic/import.c.h _imp_source_hash _parser -
+Python/clinic/sysmodule.c.h sys_addaudithook _parser -
+Python/clinic/sysmodule.c.h sys_set_coroutine_origin_tracking_depth _parser -
+Python/clinic/_warnings.c.h warnings_warn _parser -
+
+#-----------------------
+# other vars that are actually constant
+# []
+
+Modules/_csv.c - quote_styles -
+Modules/_ctypes/cfield.c - ffi_type_void -
+Modules/_ctypes/cfield.c - ffi_type_uint8 -
+Modules/_ctypes/cfield.c - ffi_type_sint8 -
+Modules/_ctypes/cfield.c - ffi_type_uint16 -
+Modules/_ctypes/cfield.c - ffi_type_sint16 -
+Modules/_ctypes/cfield.c - ffi_type_uint32 -
+Modules/_ctypes/cfield.c - ffi_type_sint32 -
+Modules/_ctypes/cfield.c - ffi_type_uint64 -
+Modules/_ctypes/cfield.c - ffi_type_sint64 -
+Modules/_ctypes/cfield.c - ffi_type_float -
+Modules/_ctypes/cfield.c - ffi_type_double -
+Modules/_ctypes/cfield.c - ffi_type_longdouble -
+Modules/_ctypes/cfield.c - ffi_type_pointer -
+Modules/_datetimemodule.c - epoch -
+Modules/_datetimemodule.c - max_fold_seconds -
+Modules/_datetimemodule.c datetime_isoformat specs -
+Modules/_datetimemodule.c time_isoformat specs -
+Modules/_decimal/_decimal.c - cond_map -
+Modules/_decimal/_decimal.c - dec_signal_string -
+Modules/_decimal/_decimal.c - dflt_ctx -
+Modules/_decimal/_decimal.c - int_constants -
+Modules/_decimal/_decimal.c - invalid_rounding_err -
+Modules/_decimal/_decimal.c - invalid_signals_err -
+Modules/_decimal/_decimal.c - signal_map -
+Modules/_decimal/_decimal.c - ssize_constants -
+Modules/_elementtree.c - ExpatMemoryHandler -
+Modules/_io/textio.c - encodefuncs -
+Modules/_localemodule.c - langinfo_constants -
+Modules/_sre.c pattern_repr flag_names -
+Modules/_struct.c - bigendian_table -
+Modules/_struct.c - lilendian_table -
+Modules/_tkinter.c - state_key -
+Modules/_xxsubinterpretersmodule.c - _channelid_end_send -
+Modules/_xxsubinterpretersmodule.c - _channelid_end_recv -
+Modules/arraymodule.c - descriptors -
+Modules/arraymodule.c - emptybuf -
+Modules/cjkcodecs/cjkcodecs.h - __methods -
+Modules/cmathmodule.c - acos_special_values -
+Modules/cmathmodule.c - acosh_special_values -
+Modules/cmathmodule.c - asinh_special_values -
+Modules/cmathmodule.c - atanh_special_values -
+Modules/cmathmodule.c - cosh_special_values -
+Modules/cmathmodule.c - exp_special_values -
+Modules/cmathmodule.c - log_special_values -
+Modules/cmathmodule.c - sinh_special_values -
+Modules/cmathmodule.c - sqrt_special_values -
+Modules/cmathmodule.c - tanh_special_values -
+Modules/cmathmodule.c - rect_special_values -
+Modules/config.c - _PyImport_Inittab -
+Modules/faulthandler.c - faulthandler_handlers -
+Modules/getnameinfo.c - gni_afdl -
+Modules/ossaudiodev.c - control_labels -
+Modules/ossaudiodev.c - control_names -
+Modules/nismodule.c - aliases -
+Modules/nismodule.c - TIMEOUT -
+Modules/posixmodule.c - posix_constants_pathconf -
+Modules/posixmodule.c - posix_constants_confstr -
+Modules/posixmodule.c - posix_constants_sysconf -
+Modules/pyexpat.c - ExpatMemoryHandler -
+Modules/pyexpat.c - handler_info -
+Modules/termios.c - termios_constants -
+Modules/timemodule.c init_timezone YEAR -
+Objects/bytearrayobject.c - _PyByteArray_empty_string -
+Objects/complexobject.c - c_1 -
+Objects/genobject.c - NON_INIT_CORO_MSG -
+Objects/genobject.c - ASYNC_GEN_IGNORED_EXIT_MSG -
+Objects/longobject.c - _PyLong_DigitValue -
+Objects/object.c - _Py_abstract_hack -
+Objects/object.c - _Py_SwappedOp -
+Objects/obmalloc.c - _PyMem -
+Objects/obmalloc.c - _PyMem_Debug -
+Objects/obmalloc.c - _PyMem_Raw -
+Objects/obmalloc.c - _PyObject -
+Objects/obmalloc.c - usedpools -
+Objects/unicodeobject.c unicode_decode_call_errorhandler_wchar argparse -
+Objects/unicodeobject.c unicode_decode_call_errorhandler_writer argparse -
+Objects/unicodeobject.c unicode_encode_call_errorhandler argparse -
+Objects/unicodeobject.c unicode_translate_call_errorhandler argparse -
+Objects/unicodeobject.c - stripfuncnames -
+Objects/unicodeobject.c - utf7_category -
+Parser/parser.c - reserved_keywords -
+Parser/tokenizer.c - type_comment_prefix -
+Python/opcode_targets.h - opcode_targets -
+
+
+##################################
+# temporary whitelist - globals to fix
+
+# These are all variables that we will be making non-global.
+
+#-----------------------
+# runtime static types
+# []
+
+Objects/floatobject.c - FloatInfoType -
+Objects/floatobject.c - PyFloat_Type -
+Objects/listobject.c - PyList_Type -
+Objects/listobject.c - PyListIter_Type -
+Objects/listobject.c - PyListRevIter_Type -
+Objects/setobject.c - _PySetDummy_Type -
+Objects/setobject.c - PySetIter_Type -
+Objects/setobject.c - PySet_Type -
+Objects/setobject.c - PyFrozenSet_Type -
+Objects/genobject.c - PyGen_Type -
+Objects/genobject.c - PyCoro_Type -
+Objects/genobject.c - _PyCoroWrapper_Type -
+Objects/genobject.c - PyAsyncGen_Type -
+Objects/genobject.c - _PyAsyncGenASend_Type -
+Objects/genobject.c - _PyAsyncGenWrappedValue_Type -
+Objects/genobject.c - _PyAsyncGenAThrow_Type -
+Objects/classobject.c - PyMethod_Type -
+Objects/classobject.c - PyInstanceMethod_Type -
+Objects/complexobject.c - PyComplex_Type -
+Objects/sliceobject.c - PyEllipsis_Type -
+Objects/sliceobject.c - PySlice_Type -
+Objects/bytesobject.c - PyBytes_Type -
+Objects/bytesobject.c - PyBytesIter_Type -
+Objects/descrobject.c - PyMethodDescr_Type -
+Objects/descrobject.c - PyClassMethodDescr_Type -
+Objects/descrobject.c - PyMemberDescr_Type -
+Objects/descrobject.c - PyGetSetDescr_Type -
+Objects/descrobject.c - PyWrapperDescr_Type -
+Objects/descrobject.c - _PyMethodWrapper_Type -
+Objects/descrobject.c - PyDictProxy_Type -
+Objects/descrobject.c - PyProperty_Type -
+Objects/unicodeobject.c - EncodingMapType -
+Objects/unicodeobject.c - PyUnicode_Type -
+Objects/unicodeobject.c - PyUnicodeIter_Type -
+Objects/unionobject.c - _Py_UnionType -
+Objects/moduleobject.c - PyModuleDef_Type -
+Objects/moduleobject.c - PyModule_Type -
+Objects/capsule.c - PyCapsule_Type -
+Objects/methodobject.c - PyCFunction_Type -
+Objects/methodobject.c - PyCMethod_Type -
+Objects/bytearrayobject.c - PyByteArray_Type -
+Objects/bytearrayobject.c - PyByteArrayIter_Type -
+Objects/interpreteridobject.c - _PyInterpreterID_Type -
+Objects/enumobject.c - PyEnum_Type -
+Objects/enumobject.c - PyReversed_Type -
+Objects/picklebufobject.c - PyPickleBuffer_Type -
+Objects/object.c - _PyNone_Type -
+Objects/object.c - _PyNotImplemented_Type -
+Objects/fileobject.c - PyStdPrinter_Type -
+Objects/weakrefobject.c - _PyWeakref_RefType -
+Objects/weakrefobject.c - _PyWeakref_ProxyType -
+Objects/weakrefobject.c - _PyWeakref_CallableProxyType -
+Objects/genericaliasobject.c - Py_GenericAliasType -
+Objects/rangeobject.c - PyRange_Type -
+Objects/rangeobject.c - PyRangeIter_Type -
+Objects/rangeobject.c - PyLongRangeIter_Type -
+Objects/namespaceobject.c - _PyNamespace_Type -
+Objects/iterobject.c - PySeqIter_Type -
+Objects/iterobject.c - PyCallIter_Type -
+Objects/boolobject.c - PyBool_Type -
+Objects/frameobject.c - PyFrame_Type -
+Objects/longobject.c - Int_InfoType -
+Objects/longobject.c - PyLong_Type -
+Objects/funcobject.c - PyFunction_Type -
+Objects/funcobject.c - PyClassMethod_Type -
+Objects/funcobject.c - PyStaticMethod_Type -
+Objects/typeobject.c - PyType_Type -
+Objects/typeobject.c - PyBaseObject_Type -
+Objects/typeobject.c - PySuper_Type -
+Objects/cellobject.c - PyCell_Type -
+Objects/odictobject.c - PyODict_Type -
+Objects/odictobject.c - PyODictIter_Type -
+Objects/odictobject.c - PyODictKeys_Type -
+Objects/odictobject.c - PyODictItems_Type -
+Objects/odictobject.c - PyODictValues_Type -
+Objects/dictobject.c - PyDict_Type -
+Objects/dictobject.c - PyDictIterKey_Type -
+Objects/dictobject.c - PyDictIterValue_Type -
+Objects/dictobject.c - PyDictIterItem_Type -
+Objects/dictobject.c - PyDictRevIterKey_Type -
+Objects/dictobject.c - PyDictRevIterItem_Type -
+Objects/dictobject.c - PyDictRevIterValue_Type -
+Objects/dictobject.c - PyDictKeys_Type -
+Objects/dictobject.c - PyDictItems_Type -
+Objects/dictobject.c - PyDictValues_Type -
+Objects/memoryobject.c - PyMemoryIter_Type -
+Objects/memoryobject.c - _PyManagedBuffer_Type -
+Objects/memoryobject.c - PyMemoryView_Type -
+Objects/tupleobject.c - PyTuple_Type -
+Objects/tupleobject.c - PyTupleIter_Type -
+Objects/codeobject.c - PyCode_Type -
+
+#-----------------------
+# builtin exception types
+# []
+
+Objects/exceptions.c - _PyExc_BaseException -
+Objects/exceptions.c - _PyExc_UnicodeEncodeError -
+Objects/exceptions.c - _PyExc_UnicodeDecodeError -
+Objects/exceptions.c - _PyExc_UnicodeTranslateError -
+Objects/exceptions.c - _PyExc_MemoryError -
+Objects/exceptions.c - _PyExc_Exception -
+Objects/exceptions.c - _PyExc_TypeError -
+Objects/exceptions.c - _PyExc_StopAsyncIteration -
+Objects/exceptions.c - _PyExc_StopIteration -
+Objects/exceptions.c - _PyExc_GeneratorExit -
+Objects/exceptions.c - _PyExc_SystemExit -
+Objects/exceptions.c - _PyExc_KeyboardInterrupt -
+Objects/exceptions.c - _PyExc_ImportError -
+Objects/exceptions.c - _PyExc_ModuleNotFoundError -
+Objects/exceptions.c - _PyExc_OSError -
+Objects/exceptions.c - _PyExc_BlockingIOError -
+Objects/exceptions.c - _PyExc_ConnectionError -
+Objects/exceptions.c - _PyExc_ChildProcessError -
+Objects/exceptions.c - _PyExc_BrokenPipeError -
+Objects/exceptions.c - _PyExc_ConnectionAbortedError -
+Objects/exceptions.c - _PyExc_ConnectionRefusedError -
+Objects/exceptions.c - _PyExc_ConnectionResetError -
+Objects/exceptions.c - _PyExc_FileExistsError -
+Objects/exceptions.c - _PyExc_FileNotFoundError -
+Objects/exceptions.c - _PyExc_IsADirectoryError -
+Objects/exceptions.c - _PyExc_NotADirectoryError -
+Objects/exceptions.c - _PyExc_InterruptedError -
+Objects/exceptions.c - _PyExc_PermissionError -
+Objects/exceptions.c - _PyExc_ProcessLookupError -
+Objects/exceptions.c - _PyExc_TimeoutError -
+Objects/exceptions.c - _PyExc_EOFError -
+Objects/exceptions.c - _PyExc_RuntimeError -
+Objects/exceptions.c - _PyExc_RecursionError -
+Objects/exceptions.c - _PyExc_NotImplementedError -
+Objects/exceptions.c - _PyExc_NameError -
+Objects/exceptions.c - _PyExc_UnboundLocalError -
+Objects/exceptions.c - _PyExc_AttributeError -
+Objects/exceptions.c - _PyExc_SyntaxError -
+Objects/exceptions.c - _PyExc_IndentationError -
+Objects/exceptions.c - _PyExc_TabError -
+Objects/exceptions.c - _PyExc_LookupError -
+Objects/exceptions.c - _PyExc_IndexError -
+Objects/exceptions.c - _PyExc_KeyError -
+Objects/exceptions.c - _PyExc_ValueError -
+Objects/exceptions.c - _PyExc_UnicodeError -
+Objects/exceptions.c - _PyExc_AssertionError -
+Objects/exceptions.c - _PyExc_ArithmeticError -
+Objects/exceptions.c - _PyExc_FloatingPointError -
+Objects/exceptions.c - _PyExc_OverflowError -
+Objects/exceptions.c - _PyExc_ZeroDivisionError -
+Objects/exceptions.c - _PyExc_SystemError -
+Objects/exceptions.c - _PyExc_ReferenceError -
+Objects/exceptions.c - _PyExc_BufferError -
+Objects/exceptions.c - _PyExc_Warning -
+Objects/exceptions.c - _PyExc_UserWarning -
+Objects/exceptions.c - _PyExc_DeprecationWarning -
+Objects/exceptions.c - _PyExc_PendingDeprecationWarning -
+Objects/exceptions.c - _PyExc_SyntaxWarning -
+Objects/exceptions.c - _PyExc_RuntimeWarning -
+Objects/exceptions.c - _PyExc_FutureWarning -
+Objects/exceptions.c - _PyExc_ImportWarning -
+Objects/exceptions.c - _PyExc_UnicodeWarning -
+Objects/exceptions.c - _PyExc_BytesWarning -
+Objects/exceptions.c - _PyExc_ResourceWarning -
+Objects/exceptions.c - PyExc_EnvironmentError -
+Objects/exceptions.c - PyExc_IOError -
+Objects/exceptions.c - PyExc_BaseException -
+Objects/exceptions.c - PyExc_Exception -
+Objects/exceptions.c - PyExc_TypeError -
+Objects/exceptions.c - PyExc_StopAsyncIteration -
+Objects/exceptions.c - PyExc_StopIteration -
+Objects/exceptions.c - PyExc_GeneratorExit -
+Objects/exceptions.c - PyExc_SystemExit -
+Objects/exceptions.c - PyExc_KeyboardInterrupt -
+Objects/exceptions.c - PyExc_ImportError -
+Objects/exceptions.c - PyExc_ModuleNotFoundError -
+Objects/exceptions.c - PyExc_OSError -
+Objects/exceptions.c - PyExc_BlockingIOError -
+Objects/exceptions.c - PyExc_ConnectionError -
+Objects/exceptions.c - PyExc_ChildProcessError -
+Objects/exceptions.c - PyExc_BrokenPipeError -
+Objects/exceptions.c - PyExc_ConnectionAbortedError -
+Objects/exceptions.c - PyExc_ConnectionRefusedError -
+Objects/exceptions.c - PyExc_ConnectionResetError -
+Objects/exceptions.c - PyExc_FileExistsError -
+Objects/exceptions.c - PyExc_FileNotFoundError -
+Objects/exceptions.c - PyExc_IsADirectoryError -
+Objects/exceptions.c - PyExc_NotADirectoryError -
+Objects/exceptions.c - PyExc_InterruptedError -
+Objects/exceptions.c - PyExc_PermissionError -
+Objects/exceptions.c - PyExc_ProcessLookupError -
+Objects/exceptions.c - PyExc_TimeoutError -
+Objects/exceptions.c - PyExc_EOFError -
+Objects/exceptions.c - PyExc_RuntimeError -
+Objects/exceptions.c - PyExc_RecursionError -
+Objects/exceptions.c - PyExc_NotImplementedError -
+Objects/exceptions.c - PyExc_NameError -
+Objects/exceptions.c - PyExc_UnboundLocalError -
+Objects/exceptions.c - PyExc_AttributeError -
+Objects/exceptions.c - PyExc_SyntaxError -
+Objects/exceptions.c - PyExc_IndentationError -
+Objects/exceptions.c - PyExc_TabError -
+Objects/exceptions.c - PyExc_LookupError -
+Objects/exceptions.c - PyExc_IndexError -
+Objects/exceptions.c - PyExc_KeyError -
+Objects/exceptions.c - PyExc_ValueError -
+Objects/exceptions.c - PyExc_UnicodeError -
+Objects/exceptions.c - PyExc_UnicodeEncodeError -
+Objects/exceptions.c - PyExc_UnicodeDecodeError -
+Objects/exceptions.c - PyExc_UnicodeTranslateError -
+Objects/exceptions.c - PyExc_AssertionError -
+Objects/exceptions.c - PyExc_ArithmeticError -
+Objects/exceptions.c - PyExc_FloatingPointError -
+Objects/exceptions.c - PyExc_OverflowError -
+Objects/exceptions.c - PyExc_ZeroDivisionError -
+Objects/exceptions.c - PyExc_SystemError -
+Objects/exceptions.c - PyExc_ReferenceError -
+Objects/exceptions.c - PyExc_MemoryError -
+Objects/exceptions.c - PyExc_BufferError -
+Objects/exceptions.c - PyExc_Warning -
+Objects/exceptions.c - PyExc_UserWarning -
+Objects/exceptions.c - PyExc_DeprecationWarning -
+Objects/exceptions.c - PyExc_PendingDeprecationWarning -
+Objects/exceptions.c - PyExc_SyntaxWarning -
+Objects/exceptions.c - PyExc_RuntimeWarning -
+Objects/exceptions.c - PyExc_FutureWarning -
+Objects/exceptions.c - PyExc_ImportWarning -
+Objects/exceptions.c - PyExc_UnicodeWarning -
+Objects/exceptions.c - PyExc_BytesWarning -
+Objects/exceptions.c - PyExc_ResourceWarning -
+
+#-----------------------
+# singletons
+# []
+
+Objects/boolobject.c - _Py_FalseStruct -
+Objects/boolobject.c - _Py_TrueStruct -
+Objects/dictobject.c - empty_keys_struct -
+Objects/dictobject.c - empty_values -
+Objects/object.c - _Py_NoneStruct -
+Objects/object.c - _Py_NotImplementedStruct -
+Objects/setobject.c - _dummy_struct -
+Objects/setobject.c - _PySet_Dummy -
+Objects/sliceobject.c - _Py_EllipsisObject -
+
+#-----------------------
+# runtime initialized once - cached PyUnicode
+# []
+
+# Py_IDENTIFIER (global) []
+Objects/classobject.c - PyId___name__ -
+Objects/classobject.c - PyId___qualname__ -
+Objects/structseq.c - PyId_n_sequence_fields -
+Objects/structseq.c - PyId_n_fields -
+Objects/structseq.c - PyId_n_unnamed_fields -
+Objects/bytesobject.c - PyId___bytes__ -
+Objects/descrobject.c - PyId_getattr -
+Objects/moduleobject.c - PyId___doc__ -
+Objects/moduleobject.c - PyId___name__ -
+Objects/moduleobject.c - PyId___spec__ -
+Objects/object.c - PyId_Py_Repr -
+Objects/object.c - PyId___bytes__ -
+Objects/object.c - PyId___dir__ -
+Objects/object.c - PyId___isabstractmethod__ -
+Objects/fileobject.c - PyId_open -
+Objects/rangeobject.c - PyId_iter -
+Objects/iterobject.c - PyId_iter -
+Objects/frameobject.c - PyId___builtins__ -
+Objects/longobject.c - PyId_little -
+Objects/longobject.c - PyId_big -
+Objects/typeobject.c - PyId___abstractmethods__ -
+Objects/typeobject.c - PyId___class__ -
+Objects/typeobject.c - PyId___class_getitem__ -
+Objects/typeobject.c - PyId___delitem__ -
+Objects/typeobject.c - PyId___dict__ -
+Objects/typeobject.c - PyId___doc__ -
+Objects/typeobject.c - PyId___getattribute__ -
+Objects/typeobject.c - PyId___getitem__ -
+Objects/typeobject.c - PyId___hash__ -
+Objects/typeobject.c - PyId___init_subclass__ -
+Objects/typeobject.c - PyId___len__ -
+Objects/typeobject.c - PyId___module__ -
+Objects/typeobject.c - PyId___name__ -
+Objects/typeobject.c - PyId___new__ -
+Objects/typeobject.c - PyId___set_name__ -
+Objects/typeobject.c - PyId___setitem__ -
+Objects/typeobject.c - PyId_builtins -
+Objects/typeobject.c - PyId_mro -
+Objects/odictobject.c - PyId_items -
+
+# Py_IDENTIFIER (local) []
+Objects/listobject.c listiter_reduce_general PyId_iter -
+Objects/listobject.c listiter_reduce_general PyId_reversed -
+Objects/setobject.c setiter_reduce PyId_iter -
+Objects/setobject.c set_reduce PyId___dict__ -
+Objects/abstract.c PyObject_LengthHint PyId___length_hint__ -
+Objects/abstract.c PyObject_GetItem PyId___class_getitem__ -
+Objects/abstract.c PyObject_Format PyId___format__ -
+Objects/abstract.c PyNumber_Long PyId___trunc__ -
+Objects/abstract.c PyMapping_Keys PyId_keys -
+Objects/abstract.c PyMapping_Items PyId_items -
+Objects/abstract.c PyMapping_Values PyId_values -
+Objects/abstract.c abstract_get_bases PyId___bases__ -
+Objects/abstract.c object_isinstance PyId___class__ -
+Objects/abstract.c object_recursive_isinstance PyId___instancecheck__ -
+Objects/abstract.c object_issubclass PyId___subclasscheck__ -
+Objects/genobject.c PyIter_Send PyId_send -
+Objects/genobject.c gen_close_iter PyId_close -
+Objects/genobject.c _gen_throw PyId_throw -
+Objects/classobject.c method_reduce PyId_getattr -
+Objects/complexobject.c try_complex_special_method PyId___complex__ -
+Objects/bytesobject.c striter_reduce PyId_iter -
+Objects/descrobject.c calculate_qualname PyId___qualname__ -
+Objects/descrobject.c mappingproxy_get PyId_get -
+Objects/descrobject.c mappingproxy_keys PyId_keys -
+Objects/descrobject.c mappingproxy_values PyId_values -
+Objects/descrobject.c mappingproxy_items PyId_items -
+Objects/descrobject.c mappingproxy_copy PyId_copy -
+Objects/descrobject.c mappingproxy_reversed PyId___reversed__ -
+Objects/descrobject.c property_init_impl PyId___doc__ -
+Objects/unicodeobject.c unicodeiter_reduce PyId_iter -
+Objects/unionobject.c union_repr_item PyId___module__ -
+Objects/unionobject.c union_repr_item PyId___qualname__ -
+Objects/unionobject.c union_repr_item PyId___origin__ -
+Objects/unionobject.c union_repr_item PyId___args__ -
+Objects/moduleobject.c module_init_dict PyId___package__ -
+Objects/moduleobject.c module_init_dict PyId___loader__ -
+Objects/moduleobject.c PyModule_GetFilenameObject PyId___file__ -
+Objects/moduleobject.c _PyModuleSpec_IsInitializing PyId__initializing -
+Objects/moduleobject.c module_getattro PyId___getattr__ -
+Objects/moduleobject.c module_dir PyId___dict__ -
+Objects/moduleobject.c module_dir PyId___dir__ -
+Objects/methodobject.c meth_reduce PyId_getattr -
+Objects/methodobject.c meth_get__qualname__ PyId___qualname__ -
+Objects/bytearrayobject.c _common_reduce PyId___dict__ -
+Objects/bytearrayobject.c bytearrayiter_reduce PyId_iter -
+Objects/enumobject.c reversed_new_impl PyId___reversed__ -
+Objects/object.c _PyObject_FunctionStr PyId___module__ -
+Objects/object.c _PyObject_FunctionStr PyId___qualname__ -
+Objects/object.c _PyObject_FunctionStr PyId_builtins -
+Objects/fileobject.c PyFile_GetLine PyId_readline -
+Objects/fileobject.c PyFile_WriteObject PyId_write -
+Objects/fileobject.c PyObject_AsFileDescriptor PyId_fileno -
+Objects/weakrefobject.c weakref_repr PyId___name__ -
+Objects/weakrefobject.c proxy_bytes PyId___bytes__ -
+Objects/weakrefobject.c proxy_reversed PyId___reversed__ -
+Objects/genericaliasobject.c ga_repr_item PyId___module__ -
+Objects/genericaliasobject.c ga_repr_item PyId___qualname__ -
+Objects/genericaliasobject.c ga_repr_item PyId___origin__ -
+Objects/genericaliasobject.c ga_repr_item PyId___args__ -
+Objects/genericaliasobject.c make_parameters PyId___parameters__ -
+Objects/genericaliasobject.c subs_tvars PyId___parameters__ -
+Objects/exceptions.c ImportError_getstate PyId_name -
+Objects/exceptions.c ImportError_getstate PyId_path -
+Objects/typeobject.c type_new PyId___qualname__ -
+Objects/typeobject.c type_new PyId___slots__ -
+Objects/typeobject.c type_new PyId___classcell__ -
+Objects/typeobject.c type_new PyId___mro_entries__ -
+Objects/typeobject.c merge_class_dict PyId___bases__ -
+Objects/typeobject.c import_copyreg PyId_copyreg -
+Objects/typeobject.c _PyType_GetSlotNames PyId___slotnames__ -
+Objects/typeobject.c _PyType_GetSlotNames PyId__slotnames -
+Objects/typeobject.c _PyObject_GetState PyId___getstate__ -
+Objects/typeobject.c _PyObject_GetNewArguments PyId___getnewargs_ex__ -
+Objects/typeobject.c _PyObject_GetNewArguments PyId___getnewargs__ -
+Objects/typeobject.c _PyObject_GetItemsIter PyId_items -
+Objects/typeobject.c reduce_newobj PyId___newobj__ -
+Objects/typeobject.c reduce_newobj PyId___newobj_ex__ -
+Objects/typeobject.c object___reduce_ex___impl PyId___reduce__ -
+Objects/typeobject.c overrides_hash PyId___eq__ -
+Objects/typeobject.c slot_sq_contains PyId___contains__ -
+Objects/typeobject.c slot_nb_power PyId___pow__ -
+Objects/typeobject.c slot_nb_bool PyId___bool__ -
+Objects/typeobject.c slot_nb_index PyId___index__ -
+Objects/typeobject.c slot_nb_inplace_power PyId___ipow__ -
+Objects/typeobject.c slot_tp_repr PyId___repr__ -
+Objects/typeobject.c slot_tp_call PyId___call__ -
+Objects/typeobject.c slot_tp_getattr_hook PyId___getattr__ -
+Objects/typeobject.c slot_tp_setattro PyId___delattr__ -
+Objects/typeobject.c slot_tp_setattro PyId___setattr__ -
+Objects/typeobject.c slot_tp_iter PyId___iter__ -
+Objects/typeobject.c slot_tp_iternext PyId___next__ -
+Objects/typeobject.c slot_tp_descr_get PyId___get__ -
+Objects/typeobject.c slot_tp_descr_set PyId___delete__ -
+Objects/typeobject.c slot_tp_descr_set PyId___set__ -
+Objects/typeobject.c slot_tp_init PyId___init__ -
+Objects/typeobject.c slot_tp_finalize PyId___del__ -
+Objects/typeobject.c slot_am_await PyId___await__ -
+Objects/typeobject.c slot_am_aiter PyId___aiter__ -
+Objects/typeobject.c slot_am_anext PyId___anext__ -
+Objects/odictobject.c odict_reduce PyId___dict__ -
+Objects/odictobject.c odictiter_reduce PyId_iter -
+Objects/odictobject.c mutablemapping_update_arg PyId_keys -
+Objects/dictobject.c dict_subscript PyId___missing__ -
+Objects/dictobject.c dict_update_arg PyId_keys -
+Objects/dictobject.c dictiter_reduce PyId_iter -
+Objects/dictobject.c dictviews_sub PyId_difference_update -
+Objects/dictobject.c _PyDictView_Intersect PyId_intersection -
+Objects/dictobject.c dictitems_xor PyId_items -
+Objects/dictobject.c dictviews_xor PyId_symmetric_difference_update -
+Objects/tupleobject.c tupleiter_reduce PyId_iter -
+Parser/tokenizer.c fp_setreadl PyId_open -
+Parser/tokenizer.c fp_setreadl PyId_readline -
+
+# _Py_static_string []
+Objects/typeobject.c - name_op -
+Objects/typeobject.c object_new comma_id -
+Objects/typeobject.c slot_mp_subscript id -
+Objects/typeobject.c slot_nb_add op_id -
+Objects/typeobject.c slot_nb_add rop_id -
+Objects/typeobject.c slot_nb_subtract op_id -
+Objects/typeobject.c slot_nb_subtract rop_id -
+Objects/typeobject.c slot_nb_multiply op_id -
+Objects/typeobject.c slot_nb_multiply rop_id -
+Objects/typeobject.c slot_nb_matrix_multiply op_id -
+Objects/typeobject.c slot_nb_matrix_multiply rop_id -
+Objects/typeobject.c slot_nb_remainder op_id -
+Objects/typeobject.c slot_nb_remainder rop_id -
+Objects/typeobject.c slot_nb_divmod op_id -
+Objects/typeobject.c slot_nb_divmod rop_id -
+Objects/typeobject.c slot_nb_power_binary op_id -
+Objects/typeobject.c slot_nb_power_binary rop_id -
+Objects/typeobject.c slot_nb_negative id -
+Objects/typeobject.c slot_nb_positive id -
+Objects/typeobject.c slot_nb_absolute id -
+Objects/typeobject.c slot_nb_invert id -
+Objects/typeobject.c slot_nb_lshift op_id -
+Objects/typeobject.c slot_nb_lshift rop_id -
+Objects/typeobject.c slot_nb_rshift op_id -
+Objects/typeobject.c slot_nb_rshift rop_id -
+Objects/typeobject.c slot_nb_and op_id -
+Objects/typeobject.c slot_nb_and rop_id -
+Objects/typeobject.c slot_nb_xor op_id -
+Objects/typeobject.c slot_nb_xor rop_id -
+Objects/typeobject.c slot_nb_or op_id -
+Objects/typeobject.c slot_nb_or rop_id -
+Objects/typeobject.c slot_nb_int id -
+Objects/typeobject.c slot_nb_float id -
+Objects/typeobject.c slot_nb_inplace_add id -
+Objects/typeobject.c slot_nb_inplace_subtract id -
+Objects/typeobject.c slot_nb_inplace_multiply id -
+Objects/typeobject.c slot_nb_inplace_matrix_multiply id -
+Objects/typeobject.c slot_nb_inplace_remainder id -
+Objects/typeobject.c slot_nb_inplace_lshift id -
+Objects/typeobject.c slot_nb_inplace_rshift id -
+Objects/typeobject.c slot_nb_inplace_and id -
+Objects/typeobject.c slot_nb_inplace_xor id -
+Objects/typeobject.c slot_nb_inplace_or id -
+Objects/typeobject.c slot_nb_floor_divide op_id -
+Objects/typeobject.c slot_nb_floor_divide rop_id -
+Objects/typeobject.c slot_nb_true_divide op_id -
+Objects/typeobject.c slot_nb_true_divide rop_id -
+Objects/typeobject.c slot_nb_inplace_floor_divide id -
+Objects/typeobject.c slot_nb_inplace_true_divide id -
+Objects/typeobject.c slot_tp_str id -
+Python/compile.c compiler_set_qualname dot -
+Python/compile.c compiler_set_qualname dot_locals -
+
+# manually cached PyUnicodeOjbect []
+Objects/boolobject.c - false_str -
+Objects/boolobject.c - true_str -
+Objects/classobject.c method_get_doc docstr -
+Objects/classobject.c instancemethod_get_doc docstr -
+Objects/codeobject.c PyCode_NewEmpty emptystring -
+Objects/exceptions.c _check_for_legacy_statements print_prefix -
+Objects/exceptions.c _check_for_legacy_statements exec_prefix -
+Objects/funcobject.c PyFunction_NewWithQualName __name__ -
+Objects/listobject.c - indexerr -
+Objects/typeobject.c object___reduce_ex___impl objreduce -
+# XXX This should have been found by the analyzer but wasn't:
+Python/ast_unparse.c - _str_close_br -
+# XXX This should have been found by the analyzer but wasn't:
+Python/ast_unparse.c - _str_dbl_close_br -
+# XXX This should have been found by the analyzer but wasn't:
+Python/ast_unparse.c - _str_dbl_open_br -
+# XXX This should have been found by the analyzer but wasn't:
+Python/ast_unparse.c - _str_inf -
+# XXX This should have been found by the analyzer but wasn't:
+Python/ast_unparse.c - _str_open_br -
+# XXX This should have been found by the analyzer but wasn't:
+Python/ast_unparse.c - _str_replace_inf -
+# XXX This should have been found by the analyzer but wasn't:
+Python/compile.c - __annotations__ -
+# XXX This should have been found by the analyzer but wasn't:
+Python/compile.c - __doc__ -
+# XXX This should have been found by the analyzer but wasn't:
+Python/compile.c compiler_dictcomp name -
+# XXX This should have been found by the analyzer but wasn't:
+Python/compile.c compiler_from_import empty_string -
+# XXX This should have been found by the analyzer but wasn't:
+Python/compile.c compiler_genexp name -
+# XXX This should have been found by the analyzer but wasn't:
+Python/compile.c compiler_lambda name -
+# XXX This should have been found by the analyzer but wasn't:
+Python/compile.c compiler_listcomp name -
+# XXX This should have been found by the analyzer but wasn't:
+Python/compile.c compiler_setcomp name -
+# XXX This should have been found by the analyzer but wasn't:
+Python/compile.c compiler_visit_annotations return_str -
+# XXX This should have been found by the analyzer but wasn't:
+Python/import.c PyImport_Import builtins_str -
+# XXX This should have been found by the analyzer but wasn't:
+Python/import.c PyImport_Import import_str -
+# XXX This should have been found by the analyzer but wasn't:
+Python/sysmodule.c - whatstrings -
+# XXX This should have been found by the analyzer but wasn't:
+Python/sysmodule.c sys_displayhook newline -
+# XXX This should have been found by the analyzer but wasn't:
+Python/_warnings.c is_internal_frame bootstrap_string -
+# XXX This should have been found by the analyzer but wasn't:
+Python/_warnings.c is_internal_frame importlib_string -
+
+#-----------------------
+# runtime initialized once - other PyObject
+# []
+
+# cache []
+Objects/unicodeobject.c - interned -
+Objects/unicodeobject.c - static_strings -
+Objects/typeobject.c - method_cache -
+
+# other []
+# XXX This should have been found by the analyzer but wasn't:
+Python/context.c - _token_missing -
+# XXX This should have been found by the analyzer but wasn't:
+Python/hamt.c - _empty_bitmap_node -
+# XXX This should have been found by the analyzer but wasn't:
+Python/hamt.c - _empty_hamt -
+# XXX This should have been found by the analyzer but wasn't:
+Python/import.c PyImport_Import silly_list -
+
+#-----------------------
+# runtime initialized once - non-PyObject
+# []
+
+# during init []
+Parser/parser.c - Py_DebugFlag -
+
+# other []
+Objects/codeobject.c PyCode_NewEmpty nulltuple -
+Objects/longobject.c PyLong_FromString log_base_BASE -
+Objects/longobject.c PyLong_FromString convwidth_base -
+Objects/longobject.c PyLong_FromString convmultmax_base -
+Objects/typeobject.c - slotdefs -
+Objects/typeobject.c - slotdefs_initialized -
+Objects/unicodeobject.c - bloom_linebreak -
+Objects/unicodeobject.c - ucnhash_capi -
+Parser/pegen.c _PyPegen_dummy_name cache -
+# XXX This should have been found by the analyzer but wasn't:
+Python/import.c - import_lock -
+# XXX This should have been found by the analyzer but wasn't:
+Python/import.c import_find_and_load header -
+
+#-----------------------
+# runtime state
+
+# (look at the bottome of the file)
+
+#-----------------------
+# modules
+# [119]
+
+Modules/pwdmodule.c - pwdmodule -
+Modules/grpmodule.c - grpmodule -
+Modules/_ssl.c - PySocketModule -
+Modules/_ssl.c - _sslmodule -
+Modules/_struct.c - _structmodule -
+Modules/_sre.c - sremodule -
+Modules/timemodule.c - timemodule -
+Modules/xxmodule.c - xxmodule -
+Modules/itertoolsmodule.c - itertoolsmodule -
+Modules/_tkinter.c - _tkintermodule -
+Modules/gcmodule.c - gcmodule -
+Modules/mmapmodule.c - mmapmodule -
+Modules/errnomodule.c - errnomodule -
+Modules/_gdbmmodule.c - _gdbmmodule -
+Modules/xxlimited.c - xxmodule -
+Modules/arraymodule.c - arraymodule -
+Modules/_uuidmodule.c - uuidmodule -
+Modules/_collectionsmodule.c - _collectionsmodule -
+Modules/_csv.c - _csvmodule -
+Modules/_json.c - jsonmodule -
+Modules/zlibmodule.c - zlibmodule -
+Modules/readline.c - readlinemodule -
+Modules/faulthandler.c - module_def -
+Modules/_codecsmodule.c - codecsmodule -
+Modules/_asynciomodule.c - _asynciomodule -
+Modules/signalmodule.c - signalmodule -
+Modules/binascii.c - binasciimodule -
+Modules/mathmodule.c - mathmodule -
+Modules/_stat.c - statmodule -
+Modules/_opcode.c - opcodemodule -
+Modules/_operator.c - operatormodule -
+Modules/_cryptmodule.c - cryptmodule -
+Modules/cmathmodule.c - cmathmodule -
+Modules/_lzmamodule.c - _lzmamodule -
+Modules/_zoneinfo.c - zoneinfomodule -
+Modules/posixmodule.c - posixmodule -
+Modules/_bz2module.c - _bz2module -
+Modules/_functoolsmodule.c - _functools_module -
+Modules/_abc.c - _abcmodule -
+Modules/_heapqmodule.c - _heapqmodule -
+Modules/_bisectmodule.c - _bisectmodule -
+Modules/_tracemalloc.c - module_def -
+Modules/pyexpat.c - pyexpatmodule -
+Modules/_randommodule.c - _randommodule -
+Modules/atexitmodule.c - atexitmodule -
+Modules/syslogmodule.c - syslogmodule -
+Modules/_queuemodule.c - queuemodule -
+Modules/_threadmodule.c - threadmodule -
+Modules/_weakref.c - weakrefmodule -
+Modules/spwdmodule.c - spwdmodule -
+Modules/_contextvarsmodule.c - _contextvarsmodule -
+Modules/_posixsubprocess.c - _posixsubprocessmodule -
+Modules/_xxsubinterpretersmodule.c - interpretersmodule -
+Modules/_curses_panel.c - _curses_panelmodule -
+Modules/audioop.c - audioopmodule -
+Modules/nismodule.c - nismodule -
+Modules/_elementtree.c - elementtreemodule -
+Modules/sha256module.c - _sha256module -
+Modules/resource.c - resourcemodule -
+Modules/symtablemodule.c - symtablemodule -
+Modules/sha1module.c - _sha1module -
+Modules/selectmodule.c - selectmodule -
+Modules/_pickle.c - _picklemodule -
+Modules/_localemodule.c - _localemodule -
+Modules/unicodedata.c - unicodedata_module -
+Modules/_statisticsmodule.c - statisticsmodule -
+Modules/termios.c - termiosmodule -
+Modules/xxsubtype.c - xxsubtypemodule -
+Modules/sha512module.c - _sha512module -
+Modules/_cursesmodule.c - _cursesmodule -
+Modules/md5module.c - _md5module -
+Modules/socketmodule.c - socketmodule -
+Modules/_datetimemodule.c - datetimemodule -
+Modules/_hashopenssl.c - _hashlibmodule -
+Modules/fcntlmodule.c - fcntlmodule -
+Modules/ossaudiodev.c - ossaudiodevmodule -
+Modules/_lsprof.c - _lsprofmodule -
+Modules/_blake2/blake2module.c - blake2_module -
+Modules/_multiprocessing/multiprocessing.c - multiprocessing_module -
+Modules/_multiprocessing/posixshmem.c - this_module -
+Modules/_sqlite/module.c - _sqlite3module -
+Modules/_sha3/sha3module.c - _sha3module -
+Modules/cjkcodecs/multibytecodec.c - _multibytecodecmodule -
+Modules/_decimal/_decimal.c - _decimal_module -
+Modules/_ctypes/_ctypes.c - _ctypesmodule -
+Objects/unicodeobject.c - _string_module -
+Modules/_io/_iomodule.h - _PyIO_Module -
+Modules/_io/_iomodule.c - _PyIO_Module -
+
+#-----------------------
+# module static types
+# []
+
+Modules/arraymodule.c - Arraytype -
+Modules/arraymodule.c - PyArrayIter_Type -
+Modules/_asynciomodule.c - FutureType -
+Modules/_asynciomodule.c - FutureIterType -
+Modules/_asynciomodule.c - TaskStepMethWrapper_Type -
+Modules/_asynciomodule.c - TaskType -
+Modules/_asynciomodule.c - PyRunningLoopHolder_Type -
+Modules/cjkcodecs/multibytecodec.c - MultibyteCodec_Type -
+Modules/cjkcodecs/multibytecodec.c - MultibyteIncrementalEncoder_Type -
+Modules/cjkcodecs/multibytecodec.c - MultibyteIncrementalDecoder_Type -
+Modules/cjkcodecs/multibytecodec.c - MultibyteStreamReader_Type -
+Modules/cjkcodecs/multibytecodec.c - MultibyteStreamWriter_Type -
+Modules/_collectionsmodule.c - deque_type -
+Modules/_collectionsmodule.c - dequeiter_type -
+Modules/_collectionsmodule.c - dequereviter_type -
+Modules/_collectionsmodule.c - defdict_type -
+Modules/_collectionsmodule.c - tuplegetter_type -
+Modules/_csv.c - Dialect_Type -
+Modules/_csv.c - Reader_Type -
+Modules/_csv.c - Writer_Type -
+Modules/_ctypes/callbacks.c - PyCThunk_Type -
+Modules/_ctypes/callproc.c - PyCArg_Type -
+Modules/_ctypes/cfield.c - PyCField_Type -
+Modules/_ctypes/_ctypes.c - DictRemover_Type -
+Modules/_ctypes/_ctypes.c - StructParam_Type -
+Modules/_ctypes/_ctypes.c - PyCStructType_Type -
+Modules/_ctypes/_ctypes.c - UnionType_Type -
+Modules/_ctypes/_ctypes.c - PyCPointerType_Type -
+Modules/_ctypes/_ctypes.c - PyCArrayType_Type -
+Modules/_ctypes/_ctypes.c - PyCSimpleType_Type -
+Modules/_ctypes/_ctypes.c - PyCFuncPtrType_Type -
+Modules/_ctypes/_ctypes.c - PyCData_Type -
+Modules/_ctypes/_ctypes.c - PyCFuncPtr_Type -
+Modules/_ctypes/_ctypes.c - Struct_Type -
+Modules/_ctypes/_ctypes.c - Union_Type -
+Modules/_ctypes/_ctypes.c - PyCArray_Type -
+Modules/_ctypes/_ctypes.c - Simple_Type -
+Modules/_ctypes/_ctypes.c - PyCPointer_Type -
+Modules/_ctypes/_ctypes.c - PyComError_Type -
+Modules/_ctypes/stgdict.c - PyCStgDict_Type -
+Modules/_cursesmodule.c - PyCursesWindow_Type -
+Modules/_datetimemodule.c - PyDateTime_DeltaType -
+Modules/_datetimemodule.c - PyDateTime_IsoCalendarDateType -
+Modules/_datetimemodule.c - PyDateTime_DateType -
+Modules/_datetimemodule.c - PyDateTime_TZInfoType -
+Modules/_datetimemodule.c - PyDateTime_TimeZoneType -
+Modules/_datetimemodule.c - PyDateTime_TimeType -
+Modules/_datetimemodule.c - PyDateTime_DateTimeType -
+Modules/_decimal/_decimal.c - PyDecSignalDictMixin_Type -
+Modules/_decimal/_decimal.c - PyDecContextManager_Type -
+Modules/_decimal/_decimal.c - PyDec_Type -
+Modules/_decimal/_decimal.c - PyDecContext_Type -
+Modules/_elementtree.c - ElementIter_Type -
+Modules/_elementtree.c - Element_Type -
+Modules/_elementtree.c - TreeBuilder_Type -
+Modules/_elementtree.c - XMLParser_Type -
+Modules/_functoolsmodule.c - partial_type -
+Modules/_functoolsmodule.c - keyobject_type -
+Modules/_functoolsmodule.c - lru_list_elem_type -
+Modules/_functoolsmodule.c - lru_cache_type -
+Modules/_io/bufferedio.c - PyBufferedIOBase_Type -
+Modules/_io/bufferedio.c - PyBufferedReader_Type -
+Modules/_io/bufferedio.c - PyBufferedWriter_Type -
+Modules/_io/bufferedio.c - PyBufferedRWPair_Type -
+Modules/_io/bufferedio.c - PyBufferedRandom_Type -
+Modules/_io/bytesio.c - PyBytesIO_Type -
+Modules/_io/bytesio.c - _PyBytesIOBuffer_Type -
+Modules/_io/fileio.c - PyFileIO_Type -
+Modules/_io/iobase.c - PyIOBase_Type -
+Modules/_io/iobase.c - PyRawIOBase_Type -
+Modules/_io/stringio.c - PyStringIO_Type -
+Modules/_io/textio.c - PyTextIOBase_Type -
+Modules/_io/textio.c - PyIncrementalNewlineDecoder_Type -
+Modules/_io/textio.c - PyTextIOWrapper_Type -
+Modules/_io/winconsoleio.c - PyWindowsConsoleIO_Type -
+Modules/itertoolsmodule.c - groupby_type -
+Modules/itertoolsmodule.c - _grouper_type -
+Modules/itertoolsmodule.c - teedataobject_type -
+Modules/itertoolsmodule.c - tee_type -
+Modules/itertoolsmodule.c - cycle_type -
+Modules/itertoolsmodule.c - dropwhile_type -
+Modules/itertoolsmodule.c - takewhile_type -
+Modules/itertoolsmodule.c - islice_type -
+Modules/itertoolsmodule.c - starmap_type -
+Modules/itertoolsmodule.c - chain_type -
+Modules/itertoolsmodule.c - product_type -
+Modules/itertoolsmodule.c - combinations_type -
+Modules/itertoolsmodule.c - cwr_type -
+Modules/itertoolsmodule.c - permutations_type -
+Modules/itertoolsmodule.c - accumulate_type -
+Modules/itertoolsmodule.c - compress_type -
+Modules/itertoolsmodule.c - filterfalse_type -
+Modules/itertoolsmodule.c - count_type -
+Modules/itertoolsmodule.c - repeat_type -
+Modules/itertoolsmodule.c - ziplongest_type -
+Modules/mmapmodule.c - mmap_object_type -
+Modules/_multiprocessing/semaphore.c - _PyMp_SemLockType -
+Modules/ossaudiodev.c - OSSAudioType -
+Modules/ossaudiodev.c - OSSMixerType -
+Modules/_pickle.c - Pdata_Type -
+Modules/_pickle.c - PicklerMemoProxyType -
+Modules/_pickle.c - Pickler_Type -
+Modules/_pickle.c - UnpicklerMemoProxyType -
+Modules/_pickle.c - Unpickler_Type -
+Modules/pyexpat.c - Xmlparsetype -
+Modules/_queuemodule.c - PySimpleQueueType -
+Modules/socketmodule.c - sock_type -
+Modules/_sre.c - Pattern_Type -
+Modules/_sre.c - Match_Type -
+Modules/_sre.c - Scanner_Type -
+Modules/_ssl.c - PySSLSocket_Type -
+Modules/_ssl.c - PySSLContext_Type -
+Modules/_ssl.c - PySSLMemoryBIO_Type -
+Modules/_ssl.c - PySSLSession_Type -
+Modules/_threadmodule.c - Locktype -
+Modules/_threadmodule.c - RLocktype -
+Modules/_threadmodule.c - localdummytype -
+Modules/_threadmodule.c - localtype -
+Modules/xxmodule.c - Xxo_Type -
+Modules/xxmodule.c - Str_Type -
+Modules/xxmodule.c - Null_Type -
+Modules/_xxsubinterpretersmodule.c - ChannelIDtype -
+Modules/xxsubtype.c - spamlist_type -
+Modules/xxsubtype.c - spamdict_type -
+Modules/_zoneinfo.c - PyZoneInfo_ZoneInfoType -
+
+#-----------------------
+# module initialized once - non-static types
+# []
+
+# structseq types [6]
+Modules/timemodule.c - StructTimeType -
+Modules/signalmodule.c - SiginfoType -
+Modules/_threadmodule.c - ExceptHookArgsType -
+Modules/spwdmodule.c - StructSpwdType -
+Modules/resource.c - StructRUsageType -
+Modules/_cursesmodule.c - NcursesVersionType -
+
+# heap types [12]
+Modules/_tkinter.c - Tkapp_Type -
+Modules/_tkinter.c - PyTclObject_Type -
+Modules/_tkinter.c - Tktt_Type -
+Modules/xxlimited.c - Xxo_Type -
+Modules/_decimal/_decimal.c - DecimalTuple -
+Modules/_decimal/_decimal.c - PyDecSignalDict_Type -
+Modules/_sqlite/connection.c - pysqlite_ConnectionType -
+Modules/_sqlite/statement.c - pysqlite_StatementType -
+Modules/_sqlite/cache.c - pysqlite_NodeType -
+Modules/_sqlite/cache.c - pysqlite_CacheType -
+Modules/_sqlite/row.c - pysqlite_RowType -
+Modules/_sqlite/prepare_protocol.c - pysqlite_PrepareProtocolType -
+Modules/_sqlite/cursor.c - pysqlite_CursorType -
+
+# exception types []
+Modules/_ctypes/_ctypes.c - PyExc_ArgError -
+Modules/_cursesmodule.c - PyCursesError -
+Modules/_decimal/_decimal.c - DecimalException -
+Modules/_queuemodule.c - EmptyError -
+Modules/_sqlite/module.h - pysqlite_Error -
+Modules/_sqlite/module.h - pysqlite_Warning -
+Modules/_sqlite/module.h - pysqlite_InterfaceError -
+Modules/_sqlite/module.h - pysqlite_DatabaseError -
+Modules/_sqlite/module.h - pysqlite_InternalError -
+Modules/_sqlite/module.h - pysqlite_OperationalError -
+Modules/_sqlite/module.h - pysqlite_ProgrammingError -
+Modules/_sqlite/module.h - pysqlite_IntegrityError -
+Modules/_sqlite/module.h - pysqlite_DataError -
+Modules/_sqlite/module.h - pysqlite_NotSupportedError -
+Modules/_ssl.c - PySSLErrorObject -
+Modules/_ssl.c - PySSLCertVerificationErrorObject -
+Modules/_ssl.c - PySSLZeroReturnErrorObject -
+Modules/_ssl.c - PySSLWantReadErrorObject -
+Modules/_ssl.c - PySSLWantWriteErrorObject -
+Modules/_ssl.c - PySSLSyscallErrorObject -
+Modules/_ssl.c - PySSLEOFErrorObject -
+Modules/_threadmodule.c - ThreadError -
+Modules/_tkinter.c - Tkinter_TclError -
+Modules/_xxsubinterpretersmodule.c - ChannelError -
+Modules/_xxsubinterpretersmodule.c - ChannelNotFoundError -
+Modules/_xxsubinterpretersmodule.c - ChannelClosedError -
+Modules/_xxsubinterpretersmodule.c - ChannelEmptyError -
+Modules/_xxsubinterpretersmodule.c - ChannelNotEmptyError -
+Modules/_xxsubinterpretersmodule.c - RunFailedError -
+Modules/ossaudiodev.c - OSSAudioError -
+Modules/pyexpat.c - ErrorObject -
+Modules/signalmodule.c - ItimerError -
+Modules/socketmodule.c - socket_herror -
+Modules/socketmodule.c - socket_gaierror -
+Modules/socketmodule.c - socket_timeout -
+Modules/xxlimited.c - ErrorObject -
+Modules/xxmodule.c - ErrorObject -
+
+#-----------------------
+# module initialized once - cached PyUnicode
+# []
+
+# Py_IDENTIFIER (global) []
+Modules/faulthandler.c - PyId_enable -
+Modules/faulthandler.c - PyId_fileno -
+Modules/faulthandler.c - PyId_flush -
+Modules/faulthandler.c - PyId_stderr -
+Modules/_asynciomodule.c - PyId___asyncio_running_event_loop__ -
+Modules/_asynciomodule.c - PyId__asyncio_future_blocking -
+Modules/_asynciomodule.c - PyId_add_done_callback -
+Modules/_asynciomodule.c - PyId_call_soon -
+Modules/_asynciomodule.c - PyId_cancel -
+Modules/_asynciomodule.c - PyId_get_event_loop -
+Modules/_asynciomodule.c - PyId_throw -
+Modules/posixmodule.c - PyId___fspath__ -
+Modules/_abc.c - PyId___abstractmethods__ -
+Modules/_abc.c - PyId___class__ -
+Modules/_abc.c - PyId___dict__ -
+Modules/_abc.c - PyId___bases__ -
+Modules/_abc.c - PyId__abc_impl -
+Modules/_abc.c - PyId___subclasscheck__ -
+Modules/_abc.c - PyId___subclasshook__ -
+Modules/_bisectmodule.c - PyId_insert -
+Modules/_threadmodule.c - PyId_stderr -
+Modules/_threadmodule.c - PyId_flush -
+Modules/unicodedata.c - PyId_NFC -
+Modules/unicodedata.c - PyId_NFD -
+Modules/unicodedata.c - PyId_NFKC -
+Modules/unicodedata.c - PyId_NFKD -
+Modules/_datetimemodule.c - PyId_as_integer_ratio -
+Modules/_datetimemodule.c - PyId_fromutc -
+Modules/_datetimemodule.c - PyId_isoformat -
+Modules/_datetimemodule.c - PyId_strftime -
+Modules/_sqlite/connection.c - PyId_cursor -
+Modules/cjkcodecs/multibytecodec.c - PyId_write -
+Modules/_io/textio.c - PyId_close -
+Modules/_io/textio.c - PyId__dealloc_warn -
+Modules/_io/textio.c - PyId_decode -
+Modules/_io/textio.c - PyId_fileno -
+Modules/_io/textio.c - PyId_flush -
+Modules/_io/textio.c - PyId_getpreferredencoding -
+Modules/_io/textio.c - PyId_isatty -
+Modules/_io/textio.c - PyId_mode -
+Modules/_io/textio.c - PyId_name -
+Modules/_io/textio.c - PyId_raw -
+Modules/_io/textio.c - PyId_read -
+Modules/_io/textio.c - PyId_readable -
+Modules/_io/textio.c - PyId_replace -
+Modules/_io/textio.c - PyId_reset -
+Modules/_io/textio.c - PyId_seek -
+Modules/_io/textio.c - PyId_seekable -
+Modules/_io/textio.c - PyId_setstate -
+Modules/_io/textio.c - PyId_strict -
+Modules/_io/textio.c - PyId_tell -
+Modules/_io/textio.c - PyId_writable -
+Modules/_io/fileio.c - PyId_name -
+Modules/_io/bufferedio.c - PyId_close -
+Modules/_io/bufferedio.c - PyId__dealloc_warn -
+Modules/_io/bufferedio.c - PyId_flush -
+Modules/_io/bufferedio.c - PyId_isatty -
+Modules/_io/bufferedio.c - PyId_mode -
+Modules/_io/bufferedio.c - PyId_name -
+Modules/_io/bufferedio.c - PyId_peek -
+Modules/_io/bufferedio.c - PyId_read -
+Modules/_io/bufferedio.c - PyId_read1 -
+Modules/_io/bufferedio.c - PyId_readable -
+Modules/_io/bufferedio.c - PyId_readinto -
+Modules/_io/bufferedio.c - PyId_readinto1 -
+Modules/_io/bufferedio.c - PyId_writable -
+Modules/_io/bufferedio.c - PyId_write -
+Modules/_io/iobase.c - PyId___IOBase_closed -
+Modules/_io/iobase.c - PyId_read -
+
+# Py_IDENTIFIER (local) []
+Modules/_ssl.c fill_and_set_sslerror PyId_reason -
+Modules/_ssl.c fill_and_set_sslerror PyId_library -
+Modules/_ssl.c fill_and_set_sslerror PyId_verify_message -
+Modules/_ssl.c fill_and_set_sslerror PyId_verify_code -
+Modules/timemodule.c time_strptime PyId__strptime_time -
+Modules/itertoolsmodule.c _grouper_reduce PyId_iter -
+Modules/itertoolsmodule.c itertools_tee_impl PyId___copy__ -
+Modules/itertoolsmodule.c cycle_reduce PyId___setstate__ -
+Modules/itertoolsmodule.c zip_longest_new PyId_fillvalue -
+Modules/mmapmodule.c mmap__exit__method PyId_close -
+Modules/_gdbmmodule.c gdbm__exit__ PyId_close -
+Modules/arraymodule.c array_array_fromfile_impl PyId_read -
+Modules/arraymodule.c array_array_tofile PyId_write -
+Modules/arraymodule.c array_array___reduce_ex__ PyId__array_reconstructor -
+Modules/arraymodule.c array_array___reduce_ex__ PyId___dict__ -
+Modules/arraymodule.c array_arrayiterator___reduce___impl PyId_iter -
+Modules/_collectionsmodule.c deque_reduce PyId___dict__ -
+Modules/_collectionsmodule.c defdict_reduce PyId_items -
+Modules/_collectionsmodule.c _collections__count_elements_impl PyId_get -
+Modules/_collectionsmodule.c _collections__count_elements_impl PyId___setitem__ -
+Modules/_csv.c csv_writer PyId_write -
+Modules/_asynciomodule.c get_future_loop PyId_get_loop -
+Modules/_asynciomodule.c get_future_loop PyId__loop -
+Modules/_asynciomodule.c future_init PyId_get_debug -
+Modules/_asynciomodule.c FutureObj_get_state PyId_PENDING -
+Modules/_asynciomodule.c FutureObj_get_state PyId_CANCELLED -
+Modules/_asynciomodule.c FutureObj_get_state PyId_FINISHED -
+Modules/_asynciomodule.c FutureObj_repr PyId__repr_info -
+Modules/_asynciomodule.c FutureObj_finalize PyId_call_exception_handler -
+Modules/_asynciomodule.c FutureObj_finalize PyId_message -
+Modules/_asynciomodule.c FutureObj_finalize PyId_exception -
+Modules/_asynciomodule.c FutureObj_finalize PyId_future -
+Modules/_asynciomodule.c FutureObj_finalize PyId_source_traceback -
+Modules/_asynciomodule.c register_task PyId_add -
+Modules/_asynciomodule.c unregister_task PyId_discard -
+Modules/_asynciomodule.c TaskObj_finalize PyId_call_exception_handler -
+Modules/_asynciomodule.c TaskObj_finalize PyId_task -
+Modules/_asynciomodule.c TaskObj_finalize PyId_message -
+Modules/_asynciomodule.c TaskObj_finalize PyId_source_traceback -
+Modules/mathmodule.c math_ceil PyId___ceil__ -
+Modules/mathmodule.c math_floor PyId___floor__ -
+Modules/mathmodule.c math_trunc PyId___trunc__ -
+Modules/_operator.c methodcaller_reduce PyId_partial -
+Modules/_lzmamodule.c build_filter_spec PyId_id -
+Modules/_lzmamodule.c build_filter_spec PyId_lc -
+Modules/_lzmamodule.c build_filter_spec PyId_lp -
+Modules/_lzmamodule.c build_filter_spec PyId_pb -
+Modules/_lzmamodule.c build_filter_spec PyId_dict_size -
+Modules/_lzmamodule.c build_filter_spec PyId_dist -
+Modules/_lzmamodule.c build_filter_spec PyId_start_offset -
+Modules/pyexpat.c pyexpat_xmlparser_ParseFile PyId_read -
+Modules/_threadmodule.c thread_excepthook_file PyId_name -
+Modules/_elementtree.c _elementtree_Element_find_impl PyId_find -
+Modules/_elementtree.c _elementtree_Element_findtext_impl PyId_findtext -
+Modules/_elementtree.c _elementtree_Element_findall_impl PyId_findall -
+Modules/_elementtree.c _elementtree_Element_iterfind_impl PyId_iterfind -
+Modules/_elementtree.c treebuilder_flush_data PyId_text -
+Modules/_elementtree.c treebuilder_flush_data PyId_tail -
+Modules/_elementtree.c treebuilder_add_subelement PyId_append -
+Modules/_elementtree.c expat_start_doctype_handler PyId_doctype -
+Modules/_pickle.c _Pickle_InitState PyId_getattr -
+Modules/_pickle.c _Pickler_SetOutputStream PyId_write -
+Modules/_pickle.c _Unpickler_SetInputStream PyId_peek -
+Modules/_pickle.c _Unpickler_SetInputStream PyId_read -
+Modules/_pickle.c _Unpickler_SetInputStream PyId_readinto -
+Modules/_pickle.c _Unpickler_SetInputStream PyId_readline -
+Modules/_pickle.c whichmodule PyId___module__ -
+Modules/_pickle.c whichmodule PyId_modules -
+Modules/_pickle.c whichmodule PyId___main__ -
+Modules/_pickle.c save_bytes PyId_latin1 -
+Modules/_pickle.c save_dict PyId_items -
+Modules/_pickle.c save_global PyId___name__ -
+Modules/_pickle.c save_global PyId___qualname__ -
+Modules/_pickle.c get_class PyId___class__ -
+Modules/_pickle.c save_reduce PyId___name__ -
+Modules/_pickle.c save_reduce PyId___newobj_ex__ -
+Modules/_pickle.c save_reduce PyId___newobj__ -
+Modules/_pickle.c save_reduce PyId___new__ -
+Modules/_pickle.c save PyId___reduce__ -
+Modules/_pickle.c save PyId___reduce_ex__ -
+Modules/_pickle.c dump PyId_reducer_override -
+Modules/_pickle.c _pickle_Pickler___init___impl PyId_persistent_id -
+Modules/_pickle.c _pickle_Pickler___init___impl PyId_dispatch_table -
+Modules/_pickle.c find_class PyId_find_class -
+Modules/_pickle.c instantiate PyId___getinitargs__ -
+Modules/_pickle.c instantiate PyId___new__ -
+Modules/_pickle.c do_append PyId_extend -
+Modules/_pickle.c do_append PyId_append -
+Modules/_pickle.c load_additems PyId_add -
+Modules/_pickle.c load_build PyId___setstate__ -
+Modules/_pickle.c load_build PyId___dict__ -
+Modules/_pickle.c _pickle_Unpickler___init___impl PyId_persistent_load -
+Modules/_cursesmodule.c _curses_window_putwin PyId_write -
+Modules/_cursesmodule.c _curses_getwin PyId_read -
+Modules/_cursesmodule.c update_lines_cols PyId_LINES -
+Modules/_cursesmodule.c update_lines_cols PyId_COLS -
+Modules/_datetimemodule.c call_tzname PyId_tzname -
+Modules/_datetimemodule.c make_Zreplacement PyId_replace -
+Modules/_datetimemodule.c time_time PyId_time -
+Modules/_datetimemodule.c build_struct_time PyId_struct_time -
+Modules/_datetimemodule.c date_today PyId_fromtimestamp -
+Modules/_datetimemodule.c date_strftime PyId_timetuple -
+Modules/_datetimemodule.c tzinfo_reduce PyId___getinitargs__ -
+Modules/_datetimemodule.c tzinfo_reduce PyId___getstate__ -
+Modules/_datetimemodule.c datetime_strptime PyId__strptime_datetime -
+Modules/ossaudiodev.c oss_exit PyId_close -
+Modules/main.c pymain_sys_path_add_path0 PyId_path -
+Modules/_sqlite/microprotocols.c pysqlite_microprotocols_adapt PyId___adapt__ -
+Modules/_sqlite/microprotocols.c pysqlite_microprotocols_adapt PyId___conform__ -
+Modules/_sqlite/connection.c _pysqlite_final_callback PyId_finalize -
+Modules/_sqlite/connection.c pysqlite_connection_set_isolation_level PyId_upper -
+Modules/_sqlite/connection.c pysqlite_connection_iterdump PyId__iterdump -
+Modules/_sqlite/connection.c pysqlite_connection_create_collation PyId_upper -
+Modules/_sqlite/module.c module_register_converter PyId_upper -
+Modules/_sqlite/cursor.c _pysqlite_get_converter PyId_upper -
+Modules/_io/_iomodule.c _io_open_impl PyId__blksize -
+Modules/_io/_iomodule.c _io_open_impl PyId_isatty -
+Modules/_io/_iomodule.c _io_open_impl PyId_mode -
+Modules/_io/_iomodule.c _io_open_impl PyId_close -
+Modules/_io/fileio.c _io_FileIO_close_impl PyId_close -
+Modules/_io/iobase.c _io__IOBase_tell_impl PyId_seek -
+Modules/_io/iobase.c iobase_finalize PyId__finalizing -
+Modules/_io/iobase.c _io__IOBase_readlines_impl PyId_extend -
+Modules/_io/iobase.c _io__RawIOBase_read_impl PyId_readall -
+Modules/_ctypes/stgdict.c MakeAnonFields PyId__anonymous_ -
+Modules/_ctypes/stgdict.c PyCStructUnionType_update_stgdict PyId__swappedbytes_ -
+Modules/_ctypes/stgdict.c PyCStructUnionType_update_stgdict PyId__use_broken_old_ctypes_structure_semantics_ -
+Modules/_ctypes/stgdict.c PyCStructUnionType_update_stgdict PyId__pack_ -
+Modules/_ctypes/callproc.c ConvParam PyId__as_parameter_ -
+Modules/_ctypes/callproc.c unpickle PyId___new__ -
+Modules/_ctypes/callproc.c unpickle PyId___setstate__ -
+Modules/_ctypes/_ctypes.c StructUnionType_new PyId__abstract_ -
+Modules/_ctypes/_ctypes.c StructUnionType_new PyId__fields_ -
+Modules/_ctypes/_ctypes.c CDataType_from_param PyId__as_parameter_ -
+Modules/_ctypes/_ctypes.c PyCPointerType_new PyId__type_ -
+Modules/_ctypes/_ctypes.c PyCPointerType_set_type PyId__type_ -
+Modules/_ctypes/_ctypes.c PyCArrayType_new PyId__length_ -
+Modules/_ctypes/_ctypes.c PyCArrayType_new PyId__type_ -
+Modules/_ctypes/_ctypes.c c_wchar_p_from_param PyId__as_parameter_ -
+Modules/_ctypes/_ctypes.c c_char_p_from_param PyId__as_parameter_ -
+Modules/_ctypes/_ctypes.c c_void_p_from_param PyId__as_parameter_ -
+Modules/_ctypes/_ctypes.c PyCSimpleType_new PyId__type_ -
+Modules/_ctypes/_ctypes.c PyCSimpleType_from_param PyId__as_parameter_ -
+Modules/_ctypes/_ctypes.c converters_from_argtypes PyId_from_param -
+Modules/_ctypes/_ctypes.c make_funcptrtype_dict PyId__flags_ -
+Modules/_ctypes/_ctypes.c make_funcptrtype_dict PyId__argtypes_ -
+Modules/_ctypes/_ctypes.c make_funcptrtype_dict PyId__restype_ -
+Modules/_ctypes/_ctypes.c make_funcptrtype_dict PyId__check_retval_ -
+Modules/_ctypes/_ctypes.c PyCFuncPtr_set_restype PyId__check_retval_ -
+Modules/_ctypes/_ctypes.c _build_result PyId___ctypes_from_outparam__ -
+Modules/_ctypes/_ctypes.c _init_pos_args PyId__fields_ -
+
+# _Py_static_string []
+Modules/_pickle.c get_dotted_path PyId_dot -
+
+# manually cached PyUnicodeOjbect []
+Modules/_asynciomodule.c - context_kwname -
+Modules/_ctypes/callproc.c _ctypes_get_errobj error_object_name -
+Modules/_ctypes/_ctypes.c CreateSwappedType suffix -
+Modules/_io/_iomodule.c - _PyIO_str_close -
+Modules/_io/_iomodule.c - _PyIO_str_closed -
+Modules/_io/_iomodule.c - _PyIO_str_decode -
+Modules/_io/_iomodule.c - _PyIO_str_encode -
+Modules/_io/_iomodule.c - _PyIO_str_fileno -
+Modules/_io/_iomodule.c - _PyIO_str_flush -
+Modules/_io/_iomodule.c - _PyIO_str_getstate -
+Modules/_io/_iomodule.c - _PyIO_str_isatty -
+Modules/_io/_iomodule.c - _PyIO_str_newlines -
+Modules/_io/_iomodule.c - _PyIO_str_nl -
+Modules/_io/_iomodule.c - _PyIO_str_peek -
+Modules/_io/_iomodule.c - _PyIO_str_read -
+Modules/_io/_iomodule.c - _PyIO_str_read1 -
+Modules/_io/_iomodule.c - _PyIO_str_readable -
+Modules/_io/_iomodule.c - _PyIO_str_readall -
+Modules/_io/_iomodule.c - _PyIO_str_readinto -
+Modules/_io/_iomodule.c - _PyIO_str_readline -
+Modules/_io/_iomodule.c - _PyIO_str_reset -
+Modules/_io/_iomodule.c - _PyIO_str_seek -
+Modules/_io/_iomodule.c - _PyIO_str_seekable -
+Modules/_io/_iomodule.c - _PyIO_str_setstate -
+Modules/_io/_iomodule.c - _PyIO_str_tell -
+Modules/_io/_iomodule.c - _PyIO_str_truncate -
+Modules/_io/_iomodule.c - _PyIO_str_writable -
+Modules/_io/_iomodule.c - _PyIO_str_write -
+Modules/_io/_iomodule.c - _PyIO_empty_str -
+Modules/_json.c _encoded_const s_null -
+Modules/_json.c _encoded_const s_true -
+Modules/_json.c _encoded_const s_false -
+Modules/_json.c encoder_listencode_dict open_dict -
+Modules/_json.c encoder_listencode_dict close_dict -
+Modules/_json.c encoder_listencode_dict empty_dict -
+Modules/_json.c encoder_listencode_list open_array -
+Modules/_json.c encoder_listencode_list close_array -
+Modules/_json.c encoder_listencode_list empty_array -
+Modules/_threadmodule.c - str_dict -
+Modules/_tracemalloc.c - unknown_filename -
+
+#-----------------------
+# module initialized once - other PyObject
+# []
+
+# cached during module init []
+Modules/_asynciomodule.c - asyncio_mod -
+Modules/_asynciomodule.c - traceback_extract_stack -
+Modules/_asynciomodule.c - asyncio_get_event_loop_policy -
+Modules/_asynciomodule.c - asyncio_future_repr_info_func -
+Modules/_asynciomodule.c - asyncio_iscoroutine_func -
+Modules/_asynciomodule.c - asyncio_task_get_stack_func -
+Modules/_asynciomodule.c - asyncio_task_print_stack_func -
+Modules/_asynciomodule.c - asyncio_task_repr_info_func -
+Modules/_asynciomodule.c - asyncio_InvalidStateError -
+Modules/_asynciomodule.c - asyncio_CancelledError -
+Modules/_zoneinfo.c - io_open -
+Modules/_zoneinfo.c - _tzpath_find_tzfile -
+Modules/_zoneinfo.c - _common_mod -
+
+# other []
+Modules/_ctypes/_ctypes.c - _unpickle -
+Modules/_ctypes/_ctypes.c PyCArrayType_from_ctype cache -
+Modules/_cursesmodule.c - ModDict -
+Modules/_datetimemodule.c datetime_strptime module -
+Modules/_datetimemodule.c - PyDateTime_TimeZone_UTC -
+Modules/_datetimemodule.c - PyDateTime_Epoch -
+Modules/_datetimemodule.c - us_per_ms -
+Modules/_datetimemodule.c - us_per_second -
+Modules/_datetimemodule.c - us_per_minute -
+Modules/_datetimemodule.c - us_per_hour -
+Modules/_datetimemodule.c - us_per_day -
+Modules/_datetimemodule.c - us_per_week -
+Modules/_datetimemodule.c - seconds_per_day -
+Modules/_decimal/_decimal.c PyInit__decimal capsule -
+Modules/_decimal/_decimal.c - basic_context_template -
+Modules/_decimal/_decimal.c - current_context_var -
+Modules/_decimal/_decimal.c - default_context_template -
+Modules/_decimal/_decimal.c - extended_context_template -
+Modules/_decimal/_decimal.c - round_map -
+Modules/_decimal/_decimal.c - Rational -
+Modules/_decimal/_decimal.c - SignalTuple -
+Modules/_functoolsmodule.c - kwd_mark -
+Modules/_io/_iomodule.c - _PyIO_empty_bytes -
+Modules/_json.c raise_errmsg JSONDecodeError -
+Modules/_sqlite/microprotocols.c - psyco_adapters -
+Modules/_sqlite/module.h - _pysqlite_converters -
+Modules/_ssl.c - err_codes_to_names -
+Modules/_ssl.c - err_names_to_codes -
+Modules/_ssl.c - lib_codes_to_names -
+# XXX This should have been found by the analyzer but wasn't:
+Modules/_ssl.c - _ssl_locks -
+Modules/_struct.c - cache -
+Modules/_tracemalloc.c - tracemalloc_empty_traceback -
+Modules/arraymodule.c array_array___reduce_ex__ array_reconstructor -
+Modules/cjkcodecs/cjkcodecs.h getmultibytecodec cofunc -
+Modules/signalmodule.c - DefaultHandler -
+Modules/signalmodule.c - IgnoreHandler -
+Modules/signalmodule.c - IntHandler -
+
+#-----------------------
+# module initialized once - non-PyObject
+# []
+
+# pre-allocated buffer []
+Modules/getbuildinfo.c Py_GetBuildInfo buildinfo -
+Modules/nismodule.c nisproc_maplist_2 res -
+Modules/pyexpat.c PyUnknownEncodingHandler template_buffer -
+
+# other []
+Include/datetime.h - PyDateTimeAPI -
+Modules/_asynciomodule.c - module_initialized -
+Modules/_ctypes/cfield.c _ctypes_get_fielddesc initialized -
+Modules/_ctypes/malloc_closure.c - _pagesize -
+Modules/_cursesmodule.c - initialised -
+Modules/_cursesmodule.c - initialised_setupterm -
+Modules/_cursesmodule.c - initialisedcolors -
+Modules/_cursesmodule.c - screen_encoding -
+Modules/_cursesmodule.c PyInit__curses PyCurses_API -
+Modules/_datetimemodule.c - CAPI -
+Modules/_decimal/_decimal.c PyInit__decimal initialized -
+Modules/_decimal/_decimal.c - _py_long_multiply -
+Modules/_decimal/_decimal.c - _py_long_floor_divide -
+Modules/_decimal/_decimal.c - _py_long_power -
+Modules/_decimal/_decimal.c - _py_float_abs -
+Modules/_decimal/_decimal.c - _py_long_bit_length -
+Modules/_decimal/_decimal.c - _py_float_as_integer_ratio -
+Modules/_decimal/_decimal.c - _decimal_api -
+Modules/_elementtree.c - expat_capi -
+Modules/_io/bufferedio.c _PyIO_trap_eintr eintr_int -
+Modules/_sqlite/module.h - _pysqlite_enable_callback_tracebacks -
+Modules/_sqlite/module.h - pysqlite_BaseTypeAdapted -
+Modules/_ssl.c - _ssl_locks_count -
+Modules/cjkcodecs/cjkcodecs.h - codec_list -
+Modules/cjkcodecs/cjkcodecs.h - mapping_list -
+# XXX This should have been found by the analyzer but wasn't:
+Python/fileutils.c - _Py_open_cloexec_works -
+Modules/getaddrinfo.c - gai_afdl -
+Modules/posixmodule.c os_dup2_impl dup3_works -
+Modules/posixmodule.c - structseq_new -
+Modules/posixmodule.c - ticks_per_second -
+Modules/pyexpat.c PyInit_pyexpat capi -
+Modules/readline.c - using_libedit_emulation -
+Modules/readline.c - libedit_history_start -
+Modules/resource.c - initialized -
+Modules/signalmodule.c - initialized -
+Modules/socketmodule.c - accept4_works -
+Modules/socketmodule.c - sock_cloexec_works -
+Modules/socketmodule.c - PySocketModuleAPI -
+Modules/spwdmodule.c - initialized -
+Modules/timemodule.c - initialized -
+Modules/timemodule.c _PyTime_GetClockWithInfo initialized -
+Modules/timemodule.c _PyTime_GetProcessTimeWithInfo ticks_per_second -
+
+#-----------------------
+# module state
+# []
+
+Modules/posixmodule.c - environ -
+
+# PyObject []
+Modules/_asynciomodule.c - cached_running_holder -
+Modules/_asynciomodule.c - fi_freelist -
+Modules/_asynciomodule.c - fi_freelist_len -
+Modules/_asynciomodule.c - all_tasks -
+Modules/_asynciomodule.c - current_tasks -
+Modules/_asynciomodule.c - iscoroutine_typecache -
+Modules/_ctypes/_ctypes.c - _ctypes_ptrtype_cache -
+Modules/_tkinter.c - tcl_lock -
+Modules/_tkinter.c - excInCmd -
+Modules/_tkinter.c - valInCmd -
+Modules/_tkinter.c - trbInCmd -
+Modules/_zoneinfo.c - TIMEDELTA_CACHE -
+Modules/_zoneinfo.c - ZONEINFO_WEAK_CACHE -
+Modules/faulthandler.c - fatal_error -
+Modules/faulthandler.c - thread -
+Modules/faulthandler.c - user_signals -
+Modules/faulthandler.c - stack -
+Modules/faulthandler.c - old_stack -
+Modules/signalmodule.c - Handlers -
+Modules/syslogmodule.c - S_ident_o -
+
+# other []
+Modules/_asynciomodule.c - cached_running_holder_tsid -
+Modules/_asynciomodule.c - task_name_counter -
+Modules/_ctypes/cfield.c - formattable -
+Modules/_ctypes/malloc_closure.c - free_list -
+Modules/_curses_panel.c - lop -
+Modules/_tkinter.c - quitMainLoop -
+Modules/_tkinter.c - errorInCmd -
+Modules/_tkinter.c - Tkinter_busywaitinterval -
+Modules/_tkinter.c - call_mutex -
+Modules/_tkinter.c - var_mutex -
+Modules/_tkinter.c - command_mutex -
+Modules/_tkinter.c - HeadFHCD -
+Modules/_tkinter.c - stdin_ready -
+Modules/_tkinter.c - event_tstate -
+Modules/_tracemalloc.c - allocators -
+Modules/_tracemalloc.c - tables_lock -
+Modules/_tracemalloc.c - tracemalloc_traced_memory -
+Modules/_tracemalloc.c - tracemalloc_peak_traced_memory -
+Modules/_tracemalloc.c - tracemalloc_filenames -
+Modules/_tracemalloc.c - tracemalloc_traceback -
+Modules/_tracemalloc.c - tracemalloc_tracebacks -
+Modules/_tracemalloc.c - tracemalloc_traces -
+Modules/_tracemalloc.c - tracemalloc_domains -
+Modules/_tracemalloc.c - tracemalloc_reentrant_key -
+Modules/_xxsubinterpretersmodule.c - _globals -
+Modules/_zoneinfo.c - ZONEINFO_STRONG_CACHE -
+Modules/_zoneinfo.c - ZONEINFO_STRONG_CACHE_MAX_SIZE -
+Modules/_zoneinfo.c - NO_TTINFO -
+Modules/faulthandler.c faulthandler_dump_traceback reentrant -
+Modules/readline.c - completer_word_break_characters -
+Modules/readline.c - _history_length -
+Modules/readline.c - should_auto_add_history -
+Modules/readline.c - sigwinch_received -
+Modules/readline.c - sigwinch_ohandler -
+Modules/readline.c - completed_input_string -
+Modules/rotatingtree.c - random_stream -
+Modules/rotatingtree.c - random_value -
+Modules/signalmodule.c - is_tripped -
+Modules/signalmodule.c - wakeup -
+Modules/socketmodule.c - defaulttimeout -
+Modules/syslogmodule.c - S_log_open -
+
+#-----------------------
+# runtime state
+# []
+
+# PyObject []
+Objects/typeobject.c resolve_slotdups pname -
+# XXX This should have been found by the analyzer but wasn't:
+Python/import.c - extensions -
+
+# allocator []
+Objects/obmalloc.c - _Py_tracemalloc_config -
+Objects/obmalloc.c - _PyObject_Arena -
+Objects/obmalloc.c - arenas -
+Objects/obmalloc.c - maxarenas -
+Objects/obmalloc.c - unused_arena_objects -
+Objects/obmalloc.c - usable_arenas -
+Objects/obmalloc.c - nfp2lasta -
+Objects/obmalloc.c - narenas_currently_allocated -
+Objects/obmalloc.c - ntimes_arena_allocated -
+Objects/obmalloc.c - narenas_highwater -
+Objects/obmalloc.c - raw_allocated_blocks -
+Objects/obmalloc.c new_arena debug_stats -
+
+# REPL []
+Parser/myreadline.c - _PyOS_ReadlineLock -
+Parser/myreadline.c - _PyOS_ReadlineTState -
+Parser/myreadline.c - PyOS_InputHook -
+Parser/myreadline.c - PyOS_ReadlineFunctionPointer -
+
+# other []
+Objects/dictobject.c - pydict_global_version -
+Objects/floatobject.c - double_format -
+Objects/floatobject.c - float_format -
+Objects/floatobject.c - detected_double_format -
+Objects/floatobject.c - detected_float_format -
+Objects/moduleobject.c - max_module_number -
+Objects/object.c - _Py_RefTotal -
+Objects/typeobject.c - next_version_tag -
+Objects/typeobject.c resolve_slotdups ptrs -
+Parser/pegen.c - memo_statistics -
+# XXX This should have been found by the analyzer but wasn't:
+Python/bootstrap_hash.c - urandom_cache -
+# XXX This should have been found by the analyzer but wasn't:
+Python/ceval.c - lltrace -
+# XXX This should have been found by the analyzer but wasn't:
+Python/ceval.c make_pending_calls busy -
+Python/dynload_shlib.c - handles -
+Python/dynload_shlib.c - nhandles -
+# XXX This should have been found by the analyzer but wasn't:
+Python/import.c - import_lock_level -
+# XXX This should have been found by the analyzer but wasn't:
+Python/import.c - import_lock_thread -
+# XXX This should have been found by the analyzer but wasn't:
+Python/import.c import_find_and_load accumulated -
+# XXX This should have been found by the analyzer but wasn't:
+Python/import.c import_find_and_load import_level -
+# XXX This should have been found by the analyzer but wasn't:
+Python/pylifecycle.c - _Py_UnhandledKeyboardInterrupt -
+# XXX This should have been found by the analyzer but wasn't:
+Python/pylifecycle.c fatal_error reentrant -
diff --git a/Tools/c-analyzer/must-resolve.sh b/Tools/c-analyzer/must-resolve.sh
new file mode 100755
index 0000000000..191e42241f
--- /dev/null
+++ b/Tools/c-analyzer/must-resolve.sh
@@ -0,0 +1,75 @@
+#!/usr/bin/env bash
+
+# Any PyObject exposed via the public API is problematic since it must
+# be made per-interpreter. This involves the following:
+#
+# singletons:
+# - None
+# - True
+# - False
+# - NotImplemented
+# - Ellipsis
+# PyTypeObject:
+# - PyExc* [97]
+# - static types [81]
+#
+# In the non-stable API we could use #defines to do the conversion
+# transparently (though Py_None is perhaps problematic for performance
+# reasons). However, we can't take that approach with the stable API.
+# That means we must find all functions (& macros) in the stable API
+# (and probably the full public API, for sanity sake) and adjust them.
+# This will involve internally converting from the public object to the
+# corresponding per-interpreter object.
+#
+# Note that the only place this solution fails is with direct pointer
+# equality checks with the public objects.
+
+# XXX What about saying that the stable API is not sub-interpreter
+# compatible?
+
+
+function run_capi() {
+ ./python Tools/c-analyzer/c-analyzer.py capi \
+ --no-progress \
+ --group-by kind \
+ --func --inline --macro \
+ --no-show-empty \
+ --ignore '<must-resolve.ignored>' \
+ $@
+}
+
+echo ''
+echo '#################################################'
+echo '# All API'
+echo '#################################################'
+run_capi --format summary Include/*.h Include/cpython/*.h
+run_capi --format table Include/*.h Include/cpython/*.h
+echo ''
+echo ''
+echo '#################################################'
+echo '# stable API'
+echo '#################################################'
+echo ''
+echo '# public:'
+run_capi --format summary --public --no-show-empty Include/*.h
+echo ''
+echo '# private:'
+run_capi --format summary --private --no-show-empty Include/*.h
+echo ''
+run_capi --format full -v Include/*.h
+#run_capi --format full -v --public Include/*.h
+#run_capi --format full -v --private Include/*.h
+echo ''
+echo '#################################################'
+echo '# cpython API'
+echo '#################################################'
+echo ''
+echo '# public:'
+run_capi --format summary --public --no-show-empty Include/cpython/*.h
+echo ''
+echo '# private:'
+run_capi --format summary --private --no-show-empty Include/cpython/*.h
+echo ''
+run_capi --format full -v Include/cpython/*.h
+#run_capi --format full -v --public Include/cpython/*.h
+#run_capi --format full -v --private Include/cpython/*.h
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 5f2eb53e6a..d4d7795246 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -1777,6 +1777,30 @@ legacy_converters = {}
# The callable should not call builtins.print.
return_converters = {}
+
+def write_file(filename, new_contents):
+ try:
+ with open(filename, 'r', encoding="utf-8") as fp:
+ old_contents = fp.read()
+
+ if old_contents == new_contents:
+ # no change: avoid modifying the file modification time
+ return
+ except FileNotFoundError:
+ pass
+
+ # Atomic write using a temporary file and os.replace()
+ filename_new = f"{filename}.new"
+ with open(filename_new, "w", encoding="utf-8") as fp:
+ fp.write(new_contents)
+
+ try:
+ os.replace(filename_new, filename)
+ except:
+ os.unlink(filename_new)
+ raise
+
+
clinic = None
class Clinic:
@@ -1823,7 +1847,7 @@ impl_definition block
"""
- def __init__(self, language, printer=None, *, force=False, verify=True, filename=None):
+ def __init__(self, language, printer=None, *, verify=True, filename=None):
# maps strings to Parser objects.
# (instantiated from the "parsers" global.)
self.parsers = {}
@@ -1832,7 +1856,6 @@ impl_definition block
fail("Custom printers are broken right now")
self.printer = printer or BlockPrinter(language)
self.verify = verify
- self.force = force
self.filename = filename
self.modules = collections.OrderedDict()
self.classes = collections.OrderedDict()
@@ -1965,8 +1988,7 @@ impl_definition block
block.input = 'preserve\n'
printer_2 = BlockPrinter(self.language)
printer_2.print_block(block)
- with open(destination.filename, "wt") as f:
- f.write(printer_2.f.getvalue())
+ write_file(destination.filename, printer_2.f.getvalue())
continue
text = printer.f.getvalue()
@@ -2018,7 +2040,10 @@ impl_definition block
return module, cls
-def parse_file(filename, *, force=False, verify=True, output=None, encoding='utf-8'):
+def parse_file(filename, *, verify=True, output=None):
+ if not output:
+ output = filename
+
extension = os.path.splitext(filename)[1][1:]
if not extension:
fail("Can't extract file type for file " + repr(filename))
@@ -2028,7 +2053,7 @@ def parse_file(filename, *, force=False, verify=True, output=None, encoding='utf
except KeyError:
fail("Can't identify file type for file " + repr(filename))
- with open(filename, 'r', encoding=encoding) as f:
+ with open(filename, 'r', encoding="utf-8") as f:
raw = f.read()
# exit quickly if there are no clinic markers in the file
@@ -2036,19 +2061,10 @@ def parse_file(filename, *, force=False, verify=True, output=None, encoding='utf
if not find_start_re.search(raw):
return
- clinic = Clinic(language, force=force, verify=verify, filename=filename)
+ clinic = Clinic(language, verify=verify, filename=filename)
cooked = clinic.parse(raw)
- if (cooked == raw) and not force:
- return
-
- directory = os.path.dirname(filename) or '.'
- with tempfile.TemporaryDirectory(prefix="clinic", dir=directory) as tmpdir:
- bytes = cooked.encode(encoding)
- tmpfilename = os.path.join(tmpdir, os.path.basename(filename))
- with open(tmpfilename, "wb") as f:
- f.write(bytes)
- os.replace(tmpfilename, output or filename)
+ write_file(output, cooked)
def compute_checksum(input, length=None):
@@ -5105,7 +5121,7 @@ For more information see https://docs.python.org/3/howto/clinic.html""")
path = os.path.join(root, filename)
if ns.verbose:
print(path)
- parse_file(path, force=ns.force, verify=not ns.force)
+ parse_file(path, verify=not ns.force)
return
if not ns.filename:
@@ -5121,7 +5137,7 @@ For more information see https://docs.python.org/3/howto/clinic.html""")
for filename in ns.filename:
if ns.verbose:
print(filename)
- parse_file(filename, output=ns.output, force=ns.force, verify=not ns.force)
+ parse_file(filename, output=ns.output, verify=not ns.force)
if __name__ == "__main__":
diff --git a/Tools/freeze/freeze.py b/Tools/freeze/freeze.py
index 83aa508a46..d66e1e2708 100755
--- a/Tools/freeze/freeze.py
+++ b/Tools/freeze/freeze.py
@@ -93,6 +93,7 @@ import modulefinder
import getopt
import os
import sys
+import sysconfig
# Import the freeze-private modules
@@ -226,7 +227,7 @@ def main():
extensions_c = 'frozen_extensions.c'
if ishome:
print("(Using Python source directory)")
- binlib = exec_prefix
+ configdir = exec_prefix
incldir = os.path.join(prefix, 'Include')
config_h_dir = exec_prefix
config_c_in = os.path.join(prefix, 'Modules', 'config.c.in')
@@ -235,22 +236,21 @@ def main():
if win:
frozendllmain_c = os.path.join(exec_prefix, 'Pc\\frozen_dllmain.c')
else:
- binlib = os.path.join(exec_prefix,
- 'lib', 'python%s' % version,
- 'config-%s' % flagged_version)
+ configdir = sysconfig.get_config_var('LIBPL')
incldir = os.path.join(prefix, 'include', 'python%s' % flagged_version)
config_h_dir = os.path.join(exec_prefix, 'include',
'python%s' % flagged_version)
- config_c_in = os.path.join(binlib, 'config.c.in')
- frozenmain_c = os.path.join(binlib, 'frozenmain.c')
- makefile_in = os.path.join(binlib, 'Makefile')
- frozendllmain_c = os.path.join(binlib, 'frozen_dllmain.c')
+ config_c_in = os.path.join(configdir, 'config.c.in')
+ frozenmain_c = os.path.join(configdir, 'frozenmain.c')
+ makefile_in = os.path.join(configdir, 'Makefile')
+ frozendllmain_c = os.path.join(configdir, 'frozen_dllmain.c')
+ libdir = sysconfig.get_config_var('LIBDIR')
supp_sources = []
defines = []
includes = ['-I' + incldir, '-I' + config_h_dir]
# sanity check of directories and files
- check_dirs = [prefix, exec_prefix, binlib, incldir]
+ check_dirs = [prefix, exec_prefix, configdir, incldir]
if not win:
# These are not directories on Windows.
check_dirs = check_dirs + extensions
@@ -457,7 +457,7 @@ def main():
cflags = ['$(OPT)']
cppflags = defines + includes
- libs = [os.path.join(binlib, '$(LDLIBRARY)')]
+ libs = [os.path.join(libdir, '$(LDLIBRARY)')]
somevars = {}
if os.path.exists(makefile_in):
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index 83a5fa93cf..e18ab0d873 100755
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -468,7 +468,7 @@ class InstanceProxy(object):
def __repr__(self):
if isinstance(self.attrdict, dict):
kwargs = ', '.join(["%s=%r" % (arg, val)
- for arg, val in self.attrdict.iteritems()])
+ for arg, val in self.attrdict.items()])
return '<%s(%s) at remote 0x%x>' % (self.cl_name,
kwargs, self.address)
else:
@@ -648,19 +648,28 @@ class PyCodeObjectPtr(PyObjectPtr):
Analogous to PyCode_Addr2Line; translated from pseudocode in
Objects/lnotab_notes.txt
'''
- co_lnotab = self.pyop_field('co_lnotab').proxyval(set())
+ co_linetable = self.pyop_field('co_linetable').proxyval(set())
# Initialize lineno to co_firstlineno as per PyCode_Addr2Line
# not 0, as lnotab_notes.txt has it:
lineno = int_from_int(self.field('co_firstlineno'))
+ if addrq < 0:
+ return lineno
addr = 0
- for addr_incr, line_incr in zip(co_lnotab[::2], co_lnotab[1::2]):
+ for addr_incr, line_incr in zip(co_linetable[::2], co_linetable[1::2]):
+ if addr_incr == 255:
+ break
addr += ord(addr_incr)
+ line_delta = ord(line_incr)
+ if line_delta == 128:
+ line_delta = 0
+ elif line_delta > 128:
+ line_delta -= 256
+ lineno += line_delta
if addr > addrq:
return lineno
- lineno += ord(line_incr)
- return lineno
+ assert False, "Unreachable"
class PyDictObjectPtr(PyObjectPtr):
diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py
index b1d281d793..9dd65c221f 100755
--- a/Tools/i18n/pygettext.py
+++ b/Tools/i18n/pygettext.py
@@ -162,6 +162,7 @@ import sys
import glob
import time
import getopt
+import ast
import token
import tokenize
@@ -343,6 +344,58 @@ class TokenEater:
return
if ttype == tokenize.NAME and tstring in opts.keywords:
self.__state = self.__keywordseen
+ return
+ if ttype == tokenize.STRING:
+ maybe_fstring = ast.parse(tstring, mode='eval').body
+ if not isinstance(maybe_fstring, ast.JoinedStr):
+ return
+ for value in filter(lambda node: isinstance(node, ast.FormattedValue),
+ maybe_fstring.values):
+ for call in filter(lambda node: isinstance(node, ast.Call),
+ ast.walk(value)):
+ func = call.func
+ if isinstance(func, ast.Name):
+ func_name = func.id
+ elif isinstance(func, ast.Attribute):
+ func_name = func.attr
+ else:
+ continue
+
+ if func_name not in opts.keywords:
+ continue
+ if len(call.args) != 1:
+ print(_(
+ '*** %(file)s:%(lineno)s: Seen unexpected amount of'
+ ' positional arguments in gettext call: %(source_segment)s'
+ ) % {
+ 'source_segment': ast.get_source_segment(tstring, call) or tstring,
+ 'file': self.__curfile,
+ 'lineno': lineno
+ }, file=sys.stderr)
+ continue
+ if call.keywords:
+ print(_(
+ '*** %(file)s:%(lineno)s: Seen unexpected keyword arguments'
+ ' in gettext call: %(source_segment)s'
+ ) % {
+ 'source_segment': ast.get_source_segment(tstring, call) or tstring,
+ 'file': self.__curfile,
+ 'lineno': lineno
+ }, file=sys.stderr)
+ continue
+ arg = call.args[0]
+ if not isinstance(arg, ast.Constant):
+ print(_(
+ '*** %(file)s:%(lineno)s: Seen unexpected argument type'
+ ' in gettext call: %(source_segment)s'
+ ) % {
+ 'source_segment': ast.get_source_segment(tstring, call) or tstring,
+ 'file': self.__curfile,
+ 'lineno': lineno
+ }, file=sys.stderr)
+ continue
+ if isinstance(arg.value, str):
+ self.__addentry(arg.value, lineno)
def __suiteseen(self, ttype, tstring, lineno):
# skip over any enclosure pairs until we see the colon
diff --git a/Tools/msi/purge.py b/Tools/msi/purge.py
index a8b8f4d897..27b6b054a4 100644
--- a/Tools/msi/purge.py
+++ b/Tools/msi/purge.py
@@ -12,7 +12,7 @@ import sys
from urllib.request import *
-VERSION_RE = re.compile(r'(\d+\.\d+\.\d+)(\w+\d+)?$')
+VERSION_RE = re.compile(r'(\d+\.\d+\.\d+)([A-Za-z_]+\d+)?$')
try:
m = VERSION_RE.match(sys.argv[1])
diff --git a/Tools/msi/sdktools.psm1 b/Tools/msi/sdktools.psm1
index 8081b104d8..c5973f9abc 100644
--- a/Tools/msi/sdktools.psm1
+++ b/Tools/msi/sdktools.psm1
@@ -37,11 +37,11 @@ function Sign-File {
foreach ($a in $files) {
if ($certsha1) {
- SignTool sign /sha1 $certsha1 /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d $description $a
+ SignTool sign /sha1 $certsha1 /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d $description $a
} elseif ($certname) {
- SignTool sign /a /n $certname /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d $description $a
+ SignTool sign /a /n $certname /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d $description $a
} elseif ($certfile) {
- SignTool sign /f $certfile /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d $description $a
+ SignTool sign /f $certfile /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d $description $a
}
}
}
diff --git a/Tools/msi/test/test_files.wxs b/Tools/msi/test/test_files.wxs
index 82a9115f75..9127ce8948 100644
--- a/Tools/msi/test/test_files.wxs
+++ b/Tools/msi/test/test_files.wxs
@@ -1,6 +1,6 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
- <?define exts=_testcapi;_ctypes_test;_testbuffer;_testimportmultiple;_testmultiphase;_testconsole ?>
+ <?define exts=_testcapi;_ctypes_test;_testbuffer;_testimportmultiple;_testmultiphase;_testconsole;_testinternalcapi ?>
<Fragment>
<ComponentGroup Id="test_extensions">
<?foreach ext in $(var.exts)?>
diff --git a/Tools/peg_generator/pegen/__main__.py b/Tools/peg_generator/pegen/__main__.py
index 1dcbaad1c3..c0f3b68758 100755
--- a/Tools/peg_generator/pegen/__main__.py
+++ b/Tools/peg_generator/pegen/__main__.py
@@ -14,6 +14,7 @@ import traceback
from typing import Tuple
from pegen.build import Grammar, Parser, Tokenizer, ParserGenerator
+from pegen.validator import validate_grammar
def generate_c_code(
@@ -128,6 +129,8 @@ def main() -> None:
grammar, parser, tokenizer, gen = args.func(args)
t1 = time.time()
+ validate_grammar(grammar)
+
if not args.quiet:
if args.verbose:
print("Raw Grammar:")
diff --git a/Tools/peg_generator/pegen/validator.py b/Tools/peg_generator/pegen/validator.py
new file mode 100644
index 0000000000..0e3dd41cca
--- /dev/null
+++ b/Tools/peg_generator/pegen/validator.py
@@ -0,0 +1,52 @@
+from pegen import grammar
+from pegen.grammar import (
+ Alt,
+ Cut,
+ Gather,
+ GrammarVisitor,
+ Group,
+ Lookahead,
+ NamedItem,
+ NameLeaf,
+ NegativeLookahead,
+ Opt,
+ PositiveLookahead,
+ Repeat0,
+ Repeat1,
+ Rhs,
+ Rule,
+ StringLeaf,
+)
+
+class ValidationError(Exception):
+ pass
+
+class GrammarValidator(GrammarVisitor):
+ def __init__(self, grammar: grammar.Grammar):
+ self.grammar = grammar
+ self.rulename = None
+
+ def validate_rule(self, rulename: str, node: Rule):
+ self.rulename = rulename
+ self.visit(node)
+ self.rulename = None
+
+
+class SubRuleValidator(GrammarValidator):
+ def visit_Rhs(self, node: Rule):
+ for index, alt in enumerate(node.alts):
+ alts_to_consider = node.alts[index+1:]
+ for other_alt in alts_to_consider:
+ self.check_intersection(alt, other_alt)
+
+ def check_intersection(self, first_alt: Alt, second_alt: Alt) -> bool:
+ if str(second_alt).startswith(str(first_alt)):
+ raise ValidationError(
+ f"In {self.rulename} there is an alternative that will "
+ f"never be visited:\n{second_alt}")
+
+def validate_grammar(the_grammar: grammar.Grammar):
+ for validator_cls in GrammarValidator.__subclasses__():
+ validator = validator_cls(the_grammar)
+ for rule_name, rule in the_grammar.rules.items():
+ validator.validate_rule(rule_name, rule)
diff --git a/Tools/pynche/PyncheWidget.py b/Tools/pynche/PyncheWidget.py
index ef12198a21..ea456e577e 100644
--- a/Tools/pynche/PyncheWidget.py
+++ b/Tools/pynche/PyncheWidget.py
@@ -36,15 +36,11 @@ class PyncheWidget:
else:
# Is there already a default root for Tk, say because we're
# running under Guido's IDE? :-) Two conditions say no, either the
- # import fails or _default_root is None.
- tkroot = None
- try:
- from Tkinter import _default_root
- tkroot = self.__tkroot = _default_root
- except ImportError:
- pass
+ # _default_root is None or it is unset.
+ tkroot = getattr(tkinter, '_default_root', None)
if not tkroot:
- tkroot = self.__tkroot = Tk(className='Pynche')
+ tkroot = Tk(className='Pynche')
+ self.__tkroot = tkroot
# but this isn't our top level widget, so make it invisible
tkroot.withdraw()
# create the menubar
diff --git a/Tools/scripts/smelly.py b/Tools/scripts/smelly.py
index 43d091654d..e8a375c808 100755
--- a/Tools/scripts/smelly.py
+++ b/Tools/scripts/smelly.py
@@ -1,17 +1,47 @@
#!/usr/bin/env python
# Script checking that all symbols exported by libpython start with Py or _Py
+import os.path
import subprocess
import sys
import sysconfig
-def get_exported_symbols():
- LIBRARY = sysconfig.get_config_var('LIBRARY')
- if not LIBRARY:
- raise Exception("failed to get LIBRARY")
+ALLOWED_PREFIXES = ('Py', '_Py')
+if sys.platform == 'darwin':
+ ALLOWED_PREFIXES += ('__Py',)
+
+IGNORED_EXTENSION = "_ctypes_test"
+# Ignore constructor and destructor functions
+IGNORED_SYMBOLS = {'_init', '_fini'}
+
+
+def is_local_symbol_type(symtype):
+ # Ignore local symbols.
+
+ # If lowercase, the symbol is usually local; if uppercase, the symbol
+ # is global (external). There are however a few lowercase symbols that
+ # are shown for special global symbols ("u", "v" and "w").
+ if symtype.islower() and symtype not in "uvw":
+ return True
+
+ # Ignore the initialized data section (d and D) and the BSS data
+ # section. For example, ignore "__bss_start (type: B)"
+ # and "_edata (type: D)".
+ if symtype in "bBdD":
+ return True
+
+ return False
- args = ('nm', '-p', LIBRARY)
+
+def get_exported_symbols(library, dynamic=False):
+ print(f"Check that {library} only exports symbols starting with Py or _Py")
+
+ # Only look at dynamic symbols
+ args = ['nm', '--no-sort']
+ if dynamic:
+ args.append('--dynamic')
+ args.append(library)
print("+ %s" % ' '.join(args))
proc = subprocess.run(args, stdout=subprocess.PIPE, universal_newlines=True)
if proc.returncode:
@@ -25,12 +55,9 @@ def get_exported_symbols():
def get_smelly_symbols(stdout):
- symbols = []
- ignored_symtypes = set()
-
- allowed_prefixes = ('Py', '_Py')
- if sys.platform == 'darwin':
- allowed_prefixes += ('__Py',)
+ smelly_symbols = []
+ python_symbols = []
+ local_symbols = []
for line in stdout.splitlines():
# Split line '0000000000001b80 D PyTextIOWrapper_Type'
@@ -42,41 +69,98 @@ def get_smelly_symbols(stdout):
continue
symtype = parts[1].strip()
- # Ignore private symbols.
- #
- # If lowercase, the symbol is usually local; if uppercase, the symbol
- # is global (external). There are however a few lowercase symbols that
- # are shown for special global symbols ("u", "v" and "w").
- if symtype.islower() and symtype not in "uvw":
- ignored_symtypes.add(symtype)
+ symbol = parts[-1]
+ result = '%s (type: %s)' % (symbol, symtype)
+
+ if symbol.startswith(ALLOWED_PREFIXES):
+ python_symbols.append(result)
continue
- symbol = parts[-1]
- if symbol.startswith(allowed_prefixes):
+ if is_local_symbol_type(symtype):
+ local_symbols.append(result)
+ elif symbol in IGNORED_SYMBOLS:
+ local_symbols.append(result)
+ else:
+ smelly_symbols.append(result)
+
+ if local_symbols:
+ print(f"Ignore {len(local_symbols)} local symbols")
+ return smelly_symbols, python_symbols
+
+
+def check_library(library, dynamic=False):
+ nm_output = get_exported_symbols(library, dynamic)
+ smelly_symbols, python_symbols = get_smelly_symbols(nm_output)
+
+ if not smelly_symbols:
+ print(f"OK: no smelly symbol found ({len(python_symbols)} Python symbols)")
+ return 0
+
+ print()
+ smelly_symbols.sort()
+ for symbol in smelly_symbols:
+ print("Smelly symbol: %s" % symbol)
+
+ print()
+ print("ERROR: Found %s smelly symbols!" % len(smelly_symbols))
+ return len(smelly_symbols)
+
+
+def check_extensions():
+ print(__file__)
+ srcdir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
+ filename = os.path.join(srcdir, "pybuilddir.txt")
+ try:
+ with open(filename, encoding="utf-8") as fp:
+ pybuilddir = fp.readline()
+ except FileNotFoundError:
+ print(f"Cannot check extensions because {filename} does not exist")
+ return True
+
+ print(f"Check extension modules from {pybuilddir} directory")
+ builddir = os.path.join(srcdir, pybuilddir)
+ nsymbol = 0
+ for name in os.listdir(builddir):
+ if not name.endswith(".so"):
+ continue
+ if IGNORED_EXTENSION in name:
+ print()
+ print(f"Ignore extension: {name}")
continue
- symbol = '%s (type: %s)' % (symbol, symtype)
- symbols.append(symbol)
- if ignored_symtypes:
- print("Ignored symbol types: %s" % ', '.join(sorted(ignored_symtypes)))
print()
- return symbols
+ filename = os.path.join(builddir, name)
+ nsymbol += check_library(filename, dynamic=True)
+
+ return nsymbol
def main():
- nm_output = get_exported_symbols()
- symbols = get_smelly_symbols(nm_output)
+ # static library
+ LIBRARY = sysconfig.get_config_var('LIBRARY')
+ if not LIBRARY:
+ raise Exception("failed to get LIBRARY variable from sysconfig")
+ nsymbol = check_library(LIBRARY)
+
+ # dynamic library
+ LDLIBRARY = sysconfig.get_config_var('LDLIBRARY')
+ if not LDLIBRARY:
+ raise Exception("failed to get LDLIBRARY variable from sysconfig")
+ if LDLIBRARY != LIBRARY:
+ print()
+ nsymbol += check_library(LDLIBRARY, dynamic=True)
- if not symbols:
- print("OK: no smelly symbol found")
- sys.exit(0)
+ # Check extension modules like _ssl.cpython-310d-x86_64-linux-gnu.so
+ nsymbol += check_extensions()
+
+ if nsymbol:
+ print()
+ print(f"ERROR: Found {nsymbol} smelly symbols in total!")
+ sys.exit(1)
- symbols.sort()
- for symbol in symbols:
- print("Smelly symbol: %s" % symbol)
print()
- print("ERROR: Found %s smelly symbols!" % len(symbols))
- sys.exit(1)
+ print(f"OK: all exported symbols of all libraries "
+ f"are prefixed with {' or '.join(map(repr, ALLOWED_PREFIXES))}")
if __name__ == "__main__":
diff --git a/Tools/scripts/stable_abi.py b/Tools/scripts/stable_abi.py
new file mode 100755
index 0000000000..47547a97bf
--- /dev/null
+++ b/Tools/scripts/stable_abi.py
@@ -0,0 +1,258 @@
+#!/usr/bin/env python
+
+import argparse
+import glob
+import re
+import pathlib
+import subprocess
+import sys
+import sysconfig
+
+EXCLUDED_HEADERS = {
+ "bytes_methods.h",
+ "cellobject.h",
+ "classobject.h",
+ "code.h",
+ "compile.h",
+ "datetime.h",
+ "dtoa.h",
+ "frameobject.h",
+ "funcobject.h",
+ "genobject.h",
+ "longintrepr.h",
+ "parsetok.h",
+ "pyarena.h",
+ "pyatomic.h",
+ "pyctype.h",
+ "pydebug.h",
+ "pytime.h",
+ "symtable.h",
+ "token.h",
+ "ucnhash.h",
+}
+
+MACOS = (sys.platform == "darwin")
+
+def get_exported_symbols(library, dynamic=False):
+ # Only look at dynamic symbols
+ args = ["nm", "--no-sort"]
+ if dynamic:
+ args.append("--dynamic")
+ args.append(library)
+ proc = subprocess.run(args, stdout=subprocess.PIPE, universal_newlines=True)
+ if proc.returncode:
+ sys.stdout.write(proc.stdout)
+ sys.exit(proc.returncode)
+
+ stdout = proc.stdout.rstrip()
+ if not stdout:
+ raise Exception("command output is empty")
+
+ for line in stdout.splitlines():
+ # Split line '0000000000001b80 D PyTextIOWrapper_Type'
+ if not line:
+ continue
+
+ parts = line.split(maxsplit=2)
+ if len(parts) < 3:
+ continue
+
+ symbol = parts[-1]
+ if MACOS and symbol.startswith("_"):
+ yield symbol[1:]
+ else:
+ yield symbol
+
+
+def check_library(stable_abi_file, library, abi_funcs, dynamic=False):
+ available_symbols = set(get_exported_symbols(library, dynamic))
+ missing_symbols = abi_funcs - available_symbols
+ if missing_symbols:
+ raise Exception(
+ f"""\
+Some symbols from the limited API are missing: {', '.join(missing_symbols)}
+
+This error means that there are some missing symbols among the ones exported
+in the Python library ("libpythonx.x.a" or "libpythonx.x.so"). This normally
+means that some symbol, function implementation or a prototype, belonging to
+a symbol in the limited API has been deleted or is missing.
+
+Check if this was a mistake and if not, update the file containing the limited
+API symbols. This file is located at:
+
+{stable_abi_file}
+
+You can read more about the limited API and its contracts at:
+
+https://docs.python.org/3/c-api/stable.html
+
+And in PEP 384:
+
+https://www.python.org/dev/peps/pep-0384/
+"""
+ )
+
+
+def generate_limited_api_symbols(args):
+ if hasattr(sys, "gettotalrefcount"):
+ print(
+ "Stable ABI symbols cannot be generated from a debug build", file=sys.stderr
+ )
+ sys.exit(1)
+ library = sysconfig.get_config_var("LIBRARY")
+ ldlibrary = sysconfig.get_config_var("LDLIBRARY")
+ if ldlibrary != library:
+ raise Exception("Limited ABI symbols can only be generated from a static build")
+ available_symbols = {
+ symbol for symbol in get_exported_symbols(library) if symbol.startswith("Py")
+ }
+
+ headers = [
+ file
+ for file in pathlib.Path("Include").glob("*.h")
+ if file.name not in EXCLUDED_HEADERS
+ ]
+ stable_data, stable_exported_data, stable_functions = get_limited_api_definitions(
+ headers
+ )
+ macros = get_limited_api_macros(headers)
+
+ stable_symbols = {
+ symbol
+ for symbol in (stable_functions | stable_exported_data | stable_data | macros)
+ if symbol.startswith("Py") and symbol in available_symbols
+ }
+ with open(args.output_file, "w") as output_file:
+ output_file.write(f"# File generated by 'make regen-limited-abi'\n")
+ output_file.write(
+ f"# This is NOT an authoritative list of stable ABI symbols\n"
+ )
+ for symbol in sorted(stable_symbols):
+ output_file.write(f"{symbol}\n")
+
+
+def get_limited_api_macros(headers):
+ """Run the preprocesor over all the header files in "Include" setting
+ "-DPy_LIMITED_API" to the correct value for the running version of the interpreter
+ and extracting all macro definitions (via adding -dM to the compiler arguments).
+ """
+
+ preprocesor_output_with_macros = subprocess.check_output(
+ sysconfig.get_config_var("CC").split()
+ + [
+ # Prevent the expansion of the exported macros so we can capture them later
+ "-DSIZEOF_WCHAR_T=4", # The actual value is not important
+ f"-DPy_LIMITED_API={sys.version_info.major << 24 | sys.version_info.minor << 16}",
+ "-I.",
+ "-I./Include",
+ "-dM",
+ "-E",
+ ]
+ + [str(file) for file in headers],
+ text=True,
+ stderr=subprocess.DEVNULL,
+ )
+
+ return {
+ target
+ for _, target in re.findall(
+ r"#define (\w+)\s*(?:\(.*?\))?\s+(\w+)", preprocesor_output_with_macros
+ )
+ }
+
+
+def get_limited_api_definitions(headers):
+ """Run the preprocesor over all the header files in "Include" setting
+ "-DPy_LIMITED_API" to the correct value for the running version of the interpreter.
+
+ The limited API symbols will be extracted from the output of this command as it includes
+ the prototypes and definitions of all the exported symbols that are in the limited api.
+
+ This function does *NOT* extract the macros defined on the limited API
+ """
+ preprocesor_output = subprocess.check_output(
+ sysconfig.get_config_var("CC").split()
+ + [
+ # Prevent the expansion of the exported macros so we can capture them later
+ "-DPyAPI_FUNC=__PyAPI_FUNC",
+ "-DPyAPI_DATA=__PyAPI_DATA",
+ "-DEXPORT_DATA=__EXPORT_DATA",
+ "-D_Py_NO_RETURN=",
+ "-DSIZEOF_WCHAR_T=4", # The actual value is not important
+ f"-DPy_LIMITED_API={sys.version_info.major << 24 | sys.version_info.minor << 16}",
+ "-I.",
+ "-I./Include",
+ "-E",
+ ]
+ + [str(file) for file in headers],
+ text=True,
+ stderr=subprocess.DEVNULL,
+ )
+ stable_functions = set(
+ re.findall(r"__PyAPI_FUNC\(.*?\)\s*(.*?)\s*\(", preprocesor_output)
+ )
+ stable_exported_data = set(
+ re.findall(r"__EXPORT_DATA\((.*?)\)", preprocesor_output)
+ )
+ stable_data = set(
+ re.findall(r"__PyAPI_DATA\(.*?\)\s*\(?(.*?)\)?\s*;", preprocesor_output)
+ )
+ return stable_data, stable_exported_data, stable_functions
+
+
+def check_symbols(parser_args):
+ with open(parser_args.stable_abi_file, "r") as filename:
+ abi_funcs = {
+ symbol
+ for symbol in filename.read().splitlines()
+ if symbol and not symbol.startswith("#")
+ }
+
+ try:
+ # static library
+ LIBRARY = sysconfig.get_config_var("LIBRARY")
+ if not LIBRARY:
+ raise Exception("failed to get LIBRARY variable from sysconfig")
+ check_library(parser_args.stable_abi_file, LIBRARY, abi_funcs)
+
+ # dynamic library
+ LDLIBRARY = sysconfig.get_config_var("LDLIBRARY")
+ if not LDLIBRARY:
+ raise Exception("failed to get LDLIBRARY variable from sysconfig")
+ if LDLIBRARY != LIBRARY:
+ check_library(
+ parser_args.stable_abi_file, LDLIBRARY, abi_funcs, dynamic=True
+ )
+ except Exception as e:
+ print(e, file=sys.stderr)
+ sys.exit(1)
+
+
+def main():
+ parser = argparse.ArgumentParser(description="Process some integers.")
+ subparsers = parser.add_subparsers()
+ check_parser = subparsers.add_parser(
+ "check", help="Check the exported symbols against a given ABI file"
+ )
+ check_parser.add_argument(
+ "stable_abi_file", type=str, help="File with the stable abi functions"
+ )
+ check_parser.set_defaults(func=check_symbols)
+ generate_parser = subparsers.add_parser(
+ "generate",
+ help="Generate symbols from the header files and the exported symbols",
+ )
+ generate_parser.add_argument(
+ "output_file", type=str, help="File to dump the symbols to"
+ )
+ generate_parser.set_defaults(func=generate_limited_api_symbols)
+ args = parser.parse_args()
+ if "func" not in args:
+ parser.error("Either 'check' or 'generate' must be used")
+ sys.exit(1)
+
+ args.func(args)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/aclocal.m4 b/aclocal.m4
index 99913e7f3b..c003f3c705 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -67,7 +67,7 @@ AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
-# serial 11 (pkg-config-0.29.1)
+# serial 12 (pkg-config-0.29.2)
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
@@ -109,7 +109,7 @@ dnl
dnl See the "Since" comment for each macro you use to see what version
dnl of the macros you require.
m4_defun([PKG_PREREQ],
-[m4_define([PKG_MACROS_VERSION], [0.29.1])
+[m4_define([PKG_MACROS_VERSION], [0.29.2])
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
])dnl PKG_PREREQ
@@ -210,7 +210,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
-AC_MSG_CHECKING([for $1])
+AC_MSG_CHECKING([for $2])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
@@ -220,11 +220,11 @@ and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
- AC_MSG_RESULT([no])
+ AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
- else
+ else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
@@ -241,7 +241,7 @@ installed software in a non-standard prefix.
_PKG_TEXT])[]dnl
])
elif test $pkg_failed = untried; then
- AC_MSG_RESULT([no])
+ AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
@@ -342,73 +342,5 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])dnl PKG_CHECK_VAR
-dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
-dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
-dnl [DESCRIPTION], [DEFAULT])
-dnl ------------------------------------------
-dnl
-dnl Prepare a "--with-" configure option using the lowercase
-dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
-dnl PKG_CHECK_MODULES in a single macro.
-AC_DEFUN([PKG_WITH_MODULES],
-[
-m4_pushdef([with_arg], m4_tolower([$1]))
-
-m4_pushdef([description],
- [m4_default([$5], [build with ]with_arg[ support])])
-
-m4_pushdef([def_arg], [m4_default([$6], [auto])])
-m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
-m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
-
-m4_case(def_arg,
- [yes],[m4_pushdef([with_without], [--without-]with_arg)],
- [m4_pushdef([with_without],[--with-]with_arg)])
-
-AC_ARG_WITH(with_arg,
- AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
- [AS_TR_SH([with_]with_arg)=def_arg])
-
-AS_CASE([$AS_TR_SH([with_]with_arg)],
- [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
- [auto],[PKG_CHECK_MODULES([$1],[$2],
- [m4_n([def_action_if_found]) $3],
- [m4_n([def_action_if_not_found]) $4])])
-
-m4_popdef([with_arg])
-m4_popdef([description])
-m4_popdef([def_arg])
-
-])dnl PKG_WITH_MODULES
-
-dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
-dnl [DESCRIPTION], [DEFAULT])
-dnl -----------------------------------------------
-dnl
-dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
-dnl check._[VARIABLE-PREFIX] is exported as make variable.
-AC_DEFUN([PKG_HAVE_WITH_MODULES],
-[
-PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
-
-AM_CONDITIONAL([HAVE_][$1],
- [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
-])dnl PKG_HAVE_WITH_MODULES
-
-dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
-dnl [DESCRIPTION], [DEFAULT])
-dnl ------------------------------------------------------
-dnl
-dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
-dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
-dnl and preprocessor variable.
-AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
-[
-PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
-
-AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
- [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
-])dnl PKG_HAVE_DEFINE_WITH_MODULES
-
m4_include([m4/ax_c_float_words_bigendian.m4])
m4_include([m4/ax_check_openssl.m4])
diff --git a/configure b/configure
index bc87485bf5..530c04a0ed 100755
--- a/configure
+++ b/configure
@@ -1511,8 +1511,8 @@ Optional Packages:
specify the kind of universal binary that should be
created. this option is only valid when
--enable-universalsdk is set; options are:
- ("32-bit", "64-bit", "3-way", "intel", "intel-32",
- "intel-64", or "all") see Mac/README.rst
+ ("universal2", "32-bit", "64-bit", "3-way", "intel",
+ "intel-32", "intel-64", or "all") see Mac/README.rst
--with-framework-name=FRAMEWORK
specify the name for the python framework on macOS
only valid when --enable-framework is set. see
@@ -3430,16 +3430,6 @@ $as_echo "#define _BSD_SOURCE 1" >>confdefs.h
define_xopen_source=no;;
Darwin/[12][0-9].*)
define_xopen_source=no;;
- # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
- # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
- # or has another value. By not (re)defining it, the defaults come in place.
- AIX/4)
- define_xopen_source=no;;
- AIX/5)
- if test `uname -r` -eq 1; then
- define_xopen_source=no
- fi
- ;;
# On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
# defining NI_NUMERICHOST.
QNX/6.3.2)
@@ -5828,10 +5818,7 @@ $as_echo_n "checking EXPORTSYMS... " >&6; }
case $ac_sys_system in
AIX*)
EXPORTSYMS="Modules/python.exp"
- if test $ac_sys_release -ge 5 -o \
- $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
- EXPORTSFROM=. # the main executable
- fi
+ EXPORTSFROM=. # the main executable
;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $EXPORTSYMS" >&5
@@ -5950,7 +5937,7 @@ $as_echo "#define Py_ENABLE_SHARED 1" >>confdefs.h
PY3LIBRARY=libpython3.so
fi
;;
- Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
+ Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*|VxWorks*)
LDLIBRARY='libpython$(LDVERSION).so'
BLDLIBRARY='-L. -lpython$(LDVERSION)'
RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
@@ -7002,7 +6989,7 @@ fi
-# The -arch flags for universal builds on OSX
+# The -arch flags for universal builds on macOS
UNIVERSAL_ARCH_FLAGS=
@@ -7529,6 +7516,11 @@ $as_echo "$CC" >&6; }
LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
;;
+ universal2)
+ UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64"
+ LIPO_32BIT_FLAGS=""
+ ARCH_RUN_32BIT="true"
+ ;;
intel)
UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
LIPO_32BIT_FLAGS="-extract i386"
@@ -7550,7 +7542,7 @@ $as_echo "$CC" >&6; }
ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
;;
*)
- as_fn_error $? "proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way" "$LINENO" 5
+ as_fn_error $? "proper usage is --with-universal-arch=universal2|32-bit|64-bit|all|intel|3-way" "$LINENO" 5
;;
esac
@@ -7619,6 +7611,31 @@ $as_echo_n "checking which MACOSX_DEPLOYMENT_TARGET to use... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MACOSX_DEPLOYMENT_TARGET" >&5
$as_echo "$MACOSX_DEPLOYMENT_TARGET" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if specified universal architectures work" >&5
+$as_echo_n "checking if specified universal architectures work... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdio.h>
+int
+main ()
+{
+printf("%d", 42);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ as_fn_error $? "check config.log and use the '--with-universal-archs' option" "$LINENO" 5
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
# end of Darwin* tests
;;
esac
@@ -8027,7 +8044,8 @@ sys/stat.h sys/syscall.h sys/sys_domain.h sys/termio.h sys/time.h \
sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \
libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \
-sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h sys/mman.h
+sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h \
+sys/mman.h sys/eventfd.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -9382,7 +9400,7 @@ fi
MACOSX_DEFAULT_ARCH="ppc"
;;
*)
- as_fn_error $? "Unexpected output of 'arch' on OSX" "$LINENO" 5
+ as_fn_error $? "Unexpected output of 'arch' on macOS" "$LINENO" 5
;;
esac
else
@@ -9392,9 +9410,12 @@ fi
;;
ppc)
MACOSX_DEFAULT_ARCH="ppc64"
+ ;;
+ arm64)
+ MACOSX_DEFAULT_ARCH="arm64"
;;
*)
- as_fn_error $? "Unexpected output of 'arch' on OSX" "$LINENO" 5
+ as_fn_error $? "Unexpected output of 'arch' on macOS" "$LINENO" 5
;;
esac
@@ -9700,7 +9721,7 @@ then
# when running test_compile.py.
LINKFORSHARED='-Wl,-E -N 2048K';;
VxWorks*)
- LINKFORSHARED='--export-dynamic';;
+ LINKFORSHARED='-Wl,-export-dynamic';;
esac
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LINKFORSHARED" >&5
@@ -11087,10 +11108,10 @@ else
main() {
pthread_attr_t attr;
pthread_t id;
- if (pthread_attr_init(&attr)) exit(-1);
- if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
- if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
- exit(0);
+ if (pthread_attr_init(&attr)) return (-1);
+ if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) return (-1);
+ if (pthread_create(&id, &attr, foo, NULL)) return (-1);
+ return (0);
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
@@ -11648,7 +11669,7 @@ fi
DLINCLDIR=.
# the dlopen() function means we might want to use dynload_shlib.o. some
-# platforms, such as AIX, have dlopen(), but don't want to use it.
+# platforms have dlopen(), but don't want to use it.
for ac_func in dlopen
do :
ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
@@ -11730,7 +11751,7 @@ for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \
sched_rr_get_interval \
sigaction sigaltstack sigfillset siginterrupt sigpending sigrelse \
- sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy strsignal symlinkat sync \
+ sigtimedwait sigwait sigwaitinfo snprintf splice strftime strlcpy strsignal symlinkat sync \
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
truncate uname unlinkat utimensat utimes vfork waitid waitpid wait3 wait4 \
wcscoll wcsftime wcsxfrm wmemcmp writev _getpty rtpSpawn
@@ -12031,6 +12052,31 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _dyld_shared_cache_contains_path" >&5
+$as_echo_n "checking for _dyld_shared_cache_contains_path... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <mach-o/dyld.h>
+int
+main ()
+{
+void *x=_dyld_shared_cache_contains_path
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH 1" >>confdefs.h
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for memfd_create" >&5
$as_echo_n "checking for memfd_create... " >&6; }
@@ -12065,6 +12111,36 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for eventfd" >&5
+$as_echo_n "checking for eventfd... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#ifdef HAVE_SYS_EVENTFD_H
+#include <sys/eventfd.h>
+#endif
+
+int
+main ()
+{
+int x = eventfd(0, EFD_CLOEXEC)
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define HAVE_EVENTFD 1" >>confdefs.h
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
# On some systems (eg. FreeBSD 5), we would find a definition of the
# functions ctermid_r, setgroups in the library, but no prototype
# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
@@ -15054,7 +15130,7 @@ else
int main()
{
/* Success: exit code 0 */
- exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
+ return ((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
}
_ACEOF
@@ -15354,12 +15430,7 @@ _ACEOF
fi
-case $ac_sys_system in
- Linux*|GNU*|Darwin|VxWorks)
- EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};;
- *)
- EXT_SUFFIX=${SHLIB_SUFFIX};;
-esac
+EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking LDVERSION" >&5
$as_echo_n "checking LDVERSION... " >&6; }
@@ -15435,7 +15506,7 @@ else
int main()
{
- exit(((-1)>>3 == -1) ? 0 : 1);
+ return (((-1)>>3 == -1) ? 0 : 1);
}
_ACEOF
@@ -15905,6 +15976,7 @@ else
/* end confdefs.h. */
#include <poll.h>
+#include <unistd.h>
int main()
{
@@ -17024,16 +17096,17 @@ $as_echo "#define HAVE_STD_ATOMIC 1" >>confdefs.h
fi
-# Check for GCC >= 4.7 __atomic builtins
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC >= 4.7 __atomic builtins" >&5
-$as_echo_n "checking for GCC >= 4.7 __atomic builtins... " >&6; }
+# Check for GCC >= 4.7 and clang __atomic builtin functions
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for builtin __atomic_load_n and __atomic_store_n functions" >&5
+$as_echo_n "checking for builtin __atomic_load_n and __atomic_store_n functions... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
- volatile int val = 1;
+ int val;
int main() {
- __atomic_load_n(&val, __ATOMIC_SEQ_CST);
+ __atomic_store_n(&val, 1, __ATOMIC_SEQ_CST);
+ (void)__atomic_load_n(&val, __ATOMIC_SEQ_CST);
return 0;
}
diff --git a/configure.ac b/configure.ac
index 49ed09a3a0..39eadfedfb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -218,7 +218,7 @@ AC_ARG_WITH(universal-archs,
AS_HELP_STRING([--with-universal-archs=ARCH],
[specify the kind of universal binary that should be created. this option is
only valid when --enable-universalsdk is set; options are:
- ("32-bit", "64-bit", "3-way", "intel", "intel-32", "intel-64", or "all")
+ ("universal2", "32-bit", "64-bit", "3-way", "intel", "intel-32", "intel-64", or "all")
see Mac/README.rst]),
[
UNIVERSAL_ARCHS="$withval"
@@ -512,16 +512,6 @@ case $ac_sys_system/$ac_sys_release in
define_xopen_source=no;;
Darwin/@<:@[12]@:>@@<:@0-9@:>@.*)
define_xopen_source=no;;
- # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
- # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
- # or has another value. By not (re)defining it, the defaults come in place.
- AIX/4)
- define_xopen_source=no;;
- AIX/5)
- if test `uname -r` -eq 1; then
- define_xopen_source=no
- fi
- ;;
# On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
# defining NI_NUMERICHOST.
QNX/6.3.2)
@@ -1048,10 +1038,7 @@ AC_MSG_CHECKING(EXPORTSYMS)
case $ac_sys_system in
AIX*)
EXPORTSYMS="Modules/python.exp"
- if test $ac_sys_release -ge 5 -o \
- $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
- EXPORTSFROM=. # the main executable
- fi
+ EXPORTSFROM=. # the main executable
;;
esac
AC_MSG_RESULT($EXPORTSYMS)
@@ -1146,7 +1133,7 @@ if test $enable_shared = "yes"; then
PY3LIBRARY=libpython3.so
fi
;;
- Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
+ Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*|VxWorks*)
LDLIBRARY='libpython$(LDVERSION).so'
BLDLIBRARY='-L. -lpython$(LDVERSION)'
RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
@@ -1597,7 +1584,7 @@ AC_SUBST(BASECFLAGS)
AC_SUBST(CFLAGS_NODIST)
AC_SUBST(LDFLAGS_NODIST)
-# The -arch flags for universal builds on OSX
+# The -arch flags for universal builds on macOS
UNIVERSAL_ARCH_FLAGS=
AC_SUBST(UNIVERSAL_ARCH_FLAGS)
@@ -1898,6 +1885,11 @@ yes)
LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
;;
+ universal2)
+ UNIVERSAL_ARCH_FLAGS="-arch arm64 -arch x86_64"
+ LIPO_32BIT_FLAGS=""
+ ARCH_RUN_32BIT="true"
+ ;;
intel)
UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
LIPO_32BIT_FLAGS="-extract i386"
@@ -1919,7 +1911,7 @@ yes)
ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
;;
*)
- AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
+ AC_MSG_ERROR([proper usage is --with-universal-arch=universal2|32-bit|64-bit|all|intel|3-way])
;;
esac
@@ -1986,6 +1978,13 @@ yes)
EXPORT_MACOSX_DEPLOYMENT_TARGET=''
AC_MSG_RESULT($MACOSX_DEPLOYMENT_TARGET)
+ AC_MSG_CHECKING(if specified universal architectures work)
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[printf("%d", 42);]])],
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)
+ AC_MSG_ERROR(check config.log and use the '--with-universal-archs' option)
+ ])
+
# end of Darwin* tests
;;
esac
@@ -2205,7 +2204,8 @@ sys/stat.h sys/syscall.h sys/sys_domain.h sys/termio.h sys/time.h \
sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \
libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \
-sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h sys/mman.h)
+sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h \
+sys/mman.h sys/eventfd.h)
AC_HEADER_DIRENT
AC_HEADER_MAJOR
@@ -2489,7 +2489,7 @@ case $ac_sys_system/$ac_sys_release in
MACOSX_DEFAULT_ARCH="ppc"
;;
*)
- AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
+ AC_MSG_ERROR([Unexpected output of 'arch' on macOS])
;;
esac
else
@@ -2499,9 +2499,12 @@ case $ac_sys_system/$ac_sys_release in
;;
ppc)
MACOSX_DEFAULT_ARCH="ppc64"
+ ;;
+ arm64)
+ MACOSX_DEFAULT_ARCH="arm64"
;;
*)
- AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
+ AC_MSG_ERROR([Unexpected output of 'arch' on macOS])
;;
esac
@@ -2795,7 +2798,7 @@ then
# when running test_compile.py.
LINKFORSHARED='-Wl,-E -N 2048K';;
VxWorks*)
- LINKFORSHARED='--export-dynamic';;
+ LINKFORSHARED='-Wl,-export-dynamic';;
esac
fi
AC_MSG_RESULT($LINKFORSHARED)
@@ -3308,10 +3311,10 @@ if test "$posix_threads" = "yes"; then
main() {
pthread_attr_t attr;
pthread_t id;
- if (pthread_attr_init(&attr)) exit(-1);
- if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
- if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
- exit(0);
+ if (pthread_attr_init(&attr)) return (-1);
+ if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) return (-1);
+ if (pthread_create(&id, &attr, foo, NULL)) return (-1);
+ return (0);
}]])],
[ac_cv_pthread_system_supported=yes],
[ac_cv_pthread_system_supported=no],
@@ -3622,7 +3625,7 @@ AC_SUBST(DLINCLDIR)
DLINCLDIR=.
# the dlopen() function means we might want to use dynload_shlib.o. some
-# platforms, such as AIX, have dlopen(), but don't want to use it.
+# platforms have dlopen(), but don't want to use it.
AC_CHECK_FUNCS(dlopen)
# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
@@ -3688,7 +3691,7 @@ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \
sched_rr_get_interval \
sigaction sigaltstack sigfillset siginterrupt sigpending sigrelse \
- sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy strsignal symlinkat sync \
+ sigtimedwait sigwait sigwaitinfo snprintf splice strftime strlcpy strsignal symlinkat sync \
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
truncate uname unlinkat utimensat utimes vfork waitid waitpid wait3 wait4 \
wcscoll wcsftime wcsxfrm wmemcmp writev _getpty rtpSpawn)
@@ -3774,6 +3777,12 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
])
+AC_MSG_CHECKING(for _dyld_shared_cache_contains_path)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <mach-o/dyld.h>]], [[void *x=_dyld_shared_cache_contains_path]])],
+ [AC_DEFINE(HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH, 1, Define if you have the '_dyld_shared_cache_contains_path' function.)
+ AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)
+])
AC_MSG_CHECKING(for memfd_create)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@@ -3789,6 +3798,17 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
[AC_MSG_RESULT(no)
])
+AC_MSG_CHECKING(for eventfd)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef HAVE_SYS_EVENTFD_H
+#include <sys/eventfd.h>
+#endif
+]], [[int x = eventfd(0, EFD_CLOEXEC)]])],
+ [AC_DEFINE(HAVE_EVENTFD, 1, Define if you have the 'eventfd' function.)
+ AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)
+])
+
# On some systems (eg. FreeBSD 5), we would find a definition of the
# functions ctermid_r, setgroups in the library, but no prototype
# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
@@ -4708,7 +4728,7 @@ then
int main()
{
/* Success: exit code 0 */
- exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
+ return ((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
}
]])],
[ac_cv_wchar_t_signed=yes],
@@ -4766,12 +4786,7 @@ if test "$Py_DEBUG" = 'true' -a "$with_trace_refs" != "yes"; then
fi
AC_SUBST(EXT_SUFFIX)
-case $ac_sys_system in
- Linux*|GNU*|Darwin|VxWorks)
- EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};;
- *)
- EXT_SUFFIX=${SHLIB_SUFFIX};;
-esac
+EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX}
AC_MSG_CHECKING(LDVERSION)
LDVERSION='$(VERSION)$(ABIFLAGS)'
@@ -4830,7 +4845,7 @@ AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
AC_RUN_IFELSE([AC_LANG_SOURCE([[
int main()
{
- exit(((-1)>>3 == -1) ? 0 : 1);
+ return (((-1)>>3 == -1) ? 0 : 1);
}
]])],
[ac_cv_rshift_extends_sign=yes],
@@ -4977,6 +4992,7 @@ AC_MSG_CHECKING(for broken poll())
AC_CACHE_VAL(ac_cv_broken_poll,
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <poll.h>
+#include <unistd.h>
int main()
{
@@ -5570,14 +5586,15 @@ if test "$have_stdatomic_h" = yes; then
[Has stdatomic.h with atomic_int and atomic_uintptr_t])
fi
-# Check for GCC >= 4.7 __atomic builtins
-AC_MSG_CHECKING(for GCC >= 4.7 __atomic builtins)
+# Check for GCC >= 4.7 and clang __atomic builtin functions
+AC_MSG_CHECKING(for builtin __atomic_load_n and __atomic_store_n functions)
AC_LINK_IFELSE(
[
AC_LANG_SOURCE([[
- volatile int val = 1;
+ int val;
int main() {
- __atomic_load_n(&val, __ATOMIC_SEQ_CST);
+ __atomic_store_n(&val, 1, __ATOMIC_SEQ_CST);
+ (void)__atomic_load_n(&val, __ATOMIC_SEQ_CST);
return 0;
}
]])
@@ -5586,7 +5603,7 @@ AC_LINK_IFELSE(
AC_MSG_RESULT($have_builtin_atomic)
if test "$have_builtin_atomic" = yes; then
- AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Has builtin atomics])
+ AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Has builtin __atomic_load_n() and __atomic_store_n() functions])
fi
# ensurepip option
diff --git a/pyconfig.h.in b/pyconfig.h.in
index af8a3d6d9c..045cbd53ae 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -115,7 +115,7 @@
/* Define if `unsetenv` does not return an int. */
#undef HAVE_BROKEN_UNSETENV
-/* Has builtin atomics */
+/* Has builtin __atomic_load_n() and __atomic_store_n() functions */
#undef HAVE_BUILTIN_ATOMIC
/* Define to 1 if you have the 'chflags' function. */
@@ -287,6 +287,9 @@
/* Define to 1 if you have the `dup3' function. */
#undef HAVE_DUP3
+/* Define if you have the '_dyld_shared_cache_contains_path' function. */
+#undef HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH
+
/* Defined when any dynamic module loading is enabled. */
#undef HAVE_DYNAMIC_LOADING
@@ -308,6 +311,9 @@
/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
+/* Define if you have the 'eventfd' function. */
+#undef HAVE_EVENTFD
+
/* Define to 1 if you have the `execv' function. */
#undef HAVE_EXECV
@@ -1012,6 +1018,9 @@
/* Define to 1 if you have the <spawn.h> header file. */
#undef HAVE_SPAWN_H
+/* Define to 1 if you have the `splice' function. */
+#undef HAVE_SPLICE
+
/* Define if your compiler provides ssize_t */
#undef HAVE_SSIZE_T
@@ -1116,6 +1125,9 @@
/* Define to 1 if you have the <sys/epoll.h> header file. */
#undef HAVE_SYS_EPOLL_H
+/* Define to 1 if you have the <sys/eventfd.h> header file. */
+#undef HAVE_SYS_EVENTFD_H
+
/* Define to 1 if you have the <sys/event.h> header file. */
#undef HAVE_SYS_EVENT_H
diff --git a/setup.py b/setup.py
index b3f47603f7..e055e44b0f 100644
--- a/setup.py
+++ b/setup.py
@@ -9,6 +9,7 @@ import re
import sys
import sysconfig
from glob import glob, escape
+import _osx_support
try:
@@ -178,32 +179,9 @@ def macosx_sdk_root():
MACOS_SDK_ROOT = m.group(1)
MACOS_SDK_SPECIFIED = MACOS_SDK_ROOT != '/'
else:
- MACOS_SDK_ROOT = '/'
+ MACOS_SDK_ROOT = _osx_support._default_sysroot(
+ sysconfig.get_config_var('CC'))
MACOS_SDK_SPECIFIED = False
- cc = sysconfig.get_config_var('CC')
- tmpfile = '/tmp/setup_sdk_root.%d' % os.getpid()
- try:
- os.unlink(tmpfile)
- except:
- pass
- ret = run_command('%s -E -v - </dev/null 2>%s 1>/dev/null' % (cc, tmpfile))
- in_incdirs = False
- try:
- if ret == 0:
- with open(tmpfile) as fp:
- for line in fp.readlines():
- if line.startswith("#include <...>"):
- in_incdirs = True
- elif line.startswith("End of search list"):
- in_incdirs = False
- elif in_incdirs:
- line = line.strip()
- if line == '/usr/include':
- MACOS_SDK_ROOT = '/'
- elif line.endswith(".sdk/usr/include"):
- MACOS_SDK_ROOT = line[:-12]
- finally:
- os.unlink(tmpfile)
return MACOS_SDK_ROOT
@@ -239,6 +217,13 @@ def is_macosx_sdk_path(path):
or path.startswith('/Library/') )
+def grep_headers_for(function, headers):
+ for header in headers:
+ with open(header, 'r', errors='surrogateescape') as f:
+ if function in f.read():
+ return True
+ return False
+
def find_file(filename, std_dirs, paths):
"""Searches for the directory where a given file is located,
and returns a possibly-empty list of additional directories, or None
@@ -869,8 +854,6 @@ class PyBuildExt(build_ext):
# C-optimized pickle replacement
self.add(Extension("_pickle", ["_pickle.c"],
extra_compile_args=['-DPy_BUILD_CORE_MODULE']))
- # atexit
- self.add(Extension("atexit", ["atexitmodule.c"]))
# _json speedups
self.add(Extension("_json", ["_json.c"],
extra_compile_args=['-DPy_BUILD_CORE_MODULE']))
@@ -1030,7 +1013,7 @@ class PyBuildExt(build_ext):
os_release = int(os.uname()[2].split('.')[0])
dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
if (dep_target and
- (tuple(int(n) for n in dep_target.split('.')[0:2])
+ (tuple(int(n) for n in str(dep_target).split('.')[0:2])
< (10, 5) ) ):
os_release = 8
if os_release < 9:
@@ -1147,18 +1130,12 @@ class PyBuildExt(build_ext):
def detect_socket(self):
# socket(2)
- if not VXWORKS:
- kwargs = {'depends': ['socketmodule.h']}
- if MACOS:
- # Issue #35569: Expose RFC 3542 socket options.
- kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542']
-
- self.add(Extension('_socket', ['socketmodule.c'], **kwargs))
- elif self.compiler.find_library_file(self.lib_dirs, 'net'):
- libs = ['net']
- self.add(Extension('_socket', ['socketmodule.c'],
- depends=['socketmodule.h'],
- libraries=libs))
+ kwargs = {'depends': ['socketmodule.h']}
+ if MACOS:
+ # Issue #35569: Expose RFC 3542 socket options.
+ kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542']
+
+ self.add(Extension('_socket', ['socketmodule.c'], **kwargs))
def detect_dbm_gdbm(self):
# Modules that provide persistent dictionary-like semantics. You will
@@ -1824,8 +1801,16 @@ class PyBuildExt(build_ext):
## self.add(Extension('xx', ['xxmodule.c']))
if 'd' not in sysconfig.get_config_var('ABIFLAGS'):
+ # Non-debug mode: Build xxlimited with limited API
self.add(Extension('xxlimited', ['xxlimited.c'],
+ define_macros=[('Py_LIMITED_API', '0x03100000')]))
+ self.add(Extension('xxlimited_35', ['xxlimited_35.c'],
define_macros=[('Py_LIMITED_API', '0x03050000')]))
+ else:
+ # Debug mode: Build xxlimited with the full API
+ # (which is compatible with the limited one)
+ self.add(Extension('xxlimited', ['xxlimited.c']))
+ self.add(Extension('xxlimited_35', ['xxlimited_35.c']))
def detect_tkinter_explicitly(self):
# Build _tkinter using explicit locations for Tcl/Tk.
@@ -2105,43 +2090,17 @@ class PyBuildExt(build_ext):
library_dirs=added_lib_dirs))
return True
- def configure_ctypes_darwin(self, ext):
- # Darwin (OS X) uses preconfigured files, in
- # the Modules/_ctypes/libffi_osx directory.
- ffi_srcdir = os.path.abspath(os.path.join(self.srcdir, 'Modules',
- '_ctypes', 'libffi_osx'))
- sources = [os.path.join(ffi_srcdir, p)
- for p in ['ffi.c',
- 'x86/darwin64.S',
- 'x86/x86-darwin.S',
- 'x86/x86-ffi_darwin.c',
- 'x86/x86-ffi64.c',
- 'powerpc/ppc-darwin.S',
- 'powerpc/ppc-darwin_closure.S',
- 'powerpc/ppc-ffi_darwin.c',
- 'powerpc/ppc64-darwin_closure.S',
- ]]
-
- # Add .S (preprocessed assembly) to C compiler source extensions.
- self.compiler.src_extensions.append('.S')
-
- include_dirs = [os.path.join(ffi_srcdir, 'include'),
- os.path.join(ffi_srcdir, 'powerpc')]
- ext.include_dirs.extend(include_dirs)
- ext.sources.extend(sources)
- return True
-
def configure_ctypes(self, ext):
- if not self.use_system_libffi:
- if MACOS:
- return self.configure_ctypes_darwin(ext)
- print('INFO: Could not locate ffi libs and/or headers')
- return False
return True
def detect_ctypes(self):
# Thomas Heller's _ctypes module
- self.use_system_libffi = False
+
+ if (not sysconfig.get_config_var("LIBFFI_INCLUDEDIR") and MACOS):
+ self.use_system_libffi = True
+ else:
+ self.use_system_libffi = '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS")
+
include_dirs = []
extra_compile_args = ['-DPy_BUILD_CORE_MODULE']
extra_link_args = []
@@ -2154,11 +2113,9 @@ class PyBuildExt(build_ext):
if MACOS:
sources.append('_ctypes/malloc_closure.c')
- sources.append('_ctypes/darwin/dlfcn_simple.c')
+ extra_compile_args.append('-DUSING_MALLOC_CLOSURE_DOT_C=1')
extra_compile_args.append('-DMACOSX')
include_dirs.append('_ctypes/darwin')
- # XXX Is this still needed?
- # extra_link_args.extend(['-read_only_relocs', 'warning'])
elif HOST_PLATFORM == 'sunos5':
# XXX This shouldn't be necessary; it appears that some
@@ -2188,31 +2145,48 @@ class PyBuildExt(build_ext):
sources=['_ctypes/_ctypes_test.c'],
libraries=['m']))
+ ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR")
+ ffi_lib = None
+
ffi_inc_dirs = self.inc_dirs.copy()
if MACOS:
- if '--with-system-ffi' not in sysconfig.get_config_var("CONFIG_ARGS"):
- return
- # OS X 10.5 comes with libffi.dylib; the include files are
- # in /usr/include/ffi
- ffi_inc_dirs.append('/usr/include/ffi')
-
- ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")]
- if not ffi_inc or ffi_inc[0] == '':
- ffi_inc = find_file('ffi.h', [], ffi_inc_dirs)
- if ffi_inc is not None:
- ffi_h = ffi_inc[0] + '/ffi.h'
+ ffi_in_sdk = os.path.join(macosx_sdk_root(), "usr/include/ffi")
+
+ if not ffi_inc:
+ if os.path.exists(ffi_in_sdk):
+ ext.extra_compile_args.append("-DUSING_APPLE_OS_LIBFFI=1")
+ ffi_inc = ffi_in_sdk
+ ffi_lib = 'ffi'
+ else:
+ # OS X 10.5 comes with libffi.dylib; the include files are
+ # in /usr/include/ffi
+ ffi_inc_dirs.append('/usr/include/ffi')
+
+ if not ffi_inc:
+ found = find_file('ffi.h', [], ffi_inc_dirs)
+ if found:
+ ffi_inc = found[0]
+ if ffi_inc:
+ ffi_h = ffi_inc + '/ffi.h'
if not os.path.exists(ffi_h):
ffi_inc = None
print('Header file {} does not exist'.format(ffi_h))
- ffi_lib = None
- if ffi_inc is not None:
+ if ffi_lib is None and ffi_inc:
for lib_name in ('ffi', 'ffi_pic'):
if (self.compiler.find_library_file(self.lib_dirs, lib_name)):
ffi_lib = lib_name
break
if ffi_inc and ffi_lib:
- ext.include_dirs.extend(ffi_inc)
+ ffi_headers = glob(os.path.join(ffi_inc, '*.h'))
+ if grep_headers_for('ffi_prep_cif_var', ffi_headers):
+ ext.extra_compile_args.append("-DHAVE_FFI_PREP_CIF_VAR=1")
+ if grep_headers_for('ffi_prep_closure_loc', ffi_headers):
+ ext.extra_compile_args.append("-DHAVE_FFI_PREP_CLOSURE_LOC=1")
+ if grep_headers_for('ffi_closure_alloc', ffi_headers):
+ ext.extra_compile_args.append("-DHAVE_FFI_CLOSURE_ALLOC=1")
+
+ ext.include_dirs.append(ffi_inc)
ext.libraries.append(ffi_lib)
self.use_system_libffi = True