summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* Record cache hits for BINARY_SUBSCR specializations (GH-29060)Ken Jin2021-10-191-0/+3
|
* bpo-35134: Add Include/cpython/longobject.h (GH-29044)Victor Stinner2021-10-192-2/+3
| | | | | | | | | | Move Include/longobject.h non-limited API to a new Include/cpython/longobject.h header file. Move the following definitions to the internal C API: * _PyLong_DigitValue * _PyLong_FormatAdvancedWriter() * _PyLong_FormatWriter()
* bpo-43760: Rename _PyThreadState_DisableTracing() (GH-29032)Victor Stinner2021-10-182-9/+9
| | | | | | * Rename _PyThreadState_DisableTracing() to _PyThreadState_PauseTracing() * Rename _PyThreadState_ResetTracing() to _PyThreadState_ResumeTracing()
* bpo-45256: Avoid C calls for most Python to Python calls. (GH-28937)Mark Shannon2021-10-181-153/+97
| | | | | | * Avoid making C calls for most calls to Python functions. * Change initialize_locals(steal=true) and _PyTuple_FromArraySteal to consume the argument references regardless of whether they succeed or fail.
* bpo-45434: Include stdlib.h for specialize stat (GH-29015)Dong-hee Na2021-10-181-1/+2
|
* bpo-45020: Default to using frozen modules unless running from source tree. ↵Eric Snow2021-10-162-19/+73
| | | | | | | (gh-28940) The default was "off". Switching it to "on" means users get the benefit of frozen stdlib modules without having to do anything. There's a special-case for running-in-source-tree, so contributors don't get surprised when their stdlib changes don't get used. https://bugs.python.org/issue45020
* bpo-45440: Remove pymath.c fallbacks (GH-28977)Victor Stinner2021-10-151-48/+0
| | | | | | | | Remove fallbacks for missing round(), copysign() and hypot() in Python/pymath.c. Python now requires these functions to build. These fallbacks were needed on Visual Studio 2012 and older. They are no longer needed since Visual Stuido 2013. Python is now built with Visual Studio 2017 or newer since Python 3.6.
* bpo-43760: Add PyThreadState_EnterTracing() (GH-28542)Victor Stinner2021-10-153-18/+27
| | | | | | | | | | Add PyThreadState_EnterTracing() and PyThreadState_LeaveTracing() functions to the limited C API to suspend and resume tracing and profiling. Add an unit test on the PyThreadState C API to _testcapi. Add also internal _PyThreadState_DisableTracing() and _PyThreadState_ResetTracing().
* bpo-45482: Rename namespaceobject.h to pycore_namespace.h (GH-28975)Victor Stinner2021-10-152-10/+11
| | | | | | | | | Rename Include/namespaceobject.h to Include/internal/pycore_namespace.h. The _testmultiphase extension is now built with the Py_BUILD_CORE_MODULE macro defined to access _PyNamespace_Type. object.c: remove unused "pycore_context.h" include.
* bpo-35134: Move classobject.h to Include/cpython/ (GH-28968)Victor Stinner2021-10-151-1/+0
| | | | | | | | | Move classobject.h, context.h, genobject.h and longintrepr.h header files from Include/ to Include/cpython/. Remove redundant "#ifndef Py_LIMITED_API" in context.h. Remove explicit #include "longintrepr.h" in C files. It's not needed, Python.h already includes it.
* bpo-35134: Add Include/cpython/floatobject.h (GH-28957)Victor Stinner2021-10-141-0/+1
| | | | | Split Include/floatobject.h into sub-files: add Include/cpython/floatobject.h and Include/internal/pycore_floatobject.h.
* bpo-21736: Set __file__ on frozen stdlib modules. (gh-28656)Eric Snow2021-10-142-25/+59
| | | | | | | | | | | | | | | | | | | | | | | | Currently frozen modules do not have __file__ set. In their spec, origin is set to "frozen" and they are marked as not having a location. (Similarly, for frozen packages __path__ is set to an empty list.) However, for frozen stdlib modules we are able to extrapolate __file__ as long as we can determine the stdlib directory at runtime. (We now do so since gh-28586.) Having __file__ set is helpful for a number of reasons. Likewise, having a non-empty __path__ means we can import submodules of a frozen package from the filesystem (e.g. we could partially freeze the encodings module). This change sets __file__ (and adds to __path__) for frozen stdlib modules. It uses sys._stdlibdir (from gh-28586) and the frozen module alias information (from gh-28655). All that work is done in FrozenImporter (in Lib/importlib/_bootstrap.py). Also, if a frozen module is imported before importlib is bootstrapped (during interpreter initialization) then we fix up that module and its spec during the importlib bootstrapping step (i.e. imporlib._bootstrap._setup()) to match what gets set by FrozenImporter, including setting the file info (if the stdlib dir is known). To facilitate this, modules imported using PyImport_ImportFrozenModule() have __origname__ set using the frozen module alias info. __origname__ is popped off during importlib bootstrap. (To be clear, even with this change the new code to set __file__ during fixups in imporlib._bootstrap._setup() doesn't actually get triggered yet. This is because sys._stdlibdir hasn't been set yet in interpreter initialization at the point importlib is bootstrapped. However, we do fix up such modules at that point to otherwise match the result of importing through FrozenImporter, just not the __file__ and __path__ parts. Doing so will require changes in the order in which things happen during interpreter initialization. That can be addressed separately. Once it is, the file-related fixup code from this PR will kick in.) Here are things this change does not do: * set __file__ for non-stdlib modules (no way of knowing the parent dir) * set __file__ if the stdlib dir is not known (nor assume the expense of finding it) * relatedly, set __file__ if the stdlib is in a zip file * verify that the filename set to __file__ actually exists (too expensive) * update __path__ for frozen packages that alias a non-package (since there is no package dir) Other things this change skips, but we may do later: * set __file__ on modules imported using PyImport_ImportFrozenModule() * set co_filename when we unmarshal the frozen code object while importing the module (e.g. in FrozenImporter.exec_module()) -- this would allow tracebacks to show source lines * implement FrozenImporter.get_filename() and FrozenImporter.get_source() https://bugs.python.org/issue21736
* bpo-45471: Do not set PyConfig.stdlib_dir in Py_SetPythonHome(). (gh-28954)Eric Snow2021-10-141-4/+1
| | | | | The change in gh-28586 (bpo-45211) should not have included code to set _Py_path_config.stdlib_dir in Py_SetPythonHome(). We fix that here. https://bugs.python.org/issue45471
* bpo-45439: Move _PyObject_VectorcallTstate() to pycore_call.h (GH-28893)Victor Stinner2021-10-141-1/+1
| | | | | | | | | | | * Move _PyObject_VectorcallTstate() and _PyObject_FastCallTstate() to pycore_call.h (internal C API). * Convert PyObject_CallOneArg(), PyObject_Vectorcall(), _PyObject_FastCall() and PyVectorcall_Function() static inline functions to regular functions. * Add _PyVectorcall_FunctionInline() static inline function. * PyObject_Vectorcall(), _PyObject_FastCall(), and PyObject_CallOneArg() now call _PyThreadState_GET() rather than PyThreadState_Get().
* bpo-45367: Specialize BINARY_MULTIPLY (GH-28727)Dennis Sweeney2021-10-143-23/+116
|
* Ensure that instruction cases are self-contained (GH-28938)Brandt Bucher2021-10-131-6/+6
|
* bpo-45440: Require math.h isinf() to build (GH-28894)Victor Stinner2021-10-131-13/+0
| | | | | | | | | | | | | | | Building Python now requires a C99 <math.h> header file providing isinf(), isnan() and isfinite() functions. Remove the Py_FORCE_DOUBLE() macro. It was used by the Py_IS_INFINITY() macro. Changes: * Remove Py_IS_NAN(), Py_IS_INFINITY() and Py_IS_FINITE() in PC/pyconfig.h. * Remove the _Py_force_double() function. * configure no longer checks if math.h defines isinf(), isnan() and isfinite().
* bpo-45434: pyport.h no longer includes <stdlib.h> (GH-28914)Victor Stinner2021-10-137-5/+13
| | | | | Include <stdlib.h> explicitly in C files. Python.h includes <wchar.h>.
* bpo-45445: Fail if an invalid X-option is provided in the command line ↵Pablo Galindo Salgado2021-10-131-0/+48
| | | | (GH-28823)
* bpo-45434: Mark the PyTokenizer C API as private (GH-28924)Victor Stinner2021-10-133-6/+5
| | | | | | | | | | | | | | Rename PyTokenize functions to mark them as private: * PyTokenizer_FindEncodingFilename() => _PyTokenizer_FindEncodingFilename() * PyTokenizer_FromString() => _PyTokenizer_FromString() * PyTokenizer_FromFile() => _PyTokenizer_FromFile() * PyTokenizer_FromUTF8() => _PyTokenizer_FromUTF8() * PyTokenizer_Free() => _PyTokenizer_Free() * PyTokenizer_Get() => _PyTokenizer_Get() Remove the unused PyTokenizer_FindEncoding() function. import.c: remove unused #include "errcode.h".
* bpo-45256: Fix cleanup of stolen locals for Python-to-Python calls (GH-28905)Pablo Galindo Salgado2021-10-131-10/+24
|
* bpo-45434: Remove pystrhex.h header file (GH-28923)Victor Stinner2021-10-131-2/+2
| | | | | | | | | | | | | | | Move Include/pystrhex.h to Include/internal/pycore_strhex.h. The header file only contains private functions. The following C extensions are now built with Py_BUILD_CORE_MODULE macro defined to get access to the internal C API: * _blake2 * _hashopenssl * _md5 * _sha1 * _sha3 * _ssl * binascii
* bpo-45340: Don't create object dictionaries unless actually needed (GH-28802)Mark Shannon2021-10-133-119/+112
| | | | | | | | | | | | | | * Never change types' cached keys. It could invalidate inline attribute objects. * Lazily create object dictionaries. * Update specialization of LOAD/STORE_ATTR. * Don't update shared keys version for deletion of value. * Update gdb support to handle instance values. * Rename SPLIT_KEYS opcodes to INSTANCE_VALUE.
* bpo-45434: Move _Py_BEGIN_SUPPRESS_IPH to pycore_fileutils.h (GH-28922)Victor Stinner2021-10-131-2/+3
|
* pycore_pystate.h no longer redefines PyThreadState_GET() (GH-28921)Victor Stinner2021-10-136-11/+17
| | | | | | | | | | | | | | | | | | | | | | Redefining the PyThreadState_GET() macro in pycore_pystate.h is useless since it doesn't affect files not including it. Either use _PyThreadState_GET() directly, or don't use pycore_pystate.h internal C API. For example, the _testcapi extension don't use the internal C API, but use the public PyThreadState_Get() function instead. Replace PyThreadState_Get() with _PyThreadState_GET(). The _PyThreadState_GET() macro is more efficient than PyThreadState_Get() and PyThreadState_GET() function calls which call fail with a fatal Python error. posixmodule.c and _ctypes extension now include <windows.h> before pycore header files (like pycore_call.h). _PyTraceback_Add() now uses _PyErr_Fetch()/_PyErr_Restore() instead of PyErr_Fetch()/PyErr_Restore(). The _decimal and _xxsubinterpreters extensions are now built with the Py_BUILD_CORE_MODULE macro defined to get access to the internal C API.
* bpo-45434: Convert Py_GETENV() macro to a function (GH-28912)Victor Stinner2021-10-131-0/+8
| | | Avoid calling directly getenv() in the header file.
* Fix format string in _PyImport_LoadDynamicModuleWithSpec() (GH-28863)Serhiy Storchaka2021-10-121-1/+1
|
* bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895)Victor Stinner2021-10-126-13/+18
| | | | | | | * Move _PyObject_CallNoArgs() to pycore_call.h (internal C API). * _ssl, _sqlite and _testcapi extensions now call the public PyObject_CallNoArgs() function, rather than _PyObject_CallNoArgs(). * _lsprof extension is now built with Py_BUILD_CORE_MODULE macro defined to get access to internal _PyObject_CallNoArgs().
* bpo-45439: Rename _PyObject_CallNoArg() to _PyObject_CallNoArgs() (GH-28891)Victor Stinner2021-10-116-10/+10
| | | | | Fix typo in the private _PyObject_CallNoArg() function name: rename it to _PyObject_CallNoArgs() to be consistent with the public function PyObject_CallNoArgs().
* bpo-45412: Move _Py_SET_53BIT_PRECISION_START to pycore_pymath.h (GH-28882)Victor Stinner2021-10-112-5/+5
| | | | | | | | | | | | | | | Move the following macros , to pycore_pymath.h (internal C API): * _Py_SET_53BIT_PRECISION_HEADER * _Py_SET_53BIT_PRECISION_START * _Py_SET_53BIT_PRECISION_END PEP 7: add braces to if and "do { ... } while (0)" in these macros. Move also _Py_get_387controlword() and _Py_set_387controlword() definitions to pycore_pymath.h. These functions are no longer exported. pystrtod.c now includes pycore_pymath.h.
* bpo-45412: Remove Py_SET_ERRNO_ON_MATH_ERROR() macro (GH-28820)Victor Stinner2021-10-111-2/+3
| | | | | | | | | | | | | | | | | | | | | | Remove the following math macros using the errno variable: * Py_ADJUST_ERANGE1() * Py_ADJUST_ERANGE2() * Py_OVERFLOWED() * Py_SET_ERANGE_IF_OVERFLOW() * Py_SET_ERRNO_ON_MATH_ERROR() Create pycore_pymath.h internal header file. Rename Py_ADJUST_ERANGE1() and Py_ADJUST_ERANGE2() to _Py_ADJUST_ERANGE1() and _Py_ADJUST_ERANGE2(), and convert these macros to static inline functions. Move the following macros to pycore_pymath.h: * _Py_IntegralTypeSigned() * _Py_IntegralTypeMax() * _Py_IntegralTypeMin() * _Py_InIntegralTypeRange()
* Handle error when PyUnicode_GetLength returns a negative value. (GH-28859)Dong-hee Na2021-10-111-0/+3
|
* Restore PEP 523 functionality. (GH-28871)Mark Shannon2021-10-112-6/+12
|
* Fix a leak in _PyImport_LoadDynamicModuleWithSpec() after failing ↵Serhiy Storchaka2021-10-111-1/+1
| | | | PySys_Audit() (GH-28862)
* bpo-29410: Change the default hash algorithm to SipHash13. (GH-28752)Inada Naoki2021-10-101-7/+72
| | | | Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no> Co-authored-by: Christian Heimes <christian@python.org>
* bpo-45256: Small cleanups for the code that inlines Python-to-Python calls ↵Pablo Galindo Salgado2021-10-091-11/+22
| | | | in ceval.c (GH-28836)
* bpo-45256: Remove the usage of the C stack in Python to Python calls (GH-28488)Pablo Galindo Salgado2021-10-091-29/+120
| | | | Ths commit inlines calls to Python functions in the eval loop and steals all the arguments in the call from the caller for performance.
* Fix typos in the Python directory (GH-28767)Christian Clauss2021-10-067-11/+11
|
* bpo-40116: Add insertion order bit-vector to dict values to allow dicts to ↵Mark Shannon2021-10-061-5/+6
| | | | share keys more freely. (GH-28520)
* Normalize jumps in compiler. All forward jumps to use JUMP_FORWARD. (GH-28755)Mark Shannon2021-10-062-12/+35
|
* bpo-45020: Identify which frozen modules are actually aliases. (gh-28655)Eric Snow2021-10-053-14/+92
| | | | | | | In the list of generated frozen modules at the top of Tools/scripts/freeze_modules.py, you will find that some of the modules have a different name than the module (or .py file) that is actually frozen. Let's call each case an "alias". Aliases do not come into play until we get to the (generated) list of modules in Python/frozen.c. (The tool for freezing modules, Programs/_freeze_module, is only concerned with the source file, not the module it will be used for.) Knowledge of which frozen modules are aliases (and the identity of the original module) normally isn't important. However, this information is valuable when we go to set __file__ on frozen stdlib modules. This change updates Tools/scripts/freeze_modules.py to map aliases to the original module name (or None if not a stdlib module) in Python/frozen.c. We also add a helper function in Python/import.c to look up a frozen module's alias and add the result of that function to the frozen info returned from find_frozen(). https://bugs.python.org/issue45020
* bpo-45324: Capture data in FrozenImporter.find_spec() to use in ↵Eric Snow2021-10-052-90/+245
| | | | | | | | | | | exec_module(). (gh-28633) Before this change we end up duplicating effort and throwing away data in FrozenImporter.find_spec(). Now we do the work once in find_spec() and the only thing we do in FrozenImporter.exec_module() is turn the raw frozen data into a code object and then exec it. We've added _imp.find_frozen(), add an arg to _imp.get_frozen_object(), and updated FrozenImporter. We've also moved some code around to reduce duplication, get a little more consistency in outcomes, and be more efficient. Note that this change is mostly necessary if we want to set __file__ on frozen stdlib modules. (See https://bugs.python.org/issue21736.) https://bugs.python.org/issue45324
* bpo-44050: Extension modules can share state when they don't support ↵Hai Shi2021-10-051-1/+3
| | | | | sub-interpreters. (GH-27794) Automerge-Triggered-By: GH:encukou
* bpo-43760: Check for tracing using 'bitwise or' instead of branch in ↵Mark Shannon2021-10-054-216/+244
| | | | dispatch. (GH-28723)
* Fix compiler warning in ceval.c regarding signed comparison (GH-28716)Pablo Galindo Salgado2021-10-041-1/+1
|
* bpo-45355: More use of sizeof(_Py_CODEUNIT) (GH-28720)Serhiy Storchaka2021-10-041-1/+1
|
* bpo-45355: Use sizeof(_Py_CODEUNIT) instead of literal 2 for the size of the ↵Serhiy Storchaka2021-10-032-11/+11
| | | | code unit (GH-28711)
* Remove trailing spaces. (GH-28706)Serhiy Storchaka2021-10-032-2/+2
|
* Fix a couple of compiler warnings. (GH-28677)Mark Shannon2021-10-011-2/+2
|
* bpo-41710: Add private _PyDeadline_Get() function (GH-28674)Victor Stinner2021-10-013-40/+77
| | | | | | | | Add a private C API for deadlines: add _PyDeadline_Init() and _PyDeadline_Get() functions. * Add _PyTime_Add() and _PyTime_Mul() functions which compute t1+t2 and t1*t2 and clamp the result on overflow. * _PyTime_MulDiv() now uses _PyTime_Add() and _PyTime_Mul().