8000 Reference count error from subscript operation · Issue #5063 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
8000
Reference count error from subscript operation #5063
Closed
@abalkin

Description

@abalkin

Running the following code with numpy 1.8.1

import numpy

class C(object):
    def __index__(self):
        return 0
    def __len__(self):
        return 1
    def __getitem__(self, item):
        raise IndexError

x = numpy.array([1])
i = C()
print(repr(x[i]))

I get

*** Reference count error detected:
an attempt was made to deallocate 5 (i) ***
Traceback (most recent call last):
  File "x.py", line 13, in <module>
    print(x[i])
  File "x.py", line 9, in __getitem__
    raise NotImplementedError
NotImplementedError

With 1.9.0, I don't get a reference error, but the result is still wrong:

array([1])

(I expect 1.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0