Re: [C++-sig] boost::python::str and Python's str and unicode types

2009-07-28 Thread Robert Smallshire

> On 07/23/2009 10:17 AM, Robert Smallshire wrote:
> > Hello,
> >
> > I'm looking for some confirmation that my understanding of what
> > boost.python is doing is correct.
> >
> > > From what I understand boost::python::str represents the str
> > (PyStringObject) type in Python.  Unless I'm missing
> something, here
> > doesn't seem to be anything like boost::python::unicode
> representing
> > the unicode type (PyUnicodeObject).
> >
> > Boost.Python does have a built-in conversion from std::wstring to
> > object, but this creates a str in Python, so presumably
> there is some
> > (lossy?) decoding going on here.
> >
> > It seems that to directly create a PyUnicodeObject from C++ I will
> > need to do one or more of the following:
> >
> > 1) Directly use the Python C API to create and manipulate
> > PyUnicodeObject.
> > 2) Create my own subclass of boost::python::object called
> for example
> > 'unicode', which would be similar to the str class provided
> out of the
> > box, but would use PyUnicodeObject underneath and deal with wchar_t
> > rather than char.

I have modified my local build of boost.python to include a
boost::python::unicode class, together with appropriate conversions from
wchar, const wchar_t* and std::wstring, together with additional tests
in the boost.python test suite.  As you would expect, the code is
closely derived from the existing boost::python::str code but uses the
Python C API for PyUnicode_Type rather than PyString_Type. There are no
breaking changes to the existing boost.python API.

I'd like to contribute these changes back to boost.python so they can be
hopefully integrated into future official Boost releases.  What is the
procedure for this?  Where do I start?

Cheers,

Robert Smallshire

DISCLAIMER:
This message contains information that may be privileged or confidential and is 
the property of the Roxar Group. It is intended only for the person to whom it 
is addressed. If you are not the intended recipient, you are not authorised to 
read, print, retain, copy, disseminate, distribute, or use this message or any 
part thereof. If you receive this message in error, please notify the sender 
immediately and delete all copies of this message.
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] boost::python::str and Python's str and unicode types

2009-07-28 Thread Thomas Berg
On Tue, Jul 28, 2009 at 4:11 PM, Robert
Smallshire wrote:
> I have modified my local build of boost.python to include a
> boost::python::unicode class, together with appropriate conversions from
> wchar, const wchar_t* and std::wstring, together with additional tests
> in the boost.python test suite.  As you would expect, the code is
> closely derived from the existing boost::python::str code but uses the
> Python C API for PyUnicode_Type rather than PyString_Type. There are no
> breaking changes to the existing boost.python API.
>
> I'd like to contribute these changes back to boost.python so they can be
> hopefully integrated into future official Boost releases.  What is the
> procedure for this?  Where do I start?
>
> Cheers,
>
> Robert Smallshire

Just a side note, I think Haoyu Bai is already adding unicode support
to boost.python in his GSoC project. His work should at least be
available through svn, according to his post from 4 weeks ago:
http://mail.python.org/pipermail/cplusplus-sig/2009-July/014664.html

Cheers,
Thomas Berg
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] boost::python::str and Python's str and unicode types

2009-07-28 Thread Ralf W. Grosse-Kunstleve
I'd be happy to help out, but I don't know if/how this could interfere with 
Haoyu Bai's work.
Could you post your patches to the trac system at svn.boost.org so we can have 
a look
and figure out a way forward?
Ralf




- Original Message 
From: Robert Smallshire 
To: Development of Python/C++ integration 
Sent: Tuesday, July 28, 2009 7:11:35 AM
Subject: Re: [C++-sig] boost::python::str and Python's str and unicode types


> On 07/23/2009 10:17 AM, Robert Smallshire wrote:
> > Hello,
> >
> > I'm looking for some confirmation that my understanding of what
> > boost.python is doing is correct.
> >
> > > From what I understand boost::python::str represents the str
> > (PyStringObject) type in Python.  Unless I'm missing
> something, here
> > doesn't seem to be anything like boost::python::unicode
> representing
> > the unicode type (PyUnicodeObject).
> >
> > Boost.Python does have a built-in conversion from std::wstring to
> > object, but this creates a str in Python, so presumably
> there is some
> > (lossy?) decoding going on here.
> >
> > It seems that to directly create a PyUnicodeObject from C++ I will
> > need to do one or more of the following:
> >
> > 1) Directly use the Python C API to create and manipulate
> > PyUnicodeObject.
> > 2) Create my own subclass of boost::python::object called
> for example
> > 'unicode', which would be similar to the str class provided
> out of the
> > box, but would use PyUnicodeObject underneath and deal with wchar_t
> > rather than char.

I have modified my local build of boost.python to include a
boost::python::unicode class, together with appropriate conversions from
wchar, const wchar_t* and std::wstring, together with additional tests
in the boost.python test suite.  As you would expect, the code is
closely derived from the existing boost::python::str code but uses the
Python C API for PyUnicode_Type rather than PyString_Type. There are no
breaking changes to the existing boost.python API.

I'd like to contribute these changes back to boost.python so they can be
hopefully integrated into future official Boost releases.  What is the
procedure for this?  Where do I start?

Cheers,

Robert Smallshire

___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] boost::python::str and Python's str and unicode types

2009-07-28 Thread Robert Smallshire
--- Begin Message ---
Hi Thomas,
 
Thanks for the remark. It looks like Bayou is working supporting unicode in 
Python 3.  I have implemented unicode support in Python 2.x which it what I, 
and I'm sure many others will be using for the forseeable future.
 
Rob



From: [email protected] on behalf of 
Thomas Berg
Sent: Tue 7/28/2009 17:43
To: Development of Python/C++ integration
Subject: Re: [C++-sig] boost::python::str and Python's str and unicode types



On Tue, Jul 28, 2009 at 4:11 PM, Robert
Smallshire wrote:
> I have modified my local build of boost.python to include a
> boost::python::unicode class, together with appropriate conversions from
> wchar, const wchar_t* and std::wstring, together with additional tests
> in the boost.python test suite.  As you would expect, the code is
> closely derived from the existing boost::python::str code but uses the
> Python C API for PyUnicode_Type rather than PyString_Type. There are no
> breaking changes to the existing boost.python API.
>
> I'd like to contribute these changes back to boost.python so they can be
> hopefully integrated into future official Boost releases.  What is the
> procedure for this?  Where do I start?
>
> Cheers,
>
> Robert Smallshire

Just a side note, I think Haoyu Bai is already adding unicode support
to boost.python in his GSoC project. His work should at least be
available through svn, according to his post from 4 weeks ago:
http://mail.python.org/pipermail/cplusplus-sig/2009-July/014664.html

Cheers,
Thomas Berg
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig


<>--- End Message ---
DISCLAIMER:
This message contains information that may be privileged or confidential and is 
the property of the Roxar Group. It is intended only for the person to whom it 
is addressed. If you are not the intended recipient, you are not authorised to 
read, print, retain, copy, disseminate, distribute, or use this message or any 
part thereof. If you receive this message in error, please notify the sender 
immediately and delete all copies of this message. ___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig