to.startswith(SEP): jinja2.exceptions.UndefinedError: 'str object' has no attribute 'filename'
ReproducibleProject.zip Subject: Exception occurred: File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\util\osutil.py", line 61, in relative_uri if to.startswith(SEP): jinja2.exceptions.UndefinedError: 'str object' has no attribute 'filename' The full traceback has been saved in C:\Users\vikra\AppData\Local\Temp\sphinx-err-c0nov5h0.log, if you want to report the issue to the developers.
Problem
- I just have above sentence to explain.
Procedure to reproduce the problem
make html
Error logs / results
# Sphinx version: 1.6.2
# Python version: 3.6.1 (CPython)
# Docutils version: 0.14rc1 prerelease
# Jinja2 version: 2.9.6
# Last messages:
# checking consistency...
#
# done
#
# preparing documents...
#
# done
#
# writing output... [100%] Index
#
# Loaded extensions:
# alabaster (0.7.10) from c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\alabaster-0.7.10-py3.6.egg\alabaster\__init__.py
# sphinx.ext.autodoc (1.6.2) from c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\ext\autodoc.py
# sphinx.ext.doctest (1.6.2) from c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\ext\doctest.py
# sphinx.ext.intersphinx (1.6.2) from c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\ext\intersphinx.py
# sphinx.ext.todo (1.6.2) from c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\ext\todo.py
# sphinx.ext.coverage (1.6.2) from c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\ext\coverage.py
# sphinx.ext.imgmath (1.6.2) from c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\ext\imgmath.py
# sphinx.ext.ifconfig (1.6.2) from c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\ext\ifconfig.py
# sphinx.ext.viewcode (1.6.2) from c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\ext\viewcode.py
Traceback (most recent call last):
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\cmdline.py", line 306, in main
app.build(opts.force_all, filenames)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\application.py", line 339, in build
self.builder.build_update()
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\builders\__init__.py", line 328, in build_update
'out of date' % len(to_build))
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\builders\__init__.py", line 394, in build
self.write(docnames, list(updated_docnames), method)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\builders\__init__.py", line 431, in write
self._write_serial(sorted(docnames))
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\builders\__init__.py", line 440, in _write_serial
self.write_doc(docname, doctree)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\builders\html.py", line 561, in write_doc
self.handle_page(docname, ctx, event_arg=doctree)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\builders\html.py", line 945, in handle_page
output = self.templates.render(templatename, ctx)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\jinja2glue.py", line 176, in render
return self.environment.get_template(template).render(context)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\jinja2-2.9.6-py3.6.egg\jinja2\asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\jinja2-2.9.6-py3.6.egg\jinja2\environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\jinja2-2.9.6-py3.6.egg\jinja2\environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\jinja2-2.9.6-py3.6.egg\jinja2\_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\themes\basic\page.html", line 10, in top-level template code
{%- extends "layout.html" %}
File "D:\ReproducibleProject\_templates\layout.html", line 5, in top-level template code
{% set css_files = css_files + ['_static/table.css'] %}
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\themes\bizstyle\layout.html", line 12, in top-level template code
{% set script_files = script_files + ["_static/bizstyle.js"] %}
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\themes\bizstyle\..\basic/layout.html", line 128, in top-level template code
{%- block csss %}
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\themes\bizstyle\..\basic/layout.html", line 129, in block "csss"
{{ css() }}
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\jinja2-2.9.6-py3.6.egg\jinja2\sandbox.py", line 427, in call
return __context.call(__obj, *args, **kwargs)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\jinja2-2.9.6-py3.6.egg\jinja2\runtime.py", line 553, in _invoke
rv = self._func(*arguments)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\themes\bizstyle\..\basic/layout.html", line 109, in template
<link rel="{{ css.rel }}" href="{{ pathto(css.filename, 1) }}" type="text/css"{% if css.title is not none %} title="{{ css.title }}"{% endif %} />
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\jinja2-2.9.6-py3.6.egg\jinja2\sandbox.py", line 427, in call
return __context.call(__obj, *args, **kwargs)
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\builders\html.py", line 917, in pathto
uri = relative_uri(baseuri, otheruri) or '#'
File "c:\users\vikra\appdata\local\programs\python\python36\lib\site-packages\sphinx\util\osutil.py", line 61, in relative_uri
if to.startswith(SEP):
jinja2.exceptions.UndefinedError: 'str object' has no attribute 'filename'
[ReproducibleProject.zip](https://github.com/sphinx-doc/sphinx/files/1048229/ReproducibleProject.zip)
Expected results
I just updated my latest Sphinx version and executed make html.
Reproducible project / your project
- Find the attached project you can use it. The error also work, Ignore all warning because those files I have removed.
Environment info
- OS: Windows 10
- Python version: 3.6.1
- Sphinx version: 1.6.2
- <Extra tools e.g.: Browser, tex or something else>
Thank you for reporting.
it comes from the following setting. Since 1.6, the form of css_files are changed. I'll take a look.
html_context = {
'css_files': ['_static/table.css'],
'css_files': ['_static/custom.css'],
}
Note: As a workaround, you can add custom stylesheets through template. In your _templates/layout.html, table.css is added like following.
{# layout.html #}
{# Import the theme's layout. #}
{% extends "!layout.html" %}
{% set css_files = css_files + ['_static/table.css'] %}
@tk0miya : I think a347b0bb9869326622e8b695fb0f4c7e06e58d82 fixed this issue already and it's already merged to master.
Yes, I will close this after @VikramShetty's confirmation.
It seems this is already resolved. So I close this now. Thanks,