-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing mock of os.dup
#970
Comments
I remember having done something about that some time ago, but obviously didn't finish it... |
Hm, that would also be true for |
@vector-of-bool - this was the last of your issues so far. I will wait with a release at least until you have retested with the current version. |
Thanks! I'll test things out. |
Describe the bug
The
os.dup
function is not implemented bypyfakefs
, and defers to the underlyingdup
. This can cause the pyfakefs file numbers to be given to the realdup
syscall, leading to unexpected behavior.How To Reproduce
The fileno returned by the patched
os.open
will be given to the built-inos.dup
, which may or may not generate an error depending on whetherfd1
is coincidentally equal to a real file descriptor. The call toos.read(fd2)
will likely fail since the patchedos.read
will be given a fileno that wasn't created bypyfakefs
.Your environment
Please run the following in the environment where the problem happened and
paste the output.
This one may be trickier to solve since
os.dup
is also useful with non-filesystem file descriptors. i.e. it would be bad ifpyfakefs
brokeos.dup
for sockets and pipes. Distinguishing between a socket fileno and a fakefs fileno may require separating the domain of integers used by the fake os module.The text was updated successfully, but these errors were encountered: