Skip to content

fix: handle OSError in _get_mtime for non-file paths - #11392

Merged
dcherian merged 1 commit into
pydata:mainfrom
gaoflow:fix-11386-get-mtime-non-file
Jun 24, 2026
Merged

fix: handle OSError in _get_mtime for non-file paths#11392
dcherian merged 1 commit into
pydata:mainfrom
gaoflow:fix-11386-get-mtime-non-file

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

_get_mtime() calls os.path.getmtime() on any non-remote path,
but some paths that look like local filesystem paths are actually
GDAL virtual filesystems (/vsicurl/..., /vsis3/...) or other
URI schemes that don't support stat(). This causes OSError to
propagate and crash open_dataset().

Wrap the getmtime call in contextlib.suppress(OSError) so that
non-file paths gracefully return mtime = None instead of raising.

  • Tests added
  • All tests pass

@welcome

welcome Bot commented Jun 17, 2026

Copy link
Copy Markdown

Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient.
If you have questions, some answers may be found in our contributing guidelines.

@wahajahmed010

Copy link
Copy Markdown

test

)

_get_mtime calls os.path.getmtime on any non-remote path, but some
paths that look like local filesystem paths are actually GDAL virtual
filesystems (/vsicurl/..., /vsis3/...) or other URI schemes that
don't support stat(). Wrap the call in suppress(OSError) to avoid
crashing on these paths.
@gaoflow
gaoflow force-pushed the fix-11386-get-mtime-non-file branch from 3182017 to 861bad8 Compare June 19, 2026 00:09
@dcherian dcherian changed the title fix: handle OSError in _get_mtime for non-file paths (fixes #11386) fix: handle OSError in _get_mtime for non-file paths Jun 24, 2026
@dcherian
dcherian merged commit 0d0be21 into pydata:main Jun 24, 2026
43 checks passed
@welcome

welcome Bot commented Jun 24, 2026

Copy link
Copy Markdown

Congratulations on completing your first pull request! Welcome to Xarray! We are proud of you, and hope to see you again! celebration gif

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants