From: Alberchou <tun...@ho...> - 2012-05-22 16:55:37
|
Well, I have modified my C++ function just to try if it works only with an "int" parameter --- function(int param); It doesn't give me the same error that I've told before but it crashes while executing this: # In python rutaResultado = Ejecutor.ejecutarBusqueda(cNumVehiculos) ejecutarBusqueda(int) is the function at C++. It gives me the following error: Assertion failed: (_flags & F_lock_count) != 0 at line 68 of c:\buildslave\release_sdk_win32\build\panda3d\built\include\mutexSimpleImpl.I And a windows message: "python.exe stopped working" with these details: Problem name: APPCRASH Application name: python.exe Module name with errors: ntdll.dll Version of the module with errors: 6.1.7600.16915 Exception code: c0000005 My python version is 2.6.5 and I'm running it with Panda3D libraries for programing 3D games. Please, I need urgent help, I'm wasting too much time with this :(. Thank you so much! Bob Hood wrote: > > On 5/21/2012 5:34 AM, Alberchou wrote: >> Hi everybody, >> >> I have a problem. At C++ I have this: string ejecutarBusqueda(int >> cantidad, >> string vehiculos); >> >> When I try to execute that C++ method from Python, it throws this error >> message: >> >> File "C:\Panda3D-1.7.2\samples\PFC\Interfaz.py", line 185, in >> resolverTablero >> rutaResultado = Ejecutor.ejecutarBusqueda(cNumVehiculos, cVehiculos) >> TypeError: in method 'ejecutarBusqueda', argument 2 of type 'string' >> >> I don't understand why it throws this error when I'm calling C++ method >> with >> (int, string) parameters... >> >> Could you tell me what happens? > > Just guessing, but perhaps you need to convert between an incoming Python > string and your target type of std::string? Something like: > > %typemap(in) std::string > { > if(PyString_Check($input)) > $1 = PyString_AsString($input); > else > SWIG_exception_fail(SWIG_TypeError, "string expected"); > } > > Or there may be helpers in the SWIG library (e.g., "%include > <std_string.i>") > that could do the job for you if you don't want to roll your own typemaps. > > > Render me gone, ||| > Bob ^(===)^ > ---------------------------------oOO--(_)--OOo--------------------------------- > I'm not so good with advice...can I interest you in a sarcastic > comment? > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user > > -- View this message in context: http://old.nabble.com/TypeError-Python-%3C-%3E-C%2B%2B-tp33882112p33890592.html Sent from the swig-user mailing list archive at Nabble.com. |