mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Issue #17025: Add dumps() and loads() to ForkingPickler.
This commit is contained in:
		
							parent
							
								
									89e6b31845
								
							
						
					
					
						commit
						a655075d16
					
				
					 2 changed files with 13 additions and 5 deletions
				
			
		|  | @ -7,7 +7,9 @@ | |||
| # Licensed to PSF under a Contributor Agreement. | ||||
| # | ||||
| 
 | ||||
| import io | ||||
| import os | ||||
| import pickle | ||||
| import sys | ||||
| import signal | ||||
| import errno | ||||
|  | @ -44,6 +46,15 @@ def __init__(self, *args): | |||
|     def register(cls, type, reduce): | ||||
|         cls._extra_reducers[type] = reduce | ||||
| 
 | ||||
|     @staticmethod | ||||
|     def dumps(obj): | ||||
|         buf = io.BytesIO() | ||||
|         ForkingPickler(buf, pickle.HIGHEST_PROTOCOL).dump(obj) | ||||
|         return buf.getbuffer() | ||||
| 
 | ||||
|     loads = pickle.loads | ||||
| 
 | ||||
| 
 | ||||
| def _reduce_method(m): | ||||
|     if m.__self__ is None: | ||||
|         return getattr, (m.__class__, m.__func__.__name__) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Charles-François Natali
						Charles-François Natali