GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — C API: Remove PyEval_AcquireLock() and PyEval_InitThreads() functions · Issue #105182 · python/cpython

C API: Remove PyEval_AcquireLock() and PyEval_InitThreads() functions #105182

New issue
Copy link
New issue
Copy link
Closed
Closed
C API: Remove PyEval_AcquireLock() and PyEval_InitThreads() functions#105182
Copy link
Labels
topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@vstinner
vstinner
opened on Jun 1, 2023
Issue body actions

Since 3.7, PyEval_ThreadsInitialized() always returns non-zero and calling PyEval_InitThreads() is useless: Py_Initialize() now always creates the GIL. These functions were deprecated in Python 3.9 by PR #18892 (commit b4698ec) of issue #84058. What's New in Python 3.9:

* The :c:func:`PyEval_InitThreads` and :c:func:`PyEval_ThreadsInitialized`
  functions are now deprecated and will be removed in Python 3.11. Calling
  :c:func:`PyEval_InitThreads` now does nothing. The :term:`GIL` is initialized
  by :c:func:`Py_Initialize()` since Python 3.7.
  (Contributed by Victor Stinner in :issue:`39877`.)

Well, the removal missed Python 3.11.

PyEval_AcquireLock() and PyEval_ReleaseLock() don't update the current thread state and were deprecated in Python 3.2 by issue #55122:

These two functions are very low-level and no good to use outside the interpreter core (actually, inside the core I don't think they are useful either). We should deprecate them and recommend the thread-state aware functions instead. See issue #44960 for an example confusion.

The commit ebeb903 adds this entry to What's New in Python 3.2:

* The misleading functions :c:func:`PyEval_AcquireLock()` and
  :c:func:`PyEval_ReleaseLock()` have been officially deprecated.  The
  thread-state aware APIs (such as :c:func:`PyEval_SaveThread()`
  and :c:func:`PyEval_RestoreThread()`) should be used instead.

I propose to now removed these 4 deprecated functions.

In 2020, I already proposed to remove PyEval_AcquireLock() and PyEval_ReleaseLock() functions in https://bugs.python.org/issue39998 But I closed my issue when I discovered that they were part of the stable ABI. This is way to keep these functions in the stable ABI and remove them in the C API.

Linked PRs

  • gh-105182: Remove PyEval_AcquireLock() and PyEval_InitThreads() #105183

Activity

  1. vstinner
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jun 1, 2023
  2. vstinner
    added a commit that references this issue on Jun 1, 2023

    pythongh-105182: Remove PyEval_AcquireLock() and PyEval_InitThreads()

    3ab1750
  3. AlexWaygood
    added
    topic-C-API
    on Jun 1, 2023
  4. vstinner
    added a commit that references this issue on Jun 1, 2023

    gh-105182: Remove PyEval_AcquireLock() and PyEval_InitThreads() (#105183

    ec0082c
  5. vstinner
    closed this as completedon Jun 1, 2023
  6. musicinmybrain
    added 2 commits that reference this issue on Nov 2, 2023

    Do not call PyEval_InitThreads

    3100ba8

    [Python] Do not call PyEval_InitThreads

    d583a79
  7. gnossen
    added a commit that references this issue on Nov 2, 2023

    [Python] Do not call PyEval_InitThreads (#34857)

    4580cfd
  8. yarda
    added a commit that references this issue on Apr 4, 2024

    Fixed build with python-3.13

    0e09ee3
  9. jopohl
    added a commit that references this issue on Apr 6, 2024

    Fixed build with python-3.13 (#1111)

    8886970
  10. dl1jbe
    added 2 commits that reference this issue on Nov 15, 2025

    Fixed build with python-3.13 (jopohl#1111)

    2b6c90d

    Fixed build with python-3.13 (jopohl#1111)

    aeea6c0
  11. dl1jbe
    added a commit that references this issue on Nov 23, 2025

    Fixed build with python-3.13 (jopohl#1111)

    da7bfd9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.