Skip to content

Commit 4d37c85

Browse files
Use default values for all parameters when creating a session pool.
1 parent e763419 commit 4d37c85

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

doc/src/module.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ Module Interface
176176
This method is an extension to the DB API definition.
177177

178178

179-
.. function:: SessionPool(user, password, dsn, min, max, increment, \
180-
connectiontype=cx_Oracle.Connection, threaded=False, \
179+
.. function:: SessionPool(user=None, password=None, dsn=None, min=1, max=2, \
180+
increment=1, connectiontype=cx_Oracle.Connection, threaded=False, \
181181
getmode=cx_Oracle.SPOOL_ATTRVAL_NOWAIT, events=False, \
182182
homogeneous=True, externalauth=False, encoding=None, nencoding=None, \
183183
edition=None)

src/cxoBuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
int cxoBuffer_fromObject(cxoBuffer *buf, PyObject *obj, const char *encoding)
2424
{
2525
cxoBuffer_init(buf);
26-
if (!obj)
26+
if (!obj || obj == Py_None)
2727
return 0;
2828
if (PyUnicode_Check(obj)) {
2929
buf->obj = PyUnicode_AsEncodedString(obj, encoding, NULL);

src/cxoSessionPool.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,13 @@ static int cxoSessionPool_init(cxoSessionPool *pool, PyObject *args,
169169
NULL };
170170

171171
// parse arguments and keywords
172-
externalAuthObj = editionObj = NULL;
172+
usernameObj = passwordObj = dsnObj = editionObj = Py_None;
173+
externalAuthObj = NULL;
173174
threadedObj = eventsObj = homogeneousObj = passwordObj = NULL;
174175
connectionType = &cxoPyTypeConnection;
176+
minSessions = 1;
177+
maxSessions = 2;
178+
sessionIncrement = 1;
175179
if (cxoUtils_initializeDPI() < 0)
176180
return -1;
177181
if (dpiContext_initCommonCreateParams(cxoDpiContext, &dpiCommonParams) < 0)
@@ -181,11 +185,11 @@ static int cxoSessionPool_init(cxoSessionPool *pool, PyObject *args,
181185
(uint32_t) strlen(dpiCommonParams.driverName);
182186
if (dpiContext_initPoolCreateParams(cxoDpiContext, &dpiCreateParams) < 0)
183187
return cxoError_raiseAndReturnInt();
184-
if (!PyArg_ParseTupleAndKeywords(args, keywordArgs, "OOOiii|OObOOOssO",
185-
keywordList, &usernameObj, &passwordObj, &dsnObj,
186-
&minSessions, &maxSessions, &sessionIncrement, &connectionType,
187-
&threadedObj, &dpiCreateParams.getMode, &eventsObj,
188-
&homogeneousObj, &externalAuthObj, &dpiCommonParams.encoding,
188+
if (!PyArg_ParseTupleAndKeywords(args, keywordArgs, "|OOOiiiOObOOOssO",
189+
keywordList, &usernameObj, &passwordObj, &dsnObj, &minSessions,
190+
&maxSessions, &sessionIncrement, &connectionType, &threadedObj,
191+
&dpiCreateParams.getMode, &eventsObj, &homogeneousObj,
192+
&externalAuthObj, &dpiCommonParams.encoding,
189193
&dpiCommonParams.nencoding, &editionObj))
190194
return -1;
191195
if (!PyType_Check(connectionType)) {
@@ -228,18 +232,14 @@ static int cxoSessionPool_init(cxoSessionPool *pool, PyObject *args,
228232

229233
// populate parameters
230234
encoding = cxoUtils_getAdjustedEncoding(dpiCommonParams.encoding);
231-
if (cxoBuffer_fromObject(&userNameBuffer, pool->username, encoding) < 0)
232-
return -1;
233-
if (cxoBuffer_fromObject(&passwordBuffer, passwordObj, encoding) < 0) {
234-
cxoBuffer_clear(&userNameBuffer);
235-
return -1;
236-
}
237-
if (cxoBuffer_fromObject(&dsnBuffer, pool->dsn, encoding) < 0) {
238-
cxoBuffer_clear(&userNameBuffer);
239-
cxoBuffer_clear(&passwordBuffer);
240-
return -1;
241-
}
242-
if (cxoBuffer_fromObject(&editionBuffer, editionObj, encoding) < 0) {
235+
cxoBuffer_init(&userNameBuffer);
236+
cxoBuffer_init(&passwordBuffer);
237+
cxoBuffer_init(&dsnBuffer);
238+
cxoBuffer_init(&editionBuffer);
239+
if (cxoBuffer_fromObject(&userNameBuffer, usernameObj, encoding) < 0 ||
240+
cxoBuffer_fromObject(&passwordBuffer, passwordObj, encoding) < 0 ||
241+
cxoBuffer_fromObject(&dsnBuffer, dsnObj, encoding) < 0 ||
242+
cxoBuffer_fromObject(&editionBuffer, editionObj, encoding) < 0) {
243243
cxoBuffer_clear(&userNameBuffer);
244244
cxoBuffer_clear(&passwordBuffer);
245245
cxoBuffer_clear(&dsnBuffer);

0 commit comments

Comments
 (0)