mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-04 01:37:31 +03:00 
			
		
		
		
	Assume there may be files returning Unicode in Python 2 too
This is the case in Python 2.7 with files implementing io.TextIOBase.
This commit is contained in:
		
							parent
							
								
									8a08114314
								
							
						
					
					
						commit
						6098ced761
					
				| 
						 | 
					@ -1081,10 +1081,10 @@ _pq_copy_in_v3(cursorObject *curs)
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* a file may return unicode in Py3: encode in client encoding. */
 | 
					        /* a file may return unicode if implements io.TextIOBase */
 | 
				
			||||||
#if PY_MAJOR_VERSION > 2
 | 
					 | 
				
			||||||
        if (PyUnicode_Check(o)) {
 | 
					        if (PyUnicode_Check(o)) {
 | 
				
			||||||
            PyObject *tmp;
 | 
					            PyObject *tmp;
 | 
				
			||||||
 | 
					            Dprintf("_pq_copy_in_v3: encoding in %s", curs->conn->codec);
 | 
				
			||||||
            if (!(tmp = PyUnicode_AsEncodedString(o, curs->conn->codec, NULL))) {
 | 
					            if (!(tmp = PyUnicode_AsEncodedString(o, curs->conn->codec, NULL))) {
 | 
				
			||||||
                Dprintf("_pq_copy_in_v3: encoding() failed");
 | 
					                Dprintf("_pq_copy_in_v3: encoding() failed");
 | 
				
			||||||
                error = 1;
 | 
					                error = 1;
 | 
				
			||||||
| 
						 | 
					@ -1093,7 +1093,6 @@ _pq_copy_in_v3(cursorObject *curs)
 | 
				
			||||||
            Py_DECREF(o);
 | 
					            Py_DECREF(o);
 | 
				
			||||||
            o = tmp;
 | 
					            o = tmp;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!Bytes_Check(o)) {
 | 
					        if (!Bytes_Check(o)) {
 | 
				
			||||||
            Dprintf("_pq_copy_in_v3: got %s instead of bytes",
 | 
					            Dprintf("_pq_copy_in_v3: got %s instead of bytes",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user