Skip to content

[Bug]: Unexpected warning about filepath not ending with nwb with BytesIO backing #2125

@t-b

Description

@t-b

What happened?

pynwb 3.2.1, python

In ipfx we have a test 1 which triggers the warning:

ests/attach_metadata/test_nwb2_sink.py::test_serialize
  /home/thomas/.venvs/ipfx-3.9/lib/python3.9/site-packages/pynwb/__init__.py:432: UserWarning: The file path provided: <_io.BytesIO object at 0x7f204e8dcea0> does not end in '.nwb'. It is recommended that NWB files using the HDF5 backend use the '.nwb' extension.
    warn(f"The file path provided: {path} does not end in '.nwb'. "

Steps to Reproduce

$python
Python 3.9.23 (main, Aug 19 2025, 13:12:00) 
[GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import h5py
>>> import pynwb
>>> import io
>>> data = io.BytesIO()
>>> h5file = h5py.File(data, "w")
>>> nwb_file = pynwb.NWBHDF5IO(path=h5file.filename, mode = "w", file = h5file)
/home/thomas/.venvs/ipfx-3.9/lib/python3.9/site-packages/pynwb/__init__.py:432: UserWarning: The file path provided: <_io.BytesIO object at 0x7fdd53d68ef0> does not end in '.nwb'. It is recommended that NWB files using the HDF5 backend use the '.nwb' extension.
  warn(f"The file path provided: {path} does not end in '.nwb'. "

Traceback

Operating System

Linux

Python Executable

Python

Python Version

3.9

Package Versions

environment_for_issue.txt

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    category: bugerrors in the code or code behaviorpriority: lowalternative solution already working and/or relevant to only specific user(s)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions