Issue22184
Created on 2014-08-11 19:53 by jaraco, last changed 2014-08-13 04:59 by rhettinger. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| lru.diff | rhettinger, 2014-08-12 04:35 | Add type check for maxsize | review | |
| Messages (4) | |||
|---|---|---|---|
| msg225202 - (view) | Author: Jason R. Coombs (jaraco) * | Date: 2014-08-11 19:53 | |
In https://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): pass One 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) | Date: 2014-08-12 19:45 | |
New changeset 780693490c84 by Raymond Hettinger in branch '3.4': Issue 22184: Early detection and reporting of missing lru_cache parameters http://hg.python.org/cpython/rev/780693490c84 |
|||
| msg225251 - (view) | Author: Jason R. Coombs (jaraco) * | Date: 2014-08-13 00:45 | |
Awesome. Thanks for the quick implementation. |
|||
| msg225254 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2014-08-13 04:59 | |
> Awesome. Thanks for the quick implementation. Happy to do it. Thanks for the clean bug report. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2014-08-13 04:59:43 | rhettinger | set | messages: + msg225254 |
| 2014-08-13 00:45:10 | jaraco | set | messages: + msg225251 |
| 2014-08-12 19:46:12 | rhettinger | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2014-08-12 19:45:36 | python-dev | set | nosy:
+ python-dev messages: + msg225241 |
| 2014-08-12 18:37:49 | jwilk | set | nosy:
+ jwilk |
| 2014-08-12 06:12:02 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka |
| 2014-08-12 04:35:26 | rhettinger | set | files:
+ lru.diff keywords: + patch stage: patch review type: behavior versions: + Python 3.4 |
| 2014-08-12 04:15:42 | rhettinger | set | priority: normal -> low assignee: rhettinger versions: + Python 3.5 |
| 2014-08-11 19:53:01 | jaraco | create | |