summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-08-11 19:28:53 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2007-08-11 19:28:53 (GMT)
commit7ac971243b2e3810f3e94609d3121beac9512bff (patch)
tree8c69289023a5e61aa47ecd11e106a01338324efe /Modules
parent03fc7799b02c5c66ce4115bb4bee290bfca1f710 (diff)
downloadcpython-7ac971243b2e3810f3e94609d3121beac9512bff.zip
cpython-7ac971243b2e3810f3e94609d3121beac9512bff.tar.gz
cpython-7ac971243b2e3810f3e94609d3121beac9512bff.tar.bz2
Change module to produce and consume bytes.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/gdbmmodule.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/Modules/gdbmmodule.c b/Modules/gdbmmodule.c
index 52659e1..5ee9c9a 100644
--- a/Modules/gdbmmodule.c
+++ b/Modules/gdbmmodule.c
@@ -220,7 +220,7 @@ dbm_keys(register dbmobject *dp, PyObject *unused)
key = gdbm_firstkey(dp->di_dbm);
while (key.dptr) {
- item = PyString_FromStringAndSize(key.dptr, key.dsize);
+ item = PyBytes_FromStringAndSize(key.dptr, key.dsize);
if (item == NULL) {
free(key.dptr);
Py_DECREF(v);
@@ -251,19 +251,14 @@ dbm_contains(PyObject *self, PyObject *arg)
"GDBM object has already been closed");
return -1;
}
- if (PyUnicode_Check(arg)) {
- arg = _PyUnicode_AsDefaultEncodedString(arg, NULL);
- if (arg == NULL)
- return -1;
- }
- if (!PyString_Check(arg)) {
+ if (!PyBytes_Check(arg)) {
PyErr_Format(PyExc_TypeError,
- "gdbm key must be string, not %.100s",
+ "gdbm key must be bytes, not %.100s",
arg->ob_type->tp_name);
return -1;
}
- key.dptr = PyString_AS_STRING(arg);
- key.dsize = PyString_GET_SIZE(arg);
+ key.dptr = PyBytes_AsString(arg);
+ key.dsize = PyBytes_Size(arg);
return gdbm_exists(dp->di_dbm, key);
}
@@ -296,7 +291,7 @@ dbm_firstkey(register dbmobject *dp, PyObject *unused)
check_dbmobject_open(dp);
key = gdbm_firstkey(dp->di_dbm);
if (key.dptr) {
- v = PyString_FromStringAndSize(key.dptr, key.dsize);
+ v = PyBytes_FromStringAndSize(key.dptr, key.dsize);
free(key.dptr);
return v;
}
@@ -328,7 +323,7 @@ dbm_nextkey(register dbmobject *dp, PyObject *args)
check_dbmobject_open(dp);
nextkey = gdbm_nextkey(dp->di_dbm, key);
if (nextkey.dptr) {
- v = PyString_FromStringAndSize(nextkey.dptr, nextkey.dsize);
+ v = PyBytes_FromStringAndSize(nextkey.dptr, nextkey.dsize);
free(nextkey.dptr);
return v;
}
@@ -531,7 +526,7 @@ initgdbm(void) {
DbmError = PyErr_NewException("gdbm.error", NULL, NULL);
if (DbmError != NULL) {
PyDict_SetItemString(d, "error", DbmError);
- s = PyString_FromString(dbmmodule_open_flags);
+ s = PyUnicode_FromString(dbmmodule_open_flags);
PyDict_SetItemString(d, "open_flags", s);
Py_DECREF(s);
}