Comments (6)
As a quick fix, I added width = margin_container.width
to the finally block -- this seems to squelch the error and cause the image to be rendered. If the image is oversize for the page it simply overflows the right-hand side; I'm not sure whether or not that is the expected behavior.
Note that when the width is not set (in the .rst source) on this oversize image, it causes runaway creation of excess pages. So I suspect that this fix is not appropriate, but it will do for my purposes for now.
I'm not familiar enough with the inner workings of rinohtype to say much more, but hopefully this is helpful.
from rinohtype.
@brechtm Fantastic, thanks for the quick response. I'll switch over to the stable branch. Great project; really enjoying it so far!
from rinohtype.
This bug is no longer present in the current master branch.
from rinohtype.
@brechtm I beg to differ.
With rinohtype==0.3.1.dev0 (installed from f1cca5b)
# Sphinx version: 1.6.3
# Python version: 3.6.1 (CPython)
# Docutils version: 0.13.1 release
# Jinja2 version: 2.9.6
# Last messages:
# quality_requirements
#
# risks_and_technical_debt
#
#
#
# resolving references...
#
# rendering...
#
# Loaded extensions:
# alabaster (0.7.10) from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/alabaster/__init__.py
# sphinx.ext.todo (1.6.3) from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/ext/todo.py
# sphinx.ext.autodoc (1.6.3) from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/ext/autodoc.py
# sphinx.ext.autosummary (1.6.3) from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/ext/autosummary/__init__.py
# sphinx.ext.intersphinx (1.6.3) from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/ext/intersphinx.py
# sphinx.ext.mathjax (1.6.3) from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/ext/mathjax.py
# sphinx.ext.viewcode (1.6.3) from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/ext/viewcode.py
# sphinx.ext.graphviz (1.6.3) from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/ext/graphviz.py
# rinoh.frontend.sphinx (unknown version) from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/frontend/sphinx/__init__.py
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/image.py", line 192, in render
container.advance(h, ignore_overflow)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/layout.py", line 265, in advance
raise ContainerOverflow(self.page.number)
rinoh.layout.ContainerOverflow: 17
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 154, in flow
raise eoc
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 149, in flow
state=state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 186, in flow_inner
self.render(pad_cntnr, descender, state=state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/image.py", line 194, in render
raise EndOfContainer(state)
rinoh.layout.EndOfContainer: <rinoh.image.ImageState object at 0x10b529048>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/cmdline.py", line 306, in main
app.build(opts.force_all, filenames)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/application.py", line 333, in build
self.builder.build_all()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 288, in build_all
self.build(None, summary='all source files', method='all')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 397, in build
self.write(docnames, list(updated_docnames), method)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/frontend/sphinx/__init__.py", line 220, in write
targetname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/frontend/sphinx/__init__.py", line 242, in write_doc
rinoh_document.render(outfilename)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/document.py", line 428, in render
self.part_page_counts = self._render_pages()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/document.py", line 492, in _render_pages
part_page_count += part.render(part_page_count.count + 1)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/document.py", line 228, in render
page.render()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/document.py", line 159, in render
super().render(CONTENT, rerender=index > 0)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/layout.py", line 185, in render
child.render(type, rerender)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/layout.py", line 185, in render
child.render(type, rerender)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/layout.py", line 273, in render
self._render(type, rerender)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/layout.py", line 327, in _render
self.chain.render(self, rerender=rerender)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/layout.py", line 616, in render
self._state.flowable_state)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 149, in flow
state=state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 186, in flow_inner
self.render(pad_cntnr, descender, state=state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 392, in render
**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 416, in _flow_with_next
state=state.first_flowable_state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 149, in flow
state=state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 186, in flow_inner
self.render(pad_cntnr, descender, state=state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 392, in render
**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 416, in _flow_with_next
state=state.first_flowable_state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 149, in flow
state=state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 186, in flow_inner
self.render(pad_cntnr, descender, state=state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 392, in render
**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 416, in _flow_with_next
state=state.first_flowable_state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 791, in flow
return super().flow(container, last_descender, state)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 149, in flow
state=state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 186, in flow_inner
self.render(pad_cntnr, descender, state=state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 392, in render
**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 416, in _flow_with_next
state=state.first_flowable_state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 755, in flow
**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 149, in flow
state=state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 186, in flow_inner
self.render(pad_cntnr, descender, state=state, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 318, in render
flowable.flow(maybe_container, last_descender)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 715, in flow
super().flow(align_container, last_descender, state)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rinoh/flowable.py", line 159, in flow
0, 0, width, height)
UnboundLocalError: local variable 'width' referenced before assignment
Indeed, width
is not set in the except block, but is referenced in the finally block.
Note: I take this bug to be specifically about the UnboundLocalError
-- the question of why ContainerOverflow
is being raised on a well-formed sources is another (separate) interesting question.
from rinohtype.
This is in fact a different but similar bug. But I'm still grateful for the detailed report. Thanks @erickpeirson!
Development is taking place on the stable branch, (I need to clean up) so you might want to check with the latest version. If it still crashes (looks like it will), can you share the Sphinx project with me so I can see exactly what is going on?
Note: I take this bug to be specifically about the UnboundLocalError -- the question of why ContainerOverflow is being raised on a well-formed sources is another (separate) interesting question.
It is normal for ContainerOverflow
to be raised. This is just how things are handled every time an item (Flowable
) cannot fit on the current container/page and we need to move to the next.
As a quick fix, I added width = margin_container.width to the finally block -- this seems to squelch the error and cause the image to be rendered. If the image is oversize for the page it simply overflows the right-hand side; I'm not sure whether or not that is the expected behavior.
In the stable branch, oversized images are downsized automatically to fit in the available width.
Note that when the width is not set (in the .rst source) on this oversize image, it causes runaway creation of excess pages. So I suspect that this fix is not appropriate, but it will do for my purposes for now.
This will probably still happen when the image is too tall to fit on the page. Or it could be that this is being handled now. I can't remember...
from rinohtype.
It's not clear whether this bug still exists since the Flowable code has changed significantly. Please create a new issue when you run into an UnboundLocalError.
from rinohtype.
Related Issues (20)
- How do I add a rear page to my pdf? HOT 25
- Part of image missing.... HOT 3
- More indexing woes... HOT 11
- Incorrect entry in footer HOT 1
- Hyphenated word at bottom of page merged
- TypeError: Can't instantiate abstract class DynamicRinohDistribution with... HOT 12
- How do you use a custom template? HOT 1
- Support for reST raw:: HOT 1
- Add ability to print alternative text instead of error message for rst :image: directive HOT 1
- Table cause endless loop 'item too long to fit on line (page N)' HOT 6
- KeyError: 'desc_sig_space' HOT 3
- Zero width spaces lead to an attribute error
- The first word on a line is never hyphenated HOT 3
- Another: NotImplementedError: None:None the 'desc_sig_space' node is not yet supported (rinoh.frontend.sphinx.nodes) HOT 9
- Hyphenating a word across two pages concatenates the word part to the next one HOT 2
- Rinohtype crashes when processing a heading-only / empty body table HOT 2
- Improve error message for unsupported nodes HOT 4
- Repetition of words when using the fallback font
- References not resolved correctly for orphan pages HOT 2
- add hungarian language HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rinohtype.