Skip to content

Commit

Permalink
Merge pull request #11897 from rtibbles/markdown_markedoff
Browse files Browse the repository at this point in the history
Set markdown to None in module cache to prevent it being imported by DRF.
  • Loading branch information
marcellamaki authored Feb 19, 2024
2 parents 142dcfb + d96bc00 commit 96c528b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions kolibri/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ def check_python_versions():
warn(warning_text, DeprecationWarning)


def monkey_patch_markdown():
"""
Monkey patch markdown module into module cache to set to None.
This is to avoid a bug caused by newer versions of markdown that causes
a crash during the attempted optional import of markdown in DRF.
"""
# TODO: rtibbles remove this once we upgrade to a newer version of Django REST Framework
# that doesn't have this issue.
sys.modules["markdown"] = None


def set_env():
"""
Sets the Kolibri environment for the CLI or other application worker
Expand All @@ -114,6 +125,8 @@ def set_env():
"""
check_python_versions()

monkey_patch_markdown()

from kolibri import dist as kolibri_dist # noqa

monkey_patch_collections()
Expand Down

0 comments on commit 96c528b

Please sign in to comment.