Skip to content

Commit aa1ada3

Browse files
committed
More specific error message, moved imports to top of files
1 parent bf60d23 commit aa1ada3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pandas/io/sas/sasreader.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Read SAS sas7bdat or xport files.
33
"""
4-
4+
from pandas import compat
55

66
def read_sas(filepath_or_buffer, format=None, index=None, encoding=None,
77
chunksize=None, iterator=False):
@@ -29,11 +29,11 @@ def read_sas(filepath_or_buffer, format=None, index=None, encoding=None,
2929
DataFrame if iterator=False and chunksize=None, else SAS7BDATReader
3030
or XportReader
3131
"""
32-
from pandas import compat
3332
if format is None:
34-
buffErr = "Format unrecognized. If buffer object, specify format"
33+
buffer_error_msg = "If this is a buffer object rather\
34+
than a string name, you must specify a format string"
3535
if not isinstance(filepath_or_buffer,compat.string_types):
36-
raise TypeError(buffErr)
36+
raise TypeError(buffer_error_msg)
3737
try:
3838
fname = filepath_or_buffer.lower()
3939
if fname.endswith(".xpt"):

pandas/io/tests/sas/test_sas.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import pandas.util.testing as tm
2+
from pandas.compat import StringIO
3+
from pandas import read_sas
24

35
class TestSasBuff(tm.TestCase):
46
def test_sas_buffer_format(self):
5-
import StringIO
6-
from pandas.io.sas.sasreader import read_sas
7-
b = StringIO.StringIO("")
7+
b = StringIO("")
88
with self.assertRaises(TypeError):
99
read_sas(b)

0 commit comments

Comments
 (0)