Issue17071
Created on 2013-01-29 13:10 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| sig_bind_self.patch | pitrou, 2013-01-29 18:43 | review | ||
| Messages (8) | |||
|---|---|---|---|
| msg180906 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2013-01-29 13:10 | |
>>> def f(a, self): pass ... >>> sig = inspect.signature(f) >>> sig.bind(1, 2) <inspect.BoundArguments object at 0x7f607ead1e28> >>> sig.bind(a=1, self=2) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: bind() got multiple values for argument 'self' |
|||
| msg180909 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2013-01-29 15:08 | |
I'll take a look later today. |
|||
| msg180926 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2013-01-29 18:43 | |
Here is a patch. |
|||
| msg180937 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2013-01-29 19:28 | |
Thanks Antoine, the patch looks good to me. The only thing I would have done differently myself is to name "self" as "__bind_self__" (with two underscores at the end). Could you please apply the patch? |
|||
| msg180943 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2013-01-29 20:24 | |
New changeset 49fd1c8aeca5 by Antoine Pitrou in branch '3.3': Issue #17071: Signature.bind() now works when one of the keyword arguments is named ``self``. http://hg.python.org/cpython/rev/49fd1c8aeca5 New changeset 4ff1dc8c0a3c by Antoine Pitrou in branch 'default': Issue #17071: Signature.bind() now works when one of the keyword arguments is named self. http://hg.python.org/cpython/rev/4ff1dc8c0a3c |
|||
| msg180944 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2013-01-29 20:26 | |
Committed to 3.3 and default! |
|||
| msg180951 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2013-01-29 21:38 | |
self doesn't need to have a name, you can use: def bind(*args, **kw): self = args[0] args = args[1:] To accept any name ;-) |
|||
| msg180952 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2013-01-29 21:40 | |
Indeed, there were several solutions to this. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:41 | admin | set | github: 61273 |
| 2013-01-29 21:40:36 | pitrou | set | messages: + msg180952 |
| 2013-01-29 21:38:38 | vstinner | set | nosy:
+ vstinner messages: + msg180951 |
| 2013-01-29 20:26:09 | pitrou | set | status: open -> closed resolution: fixed messages: + msg180944 stage: resolved |
| 2013-01-29 20:24:54 | python-dev | set | nosy:
+ python-dev messages: + msg180943 |
| 2013-01-29 19:28:36 | yselivanov | set | messages: + msg180937 |
| 2013-01-29 18:43:55 | pitrou | set | files:
+ sig_bind_self.patch keywords: + patch messages: + msg180926 |
| 2013-01-29 15:08:38 | yselivanov | set | messages: + msg180909 |
| 2013-01-29 13:11:04 | vstinner | set | nosy:
+ brett.cannon |
| 2013-01-29 13:10:35 | pitrou | link | issue17015 dependencies |
| 2013-01-29 13:10:10 | pitrou | create | |

