Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SaferGetAttr(name, default)#1578

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
lostmsu merged 1 commit intopythonnet:masterfromlosttech:get-attr-default
Oct 1, 2021

Conversation

lostmsu
Copy link
Member

What does this implement/fix? Explain your changes.

Prior to this changePyObject.GetAttr(name, default) would ignore any exceptions, including ones unrelated to missing attribute. For example (hypothetically)PyObject is a file, and you callfile.GetAttr("len", 0), it would return0 on I/O error even thoughfile object actually haslen attribute.

Remarks

I marked the method obsolete, as even now when we restrict ignored errors toAttributeError and derived types, the behavior of this method still going to be misleading in some scenarios. For example,

classRaisesAttrErr:@propertydefprop(self):raiseAttributeErrorclassOK:def__init__(self,impl):self._impl=impl@propertydefexisting_prop(self):returnself._impl.prop
PythonEngine.Eval("OK(RaisesAttrErr())").GetAttr("existing_prop",0)// returns 0 despite existing_prop actually existing -^ in OK

Does this close any currently open issues?

fixes#1036

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • Updated theCHANGELOG

@lostmsulostmsu merged commit5d0d01a intopythonnet:masterOct 1, 2021
@lostmsulostmsu deleted the get-attr-default branchOctober 1, 2021 20:07
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@filmorfilmorfilmor approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

PyObject.GetAttr(string, PyObject _default) masks any exceptions
2 participants
@lostmsu@filmor

[8]ページ先頭

©2009-2025 Movatter.jp