[Python-3000] Heaptypes

Guido van Rossum guido at python.org
Wed Jul 11 16:47:47 CEST 2007


On 7/11/07, Thomas Heller <theller at ctypes.org> wrote:
> Let me explain it in other words.  This code creates a new type:
>
> >>> ht = type("name", (object,), {})
> [47054 refs]
> >>> ht
> <class '__main__.name'>
> [47093 refs]
>
> The '__name__' attribute is a (unicode) string:
>
> >>> ht.__name__
> 'name'
> [47121 refs]
> >>>
>
> But I can also create a type in this way:
>
> >>> ht = type(str8(b"name"), (object,), {})
> [47208 refs]
>
> The __name__ attribute is a str8 instance:
>
> >>> ht.__name__
> s'name'
> [47236 refs]
>
> Printing the type triggers an assertion:
>
> >>> ht
> Assertion failed: obj && PyUnicode_Check(obj), file \svn\py3k-struni\Objects\unicodeobject.c, line 630
> C:\svn\py3k-struni\PCbuild>
>
> because parts of the code assume that the '__name__' is a (unicode) string.

Hm. I guess the creation must insist that __name__ is a unicode. Can
you fix this yourself?

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list