GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix logging error message by larsoner · Pull Request #22276 · python/cpython

Conversation

@larsoner

@larsoner larsoner commented Sep 16, 2020

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@larsoner
Fix logging error message
ed4ba51
@larsoner
larsoner requested a review from vsajip as a code owner September 16, 2020 13:22
@the-knights-who-say-ni the-knights-who-say-ni added the CLA not signed label Sep 16, 2020
@the-knights-who-say-ni

the-knights-who-say-ni commented Sep 16, 2020

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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added the awaiting review label Sep 16, 2020
vsajip
vsajip requested changes Sep 16, 2020
View reviewed changes
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)}")

@vsajip vsajip Sep 16, 2020

Copy link
Copy Markdown
Member

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.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
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: "

@vsajip vsajip Sep 16, 2020

Copy link
Copy Markdown
Member

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 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@larsoner larsoner Sep 17, 2020

Copy link
Copy Markdown
Contributor Author

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.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting changes and removed awaiting review labels Sep 16, 2020
@bedevere-bot

bedevere-bot commented Sep 16, 2020

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@the-knights-who-say-ni the-knights-who-say-ni added CLA signed and removed CLA not signed labels Sep 17, 2020
@larsoner
STY: Dont use f-strings
c04a0a9
@larsoner

larsoner commented Sep 17, 2020

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added awaiting change review and removed awaiting changes labels Sep 17, 2020
@bedevere-bot

bedevere-bot commented Sep 17, 2020

Copy link
Copy Markdown

Thanks for making the requested changes!

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot
bedevere-bot requested a review from vsajip September 17, 2020 12:57
@vsajip vsajip added skip issue skip news labels Sep 18, 2020
@vsajip

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

bedevere-bot commented 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

vsajip commented Sep 25, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@larsoner larsoner mentioned this pull request Sep 25, 2020
Fix logging error message #22410
Merged
@larsoner

larsoner commented Sep 25, 2020

Copy link
Copy Markdown
Contributor Author

Closing for #22276

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@larsoner larsoner closed this Sep 25, 2020
miss-islington pushed a commit that referenced this pull request Sep 25, 2020
@larsoner
Fix logging error message (GH-22410)
9fdb76c
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
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
@larsoner @xzy3-cdc
Fix logging error message (pythonGH-22410)
01503d1
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vsajip vsajip Awaiting requested review from vsajip

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting change review skip issue skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@larsoner @the-knights-who-say-ni @bedevere-bot @vsajip
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.