Skip to content

Commit f8166fc

Browse files
committed
Updated based on feedback from jreback
1 parent b52f204 commit f8166fc

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

doc/source/whatsnew/v0.20.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ Performance Improvements
271271
- Improved performance of ``pd.wide_to_long()`` (:issue:`14779`)
272272
- Increased performance of ``pd.factorize()`` by releasing the GIL with ``object`` dtype when inferred as strings (:issue:`14859`)
273273

274-
- When reading buffer object in ``read_sas()`` method without specified format, filepath string is inferred rather than buffer object. Error is now thrown if buffer object is provided without format {sas7bdat|xport} specification.
274+
- When reading buffer object in ``read_sas()`` method without specified format, filepath string is inferred rather than buffer object.
275275

276276

277277
.. _whatsnew_0200.bug_fixes:

pandas/io/sas/sasreader.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -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-
32+
from pandas import compat
3333
if format is None:
34-
bufferr = "Format unrecognized. If buffer object, specify format")
35-
if type(filesize_or_buffer) != str:
36-
raise TypeError(bufferr)
34+
buffErr = "Format unrecognized. If buffer object, specify format")
35+
if not isinstance(filepath_or_buffer,compat.string_types):
36+
raise TypeError(buffErr)
3737
try:
3838
fname = filepath_or_buffer.lower()
3939
if fname.endswith(".xpt"):

pandas/io/tests/sas/test_sas.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def test_sas_buffer_format(self):
2+
import StringIO
3+
b = StringIO.StringIO("")
4+
with self.assertRaises(TypeError):
5+
result=pd.read_sas(b)

0 commit comments

Comments
 (0)