mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-32381: Rewrite PyErr_ProgramText() (GH-23700)
PyErr_ProgramText() now calls PyErr_ProgramTextObject().
This commit is contained in:
		
							parent
							
								
									6d3dfee271
								
							
						
					
					
						commit
						815506d852
					
				
					 1 changed files with 10 additions and 5 deletions
				
			
		|  | @ -1697,13 +1697,18 @@ err_programtext(PyThreadState *tstate, FILE *fp, int lineno) | |||
| PyObject * | ||||
| PyErr_ProgramText(const char *filename, int lineno) | ||||
| { | ||||
|     FILE *fp; | ||||
|     if (filename == NULL || *filename == '\0' || lineno <= 0) { | ||||
|     if (filename == NULL) { | ||||
|         return NULL; | ||||
|     } | ||||
|     PyThreadState *tstate = _PyThreadState_GET(); | ||||
|     fp = _Py_fopen(filename, "r" PY_STDIOTEXTMODE); | ||||
|     return err_programtext(tstate, fp, lineno); | ||||
| 
 | ||||
|     PyObject *filename_obj = PyUnicode_DecodeFSDefault(filename); | ||||
|     if (filename_obj == NULL) { | ||||
|         PyErr_Clear(); | ||||
|         return NULL; | ||||
|     } | ||||
|     PyObject *res = PyErr_ProgramTextObject(filename_obj, lineno); | ||||
|     Py_DECREF(filename_obj); | ||||
|     return res; | ||||
| } | ||||
| 
 | ||||
| PyObject * | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Victor Stinner
						Victor Stinner