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

asciidocapi: Fix crash on load of the loader #86

Merged
merged 1 commit into from
Nov 24, 2019

Conversation

aerostitch
Copy link
Contributor

Hi guys!

As describe by Simon in Debian bug #945391, when trying to instantiate the asciidocapi with the version I put in Debian based on commit 51d7c14, the loader fails:

$ python3
Python 3.7.5 (default, Oct 27 2019, 15:43:29) 
[GCC 9.2.1 20191022] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
>>> import sys
>>> sys.path.append('/usr/share/asciidoc')
>>> import asciidocapi
>>> infile = io.StringIO('Test')
>>> outfile = io.StringIO()
>>> adoc = asciidocapi.AsciiDocAPI()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/share/asciidoc/asciidocapi.py", line 209, in __init__
    self.__import_asciidoc()
  File "/usr/share/asciidoc/asciidocapi.py", line 244, in __import_asciidoc
    module = importlib.util.module_from_spec(spec)
  File "<frozen importlib._bootstrap>", line 580, in module_from_spec
AttributeError: 'NoneType' object has no attribute 'loader'
>>> 

This patch was proposed by Simon Ruderich in his bug report and it works!

$ python3
Python 3.7.5 (default, Oct 27 2019, 15:43:29) 
[GCC 9.2.1 20191022] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
>>> import sys
>>> sys.path.append('/usr/share/asciidoc')
>>> import asciidocapi
>>> infile = io.StringIO('Test')
>>> outfile = io.StringIO()
>>> adoc = asciidocapi.AsciiDocAPI()
>>> adoc.execute(infile, outfile)
>>> outfile.getvalue()
*** content stripped here because it's a big html code but it works! ***

Thanks for considering this.

Joseph

@MasterOdin
Copy link
Member

Can reproduce the bug by just renaming asciidoc.py to asciidoc in the repo and then running the code, as I guess spec_from_file_location requires a file extension to exist for it to work.

@MasterOdin MasterOdin merged commit 813fb51 into asciidoc-py:master Nov 24, 2019
@aerostitch aerostitch deleted the deb_945391 branch November 25, 2019 19:56
@aerostitch
Copy link
Contributor Author

Thx! :)

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

Successfully merging this pull request may close these issues.

None yet

2 participants