[3.7] bpo-33383: Fix crash in get() of the dbm.ndbm database object. … · python/cpython@ee95feb

Original file line numberDiff line numberDiff line change

@@ -39,7 +39,7 @@ _dbm_dbm_keys(dbmobject *self, PyObject *Py_UNUSED(ignored))

3939

}

4040
4141

PyDoc_STRVAR(_dbm_dbm_get__doc__,

42-

"get($self, key, default=b\'\', /)\n"

42+

"get($self, key, default=None, /)\n"

4343

"--\n"

4444

"\n"

4545

"Return the value for key if present, otherwise default.");

@@ -57,7 +57,7 @@ _dbm_dbm_get(dbmobject *self, PyObject *const *args, Py_ssize_t nargs)

5757

PyObject *return_value = NULL;

5858

const char *key;

5959

Py_ssize_clean_t key_length;

60-

PyObject *default_value = NULL;

60+

PyObject *default_value = Py_None;

6161
6262

if (!_PyArg_ParseStack(args, nargs, "s#|O:get",

6363

&key, &key_length, &default_value)) {

@@ -141,4 +141,4 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs)

141141

exit:

142142

return return_value;

143143

}

144-

/*[clinic end generated code: output=5c858b4080a011a4 input=a9049054013a1b77]*/

144+

/*[clinic end generated code: output=1cba297bc8d7c2c2 input=a9049054013a1b77]*/