Add pathlib.Path support for audio file I/O#475
Open
gijzelaerr wants to merge 5 commits intospotify:masterfrom
Open
Add pathlib.Path support for audio file I/O#475gijzelaerr wants to merge 5 commits intospotify:masterfrom
gijzelaerr wants to merge 5 commits intospotify:masterfrom
Conversation
…ects The py::object overloads for write mode would call pathToString() without first checking isPathLike(), causing errors when pybind11 routed file-like objects to the wrong overload. Add proper type dispatch: check isPathLike() first, then fall back to isWriteableFileLike(), with a clear error otherwise. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Picks up @psobot's work from #451 to add
pathlib.Pathsupport throughout the audio file I/O API.os.fspath()via pybind11 to convert path-like objects to strings (PathUtils.h)py::objectoverloads inReadableAudioFile,WriteableAudioFile, andAudioFileconstructors that acceptpathlib.Path(and anyos.PathLike)pathToString()Union[str, Path]Changes from psobot's original PR
pathLikeOrStrreferences)py::object filenameoverloadTest plan
pathlib.Pathworks end-to-end for reading and writing WAV filesAudioFile(Path(...))works for both read and write modestest_write_to_seekable_streamfailures also present on master)test_read_from_end_of_stream_produces_helpful_error_messagepasses locallyCloses #451
🤖 Generated with Claude Code