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
8d3f130d
Kaydet (Commit)
8d3f130d
authored
Şub 02, 2010
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix idioms and a couple of py3k warnings. Patch by Florent Xicluna.
üst
0ac4d4c8
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
45 additions
and
51 deletions
+45
-51
dbshelve.py
Lib/bsddb/dbshelve.py
+3
-3
dbtables.py
Lib/bsddb/dbtables.py
+5
-5
test_all.py
Lib/bsddb/test/test_all.py
+9
-9
test_basics.py
Lib/bsddb/test/test_basics.py
+2
-2
test_compare.py
Lib/bsddb/test/test_compare.py
+1
-6
test_dbtables.py
Lib/bsddb/test/test_dbtables.py
+1
-1
test_recno.py
Lib/bsddb/test/test_recno.py
+11
-11
test_replication.py
Lib/bsddb/test/test_replication.py
+10
-10
test_thread.py
Lib/bsddb/test/test_thread.py
+2
-2
test_bsddb3.py
Lib/test/test_bsddb3.py
+1
-2
No files found.
Lib/bsddb/dbshelve.py
Dosyayı görüntüle @
8d3f130d
...
...
@@ -157,7 +157,7 @@ class DBShelf(MutableMapping):
def
keys
(
self
,
txn
=
None
):
if
txn
!=
None
:
if
txn
is
not
None
:
return
self
.
db
.
keys
(
txn
)
else
:
return
self
.
db
.
keys
()
...
...
@@ -185,7 +185,7 @@ class DBShelf(MutableMapping):
def
items
(
self
,
txn
=
None
):
if
txn
!=
None
:
if
txn
is
not
None
:
items
=
self
.
db
.
items
(
txn
)
else
:
items
=
self
.
db
.
items
()
...
...
@@ -196,7 +196,7 @@ class DBShelf(MutableMapping):
return
newitems
def
values
(
self
,
txn
=
None
):
if
txn
!=
None
:
if
txn
is
not
None
:
values
=
self
.
db
.
values
(
txn
)
else
:
values
=
self
.
db
.
values
()
...
...
Lib/bsddb/dbtables.py
Dosyayı görüntüle @
8d3f130d
...
...
@@ -179,14 +179,14 @@ class bsdTableDB :
def
set_range
(
self
,
search
)
:
v
=
self
.
_dbcursor
.
set_range
(
bytes
(
search
,
"iso8859-1"
))
if
v
!=
None
:
if
v
is
not
None
:
v
=
(
v
[
0
]
.
decode
(
"iso8859-1"
),
v
[
1
]
.
decode
(
"iso8859-1"
))
return
v
def
__next__
(
self
)
:
v
=
getattr
(
self
.
_dbcursor
,
"next"
)()
if
v
!=
None
:
if
v
is
not
None
:
v
=
(
v
[
0
]
.
decode
(
"iso8859-1"
),
v
[
1
]
.
decode
(
"iso8859-1"
))
return
v
...
...
@@ -204,7 +204,7 @@ class bsdTableDB :
def
put
(
self
,
key
,
value
,
flags
=
0
,
txn
=
None
)
:
key
=
bytes
(
key
,
"iso8859-1"
)
if
value
!=
None
:
if
value
is
not
None
:
value
=
bytes
(
value
,
"iso8859-1"
)
return
self
.
_db
.
put
(
key
,
value
,
flags
=
flags
,
txn
=
txn
)
...
...
@@ -215,7 +215,7 @@ class bsdTableDB :
def
get
(
self
,
key
,
txn
=
None
,
flags
=
0
)
:
key
=
bytes
(
key
,
"iso8859-1"
)
v
=
self
.
_db
.
get
(
key
,
txn
=
txn
,
flags
=
flags
)
if
v
!=
None
:
if
v
is
not
None
:
v
=
v
.
decode
(
"iso8859-1"
)
return
v
...
...
@@ -540,7 +540,7 @@ class bsdTableDB :
# error
dataitem
=
None
dataitem
=
mappings
[
column
](
dataitem
)
if
dataitem
!=
None
:
if
dataitem
is
not
None
:
self
.
db
.
put
(
_data_key
(
table
,
column
,
rowid
),
dataitem
,
txn
=
txn
)
...
...
Lib/bsddb/test/test_all.py
Dosyayı görüntüle @
8d3f130d
...
...
@@ -23,7 +23,7 @@ if sys.version_info[0] >= 3 :
return
getattr
(
self
.
_dbcursor
,
v
)
def
_fix
(
self
,
v
)
:
if
v
==
None
:
return
None
if
v
is
None
:
return
None
key
,
value
=
v
if
isinstance
(
key
,
bytes
)
:
key
=
key
.
decode
(
charset
)
...
...
@@ -90,7 +90,7 @@ if sys.version_info[0] >= 3 :
def
pget
(
self
,
key
=
None
,
data
=
None
,
flags
=
0
)
:
# Incorrect because key can be a bare number,
# but enough to pass testsuite
if
isinstance
(
key
,
int
)
and
(
data
==
None
)
and
(
flags
==
0
)
:
if
isinstance
(
key
,
int
)
and
(
data
is
None
)
and
(
flags
==
0
)
:
flags
=
key
key
=
None
if
isinstance
(
key
,
str
)
:
...
...
@@ -101,7 +101,7 @@ if sys.version_info[0] >= 3 :
if
isinstance
(
data
,
str
)
:
data
=
bytes
(
data
,
charset
)
v
=
self
.
_dbcursor
.
pget
(
key
=
key
,
data
=
data
,
flags
=
flags
)
if
v
!=
None
:
if
v
is
not
None
:
v1
,
v2
,
v3
=
v
if
isinstance
(
v1
,
bytes
)
:
v1
=
v1
.
decode
(
charset
)
...
...
@@ -114,7 +114,7 @@ if sys.version_info[0] >= 3 :
def
join_item
(
self
)
:
v
=
self
.
_dbcursor
.
join_item
()
if
v
!=
None
:
if
v
is
not
None
:
v
=
v
.
decode
(
charset
)
return
v
...
...
@@ -134,7 +134,7 @@ if sys.version_info[0] >= 3 :
args
=
(
k
,
d
,
f
)
v
=
self
.
_dbcursor
.
get
(
*
args
,
**
kwargs
)
if
v
!=
None
:
if
v
is
not
None
:
k
,
v
=
v
if
isinstance
(
k
,
bytes
)
:
k
=
k
.
decode
(
charset
)
...
...
@@ -176,7 +176,7 @@ if sys.version_info[0] >= 3 :
if
isinstance
(
k
,
str
)
:
k
=
bytes
(
k
,
charset
)
v
=
self
.
_db
[
k
]
if
v
!=
None
:
if
v
is
not
None
:
v
=
v
.
decode
(
charset
)
return
v
...
...
@@ -230,7 +230,7 @@ if sys.version_info[0] >= 3 :
else
:
v
=
self
.
_db
.
get
(
key
,
txn
=
txn
,
flags
=
flags
,
dlen
=
dlen
,
doff
=
doff
)
if
(
v
!=
None
)
and
isinstance
(
v
,
bytes
)
:
if
(
v
is
not
None
)
and
isinstance
(
v
,
bytes
)
:
v
=
v
.
decode
(
charset
)
return
v
...
...
@@ -238,7 +238,7 @@ if sys.version_info[0] >= 3 :
if
isinstance
(
key
,
str
)
:
key
=
bytes
(
key
,
charset
)
v
=
self
.
_db
.
pget
(
key
,
txn
=
txn
)
if
v
!=
None
:
if
v
is
not
None
:
v1
,
v2
=
v
if
isinstance
(
v1
,
bytes
)
:
v1
=
v1
.
decode
(
charset
)
...
...
@@ -252,7 +252,7 @@ if sys.version_info[0] >= 3 :
if
isinstance
(
value
,
str
)
:
value
=
bytes
(
value
,
charset
)
v
=
self
.
_db
.
get_both
(
key
,
value
,
txn
=
txn
,
flags
=
flags
)
if
v
!=
None
:
if
v
is
not
None
:
v
=
v
.
decode
(
charset
)
return
v
...
...
Lib/bsddb/test/test_basics.py
Dosyayı görüntüle @
8d3f130d
...
...
@@ -342,7 +342,7 @@ class BasicTestCase(unittest.TestCase):
else
:
if
set_raises_error
:
self
.
fail
(
"expected exception"
)
if
n
!=
None
:
if
n
is
not
None
:
self
.
fail
(
"expected None:
%
r"
%
(
n
,))
rec
=
c
.
get_both
(
'0404'
,
self
.
makeData
(
'0404'
))
...
...
@@ -356,7 +356,7 @@ class BasicTestCase(unittest.TestCase):
else
:
if
get_raises_error
:
self
.
fail
(
"expected exception"
)
if
n
!=
None
:
if
n
is
not
None
:
self
.
fail
(
"expected None:
%
r"
%
(
n
,))
if
self
.
d
.
get_type
()
==
db
.
DB_BTREE
:
...
...
Lib/bsddb/test/test_compare.py
Dosyayı görüntüle @
8d3f130d
...
...
@@ -238,12 +238,7 @@ class BtreeExceptionsTestCase (AbstractBtreeKeyCompareTestCase):
self
.
startTest
()
self
.
createDB
(
my_compare
)
try
:
self
.
db
.
set_bt_compare
(
my_compare
)
self
.
assert_
(
0
,
"this set should fail"
)
except
RuntimeError
,
msg
:
pass
self
.
assertRaises
(
RuntimeError
,
self
.
db
.
set_bt_compare
,
my_compare
)
def
test_suite
():
res
=
unittest
.
TestSuite
()
...
...
Lib/bsddb/test/test_dbtables.py
Dosyayı görüntüle @
8d3f130d
...
...
@@ -341,7 +341,7 @@ class TableDBTestCase(unittest.TestCase):
self
.
tdb
.
Insert
(
tabname
,
{
'Type'
:
'Unknown'
,
'Access'
:
'0'
})
def
set_type
(
type
):
if
type
==
None
:
if
type
is
None
:
return
'MP3'
return
type
...
...
Lib/bsddb/test/test_recno.py
Dosyayı görüntüle @
8d3f130d
...
...
@@ -38,8 +38,8 @@ class SimpleRecnoTestCase(unittest.TestCase):
for
x
in
letters
:
recno
=
d
.
append
(
x
*
60
)
self
.
assert
Equal
(
type
(
recno
),
type
(
0
)
)
self
.
assert
_
(
recno
>=
1
)
self
.
assert
IsInstance
(
recno
,
int
)
self
.
assert
GreaterEqual
(
recno
,
1
)
if
verbose
:
print
recno
,
...
...
@@ -54,7 +54,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
if
verbose
:
print
data
self
.
assert
Equal
(
type
(
data
),
type
(
""
)
)
self
.
assert
IsInstance
(
data
,
str
)
self
.
assertEqual
(
data
,
d
.
get
(
recno
))
try
:
...
...
@@ -91,21 +91,21 @@ class SimpleRecnoTestCase(unittest.TestCase):
keys
=
d
.
keys
()
if
verbose
:
print
keys
self
.
assert
Equal
(
type
(
keys
),
type
([])
)
self
.
assert
Equal
(
type
(
keys
[
0
]),
type
(
123
)
)
self
.
assert
IsInstance
(
keys
,
list
)
self
.
assert
IsInstance
(
keys
[
0
],
int
)
self
.
assertEqual
(
len
(
keys
),
len
(
d
))
items
=
d
.
items
()
if
verbose
:
pprint
(
items
)
self
.
assert
Equal
(
type
(
items
),
type
([])
)
self
.
assert
Equal
(
type
(
items
[
0
]),
type
(())
)
self
.
assert
IsInstance
(
items
,
list
)
self
.
assert
IsInstance
(
items
[
0
],
tuple
)
self
.
assertEqual
(
len
(
items
[
0
]),
2
)
self
.
assert
Equal
(
type
(
items
[
0
][
0
]),
type
(
123
)
)
self
.
assert
Equal
(
type
(
items
[
0
][
1
]),
type
(
""
)
)
self
.
assert
IsInstance
(
items
[
0
][
0
],
int
)
self
.
assert
IsInstance
(
items
[
0
][
1
],
str
)
self
.
assertEqual
(
len
(
items
),
len
(
d
))
self
.
assert
_
(
d
.
has_key
(
25
))
self
.
assert
True
(
d
.
has_key
(
25
))
del
d
[
25
]
self
.
assertFalse
(
d
.
has_key
(
25
))
...
...
@@ -177,7 +177,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
if
get_returns_none
:
self
.
fail
(
"unexpected DBKeyEmptyError exception"
)
else
:
self
.
assertEqual
(
val
[
0
],
db
.
DB_KEYEMPTY
)
self
.
assertEqual
(
val
.
args
[
0
],
db
.
DB_KEYEMPTY
)
if
verbose
:
print
val
else
:
if
not
get_returns_none
:
...
...
Lib/bsddb/test/test_replication.py
Dosyayı görüntüle @
8d3f130d
...
...
@@ -188,11 +188,11 @@ class DBReplicationManager(unittest.TestCase):
import
time
timeout
=
time
.
time
()
+
10
v
=
None
while
(
time
.
time
()
<
timeout
)
and
(
v
==
None
)
:
while
(
time
.
time
()
<
timeout
)
and
(
v
is
None
)
:
txn
=
self
.
dbenvClient
.
txn_begin
()
v
=
self
.
dbClient
.
get
(
"ABC"
,
txn
=
txn
)
txn
.
commit
()
if
v
==
None
:
if
v
is
None
:
time
.
sleep
(
0.02
)
self
.
assertTrue
(
time
.
time
()
<
timeout
)
self
.
assertEquals
(
"123"
,
v
)
...
...
@@ -201,11 +201,11 @@ class DBReplicationManager(unittest.TestCase):
self
.
dbMaster
.
delete
(
"ABC"
,
txn
=
txn
)
txn
.
commit
()
timeout
=
time
.
time
()
+
10
while
(
time
.
time
()
<
timeout
)
and
(
v
!=
None
)
:
while
(
time
.
time
()
<
timeout
)
and
(
v
is
not
None
)
:
txn
=
self
.
dbenvClient
.
txn_begin
()
v
=
self
.
dbClient
.
get
(
"ABC"
,
txn
=
txn
)
txn
.
commit
()
if
v
==
None
:
if
v
is
None
:
time
.
sleep
(
0.02
)
self
.
assertTrue
(
time
.
time
()
<
timeout
)
self
.
assertEquals
(
None
,
v
)
...
...
@@ -298,7 +298,7 @@ class DBBaseReplication(DBReplicationManager):
def
thread_do
(
env
,
q
,
envid
,
election_status
,
must_be_master
)
:
while
True
:
v
=
q
.
get
()
if
v
==
None
:
return
if
v
is
None
:
return
env
.
rep_process_message
(
v
[
0
],
v
[
1
],
envid
)
self
.
thread_do
=
thread_do
...
...
@@ -351,11 +351,11 @@ class DBBaseReplication(DBReplicationManager):
import
time
timeout
=
time
.
time
()
+
10
v
=
None
while
(
time
.
time
()
<
timeout
)
and
(
v
==
None
)
:
while
(
time
.
time
()
<
timeout
)
and
(
v
is
None
)
:
txn
=
self
.
dbenvClient
.
txn_begin
()
v
=
self
.
dbClient
.
get
(
"ABC"
,
txn
=
txn
)
txn
.
commit
()
if
v
==
None
:
if
v
is
None
:
time
.
sleep
(
0.02
)
self
.
assertTrue
(
time
.
time
()
<
timeout
)
self
.
assertEquals
(
"123"
,
v
)
...
...
@@ -364,11 +364,11 @@ class DBBaseReplication(DBReplicationManager):
self
.
dbMaster
.
delete
(
"ABC"
,
txn
=
txn
)
txn
.
commit
()
timeout
=
time
.
time
()
+
10
while
(
time
.
time
()
<
timeout
)
and
(
v
!=
None
)
:
while
(
time
.
time
()
<
timeout
)
and
(
v
is
not
None
)
:
txn
=
self
.
dbenvClient
.
txn_begin
()
v
=
self
.
dbClient
.
get
(
"ABC"
,
txn
=
txn
)
txn
.
commit
()
if
v
==
None
:
if
v
is
None
:
time
.
sleep
(
0.02
)
self
.
assertTrue
(
time
.
time
()
<
timeout
)
self
.
assertEquals
(
None
,
v
)
...
...
@@ -391,7 +391,7 @@ class DBBaseReplication(DBReplicationManager):
def
thread_do
(
env
,
q
,
envid
,
election_status
,
must_be_master
)
:
while
True
:
v
=
q
.
get
()
if
v
==
None
:
return
if
v
is
None
:
return
r
=
env
.
rep_process_message
(
v
[
0
],
v
[
1
],
envid
)
if
must_be_master
and
self
.
confirmed_master
:
self
.
dbenvMaster
.
rep_start
(
flags
=
db
.
DB_REP_MASTER
)
...
...
Lib/bsddb/test/test_thread.py
Dosyayı görüntüle @
8d3f130d
...
...
@@ -424,7 +424,7 @@ class ThreadedTransactionsBase(BaseThreadedTestCase):
readers
.
pop
()
.
start
()
except
(
db
.
DBLockDeadlockError
,
db
.
DBLockNotGrantedError
),
val
:
if
verbose
:
print
"
%
s: Aborting transaction (
%
s)"
%
(
name
,
val
[
1
])
print
"
%
s: Aborting transaction (
%
s)"
%
(
name
,
val
.
args
[
1
])
txn
.
abort
()
if
verbose
:
...
...
@@ -455,7 +455,7 @@ class ThreadedTransactionsBase(BaseThreadedTestCase):
finished
=
True
except
(
db
.
DBLockDeadlockError
,
db
.
DBLockNotGrantedError
),
val
:
if
verbose
:
print
"
%
s: Aborting transaction (
%
s)"
%
(
name
,
val
[
1
])
print
"
%
s: Aborting transaction (
%
s)"
%
(
name
,
val
.
args
[
1
])
c
.
close
()
txn
.
abort
()
...
...
Lib/test/test_bsddb3.py
Dosyayı görüntüle @
8d3f130d
...
...
@@ -7,8 +7,7 @@ import sys
import
tempfile
import
time
import
unittest
from
test.test_support
import
(
requires
,
verbose
,
run_unittest
,
unlink
,
rmtree
,
import_module
)
from
test.test_support
import
requires
,
run_unittest
,
import_module
# Skip test if _bsddb module was not built.
import_module
(
'_bsddb'
)
...
...
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