Skip to content

Add weak proxy str#3731

Merged
youknowone merged 3 commits intoRustPython:mainfrom
CHOUMnote:addWeakProxyStr
May 21, 2022
Merged

Add weak proxy str#3731
youknowone merged 3 commits intoRustPython:mainfrom
CHOUMnote:addWeakProxyStr

Conversation

@CHOUMnote
Copy link
Copy Markdown
Contributor

After a weakReference and str() call, the two values were different in comparison, resulting in an error
I found it, "weakproxy object" is not have "__str__()" so calling by "parent object" in "__str__()"
So I added in "weakproxy. rs" made it and "str()"method is work normally


# TODO: RUSTPYTHON
@unittest.expectedFailure

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

use super::{PyStrRef, PyTypeRef, PyWeak};
use crate::{
class::PyClassImpl,
convert::ToPyObject,
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
convert::ToPyObject,

unused import

Comment on lines +78 to +80
None => Err(vm.new_exception_msg(
vm.ctx.exceptions.reference_error.clone(),
"weakly-referenced object no longer exists".to_owned(),
)),
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.

this part is an exact repeat of error in getattr().

please create a function new_reference_error() not to manually repeat the exception creation.

CHOUMnote added 2 commits May 21, 2022 19:30
  file : test_deque.py
  method : test_weakref()

  error occurred because the return value of str() was different
  so add __str__() in weakproxy
Signed-off-by: CHOUMnote <rlawlgh1028@naver.com>
@CHOUMnote CHOUMnote force-pushed the addWeakProxyStr branch 2 times, most recently from 7b34961 to 70c0c70 Compare May 21, 2022 10:58
Copy link
Copy Markdown
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

looks good, thank you for contributing!

@youknowone youknowone merged commit 4a0be5a into RustPython:main May 21, 2022
@CHOUMnote CHOUMnote deleted the addWeakProxyStr branch May 22, 2022 13:05
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