mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-29 12:23:42 +03:00
parent
19c74cc654
commit
214600fcc0
1
NEWS
1
NEWS
|
@ -7,6 +7,7 @@ What's new in psycopg 2.7.5
|
||||||
- Fixed building on Solaris 11 and derivatives such as SmartOS and illumos
|
- Fixed building on Solaris 11 and derivatives such as SmartOS and illumos
|
||||||
(:ticket:`#677`).
|
(:ticket:`#677`).
|
||||||
- Maybe fixed building on MSYS2 (as reported in :ticket:`#658`).
|
- Maybe fixed building on MSYS2 (as reported in :ticket:`#658`).
|
||||||
|
- Allow string subclasses in connection and other places (:ticket:`#679`).
|
||||||
|
|
||||||
|
|
||||||
What's new in psycopg 2.7.4
|
What's new in psycopg 2.7.4
|
||||||
|
|
|
@ -168,11 +168,11 @@ psycopg_ensure_bytes(PyObject *obj)
|
||||||
PyObject *rv = NULL;
|
PyObject *rv = NULL;
|
||||||
if (!obj) { return NULL; }
|
if (!obj) { return NULL; }
|
||||||
|
|
||||||
if (PyUnicode_CheckExact(obj)) {
|
if (PyUnicode_Check(obj)) {
|
||||||
rv = PyUnicode_AsUTF8String(obj);
|
rv = PyUnicode_AsUTF8String(obj);
|
||||||
Py_DECREF(obj);
|
Py_DECREF(obj);
|
||||||
}
|
}
|
||||||
else if (Bytes_CheckExact(obj)) {
|
else if (Bytes_Check(obj)) {
|
||||||
rv = obj;
|
rv = obj;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -246,6 +246,13 @@ class ConnectionTests(ConnectingTestCase):
|
||||||
else:
|
else:
|
||||||
del os.environ['PGCLIENTENCODING']
|
del os.environ['PGCLIENTENCODING']
|
||||||
|
|
||||||
|
def test_connect_no_string(self):
|
||||||
|
class MyString(str):
|
||||||
|
pass
|
||||||
|
|
||||||
|
conn = psycopg2.connect(MyString(dsn))
|
||||||
|
conn.close()
|
||||||
|
|
||||||
def test_weakref(self):
|
def test_weakref(self):
|
||||||
from weakref import ref
|
from weakref import ref
|
||||||
import gc
|
import gc
|
||||||
|
@ -401,6 +408,13 @@ class ParseDsnTestCase(ConnectingTestCase):
|
||||||
self.assertRaises(TypeError, ext.parse_dsn, None)
|
self.assertRaises(TypeError, ext.parse_dsn, None)
|
||||||
self.assertRaises(TypeError, ext.parse_dsn, 42)
|
self.assertRaises(TypeError, ext.parse_dsn, 42)
|
||||||
|
|
||||||
|
def test_str_subclass(self):
|
||||||
|
class MyString(str):
|
||||||
|
pass
|
||||||
|
|
||||||
|
res = ext.parse_dsn(MyString("dbname=test"))
|
||||||
|
self.assertEqual(res, {'dbname': 'test'})
|
||||||
|
|
||||||
|
|
||||||
class MakeDsnTestCase(ConnectingTestCase):
|
class MakeDsnTestCase(ConnectingTestCase):
|
||||||
def test_empty_arguments(self):
|
def test_empty_arguments(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user