8000 __setitem__ bug on structured arrays with objects (Trac #1299) · Issue #1897 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

__setitem__ bug on structured arrays with objects (Trac #1299) #1897

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

Closed
thouis opened this issue Oct 19, 2012 · 2 comments
Closed

__setitem__ bug on structured arrays with objects (Trac #1299) #1897

thouis opened this issue Oct 19, 2012 · 2 comments

Comments

@thouis
Copy link
Contributor
thouis commented Oct 19, 2012

Original ticket http://projects.scipy.org/numpy/ticket/1299 on 2009-11-19 by trac user crobin, assigned to unknown.

I think there is a bug with __setitem__ when using advanced selection on a structured array with objects when dimension is at least 2.

x = numpy.rec.fromarrays([[0,1],['a','b']], formats='i8,O')[None]
print x
x[x.nonzero()] = x.ravel()[:1]
print x

This gives:

[[(0, 'a') (1, 'b')]]
[[(0, 'a') (0, 'b')]]  ## WRONG

The very last 'b' should be an 'a'.

As a bonus, the reference count of the string ‘b’ decreases, even though it still remains in the array x. So the interpreter will crash if you repeat the above:

while True:
    x[x.nonzero()] = x.ravel()[:1]

...leads to:

Fatal Python error: deletion of interned string failed
zsh: IOT instruction (core dumped)  python2.6

Note that this bug does not seem to occur when x is dimension 1, or when basic selection is used. The offset of the object in the dtype does not seem to matter.

@thouis
Copy link
Contributor Author
thouis commented Oct 19, 2012

Milestone changed to 1.4.0 by @cournape on 2009-11-25

@thouis
Copy link
Contributor Author
thouis commented Oct 19, 2012

@teoliphant wrote on 2009-12-02

Fixed in check-in #7818. This bug-report actually found 2 underlying problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0