Commit 55689029 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/fs1: Fix index load from py3 data

Python3 emits index entries using bytes, but index.go was expecting only
bytestrings. As the result loading index produced by py3 was failing
e.g. as

    index_test.go:201: index load: testdata/py3_pickle3/1.fs.index: pickle @6: invalid oidPrefix: type ogórek.Bytes

-> Fix it by accepting both bytes and bytestrings inside the index.
parent 610c5880
......@@ -280,9 +280,9 @@ loop:
// decode oidPrefix
xoidPrefixStr := v[0]
oidPrefixStr, ok := xoidPrefixStr.(pickle.ByteString)
if !ok {
return nil, fmt.Errorf("invalid oidPrefix: type %T", xoidPrefixStr)
oidPrefixStr, err := pickle.AsBytes(xoidPrefixStr)
if err != nil {
return nil, fmt.Errorf("invalid oidPrefix: %s", err)
}
if l := len(oidPrefixStr); l != 6 {
return nil, fmt.Errorf("invalid oidPrefix: len = %d", l)
......@@ -292,9 +292,9 @@ loop:
// check fsBucket
xkvStr := v[1]
kvStr, ok := xkvStr.(pickle.ByteString)
if !ok {
return nil, fmt.Errorf("invalid fsBucket: type %T", xkvStr)
kvStr, err := pickle.AsBytes(xkvStr)
if err != nil {
return nil, fmt.Errorf("invalid fsBucket: %s", err)
}
if l := len(kvStr); l%8 != 0 {
return nil, fmt.Errorf("invalid fsBucket: len = %d", l)
......
......@@ -196,9 +196,6 @@ func TestIndexLoadFromPy(t *testing.T) {
ztestdataReg.RunWithEach(t, _TestIndexLoadFromPy)
}
func _TestIndexLoadFromPy(t *testing.T, z *ZTestData) {
if z.Kind == "py3_pickle3" {
t.Skip("xfail")
}
fsiPy, err := LoadIndexFile(z.Path("1.fs.index"))
if err != nil {
t.Fatal(err)
......@@ -268,9 +265,6 @@ func BenchmarkIndexLoad(b *testing.B) {
ztestdataReg.BenchWithEach(b, _BenchmarkIndexLoad)
}
func _BenchmarkIndexLoad(b *testing.B, z *ZTestData) {
if z.Kind == "py3_pickle3" {
b.Skip("xfail")
}
// FIXME small testdata/1.fs is not representative for benchmarks
for i := 0; i < b.N; i++ {
_, err := LoadIndexFile(z.Path("1.fs.index"))
......@@ -308,9 +302,6 @@ func BenchmarkIndexGet(b *testing.B) {
ztestdataReg.BenchWithEach(b, _BenchmarkIndexGet)
}
func _BenchmarkIndexGet(b *testing.B, z *ZTestData) {
if z.Kind == "py3_pickle3" {
b.Skip("xfail")
}
// FIXME small testdata/1.fs is not representative for benchmarks
fsi, err := LoadIndexFile(z.Path("1.fs.index"))
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment