ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> C++-sig
C++-sig
[C++-sig] Re: class data members
by David Abrahams other posts by this author
Aug 18 2003 8:24PM messages near this date
[C++-sig] Re: Some patches to make the "Automatic PyUnicode to 'const char*'" possible, and make __stdcall function bindable | (Fwd) Re: [C++-sig] Re: Twas a bug in MSVC7.1
"Sam Bloomquist" <sam@[...].com>  writes:

>  I have an update to the question I posted earlier, shown below.  It turns
>  out that my crash only happens when the string I am trying to set is longer
>  than 15 characters.  Anyone have any guesses where the 15 character limit
>  came from?
> 
>  I am currently working on moving an application from visual studio 6.0 to
>  visual studio .net 2003 and boost 1.29.0 to boost 1.30.0 and am having a few
>  problems with class data members.  My c++ struct and python wrapper are as
>  follows:
> 
>  struct JunkObject
>  {
>  	bool operator == (JunkObject& jo);
>  	std::string m_sName;
>  	int m_iID;
>  };
> 
>  class_<JunkObject>("JunkObject")
>  	.def_readwrite("name", &JunkObject::m_sName)
>  	.def_readwrite("id", &JunkObject::m_iID);
> 
>  # Then in python when I do this...
> 
>  obj = plus.JunkObject()
>  obj.id = 5
> 
>  # where "plus" is my boost python module, everthing is fine.  But if I do...
> 
>  obj.name = "Bob went for a walk in the park."
> 
>  # my program crashes.  Does anyone see something I'm missing?  This worked
>  fine in msvs 6.0 and boost 1.29.

Sam,

Your example (well, if I fill in the missing details like
BOOST_PYTHON_MODULE, etc.) works fine with the current Boost CVS and
MSVC 6.5 for me.  I bet you haven't really reduced this to a minimal
example, have you?  I'm fairly certain you'll find your bug if you do
that.  The Jamfile I used to test it was:

-------
subproject libs/python/user ;

# bring in the rules for python
SEARCH on python.jam = $(BOOST_BUILD_PATH) ;
include python.jam ;

extension foo_ext : foo.cpp <include> ../../.. ;
boost-python-runtest foo : foo.py <pyd> foo_ext ;
------

I placed it in a subdirectory "user" of $BOOST_ROOT/libs/python along
with the enclosed:
Attachments:
unknown1
unknown2
unknown3
unknown4

Thread:
Sam Bloomquist
David Abrahams

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved