Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
senpy
senpy
Commits
0f89b924
Commit
0f89b924
authored
May 17, 2017
by
J. Fernando Sánchez
Browse files
Fixed pickling error in py2.7
parent
ea91e3e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
senpy/plugins/__init__.py
View file @
0f89b924
...
...
@@ -98,7 +98,7 @@ class ShelfMixin(object):
if
os
.
path
.
isfile
(
self
.
shelf_file
):
try
:
self
.
__dict__
[
'_sh'
]
=
pickle
.
load
(
open
(
self
.
shelf_file
,
'rb'
))
except
(
EOFError
,
pickle
.
UnpicklingError
):
except
(
IndexError
,
EOFError
,
pickle
.
UnpicklingError
):
logger
.
warning
(
'{} has a corrupted shelf file!'
.
format
(
self
.
id
))
if
not
self
.
get
(
'force_shelf'
,
False
):
raise
...
...
tests/test_plugins.py
View file @
0f89b924
...
...
@@ -91,8 +91,8 @@ class PluginsTest(TestCase):
with
open
(
emptyfile
,
'w+b'
),
open
(
invalidfile
,
'w+b'
)
as
inf
:
inf
.
write
(
b
'ohno'
)
files
=
{
emptyfile
:
[
'empty file'
,
EOFError
],
invalidfile
:
[
'invalid file'
,
pickle
.
UnpicklingError
]}
files
=
{
emptyfile
:
[
'empty file'
,
(
EOFError
,
IndexError
)
],
invalidfile
:
[
'invalid file'
,
(
pickle
.
UnpicklingError
,
IndexError
)
]}
for
fn
in
files
:
with
open
(
fn
,
'rb'
)
as
f
:
...
...
@@ -105,7 +105,6 @@ class PluginsTest(TestCase):
assert
os
.
path
.
isfile
(
a
.
shelf_file
)
print
(
'Shelf file: %s'
%
a
.
shelf_file
)
with
self
.
assertRaises
(
error
):
# By default, raise an error
a
.
sh
[
'a'
]
=
'fromA'
a
.
save
()
del
a
.
_sh
...
...
Write
Preview
Supports
Markdown
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