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

PR: Catch search regexp error while doing replace/find #5618

Merged
merged 3 commits into from
Nov 1, 2017

Conversation

timhoffm
Copy link
Contributor

fixes #5386

Perfroming replace_find() and replace_find_selection() with an invalid regexp used to raise an exception. After this patch, they will do nothing and silently return.

@ccordoba12 ccordoba12 added this to the v3.2.5 milestone Oct 31, 2017
@ccordoba12 ccordoba12 requested a review from dalthviz October 31, 2017 13:40
@ccordoba12
Copy link
Member

Nice! Thanks a lot for this!

@dalthviz, please review @timhoffm's work.

@rlaverde
Copy link
Member

Maybe you could generalize the function rexexp_error_msg of #5614 and use in this PR too, something like:

def safe_regex(pattern):
    ....
    return compile_pattern, error 

@pep8speaks
Copy link

Hello @timhoffm! Thanks for updating the PR.

Line 338:1: E302 expected 2 blank lines, found 1

@ccordoba12
Copy link
Member

@timhoffm, don't worry about PEP8 issues in our test files. You can safely ignore pep8speaks in that case.

@timhoffm
Copy link
Contributor Author

@ccordoba12 If you don't want pep8speaks on test files, you could add

pycodestyle:
    exclude: test_*.py

to .pep8speaks.yml

@ccordoba12
Copy link
Member

Good to know! Will do that in another PR (I looked how to do it some time ago but didn't find a straight answer).

Copy link
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

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

Thanks @timhoffm, nice work I think everything its ok. I also tested locally and everything regarding your changes works as expected 👍

@dalthviz
Copy link
Member

About what @rlaverde says (in terms of the generalization of the rexexp_error_msg of #5614) it could be a possibility. Maybe we could merge this one first an decide what to do regarding the rexexp_error_msg in #5614

What do you guys think @rlaverde, @ccordoba12, @timhoffm?

@dalthviz dalthviz changed the title PR: Catch seatch regexp error PR: Catch search regexp error while doing replace/find Oct 31, 2017
@ccordoba12
Copy link
Member

I agree, let's merge this one first. I think there's an error with Pandas that's making our tests to fail, so I'll take a look at that first before merging more work.

@timhoffm
Copy link
Contributor Author

timhoffm commented Oct 31, 2017

@rlaverde, @ccordoba12, @dalthviz

I would do one step at a time. Both this PR and #5614 are reasonable solutions in themselves and can be merged as they are.

In a second step, we can then see if a generalization of regexp_error_msg (note: typo is fixed) makes sense. I'm not yet sure about this. In this request, we don't need the message, and in #5614 we don't need the compiled expression.

@ccordoba12
Copy link
Member

In this request we don't need the message and in #5614 we don't need the pattern.

@rlaverde?

@rlaverde
Copy link
Member

In this request we don't need the message and in #5614 we don't need the pattern

yes, that's true, but in both the try..except is repeated

try:
    re_pattern = re.compile(search_text)
except re.error:
    return

@ccordoba12
Copy link
Member

Let's leave a further refactoring for another PR.

@ccordoba12 ccordoba12 merged commit f77939b into spyder-ide:3.x Nov 1, 2017
ccordoba12 added a commit that referenced this pull request Nov 1, 2017
@timhoffm timhoffm deleted the catch-serach-regexp-error branch November 1, 2017 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants