Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
6ed43a18
Commit
6ed43a18
authored
Oct 21, 2008
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make is_blob_record tolerant of invalid pickles.
parent
5de7b02f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
src/ZODB/blob.py
src/ZODB/blob.py
+6
-1
src/ZODB/tests/testblob.py
src/ZODB/tests/testblob.py
+10
-1
No files found.
src/ZODB/blob.py
View file @
6ed43a18
...
...
@@ -745,4 +745,9 @@ def is_blob_record(record):
storage to another.
"""
return
cPickle
.
loads
(
record
)
is
ZODB
.
blob
.
Blob
try
:
return
cPickle
.
loads
(
record
)
is
ZODB
.
blob
.
Blob
except
(
MemoryError
,
KeyboardInterrupt
,
SystemExit
):
raise
except
Exception
:
return
False
src/ZODB/tests/testblob.py
View file @
6ed43a18
...
...
@@ -589,7 +589,7 @@ def loadblob_tmpstore():
"""
def
is_blob_record
():
"""
r
"""
>>> fs = FileStorage('Data.fs')
>>> bs = ZODB.blob.BlobStorage('blobs', fs)
>>> db = DB(bs)
...
...
@@ -601,6 +601,15 @@ def is_blob_record():
>>> ZODB.blob.is_blob_record(fs.load(ZODB.utils.p64(1), '')[0])
True
An invalid pickle yields a false value:
>>> ZODB.blob.is_blob_record("Hello world!")
False
>>> ZODB.blob.is_blob_record('c__main__\nC\nq\x01.')
False
>>> ZODB.blob.is_blob_record('cWaaaa\nC\nq\x01.')
False
>>> db.close()
"""
...
...
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