Commit b9efd0b5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8708ccde
...@@ -55,7 +55,7 @@ func NeedPy(t testing.TB, modules ...string) { ...@@ -55,7 +55,7 @@ func NeedPy(t testing.TB, modules ...string) {
// verify if python is present // verify if python is present
havePy, know := pyHave[".python"] havePy, know := pyHave[".python"]
if !know { if !know {
cmd := exec.Command("python2", "-c", "0") cmd := exec.Command("python", "-c", "0")
err := cmd.Run() err := cmd.Run()
havePy = (err == nil) havePy = (err == nil)
pyHave[".python"] = havePy pyHave[".python"] = havePy
...@@ -69,7 +69,7 @@ func NeedPy(t testing.TB, modules ...string) { ...@@ -69,7 +69,7 @@ func NeedPy(t testing.TB, modules ...string) {
for _, pymod := range modules { for _, pymod := range modules {
have, know := pyHave[pymod] have, know := pyHave[pymod]
if !know { if !know {
cmd := exec.Command("python2", "-c", "import "+pymod) cmd := exec.Command("python", "-c", "import "+pymod)
err := cmd.Run() err := cmd.Run()
have = (err == nil) have = (err == nil)
pyHave[pymod] = have pyHave[pymod] = have
...@@ -112,7 +112,7 @@ func ZPyCommitRaw(zurl string, at zodb.Tid, objv ...ZRawObject) (_ zodb.Tid, err ...@@ -112,7 +112,7 @@ func ZPyCommitRaw(zurl string, at zodb.Tid, objv ...ZRawObject) (_ zodb.Tid, err
zin.WriteString("\n") zin.WriteString("\n")
// run py `zodb commit` // run py `zodb commit`
cmd:= exec.Command("python2", "-m", "zodbtools.zodb", "commit", zurl, at.String()) cmd:= exec.Command("python", "-m", "zodbtools.zodb", "commit", zurl, at.String())
cmd.Stdin = zin cmd.Stdin = zin
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
out, err := cmd.Output() out, err := cmd.Output()
......
...@@ -69,7 +69,7 @@ func encodePyData(pyclass pickle.Class, pystate interface{}) PyData { ...@@ -69,7 +69,7 @@ func encodePyData(pyclass pickle.Class, pystate interface{}) PyData {
p := pickle.NewEncoderWithConfig(buf, &pickle.EncoderConfig{ p := pickle.NewEncoderWithConfig(buf, &pickle.EncoderConfig{
// allow pristine python2 to decode the pickle. // allow pristine python2 to decode the pickle.
// TODO 2 -> 3 since ZODB5 switched to it and uses zodbpickle. // TODO 2 -> 3 since ZODB5 switched to it and uses zodbpickle.
Protocol: 2, Protocol: 2, // XXX -> 3?
PersistentRef: persistentRef, PersistentRef: persistentRef,
}) })
......
...@@ -68,7 +68,8 @@ type DataHeader struct { ...@@ -68,7 +68,8 @@ type DataHeader struct {
} }
const ( const (
Magic = "FS21" // every FileStorage file starts with this Magic21 = "FS21" // FileStorage file produced by Python2 starts with this
Magic30 = "FS30" // ----//---- by Python3 XXX +test
// on-disk sizes // on-disk sizes
FileHeaderSize = 4 FileHeaderSize = 4
...@@ -154,8 +155,12 @@ func (fh *FileHeader) Load(r io.ReaderAt) error { ...@@ -154,8 +155,12 @@ func (fh *FileHeader) Load(r io.ReaderAt) error {
if err != nil { if err != nil {
return fmt.Errorf("%sread magic: %s", ioprefix(r), err) return fmt.Errorf("%sread magic: %s", ioprefix(r), err)
} }
if string(fh.Magic[:]) != Magic { switch string(fh.Magic[:]) {
default:
return fmt.Errorf("%sinvalid fs1 magic %q", ioprefix(r), fh.Magic) return fmt.Errorf("%sinvalid fs1 magic %q", ioprefix(r), fh.Magic)
case Magic21, Magic30:
// ok XXX do we need to distinguish them somehow?
} }
return nil return nil
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
package fs1tools package fs1tools
// XXX + py3
//go:generate sh -c "python2 -m ZODB.scripts.fstail -n 1000000 ../testdata/1.fs >testdata/1.fstail.ok" //go:generate sh -c "python2 -m ZODB.scripts.fstail -n 1000000 ../testdata/1.fs >testdata/1.fstail.ok"
//go:generate sh -c "python2 -c 'from ZODB.FileStorage import fsdump; fsdump.main()' ../testdata/1.fs >testdata/1.fsdump.ok" //go:generate sh -c "python2 -c 'from ZODB.FileStorage import fsdump; fsdump.main()' ../testdata/1.fs >testdata/1.fsdump.ok"
//go:generate sh -c "python2 -c 'from ZODB.FileStorage.fsdump import Dumper; import sys; d = Dumper(sys.argv[1]); d.dump()' ../testdata/1.fs >testdata/1.fsdumpv.ok" //go:generate sh -c "python2 -c 'from ZODB.FileStorage.fsdump import Dumper; import sys; d = Dumper(sys.argv[1]); d.dump()' ../testdata/1.fs >testdata/1.fsdumpv.ok"
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
package zodbtools package zodbtools
// XXX +py3 ?
//go:generate sh -c "python2 -m zodbtools.zodb dump ../../zodb/storage/fs1/testdata/1.fs >testdata/1.zdump.pyok" //go:generate sh -c "python2 -m zodbtools.zodb dump ../../zodb/storage/fs1/testdata/1.fs >testdata/1.zdump.pyok"
//go:generate sh -c "python2 -m zodbtools.zodb dump ../../zodb/storage/fs1/testdata/empty.fs >testdata/empty.zdump.pyok" //go:generate sh -c "python2 -m zodbtools.zodb dump ../../zodb/storage/fs1/testdata/empty.fs >testdata/empty.zdump.pyok"
......
...@@ -118,7 +118,7 @@ func (δtail *ΔTail) Tail() Tid { ...@@ -118,7 +118,7 @@ func (δtail *ΔTail) Tail() Tid {
// //
// Note: contrary to regular go slicing, low is exclusive while high is inclusive. // Note: contrary to regular go slicing, low is exclusive while high is inclusive.
func (δtail *ΔTail) SliceByRev(low, high Tid) /*readonly*/ []ΔRevEntry { func (δtail *ΔTail) SliceByRev(low, high Tid) /*readonly*/ []ΔRevEntry {
tail := δtail.Tail() tail := δtail.tail
head := δtail.head head := δtail.head
if !(tail <= low && low <= high && high <= head) { if !(tail <= low && low <= high && high <= head) {
panic(fmt.Sprintf("δtail.Slice: invalid query: (%s, %s]; (tail, head] = (%s, %s]", low, high, tail, head)) panic(fmt.Sprintf("δtail.Slice: invalid query: (%s, %s]; (tail, head] = (%s, %s]", low, high, tail, head))
......
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