File: test_1334.py

package info (click to toggle)
python-asdf 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,032 kB
  • sloc: python: 24,068; makefile: 123
file content (21 lines) | stat: -rw-r--r-- 447 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import numpy as np

import asdf


def test_memmap_view_access_after_close(tmp_path):
    """
    Accessing a view of a memmap after the asdf file
    is closed results in a segfault

    https://github.com/asdf-format/asdf/issues/1334
    """

    a = np.ones(10, dtype="uint8")
    fn = tmp_path / "test.asdf"
    asdf.AsdfFile({"a": a}).write_to(fn)

    with asdf.open(fn, memmap=True) as af:
        v = af["a"][:5]

    assert np.all(v == 1)