Bugs item #1576241, was opened at 2006-10-12 18:24 Message generated for change (Settings changed) made by akuchling You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1576241&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.5 >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: kajiuma (kajiuma) >Assigned to: A.M. Kuchling (akuchling) Summary: functools.wraps fails on builtins Initial Comment: functools.wraps assumes that the wrapped function has a __dict__ attribute, which is not true for builtins. The attached patch provides an empty dictionaries for functions that do not have the required attributes. This will cause programs expecting an AttributeError (if there are any) to fail. ---------------------------------------------------------------------- >Comment By: A.M. Kuchling (akuchling) Date: 2006-10-27 12:42 Message: Logged In: YES user_id=11375 Committed to trunk (rev.52476) and 25-maint (rev. 52477). thanks for your patch! ---------------------------------------------------------------------- Comment By: Nick Coghlan (ncoghlan) Date: 2006-10-27 12:07 Message: Logged In: YES user_id=1038590 I was mainly considering the decorator use case when I wrote the function, so the idea of a wrapped function without a dict attribute didn't occur to me (obviously!). So definitely fix it on the trunk, and I'd say backport it to 2.5 as well. My reasoning regarding the latter is that the example code in the documentation for functools.wraps is actually buggy with the current behaviour. With this bug fixed, the documentation example will work as intended. ---------------------------------------------------------------------- Comment By: A.M. Kuchling (akuchling) Date: 2006-10-26 15:18 Message: Logged In: YES user_id=11375 The change seems reasonable, but arguably this is an API change because of the AttributeError no longer being raised. Nick, do you want to decide whether to make this change or not? (I can make the edit and add a test if you agree to apply this change.) ---------------------------------------------------------------------- Comment By: kajiuma (kajiuma) Date: 2006-10-12 18:33 Message: Logged In: YES user_id=1619773 Looks like lynx cannot send files. The patch changed: getattr(wrapped, attr) to: getattr(wrapped, attr, {}) At then end of line 35 of Lib/functools.py ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1576241&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com