Skip to content
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

shutil.copystat raises AttributeError when used on symlinks #799

Closed
henniss opened this issue Mar 31, 2023 · 4 comments · Fixed by #801
Closed

shutil.copystat raises AttributeError when used on symlinks #799

henniss opened this issue Mar 31, 2023 · 4 comments · Fixed by #801
Labels

Comments

@henniss
Copy link

henniss commented Mar 31, 2023

Describe the bug
shutil.copystat(s,d,follow_symlink=False) raises AttributeError while patched with fake_filesystem_unittest and when both s, d are symlinks. This looks to be related to http://github.com/pytest-dev/pyfakefs/issues/533

Traceback (most recent call last):
  File "/usr/local/google/home/henniss/github/pyfakefs/pyfakefs/tests/fake_filesystem_shutil_test.py", line 241, in test_copystat_symlinks
    shutil.copystat(sym1, sym2, follow_symlinks=False)
  File "/usr/lib/python3.10/shutil.py", line 373, in copystat
    mode = stat.S_IMODE(st.st_mode)
AttributeError: 'NoneType' object has no attribute 'st_mode'

How To Reproduce
I'm including a PR which adds a (failing) test: http://github.com/pytest-dev/pyfakefs/pull/800

Your environment

python -c "import sys; print('Python', sys.version)"
python -c "from pyfakefs.fake_filesystem import __version__; print('pyfakefs', __version__)"
python -c "import pytest; print('pytest', pytest.__version__)"
Linux-5.19.11-1rodete1-amd64-x86_64-with-glibc2.36
Python 3.10.9 (main, Dec  7 2022, 13:47:07) [GCC 12.2.0]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name '__version__' from 'pyfakefs.fake_filesystem' (/usr/local/google/home/henniss/github/pyfakefs/pyfakefs/fake_filesystem.py)
pytest 7.2.2

(n.b. this fails at head, Import error above notwithstanding).

@mrbean-bremen
Copy link
Member

Thanks, I will have a look!

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Apr 2, 2023
- return the faked functions instead of the real ones
- fixes pytest-dev#799
mrbean-bremen added a commit that referenced this issue Apr 3, 2023
- return the faked functions instead of the real ones
- fixes #799
@mrbean-bremen
Copy link
Member

Shall be fixed in main now, please check!

@henniss
Copy link
Author

henniss commented Apr 6, 2023

LGTM, thanks for the quick fix!

@mrbean-bremen
Copy link
Member

It is now in the latest released version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants