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

Linecache updatecache can perform many useless os calls #140228

Open
Labels
performancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directorytype-refactorCode refactoring (with no changes in behavior)
@tconley1428

Description

@tconley1428

Bug report

Bug description:

Consider the scenario whereupdatecache is called with a frozen module andmodule_globals isNone.

In that case,_source_unavailable returns false because it is a frozen module, but becausemodule_globals isNone, the code carries on to look for the 'file'<frozen module> everywhere insys.path. Compare that to the behavior prior to#132662 where that frozen module would simply return unavailable. I would recommend the following change:

iffilename.startswith("<frozen ")andmodule_globalsisnotNone:# This is a frozen module, so we need to use the filename# from the module globals.fullname=module_globals.get("__file__")iffullnameisNone:print("fullname none")return []

Into

iffilename.startswith("<frozen "):ifmodule_globalsisNone:return []# This is a frozen module, so we need to use the filename# from the module globals.fullname=module_globals.get("__file__")iffullnameisNone:print("fullname none")return []

For context, this is a problem for us because we run in a sandbox which restricts many OS operations, and this is performing useless os operations where it didn't prior to3.14.

If there is agreement and it is helpful, happy to contribute a PR for this small change.

CPython versions tested on:

3.14

Operating systems tested on:

macOS, Windows, Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directorytype-refactorCode refactoring (with no changes in behavior)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp