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
8c664e86
Kaydet (Commit)
8c664e86
authored
Tem 25, 2008
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 1592: Better error reporting for operations on closed shelves.
üst
4982d5d0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
shelve.py
Lib/shelve.py
+11
-1
test_shelve.py
Lib/test/test_shelve.py
+15
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/shelve.py
Dosyayı görüntüle @
8c664e86
...
...
@@ -73,6 +73,16 @@ import warnings
__all__
=
[
"Shelf"
,
"BsdDbShelf"
,
"DbfilenameShelf"
,
"open"
]
class
_ClosedDict
(
UserDict
.
DictMixin
):
'Marker for a closed dict. Access attempts raise a ValueError.'
def
closed
(
self
,
*
args
):
raise
ValueError
(
'invalid operation on closed shelf'
)
__getitem__
=
__setitem__
=
__delitem__
=
keys
=
closed
def
__repr__
(
self
):
return
'<Closed Dictionary>'
class
Shelf
(
UserDict
.
DictMixin
):
"""Base class for shelf implementations.
...
...
@@ -136,7 +146,7 @@ class Shelf(UserDict.DictMixin):
self
.
dict
.
close
()
except
AttributeError
:
pass
self
.
dict
=
0
self
.
dict
=
_ClosedDict
()
def
__del__
(
self
):
if
not
hasattr
(
self
,
'writeback'
):
...
...
Lib/test/test_shelve.py
Dosyayı görüntüle @
8c664e86
...
...
@@ -8,6 +8,21 @@ class TestCase(unittest.TestCase):
fn
=
"shelftemp"
+
os
.
extsep
+
"db"
def
test_close
(
self
):
d1
=
{}
s
=
shelve
.
Shelf
(
d1
,
protocol
=
2
,
writeback
=
False
)
s
[
'key1'
]
=
[
1
,
2
,
3
,
4
]
self
.
assertEqual
(
s
[
'key1'
],
[
1
,
2
,
3
,
4
])
self
.
assertEqual
(
len
(
s
),
1
)
s
.
close
()
self
.
assertRaises
(
ValueError
,
len
,
s
)
try
:
s
[
'key1'
]
except
ValueError
:
pass
else
:
self
.
fail
(
'Closed shelf should not find a key'
)
def
test_ascii_file_shelf
(
self
):
try
:
s
=
shelve
.
open
(
self
.
fn
,
protocol
=
0
)
...
...
Misc/NEWS
Dosyayı görüntüle @
8c664e86
...
...
@@ -26,6 +26,9 @@ Core and Builtins
Library
-------
- Issue 1592: Improve error reporting when operations are attempted
on a closed shelf.
- Deprecate the "ast" parser function aliases.
- Issue #3120: On 64-bit Windows the subprocess module was truncating handles.
...
...
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