From 530248d4662c7c15c42d082dbfef378a471da428 Mon Sep 17 00:00:00 2001 From: Agrendalath Date: Fri, 26 May 2023 21:01:43 +0200 Subject: [PATCH] fix: do not use the `runtime.replace_urls` when the runtime is not ready This happens while generating the Block Structures. --- problem_builder/__init__.py | 2 +- problem_builder/mixins.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/problem_builder/__init__.py b/problem_builder/__init__.py index b2e51c32..36887081 100644 --- a/problem_builder/__init__.py +++ b/problem_builder/__init__.py @@ -1 +1 @@ -__version__ = "5.1.2" +__version__ = "5.1.3" diff --git a/problem_builder/mixins.py b/problem_builder/mixins.py index 166b9d07..f6729735 100644 --- a/problem_builder/mixins.py +++ b/problem_builder/mixins.py @@ -295,8 +295,8 @@ def expand_static_url(self, text): if not text: return text - if hasattr(self.runtime, 'replace_urls'): - text = self.runtime.replace_urls(text) + if replace_urls := getattr(self.runtime, 'replace_urls', None): + text = replace_urls(text) elif hasattr(self.runtime, 'course_id'): # edX Studio uses a different runtime for 'studio_view' than 'student_view', # and the 'studio_view' runtime doesn't provide the replace_urls API.