473,395 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Misleading Python error message

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
Jul 18 '05 #1
3 2199
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


-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Bestiaria Home Page: http://www.beastie.dm.net/ <
Home Page: http://www.dm.net/~wulfraed/ <


Jul 18 '05 #2
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
da***@dalkescientific.com
Jul 18 '05 #3
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
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 241 open ( -6) / 2622 closed (+26) / 2863 total (+20) Bugs : 764 open ( +6) / 4453 closed (+38) / 5217 total (+44) RFE : 150 open...
8
by: Saravanan | last post by:
Hello, Im running Python Application as a Windows Service (using windows extensions). But, sporadically the application crashes (crash in Python23.dll) and this stops the service. This problem...
0
by: Fehy | last post by:
The code below, while compiled with .NET 2003, produce misleading error description: c:\Work\error\exmaple\exmaple\exmaple.cpp(17) : error C2501: 'makeerror' : missing storage-class or type...
6
by: LuciferLeo | last post by:
given i = 0, I know i = i + 1 and i += 1 are all correct but when I type: >>> i++ the interpreter replies: File "<stdin>", line 1 i++ ^ SyntaxError: invalid syntax
8
by: Claudio Grondi | last post by:
Here an example of what I mean (Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte large file): Traceback (most recent call last): File "<pyshell#1>", line 1, in -toplevel-...
5
by: jkn | last post by:
Hi all Python 2.4.2 (#1, Apr 26 2006, 23:35:31) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "<stdin>", line 1, in...
4
by: Erik Johnson | last post by:
I ran into a problem I didn't understand at first. I got part of it figured out. Let me first demonstrate the original problem: class Super(object): def __init__(self): self._class = 'Super'...
27
by: John J. Lee | last post by:
I'm surprised to read this: http://en.wikipedia.org/wiki/Python_3 """Note that while there is no explicit requirement that code be able to run unmodified in both versions, in practice it is...
1
by: MC | last post by:
I had 2 folders I couldn't move or delete. Each had contained the executable from a console-mode Visual Studio 2008 C# application. On trying to move the folders I got the entirely misleading UAC...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.