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

Fix a crash in HyTypeError.__str__ #1431

Merged
merged 1 commit into from
Oct 29, 2017
Merged

Conversation

Kodiologist
Copy link
Member

Fixes #1412.

# write the last line
result += ' %s\n' % colored.red("".join(source[-1]))
result += ' %s\n' % colored.green('-'*(end-1) + '^')
if all(getattr(self.expression, x, None) is not None
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this would be a lot shorter and easier to read as just:

if hasattr(self.expression, 'start_line') and ...

Or even if you decide to stick with the all route, switching to hasattr would still be best.

Copy link
Member Author

@Kodiologist Kodiologist Sep 21, 2017

Choose a reason for hiding this comment

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

The reason I used getattr(x, whatever, None) is not None instead of hasattr was that I didn't want this branch to trigger if an attribute existed but was None. We don't have anything written down saying when the attributes shouldn't exist and when they should exist but be None, so it seems safest to treat the two cases the same. That's my thinking, anyway.

@Kodiologist
Copy link
Member Author

@kirbyfan64 How do you feel about my reply?

@Kodiologist Kodiologist requested a review from gilch September 27, 2017 16:37
@tuturto tuturto merged commit fabc55a into hylang:master Oct 29, 2017
@Kodiologist Kodiologist removed the request for review from gilch October 29, 2017 23:48
@Kodiologist Kodiologist deleted the repl-crash branch March 11, 2018 21:46
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.

3 participants