[Python-Dev] Replacing PyWin32's PeekNamedPipe, ReadFile, and WriteFile

Amaury Forgeot d'Arc amauryfa at gmail.com
Wed Jul 22 17:33:35 CEST 2009


Hi,

2009/7/22 Eric Pruitt <eric.pruitt at gmail.com>:
> Hello,
>
> I have written replacements for a few of Mark Hammond's PyWin32 functions
> using ctypes to call upon the Windows kernel API. Code can be found here;
> http://pastebin.com/m46de01f . When calling ReadFile, it appears that the
> kernel API converts '/n' newlines '/r/n' newlines. I have not been able to
> find any information about this but as far as I can tell, there is nothing
> in my code that is causing the problem. Initially I suspected it related to
> newline translation but the function in subprocess.Popen for translating
> newlines only converts to '/n' newlines. When I replaced my ReadFile and
> WriteFile functions with the PyWin32 functions I was imitating, the problem
> still arose. I was hoping someone could confirm this problem for me from
> experience or by testing out my code. If you would like the see the
> functions used in full context, I have a Mercurial Google Code project that
> can be checked out at http://code.google.com/p/subprocdev/source/list
> (branch "python3k"). My work entails modifications to subprocess.py so when
> running the code, please update your PYTHONPATH variable so that my
> subprocess.py will be imported.

These questions should be redirected to comp.lang.python.

But as a quick response, the subprocess stdout is likely to be opened
in text mode.
So reading \r\n is not a surprise to me.

-- 
Amaury Forgeot d'Arc


More information about the Python-Dev mailing list