Skip to content

bytes vs str in mig/shared/sandbox.py on experimental with python3 #161

@jonasbardino

Description

@jonasbardino

We see log crashes from oneclick like

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8f in position 0: invalid start byte
Traceback (most recent call last):
  File "/home/mig/mig/shared/cgiscriptstub.py", line 185, in run_cgi_script_possibly_with_cert
    (out_obj, (ret_code, ret_msg)) = main(client_id, user_arguments_dict)
  File "/home/mig/mig/shared/functionality/oneclick.py", line 72, in main
    (status, result) = get_resource(client_id, configuration, logger)
  File "/home/mig/mig/shared/sandbox.py", line 371, in get_resource
    sandboxkey = hexlify(open('/dev/urandom').read(32))
  File "/usr/lib64/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)

apparently because the plain open() defaults to text-mode and therefore tries to parse the raw bytes as utf8 on python3

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions