-
-
Notifications
You must be signed in to change notification settings - Fork 616
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixup some invalid pickle testing (#924)
* cPickle doesn't exist in Python 3+, therefore we can drop * examples/pickle_deserialize.py uses StringIO.StringIO which was replaced with io.StringIO. However, these calls expect bytes, not str * Similarly examples/dill.py using StringIO to be replaced with BytesIO. It was also using an instance of an non-existant class name of Undillr and not Unpickler. Signed-off-by: Eric Brown <eric_wade_brown@yahoo.com>
- Loading branch information
Showing
4 changed files
with
9 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import dill | ||
import StringIO | ||
import io | ||
|
||
# dill | ||
pick = dill.dumps({'a': 'b', 'c': 'd'}) | ||
print(dill.loads(pick)) | ||
|
||
file_obj = StringIO.StringIO() | ||
file_obj = io.BytesIO() | ||
dill.dump([1, 2, '3'], file_obj) | ||
file_obj.seek(0) | ||
print(dill.load(file_obj)) | ||
|
||
file_obj.seek(0) | ||
print(dill.Undillr(file_obj).load()) | ||
print(dill.Unpickler(file_obj).load()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,15 @@ | ||
import cPickle | ||
import io | ||
import pickle | ||
import StringIO | ||
|
||
|
||
# pickle | ||
pick = pickle.dumps({'a': 'b', 'c': 'd'}) | ||
print(pickle.loads(pick)) | ||
|
||
file_obj = StringIO.StringIO() | ||
file_obj = io.BytesIO() | ||
pickle.dump([1, 2, '3'], file_obj) | ||
file_obj.seek(0) | ||
print(pickle.load(file_obj)) | ||
|
||
file_obj.seek(0) | ||
print(pickle.Unpickler(file_obj).load()) | ||
|
||
# cPickle | ||
serialized = cPickle.dumps({(): []}) | ||
print(cPickle.loads(serialized)) | ||
|
||
file_obj = StringIO.StringIO() | ||
cPickle.dump((1,), file_obj) | ||
file_obj.seek(0) | ||
print(cPickle.load(file_obj)) | ||
|
||
file_obj.seek(0) | ||
print(cPickle.Unpickler(file_obj).load()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters