Re: FILE object in Python3.0 extension modules

2009-06-03 Thread Martin v. Löwis
The purpose is to dump the contents of a Python extension type to disk as binary data using C's fwrite() function. This isn't really possible anymore - the Python IO library has stopped using stdio. There are a couple of alternatives: 1. don't use fwrite(3) to write the binary data, but

FILE object in Python3.0 extension modules

2009-05-29 Thread Joachim Dahl
In Python2.x, I used PyFile_Check(obj) to check if a parameter was a file object. Now, in Python3.0 the same object (obtained as open('file.bin','wb')) is an io.BufferedWriter object. How do I perform type checking for such an object in the extension module, and how do I extract a FILE * object

Re: FILE object in Python3.0 extension modules

2009-05-29 Thread Benjamin Peterson
Joachim Dahl dahl.joachim at gmail.com writes: How do I perform type checking for such an object in the extension module, and how do I extract a FILE * object from it? I browsed the C API documentation, but couldn't find an answer. You use PyObject_IsInstance to test if the object is an

Re: FILE object in Python3.0 extension modules

2009-05-29 Thread Gabriel Genellina
En Fri, 29 May 2009 06:52:15 -0300, Joachim Dahl dahl.joac...@gmail.com escribió: In Python2.x, I used PyFile_Check(obj) to check if a parameter was a file object. Now, in Python3.0 the same object (obtained as open('file.bin','wb')) is an io.BufferedWriter object. How do I perform type

Re: FILE object in Python3.0 extension modules

2009-05-29 Thread Gabriel Genellina
En Fri, 29 May 2009 08:48:26 -0300, Benjamin Peterson benja...@python.org escribió: Joachim Dahl dahl.joachim at gmail.com writes: How do I perform type checking for such an object in the extension module, and how do I extract a FILE * object from it? I browsed the C API documentation,

Re: FILE object in Python3.0 extension modules

2009-05-29 Thread Gabriel Genellina
En Fri, 29 May 2009 23:24:32 -0300, Benjamin Peterson benja...@python.org escribió: Gabriel Genellina gagsl-py2 at yahoo.com.ar writes: But you have to import the io module first, don't you? That's not usually necesary for most built in types -- e.g. PyFloat_Check just checks for a float