Skip to content

Commits on Mar 14, 2023

  1. gh-102660: Handle m_copy Specially for the sys and builtins Modules (g…

    …h-102661)
    
    It doesn't make sense to use multi-phase init for these modules. Using a per-interpreter "m_copy" (instead of PyModuleDef.m_base.m_copy) makes this work okay. (This came up while working on gh-101660.)
    
    Note that we might instead end up disallowing re-load for sys/builtins since they are so special.
    
    #102660
    ericsnowcurrently committed Mar 14, 2023

Commits on Mar 5, 2023

  1. gh-102356: Add thrashcan macros to filter object dealloc (#102426)

    Add thrashcan macros to the deallocator of the filter objects to protect against deeply nested destruction of chains of nested filters.
    mgmacias95 committed Mar 5, 2023

Commits on Jan 30, 2023

Commits on Dec 3, 2022

  1. bpo-15999: Accept arbitrary values for boolean parameters. (#15609)

    builtins and extension module functions and methods that expect boolean values for parameters now accept any Python object rather than just a bool or int type. This is more consistent with how native Python code itself behaves.
    serhiy-storchaka committed Dec 3, 2022

Commits on Nov 23, 2022

  1. gh-99537: Use Py_SETREF(var, NULL) in C code (#99687)

    Replace "Py_DECREF(var); var = NULL;" with "Py_SETREF(var, NULL);".
    vstinner committed Nov 23, 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 16, 2022

  1. gh-99300: Replace Py_INCREF() with Py_NewRef() (#99530)

    Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef()
    and Py_XNewRef().
    vstinner committed Nov 16, 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 May 6, 2022

  1. gh-92203: Add closure support to exec(). (#92204)

    Add a closure keyword-only parameter to exec(). It can only be specified when exec-ing a code object that uses free variables. When specified, it must be a tuple, with exactly the number of cell variables referenced by the code object. closure has a default value of None, and it must be None if the code object doesn't refer to any free variables.
    larryhastings committed May 6, 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 11, 2022

Commits on Feb 8, 2022

  1. bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initi…

    …alized global objects. (gh-30928)
    
    We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code.  It is still used in a number of non-builtin stdlib modules.
    
    The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime.  A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings).
    
    https://bugs.python.org/issue46541#msg411799 explains the rationale for this change.
    
    The core of the change is in:
    
    * (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros
    * Include/internal/pycore_runtime_init.h - added the static initializers for the global strings
    * Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState
    * Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers
    
    I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings.  That check is added to the PR CI config.
    
    The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()).  This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *.
    
    The following are not changed (yet):
    
    * stop using _Py_IDENTIFIER() in the stdlib modules
    * (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API
    * (maybe) intern the strings during runtime init
    
    https://bugs.python.org/issue46541
    ericsnowcurrently committed Feb 8, 2022

Commits on Jan 22, 2022

  1. bpo-46417: Clear more static types (GH-30796)

    * Move PyContext static types into object.c static_types list.
    * Rename PyContextTokenMissing_Type to _PyContextTokenMissing_Type
      and declare it in pycore_context.h.
    * _PyHamtItems types are no long exported: replace PyAPI_DATA() with
      extern.
    vstinner committed Jan 22, 2022

Commits on Jan 18, 2022

  1. bpo-44024: Improve the TypeError message in getattr and hasattr (GH-2…

    …5863)
    
    Use common error message for non-string attribute name in the builtin
    functions getattr and hasattr.
    The special check no longer needed since Python 3.0.
    maggyero committed Jan 18, 2022

Commits on Nov 23, 2021

  1. bpo-44525: Copy free variables in bytecode to allow calls to inner fu…

    …nctions to be specialized (GH-29595)
    
    * Make internal APIs that take PyFrameConstructor take a PyFunctionObject instead.
    
    * Add reference to function to frame, borrow references to builtins and globals.
    
    * Add COPY_FREE_VARS instruction to allow specialization of calls to inner functions.
    markshannon committed Nov 23, 2021

Commits on Oct 13, 2021

  1. pycore_pystate.h no longer redefines PyThreadState_GET() (GH-28921)

    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.
    vstinner committed Oct 13, 2021

Commits on Oct 12, 2021

  1. bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895)

    * 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().
    vstinner committed Oct 12, 2021

Commits on Oct 11, 2021

  1. bpo-45439: Rename _PyObject_CallNoArg() to _PyObject_CallNoArgs() (GH…

    …-28891)
    
    Fix typo in the private _PyObject_CallNoArg() function name: rename
    it to _PyObject_CallNoArgs() to be consistent with the public
    function PyObject_CallNoArgs().
    vstinner committed Oct 11, 2021

Commits on Oct 3, 2021

Commits on Sep 12, 2021

  1. bpo-43413: Fix handling keyword arguments in subclasses of some buiti…

    …n classes (GH-26456)
    
    * Constructors of subclasses of some buitin classes (e.g. tuple, list,
      frozenset) no longer accept arbitrary keyword arguments.
    * Subclass of set can now define a __new__() method with additional
      keyword parameters without overriding also __init__().
    serhiy-storchaka committed Sep 12, 2021

Commits on Sep 7, 2021

  1. bpo-45123: PyAiter_Check and PyObject_GetAiter fix & rename. (GH-28194)

    Fix PyAiter_Check to only check for the `__anext__` presense (not for
    `__aiter__`). Rename `PyAiter_Check()` to `PyAIter_Check()`,
    `PyObject_GetAiter()` -> `PyObject_GetAIter()`.
    
    Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
    1st1 and pablogsal committed Sep 7, 2021

Commits on Aug 7, 2021

Commits on Jul 16, 2021

  1. bpo-20201: variadic arguments support for AC (GH-18609)

    Implement support for `*args` in AC, and port `print()` to use it.
    isidentical committed Jul 16, 2021

Commits on Jun 22, 2021

  1. bpo-43918: document signature and default argument of anext builtin (

    …#25551)
    
    Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
    eriknw and sweeneyde committed Jun 22, 2021
Older