[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2013-07-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2aa6c1e35b8a by Nick Coghlan in branch 'default':
Close #13266: Add inspect.unwrap
http://hg.python.org/cpython/rev/2aa6c1e35b8a

--
nosy: +python-dev
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2013-07-16 Thread Aaron Iles

Aaron Iles added the comment:

My +1 is for the callback based approach. The brevity of the search loop for 
finding the innermost function is (in my opinion at least) non-obvious, relying 
on for loops not having their own scope as it does.

If a generator based API was adopted instead, I propose a convenience function 
(unwrap_all?) to help developers avoid writing code like:

inner = None
for inner in functools.unwrap(outer):
pass
if inner is None:
inner = outer

Which combines a misunderstanding of the API with for loop scope shortcut.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2013-07-15 Thread Nick Coghlan

Nick Coghlan added the comment:

Added a version that allows the iteration to be terminated early if certain 
criteria are met, which is needed for a robust implementation of 
inspect.signature.

However, I'm thinking the callback based approach in this version isn't 
especially Pythonic, so I'm thinking it may be better to change the API to a 
generator function. That way the iterator can still take care of the wrapper 
loop detection, without needing the clumsy predicate API for early termination.

Instead, you would just use an ordinary search loop, and if you wanted the 
innermost function unconditionally you could do something like:

for f in functools.unwrap(original): pass
# f is now the innermost function

--
Added file: http://bugs.python.org/file30927/issue13266_inspect_unwrap_4.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2013-05-24 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


--
assignee:  - ncoghlan

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2013-03-24 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2013-03-19 Thread Nick Coghlan

Nick Coghlan added the comment:

Turns out there's a bug in the implementation of functools.update_wrapper :P

Added that as a dependency, since this API doesn't make sense until 
update_wrapper is behaving itself.

The new tests didn't pick it up because they don't use wraps or update_wrapper, 
they set __wrapped__ directly.

Also, the replacement of the recursion in inspect.signature is incorrect - we 
want to interleave checks for __signature__ as we recurse through the stack of 
wrapper functions.

--
dependencies: +functools.update_wrapper mishandles __wrapped__

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2012-11-22 Thread Daniel Urban

Changes by Daniel Urban urban.dani...@gmail.com:


--
stage: needs patch - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2012-11-04 Thread Daniel Urban

Daniel Urban added the comment:

I've attached a patch addressing the comments on Rietveld. I've added another 
modification: inspect.signature uses inspect.unwrap. (It already tried to 
unwrap the function, but it wasn't protected from infinite recursion. I don't 
know if this worth fixing in 3.3.)

--
Added file: http://bugs.python.org/file27876/inspect_unwrap_3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2012-10-29 Thread Aaron Iles

Aaron Iles added the comment:

I've updated the patch for the current default branch (to be Python 3.4) and 
added documentation to the inspect module for the new unwraps function. 
Functionally unwraps and it's tests are unchanged.

--
Added file: http://bugs.python.org/file27790/p13266-2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2012-08-29 Thread Aaron Iles

Changes by Aaron Iles aaron.i...@gmail.com:


--
nosy: +aliles

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2012-08-28 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
versions: +Python 3.4 -Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2012-04-25 Thread Daniel Urban

Daniel Urban urban.dani...@gmail.com added the comment:

I've attached a patch implementing inspect.unwrap (+ some tests).

--
keywords: +patch
Added file: http://bugs.python.org/file25368/inspect_unwrap.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2011-10-27 Thread Meador Inge

Changes by Meador Inge mead...@gmail.com:


--
nosy: +meador.inge

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2011-10-27 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo, rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2011-10-26 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

After a little thought, I think the explicit unwrap function is the only 
viable approach. Doing the unwrapping implicitly just has too many nasty corner 
cases to track down to ensure we aren't losing existing functionality.

I'd also suggest that we add a __wrapped__ alias for the 'func' attribute of 
functools.partial objects.

--
title: Support for unwrapping __wrapped__ functions in 'inspect' module - Add 
inspect.unwrap(f) to easily unravel __wrapped__ chains

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2011-10-26 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
nosy: +flox

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2011-10-26 Thread Daniel Urban

Changes by Daniel Urban urban.dani...@gmail.com:


--
nosy: +durban

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com