Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Problems with PyImport_GetImporter() #109521

Closed
Labels
topic-C-APItype-bugAn unexpected behavior, bug, or errortype-crashA hard crash of the interpreter, possibly with a core dump
@serhiy-storchaka

Description

@serhiy-storchaka

Bug report

  1. PyImport_GetImporter() can return NULL with set or not set error. The latter happens only ifsys.path_hooks orsys.path_importer_cache was deleted, or in more obscure cases: when string allocation for strings "path_hooks" or "path_importer_cache" fail, or thesys module was not yet created. These cases so obscure, that the user code most likely do not expect this. The only place wherePyImport_GetImporter() is used in Python itself expects an error to be set if NULL is returned.
  2. PyImport_GetImporter() can crash (in debug build) or raise SystemError ifsys.path_hooks is not a list orsys.path_importer_cache is not a dict. Note that both are set to None in_PyImport_FiniExternal() (which is called inPy_FinalizeEx() andPy_EndInterpreter()).

Crash is unacceptable, so asserts should be replaced with runtime checks and raising an exception (RuntimeError looks suitable).

And I think thatPyImport_GetImporter() should set RuntimeError when it fails to getsys.path_hooks orsys.path_importer_cache. It is the most common error in similar cases.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-C-APItype-bugAn unexpected behavior, bug, or errortype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp