Re: [C++-sig] strange behavior with respect to numeric and Boolean overloads

2009-03-17 Thread Hans Meine
On Monday 16 March 2009 22:52:16 Ralf W. Grosse-Kunstleve wrote: > [...] Boost.Python 2 was written when the Python bool type still really > was an int (Python 2.2). [...] On Tuesday 17 March 2009 06:40:14 Roman Yakovenko wrote: > Python code: > > def foo( arg ): > if isinstance( arg, int ): >

Re: [C++-sig] strange behavior with respect to numeric and Booleanoverloads

2009-03-17 Thread Matthew Scouten (TT)
isinstance( True, int ) returns True However, the code def foo( arg ): if isinstance( arg, bool ): _foo_bool( arg ) else: _foo_other( arg ) Would work in theory. I could do this. I'm just annoyed that BP is not doing it for me. -Original Message- From:

Re: [C++-sig] strange behavior with respect to numeric and Booleanoverloads

2009-03-17 Thread troy d. straszheim
I have a quasi-fix for this to the library itself, (see diff below) buuut it breaks a certain case: if you have a wrapped c++ function that takes a bool, and you try to pass it an int, you get a ArgumentError: Python argument types in builtin_converters_ext.rewrap_const_reference_b

[C++-sig] Some thoughts on py3k support

2009-03-17 Thread Haoyu Bai
Hi, Here is some thoughts on GSoC Boost.Python py3k support project. First thing come into my mind is the build system. For Python 3, we would have a separate build target, eg. having libboost_python.so built for Python 2.x and libboost_python3.so for Python 3. This would match the current situat

Re: [C++-sig] [boost] [Python] GSoC and Python 3.0 Support

2009-03-17 Thread Haoyu Bai
On Sat, Mar 14, 2009 at 9:29 PM, Stefan Seefeld wrote: > David Abrahams wrote: >> >> On Mar 14, 2009, at 4:28 AM, Niall Douglas wrote: >> >>> >>> Would it make sense if Dave acted as second as in "person we fall >>> back upon if the primaries can't figure it out?" >> >> That would make plenty of s

Re: [C++-sig] Some thoughts on py3k support

2009-03-17 Thread Matthew Scouten (TT)
A thought on this bytes vs. strings: I am not sure if others do the same thing, but: There are a number of places where the underlying library that we are wrapping has a char* or a char[] that can be either a null terminated string or an arbitrary bag of bytes depending on context. The fact that

[C++-sig] Smart pointer, polymorphism issue

2009-03-17 Thread Kamal Mansouri
Hello, I have created a Python wrapper using a custom smart pointer that is defined in the following manner: class_>("Event", init<>()) .def("f", &Event::f, &EventWrapper::default_f). implicitely_convertible, Ptr>(); register_ptr_to_python>(); Now... when I subclass this in Python

Re: [C++-sig] Some thoughts on py3k support

2009-03-17 Thread Rene Rivera
Matthew Scouten (TT) wrote: I can work with whatever you come up with, but it might convenient if a char* or char[] was treated as a bytes object and a std::string was treated as a string. Thoughts? A char* can never be fully treated as a bytes object. You must mean a char* plus a size_t (or