Skip to content

pdb does not lazy-import rlcompleter, leading to non-lazy import of readline #138860

Closed

Description

@kelu-wandb

Bug report

Bug description:

Problem summary

Starting in Python 3.13, Lib/pdb.py contains a top-level from rlcompleter import Completer, which indirectly causes a top-level import readline, which deadlocks waiting to access stdin if pdb is imported directly or indirectly in a subprocess launched with either process_group=0 or preexec_fn=setpgrp.

Proposed change

History and Details

  • python/cpython PR 112950, released in Python 3.13, added the from rlcompleter import Completer to Lib/pdb.py. There was no top-level indirect import of readline before this.
  • This only impacts import readline when it's backed by GNU libreadline. Notably, the Mac default Python installation uses libedit instead, so on Macs this can only be reproduced by using conda or pyenv with a separately downloaded copy of Python 3.13.

Rationale

Full writeup

This issue focuses on the pdb part of the problem.

Here's a comprehensive cross-functional writeup about the issue: https://github.com/kelu-wandb/public-demo/tree/main/pgrp-torch-pdb-readline

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Linked PRs

Activity

  1. kelu-wandb commented on Sep 12, 2025

    @kelu-wandb
    Author

    cc @gaogaotiantian and @iritkatriel , author and reviewer of #112950

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Sep 13, 2025
  3. added
    3.13only security fixes
    3.14bugs and security fixes
    3.15bugs and security fixes
    on Sep 20, 2025
  4. gaogaotiantian commented on Sep 20, 2025

    @gaogaotiantian
    Member

    This is a reasonable request. I'll fix it.

  5. added a commit that references this issue on Sep 24, 2025
  6. added a commit that references this issue on Sep 24, 2025
  7. added a commit that references this issue on Sep 24, 2025
  8. added a commit that references this issue on Oct 10, 2025
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 fixes3.14bugs and security fixes3.15bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions