Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rinohtype does not work with python >= 3.7.0 #133

Closed
forkedjensh opened this issue Aug 10, 2018 · 9 comments
Closed

rinohtype does not work with python >= 3.7.0 #133

forkedjensh opened this issue Aug 10, 2018 · 9 comments

Comments

@forkedjensh
Copy link

forkedjensh commented Aug 10, 2018

I try to use rinohtype 0.3.1 with python3.7 (on MacOS 10.13.6) and I am not able to create a document from any rst file.

I guess this is due to PEP479 being strictly implemented in python3.7. Therefore StopIteration is handled as a RuntimeError and this breaks the document creation with the exceptionRuntimeError: generator raised StopIteration during the document tree build.

I would be very happy if anyone can help me with this issue.

Kind regards
Jens

Full Traceback:

$ rinoh document.rst
ERROR:root:Error during import of compiled filters!
ERROR:root:No module named 'png.pngfilters'
ERROR:root:Fallback to pure python mode!
Using the reStructuredText frontend [built-in]
rinohtype 0.3.1 (2016-12-19)  Copyright (c) Brecht Machiels
This program comes with ABSOLUTELY NO WARRANTY. Its use is subject
to the terms of the GNU Affero General Public License version 3.
Traceback (most recent call last):
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/util.py", line 119, in function_wrapper
    return cache[args_kwargs]
KeyError: ('hide', DownExpandingContainer('title'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/util.py", line 119, in function_wrapper
    return cache[args_kwargs]
KeyError: (DownExpandingContainer('title'),)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/style.py", line 374, in styled_and_parents
    raise NoMoreParentElement
rinoh.style.NoMoreParentElement

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/user/env/documentation/bin/rinoh", line 11, in <module>
    sys.exit(main())
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/tool.py", line 268, in main
    document.render(input_root)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/document.py", line 432, in render
    self.part_page_counts = self._render_pages()
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/document.py", line 496, in _render_pages
    part_page_count += part.render(part_page_count.count + 1)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/document.py", line 229, in render
    page.render()
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/document.py", line 160, in render
    super().render(CONTENT, rerender=index > 0)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/layout.py", line 185, in render
    child.render(type, rerender)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/layout.py", line 273, in render
    self._render(type, rerender)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/layout.py", line 302, in _render
    _, _, last_descender = flowable.flow(self, last_descender)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/flowable.py", line 132, in flow
    if self.get_style('hide', container):
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/util.py", line 121, in function_wrapper
    cache_value = function(obj, *args, **kwargs)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/style.py", line 525, in get_style
    return self.get_style_recursive(attribute, flowable_target)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/style.py", line 560, in get_style_recursive
    style = self._style(flowable_target)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/util.py", line 121, in function_wrapper
    cache_value = function(obj, *args, **kwargs)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/style.py", line 582, in _style
    return container.document.stylesheet.find_style(self, container)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/style.py", line 766, in find_style
    key=attrgetter('specificity'), reverse=True)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/style.py", line 761, in find_matches
    for match in self.base.find_matches(styled, container):
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/style.py", line 758, in find_matches
    for match in self.matcher.match(styled, container):
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/style.py", line 653, in match
    specificity = selector.match(styled, container)
  File "/Users/user/env/documentation/lib/python3.7/site-packages/rinoh/style.py", line 381, in match
    element = next(elements)                # NoMoreParentElement
RuntimeError: generator raised StopIteration
@cadu-leite
Copy link

same here. Nothing works !

@forkedjensh
Copy link
Author

#134 is a pull request which tries to solve the RuntimeError. I am not sure, if it breaks anything else. Document creation works.

Any help is welcome.

@forkedjensh
Copy link
Author

forkedjensh commented Sep 10, 2018

@brechtm Is rinohtype dead?

Imo the failing tests have nothing to do with the PR.

@forkedjensh forkedjensh changed the title PEP 479 StopIteration rinohtype does not work with python >= 3.7.0 Sep 10, 2018
@brechtm
Copy link
Owner

brechtm commented Sep 10, 2018

Sorry for the late reply. No, rinohtype is not dead. I just don't have the time to work on it at the moment. I'm not sure when I can spend some time on it again. It will definitely not be before I'm back from vacation around mid October.

For now, I recommend you run the master version with your patch applied (thanks for the PR!). The master branch is quite a bit ahead of the last release anyway.

@oz123
Copy link

oz123 commented Oct 15, 2018

@brechtm can you please release a new version on PyPI?

@sambrilleman
Copy link

Is anyone able to update the situation here? Is rinohtype no longer maintained?

@brechtm
Copy link
Owner

brechtm commented Oct 29, 2019

@sambrilleman Let's say it's in a sort of hibernation. It is not one of my priorities at this moment. However, I'll try to make a release of the current master branch in the near future.

@sambrilleman
Copy link

Ok great, no worries! Best of luck with whatever other endeavours you are undertaking! Cheers.

@normanlorrain
Copy link
Contributor

I'd be interested in helping with this project. I've set up a development environment with VSCode, and an venv containing Python 3.8.1. I get initialization errors on startup:

Looks like something has changed in the loading of the fonts (tokenization, etc.). The font weight ("medium") is tokenized, but the type isn't the expected ENDMARKER. It's NEWLINE.

Exception has occurred: ParseError
Syntax error
  File "D:\github\rinohtype\src\rinoh\attribute.py", line 51, in parse_string
    raise ParseError('Syntax error')
  File "D:\github\rinohtype\src\rinoh\attribute.py", line 42, in from_string
    return cls.parse_string(string)
  File "D:\github\rinohtype\src\rinoh\attribute.py", line 68, in validate
    value = cls.from_string(stripped)
  File "D:\github\rinohtype\src\rinoh\font\__init__.py", line 88, in __init__
    self.weight = FontWeight.validate(weight)
  File "D:\github\rinohtype\src\rinoh\font\type1.py", line 190, in __init__
    super().__init__(filename,  weight, slant, width)
  File "D:\github\rinohtype\src\rinoh\font\type1.py", line 337, in __init__
    super().__init__(filename + '.afm', weight, slant, width,
  File "D:\github\rinohtype\src\rinoh\fonts\adobe14.py", line 25, in <module>
    Type1Font(path('Courier'), core=True),
  File "D:\github\rinohtype\src\rinoh\text.py", line 49, in <module>
    from .fonts import adobe14
  File "D:\github\rinohtype\src\rinoh\annotation.py", line 56, in <module>
    from .text import MixedStyledText
  File "D:\github\rinohtype\src\rinoh\__init__.py", line 41, in <module>
    module = import_module('.' + name, __name__)

@brechtm brechtm mentioned this issue Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants