[New-bugs-announce] [issue33209] Repeated Pickler.dump() doesn't reset the state in the C implementation of pickle

Serhiy Storchaka report at bugs.python.org
Mon Apr 2 21:08:23 EDT 2018


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

test_clear_pickler_memo tested only the default protocol and fails when bump the default protocol to 4. For some reasons C implementation writes FRAME before PROTO when call Pickler.dump() repeatedly.

Python implementation:
b'\x80\x04\x95\x13\x00\x00\x00\x00\x00\x00\x00]\x94(\x8c\x07abcdefg\x94h\x01K,e.'
    0: \x80 PROTO      4
    2: \x95 FRAME      19
   11: ]    EMPTY_LIST
   12: \x94 MEMOIZE    (as 0)
   13: (    MARK
   14: \x8c     SHORT_BINUNICODE 'abcdefg'
   23: \x94     MEMOIZE    (as 1)
   24: h        BINGET     1
   26: K        BININT1    44
   28: e        APPENDS    (MARK at 13)
   29: .    STOP
highest protocol among opcodes = 4

C implementation:
b'\x95\x15\x00\x00\x00\x00\x00\x00\x00\x80\x04]\x94(\x8c\x07abcdefg\x94h\x01K,e.'
    0: \x95 FRAME      21
    9: \x80 PROTO      4
   11: ]    EMPTY_LIST
   12: \x94 MEMOIZE    (as 0)
   13: (    MARK
   14: \x8c     SHORT_BINUNICODE 'abcdefg'
   23: \x94     MEMOIZE    (as 1)
   24: h        BINGET     1
   26: K        BININT1    44
   28: e        APPENDS    (MARK at 13)
   29: .    STOP
highest protocol among opcodes = 4

----------
components: Extension Modules
messages: 314847
nosy: alexandre.vassalotti, pitrou, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Repeated Pickler.dump() doesn't reset the state in the C implementation of pickle
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33209>
_______________________________________


More information about the New-bugs-announce mailing list