This repository was archived by the owner on Dec 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 8
8
# SFrames require a disk-backed file or directory to work with. This directory
9
9
# has to be present to allow for serialization or deserialization.
10
10
__serialization_directory = None
11
+ from sys import version_info as _version_info
11
12
12
13
13
14
def enable_sframe_serialization (serialization_directory ):
@@ -28,6 +29,8 @@ def enable_sframe_serialization(serialization_directory):
28
29
29
30
import os
30
31
32
+ if _version_info [0 ] == 2 :
33
+ raise RuntimeError ("SFrame serialization not supported in python 2." )
31
34
global __serialization_directory
32
35
if serialization_directory is None :
33
36
__serialization_directory = None
@@ -61,7 +64,10 @@ def _safe_serialization_directory():
61
64
from pickle import PickleError
62
65
63
66
if __serialization_directory is None :
64
- raise PickleError ("Serialization directory not set to enable pickling or unpickling. "
67
+
68
+ expected_error = TypeError if (_version_info [0 ] == 3 ) else PickleError
69
+
70
+ raise expected_error ("Serialization directory not set to enable pickling or unpickling. "
65
71
"Set using turicreate.data_structures.serialization.enable_sframe_serialization()." )
66
72
67
73
return __serialization_directory
Original file line number Diff line number Diff line change 12
12
from ..util import _assert_sframe_equal , generate_random_sframe
13
13
from .. import _launch , load_sframe , aggregate
14
14
from . import util
15
+ from sys import version_info
15
16
16
17
import pandas as pd
17
18
from .._cython .cy_flexible_type import GMT
@@ -642,6 +643,7 @@ def test_save_to_csv(self):
642
643
f .close ()
643
644
os .unlink (f .name )
644
645
646
+ @pytest .mark .skipif (version_info [0 ] != 3 , "Not a supported feature in python 2.7" )
645
647
def test_pickling (self ):
646
648
647
649
import pickle
@@ -650,9 +652,10 @@ def test_pickling(self):
650
652
X = generate_random_sframe (100 , "ncc" )
651
653
652
654
with util .TempDirectory () as f :
653
-
654
655
655
- self .assertRaises (pickle .PickleError , lambda : pickle .dumps (X ))
656
+ expected_error = TypeError if (version_info [0 ] == 3 ) else PicklingError
657
+
658
+ self .assertRaises (expected_error , lambda : pickle .dumps (X ))
656
659
657
660
serialization .enable_sframe_serialization (f )
658
661
You can’t perform that action at this time.
0 commit comments