msg176928 - (view) |
Author: David W. Lambert (LambertDW) |
Date: 2012-12-04 18:54 |
http://forums.devshed.com/newreply.php?do=newreply&noquote=1&p=2838814 >>> class c(tuple): ... def __init__(s,a,b): ... tuple.__init__(s,a) ... self.b = b ... >>> c(tuple(),666) Traceback (most recent call last): File "", line 1, in TypeError: tuple() takes at most 1 argument (2 given) >>> |
|
|
msg176937 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2012-12-04 19:33 |
Is your error report the fact that the name 'tuple' appears in the error message instead of 'c'? That does seem sub-optimal. It may not be easy to improve, though. |
|
|
msg176938 - (view) |
Author: David W. Lambert (LambertDW) |
Date: 2012-12-04 19:42 |
The apparent problem was that the constructing str with __init__ failed. I now recall that immutables take initial values in the __new__ method. Sorry! Otherwise, it was quite thoughtful for you to search for a problem. Dave. |
|
|
msg176946 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2012-12-04 20:08 |
I have no idea what you are referring to by 'constructing str' :( I thought at first it was your incorrect tuple call in the init that was the issue, but that didn't look right, and after reproducing it and playing with it for a bit I figured out it was the __new__ failure, and I realized the reason I was confused was that the error message said 'tuple' instead of 'c'. So I definitely think that message could use improvement if it is practical. |
|
|
msg176948 - (view) |
Author: David W. Lambert (LambertDW) |
Date: 2012-12-04 20:20 |
Sorry again. You probably didn't follow the link I posted to see the problem origination. Which was "Cannot subclass str." I generalized this to tuple. On Tue, 2012-12-04 at 20:08 +0000, R. David Murray wrote: > R. David Murray added the comment: > > I have no idea what you are referring to by 'constructing str' :( > > I thought at first it was your incorrect tuple call in the init that was the issue, but that didn't look right, and after reproducing it and playing with it for a bit I figured out it was the __new__ failure, and I realized the reason I was confused was that the error message said 'tuple' instead of 'c'. So I definitely think that message could use improvement if it is practical. > > ---------- > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue16608> > _______________________________________ |
|
|
msg176950 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2012-12-04 20:23 |
I followed the link, but it took me to a login/signup form, so it wasn't very informative. |
|
|
msg387054 - (view) |
Author: Irit Katriel (iritkatriel) *  |
Date: 2021-02-15 20:26 |
The issue still exists in 3.10: Python 3.10.0a5+ (heads/master:bf2e7e55d7, Feb 11 2021, 23:09:25) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> class c(tuple): ... def __init__(s,a,b): ... tuple.__init__(s,a) ... self.b = b ... >>> c(tuple(),666) Traceback (most recent call last): File "", line 1, in TypeError: tuple expected at most 1 argument, got 2 >>> |
|
|