Skip to content

BLD: fix py37 build warnings #26769

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 7 commits into from
Jun 27, 2019
Merged

BLD: fix py37 build warnings #26769

merged 7 commits into from
Jun 27, 2019

Conversation

jbrockmendel
Copy link
Member

Not at all sure this is the optimal way to do this, cc @WillAyd for suggestions

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Not super familiar with the buffer protocol. Comment on quick glance will deep dive later

PyObject_GetBuffer(packed, &view, PyBUF_SIMPLE)
buf = <char*>view.buf
buf_len = view.len
PyBuffer_Release(&view)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this release call come later in the function, after buf and buf_len are used?

Copy link

@scoder scoder Jun 24, 2019

Choose a reason for hiding this comment

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

Yes. There is no guarantee in the buffer protocol that the buffer stays alive beyond a call to PyBuffer_Release().
Also, PyObject_GetBuffer() can fail, in which case it will return -1. (Cython does the exception handling here.)

Simply casting packed to a <char*> might actually also work in Cython, but that won't give you the buffer length. Casting it to a memory view would, but that's also a bit more heavy than calling GetBuffer directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jbrockmendel can you move the release to the end of the function? (for both the success and unsuccessful paths)

@WillAyd
Copy link
Member

WillAyd commented Jun 10, 2019

FYI here is the bpo patch which might be helpful to compare

https://bugs.python.org/issue22896

@codecov
Copy link

codecov bot commented Jun 10, 2019

Codecov Report

Merging #26769 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26769      +/-   ##
==========================================
- Coverage   91.71%    91.7%   -0.01%     
==========================================
  Files         178      178              
  Lines       50755    50755              
==========================================
- Hits        46552    46547       -5     
- Misses       4203     4208       +5
Flag Coverage Δ
#multiple 90.3% <ø> (ø) ⬆️
#single 41.2% <ø> (-0.11%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.88% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.84% <0%> (-0.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 959e799...48e17e3. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 10, 2019

Codecov Report

Merging #26769 into master will decrease coverage by 0.08%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26769      +/-   ##
==========================================
- Coverage   92.05%   91.97%   -0.09%     
==========================================
  Files         180      180              
  Lines       50726    50756      +30     
==========================================
- Hits        46696    46681      -15     
- Misses       4030     4075      +45
Flag Coverage Δ
#multiple 90.56% <ø> (-0.12%) ⬇️
#single 41.82% <ø> (-0.16%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 88.88% <0%> (-11.12%) ⬇️
pandas/plotting/_core.py 88.2% <0%> (-1.19%) ⬇️
pandas/core/internals/managers.py 96% <0%> (-0.87%) ⬇️
pandas/core/arrays/sparse.py 93.73% <0%> (-0.79%) ⬇️
pandas/core/internals/blocks.py 94.38% <0%> (-0.77%) ⬇️
pandas/core/dtypes/missing.py 93.33% <0%> (-0.61%) ⬇️
pandas/core/dtypes/concat.py 96.58% <0%> (-0.46%) ⬇️
pandas/core/internals/concat.py 96.48% <0%> (-0.37%) ⬇️
pandas/core/dtypes/cast.py 90.53% <0%> (-0.37%) ⬇️
pandas/plotting/_misc.py 64.55% <0%> (-0.31%) ⬇️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 27f9d05...8db2301. Read the comment docs.

@jreback jreback added Build Library building on various platforms Clean labels Jun 10, 2019
@jreback jreback added this to the 0.25.0 milestone Jun 10, 2019
@jreback
Copy link
Contributor

jreback commented Jun 11, 2019

lgtm. is @WillAyd comment relevant?

@jbrockmendel
Copy link
Member Author

Will's comment is definitely relevant; the BPO conversation specifically describes this usage as unsafe.

Do we have anyone conversant in CPython internals we can hand this off to?

Do we have decent test coverage for msgpack?

@WillAyd
Copy link
Member

WillAyd commented Jun 11, 2019

I think this is fine as is but it's probably better to move the release of the object until after buf and buf_len have actually been used. Seems like as is could be at risk for segfault

@jreback
Copy link
Contributor

jreback commented Jun 12, 2019

@zooba any idea about the usage here ?

@jreback
Copy link
Contributor

jreback commented Jun 21, 2019

can you merge master, ping on green. prob ok to merge this.

@jbrockmendel
Copy link
Member Author

Updated, but since segfaults are at risk and this isn't actively broken ATM I'd rather leave this open until we get someone more conversant in the C internals to sign off on it. Any thoughts @scoder?

@jreback
Copy link
Contributor

jreback commented Jun 21, 2019

sure

@jreback
Copy link
Contributor

jreback commented Jun 27, 2019

lgtm. merge on green.

@jreback jreback merged commit de0867f into pandas-dev:master Jun 27, 2019
@jreback
Copy link
Contributor

jreback commented Jun 27, 2019

thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the bldwarns branch June 27, 2019 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Library building on various platforms Clean
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants