Issue1322

classification
Title: Metaclass error when doing simple subclassing.
Type: behaviour Severity: urgent
Components: Core Versions:
Milestone:
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: amak, kfitch42
Priority: urgent Keywords:

Created on 2009-04-21.10:51:25 by amak, last changed 2009-04-21.18:11:24 by amak.

Messages
msg4560 (view) Author: Alan Kennedy (amak) Date: 2009-04-21.10:51:23
When try to do some simple sub-classing, get a strange metaclass error.

Jython 2.5b3+ (trunk, Apr 21 2009, 11:45:20)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.5.0_17
Type "help", "copyright", "credits" or "license" for more information.
>>> import threading
>>> class MyTimer(threading.Timer): pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Error when calling the metaclass bases
    function() argument 1 must be code, not str
>>>
msg4561 (view) Author: Kevin Fitch (kfitch42) Date: 2009-04-21.16:06:34
Just looked and threading.Timer is a factory function, not a class.
Which is why subclassing it is a no-go. Although the error message could
be a bit more clear.

I don't quite see why we can't make Timer a real class, although we get
the EXACT same message from CPython.

Not a bug?!?
msg4562 (view) Author: Alan Kennedy (amak) Date: 2009-04-21.18:09:22
You're right, Kevin, subclassing from threading._Timer works as expected.

Cpython also uses a factory function.

Which I think is counter-intuitive; it means that I can't subclass
threading.Timer: I must subclass threading._Timer, which because of the
leading underscore, is a "private" implementation detail.
msg4563 (view) Author: Alan Kennedy (amak) Date: 2009-04-21.18:11:24
Since the behaviour is the same as cpython, the jython behaviour is
acceptable, is counter-intuitive.

Since I opened the bug, I'll close it.
History
Date User Action Args
2009-04-21 18:11:24amaksetstatus: open -> closed
resolution: invalid
messages: + msg4563
2009-04-21 18:09:24amaksetmessages: + msg4562
2009-04-21 16:06:35kfitch42setnosy: + kfitch42
messages: + msg4561
2009-04-21 10:51:25amakcreate