Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
956e3595
Commit
956e3595
authored
Aug 14, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The dbm module should use bytes for keys. This makes test_shelve pass.
parent
5bcf109c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
Lib/test/test_dbm.py
Lib/test/test_dbm.py
+3
-3
Modules/dbmmodule.c
Modules/dbmmodule.c
+5
-5
No files found.
Lib/test/test_dbm.py
View file @
956e3595
...
...
@@ -26,10 +26,10 @@ def cleanup():
def
test_keys
():
d
=
dbm
.
open
(
filename
,
'c'
)
verify
(
d
.
keys
()
==
[])
d
[
'a'
]
=
'b'
d
[
'12345678910'
]
=
'019237410982340912840198242'
d
[
b'a'
]
=
b
'b'
d
[
b'12345678910'
]
=
b
'019237410982340912840198242'
d
.
keys
()
if
'a'
in
d
:
if
b
'a'
in
d
:
if
verbose
:
print
(
'Test dbm keys: '
,
d
.
keys
())
...
...
Modules/dbmmodule.c
View file @
956e3595
...
...
@@ -188,7 +188,7 @@ dbm_keys(register dbmobject *dp, PyObject *unused)
return
NULL
;
for
(
key
=
dbm_firstkey
(
dp
->
di_dbm
);
key
.
dptr
;
key
=
dbm_nextkey
(
dp
->
di_dbm
))
{
item
=
Py
String
_FromStringAndSize
(
key
.
dptr
,
key
.
dsize
);
item
=
Py
Bytes
_FromStringAndSize
(
key
.
dptr
,
key
.
dsize
);
if
(
item
==
NULL
)
{
Py_DECREF
(
v
);
return
NULL
;
...
...
@@ -219,14 +219,14 @@ dbm_contains(PyObject *self, PyObject *arg)
if
(
arg
==
NULL
)
return
-
1
;
}
if
(
!
Py
String
_Check
(
arg
))
{
if
(
!
Py
Bytes
_Check
(
arg
))
{
PyErr_Format
(
PyExc_TypeError
,
"dbm key must be string, not %.100s"
,
arg
->
ob_type
->
tp_name
);
return
-
1
;
}
key
.
dptr
=
Py
String
_AS_STRING
(
arg
);
key
.
dsize
=
Py
String
_GET_SIZE
(
arg
);
key
.
dptr
=
Py
Bytes
_AS_STRING
(
arg
);
key
.
dsize
=
Py
Bytes
_GET_SIZE
(
arg
);
val
=
dbm_fetch
(
dp
->
di_dbm
,
key
);
return
val
.
dptr
!=
NULL
;
}
...
...
@@ -395,7 +395,7 @@ initdbm(void) {
d
=
PyModule_GetDict
(
m
);
if
(
DbmError
==
NULL
)
DbmError
=
PyErr_NewException
(
"dbm.error"
,
NULL
,
NULL
);
s
=
Py
String
_FromString
(
which_dbm
);
s
=
Py
Unicode
_FromString
(
which_dbm
);
if
(
s
!=
NULL
)
{
PyDict_SetItemString
(
d
,
"library"
,
s
);
Py_DECREF
(
s
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment