Skip to content

Fix deque repr to print correct format - #3218

Merged
youknowone merged 1 commit into
RustPython:mainfrom
lijm1358:deque-repr
Oct 4, 2021
Merged

youknowone merged 1 commit into
RustPython:mainfrom
lijm1358:deque-repr

Conversation

@lijm1358

@lijm1358 lijm1358 commented Oct 4, 2021

Copy link
Copy Markdown
Contributor

This fixes PyDeque.repr in #3217

before

>>>>> from collections import deque
>>>>> class MyDeque(deque): pass
>>>>> MyDeque()
deque([])

after

>>>>> from collections import deque
>>>>> class MyDeque(deque): pass
>>>>> MyDeque()
MyDeque([])

@lijm1358 lijm1358 changed the title fix deque repr to print correct format Fix deque repr to print correct format Oct 4, 2021
Comment thread vm/src/stdlib/collections.rs Outdated
format!("deque([{}]{})", elements.into_iter().format(", "), maxlen)
format!(
"{}([{}]{})",
zelf.class().slot_name(),

@youknowone youknowone Oct 4, 2021 •

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 don't know well about this spec. is this not zelf.class().name() but zelf.class().slot_name()?

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.

First thought name() and slot_name() showed the same value, but name() returning self.slot_name().rsplit('.').next().unwrap().to_string() looks more good to me now. Thanks for reviewing!

@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 5254265 into RustPython:main Oct 4, 2021
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