Describe the bug
pyfakefs filesystem methods that return paths always return them as str:
For example, this breaks the dulwich library, which uses bytes paths and expects to receive bytes paths back from filesystem methods:
>>> from pyfakefs.fake_filesystem_unittest import Patcher
>>> import dulwich.porcelain
>>> with Patcher():
... dulwich.porcelain.clone("https://github.com/pytest-dev/pyfakefs", "pyfakefs")
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/root/dulwich-pyfakefs/venv/lib/python3.11/site-packages/dulwich/porcelain.py", line 584, in clone
return client.clone(
^^^^^^^^^^^^^
File "/root/dulwich-pyfakefs/venv/lib/python3.11/site-packages/dulwich/client.py", line 874, in clone
result = self.fetch(
^^^^^^^^^^^
File "/root/dulwich-pyfakefs/venv/lib/python3.11/site-packages/dulwich/client.py", line 987, in fetch
target.get_graph_walker(),
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/dulwich-pyfakefs/venv/lib/python3.11/site-packages/dulwich/repo.py", line 633, in get_graph_walker
for sha in self.refs.as_dict(b"refs/heads").values()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/dulwich-pyfakefs/venv/lib/python3.11/site-packages/dulwich/refs.py", line 239, in as_dict
keys = self.keys(base)
^^^^^^^^^^^^^^^
File "/root/dulwich-pyfakefs/venv/lib/python3.11/site-packages/dulwich/refs.py", line 217, in keys
return self.subkeys(base)
^^^^^^^^^^^^^^^^^^
File "/root/dulwich-pyfakefs/venv/lib/python3.11/site-packages/dulwich/refs.py", line 633, in subkeys
dir = dir.strip(b"/")
^^^^^^^^^^^^^^^
TypeError: strip arg must be None or str
Describe the bug pyfakefs filesystem methods that return paths always return them as
str
:For example, this breaks the dulwich library, which uses
bytes
paths and expects to receivebytes
paths back from filesystem methods:How To Reproduce
Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.35 Python 3.11.0rc1 (main, Aug 12 2022, 10:02:14) [GCC 11.2.0] pyfakefs 5.8.dev0 pytest 8.3.3