mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	Patch #1070046: Marshal new-style objects like InstanceType
in xmlrpclib.
This commit is contained in:
		
							parent
							
								
									9eec51c04f
								
							
						
					
					
						commit
						07529354db
					
				
					 4 changed files with 33 additions and 4 deletions
				
			
		|  | @ -630,9 +630,19 @@ def __dump(self, value, write): | |||
|         try: | ||||
|             f = self.dispatch[type(value)] | ||||
|         except KeyError: | ||||
|             raise TypeError, "cannot marshal %s objects" % type(value) | ||||
|         else: | ||||
|             f(self, value, write) | ||||
|             # check if this object can be marshalled as a structure | ||||
|             try: | ||||
|                 value.__dict__ | ||||
|             except: | ||||
|                 raise TypeError, "cannot marshal %s objects" % type(value) | ||||
|             # check if this class is a sub-class of a basic type, | ||||
|             # because we don't know how to marshal these types | ||||
|             # (e.g. a string sub-class) | ||||
|             for type_ in type(value).__mro__: | ||||
|                 if type_ in self.dispatch.keys(): | ||||
|                     raise TypeError, "cannot marshal %s objects" % type(value) | ||||
|             f = self.dispatch[InstanceType] | ||||
|         f(self, value, write) | ||||
| 
 | ||||
|     def dump_nil (self, value, write): | ||||
|         if not self.allow_none: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Martin v. Löwis
						Martin v. Löwis