Commit d8249b62 authored by Kirill Smelkov's avatar Kirill Smelkov

wcfs: zdata: Replace pycompat.Int64 with ogórek.AsInt64

Our "as int64" code was put into ogórek as generalized utility in
https://github.com/kisielk/og-rek/commit/010fbd2e.
parent 727ca0d6
// XXX dup from neo/go/zodb/internal/pickletools
package pycompat
import (
"math/big"
)
// Int64 tries to convert unpickled Python value to int64.
//
// (ogórek decodes python long as big.Int)
//
// XXX + support for float?
func Int64(xv interface{}) (v int64, ok bool) {
switch v := xv.(type) {
case int64:
return v, true
case *big.Int:
if v.IsInt64() {
return v.Int64(), true
}
}
return 0, false
}
// Copyright (C) 2018-2021 Nexedi SA and Contributors.
// Copyright (C) 2018-2024 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
......@@ -53,7 +53,6 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/pycompat"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xzodb"
)
......@@ -382,9 +381,9 @@ func (bf *zBigFileState) PySetState(pystate interface{}) (err error) {
return fmt.Errorf("expect [2](); got [%d]()", len(t))
}
blksize, ok := pycompat.Int64(t[0])
if !ok {
return fmt.Errorf("blksize: expect integer; got %s", xzodb.TypeOf(t[0]))
blksize, err := pickle.AsInt64(t[0])
if err != nil {
return fmt.Errorf("blksize: %s", err)
}
if blksize <= 0 {
return fmt.Errorf("blksize: must be > 0; got %d", blksize)
......
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