Class: Python::Pickle::Protocol5

Inherits:
Protocol4 show all
Defined in:
lib/python/pickle/protocol5.rb

Constant Summary collapse

BYTEARRAY8 =

The BYTEARRAY8 opcode.

150
NEXT_BUFFER =

The NEXT_BUFFER opcode.

151
READONLY_BUFFER =

The READONLY_BUFFER opcode.

152

Constants inherited from Protocol4

Python::Pickle::Protocol4::ADDITEMS, Python::Pickle::Protocol4::BINBYTES8, Python::Pickle::Protocol4::BINUNICODE8, Python::Pickle::Protocol4::EMPTY_SET, Python::Pickle::Protocol4::FRAME, Python::Pickle::Protocol4::FROZENSET, Python::Pickle::Protocol4::MEMOIZE, Python::Pickle::Protocol4::NEWOBJ_EX, Python::Pickle::Protocol4::SHORT_BINUNICODE, Python::Pickle::Protocol4::STACK_GLOBAL

Constants inherited from Protocol3

Python::Pickle::Protocol3::BINBYTES, Python::Pickle::Protocol3::SHORT_BINBYTES

Constants inherited from Protocol2

Python::Pickle::Protocol2::EXT1, Python::Pickle::Protocol2::EXT2, Python::Pickle::Protocol2::EXT4, Python::Pickle::Protocol2::LONG1, Python::Pickle::Protocol2::LONG4, Python::Pickle::Protocol2::NEWFALSE, Python::Pickle::Protocol2::NEWOBJ, Python::Pickle::Protocol2::NEWTRUE, Python::Pickle::Protocol2::PROTO, Python::Pickle::Protocol2::TUPLE1, Python::Pickle::Protocol2::TUPLE2, Python::Pickle::Protocol2::TUPLE3

Constants inherited from Protocol1

Python::Pickle::Protocol1::APPENDS, Python::Pickle::Protocol1::BINFLOAT, Python::Pickle::Protocol1::BINGET, Python::Pickle::Protocol1::BININT1, Python::Pickle::Protocol1::BINPUT, Python::Pickle::Protocol1::BINSTRING, Python::Pickle::Protocol1::BINUNICODE, Python::Pickle::Protocol1::EMPTY_DICT, Python::Pickle::Protocol1::EMPTY_LIST, Python::Pickle::Protocol1::EMPTY_TUPLE, Python::Pickle::Protocol1::LONG_BINGET, Python::Pickle::Protocol1::SETITEMS, Python::Pickle::Protocol1::SHORT_BINSTRING

Constants inherited from Protocol0

Python::Pickle::Protocol0::APPEND, Python::Pickle::Protocol0::BINPERSID, Python::Pickle::Protocol0::BUILD, Python::Pickle::Protocol0::DICT, Python::Pickle::Protocol0::DUP, Python::Pickle::Protocol0::FLOAT, Python::Pickle::Protocol0::GET, Python::Pickle::Protocol0::GLOBAL, Python::Pickle::Protocol0::INST, Python::Pickle::Protocol0::INT, Python::Pickle::Protocol0::LIST, Python::Pickle::Protocol0::LONG, Python::Pickle::Protocol0::MARK, Python::Pickle::Protocol0::NONE, Python::Pickle::Protocol0::OBJ, Python::Pickle::Protocol0::PERSID, Python::Pickle::Protocol0::POP, Python::Pickle::Protocol0::POP_MARK, Python::Pickle::Protocol0::PUT, Python::Pickle::Protocol0::REDUCE, Python::Pickle::Protocol0::SETITEM, Python::Pickle::Protocol0::STOP, Python::Pickle::Protocol0::STRING, Python::Pickle::Protocol0::TUPLE, Python::Pickle::Protocol0::UNICODE

Instance Attribute Summary

Attributes inherited from Protocol

#io

Instance Method Summary collapse

Methods inherited from Protocol4

#enter_frame, #initialize, #leave_frame, #read_binbytes8_instruction, #read_binunicode8_instruction, #read_frame, #read_frame_instruction, #read_short_binunicode_instruction, #read_uint64_le, #read_utf8_string

Methods inherited from Protocol3

#read_binbytes_instruction, #read_short_binbytes_instruction

Methods inherited from Protocol2

#read_ext1_instruction, #read_ext2_instruction, #read_ext4_instruction, #read_int_le, #read_long1_instruction, #read_long4_instruction, #read_proto_instruction, #read_uint16_le, #unpack_int_le

Methods inherited from Protocol1

#read_binfloat_instruction, #read_binget_instruction, #read_binint1_instruction, #read_binput_instruction, #read_binstring_instruction, #read_binunicode_instruction, #read_float64_be, #read_long_binget_instruction, #read_short_binstring_instruction, #read_uint32_le, #read_uint8

Methods inherited from Protocol0

