[Patches] Py_BuildValue Unicode support

Brian Hooper brian@garage.co.jp
Thu, 20 Apr 2000 01:31:56 GMT

This is a multi-part message in MIME format.

Content-Type: text/plain; format=flowed

Hi there -

There might be a nicer way to do this, but I wanted to be able to
use Py_BuildValue to produce Unicode objects, so I added a few
lines to modsupport to do this.  Each Unicode object requires
two arguments, the raw Py_UNICODE string and the length as an
integer.  I think since all Python Unicode strings are 0 terminated,
it might be nice to make this into "U#" and also allow a plain "U"
to mean a (double) null-terminated Unicode string as input; however,
I'll leave that up to you all to determine (I would personally like
to see this option).

Brian Hooper

I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under
copyright, patent or other rights or interests ("claims").  To
the extent that I have any such claims, I hereby grant to CNRI a
nonexclusive, irrevocable, royalty-free, worldwide license to
reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part
of the Python software and its related documentation, or any
derivative versions thereof, at no cost to CNRI or its licensed
users, and to authorize others to do so.

I acknowledge that CNRI may, at its sole discretion, decide
whether or not to incorporate this contribution in the Python
software and its related documentation.  I further grant CNRI
permission to use my name and other identifying information
provided to CNRI by me for use in connection with the Python
software and its related documentation.
Get Your Private, Free Email at http://www.hotmail.com

Content-Type: text/plain; name="modsupport.diff.txt"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="modsupport.diff.txt"

diff -c Python/modsupport.c Python.new/modsupport.c
*** Python/modsupport.c Mon Apr 17 13:24:25 2000
--- Python.new/modsupport.c     Wed Apr 19 17:21:52 2000
*** 295,301 ****
                case 'L':
                        return PyLong_FromLongLong((LONG_LONG)va_arg(*p_va, 
                case 'f':
                case 'd':
                        return PyFloat_FromDouble(
--- 295,306 ----
                case 'L':
                        return PyLong_FromLongLong((LONG_LONG)va_arg(*p_va, 
!               case 'U':
!               {
!                       Py_UNICODE *u = va_arg(*p_va, Py_UNICODE *);
!                       int ulen = va_arg(*p_va, int);
!                       return PyUnicode_FromUnicode(u, ulen);
!               }
                case 'f':
                case 'd':
                        return PyFloat_FromDouble(