diff --git a/src/mariadb_pooling.c b/src/mariadb_pooling.c index 15ecaac..5bdefdf 100644 --- a/src/mariadb_pooling.c +++ b/src/mariadb_pooling.c @@ -116,7 +116,7 @@ MrdbPool_initialize(MrdbPool *self, PyObject *args, PyObject *kwargs) } /* check if pool already exists */ - if ((pn= PyDict_GetItemString(kwargs, "pool_name"))) + if (kwargs && (pn= PyDict_GetItemString(kwargs, "pool_name"))) { if (PyDict_Contains(cnx_pool, pn)) { @@ -125,6 +125,11 @@ MrdbPool_initialize(MrdbPool *self, PyObject *args, PyObject *kwargs) return -1; } } + else { + mariadb_throw_exception(NULL, Mariadb_ProgrammingError, 0, + "No pool name specified"); + return -1; + } while(PyDict_Next(kwargs, &pos, &key, &value)) { diff --git a/test/integration/test_pooling.py b/test/integration/test_pooling.py index abec967..af8fcb6 100644 --- a/test/integration/test_pooling.py +++ b/test/integration/test_pooling.py @@ -27,6 +27,12 @@ def test_connection_pools(self): del pool self.assertEqual(mariadb._CONNECTION_POOLS, {}) + def test_conpy39(self): + try: + pool= mariadb.ConnectionPool() + except mariadb.ProgrammingError: + pass + def test_connection_pool_conf(self): pool= mariadb.ConnectionPool(pool_name="test") default_conf= conf()