Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue22184

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:lrucache should reject maxsize as a function
Type:behaviorStage:resolved
Components:Library (Lib)Versions:Python 3.4, Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: rhettingerNosy List: jaraco, jwilk, python-dev, rhettinger, serhiy.storchaka
Priority:lowKeywords:patch

Created on2014-08-11 19:53 byjaraco, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
lru.diffrhettinger,2014-08-12 04:35Add type check for maxsizereview
Messages (4)
msg225202 -(view)Author: Jason R. Coombs (jaraco)*(Python committer)Date: 2014-08-11 19:53
Inhttps://bitbucket.org/jaraco/backports.functools_lru_cache/issue/1/python-2-attributeerror-int-object-has-no, a user was confused when he tried to use the lrucache decorator incorrectly, passing the wrapped function directly to lrucache. Consider:    @lrucache    def expensive(param):        passOne can even get away with profiling that now decorated function:    for x in range(10000):        expensive(x)The test will run without error, but it's not doing what the user thinks it's doing. In the first section, it's creating a decorator, and in the second section, it's wrapping an int in that decorator, but because the wrapper is never called, an error is never raised.I propose adding a simple check that if maxsize is callable, raise a TypeError. That would prevent unintentional misuse and subtle non-failure with minimal impact on performance.
msg225241 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2014-08-12 19:45
New changeset780693490c84 by Raymond Hettinger in branch '3.4':Issue 22184: Early detection and reporting of missing lru_cache parametershttp://hg.python.org/cpython/rev/780693490c84
msg225251 -(view)Author: Jason R. Coombs (jaraco)*(Python committer)Date: 2014-08-13 00:45
Awesome. Thanks for the quick implementation.
msg225254 -(view)Author: Raymond Hettinger (rhettinger)*(Python committer)Date: 2014-08-13 04:59
> Awesome. Thanks for the quick implementation.Happy to do it.  Thanks for the clean bug report.
History
DateUserActionArgs
2022-04-11 14:58:06adminsetgithub: 66380
2014-08-13 04:59:43rhettingersetmessages: +msg225254
2014-08-13 00:45:10jaracosetmessages: +msg225251
2014-08-12 19:46:12rhettingersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2014-08-12 19:45:36python-devsetnosy: +python-dev
messages: +msg225241
2014-08-12 18:37:49jwilksetnosy: +jwilk
2014-08-12 06:12:02serhiy.storchakasetnosy: +serhiy.storchaka
2014-08-12 04:35:26rhettingersetfiles: +lru.diff
keywords: +patch
stage: patch review
type: behavior
versions: + Python 3.4
2014-08-12 04:15:42rhettingersetpriority: normal -> low
assignee:rhettinger
versions: + Python 3.5
2014-08-11 19:53:01jaracocreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp