Improper handling of bytes/str in split and join throws TypeError with subprocess.call() #856
Replies: 4 comments
-
You are right - there may be quite some places where this is not supported correctly, as the initial implementation has been done in Python 2, and the Python 3 support is not complete. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, I cannot reproduce this concrete problem on my Windows machine, as this happens in the posix-specific part of subprocess, but I will look at it tomorrow anyway, if I find the time. |
Beta Was this translation helpful? Give feedback.
-
Ok, just looked into this - I did not get it right yesterday (was a little tired). Unfortunately, you seem to be out of luck here. There are indeed some str/byte issues that we may fix (I will have a look at these later), but the actual excecution code calls OS functionality that cannot be changed to use the fake file system, as far as I can see. Sorry for that... |
Beta Was this translation helpful? Give feedback.
-
Bummer. Thanks for looking into this. |
Beta Was this translation helpful? Give feedback.
-
I'm using pyfakefs with some test cases that involve spinning up subprocesses, but unfortunately, the subprocess library doesn't appear to be supported yet, because of path resolution for the executables.
This may be harder than it looks, but on a cursory glance it seems that the only hangup is that os.path functions like split and join support both
bytes
andstr
to be passed as arguments, and return the corresponding type. The subprocess library internally calls os functions withbytes
arguments, but this causes a TypeError becauseos.path.split()
and the like in pyfakefs only support strings.Here's a minimal example:
Running this throws:
subprocess would be a great additional library to add to the stable of standard libs that work with pyfakefs.
Beta Was this translation helpful? Give feedback.
All reactions