sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

'str object' has no attribute 'filename'

Open jamtwister opened this issue 9 years ago • 16 comments

Subject: When calling 'make html' at my project following exception is raised: jinja2.exceptions.UndefinedError: 'str object' has no attribute 'filename'

Problem

Everything worked fine with version 1.5.5, now I upgraded to version 1.6.1. The error occures when sphinx starts to write output.

Exception occurred: File "c:\python35\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'

Procedure to reproduce the problem

make html I am looking for a short example to reproduce this problem.

Error logs / results

sphinx-err-ud4rphou.txt

Expected results

build html should work

Reproducible project / your project

sorry it is a private project of my company, so I cannot provide a link

Environment info

  • OS: Win7 and Lubuntu 17.04
  • Python version: 3.5.3
  • Sphinx version: 1.6.1

jamtwister avatar May 19 '17 17:05 jamtwister

This is also breaking builds in runestone, if that helps.

DaveParillo avatar May 19 '17 19:05 DaveParillo

Sorry for inconvenience. BTW, what theme do you use? This might be related with additional css file. So I'd like to know it.

Thanks,

tk0miya avatar May 21 '17 13:05 tk0miya

I'd reproduced with runestone.

This is a minimal reproducible templates:

{%- extends "basic/layout.html" %}
{% set css_files = ['_static/test.css'] + css_files %}

tk0miya avatar May 21 '17 13:05 tk0miya

Fixed at c8d049b. Thank you for reporting

tk0miya avatar May 21 '17 13:05 tk0miya

When I install the latest version of Sphinx 1.6.2 . I still get the same error

if to.startswith(SEP): jinja2.exceptions.UndefinedError: 'str object' has no attribute 'filename'

To install Sphinx I used this command "pip install -U sphinx"

VikramShetty avatar Jun 02 '17 08:06 VikramShetty

@VikramShetty Please file a new issue please. I need to know your case in detail. It would be nice if you can share some reproducible project to us Thanks,

tk0miya avatar Jun 02 '17 15:06 tk0miya

I created another issue @ https://github.com/sphinx-doc/sphinx/issues/3847 . I have also attached reproducible project.

VikramShetty avatar Jun 02 '17 16:06 VikramShetty

@tk0miya : it seems that c8d049b doesn't commit the actual fix, just the note in the CHANGES

willysr avatar Jun 03 '17 06:06 willysr

oops... you're right. The bug fix code is in my git-stash... I just commited again as a347b0b.

Thank you for notation!

tk0miya avatar Jun 03 '17 07:06 tk0miya

No problem. Can I install the latest version now? Or Should I wait once the build is ready?

VikramShetty avatar Jun 03 '17 07:06 VikramShetty

It is not released yet. so please try from our repos.

$ pip install git+https://github.com/sphinx-doc/sphinx

tk0miya avatar Jun 03 '17 07:06 tk0miya

Thanks a lot I will do that, On top of it I will also have to fix my template code mentioned here https://github.com/sphinx-doc/sphinx/issues/3847#issuecomment-305839637

VikramShetty avatar Jun 03 '17 08:06 VikramShetty

This still isn't consistent with the old behaviour -- pre-1.6 added rel="stylesheet" to the <link> tag, whereas the new str fallback does not, so the resulting stylesheet isn't actually being used in the browser.

Terrance avatar Jun 09 '17 09:06 Terrance

@OllieTerrance Oh, I'd missed it. Thanks, Could you try the current HEAD again?

tk0miya avatar Jun 10 '17 02:06 tk0miya

Yes, that works great. 🙂

Terrance avatar Jun 10 '17 08:06 Terrance

We have the same problem. With your github repo it works great!

teleyinex avatar Jun 23 '17 14:06 teleyinex