-
Notifications
You must be signed in to change notification settings - Fork 85
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
base: master
Are you sure you want to change the base?
Conversation
@@ -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): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting.
No description provided.