mirror of
				https://github.com/python/cpython.git
				synced 2025-10-29 04:35:05 +00:00 
			
		
		
		
	Revert previous checkin.
This commit is contained in:
		
							parent
							
								
									f715366f23
								
							
						
					
					
						commit
						fe59dc1bd8
					
				
					 2 changed files with 34 additions and 34 deletions
				
			
		|  | @ -288,7 +288,7 @@ def save(self, obj): | ||||||
| 
 | 
 | ||||||
|         # Check for a class with a custom metaclass; treat as regular class |         # Check for a class with a custom metaclass; treat as regular class | ||||||
|         try: |         try: | ||||||
|             issc = issubclass(t, type) |             issc = issubclass(t, TypeType) | ||||||
|         except TypeError: # t is not a class (old Boost; see SF #502085) |         except TypeError: # t is not a class (old Boost; see SF #502085) | ||||||
|             issc = 0 |             issc = 0 | ||||||
|         if issc: |         if issc: | ||||||
|  | @ -313,12 +313,12 @@ def save(self, obj): | ||||||
|                                         (t.__name__, obj)) |                                         (t.__name__, obj)) | ||||||
| 
 | 
 | ||||||
|         # Check for string returned by reduce(), meaning "save as global" |         # Check for string returned by reduce(), meaning "save as global" | ||||||
|         if type(rv) is str: |         if type(rv) is StringType: | ||||||
|             self.save_global(obj, rv) |             self.save_global(obj, rv) | ||||||
|             return |             return | ||||||
| 
 | 
 | ||||||
|         # Assert that reduce() returned a tuple |         # Assert that reduce() returned a tuple | ||||||
|         if type(rv) is not tuple: |         if type(rv) is not TupleType: | ||||||
|             raise PicklingError("%s must return string or tuple" % reduce) |             raise PicklingError("%s must return string or tuple" % reduce) | ||||||
| 
 | 
 | ||||||
