Changeset 388 for python/vendor/current/Lib/pickle.py
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Lib/pickle.py
r2 r388 25 25 """ 26 26 27 __version__ = "$Revision: 65524$" # Code version27 __version__ = "$Revision: 72223 $" # Code version 28 28 29 29 from types import * … … 287 287 return 288 288 289 # Check for a class with a custom metaclass; treat as regular class290 try:291 issc = issubclass(t, TypeType)292 except TypeError: # t is not a class (old Boost; see SF #502085)293 issc = 0294 if issc:295 self.save_global(obj)296 return297 298 289 # Check copy_reg.dispatch_table 299 290 reduce = dispatch_table.get(t) … … 301 292 rv = reduce(obj) 302 293 else: 294 # Check for a class with a custom metaclass; treat as regular class 295 try: 296 issc = issubclass(t, TypeType) 297 except TypeError: # t is not a class (old Boost; see SF #502085) 298 issc = 0 299 if issc: 300 self.save_global(obj) 301 return 302 303 303 # Check for a __reduce_ex__ method, fall back to __reduce__ 304 304 reduce = getattr(obj, "__reduce_ex__", None) … … 502 502 dispatch[UnicodeType] = save_unicode 503 503 504 if StringType ==UnicodeType:504 if StringType is UnicodeType: 505 505 # This is true for Jython 506 506 def save_string(self, obj, pack=struct.pack): … … 963 963 for q in "\"'": # double or single quote 964 964 if rep.startswith(q): 965 if not rep.endswith(q):965 if len(rep) < 2 or not rep.endswith(q): 966 966 raise ValueError, "insecure string pickle" 967 967 rep = rep[len(q):-len(q)] … … 1222 1222 if state: 1223 1223 try: 1224 inst.__dict__.update(state) 1224 d = inst.__dict__ 1225 try: 1226 for k, v in state.iteritems(): 1227 d[intern(k)] = v 1228 # keys in state don't have to be strings 1229 # don't blow up, but don't go out of our way 1230 except TypeError: 1231 d.update(state) 1232 1225 1233 except RuntimeError: 1226 1234 # XXX In restricted execution, the instance's __dict__
Note:
See TracChangeset
for help on using the changeset viewer.