[New-bugs-announce] [issue15397] Unbinding of methods

Stefan Mihaila report at bugs.python.org
Thu Jul 19 19:29:06 CEST 2012


New submission from Stefan Mihaila <mstefanro at gmail.com>:

In order to implement pickling of instance methods, a means of separating
the object and the unbound method is necessary.

This is easily done for Python methods (f.__self__ and f.__func__),
but not all of builtins support __func__. Moreover, there currently
appears to be no good way to distinguish functions from bound methods.

As a first step in solving this issue, I have attached a patch which:
1) adds __func__ for all function types
2) adds a few new definitions in the types module (AllFunctionTypes etc.)
3) adds isanyfunction(), isanyboundfunction(), isanyunboundfunction() in
  inspect (admittedly these are bad names)
4) functools.unbind

In case applying this patch is being considered, serious review is necessary,
as I'm not knowledgeable of cpython internals.

----------
components: Library (Lib)
files: func.patch
keywords: patch
messages: 165845
nosy: mstefanro
priority: normal
severity: normal
status: open
title: Unbinding of methods
type: enhancement
versions: Python 3.3
Added file: http://bugs.python.org/file26438/func.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15397>
_______________________________________


More information about the New-bugs-announce mailing list