Repository navigation
[stdlib] Add Path.devnull() - #7619
Merged
Merged
Conversation
bgreni
approved these changes
Nov 15, 2026
Contributor
|
!sync |
Collaborator
|
✅🟣 This contribution has been merged 🟣✅ Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the main branch during the next Mojo nightly release, typically within the next 24-48 hours. We use Copybara to merge external contributions, click here to learn more. |
modularbot
pushed a commit
that referenced
this pull request
Nov 18, 2026
[External] [stdlib] Add Path.devnull() Associated issue: #7618 Code that needs a sink for discarded output hardcodes `"/dev/null"`, which puts a POSIX detail at every call site. `Path.devnull()` names the intent and gives one place to change if Mojo targets a platform with a different null device. Assisted-by: AI ORIGINAL_AUTHOR=Tharun-Kumar-McW <[email protected]> ORIGINAL_USER=@Tharun-Kumar-McW PUBLIC_PR_HEAD=d10b85a7a8db3a1a0ea4157a160fe03f76881b12 --------- Co-authored-by: Tharun-Kumar-McW <[email protected]> Co-authored-by: Nathan Ward <[email protected]> Pull-Request: #7619 MODULAR_ORIG_COMMIT_REV_ID: 189e9993d084b551e31e48ba8fae8ed34476950f
Collaborator
|
Landed in 8ca814a! Thank you for your contribution 🎉 |
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.
Fixes #7618
Code that needs a sink for discarded output hardcodes
"/dev/null", whichputs a POSIX detail at every call site.
Path.devnull()names the intent andgives one place to change if Mojo targets a platform with a different null
device.
Changes
Path.devnull(), a@staticmethodnext toPath.home()that returns/dev/null.raises IOErrorso a future platform canlook the path up at runtime, and uses a
comptime assertto limit it toLinux and macOS for now.
Testing
test_devnull: the path equals/dev/null, exists, and discardswrites (reading it back returns
"")../bazelw run formatreports no issues.Assisted-by: AI