iustin / pyxattr

A python module for accessing filesystem Extended Attributes
https://pyxattr.k1024.org/
GNU Lesser General Public License v2.1
30 stars 15 forks source link

PyPy3.10: `xattr.getxattr()` does not accept `pathlib.Path` whereas it works on CPython #41

Closed mgorny closed 7 months ago

mgorny commented 9 months ago
$ pypy3.10 -c 'import pathlib, xattr; xattr.getxattr(pathlib.Path("/"), "user.test")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: Can't convert 'PosixPath' object to str implicitly
# but
$ python3.10 -c 'import pathlib, xattr; xattr.getxattr(pathlib.Path("/"), "user.test")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
OSError: [Errno 61] No data available

I think the line in question is:

https://github.com/iustin/pyxattr/blob/1d0427598f3f3b310a118b1acd5f7b19eab1517b/xattr.c#L439

I suppose CPython implicitly converts pathlib.Path to a string, whereas PyPy throws an error.

CC @mattip

mgorny commented 9 months ago

Oh, sorry, I was looking at the wrong argument. It's probably https://foss.heptapod.net/pypy/pypy/-/issues/3168; i.e. PyUnicode_FSConverter not handling Path objects.

mattip commented 9 months ago

Could you change CI to use pypy-3.10-nightly, pypy-3.9-nightly and ping me on CI failures? https://github.com/iustin/pyxattr/blob/1d0427598f3f3b310a118b1acd5f7b19eab1517b/.github/workflows/ci.yml#L35-L37

mattip commented 9 months ago

I added handling for Path objects to latest nightlies.

iustin commented 9 months ago

I've switch to pypy-3.9-nightly and 3.10-nightly. The run passed: https://github.com/iustin/pyxattr/actions/runs/6982967019.

jabbalaci commented 7 months ago

You can always convert a Path object to string with str(Path(...)) and you are done.

mattip commented 7 months ago

@iustin you may want to switch back to the last stable release which contains the fix I mentioned above, since using nightlies may be noisy (no guarantee they work all the time)

iustin commented 7 months ago

@iustin you may want to switch back to the last stable release which contains the fix I mentioned above, since using nightlies may be noisy (no guarantee they work all the time)

I was actually going to ask about that, since I had to disable 3.10-nightly yesterday.

Is there a canonical list of the stable releases?

mattip commented 7 months ago

There are a few :)

The list of released downloads as a json file (consumed by the python setup github action) is here, and the downloads themselves are here

The changelogs are here, and you can see the fix for this issue in the version-specific changelog.

iustin commented 7 months ago

I've re-enabled pypy-3.10, and moved 3.9 from nightly to well, no nightly.

However, it's still not clear to me how to read the list of releases. E.g. from this snippet:

  {
    "pypy_version": "7.3.15",
    "python_version": "3.9.18",
    "stable": true,
    "latest_pypy": true,
    "date": "2024-01-15",
  …

How do you get to a valid python-version: pypy-3.9? Maybe more to the point, how can I subscribe and know when new stable versions are released? Is there a `pypy-latest' but stable?

iustin commented 7 months ago

I've enabled PathLib tests under pypy 3.10, which means it now runs all tests that CPython does. I'll mark this issue closed, now. Thanks all!

mattip commented 7 months ago

how can I subscribe and know when new stable versions are released

You can get notified of changes to the download site via something like https://visualping.io/

iustin commented 7 months ago

Well, yes, thanks, but I was hoping that there would be something built-in to GitHub actions marketplace, or similar. All good, I can periodically check myself.