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

Python 3.11 test failure #1158

Closed
bcail opened this issue Nov 22, 2022 · 3 comments · Fixed by #1168
Closed

Python 3.11 test failure #1158

bcail opened this issue Nov 22, 2022 · 3 comments · Fixed by #1168
Assignees

Comments

@bcail
Copy link
Contributor

bcail commented Nov 22, 2022

I'm seeing OfflineCompressTestCaseWithLazyStringAlikeUrls test failures under Python 3.11. Bisecting the Python 3.11 branch showed that the python/cpython@76cd81d commit introduced the issue.

I tried commenting out the @functools.lru_cache(typed=True) line from the urlsplit function in the Python 3.11 branch, and that seemed to fix the test. Does there need to be a clear_cache() call, or some other way to deal with the urlsplit cache in Python 3.11?

@diox
Copy link
Member

diox commented Jan 6, 2023

I was able to reproduce in #1168, I'll take a look.

@diox
Copy link
Member

diox commented Jan 6, 2023

So, this problem is because of our support for lazy STATIC_URL / COMPRESS_URL introduced in #876. Indeed a couple clear_cache() calls in tests fixes the problem, but I'm not sure it's a good idea... it will likely fail in real life with such lazy settings - they are passed by something (haven't bothered to look what yet) to urlsplit while still being lazy, so it caches the call with the lazy function... We can maybe find a workaround, but I'm not even sure this works correctly with Django alone today with Python 3.11.

@diox
Copy link
Member

diox commented Jan 6, 2023

Figured out a fix for the tests in eb1a728

I still think this is dangerous, things can easily break depending on implementation of the lazy wrapper, but given that the fix is trivial we can keep this in compressor for now.

@diox diox closed this as completed in #1168 Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants