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

fix: wrap django 5 imports in try-except block #958

Conversation

mariajgrimaldi
Copy link
Contributor

Description

This PR wraps Django5 warning imports in try-except blocks to avoid failures in django3 that's still in use in edx-platform's master branch. For more info on the report see: https://openedx.slack.com/archives/CGE253B7V/p1702402901252609

@mariajgrimaldi mariajgrimaldi force-pushed the MJG/fix-django4-import-errors branch from 4dbc1cd to 6e5f75b Compare December 12, 2023 18:06
@mariajgrimaldi mariajgrimaldi changed the title fix: wrap django 4 imports in try-except block fix: wrap django 5 imports in try-except block Dec 12, 2023
warnings.filterwarnings("ignore", category=RemovedInDjango50Warning)
warnings.filterwarnings("ignore", category=RemovedInDjango51Warning)
try:
from django.utils.deprecation import RemovedInDjango50Warning, RemovedInDjango51Warning
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please just add a comment that includes the "REMOVE-AFTER-V18" string? and explain why this try/except was still needed in v17.

Copy link
Contributor

@regisb regisb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the very quick PR! This doesn't require a new release because it fixes the nightly branch (which will automatically get the fix). I'll merge as soon as you add the extra comment.

Comment on lines +157 to +158
except ImportError:
pass
Copy link
Collaborator

@kdmccormick kdmccormick Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
except ImportError:
pass
except ImportError:
# REMOVE-AFTER-V18:
# In Quince, edx-platform uses Django 5. But on master, edx-platform still uses Django 3.
# So, Tutor v17 needs to silence these warnings, whereas Tutor v17-nightly fails to import them.
# Once edx-platform master is upgraded to Django 5, the try-except wrapper can be removed.
pass

friendly edit -- just adding a REMOVE-AFTER comment

@kdmccormick
Copy link
Collaborator

Merged via aa01e30

Thanks for the fix @mariajgrimaldi !

@kdmccormick
Copy link
Collaborator

@regisb Oof, I just realized I merged this to nightly instead of master 🤦🏻

I guess that fine, though, since we don't need this change on master? Let me know if you'd rather I make the same change on master too, for consistency's sake.

@regisb
Copy link
Contributor

regisb commented Dec 19, 2023

That's fine, there is no need to backport if the feature is not strictly necessary. But next time, please rebase instead of adding a merge commit.

@kdmccormick
Copy link
Collaborator

Will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants