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] PyOS_ReadlineFunctionPointer API rely on private _PyOS_ReadlineTState variable removed in Python 3.13 · Issue #112446 · python/cpython

[C API] PyOS_ReadlineFunctionPointer API rely on private _PyOS_ReadlineTState variable removed in Python 3.13 #112446

New issue
Copy link
New issue
Copy link
Closed
Closed
[C API] PyOS_ReadlineFunctionPointer API rely on private _PyOS_ReadlineTState variable removed in Python 3.13#112446
Copy link
Labels
3.13only security fixesonly security fixestopic-C-API

Description

@vstinner
vstinner
opened on Nov 27, 2023
Issue body actions

Hi,

I removed the _PyOS_ReadlineTState variable from the public C API (it was moved to the internal C API). The gdb project sets its readline callback and uses the _PyOS_ReadlineTState variable and so fails to build on Python 3.13.0 alpha2: https://bugzilla.redhat.com/show_bug.cgi?id=2250652

gdb: PyOS_ReadlineFunctionPointer = gdbpy_readline_wrapper;

The gdb function uses _PyOS_ReadlineTState to use the Python C API:

PyEval_RestoreThread (_PyOS_ReadlineTState);
gdbpy_convert_exception (except);
PyEval_SaveThread ();

source: py-gdb-readline.c

The _PyOS_ReadlineTState variable was added in 2004 by commit 30ea2f2.

The callback is called with the GIL released. The _PyOS_ReadlineTState variable is used to acquire again the GIL.


In 2020, I made fixes related to GIL but not directly to this issue:

  • commit c353764
  • commit fa7ab6a

Activity

  1. vstinner
    added
    topic-C-API
    on Nov 27, 2023
  2. AlexWaygood
    added
    3.13only security fixesonly security fixes
    on Nov 28, 2023
  3. vstinner commented on Dec 8, 2023

    @vstinner
    vstinner
    on Dec 8, 2023
    MemberAuthor
    More actions

    The documentation https://docs.python.org/dev/c-api/veryhigh.html#c.PyOS_ReadlineFunctionPointer should also mention the internal lock, at least explain that the callback cannot be called twice at the same time in two threads.

  4. vstinner commented on Dec 12, 2023

    @vstinner
    vstinner
    on Dec 12, 2023
    MemberAuthor
    More actions

    Well, if a readline callback needs to use the Python C API, PyGILState_Ensure() and PyGILState_Release() to be used to temporarily acquire/release the GIL. I'm not sure of the advantage of using PyEval_RestoreThread (_PyOS_ReadlineTState) and PyEval_SaveThread() instead.

  5. vstinner
    closed this as completedon Dec 20, 2023
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

    3.13only security fixesonly security fixestopic-C-API

    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.