Skip to content

Test failures with Python 3.13.0b1 in 4.4.0 #737

Closed

Description

@musicinmybrain

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.

Activity

  1. agronholm commented on May 27, 2024

    @agronholm
    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.

  2. musicinmybrain commented on May 27, 2024

    @musicinmybrain
    ContributorAuthor

    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.

  3. added a commit that references this issue on May 27, 2024
    8a4d651
  4. agronholm commented on May 27, 2024

    @agronholm
    Owner

    Would you mind checking against #740?

  5. musicinmybrain commented on May 28, 2024

    @musicinmybrain
    ContributorAuthor

    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.

  6. added a commit that references this issue on May 28, 2024
    0558fbb
  7. added a commit that references this issue on Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions