Fix SerializingHTMLBuilder has been crashed if jinja2 helper functions are installed.

This commit is contained in:
Takeshi KOMIYA 2018-05-23 01:42:54 +09:00
parent 76acc4775a
commit 1013038b02

View File

@ -13,6 +13,7 @@ import codecs
import posixpath import posixpath
import re import re
import sys import sys
import types
import warnings import warnings
from hashlib import md5 from hashlib import md5
from os import path from os import path
@ -1410,6 +1411,11 @@ class SerializingHTMLBuilder(StandaloneHTMLBuilder):
# actually rendered # actually rendered
self.app.emit('html-page-context', pagename, templatename, ctx, event_arg) self.app.emit('html-page-context', pagename, templatename, ctx, event_arg)
# make context object serializable
for key in list(ctx):
if isinstance(ctx[key], types.FunctionType):
del ctx[key]
ensuredir(path.dirname(outfilename)) ensuredir(path.dirname(outfilename))
self.dump_context(ctx, outfilename) self.dump_context(ctx, outfilename)