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
Fixed comment and uncomment functions in file.py #24620
Conversation
Yay! It passed lint! |
Fixes #24215 |
Fixed comment and uncomment functions in file.py
limit=regex.lstrip('^'), | ||
backup=backup) | ||
pattern = '^{0}{1}'.format(char, regex.lstrip('^').rstrip('$')) | ||
repl = "{0}".format(regex.lstrip('^').rstrip('$')) |
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.
This is completely wrong! You are replacing the matched pattern with the regex itself.
This can only work if you don't actually use a regular expression.
For example if you try to uncomment level = (warning|error)
and the file contains # level = warning
it will be replaced with level = (warning|error)
.
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.
@mtorromeo Thanks. I'll take a look at and see if I can figure out a better solution.
The change is not backward compatible: new version does not recognize "[[:space:]]*" in the beginning, just after the comment char. |
comment and uncomment now use file.replace
-- Need someone to double check the regex stuff
Added comment/uncomment to the win_file.py
Tested with states