Issue1243049

classification
Title: Can't subclass str in 2.2a1
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: fwierzbicki, kjohnson
Priority: normal Keywords:

Created on 2005-07-22.11:34:18 by kjohnson, last changed 2005-07-25.00:54:25 by fwierzbicki.

Messages
msg1008 (view) Author: Kent Johnson (kjohnson) Date: 2005-07-22.11:34:18
You can't correctly subclass str in 2.2a1. Instances of
the subclass are actually strings. Here is a simple
example:

>>> class p(str):
...   def foo(self):
...     print 'I am a p'
...
>>> s=p('bar')
>>> s
'bar'
>>> s.foo()
Traceback (innermost last):
 File "<console>", line 1, in ?
AttributeError: 'string' object has no attribute 'foo'
>>> type(s)
<type 'str'>

In Python 2.4.1 I get:
>>> class p(str):
...   def foo(self):
...     print 'I am a p'
...
>>> s = p('bar')
>>> s
'bar'
>>> s.foo()
I am a p
>>> type(s)
<class '__main__.p'>
msg1009 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2005-07-25.00:54:25
Logged In: YES 
user_id=193969

fixed.
History
Date User Action Args
2005-07-22 11:34:18kjohnsoncreate