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

lint/format-strings: Correctly exclude escaped percent symbols #14960

Merged
merged 1 commit into from Dec 22, 2018

Conversation

Projects
None yet
5 participants
@luke-jr
Copy link
Member

commented Dec 14, 2018

The current code fails to exclude correctly for patterns like "%%%X"

@MarcoFalke MarcoFalke requested a review from practicalswift Dec 14, 2018

@MarcoFalke MarcoFalke added the Tests label Dec 14, 2018

@practicalswift

This comment has been minimized.

Copy link
Member

commented Dec 15, 2018

Concept ACK. Thanks for finding and fixing this.

@luke-jr, could you add a doctest test that fails before the fix and passes after the fix?

@@ -241,12 +241,11 @@ def count_format_specifiers(format_string):
4
"""
assert(type(format_string) is str)
format_string = format_string.replace('%%', 'X')
n = 0
in_specifier = False
for i, char in enumerate(format_string):

This comment has been minimized.

Copy link
@practicalswift

practicalswift Dec 16, 2018

Member

i becomes unused after this change. Remove enumerate(...) :-)

for char in format_string:

@laanwj

This comment has been minimized.

Copy link
Member

commented Dec 18, 2018

utACK, but yes no longer need i

@promag
Copy link
Member

left a comment

tACK 5728119 — also tested @practicalswift suggestion.

@@ -241,12 +241,11 @@ def count_format_specifiers(format_string):
4
"""

This comment has been minimized.

Copy link
@promag

promag Dec 18, 2018

Member

Could add an example here.

@MarcoFalke MarcoFalke merged commit 5728119 into bitcoin:master Dec 22, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

MarcoFalke added a commit that referenced this pull request Dec 22, 2018

Merge #14960: lint/format-strings: Correctly exclude escaped percent …
…symbols

5728119 lint/format-strings: Correctly exclude escaped percent symbols (Luke Dashjr)

Pull request description:

  The current code fails to exclude correctly for patterns like `"%%%X"`

Tree-SHA512: cac6f6fb3f06a9190310cd9764ec31cd7d636f9c831057622f418ae5fd2e1d80927a88f585d18f57b279ac21e81518f714dc1a25155377b9297741a73600461e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.