Skip to content

Add os.system#1524

Merged
windelbouwman merged 4 commits into
RustPython:masterfrom
dan-fritchman:1175-extend-os
Oct 14, 2019
Merged

Add os.system#1524
windelbouwman merged 4 commits into
RustPython:masterfrom
dan-fritchman:1175-extend-os

Conversation

@dan-fritchman

Copy link
Copy Markdown
Contributor
  • Add os_system and accompanying Python attribute os.system to os.rs
  • Tested/ working on *Nix (MacOS) only. Not tested on Windows.
  • Accepts Python str argument, but not bytes or os.PathLike object

@youknowone

Copy link
Copy Markdown
Member

Thanks for contributing! Will you add some test cases about new code? There are python test snippets about os module in tests/snippets/stdlib_os.py.

Comment thread vm/src/stdlib/os.rs Outdated
fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) -> PyObjectRef {
let ctx = &vm.ctx;
extend_module!(vm, module, {
"system" => ctx.new_rustfunc(os_system),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually keep these type of lists on alphabetical order.

@dan-fritchman

Copy link
Copy Markdown
Contributor Author

Thanks for the notes.

  • Adding basic unit tests
  • Re-ordered the os-module export table, by type (function vs constant) first, and then (more or less) alphabetically
  • Linting failed on the CI server, due to the unused vm argument. (https://travis-ci.org/RustPython/RustPython/jobs/597262830) I believe os_system will always be called with a VirtualMachine as the last argument, so this is just renamed to _vm.

@windelbouwman windelbouwman merged commit 2205fec into RustPython:master Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants