Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ef671116
Kaydet (Commit)
ef671116
authored
Agu 19, 2006
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix this right for has_key(). This required adding tp_as_sequence.
üst
e014a13f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
13 deletions
+34
-13
dbmmodule.c
Modules/dbmmodule.c
+34
-13
No files found.
Modules/dbmmodule.c
Dosyayı görüntüle @
ef671116
...
...
@@ -205,20 +205,42 @@ dbm_keys(register dbmobject *dp, PyObject *unused)
return
v
;
}
static
PyObject
*
dbm_contains
(
register
dbmobject
*
dp
,
PyObject
*
args
)
static
int
dbm_contains
(
PyObject
*
self
,
PyObject
*
arg
)
{
dbmobject
*
dp
=
(
dbmobject
*
)
self
;
datum
key
,
val
;
int
tmp_size
;
if
(
!
PyArg_ParseTuple
(
args
,
"s#:__contains__"
,
&
key
.
dptr
,
&
tmp_size
))
return
NULL
;
key
.
dsize
=
tmp_size
;
check_dbmobject_open
(
dp
);
if
((
dp
)
->
di_dbm
==
NULL
)
{
PyErr_SetString
(
DbmError
,
"DBM object has already been closed"
);
return
-
1
;
}
if
(
!
PyString_Check
(
arg
))
{
PyErr_Format
(
PyExc_TypeError
,
"dbm key must be string, not %.100s"
,
arg
->
ob_type
->
tp_name
);
return
-
1
;
}
key
.
dptr
=
PyString_AS_STRING
(
arg
);
key
.
dsize
=
PyString_GET_SIZE
(
arg
);
val
=
dbm_fetch
(
dp
->
di_dbm
,
key
);
return
PyInt_FromLong
(
val
.
dptr
!=
NULL
)
;
return
val
.
dptr
!=
NULL
;
}
static
PySequenceMethods
dbm_as_sequence
=
{
0
,
/* sq_length */
0
,
/* sq_concat */
0
,
/* sq_repeat */
0
,
/* sq_item */
0
,
/* sq_slice */
0
,
/* sq_ass_item */
0
,
/* sq_ass_slice */
dbm_contains
,
/* sq_contains */
0
,
/* sq_inplace_concat */
0
,
/* sq_inplace_repeat */
};
static
PyObject
*
dbm_get
(
register
dbmobject
*
dp
,
PyObject
*
args
)
{
...
...
@@ -277,8 +299,6 @@ static PyMethodDef dbm_methods[] = {
"close()
\n
Close the database."
},
{
"keys"
,
(
PyCFunction
)
dbm_keys
,
METH_NOARGS
,
"keys() -> list
\n
Return a list of all keys in the database."
},
{
"__contains__"
,(
PyCFunction
)
dbm_contains
,
METH_VARARGS
,
"__contains__(key} -> boolean\True iff key is in the database."
},
{
"get"
,
(
PyCFunction
)
dbm_get
,
METH_VARARGS
,
"get(key[, default]) -> value
\n
"
"Return the value for key if present, otherwise default."
},
...
...
@@ -308,7 +328,7 @@ static PyTypeObject Dbmtype = {
0
,
/*tp_compare*/
0
,
/*tp_repr*/
0
,
/*tp_as_number*/
0
,
/*tp_as_sequence*/
&
dbm_as_sequence
,
/*tp_as_sequence*/
&
dbm_as_mapping
,
/*tp_as_mapping*/
};
...
...
@@ -353,7 +373,8 @@ PyMODINIT_FUNC
initdbm
(
void
)
{
PyObject
*
m
,
*
d
,
*
s
;
Dbmtype
.
ob_type
=
&
PyType_Type
;
if
(
PyType_Ready
(
&
Dbmtype
)
<
0
)
return
;
m
=
Py_InitModule
(
"dbm"
,
dbmmodule_methods
);
if
(
m
==
NULL
)
return
;
...
...
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