Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
swift
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenStack
services
swift
Commits
71f1532a
Commit
71f1532a
authored
Jul 10, 2019
by
Zuul
Committed by
Gerrit Code Review
Jul 10, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge "py3: Specify an encoding when loading db.pending pickles"
parents
392c967a
ef664700
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
swift/common/db.py
swift/common/db.py
+5
-1
test/unit/common/test_db.py
test/unit/common/test_db.py
+17
-0
No files found.
swift/common/db.py
View file @
71f1532a
...
...
@@ -730,7 +730,11 @@ class DatabaseBroker(object):
for
entry
in
fp
.
read
()
.
split
(
b
':'
):
if
entry
:
try
:
data
=
pickle
.
loads
(
base64
.
b64decode
(
entry
))
if
six
.
PY2
:
data
=
pickle
.
loads
(
base64
.
b64decode
(
entry
))
else
:
data
=
pickle
.
loads
(
base64
.
b64decode
(
entry
),
encoding
=
'utf8'
)
self
.
_commit_puts_load
(
item_list
,
data
)
except
Exception
:
self
.
logger
.
exception
(
...
...
test/unit/common/test_db.py
View file @
71f1532a
...
...
@@ -1441,6 +1441,23 @@ class TestDatabaseBroker(unittest.TestCase):
mock_merge_items
.
assert_called_once_with
([
b
'not'
,
b
'bad'
])
self
.
assertEqual
(
0
,
os
.
path
.
getsize
(
broker
.
pending_file
))
# load a pending entry that's caused trouble in py2/py3 upgrade tests
# can't quite figure out how it got generated, though, so hard-code it
with
open
(
broker
.
pending_file
,
'wb'
)
as
fd
:
fd
.
write
(
b
':gAIoVS3olIngpILrjIvrjIvpkIngpIHlmIjlmIbjnIbgp'
b
'IPjnITimIPvhI/rjI3tiI5xAVUQMTU1OTI0MTg0Ni40NjY'
b
'wMXECVQEwVQEwVQEwSwBVATB0Lg=='
)
with
patch
.
object
(
broker
,
'merge_items'
)
as
mock_merge_items
:
broker
.
_commit_puts_load
=
lambda
l
,
e
:
l
.
append
(
e
)
broker
.
_commit_puts
([])
expected_name
=
(
u'
\u8509\u0902\ub30b\ub30b\u9409\u0901\u5608\u5606
'
u'
\u3706\u0903\u3704\u2603\uf10f\ub30d\ud20e
'
)
if
six
.
PY2
:
expected_name
=
expected_name
.
encode
(
'utf8'
)
mock_merge_items
.
assert_called_once_with
([
(
expected_name
,
'1559241846.46601'
,
'0'
,
'0'
,
'0'
,
0
,
'0'
)])
self
.
assertEqual
(
0
,
os
.
path
.
getsize
(
broker
.
pending_file
))
# skip_commits True - no merge
db_file
=
os
.
path
.
join
(
self
.
testdir
,
'2.db'
)
broker
=
DatabaseBroker
(
db_file
,
skip_commits
=
True
)
...
...
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