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

Test failures with Python 3.13.0b1 in 4.4.0 #737

Closed
2 tasks done
musicinmybrain opened this issue May 27, 2024 · 4 comments · Fixed by #740
Closed
2 tasks done

Test failures with Python 3.13.0b1 in 4.4.0 #737

musicinmybrain opened this issue May 27, 2024 · 4 comments · Fixed by #740
Labels
bug Something isn't working

Comments

@musicinmybrain
Copy link
Contributor

Things to check first

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

AnyIO version

4.4.0

Python version

3.13.0b1

What happened?

______________________________________________________________________________________ TestPath.test_properties[asyncio] _______________________________________________________________________________________
tests/test_fileio.py:103: in test_properties
    assert not missing
E   AssertionError: assert not {'from_uri', 'full_match', 'parser'}
___________________________________________________________________________________ TestPath.test_properties[asyncio+uvloop] ___________________________________________________________________________________
tests/test_fileio.py:103: in test_properties
    assert not missing
E   AssertionError: assert not {'from_uri', 'full_match', 'parser'}
________________________________________________________________________________________ TestPath.test_properties[trio] ________________________________________________________________________________________
tests/test_fileio.py:103: in test_properties
    assert not missing
E   AssertionError: assert not {'from_uri', 'full_match', 'parser'}
__________________________________________________________________________________________ TestPath.test_is_reserved ___________________________________________________________________________________________
tests/test_fileio.py:274: in test_is_reserved
    assert Path("nul").is_reserved() == expected_result
src/anyio/_core/_fileio.py:445: in is_reserved
    return self._path.is_reserved()  
/usr/lib64/python3.13/pathlib/_local.py:423: in is_reserved
    warnings.warn(msg, DeprecationWarning, stacklevel=2)
E   DeprecationWarning: pathlib.PurePath.is_reserved() is deprecated and scheduled for removal in Python 3.15. Use os.path.isreserved() to detect reserved paths on Windows.

I expected these four tests to pass, as they do on Python 3.12.

How can we reproduce the bug?

$ gh repo clone agroholm/anyio
$ cd anyio
$ python3.13 --version
Python 3.13.0b1
$ python3.13 -m venv _e
$ . _e/bin/activate

Before proceeding further, we need to build uvloop ourselves, since the released sdist doesn’t build on Python 3.13 and there are no binary wheels on PyPI for Python 3.13 yet. Furthermore, we need to patch it for Cython 3 as proposed in MagicStack/uvloop#587. This reflects how uvloop is packaged in Fedora.

(_e) $ cd ..
(_e) $ gh repo clone MagicStack/uvloop
(_e) $ cd uvloop
(_e) $ git submodule update --init --recursive
(_e) $ git remote add alan-brooks https://github.com/alan-brooks/uvloop.git
(_e) $ git fetch --all
(_e) $ git branch cython3
(_e) $ git checkout cython3
(_e) $ git merge alan-brooks/cython3_update
(_e) $ sed -r -i 's/(Cython\(>=.*,<)(.*)(\))/\14\3/' pyproject.toml
(_e) $ git add pyproject.toml
(_e) $ git commit -m 'Allow Cython 3'
(_e) $ pip install .

Furthermore, to avoid errors about undefined symbol: _PyErr_WriteUnraisableMsg, we need cffi to contain python-cffi/cffi@49127c6. The easiest way is to manually install 1.17.0rc1.

(_e) $ pip install cffi==1.17.0rc1

Now we can continue:

(_e) $ cd ../anyio
(_e) $ pip install -e .[test]
(_e) $ python -m pytest
=========================================================================================== short test summary info ============================================================================================
SKIPPED [1] tests/test_debugging.py:102: Generator based coroutines have been removed in Python 3.11
SKIPPED [1] tests/test_fileio.py:135: Drive only makes sense on Windows
SKIPPED [1] tests/test_fileio.py:177: Only makes sense on Windows
SKIPPED [3] tests/test_fileio.py:366: os.lchmod() is not available
SKIPPED [1] tests/test_taskgroups.py:964: Generator based coroutines have been removed in Python 3.11
SKIPPED [1] tests/test_taskgroups.py:985: Generator based coroutines have been removed in Python 3.11
XFAIL tests/test_from_thread.py::TestBlockingPortal::test_from_async[trio-trio] - reason: known bug (#525)
XFAIL tests/test_subprocesses.py::test_process_aexit_cancellation_closes_standard_streams[asyncio] - #671 needs to be resolved first
XFAIL tests/test_subprocesses.py::test_process_aexit_cancellation_closes_standard_streams[asyncio+uvloop] - #671 needs to be resolved first
XFAIL tests/test_taskgroups.py::test_fail_after_scope_cancelled_before_timeout[asyncio] - There is currently no way to tell if cancellation happened due to timeout explicitly if the deadline has been exceeded
XFAIL tests/test_taskgroups.py::test_fail_after_scope_cancelled_before_timeout[asyncio+uvloop] - There is currently no way to tell if cancellation happened due to timeout explicitly if the deadline has been exceeded
XFAIL tests/test_taskgroups.py::test_fail_after_scope_cancelled_before_timeout[trio] - There is currently no way to tell if cancellation happened due to timeout explicitly if the deadline has been exceeded
============================================================================ 55 failed, 1379 passed, 8 skipped, 6 xfailed in 36.48s ============================================================================

I’m not as worried about the failures in tests/test_sockets.py due to socket.gaierror: [Errno -2] Name or service not known – we run tests offline in Fedora, so we don’t see these, and these reproduce in Python 3.12 – but failures in tests/test_fileio.py appear to be real regressions in Python 3.13.

@musicinmybrain musicinmybrain added the bug Something isn't working label May 27, 2024
@agronholm
Copy link
Owner

Due to the challenges you mentioned, I haven't taken any serious steps towards Python 3.13 compatibility. That said, the failures don't look serious, as they just indicate that new methods/properties in pathlib.Path are not yet mirrored by anyio.Path.

@musicinmybrain
Copy link
Contributor Author

Thanks. That makes sense. I think it’s reasonable for me to skip test_properties on Python 3.13 until you have a chance to implement from_uri, full_match, and parser.

For TestPath.test_is_reserved, I can offer a PR to expect the DeprecationWarning about pathlib.PurePath.is_reserved() on Python 3.13 and later.

@agronholm
Copy link
Owner

agronholm commented May 27, 2024

Would you mind checking against #740?

@musicinmybrain
Copy link
Contributor Author

I tested #740 in the same virtualenv, and it fixed all of the regressions in tests/test_fileio.py. As far as I could tell, the test results were the same as Python 3.12.

I also tried it as a patch in Fedora, and that built with tests passing in our Python 3.13 test environment.

So that PR looks great to me! Thanks for looking into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants