Skip to content
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

does not rescue exceptions raised by to_x #710

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

does not rescue exceptions raised by to_x #710

wants to merge 1 commit into from

Conversation

kostya
Copy link
Contributor

@kostya kostya commented May 17, 2013

No description provided.

@@ -702,7 +702,9 @@ def convert_type(self, w_obj, w_cls, method, raise_error=True):

try:
w_res = self.send(w_obj, method)
except RubyError:
except RubyError as e:
if not isinstance(e.w_value, W_NoMethodError):
Copy link
Member

Choose a reason for hiding this comment

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

Use, space.is_kind_of here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm, to_x can raise NoMethodError by itself. may be here better check respond_to? instead of try except.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, using respond_to makes more sense if we don't want to catch that issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm, respond_to not good because of method_missing

Copy link
Member

Choose a reason for hiding this comment

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

In my limited tests, Hash seems to swallow NoMethodErrors from insiide to_h.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ruby -e 'x = Object.new; def x.to_int; self.aaa; end; [].take(x)'
-e:1:in `to_int': undefined method `aaa' for #<Object:0x000000026bff88> (NoMethodError)

Copy link
Member

Choose a reason for hiding this comment

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

Interesting.

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