0

I have a python 2.7 script that accesses a named pipe server through kernel32. Someone tried to reuse the script in python 3.5, with which I am unfamiliar.

The problem they are having, is that they are getting the error ERROR_PATH_NOT_FOUND when they attempt to connect to the named pipe server with OpenFile(). The file name string being passed to the OpenFile() is '\\.\pipe\PipeName.txt'

What changed between python 2.x and 3.x, that would make this string now result in an ERROR_PATH_NOT_FOUND error?

BigBobby
  • 423
  • 1
  • 3
  • 17
  • Shouldn't it be `\\.\pipe\PipeName.txt` not `\.\pipe\PipeName.txt`? – Dietrich Epp Feb 08 '17 at 16:16
  • It seems to be SO itself that turned my double \\ into a single \. I had to make it a quadruple \\\\ for it to show up as a double \\. – BigBobby Feb 08 '17 at 16:18
  • Hmm, but it didn't have a problem with the \ in my comment. Maybe it's in the quotes? Here is a test: '\\test\test.txt' = \\test\test.txt. OK, that's really odd. I don't understand why SO is removing \ in one place but not another. – BigBobby Feb 08 '17 at 16:20
  • OK, I doubled up on my \\ in the actual script and now it works in Python 3. In other words `'\\.\pipe\PipeName.txt'` became `\\\\.\\pipe\\PipeName.txt'` – BigBobby Feb 08 '17 at 17:13
  • 1
    The other alternative is to use `r'\\.\pipe\PipeName.txt'` — the `r` tells Python to keep the backslashes. – Dietrich Epp Feb 08 '17 at 18:37

0 Answers0