httpx icon indicating copy to clipboard operation
httpx copied to clipboard

Fix compatibility with Python 3.14

Open medaminezghal opened this issue 4 months ago • 12 comments

I think this line from pyproject.toml should be changed from "httpcore==1.*", to "httpcore>=1.0.8", to make sure that it doesn't give problem when import it.

The import problem has been fixed by this commit in version 1.0.8.

medaminezghal avatar Aug 30 '25 21:08 medaminezghal

See also https://github.com/encode/httpx/discussions/3616

carlwgeorge avatar Sep 04 '25 03:09 carlwgeorge

Tested without success in:

  • #3645

cclauss avatar Sep 17 '25 11:09 cclauss

See also:

  • https://github.com/encode/httpcore/issues/1043

ilovelinux avatar Oct 08 '25 09:10 ilovelinux

Apparently this has already been fixed. You just need to upgrade the httpcore library to v1.0.8+

See https://github.com/encode/httpcore/issues/1043#issuecomment-3380758277

ilovelinux avatar Oct 08 '25 10:10 ilovelinux

Still lingers in both

  • #3645
  • #3664

https://github.com/encode/httpx/actions/runs/17672966050/job/50228530025#step:4:68 line 67

cclauss avatar Oct 08 '25 10:10 cclauss

Can't replicate:

[user@hostname tst]$ uv venv -p 3.14
Using CPython 3.14.0rc3 interpreter at: /home/user/.local/bin/python3.14
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
[user@hostname tst]$ source .venv/bin/activate
(tst) [user@hostname tst]$ uv pip install httpx
Resolved 7 packages in 9ms
Installed 7 packages in 13ms
 + anyio==4.11.0
 + certifi==2025.10.5
 + h11==0.16.0
 + httpcore==1.0.9
 + httpx==0.28.1
 + idna==3.10
 + sniffio==1.3.1
(tst) [user@hostname tst]$ python
Python 3.14.0rc3 (main, Sep 18 2025, 19:47:22) [Clang 20.1.4 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import httpx
>>> 

https://github.com/encode/httpx/actions/runs/17672966050/job/50228530025#step:4:68 line 67

It's installing a version that supports Python 3.14. I can't see what's the problem. The job has been cancelled, no errors

ilovelinux avatar Oct 08 '25 10:10 ilovelinux

@ilovelinux Because the version of httpcore is greater than 1.0.8.

medaminezghal avatar Oct 08 '25 10:10 medaminezghal

@ilovelinux uv python install # --> python3..14.0

cclauss avatar Oct 08 '25 10:10 cclauss

@ilovelinux Because the version of httpcore is greater than 1.0.8.

Yes, and it is downloaded by default.

I'm not sure pinning the libraries' version with support to the latest Python release is a good practice since it could affect support to older Python versions.

E.g. if I'm using Python 3.10 I can still upgrade httpx without upgrading httpcore. If we pin httpcore to 1.0.8, I couldnt.

AFAIK version pinning should be used for compatibility among libraries, not with Python releases.

If you think I'm wrong, I'm curious about some use-cases or some documentation about this practice 🙁

@ilovelinux uv python install # --> python3..14.0

? You can see from the output that it's Python 3.14

ilovelinux avatar Oct 08 '25 11:10 ilovelinux

I saw

[user@hostname tst]$ uv venv -p 3.14 Using CPython 3.14.0rc3 interpreter at: /home/user/.local/bin/python3.14

cclauss avatar Oct 08 '25 11:10 cclauss

@ilovelinux httpcore in its latest version should be compatible with python 3.8 and above. Why you can't install httpx when you pin httpcore version?

medaminezghal avatar Oct 08 '25 11:10 medaminezghal

  • #3645

tests/test_timeouts.py

@pytest.mark.xfail(sys.version_info >= (3, 14), reason="Fix trio on Python >= 3.14")
async def test_write_timeout(server):

cclauss avatar Oct 08 '25 12:10 cclauss