Skip to content

Fix itertools count repr - #3824

Merged
youknowone merged 5 commits into
RustPython:mainfrom
mumallaeng:fix_itertools_count_repr
Jul 1, 2022
Merged

youknowone merged 5 commits into
RustPython:mainfrom
mumallaeng:fix_itertools_count_repr

Conversation

@mumallaeng

Copy link
Copy Markdown
Contributor

No description provided.

@fanninpm

Copy link
Copy Markdown
Contributor

Feel free to ignore those Clippy failures. @youknowone likely missed them in #3817.

@fanninpm

fanninpm commented Jun 29, 2022 •

Copy link
Copy Markdown
Contributor

In Lib/test/test_itertools.py, if you comment out the @unittest.expectedFailure decorator above def test_count(self): (about line 537 or so), what happens? I suspect that the __reduce__() method of itertools.count is causing the pickle portion of that test to fail.

EDIT: Please don't add what I'm asking to a commit just yet — local results are just fine.

@youknowone

Copy link
Copy Markdown
Member

please do not use git merge. would you try to rebase it?

https://docs.gitlab.com/ee/topics/git/git_rebase.html

Comment thread vm/src/stdlib/itertools.rs Outdated
Comment on lines +225 to +226
let step = format!("{}", self.step.clone());
if step != "1" {

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.

I expected comparing the value instead of comparing the result.
Do you know what's the original way?

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.

@mumallaeng
mumallaeng force-pushed the fix_itertools_count_repr branch from 65f96a8 to 3f8eb24 Compare June 30, 2022 08:04
Comment thread vm/src/stdlib/itertools.rs Outdated
cur.push_str(", ");
cur.push_str(&step);
let cur = format!("{}", self.cur.read().clone().repr(vm)?);
let step = self.step.as_u32_mask().clone();

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.

Suggested change
let step = self.step.as_u32_mask().clone();
let step = self.step.as_bigint();

@Snowapril

Copy link
Copy Markdown
Contributor

After #3830 merged, the clippy error also will be passed.

@youknowone youknowone left a comment

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.

Thank you for contributing!

@youknowone
youknowone merged commit 99b8d29 into RustPython:main Jul 1, 2022
@mumallaeng
mumallaeng deleted the fix_itertools_count_repr branch July 1, 2022 16:14
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.

4 participants