|         # Assert that it returned an appropriately sized tuple |         # Assert that it returned an appropriately sized tuple | ||||||
|  | @ -347,7 +347,7 @@ def save_reduce(self, func, args, state=None, | ||||||
|         # This API is called by some subclasses |         # This API is called by some subclasses | ||||||
| 
 | 
 | ||||||
|         # Assert that args is a tuple or None |         # Assert that args is a tuple or None | ||||||
|         if not isinstance(args, tuple): |         if not isinstance(args, TupleType): | ||||||
|             raise PicklingError("args from reduce() should be a tuple") |             raise PicklingError("args from reduce() should be a tuple") | ||||||
| 
 | 
 | ||||||
|         # Assert that func is callable |         # Assert that func is callable | ||||||
|  | @ -425,7 +425,7 @@ def save_reduce(self, func, args, state=None, | ||||||
| 
 | 
 | ||||||
|     def save_none(self, obj): |     def save_none(self, obj): | ||||||
|         self.write(NONE) |         self.write(NONE) | ||||||
|     dispatch[type(None)] = save_none |     dispatch[NoneType] = save_none | ||||||
| 
 | 
 | ||||||
|     def save_bool(self, obj): |     def save_bool(self, obj): | ||||||
|         if self.proto >= 2: |         if self.proto >= 2: | ||||||
|  | @ -456,7 +456,7 @@ def save_int(self, obj, pack=struct.pack): | ||||||
|                 return |                 return | ||||||
|         # Text pickle, or int too big to fit in signed 4-byte format. |         # Text pickle, or int too big to fit in signed 4-byte format. | ||||||
|         self.write(INT + repr(obj) + '\n') |         self.write(INT + repr(obj) + '\n') | ||||||
|     dispatch[int] = save_int |     dispatch[IntType] = save_int | ||||||
| 
 | 
 | ||||||
|     def save_long(self, obj, pack=struct.pack): |     def save_long(self, obj, pack=struct.pack): | ||||||
|         if self.proto >= 2: |         if self.proto >= 2: | ||||||
|  | @ -468,14 +468,14 @@ def save_long(self, obj, pack=struct.pack): | ||||||
|                 self.write(LONG4 + pack("<i", n) + bytes) |                 self.write(LONG4 + pack("<i", n) + bytes) | ||||||
|             return |             return | ||||||
|         self.write(LONG + repr(obj) + '\n') |         self.write(LONG + repr(obj) + '\n') | ||||||
|     dispatch[long] = save_long |     dispatch[LongType] = save_long | ||||||
| 
 | 
 | ||||||
|     def save_float(self, obj, pack=struct.pack): |     def save_float(self, obj, pack=struct.pack): | ||||||
|         if self.bin: |         if self.bin: | ||||||
|             self.write(BINFLOAT + pack('>d', obj)) |             self.write(BINFLOAT + pack('>d', obj)) | ||||||
|         else: |         else: | ||||||
|             self.write(FLOAT + repr(obj) + '\n') |             self.write(FLOAT + repr(obj) + '\n') | ||||||
|     dispatch[float] = save_float |     dispatch[FloatType] = save_float | ||||||
| 
 | 
 | ||||||
|     def save_string(self, obj, pack=struct.pack): |     def save_string(self, obj, pack=struct.pack): | ||||||
|         if self.bin: |         if self.bin: | ||||||
|  | @ -487,7 +487,7 @@ def save_string(self, obj, pack=struct.pack): | ||||||
|         else: |         else: | ||||||
|             self.write(STRING + repr(obj) + '\n') |             self.write(STRING + repr(obj) + '\n') | ||||||
|         self.memoize(obj) |         self.memoize(obj) | ||||||
|     dispatch[str] = save_string |     dispatch[StringType] = save_string | ||||||
| 
 | 
 | ||||||
|     def save_unicode(self, obj, pack=struct.pack): |     def save_unicode(self, obj, pack=struct.pack): | ||||||
|         if self.bin: |         if self.bin: | ||||||
|  | @ -501,7 +501,7 @@ def save_unicode(self, obj, pack=struct.pack): | ||||||
|         self.memoize(obj) |         self.memoize(obj) | ||||||
|     dispatch[UnicodeType] = save_unicode |     dispatch[UnicodeType] = save_unicode | ||||||
| 
 | 
 | ||||||
|     if str == UnicodeType: |     if StringType == UnicodeType: | ||||||
|         # This is true for Jython |         # This is true for Jython | ||||||
|         def save_string(self, obj, pack=struct.pack): |         def save_string(self, obj, pack=struct.pack): | ||||||
|             unicode = obj.isunicode() |             unicode = obj.isunicode() | ||||||
|  | @ -527,7 +527,7 @@ def save_string(self, obj, pack=struct.pack): | ||||||
|                 else: |                 else: | ||||||
|                     self.write(STRING + repr(obj) + '\n') |                     self.write(STRING + repr(obj) + '\n') | ||||||
|             self.memoize(obj) |             self.memoize(obj) | ||||||
|         dispatch[str] = save_string |         dispatch[StringType] = save_string | ||||||
| 
 | 
 | ||||||
|     def save_tuple(self, obj): |     def save_tuple(self, obj): | ||||||
|         write = self.write |         write = self.write | ||||||
|  | @ -580,7 +580,7 @@ def save_tuple(self, obj): | ||||||
|         self.write(TUPLE) |         self.write(TUPLE) | ||||||
|         self.memoize(obj) |         self.memoize(obj) | ||||||
| 
 | 
 | ||||||
|     dispatch[tuple] = save_tuple |     dispatch[TupleType] = save_tuple | ||||||
| 
 | 
 | ||||||
|     # save_empty_tuple() isn't used by anything in Python 2.3.  However, I |     # save_empty_tuple() isn't used by anything in Python 2.3.  However, I | ||||||
|     # found a Pickler subclass in Zope3 that calls it, so it's not harmless |     # found a Pickler subclass in Zope3 that calls it, so it's not harmless | ||||||
|  | @ -599,7 +599,7 @@ def save_list(self, obj): | ||||||
|         self.memoize(obj) |         self.memoize(obj) | ||||||
|         self._batch_appends(iter(obj)) |         self._batch_appends(iter(obj)) | ||||||
| 
 | 
 | ||||||
|     dispatch[list] = save_list |     dispatch[ListType] = save_list | ||||||
| 
 | 
 | ||||||
|     # Keep in synch with cPickle's BATCHSIZE.  Nothing will break if it gets |     # Keep in synch with cPickle's BATCHSIZE.  Nothing will break if it gets | ||||||
|     # out of synch, though. |     # out of synch, though. | ||||||
|  | @ -648,7 +648,7 @@ def save_dict(self, obj): | ||||||
|         self.memoize(obj) |         self.memoize(obj) | ||||||
|         self._batch_setitems(obj.iteritems()) |         self._batch_setitems(obj.iteritems()) | ||||||
| 
 | 
 | ||||||
|     dispatch[dict] = save_dict |     dispatch[DictionaryType] = save_dict | ||||||
|     if not PyStringMap is None: |     if not PyStringMap is None: | ||||||
|         dispatch[PyStringMap] = save_dict |         dispatch[PyStringMap] = save_dict | ||||||
| 
 | 
 | ||||||
|  | @ -770,7 +770,7 @@ def save_global(self, obj, name=None, pack=struct.pack): | ||||||
|     dispatch[ClassType] = save_global |     dispatch[ClassType] = save_global | ||||||
|     dispatch[FunctionType] = save_global |     dispatch[FunctionType] = save_global | ||||||
|     dispatch[BuiltinFunctionType] = save_global |     dispatch[BuiltinFunctionType] = save_global | ||||||
|     dispatch[type] = save_global |     dispatch[TypeType] = save_global | ||||||
| 
 | 
 | ||||||
| # Pickling helpers | # Pickling helpers | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -138,7 +138,7 @@ | ||||||
| 
 | 
 | ||||||
| import re, string, time, operator | import re, string, time, operator | ||||||
| 
 | 
 | ||||||
| from types import InstanceType | from types import * | ||||||
| 
 | 
 | ||||||
| # -------------------------------------------------------------------- | # -------------------------------------------------------------------- | ||||||
| # Internal stuff | # Internal stuff | ||||||
|  | @ -348,8 +348,8 @@ class DateTime: | ||||||
|     """ |     """ | ||||||
| 
 | 
 | ||||||
|     def __init__(self, value=0): |     def __init__(self, value=0): | ||||||
|         if not isinstance(value, str): |         if not isinstance(value, StringType): | ||||||
|             if not isinstance(value, (tuple, time.struct_time)): |             if not isinstance(value, (TupleType, time.struct_time)): | ||||||
|                 if value == 0: |                 if value == 0: | ||||||
|                     value = time.time() |                     value = time.time() | ||||||
|                 value = time.localtime(value) |                 value = time.localtime(value) | ||||||
|  | @ -618,7 +618,7 @@ def dump_nil (self, value, write): | ||||||
|         if not self.allow_none: |         if not self.allow_none: | ||||||
|             raise TypeError, "cannot marshal None unless allow_none is enabled" |             raise TypeError, "cannot marshal None unless allow_none is enabled" | ||||||
|         write("<value><nil/></value>") |         write("<value><nil/></value>") | ||||||
|     dispatch[type(None)] = dump_nil |     dispatch[NoneType] = dump_nil | ||||||
| 
 | 
 | ||||||
|     def dump_int(self, value, write): |     def dump_int(self, value, write): | ||||||
|         # in case ints are > 32 bits |         # in case ints are > 32 bits | ||||||
|  | @ -627,7 +627,7 @@ def dump_int(self, value, write): | ||||||
|         write("<value><int>") |         write("<value><int>") | ||||||
|         write(str(value)) |         write(str(value)) | ||||||
|         write("</int></value>\n") |         write("</int></value>\n") | ||||||
|     dispatch[int] = dump_int |     dispatch[IntType] = dump_int | ||||||
| 
 | 
 | ||||||
|     if _bool_is_builtin: |     if _bool_is_builtin: | ||||||
|         def dump_bool(self, value, write): |         def dump_bool(self, value, write): | ||||||
|  | @ -642,19 +642,19 @@ def dump_long(self, value, write): | ||||||
|         write("<value><int>") |         write("<value><int>") | ||||||
|         write(str(int(value))) |         write(str(int(value))) | ||||||
|         write("</int></value>\n") |         write("</int></value>\n") | ||||||
|     dispatch[long] = dump_long |     dispatch[LongType] = dump_long | ||||||
| 
 | 
 | ||||||
|     def dump_double(self, value, write): |     def dump_double(self, value, write): | ||||||
|         write("<value><double>") |         write("<value><double>") | ||||||
|         write(repr(value)) |         write(repr(value)) | ||||||
|         write("</double></value>\n") |         write("</double></value>\n") | ||||||
|     dispatch[float] = dump_double |     dispatch[FloatType] = dump_double | ||||||
| 
 | 
 | ||||||
|     def dump_string(self, value, write, escape=escape): |     def dump_string(self, value, write, escape=escape): | ||||||
|         write("<value><string>") |         write("<value><string>") | ||||||
|         write(escape(value)) |         write(escape(value)) | ||||||
|         write("</string></value>\n") |         write("</string></value>\n") | ||||||
|     dispatch[str] = dump_string |     dispatch[StringType] = dump_string | ||||||
| 
 | 
 | ||||||
|     if unicode: |     if unicode: | ||||||
|         def dump_unicode(self, value, write, escape=escape): |         def dump_unicode(self, value, write, escape=escape): | ||||||
|  | @ -662,7 +662,7 @@ def dump_unicode(self, value, write, escape=escape): | ||||||
|             write("<value><string>") |             write("<value><string>") | ||||||
|             write(escape(value)) |             write(escape(value)) | ||||||
|             write("</string></value>\n") |             write("</string></value>\n") | ||||||
|         dispatch[unicode] = dump_unicode |         dispatch[UnicodeType] = dump_unicode | ||||||
| 
 | 
 | ||||||
|     def dump_array(self, value, write): |     def dump_array(self, value, write): | ||||||
|         i = id(value) |         i = id(value) | ||||||
|  | @ -675,8 +675,8 @@ def dump_array(self, value, write): | ||||||
|             dump(v, write) |             dump(v, write) | ||||||
|         write("</data></array></value>\n") |         write("</data></array></value>\n") | ||||||
|         del self.memo[i] |         del self.memo[i] | ||||||
|     dispatch[tuple] = dump_array |     dispatch[TupleType] = dump_array | ||||||
|     dispatch[list] = dump_array |     dispatch[ListType] = dump_array | ||||||
| 
 | 
 | ||||||
|     def dump_struct(self, value, write, escape=escape): |     def dump_struct(self, value, write, escape=escape): | ||||||
|         i = id(value) |         i = id(value) | ||||||
|  | @ -687,8 +687,8 @@ def dump_struct(self, value, write, escape=escape): | ||||||
|         write("<value><struct>\n") |         write("<value><struct>\n") | ||||||
|         for k, v in value.items(): |         for k, v in value.items(): | ||||||
|             write("<member>\n") |             write("<member>\n") | ||||||
|             if type(k) is not str: |             if type(k) is not StringType: | ||||||
|                 if unicode and type(k) is unicode: |                 if unicode and type(k) is UnicodeType: | ||||||
|                     k = k.encode(self.encoding) |                     k = k.encode(self.encoding) | ||||||
|                 else: |                 else: | ||||||
|                     raise TypeError, "dictionary key must be string" |                     raise TypeError, "dictionary key must be string" | ||||||
|  | @ -697,7 +697,7 @@ def dump_struct(self, value, write, escape=escape): | ||||||
|             write("</member>\n") |             write("</member>\n") | ||||||
|         write("</struct></value>\n") |         write("</struct></value>\n") | ||||||
|         del self.memo[i] |         del self.memo[i] | ||||||
|     dispatch[dict] = dump_struct |     dispatch[DictType] = dump_struct | ||||||
| 
 | 
 | ||||||
|     def dump_instance(self, value, write): |     def dump_instance(self, value, write): | ||||||
|         # check for special wrappers |         # check for special wrappers | ||||||
|  | @ -1010,12 +1010,12 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None, | ||||||
|     where necessary. |     where necessary. | ||||||
|     """ |     """ | ||||||
| 
 | 
 | ||||||
|     assert isinstance(params, tuple) or isinstance(params, Fault),\ |     assert isinstance(params, TupleType) or isinstance(params, Fault),\ | ||||||
|            "argument must be tuple or Fault instance" |            "argument must be tuple or Fault instance" | ||||||
| 
 | 
 | ||||||
|     if isinstance(params, Fault): |     if isinstance(params, Fault): | ||||||
|         methodresponse = 1 |         methodresponse = 1 | ||||||
|     elif methodresponse and isinstance(params, tuple): |     elif methodresponse and isinstance(params, TupleType): | ||||||
|         assert len(params) == 1, "response tuple must be a singleton" |         assert len(params) == 1, "response tuple must be a singleton" | ||||||
| 
 | 
 | ||||||
|     if not encoding: |     if not encoding: | ||||||
|  | @ -1036,7 +1036,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None, | ||||||
|     # standard XML-RPC wrappings |     # standard XML-RPC wrappings | ||||||
|     if methodname: |     if methodname: | ||||||
|         # a method call |         # a method call | ||||||
|         if not isinstance(methodname, str): |         if not isinstance(methodname, StringType): | ||||||
|             methodname = methodname.encode(encoding) |             methodname = methodname.encode(encoding) | ||||||
|         data = ( |         data = ( | ||||||
|             xmlheader, |             xmlheader, | ||||||
|  | @ -1168,7 +1168,7 @@ def getparser(self): | ||||||
|     def get_host_info(self, host): |     def get_host_info(self, host): | ||||||
| 
 | 
 | ||||||
|         x509 = {} |         x509 = {} | ||||||
|         if isinstance(host, tuple): |         if isinstance(host, TupleType): | ||||||
|             host, x509 = host |             host, x509 = host | ||||||
| 
 | 
 | ||||||
|         import urllib |         import urllib | ||||||
|  | @ -1218,7 +1218,7 @@ def send_host(self, connection, host): | ||||||
|         host, extra_headers, x509 = self.get_host_info(host) |         host, extra_headers, x509 = self.get_host_info(host) | ||||||
|         connection.putheader("Host", host) |         connection.putheader("Host", host) | ||||||
|         if extra_headers: |         if extra_headers: | ||||||
|             if isinstance(extra_headers, dict): |             if isinstance(extra_headers, DictType): | ||||||
|                 extra_headers = extra_headers.items() |                 extra_headers = extra_headers.items() | ||||||
|             for key, value in extra_headers: |             for key, value in extra_headers: | ||||||
|                 connection.putheader(key, value) |                 connection.putheader(key, value) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Raymond Hettinger
						Raymond Hettinger