Skip to content

BUG: 1.22.4 breaks frombuffer API compared with 1.22.3 #21612

@carterbox

Description

@carterbox

Describe the issue:

Arrays returned by np.frombuffer() do not have the same base attribute when compared before and after version 1.22.4. I believe this behavior may only be reproduceable on Windows/OSX.

Related:

Reproduce the code example:

import numpy as np
import multiprocessing as mp
import ctypes
shared_obj = mp.RawArray(ctypes.c_double, (6, 6))
shared_arr = np.frombuffer(shared_obj)
assert type(shared_arr) == np.ndarray
assert type(shared_obj) == type(shared_arr.base)

Error message:

>       assert type(shared_obj) == type(shared_arr.base)
E       AssertionError: assert <class 'multiprocessing.sharedctypes.c_double_Array_2'> == <class 'memoryview'>
E        +  where <class 'multiprocessing.sharedctypes.c_double_Array_2'> = type(<multiprocessing.sharedctypes.c_double_Array_2 object at 0x0000010E0B283940>)
E        +  and   <class 'memoryview'> = type(<memory at 0x0000010E0921ED00>)
E        +    where <memory at 0x0000010E0921ED00> = array([6., 6.]).base

NumPy/Python version information:

The code example works on 1.22.3, but not 1.22.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions