Skip to content

os: fix stat_result test - #3088

Merged
youknowone merged 1 commit into
RustPython:mainfrom
deantvv:os-stat-result
Sep 19, 2021
Merged

youknowone merged 1 commit into
RustPython:mainfrom
deantvv:os-stat-result

Conversation

@deantvv

@deantvv deantvv commented Sep 18, 2021

Copy link
Copy Markdown
Contributor

Implement tp_new for stat_result

To unpack args, this PR implement a flatten_args closure to
unpack args like

args = (1, 2, 3, 4, 5, 6)
args = ((1, 2, 3, 4, 5, 6))
args = (((1, 2, 3, 4, 5, 6)))  # from pickle load

Comment thread vm/src/stdlib/os.rs Outdated
Comment on lines +1127 to +1129
if vec_args.len() == 1 {
// SAFETY: len is check in previous line
let obj = vec_args.first().unwrap();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if vec_args.len() == 1 {
// SAFETY: len is check in previous line
let obj = vec_args.first().unwrap();
if let Some(obj) = vec_args.iter().exactly_one() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@youknowone Thanks for the suggestion! Will change this as suggested.

@deantvv
deantvv force-pushed the os-stat-result branch 2 times, most recently from 6834fc9 to 380d518 Compare September 18, 2021 15:57
Implement tp_new for `stat_result`

To unpack args, this PR implement a `flatten_args` closure to
unpack args like
```
args = (1, 2, 3, 4, 5)
args = ((1, 2, 3, 4, 5))
args = (((1, 2, 3, 4, 5)))  # from pickle load
```
@youknowone
youknowone merged commit 46dc7f4 into RustPython:main Sep 19, 2021
@deantvv
deantvv deleted the os-stat-result branch September 21, 2021 01:48
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.

2 participants