Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: gh-10882 may have broken ctypes compatibility in older versions of python #11150

Closed
@eric-wieser

Description

@eric-wieser

#10882 changed the behavior of np.array from.

  • Try to get a PEP3118 buffer interface
    • Try to convert the buffer interface into an array
    • If the buffer interface is not correct, try __array_interface__ instead
    • sometimes call abort() due to bad error silencing (ctypeslib.as_array aborts #6741)
  • If there's no buffer interface, try __array_interface__ instead

To

  • Try to get a PEP3118 memory view
    • Try to convert the buffer interface into an array
    • If the buffer interface is not correct, fail and tell the user that something is wrong
  • If there's no buffer interface, try __array_interface__ instead

This means that objects which incorrectly implement the buffer interface now fail loudly, rather than silently-or-with-abort().

Unfortunately, prior to python/cpython#31, (before 2.7.14 / 3.6.3 / 3.7.0) ctypes did not implement the buffer interface correctly for integer types (the format and itemsize didn't match)

Do we have a minimum supported patch version of python? If so, should we enable tests for it so that this doesn't happen again?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions