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

Does not support Python 3.9 #86

Open
fxcoudert opened this issue Oct 7, 2020 · 13 comments
Open

Does not support Python 3.9 #86

fxcoudert opened this issue Oct 7, 2020 · 13 comments

Comments

@fxcoudert
Copy link

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-req-build-8im_0e0r/setup.py", line 234, in <module>
        setup(
      File "/usr/local/Cellar/[email protected]/3.9.0/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/Cellar/[email protected]/3.9.0/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/local/Cellar/[email protected]/3.9.0/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/local/Cellar/mdv/1.7.4_1/libexec/lib/python3.9/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/local/Cellar/[email protected]/3.9.0/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/install.py", line 546, in run
        self.run_command('build')
      File "/usr/local/Cellar/[email protected]/3.9.0/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/Cellar/[email protected]/3.9.0/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/local/Cellar/[email protected]/3.9.0/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/usr/local/Cellar/[email protected]/3.9.0/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/Cellar/[email protected]/3.9.0/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/private/tmp/pip-req-build-8im_0e0r/setup.py", line 184, in run
        out = template % self._get_context(src, outfile)
      File "/private/tmp/pip-req-build-8im_0e0r/setup.py", line 116, in _get_context
        c['body'] = self.md.convert(src)
      File "build/lib/markdown/__init__.py", line 375, in convert
        newRoot = treeprocessor.run(root)
      File "build/lib/markdown/treeprocessors.py", line 361, in run
        brs = root.getiterator('br')
    AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getiterator'
    Running setup.py install for Markdown: finished with status 'error'
ERROR: Command errored out with exit status 1: /usr/local/Cellar/mdv/1.7.4_1/libexec/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-req-build-8im_0e0r/setup.py'"'"'; __file__='"'"'/private/tmp/pip-req-build-8im_0e0r/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-q346dbmz/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/Cellar/mdv/1.7.4_1/libexec/include/site/python3.9/Markdown Check the logs for full command output.

From https://docs.python.org/3.9/whatsnew/3.9.html#removed :

Methods getchildren() and getiterator() in the ElementTree module have been
removed. They were deprecated in Python 3.2. Use functions list() and iter()
instead. The xml.etree.cElementTree module has been removed.

@WillNye
Copy link

WillNye commented Nov 16, 2020

Not sure if this is still an issue for you but I created a fork with 3.9 support https://github.com/WillNye/terminal_markdown_viewer that I'll be actively maintaining as it is used in several other frameworks I use. It's worth noting python2 support was dropped because it is no longer maintained.

To install pip3 install -U mdv3

@davidrihtarsic
Copy link

Hi,
here is an easy patch for mdv working with python 3.9. Minor changes are needed.
https://github.com/davidrihtarsic/davidrihtarsic.github.io/blob/master/Linux/src/patch_mdv_py_3.9.patch.

@dhondta
Copy link
Contributor

dhondta commented Feb 6, 2021

For now, I get the following error while running my project's tests with Travis for Python 3.9 :

  File "/home/travis/virtualenv/python3.9.1/lib/python3.9/site-packages/mdv/markdownviewer.py", line 970, in formatter
      t = html_parser.unescape(t)
AttributeError: 'HTMLParser' object has no attribute 'unescape'

Does anybody get this error too ?

@davidrihtarsic
Copy link

davidrihtarsic commented Feb 6, 2021

Hi dhondta,
I had exactly the same error and fixed it with the patch I've published. You can do it by using the patch or manually:

  1. edit .../.../.../markdownviewer.py
  2. and follow the content in the patch... change all red lines with green ones.

@dhondta
Copy link
Contributor

dhondta commented Feb 6, 2021

Hi @davidrihtarsic
Thank you very much for this quick response.
However, applying your patch is perhaps not that convenient. Maybe @WillNye could apply a fix and publish the updated mdv3 package to PyPi ? This would be far better as this package can be used in the requirements of other packages and Travis CI builds...

@davidrihtarsic
Copy link

I totally agree with @dhondta. Applying a patch is not a solution.

@WillNye
Copy link

WillNye commented Feb 9, 2021

I don't mind incorporating any fixes @dhondta @davidrihtarsic. Could you give me an example that raises the exception when running mdv3?

@dhondta
Copy link
Contributor

dhondta commented Feb 10, 2021

@WillNye OK, I figured out that a previous build failed because of mdv, not mdv3. Adapting my setup.cfg for installing mdv3 with Python 3.9 fixed the problem. So, no worry, your version is well fixed. Thank you so much. 🎉

@TheLastGimbus
Copy link

Hey how is this going? Neither mdv or mdv3 work for me 😕

@WillNye
Copy link

WillNye commented May 19, 2021

@TheLastGimbus if you toss me an example that raises the exception as well as the traceback you're seeing I can look into it

@TheLastGimbus
Copy link

  • pip3 install mdv:
~$ mdv
... some stuff up here
    this is a Note

----
!!! question: You like this theme?
Styling Result
Traceback (most recent call last):
  File "/home/matiii/.local/bin/mdv", line 8, in <module>
    sys.exit(run())
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 1657, in run
    print(main(**kw) if PY3 else str(main(**kw)))
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 1375, in main
    the_html = MD.convert(md)
  File "/home/matiii/.local/lib/python3.9/site-packages/markdown/core.py", line 268, in convert
    newRoot = treeprocessor.run(root)
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 1150, in run
    formatter(doc, out)
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 1145, in formatter
    formatter(c, out, hir + 1, parent=el)
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 970, in formatter
    t = html_parser.unescape(t)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
~/my-project$ mdv README.md 
Traceback (most recent call last):
  File "/home/matiii/.local/bin/mdv", line 8, in <module>
    sys.exit(run())
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 1657, in run
    print(main(**kw) if PY3 else str(main(**kw)))
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 1375, in main
    the_html = MD.convert(md)
  File "/home/matiii/.local/lib/python3.9/site-packages/markdown/core.py", line 268, in convert
    newRoot = treeprocessor.run(root)
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 1150, in run
    formatter(doc, out)
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 1145, in formatter
    formatter(c, out, hir + 1, parent=el)
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 970, in formatter
    t = html_parser.unescape(t)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
  • pip3 uninstall mdv && pip3 install mdv3
~$ mdv
... some stuff here

----
!!! question: You like this theme?
Styling Result
Traceback (most recent call last):
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 505, in style_ansi
    lexer = get_lexer_by_name(lexer_alias(lang))
  File "/home/matiii/.local/lib/python3.9/site-packages/pygments/lexers/__init__.py", line 118, in get_lexer_by_name
    raise ClassNotFound('no lexer for alias %r found' % _alias)
pygments.util.ClassNotFound: no lexer for alias 'language-python' found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/matiii/.local/bin/mdv", line 8, in <module>
    sys.exit(run())
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 1616, in run
    print(main(**kw))
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 1365, in main
    raw = tags.code(raw.strip(), from_fenced_block=1, lang=lang)
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 690, in code
    s = style_ansi(raw_code, lang=lang)
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 507, in style_ansi
    print(col(R, 'Lexer for %s not found' % lang))
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 555, in col
    if _strt in s:
TypeError: argument of type 'int' is not iterable
~/my-project$ mdv README.md
Traceback (most recent call last):
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 505, in style_ansi
    lexer = get_lexer_by_name(lexer_alias(lang))
  File "/home/matiii/.local/lib/python3.9/site-packages/pygments/lexers/__init__.py", line 118, in get_lexer_by_name
    raise ClassNotFound('no lexer for alias %r found' % _alias)
pygments.util.ClassNotFound: no lexer for alias 'language-bash' found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/matiii/.local/bin/mdv", line 8, in <module>
    sys.exit(run())
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 1616, in run
    print(main(**kw))
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 1365, in main
    raw = tags.code(raw.strip(), from_fenced_block=1, lang=lang)
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 690, in code
    s = style_ansi(raw_code, lang=lang)
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 507, in style_ansi
    print(col(R, 'Lexer for %s not found' % lang))
  File "/home/matiii/.local/lib/python3.9/site-packages/mdv/markdownviewer.py", line 555, in col
    if _strt in s:
TypeError: argument of type 'int' is not iterable

@WillNye
Copy link

WillNye commented May 19, 2021

@TheLastGimbus Thanks for sending this over! I'm able to reproduce the problem and it looks like it stems from an existing issue where numbers in the markdown were being cast to an int. There was also an issue where an exception wasn't being handled properly. I'm busy with work today but I'll try to get to it today or tomorrow. In the meantime, I know it's a PITA an I'm sorry to ask but is there any way you could make an issue for this here? I don't actually maintain the legacy mdv or the repo this issue is filed under an I wanted to start keeping track of everything within my fork.

@TheLastGimbus
Copy link

Could do, but there is no issues tab:

image

TinfoilSubmarine added a commit to TinfoilSubmarine/void-packages that referenced this issue Feb 25, 2022
Does not support Python >=3.9, no releases since 2016.
axiros/terminal_markdown_viewer#86
TinfoilSubmarine added a commit to TinfoilSubmarine/void-packages that referenced this issue Feb 25, 2022
Does not support Python >=3.9, no releases since 2016.
axiros/terminal_markdown_viewer#86
ahesford pushed a commit to void-linux/void-packages that referenced this issue Feb 25, 2022
Does not support Python >=3.9, no releases since 2016.
axiros/terminal_markdown_viewer#86
gmbeard pushed a commit to gmbeard/void-packages that referenced this issue Mar 12, 2022
Does not support Python >=3.9, no releases since 2016.
axiros/terminal_markdown_viewer#86
algor512 pushed a commit to algor512/void-packages that referenced this issue Mar 13, 2022
Does not support Python >=3.9, no releases since 2016.
axiros/terminal_markdown_viewer#86
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

5 participants