pybind / pybind/pybind11

[BUG] Weird issue only on manylinux1 with numpy

Open
#3,056 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

Dumping this here since I need to fix this and move on for now (it's an issue in Awkward). Only on manylinux1 (2010 is fine), the following code produces a really weird result:

py::print(typeid(obj.ptr()).name());
py::print(typeid(py::module::import("numpy").attr("newaxis").ptr()).name());
py::print(typeid(Py_None).name());
py::print((long long) obj.ptr());
py::print((long long) py::module::import("numpy").attr("newaxis").ptr());
py::print((long long) Py_None);
py::print(obj.is(py::module::import("numpy").attr("newaxis")));
py::print(obj.ptr() == py::module::import("numpy").attr("newaxis").ptr());

Prints:

P7_object
P7_object
P7_object
8098416
8098416
8098416
False
True

Why is obj.is(py::module::import("numpy").attr("newaxis")) False? It's the same memory location as Py_None, but somehow is not "is" identical, only here in pybind11.

PS: obj is None, numpy.newaxis is None.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied C++ reproducer with numpy under manylinux1 and manylinux2010, comparing the reported pointer values and identity results. Then inspect pybind11's implementation of obj.is to trace the platform-specific behavior. Done means identifying the cause and verifying a fix or documented resolution for the None and numpy.newaxis identity comparison.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, numpy, python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.