mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 10:26:02 +00:00 
			
		
		
		
	bpo-34910: Ensure that PyObject_Print() always returns -1 on error. (GH-9733)
This commit is contained in:
		
							parent
							
								
									cd45385ffa
								
							
						
					
					
						commit
						ae62f01524
					
				
					 2 changed files with 5 additions and 2 deletions
				
			
		|  | @ -0,0 +1,2 @@ | ||||||
|  | Ensure that :c:func:`PyObject_Print` always returns ``-1`` on error.  Patch | ||||||
|  | by Zackery Spytz. | ||||||
|  | @ -375,8 +375,9 @@ PyObject_Print(PyObject *op, FILE *fp, int flags) | ||||||
|             else if (PyUnicode_Check(s)) { |             else if (PyUnicode_Check(s)) { | ||||||
|                 PyObject *t; |                 PyObject *t; | ||||||
|                 t = PyUnicode_AsEncodedString(s, "utf-8", "backslashreplace"); |                 t = PyUnicode_AsEncodedString(s, "utf-8", "backslashreplace"); | ||||||
|                 if (t == NULL) |                 if (t == NULL) { | ||||||
|                     ret = 0; |                     ret = -1; | ||||||
|  |                 } | ||||||
|                 else { |                 else { | ||||||
|                     fwrite(PyBytes_AS_STRING(t), 1, |                     fwrite(PyBytes_AS_STRING(t), 1, | ||||||
|                            PyBytes_GET_SIZE(t), fp); |                            PyBytes_GET_SIZE(t), fp); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Zackery Spytz
						Zackery Spytz