Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Misleading Python error message

Reply
Thread Tools

Misleading Python error message

 
 
Brian Kelley
Guest
Posts: n/a
 
      11-19-2003
I accidentally derived a class from a module (types instead of
types.Dicttype)

>>> import types
>>> class f(types): pass

....
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: function takes at most 2 arguments (3 given)

Shouldn't this report something like (TypeError: can't subclass from a
module) It goes to the right line, but I coudn't see where the function
was being called

Brian


 
Reply With Quote
 
 
 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      11-20-2003
Brian Kelley fed this fish to the penguins on Wednesday 19 November
2003 12:02 pm:


> Shouldn't this report something like (TypeError: can't subclass from a
> module) It goes to the right line, but I coudn't see where the
> function was being called
>

Which version?

Python 2.2 (#1, Nov 5 2002, 15:43:24)
[GCC 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)] on linux-i386
Type "help", "copyright", "credits" or "license" for more information.
>>> import types
>>> class f(types):

.... pass
....
>>> class f(types): pass

....
>>>
>>> dir(f)

[]
>>> t = f()

Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'module' object is not callable
>>>


--
> ================================================== ============ <
> http://www.velocityreviews.com/forums/(E-Mail Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> (E-Mail Removed) | Bestiaria Support Staff <
> ================================================== ============ <
> Bestiaria Home Page: http://www.beastie.dm.net/ <
> Home Page: http://www.dm.net/~wulfraed/ <


 
Reply With Quote
 
 
 
 
Andrew Dalke
Guest
Posts: n/a
 
      11-20-2003
Brian Kelley:
> I accidentally derived a class from a module (types instead of
> types.Dicttype)

...
> TypeError: function takes at most 2 arguments (3 given)
>
> Shouldn't this report something like (TypeError: can't subclass from a
> module) It goes to the right line, but I coudn't see where the function
> was being called


Strangely enough, I asked this question last week, titled "class with
invalid base class". (Strange because Brian and I used to work
together but there's no causation for this correlation in questions.)

Merging answers from Thomas Heller and Michael Hudson

If the type(base class) is callable, which is true for all type objects
since 2.2, then it's called with three arguments: The name of
the new class, a tuple of the bases, and a dictionary.

However, ModuleType only takes two parameters, not three,
hence the TypeError.

I completely agree that the error message is inexplicable to all
but those whose heads have exploded.

Andrew
(E-Mail Removed)


 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      11-20-2003
Dennis Lee Bieber wrote:
>
> Brian Kelley fed this fish to the penguins on Wednesday 19 November
> 2003 12:02 pm:
>
> > Shouldn't this report something like (TypeError: can't subclass from a
> > module) It goes to the right line, but I coudn't see where the
> > function was being called
> >

> Which version?


Python 2.3, of course, as a result of the new types stuff.

-Peter
 
Reply With Quote
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      11-21-2003
Peter Hansen fed this fish to the penguins on Thursday 20 November 2003
06:14 am:

>
> Python 2.3, of course, as a result of the new types stuff.
>

Ah.. new behavior, then...

--
> ================================================== ============ <
> (E-Mail Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> (E-Mail Removed) | Bestiaria Support Staff <
> ================================================== ============ <
> Bestiaria Home Page: http://www.beastie.dm.net/ <
> Home Page: http://www.dm.net/~wulfraed/ <


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Misleading error message of the day Roy Smith Python 37 12-10-2011 11:41 PM
Misleading wikipedia article on Python 3? John J. Lee Python 27 08-10-2007 08:28 AM
subclassing a module: misleading(?) error message Erik Johnson Python 4 01-11-2007 06:50 PM
Misleading error message when opening a file (on Windows XP SP 2) Claudio Grondi Python 8 08-28-2006 08:12 PM
Misleading Symantec LiveUpdate Scheduler Error Events Dick K Computer Support 1 04-18-2006 10:52 AM



Advertisments