Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
a3b87052
Commit
a3b87052
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
94a73a5e
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 @
a3b87052
...
@@ -745,4 +745,9 @@ def is_blob_record(record):
...
@@ -745,4 +745,9 @@ def is_blob_record(record):
storage to another.
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 @
a3b87052
...
@@ -589,7 +589,7 @@ def loadblob_tmpstore():
...
@@ -589,7 +589,7 @@ def loadblob_tmpstore():
"""
"""
def
is_blob_record
():
def
is_blob_record
():
"""
r
"""
>>> fs = FileStorage('Data.fs')
>>> fs = FileStorage('Data.fs')
>>> bs = ZODB.blob.BlobStorage('blobs', fs)
>>> bs = ZODB.blob.BlobStorage('blobs', fs)
>>> db = DB(bs)
>>> db = DB(bs)
...
@@ -601,6 +601,15 @@ def is_blob_record():
...
@@ -601,6 +601,15 @@ def is_blob_record():
>>> ZODB.blob.is_blob_record(fs.load(ZODB.utils.p64(1), '')[0])
>>> ZODB.blob.is_blob_record(fs.load(ZODB.utils.p64(1), '')[0])
True
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()
>>> 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