Skip to content

Add itertools.chain.__setstate__ #3779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

nonzerofloat
Copy link

No description provided.

@youknowone
Copy link
Member

@nonzerofloat you may forgot to set git config user.email

@nonzerofloat
Copy link
Author

nonzerofloat commented Jun 11, 2022

Generally git do not allow commits without an email registered. That's perhaps because the commit's email is not consistent with my account's email. I have fixed.

Correct lint errors.

impl IterNextIterable for PyItertoolsChain {}
impl IterNext for PyItertoolsChain {
fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
let iterables = zelf.iterables.read();
Copy link
Member

Choose a reason for hiding this comment

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

This change may cause dead-lock

Copy link
Author

Choose a reason for hiding this comment

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

Can you give me more detailed explanation for deadlock? I suspect the place is suitable. Deadlock is unexpected.

Copy link
Member

Choose a reason for hiding this comment

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

Guess we have a chain with self-editing iterable on __iter__. Previously, we locked iterable only before and after get_iter, it is safe.
After change, this line will hold the lock for entire loop. Any write operation in get_iter will be permanently blocked.

@rng-dynamics
Copy link
Contributor

The implementation of itertools.chain has changed with #3788. I guess we should rebase this MR onto main (or something similar).

@youknowone
Copy link
Member

youknowone commented Feb 21, 2023

Oh, this is done in #4232

Thanks @dannasman !

And thank you for contributing @nonzerofloat

@youknowone youknowone closed this Feb 21, 2023
fn setstate(&self, state: PyTupleRef, vm: &VirtualMachine) -> PyResult<()> {
let args = state.as_slice();
if args.is_empty() {
let msg = String::from("function takes at leat 1 arguments (0 given)");
Copy link

Choose a reason for hiding this comment

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

leat should be least.

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