-
Notifications
You must be signed in to change notification settings - Fork 94
Closed
Labels
Description
Describe the bug
File descriptor returned by os.pipe() cannot be closed:
_, w = os.pipe()
os.close(w)
OSError: [Errno 9] Bad file descriptor in the fake filesystem: '12'How To Reproduce
Using pytest:
import os
def test_1(fs):
read, write = os.pipe()
os.close(write)Save above as test_foobar.py and run:
$ pytest -vvvv test_foobar.py
======================================================================================= test session starts =======================================================================================
platform linux -- Python 3.6.5, pytest-4.2.1, py-1.8.0, pluggy-0.9.0 -- /service/nox/test-3-6/bin/python3.6
cachedir: .pytest_cache
rootdir: /service, inifile:
plugins: requests-mock-1.5.2, cov-2.6.1, pyfakefs-3.5.8
collected 1 item
test_foobar.py::test_1 FAILED [100%]
============================================================================================ FAILURES =============================================================================================
_____________________________________________________________________________________________ test_1 ______________________________________________________________________________________________
fs = <pyfakefs.fake_filesystem.FakeFilesystem object at 0x7fa25d6431d0>
def test_1(fs):
read, write = os.pipe()
> os.close(write)
/service/test_foobar.py:4:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/service/nox/test-3-6/lib/python3.6/site-packages/pyfakefs/fake_filesystem.py:3700: in close
file_handle = self.filesystem.get_open_file(file_des)
/service/nox/test-3-6/lib/python3.6/site-packages/pyfakefs/fake_filesystem.py:1355: in get_open_file
self.raise_os_error(errno.EBADF, str(file_des))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pyfakefs.fake_filesystem.FakeFilesystem object at 0x7fa25d6431d0>, errno = 9, filename = '10', winerror = None
def raise_os_error(self, errno, filename=None, winerror=None):
"""Raises OSError.
The error message is constructed from the given error code and shall
start with the error string issued in the real system.
Note: this is not true under Windows if winerror is given - in this
case a localized message specific to winerror will be shown in the
real file system.
Args:
errno: A numeric error code from the C variable errno.
filename: The name of the affected file, if any.
winerror: Windows only - the specific Windows error code.
"""
message = self._error_message(errno)
if (winerror is not None and sys.platform == 'win32' and
self.is_windows_fs):
if IS_PY2:
raise WindowsError(winerror, message, filename)
raise OSError(errno, message, filename, winerror)
> raise OSError(errno, message, filename)
E OSError: [Errno 9] Bad file descriptor in the fake filesystem: '10'
/service/nox/test-3-6/lib/python3.6/site-packages/pyfakefs/fake_filesystem.py:976: OSError
==================================================================================== 1 failed in 0.71 seconds =====================================================================================
Please provide a unit test or a minimal code snippet that reproduces the
problem.
Your enviroment
Linux-4.20.13-200.fc29.x86_64-x86_64-with
Python 3.6.5 (default, Aug 22 2018, 14:30:18)
pyfakefs 3.5.8