Improve symlink support for DirEntry on Windows

Hi PyPy devs, In one of my projects I noticed tests involving symlinked directories on Windows failing on PyPy 3.9/10 (v7.3.12), but succeeding on CPython 3.9/10. After digging into `pypy/module/posix/interp_scandir.py`, it looks like `W_DirEntry` has an incomplete implementation for Windows. The `W_DirEntry.is_*()` methods only return results for the symlink (the *follow_symlinks* argument is ignored via `.check_mode()`). The `W_DirEntry.stat()` method only returns the `stat_result` for the target file (ignoring the *follow_symlinks* via `.get_stat_or_lstat()`). I have a proof of concept fixing the Windows implementation based upon the adjacent POSIX code. It passes the previously skipped tests `test_stat4`, and `test_dir3-6` in `pypy/module/posix/test/test_scandir.py`. My modification to `test_scandir.py` is kind of janky to support Python 2.7 on Windows because it doesn't natively support `os.symlink()`. The test uses `pypy.module.posix.interp_posix.symlink` when `os.symlink` is unavailable. I'm not sure how to run `test_scandir.py` after compiling/translationing, and what other tests I should be running. I can successfully compile these modifications on the py3.10 branch on Windows 10 and Linux (Manjaro, an Arch Linux derivative). The Contributing Guidelines recommends that I start with the mailing list before making a random merge request. What's the next step in possibly getting this fix reviewed? Regards, Caleb Burns

On 15/9/23 03:19, cpburnz@gmail.com wrote:
Hi PyPy devs,
In one of my projects I noticed tests involving symlinked directories on Windows failing on PyPy 3.9/10 (v7.3.12), but succeeding on CPython 3.9/10. After digging into `pypy/module/posix/interp_scandir.py`, it looks like `W_DirEntry` has an incomplete implementation for Windows. The `W_DirEntry.is_*()` methods only return results for the symlink (the *follow_symlinks* argument is ignored via `.check_mode()`). The `W_DirEntry.stat()` method only returns the `stat_result` for the target file (ignoring the *follow_symlinks* via `.get_stat_or_lstat()`).
I have a proof of concept fixing the Windows implementation based upon the adjacent POSIX code. It passes the previously skipped tests `test_stat4`, and `test_dir3-6` in `pypy/module/posix/test/test_scandir.py`. My modification to `test_scandir.py` is kind of janky to support Python 2.7 on Windows because it doesn't natively support `os.symlink()`. The test uses `pypy.module.posix.interp_posix.symlink` when `os.symlink` is unavailable.
I'm not sure how to run `test_scandir.py` after compiling/translationing, and what other tests I should be running. I can successfully compile these modifications on the py3.10 branch on Windows 10 and Linux (Manjaro, an Arch Linux derivative).
The Contributing Guidelines recommends that I start with the mailing list before making a random merge request. What's the next step in possibly getting this fix reviewed?
Regards, Caleb Burns
Thanks for picking this up. You are welcome to push a branch to https://foss.heptapod.net/pypy/pypy. If you have not yet been granted permissions, you can register and request them at https://foss.heptapod.net/pypy/pypy/-/project_members. We have a number of pytest extensions to be able to run tests both pre- and post- translation. In order to run the current tests post-translation, you can run with -A python2 pytest.py -A --python=<path-to-pypy3.9-c> pypy\module\posix\test\test_scandir.py For extra points, we are trying to move tests to the newer apptest syntax. For an example, see apptest_posix.py. Then the translated tests can be run directly with pypy3 (or with CPython) <path-to-python3> pytest.py -D pypy\module\posix\test\apptest_scandir.py Matti

I have an account on foss.heptapod.net, @cpburnz, but how do I request access? I don't see an option on the Project members page to request permissions. On that page, it says: "Members can be added by project Maintainers or Owners". Thanks, I try those pytest.py methods.

On 22/9/23 04:19, cpburnz@gmail.com wrote:
I have an account on foss.heptapod.net, @cpburnz, but how do I request access? I don't see an option on the Project members page to request permissions. On that page, it says: "Members can be added by project Maintainers or Owners".
Thanks, I try those pytest.py methods.
I sent you an invite. Matti

I've just sent you an invite. Cheers, CF On 22/09/2023 03:19, cpburnz@gmail.com wrote:
I have an account on foss.heptapod.net, @cpburnz, but how do I request access? I don't see an option on the Project members page to request permissions. On that page, it says: "Members can be added by project Maintainers or Owners".
Thanks, I try those pytest.py methods. _______________________________________________ pypy-dev mailing list -- pypy-dev@python.org To unsubscribe send an email to pypy-dev-leave@python.org https://mail.python.org/mailman3/lists/pypy-dev.python.org/ Member address: cfbolz@gmx.de
participants (3)
-
CF Bolz-Tereick
-
cpburnz@gmail.com
-
Matti Picus