alexgorji / musicscore

14 stars 5 forks source link

`import musictree` fails with UnicodeDecodeError #3

Closed automaciej closed 1 year ago

automaciej commented 1 year ago

I'm testing on Debian 11, pypy.

$ pypy --version
Python 3.7.10 (7.3.5+dfsg-2+deb11u2, Nov 01 2022, 20:16:36)
[PyPy 7.3.5 with GCC 10.2.1 20210110]

I installed pypy-dev, pypy3-dev (required to find Python.h) and after the installation I got this:

$ python
Python 3.7.10 (7.3.5+dfsg-2+deb11u2, Nov 01 2022, 20:16:36)
[PyPy 7.3.5 with GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> import musictree
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/maciej/src/pypy/site-packages/musictree/__init__.py", line 1, in <module>
    from musictree.accidental import *
  File "/home/maciej/src/pypy/site-packages/musictree/accidental.py", line 3, in <module>
    from musicxml.xmlelement.xmlelement import XMLAccidental
  File "/home/maciej/src/pypy/site-packages/musicxml/xmlelement/xmlelement.py", line 10, in <module>
    from musicxml.generate_classes.utils import musicxml_xsd_et_root, ns
  File "/home/maciej/src/pypy/site-packages/musicxml/generate_classes/utils.py", line 11, in <module>
    musicxml_et_tree = ET.parse(file)
  File "/usr/lib/pypy3/lib-python/3/xml/etree/ElementTree.py", line 1197, in parse
    tree.parse(source, parser)
  File "/usr/lib/pypy3/lib-python/3/xml/etree/ElementTree.py", line 601, in parse
    data = source.read(65536)
  File "/usr/lib/pypy3/lib-python/3/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 311: ordinal not in range(128)

I didn't do a deeper dive on this, just recording that there seems to be a problem.

alexgorji commented 1 year ago

Thanks for your comment. I'm afraid musicscore2 do not run under your python version (3.7). You need at leat version 3.9.

automaciej commented 1 year ago

Thanks, I can confirm that this works with Python 3.9:

(pypy) maciej@nasturcja:~$ python
Python 3.9.16 (7.3.11+dfsg-2, Feb 06 2023, 16:52:03)
[PyPy 7.3.11 with GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> import musictree
/home/maciej/src/pypy/lib/pypy3.9/site-packages/musicxml/xsd/xsdtree.py:318: FutureWarning: The behavior of this method will change in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.
  if not found_xsd_element:
>>>>