Skip to content

[stdlib] Add Path.devnull() - #7619

Merged
modularbot merged 1 commit into
modular:mainfrom
Tharun-Kumar-McW:feat-path-devnull
Nov 18, 2026
Merged

modularbot merged 1 commit into
modular:mainfrom
Tharun-Kumar-McW:feat-path-devnull

Conversation

@Tharun-Kumar-McW

Copy link
Copy Markdown
Contributor

Fixes #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.

Changes

  • Added Path.devnull(), a @staticmethod next to Path.home() that returns
    /dev/null.
  • As agreed in the issue, it keeps raises IOError so a future platform can
    look the path up at runtime, and uses a comptime assert to limit it to
    Linux and macOS for now.
  • Added a changelog entry.

Testing

  • Added test_devnull: the path equals /dev/null, exists, and discards
    writes (reading it back returns "").
  • The pathlib tests pass locally, and ./bazelw run format reports no issues.

Assisted-by: AI

@Tharun-Kumar-McW
Tharun-Kumar-McW requested review from a team as code owners November 15, 2026 06:45
@github-actions github-actions Bot added mojo-stdlib Tag for issues related to standard library waiting-on-review mojo-docs labels Nov 15, 2026
@bgreni bgreni self-assigned this Nov 15, 2026
@bgreni

bgreni commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

!sync

@modularbot modularbot added the imported-internally Signals that a given pull request has been imported internally. label Nov 15, 2026
@modularbot

Copy link
Copy Markdown
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 modularbot added merged-internally Indicates that this pull request has been merged internally merged-externally labels Nov 18, 2026
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
@modularbot

Copy link
Copy Markdown
Collaborator

Landed in 8ca814a! Thank you for your contribution 🎉

@modularbot
modularbot merged commit c40a0db into modular:main Nov 18, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

imported-internally Signals that a given pull request has been imported internally. merged-internally Indicates that this pull request has been merged internally mojo-docs mojo-stdlib Tag for issues related to standard library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] [stdlib] Add Path.devnull() for the platform's null device

3 participants