Skip to content

COMPAT: Cast to string before raise in read_stata #14657

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

Merged
merged 1 commit into from
Nov 14, 2016

Conversation

TomAugspurger
Copy link
Contributor

In pandas.io.stata::StataReader::_read_old_header we
try to raise a ValueError.

I'm working on making a test, but this is buried pretty deep.
For now, typlist has type List[int]. We call

','.join(typlist)

which errors on py3 (and python 2 I guess?). This came up in #13856, see https://travis-ci.org/pandas-dev/pandas/jobs/175705122#L1284 for the failure.

@kshedden any memory of writing this code? This is a bare except but it looks like the only exception that would trigger this is an IndexError when something in typlist is out of bounds on self.TYPE_MAP. Any hints on writing a test to exercise this code? If not I'll dig in more tonight.

in `pandas.io.stata::StataReader::_read_old_hearder` we
try to raise a ValueError.

I'm working on making a test, but this is buried pretty deep.
For now, `typlist` has type `List[int]`. We call

```python
','.join(typlist)
```

which errors on py3.
@TomAugspurger TomAugspurger added the IO Stata read_stata, to_stata label Nov 14, 2016
@TomAugspurger
Copy link
Contributor Author

I canceled the CI builds since there aren't any new tests (yet)

@TomAugspurger
Copy link
Contributor Author

Looking further, @PKEuS would have added originally in kshedden@87d41f3#diff-2def41db3b4d04fb64de8313c0e6c25eR380 (the highlighted line had the necessary strconversion, but that was lost somewhere along the way). Sorry for the unnecessary ping Kerby.

@jreback any objections to merging this as-is (without any tests). I've verified that our current test suite doesn't touch these lines, so I'm not making anything worse 😆

@jreback
Copy link
Contributor

jreback commented Nov 14, 2016

lgtm.

@jreback jreback added this to the 0.19.2 milestone Nov 14, 2016
@jreback jreback added the Compat pandas objects compatability with Numpy or Python functions label Nov 14, 2016
@TomAugspurger TomAugspurger merged commit 1606153 into pandas-dev:master Nov 14, 2016
jorisvandenbossche pushed a commit to jorisvandenbossche/pandas that referenced this pull request Dec 14, 2016
…ad_stata (pandas-dev#14657)

Fix ValueError message in StataReader

Cast to string before joining the list of typecodes in the error message.
(cherry picked from commit 1606153)
@TomAugspurger TomAugspurger deleted the stata-error-message branch April 5, 2017 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions IO Stata read_stata, to_stata
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants