Lincoln-Murray / graphics_library

A small 3d graphics library/module for python
Creative Commons Attribution 4.0 International
4 stars 1 forks source link

Cannot load objects on linux due to encoding error! #2

Closed CaptainDeathead closed 1 month ago

CaptainDeathead commented 1 month ago

I dunno if it works on windows but it doesnt work on linux due to this error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 86: invalid start byte

(line 281)

CaptainDeathead commented 1 month ago

Found ascii encoding: captaindeathead@plazmaPC:/media/captaindeathead/HardDrive/PythonProjects/graphics_library$ file models/cube.obj models/cube.obj: ASCII text

Should be able to explicitly tell python to use ascii.

CaptainDeathead commented 1 month ago
captaindeathead@plazmaPC:/media/captaindeathead/HardDrive/PythonProjects/graphics_library$ python3 cube_demo.py
Traceback (most recent call last):
  File "/media/captaindeathead/HardDrive/PythonProjects/graphics_library/cube_demo.py", line 12, in <module>
    cube = Main.object(renderer, model,0,0,1,0,35,0, 0.0000001, 0.0000001, 0.0000001, None)
  File "/media/captaindeathead/HardDrive/PythonProjects/graphics_library/Main.py", line 362, in __init__
    if model.read()[:5] == 'solid':
  File "/usr/lib/python3.10/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 86: ordinal not in range(128)

ascii does not seem to be it.

CaptainDeathead commented 1 month ago
captaindeathead@plazmaPC:/media/captaindeathead/HardDrive/PythonProjects/graphics_library$ file models/cube.stl
models/cube.stl: data
captaindeathead@plazmaPC:/media/captaindeathead/HardDrive/PythonProjects/graphics_library$ python3 cube_demo.py
Traceback (most recent call last):
  File "/media/captaindeathead/HardDrive/PythonProjects/graphics_library/cube_demo.py", line 12, in <module>
    cube = Main.object(renderer, model,0,0,1,0,35,0, 0.0000001, 0.0000001, 0.0000001, None)
  File "/media/captaindeathead/HardDrive/PythonProjects/graphics_library/Main.py", line 281, in __init__
    model = open(_model, 'rt', encoding='data')
LookupError: unknown encoding: data

Turns out encoding is data however python does not understand it.

CaptainDeathead commented 1 month ago

Encoding turns out to be cp1252. Works now with changes to reading and converting bytes.

Made pull request.