mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	[3.13] gh-126303: Fix pickling and copying of os.sched_param objects (GH-126336) (GH-126423)
(cherry picked from commit d3840503b0)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
			
			
This commit is contained in:
		
							parent
							
								
									05da4eea5a
								
							
						
					
					
						commit
						ce1a1a6021
					
				
					 5 changed files with 46 additions and 0 deletions
				
			
		|  | @ -24,6 +24,7 @@ | |||
| #include "pycore_pystate.h"       // _PyInterpreterState_GET() | ||||
| #include "pycore_signal.h"        // Py_NSIG | ||||
| #include "pycore_time.h"          // _PyLong_FromTime_t() | ||||
| #include "pycore_typeobject.h"    // _PyType_AddMethod() | ||||
| 
 | ||||
| #ifdef HAVE_UNISTD_H | ||||
| #  include <unistd.h>             // symlink()
 | ||||
|  | @ -8172,6 +8173,16 @@ os_sched_param_impl(PyTypeObject *type, PyObject *sched_priority) | |||
|     return res; | ||||
| } | ||||
| 
 | ||||
| static PyObject * | ||||
| os_sched_param_reduce(PyObject *self, PyObject *Py_UNUSED(ignored)) | ||||
| { | ||||
|     return Py_BuildValue("(O(N))", Py_TYPE(self), PyStructSequence_GetItem(self, 0)); | ||||
| } | ||||
| 
 | ||||
| static PyMethodDef os_sched_param_reduce_method = { | ||||
|     "__reduce__", (PyCFunction)os_sched_param_reduce, METH_NOARGS|METH_COEXIST, NULL, | ||||
| }; | ||||
| 
 | ||||
| PyDoc_VAR(os_sched_param__doc__); | ||||
| 
 | ||||
| static PyStructSequence_Field sched_param_fields[] = { | ||||
|  | @ -17980,6 +17991,12 @@ posixmodule_exec(PyObject *m) | |||
|         return -1; | ||||
|     } | ||||
|     ((PyTypeObject *)state->SchedParamType)->tp_new = os_sched_param; | ||||
|     if (_PyType_AddMethod((PyTypeObject *)state->SchedParamType, | ||||
|                           &os_sched_param_reduce_method) < 0) | ||||
|     { | ||||
|         return -1; | ||||
|     } | ||||
|     PyType_Modified((PyTypeObject *)state->SchedParamType); | ||||
| #endif | ||||
| 
 | ||||
|     /* initialize TerminalSize_info */ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)