FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix logging error message by larsoner · Pull Request #22276 · python/cpython · GitHub

/ cpython Public

Fix logging error message - #22276

Closed
larsoner wants to merge 2 commits into
python:masterfrom
larsoner:fix-logger-level-message
Closed

Fix logging error message#22276
larsoner wants to merge 2 commits into
python:masterfrom
larsoner:fix-logger-level-message

Conversation

Copy link
Copy Markdown
Contributor

Not 100% sure if this needs an issue since I considered it trivial at first -- master has this pattern:

raise ValueError("Unknown level: %r" % level)

this fails if level is a tuple. This PR switches to f-string, but an alternative to keep % would be just to do % (level,).

But when implementing a test by reusing assert_error_message I noticed that assert_error_message was not doing what I think it was intended to do -- it never really checked to make sure the emitted error message actually matched the given error message. So I refactored it to actually check that the error message matched the one passed to assert_error_message, which then required fixing a few existing tests in FormatterTest, as the messages were actually outdated.

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

Recognized GitHub username

We couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames:

@larsoner

This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

Comment thread Lib/logging/__init__.py Outdated
elif str(level) == level:
if level not in _nameToLevel:
raise ValueError("Unknown level: %r" % level)
raise ValueError(f"Unknown level: {repr(level)}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

To get to this code you would need to have passed the test str(level) == level, how would a tuple do this? I wouldn't think this line needs changing.

Comment thread Lib/logging/__init__.py Outdated
rv = _nameToLevel[level]
else:
raise TypeError("Level not an integer or a valid string: %r" % level)
raise TypeError("Level not an integer or a valid string: "

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This could just be "Level not an integer or a valid string: %s" % repr(level) which should always work. I'm not against f-strings, but there is no need to introduce them here for this purpose.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I went with "...: %r" % (level,)" since it's closer to the old code, but happy to push a commit to go with your variant if you want

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

Copy link
Copy Markdown

Thanks for making the requested changes!

@vsajip: please review the changes made to this pull request.

vsajip commented Sep 18, 2020

Copy link
Copy Markdown
Member

A Travis build appears to have stalled. I'll close and re-open, then test with buildbots.

vsajip closed this Sep 18, 2020
vsajip reopened this Sep 18, 2020
vsajip added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 18, 2020

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vsajip for commit c04a0a9 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 18, 2020

vsajip commented Sep 19, 2020

Copy link
Copy Markdown
Member

Build still stalled on Travis job. Closing and reopening to see if that unblocks it.

vsajip closed this Sep 19, 2020
vsajip reopened this Sep 19, 2020

vsajip commented Sep 25, 2020
edited
Loading

Copy link
Copy Markdown
Member

@larsoner This PR is unfortunately blocked from merge due to a problem with either GitHub or Travis (not sure which, as it seems to be in the interface between them). If you're in a hurry to progress this, it might be an idea to create a new PR with your current changes, and seeing if that one can go through (don't close this PR, though, it might be useful for diagnosing the GH/Travis problem).

Discussion here.

Copy link
Copy Markdown
Contributor Author

Closing for #22276

larsoner closed this Sep 25, 2020
miss-islington pushed a commit that referenced this pull request Sep 25, 2020
Same changes as #22276 squashed to a single commit. Just hoping to get Travis to cooperate by opening a new PR...

Automerge-Triggered-By: @vsajip
larsoner deleted the fix-logger-level-message branch September 25, 2020 18:19
xzy3 pushed a commit to xzy3/cpython that referenced this pull request Oct 18, 2020
Same changes as python#22276 squashed to a single commit. Just hoping to get Travis to cooperate by opening a new PR...

Automerge-Triggered-By: @vsajip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL