As part of refactoring, I have been converting my application from using os.path to pathlib.
However, it appears that jinja2 is incompatible with paths created using pathlib.Path.
For example, if tdir is a pathlib Path object, the following generates an error:
jinja_environment = Environment(loader=FileSystemLoader(tdir), trim_blocks=False, lstrip_blocks=True),
where the bottom of the error traceback is
jinja_environment = Environment(loader=FileSystemLoader(tdir),
File ".../python/anaconda3/lib/python3.6/site-packages/jinja2/loaders.py", line 163, in __init__
self.searchpath = list(searchpath)
TypeError: 'PosixPath' object is not iterable
If I convert tdir to a string, things work fine.
jinja: v 2.10
python: v3.6.5
As part of refactoring, I have been converting my application from using
os.pathtopathlib.However, it appears that
jinja2is incompatible with paths created usingpathlib.Path.For example, if
tdiris apathlibPath object, the following generates an error:jinja_environment = Environment(loader=FileSystemLoader(tdir), trim_blocks=False, lstrip_blocks=True),where the bottom of the error traceback is
If I convert
tdirto a string, things work fine.jinja: v 2.10
python: v3.6.5