#read_escaped_char, #read_float, #read_float_instruction, #read_get_instruction, #read_global_instruction, #read_hex_escaped_char, #read_inst_instruction, #read_int, #read_int_instruction, #read_long, #read_long_instruction, #read_nl_string, #read_persid_instruction, #read_put_instruction, #read_string, #read_string_instruction, #read_unicode_escaped_char, #read_unicode_escaped_char16, #read_unicode_escaped_char32, #read_unicode_instruction, #read_unicode_string

Methods inherited from Protocol

#initialize, #read

Constructor Details

This class inherits a constructor from Python::Pickle::Protocol4

Instance Method Details

#read_bytearray8_instructionInstructions::ByteArray8

Reads a BYTEARRAY8 instruction.

Returns:

Since:

  • 0.2.0



141
142
143
144
145
146
# File 'lib/python/pickle/protocol5.rb', line 141

def read_bytearray8_instruction
  length = read_uint64_le
  bytes  = @io.read(length)

  Instructions::ByteArray8.new(length,bytes)
end

#read_instructionInstruction

Reads an instruction from the pickle stream.

Returns:

Raises:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/python/pickle/protocol5.rb', line 40

def read_instruction
  case (opcode = @io.getbyte)
  #
  # Protocol 0 instructions
  #
  when MARK      then Instructions::MARK
  when STOP      then Instructions::STOP
  when POP       then Instructions::POP
  when POP_MARK  then Instructions::POP_MARK
  when DUP       then Instructions::DUP
  when FLOAT     then read_float_instruction
  when INT       then read_int_instruction
  when LONG      then read_long_instruction
  when NONE      then Instructions::NONE
  when REDUCE    then Instructions::REDUCE
  when STRING    then read_string_instruction
  when UNICODE   then read_unicode_instruction
  when APPEND    then Instructions::APPEND
  when BUILD     then Instructions::BUILD
  when GLOBAL    then read_global_instruction
  when DICT      then Instructions::DICT
  when GET       then read_get_instruction
  when LIST      then Instructions::LIST
  when PUT       then read_put_instruction
  when SETITEM   then Instructions::SETITEM
  when TUPLE     then Instructions::TUPLE
  when INST      then read_inst_instruction
  when OBJ       then Instructions::OBJ
  when PERSID    then read_persid_instruction
  when BINPERSID then Instructions::BINPERSID
  #
  # Protocol 1 instructions
  #
  when EMPTY_TUPLE     then Instructions::EMPTY_TUPLE
  when BINFLOAT        then read_binfloat_instruction
  when BININT1         then read_binint1_instruction
  when BINSTRING       then read_binstring_instruction
  when SHORT_BINSTRING then read_short_binstring_instruction
  when BINUNICODE      then read_binunicode_instruction
  when EMPTY_LIST      then Instructions::EMPTY_LIST
  when APPENDS         then Instructions::APPENDS
  when BINGET          then read_binget_instruction
  when LONG_BINGET     then read_long_binget_instruction
  when BINPUT          then read_binput_instruction
  when SETITEMS        then Instructions::SETITEMS
  when EMPTY_DICT      then Instructions::EMPTY_DICT
  #
  # Protocol 2 instructions
  #
  when PROTO    then read_proto_instruction
  when NEWOBJ   then Instructions::NEWOBJ
  when EXT1     then read_ext1_instruction
  when EXT2     then read_ext2_instruction
  when EXT4     then read_ext4_instruction
  when TUPLE1   then Instructions::TUPLE1
  when TUPLE2   then Instructions::TUPLE2
  when TUPLE3   then Instructions::TUPLE3
  when NEWTRUE  then Instructions::NEWTRUE
  when NEWFALSE then Instructions::NEWFALSE
  when LONG1    then read_long1_instruction
  when LONG4    then read_long4_instruction
  #
  # Protocol 3 instructions
  #
  when BINBYTES       then read_binbytes_instruction
  when SHORT_BINBYTES then read_short_binbytes_instruction
  #
  # Protocol 4 instructions
  #
  when SHORT_BINUNICODE then read_short_binunicode_instruction
  when BINUNICODE8      then read_binunicode8_instruction
  when BINBYTES8        then read_binbytes8_instruction
  when EMPTY_SET        then Instructions::EMPTY_SET
  when ADDITEMS         then Instructions::ADDITEMS
  when FROZENSET        then Instructions::FROZENSET
  when NEWOBJ_EX        then Instructions::NEWOBJ_EX
  when STACK_GLOBAL     then Instructions::STACK_GLOBAL
  when MEMOIZE          then Instructions::MEMOIZE
  when FRAME            then read_frame_instruction
  #
  # Protocol 5 instructions.
  #
  when BYTEARRAY8      then read_bytearray8_instruction
  when NEXT_BUFFER     then Instructions::NEXT_BUFFER
  when READONLY_BUFFER then Instructions::READONLY_BUFFER
  else
    raise(InvalidFormat,"invalid opcode (#{opcode.inspect}) for protocol 5")
  end
ensure
  if @io.eof? && !@io_stack.empty?
    leave_frame
  end
end