Commit f7543195 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/zeo: Accept both int|bool for pickled message flags

It is already documented in pktDecodeZ comment that flags is int|bool.
However until now we were decoding it only as int.

As is it was working, but it will fail when receiving e.g.
invalidateTransaction message, because ZEO/py server actually uses bool
when sending it:

    https://github.com/zopefoundation/ZEO/blob/5.2.1-20-gcb26281d/src/ZEO/asyncio/base.py#L139

Fix it.
This will be covered by watch tests, when watch support will be added in a followup patch.
parent fe24c62f
...@@ -112,7 +112,14 @@ func pktDecodeZ(pkb *pktBuf) (msg, error) { ...@@ -112,7 +112,14 @@ func pktDecodeZ(pkb *pktBuf) (msg, error) {
flags, ok := pickletools.Xint64(tpkt[1]) flags, ok := pickletools.Xint64(tpkt[1])
if !ok { if !ok {
return m, derrf("flags: got %T; expected int", tpkt[1]) bflags, ok := tpkt[1].(bool)
if !ok {
return m, derrf("flags: got %T; expected int|bool", tpkt[1])
}
if bflags {
flags = 1
} // else: flags is already = 0
} }
// XXX check flags are in range? // XXX check flags are in range?
m.flags = msgFlags(flags) m.flags = msgFlags(flags)
......
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