[Python-bugs-list] [ python-Bugs-504343 ] Unicode docstrings and new style classes

noreply@sourceforge.net noreply@sourceforge.net
Wed, 16 Jan 2002 05:03:43 -0800


Bugs item #504343, was opened at 2002-01-16 04:10
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=504343&group_id=5470

Category: Type/class unification
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
Assigned to: Nobody/Anonymous (nobody)
Summary: Unicode docstrings and new style classes

Initial Comment:
Unicode docstrings don't work with new style
classes. With old style classes they work:
----
class foo:
   u"föö"
class bar(object):
   u"bär"

print repr(foo.__doc__)
print repr(bar.__doc__)
----
This prints
----
u'f\xf6\xf6'
None


----------------------------------------------------------------------

>Comment By: Walter Dörwald (doerwalter)
Date: 2002-01-16 05:03

Message:
Logged In: YES 
user_id=89016

What we could do is add a new slot tp_docobject, that holds 
the doc object. Then type_members would include

{"__doc__", T_OBJECT, offsetof(PyTypeObject, tp_docobject), 
READONLY},

tp_doc should be initialized with an 8bit version of 
tp_docobject (using the default encoding and error='ignore' 
if tp_docobject is unicode).

Does this sound reasonably?

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-01-16 04:18

Message:
Logged In: YES 
user_id=21627

There is a good chance that is caused by the lines following

XXX What if it's a Unicode string?  Don't know -- this
ignores it.

in Objects/typeobject.c. :-) Would you like to investigate
the options and propose a patch?

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=504343&group_id=5470