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
Joshua
zodb
Commits
e2543bbf
Commit
e2543bbf
authored
May 16, 2013
by
Tres Seaver
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9 from NextThought/master
UnicodeDecodeError with bushy blob layout and non-ASCII OID
parents
6dc3a3e0
8c9ed0db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
4 deletions
+40
-4
CHANGES.rst
CHANGES.rst
+7
-1
src/ZODB/blob.py
src/ZODB/blob.py
+9
-3
src/ZODB/tests/testblob.py
src/ZODB/tests/testblob.py
+24
-0
No files found.
CHANGES.rst
View file @
e2543bbf
...
...
@@ -2,6 +2,12 @@
Change History
================
Unreleased
==========
- Fixed: A ``UnicodeDecodeError`` could happen for non-ASCII OIDs
when using bushy blob layout.
4.0.0b2 (2013-05-14)
====================
...
...
@@ -16,7 +22,7 @@
- Skipped non-unit tests in ``setup.py test``. Use the buildout to run tests
requiring "layer" support.
- Included the filename in the exception message to support debugging in case
- Included the filename in the exception message to support debugging in case
``loadBlob`` does not find the file.
- Added support for Python 3.2 / 3.3.
...
...
src/ZODB/blob.py
View file @
e2543bbf
...
...
@@ -35,6 +35,7 @@ from ZODB._compat import BytesIO
from
ZODB._compat
import
Unpickler
from
ZODB._compat
import
decodebytes
from
ZODB._compat
import
ascii_bytes
from
ZODB._compat
import
INT_TYPES
if
sys
.
version_info
[
0
]
>=
3
:
...
...
@@ -552,9 +553,14 @@ class BushyLayout(object):
directories
=
[]
# Create the bushy directory structure with the least significant byte
# first
for
byte
in
oid
.
decode
():
directories
.
append
(
'0x%s'
%
binascii
.
hexlify
(
byte
.
encode
()).
decode
())
for
byte
in
ascii_bytes
(
oid
):
if
isinstance
(
byte
,
INT_TYPES
):
# Py3k iterates byte strings as ints
hex_segment_bytes
=
b'0x'
+
binascii
.
hexlify
(
bytes
([
byte
]))
hex_segment_string
=
hex_segment_bytes
.
decode
(
'ascii'
)
else
:
hex_segment_string
=
'0x%s'
%
binascii
.
hexlify
(
byte
)
directories
.
append
(
hex_segment_string
)
return
os
.
path
.
sep
.
join
(
directories
)
def
path_to_oid
(
self
,
path
):
...
...
src/ZODB/tests/testblob.py
View file @
e2543bbf
...
...
@@ -12,6 +12,7 @@
#
##############################################################################
from
ZODB.blob
import
Blob
from
ZODB.blob
import
BushyLayout
from
ZODB.DB
import
DB
from
ZODB.FileStorage
import
FileStorage
from
ZODB.tests.testConfig
import
ConfigTestBase
...
...
@@ -138,6 +139,28 @@ class BlobCloneTests(ZODB.tests.util.TestCase):
# tearDown
database
.
close
()
class
BushyLayoutTests
(
ZODB
.
tests
.
util
.
TestCase
):
def
testBushyLayoutOIDToPathUnicode
(
self
):
"OID-to-path should produce valid results given non-ASCII byte strings"
non_ascii_oid
=
b'>
\
xf1
<0
\
xe9
Q
\
x99
\
xf0
'
# The argument should already be bytes;
# os.path.sep is native string type under both 2 and 3
# binascii.hexlify takes bytes and produces bytes under both py2 and py3
# the result should be the native string type
oid_as_path
=
BushyLayout
().
oid_to_path
(
non_ascii_oid
)
self
.
assertEqual
(
oid_as_path
,
'0x3e/0xf1/0x3c/0x30/0xe9/0x51/0x99/0xf0'
)
# the reverse holds true as well
path_as_oid
=
BushyLayout
().
path_to_oid
(
oid_as_path
)
self
.
assertEqual
(
path_as_oid
,
non_ascii_oid
)
class
BlobTestBase
(
ZODB
.
tests
.
StorageTestBase
.
StorageTestBase
):
def
setUp
(
self
):
...
...
@@ -779,6 +802,7 @@ def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ZODBBlobConfigTest))
suite.addTest(unittest.makeSuite(BlobCloneTests))
suite.addTest(unittest.makeSuite(BushyLayoutTests))
suite.addTest(doctest.DocFileSuite(
"blob_basic.txt", "blob_consume.txt", "blob_tempdir.txt",
"blobstorage_packing.txt",
...
...
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