mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-10-31 07:47:30 +03:00 
			
		
		
		
	Check if the object wrapped in binary is not None before trying the other types
Otherwise it seems we clobber some result with NULL.
This commit is contained in:
		
							parent
							
								
									a9dc1b83ad
								
							
						
					
					
						commit
						735d50c782
					
				|  | @ -65,6 +65,13 @@ binary_quote(binaryObject *self) | ||||||
|     int got_view = 0; |     int got_view = 0; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |     /* Allow Binary(None) to work */ | ||||||
|  |     if (self->wrapped == Py_None) { | ||||||
|  |         Py_INCREF(psyco_null); | ||||||
|  |         rv = psyco_null; | ||||||
|  |         goto exit; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     /* if we got a plain string or a buffer we escape it and save the buffer */ |     /* if we got a plain string or a buffer we escape it and save the buffer */ | ||||||
| 
 | 
 | ||||||
| #if HAS_MEMORYVIEW | #if HAS_MEMORYVIEW | ||||||
|  | @ -113,12 +120,6 @@ exit: | ||||||
|     if (got_view) { PyBuffer_Release(&view); } |     if (got_view) { PyBuffer_Release(&view); } | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     /* Allow Binary(None) to work */ |  | ||||||
|     if (self->wrapped == Py_None) { |  | ||||||
|         Py_INCREF(psyco_null); |  | ||||||
|         rv = psyco_null; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /* if the wrapped object is not bytes or a buffer, this is an error */ |     /* if the wrapped object is not bytes or a buffer, this is an error */ | ||||||
|     if (!rv && !PyErr_Occurred()) { |     if (!rv && !PyErr_Occurred()) { | ||||||
|         PyErr_Format(PyExc_TypeError, "can't escape %s to binary", |         PyErr_Format(PyExc_TypeError, "can't escape %s to binary", | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user