[Python-Dev] ParseTuple question

Mark Hammond skippy.hammond at gmail.com
Sun Jan 4 11:42:49 CET 2009

On 4/01/2009 9:29 PM, Ulrich Eckhardt wrote:
>> If I'm still misunderstanding, can you be more specific about the exact
>> problem (ie, the exact function you are referring to, and how you intend
>> calling it)?
> trunk/_fileio.c/fileio_init()
> Let's leave aside that you can also pass a filedescriptor, that function
> either takes a string or a Unicode string as first parameter. Now, under CE,
> I always need a 'wchar_t*' in order to open a file, how would I get at that
> easiest?
> My approach now is to simply use "O" as format specifier for the filename and
> then take a look at the object's type. If it is a char-string, I have to
> convert (under CE) or call the char-API (desktop MS Windows), if it is a
> Unicode string, I can use it as it is.

IIUC, the block:

		if (widename != NULL)
			self->fd = _wopen(widename, flags, 0666);
			self->fd = open(name, flags, 0666);

Would probably need to change - instead of falling back to plain open(), 
if widename is NULL you would need to use MultiByteToWideChar before 
calling _wopen().  This assumes the unicode CRT is available of course - 
if not, I guess you'd need to call the win32 api instead of _wopen. 
Alternatively, the PyArg_ParseTuple() call could possibly be changed to 
use the 'e' format string

Hoping-that-was-what-you-were-asking, ly,


More information about the Python-Dev mailing list