Skip to content

BUG: strengthen typing in get_c_string, fix StringHashTable segfault #30419

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 5 commits into from
Dec 24, 2019

Conversation

jbrockmendel
Copy link
Member

Start with util.pxd, we can tighten the arg from "object" to "str" and simplify it a bit. Tracking down the places where get_c_string is used, the main one is in StringHashTable, where in set_item it is currently used incorrectly. The test added by this PR segfaults in master.

@TomAugspurger it looks like StringHashTable has relatively light testing. Should we be using it for StringArray?

buf = PyUnicode_AsUTF8AndSize(py_string, length)
else:
PyBytes_AsStringAndSize(py_string, <char**>&buf, length)
buf = PyUnicode_AsUTF8AndSize(py_string, length)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm interesting - so I guess this helper function existed in the first place for 2/3 compat? If this is all it is reduced to why not get rid of this function altogether and just replace with PyUnicode_AsUTF8AndSize?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I guess this helper function existed in the first place for 2/3

thats my guess, yah.

just replace with PyUnicode_AsUTF8AndSize?

for now at least because we need to figure out what to do about the segfault thing; the imlpementation here might end up changing

@WillAyd WillAyd added the Clean label Dec 23, 2019
@jreback jreback added this to the 1.0 milestone Dec 23, 2019
@jreback jreback added the Strings String extension data type and string data label Dec 23, 2019
@jreback
Copy link
Contributor

jreback commented Dec 23, 2019

lgtm. not sure why the 36 build is failing though.

@jbrockmendel
Copy link
Member Author

not sure why the 36 build is failing though.

Looks like we're passing np.str_ instead of str somewhere. Haven't looked into it closer than that so far (kinda hoping we bump numpy minversion and it fixes itself)

@jbrockmendel
Copy link
Member Author

So it isnt a numpy-version problem, just a slow test that is only getting run in that build. We're passing a np.str_ object instead of just a str. This is tough to check for because isinstance(some_np_str, str) is True

@jreback
Copy link
Contributor

jreback commented Dec 24, 2019

lgtm.

@jreback jreback merged commit e745be0 into pandas-dev:master Dec 24, 2019
@jreback
Copy link
Contributor

jreback commented Dec 24, 2019

thanks @jbrockmendel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Strings String extension data type and string data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants