bigfile/zodb: Allow to pass both buffer and any object with buffer interface to ZBlk.setblkdata
Since wendelin.core beginning PyBigFile.storeblk(blk, buf) is passed with buf being buffer object. See 35eb95c2 (bigfile: Python wrapper around virtual memory subsystem) for details about that. In its turn ZBigFile.storeblk was initially making bytes copy snapshot of that buffer, but later pushed that job to ZBlk.setblkdata in e0b00bda (bigfile/zodb: Make "set blkdata to be later saved to DB" explicit method of ZBlk). So on that codepath ZBlk.setblkdata(buf) is invoked with buf being python buffer as argument name suggests. However later, when working on WCFS, for preparing test data I also explicitly used ZBlk.setblkdata in wcfs/internal/zdata/testdata/zblk_test_gen.py 2c152d41 (wcfs: Add zdata package to load ZBlk/ZBigFile data) wcfs/internal/xbtree/xbtreetest/treegen.py a8595565 (wcfs: tests: Treegen functionality) and there test data is prepared by regularly using ZODB without virtmem layer involvement at all. ZBlk.setblkdata calls are made with bytes and strings which happen to work by chance on py2 more or less but turned out to break a bit on py3. -> Prepare to make all that to work robustly by allowing ZBlk.setblkdata to be called with buf being either buffer object, or any other object that provides buffer interface. Everything continues to work for py2 and we will fix issues around treegen.py on py3 in the next patch.
Showing