Extension C module
Jay Love
jslove at mindspring.com
Mon Mar 6 22:20:54 EST 2000
More information about the Python-list mailing list
Mon Mar 6 22:20:54 EST 2000
- Previous message (by thread): Cookies and Python
- Next message (by thread): Extension C module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
vmarkwart at my-deja.com wrote: > Hi, > A couple of strange things. The extension module I'm (attempting) to > write (Borland's C++ Builder 4) has a couple of little flaws. > > When I include > Py_INCREF(Py_None); > return Py_None; > in a procedure which returns no value, it compiles correctly but > returns a memory exception error when imported and run, and crashes > Python (not a happy sight). When I leave those lines out and return an > empty string the function can be called happily from Python, but > returns an unloved, unwanted empty string. Any ideas on what I'm doing > wrong.? > > Also, I have another function which returns a dictionary of values, eg > >>> import pytools > >>> pytools.volumeInfo("f:\\") > {'filenameUnicode': 'supported', 'filenameMaxLength': '255', > 'volumeName': 'SYS', 'filenameCase': 'preserved', 'volumeCompression': > 'compressed', 'filenameCompression': 'supported', 'volumeSerialNumber': > '1628725518', 'filesystemName': 'NWFS', 'filenameCaseSensitivity': > 'caseSensitive', 'filesystemACLs': 'supported'} > > In interactive mode everything looks fine, but when run in a script it > comes back with the error: > Traceback (innermost last): > File "", line 1, in ? File "pytoolstest.py", line 32, in ? vinfo = > pytools.volumeInfo(drive) TypeError: argument 1: expected string without > null bytes, string found Any clues as to where to start looking? I've > commented out virtually everything in the function, and I still get the > error. If anyone wants the sourcecode, please email me at > vmarkwart at hotmail.com Cheers Victor Sent via Deja.com > http://www.deja.com/ Before you buy. > I'm working through the same problem right now. Same situation, when I call Py_INCREF(Py_None), it segfaults. I'm using Borland C++ 5.02 and Borland Builder 3. Same deal with both compilers. I started writing my main extension module without realizing this problem, so I started a new module with just one test function. After much trial and error, I got the test function to run without segfaulting, but I can't figure out what magical set of compiler switches did it. One thing I did was use the standard python import library, but run COFF2OMF on it, to convert from MSVC format to Borland format. After that I set something in the Builder setup that got it to work on the test extension, but I can't get it going on my real extension. I suspect it was the library change that did it, but I'm not sure. Anybody out there who can help? Jay Love
- Previous message (by thread): Cookies and Python
- Next message (by thread): Extension C module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list