Skip to content

load bytes objects directly as bytes

Xiaowu Zhang requested to merge xiaowu.zhang/erp5:fix/mix_data into master

While upgrade instance from python2 to python3, i found when read old BigFile object such as Data Stream, it raise error below

  Module erp5.component.document.erp5_version.BigFile, line 105, in getData
    return btree.read(0, len(btree))
  Module erp5.component.module.erp5_version.BTreeData, line 182, in read
    return b''.join(self.iterate(offset, size))
TypeError: sequence item 0: expected a bytes-like object, str found

It's because the old data created when in python2 is firstly loaded as string

but for PersistentString, we're sure that it's bytes, let's load directly as bytes to avoid useless conversion.

in this MR, we also clean some codes

Related MR: https://lab.nexedi.com/nexedi/erp5-bin/-/merge_requests/12

Edited by Xiaowu Zhang

Merge request reports