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 — Python's help utility crashes when `collections.abc` module is asked. · Issue #123339 · python/cpython

Python's help utility crashes when collections.abc module is asked. #123339

New issue
Copy link
New issue
Copy link
Closed
Closed
Python's help utility crashes when collections.abc module is asked.#123339
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@taaaf11
taaaf11
opened on Aug 26, 2024
Issue body actions

Bug report

Bug description:

I am running Python 3.13.0-b2 on Debian 12 i386. When collections.abc is entered into python interactive help utility, the interpreter crashes.

>>> help
>>> collections.abc
(Python interpreter crashes)

The traceback is indented. So I am attaching video.

recording.mp4

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

  • gh-123339: fix out-of-bounds values in inspect.findsource #123347
  • gh-123339: Fix cases of inconsistency of __module__ and __firstlineno__ in classes #123613
  • [3.13] gh-123339: Fix cases of inconsistency of __module__ and __firstlineno__ in classes (GH-123613) #124735

Activity

  1. taaaf11
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Aug 26, 2024
  2. taaaf11 commented on Aug 26, 2024

    @taaaf11
    taaaf11
    on Aug 26, 2024 · Hidden as resolved
    Author
    show commentMore actions
  3. python
    deleted a comment from on Aug 26, 2024
  4. Eclips4 commented on Aug 26, 2024

    @Eclips4
    Eclips4
    on Aug 26, 2024 · Hidden as resolved
    show commentMore actions
  5. taaaf11 commented on Aug 26, 2024

    @taaaf11
    taaaf11
    on Aug 26, 2024 · Hidden as resolved
    Author
    show commentMore actions
  6. picnixz commented on Aug 26, 2024

    @picnixz
    picnixz
    on Aug 26, 2024
    Member
    More actions

    It appears that lines, lnum = findsource(object) returns objects with len(lines) < lnum. It appears that:

        if isclass(object):
            try:
                firstlineno = vars(object)['__firstlineno__']
            except (TypeError, KeyError):
                raise OSError('source code not available')
            return lines, firstlineno - 1

    and I assume that firstlineno is too large for lines. There is a check if lnum >= len(lines) but only for non-class objects. I can prepare a patch (and it seems it fixes the issue).

  7. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Aug 26, 2024
  8. serhiy-storchaka commented on Aug 28, 2024

    @serhiy-storchaka
    serhiy-storchaka
    on Aug 28, 2024
    Member
    More actions

    Why these classes have the wrong value at first place? I suspect there is a different issue behind this, and clipping the line number can just sweep it under cover.

  9. picnixz commented on Aug 28, 2024

    @picnixz
    picnixz
    on Aug 28, 2024
    Member
    More actions

    The issue is likely due to the fact that _collections_abc has it's name set to collections.abc (#123347 (comment))

  10. serhiy-storchaka commented on Sep 2, 2024

    @serhiy-storchaka
    serhiy-storchaka
    on Sep 2, 2024
    Member
    More actions

    This is a severe issue. Modules collections.abc and decimal are affected completely, because their content is defined in other files. But several other classes in other modules, like abc.ABCMeta or tomllib.TOMLDecodeError are affected too.

    For collections.abc and decimal the solution can be replacing these modules completely in sys.modules This allows to get sources of classes in these modules (previously this did not work). For other classes with changed __module__ the only solution is to delete __firstlineno__. Since this issue can affect not only the stdlib classes, it is better to do this on the low level: setting __module__ will delete __firstlineno__.

  11. picnixz commented on Sep 2, 2024

    @picnixz
    picnixz
    on Sep 2, 2024
    Member
    More actions

    I'll work on something now. I'm done with what I wanted to do today.

  12. picnixz commented on Sep 2, 2024

    @picnixz
    picnixz
    on Sep 2, 2024
    Member
    More actions

    Ok, I've tried to simply change the type.__module__ setter but it appears it's not sufficient enough. I have the idea but I don't have the time today. So I'll do it tomorrow.

  13. picnixz
    self-assigned this
    on Sep 2, 2024
  14. serhiy-storchaka
    added a commit that references this issue on Sep 2, 2024

    pythongh-123339: Fix cases of inconsistency of __module__ and __first…

    fa4c94a
  15. serhiy-storchaka commented on Sep 2, 2024

    @serhiy-storchaka
    serhiy-storchaka
    on Sep 2, 2024
    Member
    More actions

    I already had a ready solution, just was not able to create a PR due to a power outage.

  16. serhiy-storchaka
    added this to Inspect issues 🔍on Sep 2, 2024
  17. serhiy-storchaka
    moved this to Todo in Inspect issues 🔍on Sep 2, 2024
  18. serhiy-storchaka
    moved this from Todo to In Progress in Inspect issues 🔍on Sep 2, 2024
  19. serhiy-storchaka
    added a commit that references this issue on Sep 2, 2024

    pythongh-123339: Fix cases of inconsistency of __module__ and __first…

    f2a8b90
  20. picnixz
    removed their assignment
    on Sep 3, 2024
  21. serhiy-storchaka
    added 2 commits that reference this issue on Sep 28, 2024

    gh-123339: Fix cases of inconsistency of __module__ and __firstlineno…

    69a4063

    [3.13] pythongh-123339: Fix cases of inconsistency of __module__ and …

    27a195e
  22. Yhg1s
    added a commit that references this issue on Sep 30, 2024

    [3.13] gh-123339: Fix cases of inconsistency of __module__ and __firs…

    5bf32d1
  23. hugovk
    closed this as completedon Jan 28, 2025
  24. github-project-automation
    moved this from In Progress to Done in Inspect issues 🔍on Jan 28, 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

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • Inspect issues 🔍
      Status
      Done
      Show more project fields

    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.