On Wed, Jun 6, 2012 at 10:26 AM, Brett Cannon <br...@python.org> wrote: > On behalf of Yury, Larry, Jiwon (wherever he ended up), and myself, here is > an updated version of PEP 362 to address Guido's earlier comments. Credit > for most of the update should go to Yury with Larry also helping out. > > At this point I need a BDFAP and someone to do a code > review: http://bugs.python.org/issue15008 .
I suspect I have too many ideas for what I want the PEP to accomplish to make a good BDFL delegate for this one. One thing I would like to see this PEP achieve is to improve function introspection for @functools.wraps decorated functions where the wrapper uses a (*args, **kwds) signature. To that end, I would prefer to see it added to the functools module rather than to the inspect module. I would also like to see native support for "early binding" validation of call parameters. The idea will be for interfaces that support "lazy calls" (such as contextlib.ExitStack, unittest.TestCase.addCleanup) to detect parameter binding errors when the function is *added*, rather than when it is called. Such lazy call errors are notoriously hard to debug, since the error site (where the callback is invoked) often provides no indication as to where the actual error occurred (that is, when it was registered with the callback interface). Specific proposals: - the goals of the PEP be expanded to include error checking of parameter binding for delayed calls and improve introspection of function wrappers that accept arbitrary arguments, rather than the more nebulous "improve introspection support for functions". - the main new API be added as "functools.signature" (any necessary infrastructure from inspect would also migrate to functools as private implementations. affected inspect APIs would either be updated to use the signature API, or else to just republish the functools implementation) - "functools.update_wrapper" be enhanced to set "wrapper.__signature__ = signature(wrapped)" - At least contextlib and unittest be updated to use "functools.signature(f).bind(*args, **kwds)" for the relevant callback APIs Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com