Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3....
File: pickle.py
save(k)
[1000] Fix | Delete
save(v)
[1001] Fix | Delete
write(SETITEM)
[1002] Fix | Delete
# else tmp is empty, and we're done
[1003] Fix | Delete
if n < self._BATCHSIZE:
[1004] Fix | Delete
return
[1005] Fix | Delete
[1006] Fix | Delete
def save_set(self, obj):
[1007] Fix | Delete
save = self.save
[1008] Fix | Delete
write = self.write
[1009] Fix | Delete
[1010] Fix | Delete
if self.proto < 4:
[1011] Fix | Delete
self.save_reduce(set, (list(obj),), obj=obj)
[1012] Fix | Delete
return
[1013] Fix | Delete
[1014] Fix | Delete
write(EMPTY_SET)
[1015] Fix | Delete
self.memoize(obj)
[1016] Fix | Delete
[1017] Fix | Delete
it = iter(obj)
[1018] Fix | Delete
while True:
[1019] Fix | Delete
batch = list(islice(it, self._BATCHSIZE))
[1020] Fix | Delete
n = len(batch)
[1021] Fix | Delete
if n > 0:
[1022] Fix | Delete
write(MARK)
[1023] Fix | Delete
for item in batch:
[1024] Fix | Delete
save(item)
[1025] Fix | Delete
write(ADDITEMS)
[1026] Fix | Delete
if n < self._BATCHSIZE:
[1027] Fix | Delete
return
[1028] Fix | Delete
dispatch[set] = save_set
[1029] Fix | Delete
[1030] Fix | Delete
def save_frozenset(self, obj):
[1031] Fix | Delete
save = self.save
[1032] Fix | Delete
write = self.write
[1033] Fix | Delete
[1034] Fix | Delete
if self.proto < 4:
[1035] Fix | Delete
self.save_reduce(frozenset, (list(obj),), obj=obj)
[1036] Fix | Delete
return
[1037] Fix | Delete
[1038] Fix | Delete
write(MARK)
[1039] Fix | Delete
for item in obj:
[1040] Fix | Delete
save(item)
[1041] Fix | Delete
[1042] Fix | Delete
if id(obj) in self.memo:
[1043] Fix | Delete
# If the object is already in the memo, this means it is
[1044] Fix | Delete
# recursive. In this case, throw away everything we put on the
[1045] Fix | Delete
# stack, and fetch the object back from the memo.
[1046] Fix | Delete
write(POP_MARK + self.get(self.memo[id(obj)][0]))
[1047] Fix | Delete
return
[1048] Fix | Delete
[1049] Fix | Delete
write(FROZENSET)
[1050] Fix | Delete
self.memoize(obj)
[1051] Fix | Delete
dispatch[frozenset] = save_frozenset
[1052] Fix | Delete
[1053] Fix | Delete
def save_global(self, obj, name=None):
[1054] Fix | Delete
write = self.write
[1055] Fix | Delete
memo = self.memo
[1056] Fix | Delete
[1057] Fix | Delete
if name is None:
[1058] Fix | Delete
name = getattr(obj, '__qualname__', None)
[1059] Fix | Delete
if name is None:
[1060] Fix | Delete
name = obj.__name__
[1061] Fix | Delete
[1062] Fix | Delete
module_name = whichmodule(obj, name)
[1063] Fix | Delete
try:
[1064] Fix | Delete
__import__(module_name, level=0)
[1065] Fix | Delete
module = sys.modules[module_name]
[1066] Fix | Delete
obj2, parent = _getattribute(module, name)
[1067] Fix | Delete
except (ImportError, KeyError, AttributeError):
[1068] Fix | Delete
raise PicklingError(
[1069] Fix | Delete
"Can't pickle %r: it's not found as %s.%s" %
[1070] Fix | Delete
(obj, module_name, name)) from None
[1071] Fix | Delete
else:
[1072] Fix | Delete
if obj2 is not obj:
[1073] Fix | Delete
raise PicklingError(
[1074] Fix | Delete
"Can't pickle %r: it's not the same object as %s.%s" %
[1075] Fix | Delete
(obj, module_name, name))
[1076] Fix | Delete
[1077] Fix | Delete
if self.proto >= 2:
[1078] Fix | Delete
code = _extension_registry.get((module_name, name))
[1079] Fix | Delete
if code:
[1080] Fix | Delete
assert code > 0
[1081] Fix | Delete
if code <= 0xff:
[1082] Fix | Delete
write(EXT1 + pack("<B", code))
[1083] Fix | Delete
elif code <= 0xffff:
[1084] Fix | Delete
write(EXT2 + pack("<H", code))
[1085] Fix | Delete
else:
[1086] Fix | Delete
write(EXT4 + pack("<i", code))
[1087] Fix | Delete
return
[1088] Fix | Delete
lastname = name.rpartition('.')[2]
[1089] Fix | Delete
if parent is module:
[1090] Fix | Delete
name = lastname
[1091] Fix | Delete
# Non-ASCII identifiers are supported only with protocols >= 3.
[1092] Fix | Delete
if self.proto >= 4:
[1093] Fix | Delete
self.save(module_name)
[1094] Fix | Delete
self.save(name)
[1095] Fix | Delete
write(STACK_GLOBAL)
[1096] Fix | Delete
elif parent is not module:
[1097] Fix | Delete
self.save_reduce(getattr, (parent, lastname))
[1098] Fix | Delete
elif self.proto >= 3:
[1099] Fix | Delete
write(GLOBAL + bytes(module_name, "utf-8") + b'\n' +
[1100] Fix | Delete
bytes(name, "utf-8") + b'\n')
[1101] Fix | Delete
else:
[1102] Fix | Delete
if self.fix_imports:
[1103] Fix | Delete
r_name_mapping = _compat_pickle.REVERSE_NAME_MAPPING
[1104] Fix | Delete
r_import_mapping = _compat_pickle.REVERSE_IMPORT_MAPPING
[1105] Fix | Delete
if (module_name, name) in r_name_mapping:
[1106] Fix | Delete
module_name, name = r_name_mapping[(module_name, name)]
[1107] Fix | Delete
elif module_name in r_import_mapping:
[1108] Fix | Delete
module_name = r_import_mapping[module_name]
[1109] Fix | Delete
try:
[1110] Fix | Delete
write(GLOBAL + bytes(module_name, "ascii") + b'\n' +
[1111] Fix | Delete
bytes(name, "ascii") + b'\n')
[1112] Fix | Delete
except UnicodeEncodeError:
[1113] Fix | Delete
raise PicklingError(
[1114] Fix | Delete
"can't pickle global identifier '%s.%s' using "
[1115] Fix | Delete
"pickle protocol %i" % (module, name, self.proto)) from None
[1116] Fix | Delete
[1117] Fix | Delete
self.memoize(obj)
[1118] Fix | Delete
[1119] Fix | Delete
def save_type(self, obj):
[1120] Fix | Delete
if obj is type(None):
[1121] Fix | Delete
return self.save_reduce(type, (None,), obj=obj)
[1122] Fix | Delete
elif obj is type(NotImplemented):
[1123] Fix | Delete
return self.save_reduce(type, (NotImplemented,), obj=obj)
[1124] Fix | Delete
elif obj is type(...):
[1125] Fix | Delete
return self.save_reduce(type, (...,), obj=obj)
[1126] Fix | Delete
return self.save_global(obj)
[1127] Fix | Delete
[1128] Fix | Delete
dispatch[FunctionType] = save_global
[1129] Fix | Delete
dispatch[type] = save_type
[1130] Fix | Delete
[1131] Fix | Delete
[1132] Fix | Delete
# Unpickling machinery
[1133] Fix | Delete
[1134] Fix | Delete
class _Unpickler:
[1135] Fix | Delete
[1136] Fix | Delete
def __init__(self, file, *, fix_imports=True,
[1137] Fix | Delete
encoding="ASCII", errors="strict", buffers=None):
[1138] Fix | Delete
"""This takes a binary file for reading a pickle data stream.
[1139] Fix | Delete
[1140] Fix | Delete
The protocol version of the pickle is detected automatically, so
[1141] Fix | Delete
no proto argument is needed.
[1142] Fix | Delete
[1143] Fix | Delete
The argument *file* must have two methods, a read() method that
[1144] Fix | Delete
takes an integer argument, and a readline() method that requires
[1145] Fix | Delete
no arguments. Both methods should return bytes. Thus *file*
[1146] Fix | Delete
can be a binary file object opened for reading, an io.BytesIO
[1147] Fix | Delete
object, or any other custom object that meets this interface.
[1148] Fix | Delete
[1149] Fix | Delete
The file-like object must have two methods, a read() method
[1150] Fix | Delete
that takes an integer argument, and a readline() method that
[1151] Fix | Delete
requires no arguments. Both methods should return bytes.
[1152] Fix | Delete
Thus file-like object can be a binary file object opened for
[1153] Fix | Delete
reading, a BytesIO object, or any other custom object that
[1154] Fix | Delete
meets this interface.
[1155] Fix | Delete
[1156] Fix | Delete
If *buffers* is not None, it should be an iterable of buffer-enabled
[1157] Fix | Delete
objects that is consumed each time the pickle stream references
[1158] Fix | Delete
an out-of-band buffer view. Such buffers have been given in order
[1159] Fix | Delete
to the *buffer_callback* of a Pickler object.
[1160] Fix | Delete
[1161] Fix | Delete
If *buffers* is None (the default), then the buffers are taken
[1162] Fix | Delete
from the pickle stream, assuming they are serialized there.
[1163] Fix | Delete
It is an error for *buffers* to be None if the pickle stream
[1164] Fix | Delete
was produced with a non-None *buffer_callback*.
[1165] Fix | Delete
[1166] Fix | Delete
Other optional arguments are *fix_imports*, *encoding* and
[1167] Fix | Delete
*errors*, which are used to control compatibility support for
[1168] Fix | Delete
pickle stream generated by Python 2. If *fix_imports* is True,
[1169] Fix | Delete
pickle will try to map the old Python 2 names to the new names
[1170] Fix | Delete
used in Python 3. The *encoding* and *errors* tell pickle how
[1171] Fix | Delete
to decode 8-bit string instances pickled by Python 2; these
[1172] Fix | Delete
default to 'ASCII' and 'strict', respectively. *encoding* can be
[1173] Fix | Delete
'bytes' to read theses 8-bit string instances as bytes objects.
[1174] Fix | Delete
"""
[1175] Fix | Delete
self._buffers = iter(buffers) if buffers is not None else None
[1176] Fix | Delete
self._file_readline = file.readline
[1177] Fix | Delete
self._file_read = file.read
[1178] Fix | Delete
self.memo = {}
[1179] Fix | Delete
self.encoding = encoding
[1180] Fix | Delete
self.errors = errors
[1181] Fix | Delete
self.proto = 0
[1182] Fix | Delete
self.fix_imports = fix_imports
[1183] Fix | Delete
[1184] Fix | Delete
def load(self):
[1185] Fix | Delete
"""Read a pickled object representation from the open file.
[1186] Fix | Delete
[1187] Fix | Delete
Return the reconstituted object hierarchy specified in the file.
[1188] Fix | Delete
"""
[1189] Fix | Delete
# Check whether Unpickler was initialized correctly. This is
[1190] Fix | Delete
# only needed to mimic the behavior of _pickle.Unpickler.dump().
[1191] Fix | Delete
if not hasattr(self, "_file_read"):
[1192] Fix | Delete
raise UnpicklingError("Unpickler.__init__() was not called by "
[1193] Fix | Delete
"%s.__init__()" % (self.__class__.__name__,))
[1194] Fix | Delete
self._unframer = _Unframer(self._file_read, self._file_readline)
[1195] Fix | Delete
self.read = self._unframer.read
[1196] Fix | Delete
self.readinto = self._unframer.readinto
[1197] Fix | Delete
self.readline = self._unframer.readline
[1198] Fix | Delete
self.metastack = []
[1199] Fix | Delete
self.stack = []
[1200] Fix | Delete
self.append = self.stack.append
[1201] Fix | Delete
self.proto = 0
[1202] Fix | Delete
read = self.read
[1203] Fix | Delete
dispatch = self.dispatch
[1204] Fix | Delete
try:
[1205] Fix | Delete
while True:
[1206] Fix | Delete
key = read(1)
[1207] Fix | Delete
if not key:
[1208] Fix | Delete
raise EOFError
[1209] Fix | Delete
assert isinstance(key, bytes_types)
[1210] Fix | Delete
dispatch[key[0]](self)
[1211] Fix | Delete
except _Stop as stopinst:
[1212] Fix | Delete
return stopinst.value
[1213] Fix | Delete
[1214] Fix | Delete
# Return a list of items pushed in the stack after last MARK instruction.
[1215] Fix | Delete
def pop_mark(self):
[1216] Fix | Delete
items = self.stack
[1217] Fix | Delete
self.stack = self.metastack.pop()
[1218] Fix | Delete
self.append = self.stack.append
[1219] Fix | Delete
return items
[1220] Fix | Delete
[1221] Fix | Delete
def persistent_load(self, pid):
[1222] Fix | Delete
raise UnpicklingError("unsupported persistent id encountered")
[1223] Fix | Delete
[1224] Fix | Delete
dispatch = {}
[1225] Fix | Delete
[1226] Fix | Delete
def load_proto(self):
[1227] Fix | Delete
proto = self.read(1)[0]
[1228] Fix | Delete
if not 0 <= proto <= HIGHEST_PROTOCOL:
[1229] Fix | Delete
raise ValueError("unsupported pickle protocol: %d" % proto)
[1230] Fix | Delete
self.proto = proto
[1231] Fix | Delete
dispatch[PROTO[0]] = load_proto
[1232] Fix | Delete
[1233] Fix | Delete
def load_frame(self):
[1234] Fix | Delete
frame_size, = unpack('<Q', self.read(8))
[1235] Fix | Delete
if frame_size > sys.maxsize:
[1236] Fix | Delete
raise ValueError("frame size > sys.maxsize: %d" % frame_size)
[1237] Fix | Delete
self._unframer.load_frame(frame_size)
[1238] Fix | Delete
dispatch[FRAME[0]] = load_frame
[1239] Fix | Delete
[1240] Fix | Delete
def load_persid(self):
[1241] Fix | Delete
try:
[1242] Fix | Delete
pid = self.readline()[:-1].decode("ascii")
[1243] Fix | Delete
except UnicodeDecodeError:
[1244] Fix | Delete
raise UnpicklingError(
[1245] Fix | Delete
"persistent IDs in protocol 0 must be ASCII strings")
[1246] Fix | Delete
self.append(self.persistent_load(pid))
[1247] Fix | Delete
dispatch[PERSID[0]] = load_persid
[1248] Fix | Delete
[1249] Fix | Delete
def load_binpersid(self):
[1250] Fix | Delete
pid = self.stack.pop()
[1251] Fix | Delete
self.append(self.persistent_load(pid))
[1252] Fix | Delete
dispatch[BINPERSID[0]] = load_binpersid
[1253] Fix | Delete
[1254] Fix | Delete
def load_none(self):
[1255] Fix | Delete
self.append(None)
[1256] Fix | Delete
dispatch[NONE[0]] = load_none
[1257] Fix | Delete
[1258] Fix | Delete
def load_false(self):
[1259] Fix | Delete
self.append(False)
[1260] Fix | Delete
dispatch[NEWFALSE[0]] = load_false
[1261] Fix | Delete
[1262] Fix | Delete
def load_true(self):
[1263] Fix | Delete
self.append(True)
[1264] Fix | Delete
dispatch[NEWTRUE[0]] = load_true
[1265] Fix | Delete
[1266] Fix | Delete
def load_int(self):
[1267] Fix | Delete
data = self.readline()
[1268] Fix | Delete
if data == FALSE[1:]:
[1269] Fix | Delete
val = False
[1270] Fix | Delete
elif data == TRUE[1:]:
[1271] Fix | Delete
val = True
[1272] Fix | Delete
else:
[1273] Fix | Delete
val = int(data, 0)
[1274] Fix | Delete
self.append(val)
[1275] Fix | Delete
dispatch[INT[0]] = load_int
[1276] Fix | Delete
[1277] Fix | Delete
def load_binint(self):
[1278] Fix | Delete
self.append(unpack('<i', self.read(4))[0])
[1279] Fix | Delete
dispatch[BININT[0]] = load_binint
[1280] Fix | Delete
[1281] Fix | Delete
def load_binint1(self):
[1282] Fix | Delete
self.append(self.read(1)[0])
[1283] Fix | Delete
dispatch[BININT1[0]] = load_binint1
[1284] Fix | Delete
[1285] Fix | Delete
def load_binint2(self):
[1286] Fix | Delete
self.append(unpack('<H', self.read(2))[0])
[1287] Fix | Delete
dispatch[BININT2[0]] = load_binint2
[1288] Fix | Delete
[1289] Fix | Delete
def load_long(self):
[1290] Fix | Delete
val = self.readline()[:-1]
[1291] Fix | Delete
if val and val[-1] == b'L'[0]:
[1292] Fix | Delete
val = val[:-1]
[1293] Fix | Delete
self.append(int(val, 0))
[1294] Fix | Delete
dispatch[LONG[0]] = load_long
[1295] Fix | Delete
[1296] Fix | Delete
def load_long1(self):
[1297] Fix | Delete
n = self.read(1)[0]
[1298] Fix | Delete
data = self.read(n)
[1299] Fix | Delete
self.append(decode_long(data))
[1300] Fix | Delete
dispatch[LONG1[0]] = load_long1
[1301] Fix | Delete
[1302] Fix | Delete
def load_long4(self):
[1303] Fix | Delete
n, = unpack('<i', self.read(4))
[1304] Fix | Delete
if n < 0:
[1305] Fix | Delete
# Corrupt or hostile pickle -- we never write one like this
[1306] Fix | Delete
raise UnpicklingError("LONG pickle has negative byte count")
[1307] Fix | Delete
data = self.read(n)
[1308] Fix | Delete
self.append(decode_long(data))
[1309] Fix | Delete
dispatch[LONG4[0]] = load_long4
[1310] Fix | Delete
[1311] Fix | Delete
def load_float(self):
[1312] Fix | Delete
self.append(float(self.readline()[:-1]))
[1313] Fix | Delete
dispatch[FLOAT[0]] = load_float
[1314] Fix | Delete
[1315] Fix | Delete
def load_binfloat(self):
[1316] Fix | Delete
self.append(unpack('>d', self.read(8))[0])
[1317] Fix | Delete
dispatch[BINFLOAT[0]] = load_binfloat
[1318] Fix | Delete
[1319] Fix | Delete
def _decode_string(self, value):
[1320] Fix | Delete
# Used to allow strings from Python 2 to be decoded either as
[1321] Fix | Delete
# bytes or Unicode strings. This should be used only with the
[1322] Fix | Delete
# STRING, BINSTRING and SHORT_BINSTRING opcodes.
[1323] Fix | Delete
if self.encoding == "bytes":
[1324] Fix | Delete
return value
[1325] Fix | Delete
else:
[1326] Fix | Delete
return value.decode(self.encoding, self.errors)
[1327] Fix | Delete
[1328] Fix | Delete
def load_string(self):
[1329] Fix | Delete
data = self.readline()[:-1]
[1330] Fix | Delete
# Strip outermost quotes
[1331] Fix | Delete
if len(data) >= 2 and data[0] == data[-1] and data[0] in b'"\'':
[1332] Fix | Delete
data = data[1:-1]
[1333] Fix | Delete
else:
[1334] Fix | Delete
raise UnpicklingError("the STRING opcode argument must be quoted")
[1335] Fix | Delete
self.append(self._decode_string(codecs.escape_decode(data)[0]))
[1336] Fix | Delete
dispatch[STRING[0]] = load_string
[1337] Fix | Delete
[1338] Fix | Delete
def load_binstring(self):
[1339] Fix | Delete
# Deprecated BINSTRING uses signed 32-bit length
[1340] Fix | Delete
len, = unpack('<i', self.read(4))
[1341] Fix | Delete
if len < 0:
[1342] Fix | Delete
raise UnpicklingError("BINSTRING pickle has negative byte count")
[1343] Fix | Delete
data = self.read(len)
[1344] Fix | Delete
self.append(self._decode_string(data))
[1345] Fix | Delete
dispatch[BINSTRING[0]] = load_binstring
[1346] Fix | Delete
[1347] Fix | Delete
def load_binbytes(self):
[1348] Fix | Delete
len, = unpack('<I', self.read(4))
[1349] Fix | Delete
if len > maxsize:
[1350] Fix | Delete
raise UnpicklingError("BINBYTES exceeds system's maximum size "
[1351] Fix | Delete
"of %d bytes" % maxsize)
[1352] Fix | Delete
self.append(self.read(len))
[1353] Fix | Delete
dispatch[BINBYTES[0]] = load_binbytes
[1354] Fix | Delete
[1355] Fix | Delete
def load_unicode(self):
[1356] Fix | Delete
self.append(str(self.readline()[:-1], 'raw-unicode-escape'))
[1357] Fix | Delete
dispatch[UNICODE[0]] = load_unicode
[1358] Fix | Delete
[1359] Fix | Delete
def load_binunicode(self):
[1360] Fix | Delete
len, = unpack('<I', self.read(4))
[1361] Fix | Delete
if len > maxsize:
[1362] Fix | Delete
raise UnpicklingError("BINUNICODE exceeds system's maximum size "
[1363] Fix | Delete
"of %d bytes" % maxsize)
[1364] Fix | Delete
self.append(str(self.read(len), 'utf-8', 'surrogatepass'))
[1365] Fix | Delete
dispatch[BINUNICODE[0]] = load_binunicode
[1366] Fix | Delete
[1367] Fix | Delete
def load_binunicode8(self):
[1368] Fix | Delete
len, = unpack('<Q', self.read(8))
[1369] Fix | Delete
if len > maxsize:
[1370] Fix | Delete
raise UnpicklingError("BINUNICODE8 exceeds system's maximum size "
[1371] Fix | Delete
"of %d bytes" % maxsize)
[1372] Fix | Delete
self.append(str(self.read(len), 'utf-8', 'surrogatepass'))
[1373] Fix | Delete
dispatch[BINUNICODE8[0]] = load_binunicode8
[1374] Fix | Delete
[1375] Fix | Delete
def load_binbytes8(self):
[1376] Fix | Delete
len, = unpack('<Q', self.read(8))
[1377] Fix | Delete
if len > maxsize:
[1378] Fix | Delete
raise UnpicklingError("BINBYTES8 exceeds system's maximum size "
[1379] Fix | Delete
"of %d bytes" % maxsize)
[1380] Fix | Delete
self.append(self.read(len))
[1381] Fix | Delete
dispatch[BINBYTES8[0]] = load_binbytes8
[1382] Fix | Delete
[1383] Fix | Delete
def load_bytearray8(self):
[1384] Fix | Delete
len, = unpack('<Q', self.read(8))
[1385] Fix | Delete
if len > maxsize:
[1386] Fix | Delete
raise UnpicklingError("BYTEARRAY8 exceeds system's maximum size "
[1387] Fix | Delete
"of %d bytes" % maxsize)
[1388] Fix | Delete
b = bytearray(len)
[1389] Fix | Delete
self.readinto(b)
[1390] Fix | Delete
self.append(b)
[1391] Fix | Delete
dispatch[BYTEARRAY8[0]] = load_bytearray8
[1392] Fix | Delete
[1393] Fix | Delete
def load_next_buffer(self):
[1394] Fix | Delete
if self._buffers is None:
[1395] Fix | Delete
raise UnpicklingError("pickle stream refers to out-of-band data "
[1396] Fix | Delete
"but no *buffers* argument was given")
[1397] Fix | Delete
try:
[1398] Fix | Delete
buf = next(self._buffers)
[1399] Fix | Delete
except StopIteration:
[1400] Fix | Delete
raise UnpicklingError("not enough out-of-band buffers")
[1401] Fix | Delete
self.append(buf)
[1402] Fix | Delete
dispatch[NEXT_BUFFER[0]] = load_next_buffer
[1403] Fix | Delete
[1404] Fix | Delete
def load_readonly_buffer(self):
[1405] Fix | Delete
buf = self.stack[-1]
[1406] Fix | Delete
with memoryview(buf) as m:
[1407] Fix | Delete
if not m.readonly:
[1408] Fix | Delete
self.stack[-1] = m.toreadonly()
[1409] Fix | Delete
dispatch[READONLY_BUFFER[0]] = load_readonly_buffer
[1410] Fix | Delete
[1411] Fix | Delete
def load_short_binstring(self):
[1412] Fix | Delete
len = self.read(1)[0]
[1413] Fix | Delete
data = self.read(len)
[1414] Fix | Delete
self.append(self._decode_string(data))
[1415] Fix | Delete
dispatch[SHORT_BINSTRING[0]] = load_short_binstring
[1416] Fix | Delete
[1417] Fix | Delete
def load_short_binbytes(self):
[1418] Fix | Delete
len = self.read(1)[0]
[1419] Fix | Delete
self.append(self.read(len))
[1420] Fix | Delete
dispatch[SHORT_BINBYTES[0]] = load_short_binbytes
[1421] Fix | Delete
[1422] Fix | Delete
def load_short_binunicode(self):
[1423] Fix | Delete
len = self.read(1)[0]
[1424] Fix | Delete
self.append(str(self.read(len), 'utf-8', 'surrogatepass'))
[1425] Fix | Delete
dispatch[SHORT_BINUNICODE[0]] = load_short_binunicode
[1426] Fix | Delete
[1427] Fix | Delete
def load_tuple(self):
[1428] Fix | Delete
items = self.pop_mark()
[1429] Fix | Delete
self.append(tuple(items))
[1430] Fix | Delete
dispatch[TUPLE[0]] = load_tuple
[1431] Fix | Delete
[1432] Fix | Delete
def load_empty_tuple(self):
[1433] Fix | Delete
self.append(())
[1434] Fix | Delete
dispatch[EMPTY_TUPLE[0]] = load_empty_tuple
[1435] Fix | Delete
[1436] Fix | Delete
def load_tuple1(self):
[1437] Fix | Delete
self.stack[-1] = (self.stack[-1],)
[1438] Fix | Delete
dispatch[TUPLE1[0]] = load_tuple1
[1439] Fix | Delete
[1440] Fix | Delete
def load_tuple2(self):
[1441] Fix | Delete
self.stack[-2:] = [(self.stack[-2], self.stack[-1])]
[1442] Fix | Delete
dispatch[TUPLE2[0]] = load_tuple2
[1443] Fix | Delete
[1444] Fix | Delete
def load_tuple3(self):
[1445] Fix | Delete
self.stack[-3:] = [(self.stack[-3], self.stack[-2], self.stack[-1])]
[1446] Fix | Delete
dispatch[TUPLE3[0]] = load_tuple3
[1447] Fix | Delete
[1448] Fix | Delete
def load_empty_list(self):
[1449] Fix | Delete
self.append([])
[1450] Fix | Delete
dispatch[EMPTY_LIST[0]] = load_empty_list
[1451] Fix | Delete
[1452] Fix | Delete
def load_empty_dictionary(self):
[1453] Fix | Delete
self.append({})
[1454] Fix | Delete
dispatch[EMPTY_DICT[0]] = load_empty_dictionary
[1455] Fix | Delete
[1456] Fix | Delete
def load_empty_set(self):
[1457] Fix | Delete
self.append(set())
[1458] Fix | Delete
dispatch[EMPTY_SET[0]] = load_empty_set
[1459] Fix | Delete
[1460] Fix | Delete
def load_frozenset(self):
[1461] Fix | Delete
items = self.pop_mark()
[1462] Fix | Delete
self.append(frozenset(items))
[1463] Fix | Delete
dispatch[FROZENSET[0]] = load_frozenset
[1464] Fix | Delete
[1465] Fix | Delete
def load_list(self):
[1466] Fix | Delete
items = self.pop_mark()
[1467] Fix | Delete
self.append(items)
[1468] Fix | Delete
dispatch[LIST[0]] = load_list
[1469] Fix | Delete
[1470] Fix | Delete
def load_dict(self):
[1471] Fix | Delete
items = self.pop_mark()
[1472] Fix | Delete
d = {items[i]: items[i+1]
[1473] Fix | Delete
for i in range(0, len(items), 2)}
[1474] Fix | Delete
self.append(d)
[1475] Fix | Delete
dispatch[DICT[0]] = load_dict
[1476] Fix | Delete
[1477] Fix | Delete
# INST and OBJ differ only in how they get a class object. It's not
[1478] Fix | Delete
# only sensible to do the rest in a common routine, the two routines
[1479] Fix | Delete
# previously diverged and grew different bugs.
[1480] Fix | Delete
# klass is the class to instantiate, and k points to the topmost mark
[1481] Fix | Delete
# object, following which are the arguments for klass.__init__.
[1482] Fix | Delete
def _instantiate(self, klass, args):
[1483] Fix | Delete
if (args or not isinstance(klass, type) or
[1484] Fix | Delete
hasattr(klass, "__getinitargs__")):
[1485] Fix | Delete
try:
[1486] Fix | Delete
value = klass(*args)
[1487] Fix | Delete
except TypeError as err:
[1488] Fix | Delete
raise TypeError("in constructor for %s: %s" %
[1489] Fix | Delete
(klass.__name__, str(err)), sys.exc_info()[2])
[1490] Fix | Delete
else:
[1491] Fix | Delete
value = klass.__new__(klass)
[1492] Fix | Delete
self.append(value)
[1493] Fix | Delete
[1494] Fix | Delete
def load_inst(self):
[1495] Fix | Delete
module = self.readline()[:-1].decode("ascii")
[1496] Fix | Delete
name = self.readline()[:-1].decode("ascii")
[1497] Fix | Delete
klass = self.find_class(module, name)
[1498] Fix | Delete
self._instantiate(klass, self.pop_mark())
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function