mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	gh-119049: Fix incorrect display of warning which is constructed by C API (GH-119063)
The source line was not displayed if the warnings module had not yet been imported.
This commit is contained in:
		
							parent
							
								
									4702b7b5bd
								
							
						
					
					
						commit
						100c7ab00a
					
				
					 4 changed files with 57 additions and 4 deletions
				
			
		|  | @ -3303,6 +3303,15 @@ test_reftracer(PyObject *ob, PyObject *Py_UNUSED(ignored)) | |||
|     return NULL; | ||||
| } | ||||
| 
 | ||||
| static PyObject * | ||||
| function_set_warning(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) | ||||
| { | ||||
|     if (PyErr_WarnEx(PyExc_RuntimeWarning, "Testing PyErr_WarnEx", 2)) { | ||||
|         return NULL; | ||||
|     } | ||||
|     Py_RETURN_NONE; | ||||
| } | ||||
| 
 | ||||
| static PyMethodDef TestMethods[] = { | ||||
|     {"set_errno",               set_errno,                       METH_VARARGS}, | ||||
|     {"test_config",             test_config,                     METH_NOARGS}, | ||||
|  | @ -3444,6 +3453,7 @@ static PyMethodDef TestMethods[] = { | |||
|     {"function_set_closure", function_set_closure, METH_VARARGS, NULL}, | ||||
|     {"check_pyimport_addmodule", check_pyimport_addmodule, METH_VARARGS}, | ||||
|     {"test_weakref_capi", test_weakref_capi, METH_NOARGS}, | ||||
|     {"function_set_warning", function_set_warning, METH_NOARGS}, | ||||
|     {NULL, NULL} /* sentinel */ | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Kirill Podoprigora
						Kirill Podoprigora