question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Should cython object buffers check for NULL?

See original GitHub issue

Pandas seems to semi-regularly run into issues with NumPy’s logic which currently says that object arrays may be filled with NULL at initialization so that NULL is accepted everywhere to have the same meaning as None. (See also https://github.com/pandas-dev/pandas/pull/47097)

This is a bit weird, since NumPy also fills the array with None almost always, so in the few places where it doesn’t it is unexpected!

I have opened https://github.com/numpy/numpy/pull/21817 to solve this in NumPy. The intention would be that NumPy for now should accept NULL, but defines it as incorrect and will never produce it on its own (with some “internal” exceptions).

Now, I am not sure what the best solution is here and if you think that Cython should fix this (or we should do both), I can look into it. In some sense, a fix in cython might be best… then pandas can just upgrade its Cython dependency and stop worrying about these oddities.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
da-woodscommented, Jul 3, 2022

I’ll just create a copy of the tests for memoryviews and then it can be closed properly

0reactions
sebergcommented, Jul 6, 2022

I think we can close this now, thanks! Will try to remember to ping the pandas folks when I see the release, it sounds like they can remove some awful hacks then 😉.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is an explicit NUL-byte necessary at the end of a bytearray for ...
Cython uses the C-API function PyByteArray_AsString . The Python3 documentation for it says "The returned array always has an extra null ...
Read more >
There should be a way to use Cythons built in error handling ...
It would be nice if there was some mechanism you could use to get Cython to check these calls for you the same...
Read more >
Cython Changelog — Cython 3.0.0a11 documentation
This was a long-standing source of bugs, but can require adding the noexcept ... Ensure that object buffers (e.g. ndarray[object, ndim=1] ) containing...
Read more >
Python array.array and Cython best practices - Google Groups
the array without copying the data and big performance losses? ... need an underlying object supporting buffer protocol. Such objects
Read more >
Buffer Protocol — Python 3.11.1 documentation
Certain objects available in Python wrap access to an underlying memory array or buffer. Such objects include the built-in bytes and bytearray, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found