[Python-3000] Heaptypes (original) (raw)

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


There are currently three "string" types, here shown with there repr styles:

The s'...' notation means it's an 8-bit string (not a bytes array). This is not supported in the syntax; it's just used on output. (Use str8(b'...') to create one of these.) I'm still hoping to remove this type before the release, but it appears to be still necessary so far.

I don't know enouch about ...CallFunction to help you with the rest.

--Guido

On 7/11/07, Thomas Heller <theller at ctypes.org> wrote:

ctypes creates heaptypes with this call, in ctypes.c, line 3986 (slightly simplified):

result = PyObjectCallFunction((PyObject *)&ArrayTypeType, "s(O){s:n,s:O}", name, &ArrayType, "length", length, "type", itemtype ); The call succeeds. Printing the type fails with an assertion: theller at tubu:~/devel/py3k-struni$ ./python Python 3.0x (py3k-struni:56268M, Jul 11 2007, 15:56:43) [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from ctypes import cint [54751 refs] >>> atype = cint * 3 [54762 refs] >>> atype.name s'cintArray3' [55278 refs] >>> repr(atype) python: Objects/unicodeobject.c:630: PyUnicodeUCS2FromFormatV: Assertion `obj && ((((obj)->obtype)->tpflags & ((1L<<28))) != 0)' failed. Abgebrochen theller at tubu:~/devel/py3k-struni$ As one can see, the name is a byte string (or how is this called now?). The fix is probably to use an 'U' format character in the PyObjectCallFunction format string, but I assume the call should have failed in the first place? And what about the dictionary that is constructed for the call '{s:n,s:O}', should it use 'U' format chars also? Thomas


Python-3000 mailing list Python-3000 at python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org

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



More information about the Python-3000 mailing list