mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-16 17:10:32 +03:00
Added b() function to return bytes in both Py2 and Py3.
This commit is contained in:
parent
061079c918
commit
89c492d3a4
|
@ -100,6 +100,16 @@ TRANSACTION_STATUS_INTRANS = 2
|
|||
TRANSACTION_STATUS_INERROR = 3
|
||||
TRANSACTION_STATUS_UNKNOWN = 4
|
||||
|
||||
import sys as _sys
|
||||
|
||||
# Return bytes from a string
|
||||
if _sys.version_info[0] < 3:
|
||||
def b(s):
|
||||
return s
|
||||
else:
|
||||
def b(s):
|
||||
return s.encode('utf8')
|
||||
|
||||
def register_adapter(typ, callable):
|
||||
"""Register 'callable' as an ISQLQuote adapter for type 'typ'."""
|
||||
adapters[(typ, ISQLQuote)] = callable
|
||||
|
|
Loading…
Reference in New Issue
Block a user