-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
read_sas catches own error #24548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I see what you mean. Could quickly be resolved by swapping pass to raise and Updating the docstring. I'll add a PR for these changes. |
Is the try/except clause even required? |
If the
is odd as this is essentially a noop? |
@samgd yeah you're right. Will update to reflect that. |
Code Sample, a copy-pastable example if possible
Output (
/tmp/foo
does not have to exist):Problem description
When
format=None
the function attempts to infer the file's format by naively looking at the extension. If it is neither'.xpt'
nor'.sas7bdat'
then an error is raised. However, this logic is wrapped in a try/except block that catches the raised error and silently discards it:pandas/pandas/io/sas/sasreader.py
Lines 35 to 53 in 179822a
The function then attempts to call
format.lower()
butformat
is stillNone
so anAttributeError
is raised.Expected Output
Expected behaviour: error raised when unable to infer format. Suggest documenting that inference is done by checking the file's extension.
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]INSTALLED VERSIONS
commit: None
python: 3.7.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.19.12-arch1-1-ARCH
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
pandas: 0.23.4
pytest: None
pip: 18.1
setuptools: 40.6.3
Cython: None
numpy: 1.15.4
scipy: None
pyarrow: None
xarray: None
IPython: 7.2.0
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: