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

Revert "Cleanup Python 3.8 leftovers (#17967)" to fix Synapse in RHEL9 #18193

Closed
wants to merge 1 commit into from

Conversation

OlegGirko
Copy link
Contributor

@OlegGirko OlegGirko commented Feb 27, 2025

This reverts commit 068e22b.

Reverted commit breaks Synapse on Red Hat Enterprise Linux 9 (Alma Linux 9, Rocky Linux 9. Oracle Linux 9).
Multiple tests fail with TypeError deep inside Pydantic because issubclass(Literal, Tuple) complains that Literal is not a class.

Reverting the commit mentioned above fixes the issue.

RHEL9 has Python 3.9.21 and Pydantic 1.10.2.

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct
    (run the linters)

@OlegGirko OlegGirko requested a review from a team as a code owner February 27, 2025 17:10
@CLAassistant
Copy link

CLAassistant commented Feb 27, 2025

CLA assistant check
All committers have signed the CLA.

…se in RHEL9

This reverts commit 068e22b.

Reverted commit breaks Synapse on Red Hat Enterprise Linux 9
(Alma Linux 9, Rocky Linux 9. Oracle Linux 9).
Multiple tests fail with TypeError deep inside Pydantic because
issubclass(Literal, Tuple) complains that Literal is not a class.

Reverting the commit mentioned above fixes the issue.

RHEL9 has Python 3.9.21 and Pydantic 1.10.2.

Signed-off-by: Oleg Girko <[email protected]>
@erikjohnston
Copy link
Member

Relevant bit of the stack trace:

  File "synapse/rest/client/directory.py", line 151, in ClientDirectoryListServer
    class PutBody(RequestBodyModel):
  File "/usr/lib/python3.9/site-packages/pydantic/main.py", line 198, in __new__
    fields[ann_name] = ModelField.infer(
  File "/usr/lib/python3.9/site-packages/pydantic/fields.py", line 506, in infer
    return cls(
  File "/usr/lib/python3.9/site-packages/pydantic/fields.py", line 436, in __init__
    self.prepare()
  File "/usr/lib/python3.9/site-packages/pydantic/fields.py", line 552, in prepare
    self._type_analysis()
  File "/usr/lib/python3.9/site-packages/pydantic/fields.py", line 669, in _type_analysis
    elif issubclass(origin, Tuple):  # type: ignore
  File "/usr/lib64/python3.9/typing.py", line 853, in __subclasscheck__
    return issubclass(cls, self.__origin__)
builtins.TypeError: issubclass() arg 1 must be a class

Looks like this is pydantic/pydantic#6027, which was fixed in pydantic 1.10.8.

Not entirely clear to me what in this commit actually triggers the breakage above, possibly the move from typing_extensions.Literal to typing.Literal

@OlegGirko
Copy link
Contributor Author

Looks like this is pydantic/pydantic#6027, which was fixed in pydantic 1.10.8.

@erikjohnston: Thank you very much for clarification.

Using updated Pydantic from Fedora EPEL 9 fixed the problem. Despite disabling building Pydantic in my OBS in favour of the package in Fedora EPEL 9, I still had outdated package built long time ago lurking there, and this was the root cause of the issue.

Closing this PR because it was caused by an outdated Pydantic package in my setup, not RHEL 9.

Sorry for wasting your time.

@OlegGirko OlegGirko closed this Feb 28, 2025
@OlegGirko OlegGirko deleted the fix_rhel9 branch February 28, 2025 18:30
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 this pull request may close these issues.

3 participants