Skip to content

Commit 5c96401

Browse files
committed
fix: throw exception if field is None on scope_mappings
1 parent e0df689 commit 5c96401

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

xblock/field_data.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
simple.
66
"""
77
import copy
8-
98
from abc import ABCMeta, abstractmethod
109
from collections import defaultdict
1110

@@ -148,7 +147,12 @@ def _field_data(self, block, name):
148147
if scope not in self._scope_mappings:
149148
raise InvalidScopeError(scope)
150149

151-
return self._scope_mappings[scope]
150+
scope_mapping = self._scope_mappings[scope]
151+
152+
if scope_mapping is None:
153+
raise InvalidScopeError(scope)
154+
155+
return scope_mapping
152156

153157
def get(self, block, name):
154158
return self._field_data(block, name).get(block, name)
@@ -161,8 +165,10 @@ def set_many(self, block, update_dict):
161165
for key, value in update_dict.items():
162166
update_dicts[self._field_data(block, key)][key] = value
163167
for field_data, new_update_dict in update_dicts.items():
164-
if field_data is not None: # Ignore fields from scopes that are not loaded
168+
try:
165169
field_data.set_many(block, new_update_dict)
170+
except InvalidScopeError:
171+
pass # Ignore fields that are not in the scope_mappings
166172

167173
def delete(self, block, name):
168174
self._field_data(block, name).delete(block, name)

0 commit comments

Comments
 (0)