awake icon indicating copy to clipboard operation
awake copied to clipboard

Refactor codebase for Python 3 compatibility

Open CodeBreaker44 opened this issue 1 year ago • 1 comments

  1. Updated syntax (e.g., print function, etc.).
  2. Replaced obsolete libraries or functions with Python 3 equivalents.
  3. Updated dependencies to versions compatible with Python 3.

CodeBreaker44 avatar Dec 22 '24 18:12 CodeBreaker44

This does not work because you did not update rom.py and address.py properly.

In the rom.py, the Rom class function get(self, addr) makes a function call to struct.unpack that which will expect self.data[addr.physical()] to be the type bytes and will throw an error. I found that it is fine to do this dirty trick to quickly get it to work:

    def get(self, addr):
        return struct.unpack('B', (self.data[addr.physical()]).to_bytes(1,"little") if type(self.data[addr.physical()]) == int else self.data[addr.physical()])[0]

however, then in the address.py file, the following error will occur:

    if ":" not in conventional:
       ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: a bytes-like object is required, not 'str'

I am unsure what causes this, but another dirty trick of adding this into the function would be fine enough for my current ROM:

def fromConventional(conventional):
    if type(conventional) == bytes:
        conventional = conventional.decode()

I know I randomly showed up, but I was looking at a ROM and gave this a shot. I don't have much to provide in help, but this worked for me, so far. I haven't tried all the features but I do notice there is also a problem with the server.py as it writes to the socket and it will error because writing to the socket expects bytes. which means the strings need to be encoded or designated with b""

I notice you made this PR recently, but the author didnt update it in more than a decade. looks like it will not be merged, but thank you for making the PR either way.

Acters avatar Dec 23 '24 08:12 Acters