OpenTTD/nml

Error: (AttributeError) "'array.array' object has no attribute 'tostring'" (compile step)

m-alice opened this issue · 8 comments

nmlc ERROR: nmlc: An internal error has occurred: nmlc-version: 0.5.3 Error: (AttributeError) "'array.array' object has no attribute 'tostring'". Command: ['C:\\Users\\user\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\Scripts\\nmlc', '-c', '--grf', 'ogfx_ufo.grf', 'ogfx_ufo.nml', '-n'] Location: File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nml\lz77.py", line 28, in _encode

Python 3.9.4 (from ms store)
Windows 10 pro 19041.928
Wheel 0.36.2 (i don't know, it is needed?)

I just want to practice and set prices for UFO grf.

stream = data.tostring()

fallback module doing the wrong thing with types?

glx22 commented

Adding -s parameter to your nmlc command will give more details

nmlc -c --grf ..\..\ogfx_ufo.grf ogfx_ufo.nml -n -s  1>log.txt
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\nmlc.exe\__main__.py", line 7, in <module>
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nml\main.py", line 421, in run
    main(sys.argv[1:])
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nml\main.py", line 170, in main
    ret = nml(input, input_filename, opts.debug, outputs, opts.start_sprite_num, opts.compress, opts.crop, opts.forced_palette, opts.md5_filename, opts.rebuild_parser, opts.debug_parser)
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nml\main.py", line 365, in nml
    encoder.open(sprite_files)
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nml\spriteencoder.py", line 124, in open
    size_x, size_y, xoffset, yoffset, compressed_data, info_byte, crop_rect, pixel_stats = self.encode_sprite(sprite_info)
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nml\spriteencoder.py", line 332, in encode_sprite
    compressed_data = self.sprite_compress(sprite_data)
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nml\spriteencoder.py", line 363, in sprite_compress
    stream = lz77.encode(data)
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nml\lz77.py", line 28, in _encode
    stream = data.tostring()
AttributeError: 'array.array' object has no attribute 'tostring'
glx22 commented

Ok, it seems some parts of nmlc are broken with python 3.9.

glx22 commented

As a workaround, the standalone executable available here should run fine.

Standalone works fine, thx!

Fixed in #215