Skip to content

Port 816-opt.py to Python 3 #5

@pinobatch

Description

@pinobatch

A user in the SNESdev Discord server is having trouble running 816-opt.py in Python 3. When building "likemario" from the PVSnesLib examples, the user ran into this error:

$ 816-opt.py LikeMario.ps >LikeMario.asp
Traceback (most recent call last):
  File "../../../devkitsnes/bin/816-opt.py", line 14, in <module>
    text_raw = open(sys.argv[1],'r').readlines()
  File "/usr/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcd in position 509: invalid continuation byte

I looked at the 816-opt.py script, and it appears to be written for Python 2, not Python 3. The open() function in Python 3 returns Unicode strings, not byte strings as in Python 2. Security updates for Python 2 ended on January 1, 2020.

How practical would it be to port 816-opt.py to Python 3?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions