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

Python implementation offunctools.lru_cache does not check that argument is callable #144030

Closed
Assignees
rhettinger
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@cfbolz

Description

@cfbolz

Bug report

Bug description:

The C implementation offunctools.lru_cache checks whether its argument is callable and raises an exception if not. The Python version does not do that:

importsyssys.modules['_functools']=Noneimportfunctoolsfunctools.lru_cache()(1)# does not raise

without blocking the import of_functools you get:

Traceback (most recent call last):  File"/home/cfbolz/projects/cpython/functoolserror.py", line5, in<module>    functools.lru_cache()(1)~~~~~~~~~~~~~~~~~~~~~^^^  File"/home/cfbolz/projects/cpython/Lib/functools.py", line598, indecorating_function    wrapper= _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo)TypeError:the first argument must be callable

I think this should simply be fixed in the Python implementation and will prepare a patch.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibStandard 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


    [8]ページ先頭

    ©2009-2026 Movatter.jp