Skip to content

Commits on Dec 18, 2022

Commits on Nov 22, 2022

  1. gh-99537: Use Py_SETREF() function in C code (#99657)

    Fix potential race condition in code patterns:
    
    * Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);"
    * Replace "Py_XDECREF(var); var = new;" with "Py_XSETREF(var, new);"
    * Replace "Py_CLEAR(var); var = new;" with "Py_XSETREF(var, new);"
    
    Other changes:
    
    * Replace "old = var; var = new; Py_DECREF(var)"
      with "Py_SETREF(var, new);"
    * Replace "old = var; var = new; Py_XDECREF(var)"
      with "Py_XSETREF(var, new);"
    * And remove the "old" variable.
    vstinner committed Nov 22, 2022

Commits on Nov 14, 2022

  1. gh-87604: Avoid publishing list of active per-interpreter audit hooks…

    … via the gc module (GH-99373)
    zooba committed Nov 14, 2022

Commits on Nov 12, 2022

  1. gh-81057: Move PyImport_Inittab to _PyRuntimeState (gh-99402)

    We actually don't move PyImport_Inittab.  Instead, we make a copy that we keep on _PyRuntimeState and use only that after Py_Initialize().  We also prevent folks from modifying PyImport_Inittab (the best we can) after that point.
    
    #81057
    ericsnowcurrently committed Nov 12, 2022

