Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
a552d9cd
Commit
a552d9cd
authored
Feb 05, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
58a07e39
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
37 deletions
+40
-37
go/zodb/internal/pickletools/pickletools.go
go/zodb/internal/pickletools/pickletools.go
+37
-2
go/zodb/pydata.go
go/zodb/pydata.go
+3
-35
No files found.
go/zodb/internal/pickletools/pickletools.go
View file @
a552d9cd
// Copyright (C) 2017 Nexedi SA and Contributors.
// Copyright (C) 2017
-2019
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -25,7 +25,11 @@
...
@@ -25,7 +25,11 @@
package
pickletools
package
pickletools
import
(
import
(
"encoding/binary"
"fmt"
"math/big"
"math/big"
pickle
"github.com/kisielk/og-rek"
)
)
// Xint64 tries to convert unpickled value to int64.
// Xint64 tries to convert unpickled value to int64.
...
@@ -43,3 +47,34 @@ func Xint64(xv interface{}) (v int64, ok bool) {
...
@@ -43,3 +47,34 @@ func Xint64(xv interface{}) (v int64, ok bool) {
return
0
,
false
return
0
,
false
}
}
// Xstrbytes verifies and extacts str|bytes from unpickled value.
func
Xstrbytes
(
x
interface
{})
(
string
,
error
)
{
var
s
string
switch
x
:=
x
.
(
type
)
{
default
:
return
""
,
fmt
.
Errorf
(
"expect str|bytes; got %T"
,
x
)
case
string
:
s
=
x
case
pickle
.
Bytes
:
s
=
string
(
x
)
}
return
s
,
nil
}
// Xstrbytes8 verifies and extracts [8](str|bytes) from unpickled value as big-endian u64.
func
Xstrbytes8
(
x
interface
{})
(
uint64
,
error
)
{
s
,
err
:=
Xstrbytes
(
x
)
if
err
!=
nil
{
return
0
,
err
}
if
len
(
s
)
!=
8
{
return
0
,
fmt
.
Errorf
(
"expect [8]bytes; got [%d]bytes"
,
len
(
s
))
}
return
binary
.
BigEndian
.
Uint64
([]
byte
(
s
)),
nil
}
go/zodb/pydata.go
View file @
a552d9cd
...
@@ -22,11 +22,12 @@ package zodb
...
@@ -22,11 +22,12 @@ package zodb
import
(
import
(
"bytes"
"bytes"
"encoding/binary"
"fmt"
"fmt"
"strings"
"strings"
pickle
"github.com/kisielk/og-rek"
pickle
"github.com/kisielk/og-rek"
"lab.nexedi.com/kirr/neo/go/zodb/internal/pickletools"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xerr"
)
)
...
@@ -241,7 +242,7 @@ func xoid(x interface{}) (_ Oid, err error) {
...
@@ -241,7 +242,7 @@ func xoid(x interface{}) (_ Oid, err error) {
// ZODB >= 5.4 encodes oid as bytes; before - as str:
// ZODB >= 5.4 encodes oid as bytes; before - as str:
// https://github.com/zopefoundation/ZODB/commit/12ee41c473
// https://github.com/zopefoundation/ZODB/commit/12ee41c473
v
,
err
:=
x
strbytes8
(
x
)
v
,
err
:=
pickletools
.
X
strbytes8
(
x
)
if
err
!=
nil
{
if
err
!=
nil
{
return
InvalidOid
,
err
return
InvalidOid
,
err
}
}
...
@@ -249,39 +250,6 @@ func xoid(x interface{}) (_ Oid, err error) {
...
@@ -249,39 +250,6 @@ func xoid(x interface{}) (_ Oid, err error) {
return
Oid
(
v
),
nil
return
Oid
(
v
),
nil
}
}
// -> pickletools
// xstrbytes verifies and extacts str|bytes from unpickled value.
func
xstrbytes
(
x
interface
{})
(
string
,
error
)
{
var
s
string
switch
x
:=
x
.
(
type
)
{
default
:
return
""
,
fmt
.
Errorf
(
"expect str|bytes; got %T"
,
x
)
case
string
:
s
=
x
case
pickle
.
Bytes
:
s
=
string
(
x
)
}
return
s
,
nil
}
// xstrbytes8 verifies and extracts [8](str|bytes) from unpickled value as big-endian u64.
func
xstrbytes8
(
x
interface
{})
(
uint64
,
error
)
{
s
,
err
:=
xstrbytes
(
x
)
if
err
!=
nil
{
return
0
,
err
}
if
len
(
s
)
!=
8
{
return
0
,
fmt
.
Errorf
(
"expect [8]bytes; got [%d]bytes"
,
len
(
s
))
}
return
binary
.
BigEndian
.
Uint64
([]
byte
(
s
)),
nil
}
// pyclassPath returns full path for a python class.
// pyclassPath returns full path for a python class.
//
//
// for example class "ABC" in module "wendelin.lib" has its full path as "wendelin.lib.ABC".
// for example class "ABC" in module "wendelin.lib" has its full path as "wendelin.lib.ABC".
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment