diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py
index 99b6fb9..22836e8 100644
--- a/sphinxcontrib/serializinghtml/__init__.py
+++ b/sphinxcontrib/serializinghtml/__init__.py
@@ -63,6 +63,11 @@ def get_target_uri(self, docname: str, typ: str | None = None) -> str:
return docname + SEP
def dump_context(self, context: dict, filename: str | os.PathLike[str]) -> None:
+ context = context.copy()
+ if 'css_files' in context:
+ context['css_files'] = [css.filename for css in context['css_files']]
+ if 'script_files' in context:
+ context['script_files'] = [js.filename for js in context['script_files']]
if self.implementation_dumps_unicode:
with open(filename, 'w', encoding='utf-8') as ft:
self.implementation.dump(context, ft, *self.additional_dump_args)