Commits on Nov 10, 2022

  1. gh-99300: Use Py_NewRef() in Python/ directory (#99317)

    Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
    Py_XNewRef() in C files of the Python/ directory.
    
    Update Parser/asdl_c.py to regenerate Python/Python-ast.c.
    vstinner committed Nov 10, 2022

Commits on Oct 4, 2022

  1. gh-97670: Remove sys.getdxp() and analyze_dxp.py script (#97671)

    Remove the sys.getdxp() function and the Tools/scripts/analyze_dxp.py
    script. DXP stands for "dynamic execution pairs". They were related
    to DYNAMIC_EXECUTION_PROFILE and DXPAIRS macros which have been
    removed in Python 3.11. Python can now be built with "./configure
    --enable-pystats" to gather statistics on Python opcodes.
    vstinner committed Oct 4, 2022

Commits on Oct 3, 2022

  1. gh-96512: Move int_max_str_digits setting to PyConfig (#96944)

    It had to live as a global outside of PyConfig for stable ABI reasons in
    the pre-3.12 backports.
    
    This removes the `_Py_global_config_int_max_str_digits` and gets rid of
    the equivalent field in the internal `struct _is PyInterpreterState` as
    code can just use the existing nested config struct within that.
    
    Adds tests to verify unique settings and configs in subinterpreters.
    gpshead committed Oct 3, 2022

Commits on Sep 7, 2022

  1. gh-89545: Updates platform module to use new internal _wmi module on …

    …Windows to directly query OS properties (GH-96289)
    zooba committed Sep 7, 2022

Commits on Sep 2, 2022

  1. gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96499)

    Integer to and from text conversions via CPython's bignum `int` type is not safe against denial of service attacks due to malicious input. Very large input strings with hundred thousands of digits can consume several CPU seconds.
    
    This PR comes fresh from a pile of work done in our private PSRT security response team repo.
    
    Signed-off-by: Christian Heimes [Red Hat] <christian@python.org>
    Tons-of-polishing-up-by: Gregory P. Smith [Google] <greg@krypto.org>
    Reviews via the private PSRT repo via many others (see the NEWS entry in the PR).
    
    <!-- gh-issue-number: gh-95778 -->
    * Issue: gh-95778
    <!-- /gh-issue-number -->
    
    I wrote up [a one pager for the release managers](https://docs.google.com/document/d/1KjuF_aXlzPUxTK4BMgezGJ2Pn7uevfX7g0_mvgHlL7Y/edit#). Much of that text wound up in the Issue. Backports PRs already exist. See the issue for links.
    gpshead committed Sep 2, 2022

Commits on Aug 30, 2022

  1. gh-96143: Allow Linux perf profiler to see Python calls (GH-96123)

    ⚠️  ⚠️ Note for reviewers, hackers and fellow systems/low-level/compiler engineers ⚠️ ⚠️ 
    
    If you have a lot of experience with this kind of shenanigans and want to improve the **first** version, **please make a PR against my branch** or **reach out by email** or **suggest code changes directly on GitHub**. 
    
    If you have any **refinements or optimizations** please, wait until the first version is merged before starting hacking or proposing those so we can keep this PR productive.
    pablogsal committed Aug 30, 2022

Commits on Aug 24, 2022

  1. GH-93503: Add thread-specific APIs to set profiling and tracing funct…

    …ions in the C-API (#93504)
    
    * gh-93503: Add APIs to set profiling and tracing functions in all threads in the C-API
    
    * Use a separate API
    
    * Fix NEWS entry
    
    * Add locks around the loop
    
    * Document ignoring exceptions
    
    * Use the new APIs in the sys module
    
    * Update docs
    pablogsal committed Aug 24, 2022

Commits on Aug 13, 2022

  1. gh-95853: Add script to automate WASM build (GH-95828)

    Automate WASM build with a new Python script. The script provides
    several build profiles with configure flags for Emscripten flavors
    and WASI. The script can detect and use Emscripten SDK and WASI SDK from
    default locations or env vars.
    
    ``configure`` now detects Node arguments and creates HOSTRUNNER
    arguments for Node 16. It also sets correct arguments for
    ``wasm64-emscripten``.
    
    Co-authored-by: Brett Cannon <brett@python.org>
    tiran and brettcannon committed Aug 13, 2022

Commits on Jul 25, 2022

  1. gh-94673: Add _PyStaticType_InitBuiltin() (#95152)

    This is the first of several precursors to storing tp_subclasses (and tp_weaklist) on the interpreter state for static builtin types.
    
    We do the following:
    
    * add `_PyStaticType_InitBuiltin()`
    * add `_Py_TPFLAGS_STATIC_BUILTIN`
    * set it on all static builtin types in `_PyStaticType_InitBuiltin()`
    * shuffle some code around to be able to use _PyStaticType_InitBuiltin()
        * rename `_PyStructSequence_InitType()` to `_PyStructSequence_InitBuiltinWithFlags()`
        * add `_PyStructSequence_InitBuiltin()`.
    ericsnowcurrently committed Jul 25, 2022

Commits on Jun 21, 2022

Commits on Jun 19, 2022

  1. gh-93937, C API: Move PyFrame_GetBack() to Python.h (#93938)

    Move the follow functions and type from frameobject.h to pyframe.h,
    so the standard <Python.h> provide frame getter functions:
    
    * PyFrame_Check()
    * PyFrame_GetBack()
    * PyFrame_GetBuiltins()
    * PyFrame_GetGenerator()
    * PyFrame_GetGlobals()
    * PyFrame_GetLasti()
    * PyFrame_GetLocals()
    * PyFrame_Type
    
    Remove #include "frameobject.h" from many C files. It's no longer
    needed.
    vstinner committed Jun 19, 2022

Commits on May 5, 2022

  1. gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)

    Add the -P command line option and the PYTHONSAFEPATH environment
    variable to not prepend a potentially unsafe path to sys.path.
    
    * Add sys.flags.safe_path flag.
    * Add PyConfig.safe_path member.
    * Programs/_bootstrap_python.c uses config.safe_path=0.
    * Update subprocess._optim_args_from_interpreter_flags() to handle
      the -P command line option.
    * Modules/getpath.py sets safe_path to 1 if a "._pth" file is
      present.
    vstinner committed May 5, 2022

Commits on Apr 7, 2022

  1. bpo-35134: Remove the Include/code.h header file (GH-32385)

    Remove the Include/code.h header file. C extensions should only
    include the main <Python.h> header file.
    
    Python.h includes directly Include/cpython/code.h instead.
    vstinner committed Apr 7, 2022

Commits on Apr 4, 2022

  1. bpo-47000: Make io.text_encoding() respects UTF-8 mode (GH-32003)

    Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
    methane and ericsnowcurrently committed Apr 4, 2022

Commits on Mar 31, 2022

  1. bpo-47164: Add _PyCFunction_CAST() macro (GH-32192)

    Use the macro in C files of the Python/ directory.
    vstinner committed Mar 31, 2022

Commits on Mar 25, 2022

  1. bpo-42197: Don't create f_locals dictionary unless we actually need…

    … it. (GH-32055)
    
    * `PyFrame_FastToLocalsWithError` and `PyFrame_LocalsToFast` are no longer called during profile and tracing.
     (Contributed by Fabio Zadrozny)
    
    * Make accesses to a frame's `f_locals` safe from C code, not relying on calls to `PyFrame_FastToLocals` or `PyFrame_LocalsToFast`.
    
    * Document new `PyFrame_GetLocals` C-API function.
    markshannon committed Mar 25, 2022

Commits on Mar 21, 2022

  1. bpo-46850: Remove _PyEval_GetCoroutineOriginTrackingDepth() (GH-32018)

    Remove the private undocumented function
    _PyEval_GetCoroutineOriginTrackingDepth() from the C API. Call the
    public sys.get_coroutine_origin_tracking_depth() function instead.
    
    Change the internal function
    _PyEval_SetCoroutineOriginTrackingDepth():
    
    * Remove the 'tstate' parameter;
    * Add return value and raises an exception if depth is negative;
    * No longer export the function: call the public
      sys.set_coroutine_origin_tracking_depth() function instead.
    
    Uniformize also function declarations in pycore_ceval.h.
    vstinner committed Mar 21, 2022
  2. bpo-46850: Remove _PyEval_SetAsyncGenFinalizer() (GH-32017)

    Remove the following private undocumented functions from the C API:
    
    * _PyEval_GetAsyncGenFirstiter()
    * _PyEval_GetAsyncGenFinalizer()
    * _PyEval_SetAsyncGenFirstiter()
    * _PyEval_SetAsyncGenFinalizer()
    
    Call the public sys.get_asyncgen_hooks() and sys.set_asyncgen_hooks()
    functions instead.
    vstinner committed Mar 21, 2022

Commits on Feb 25, 2022

  1. bpo-46836: Rename InterpreterFrame to _PyInterpreterFrame (GH-31583)

    Rename also struct _interpreter_frame to struct _PyInterpreterFrame.
    
    Reduce risk of name conflicts if a project includes pycore_frame.h.
    vstinner committed Feb 25, 2022

Commits on Feb 23, 2022

  1. bpo-45412: Add _PY_SHORT_FLOAT_REPR macro (GH-31171)

    Remove the HAVE_PY_SET_53BIT_PRECISION macro (moved to the internal
    C API).
    
    * Move HAVE_PY_SET_53BIT_PRECISION macro to pycore_pymath.h.
    * Replace PY_NO_SHORT_FLOAT_REPR macro with _PY_SHORT_FLOAT_REPR
      macro which is always defined. gcc -Wundef emits a warning when
      using _PY_SHORT_FLOAT_REPR but the macro is not defined, if
      pycore_pymath.h include was forgotten.
    vstinner committed Feb 23, 2022
Older