On 15/9/23 03:19, cpbu...@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

_______________________________________________
pypy-dev mailing list -- pypy-dev@python.org
To unsubscribe send an email to pypy-dev-le...@python.org
https://mail.python.org/mailman3/lists/pypy-dev.python.org/
Member address: arch...@mail-archive.com

Reply via email to