Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(16)

#25280: Message can be formatted twice in importlib

Can't Edit
Can't Publish+Mail
Start Review
Created:
4 years, 4 months ago by storchaka+cpython
Modified:
4 years, 3 months ago
Reviewers:
brett
CC:
brett.cannon, Nick Coghlan, devnull_psf.upfronthosting.co.za, eric.snow, storchaka
Visibility:
Public.

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Lib/importlib/_bootstrap_external.py View 2 chunks +8 lines, -8 lines 3 comments Download
Python/importlib_external.h View 3 chunks +1938 lines, -1940 lines 0 comments Download

Messages

Total messages: 3
brett.cannon
Unfortunately I don't think the approach will work (see my inline comment). http://bugs.python.org/review/25280/diff/15664/Lib/importlib/_bootstrap_external.py File Lib/importlib/_bootstrap_external.py ...
4 years, 3 months ago #1
storchaka_gmail.com
http://bugs.python.org/review/25280/diff/15664/Lib/importlib/_bootstrap_external.py File Lib/importlib/_bootstrap_external.py (right): http://bugs.python.org/review/25280/diff/15664/Lib/importlib/_bootstrap_external.py#newcode433 Lib/importlib/_bootstrap_external.py:433: raise ImportError(message, **exc_details) On 2015/09/30 18:24:45, brett.cannon wrote: > ...
4 years, 3 months ago #2
brett.cannon
4 years, 3 months ago #3
http://bugs.python.org/review/25280/diff/15664/Lib/importlib/_bootstrap_exter...
File Lib/importlib/_bootstrap_external.py (right):

http://bugs.python.org/review/25280/diff/15664/Lib/importlib/_bootstrap_exter...
Lib/importlib/_bootstrap_external.py:433: raise ImportError(message,
**exc_details)
On 2015/09/30 20:14:01, storchaka wrote:
> On 2015/09/30 18:24:45, brett.cannon wrote:
> > Won't `message` be unformatted for the exception argument in this case and
the
> > ones below?
> > 
> > Might need to modify _verbose_message() to simply skip the format() call if
> > *args is empty, else added a `formatted=False` keyword parameter to
> > _verbose_message() that when set to true skips calling str.format().
> 
> Skipping the format() call if *args is empty looks dangerous. There is a risk
to
> output an unformatted message. formatted=False looks cumbersome.
> 
> We can solve this issue without changing _verbose_message if call it with
> formatted message as _verbose_message('{}', message).

SGTM
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+