This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Let logging format more messages on demand
Type: behavior Stage: resolved
Components: Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: koobs, python-dev, r.david.murray, scop, vinay.sajip, xiang.zhang
Priority: normal Keywords: patch

Created on 2016-08-30 21:35 by scop, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
logging.patch scop, 2016-08-30 21:35 review
logging-regressions.patch scop, 2016-08-31 14:11 review
Messages (6)
msg273971 - (view) Author: Ville Skyttä (scop) * Date: 2016-08-30 21:35
Avoid some string formatting operations on disabled log levels.
msg274004 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-08-31 07:22
New changeset 1340e298aa7e by Vinay Sajip in branch 'default':
Closes #27904: Improved logging statements to defer formatting until needed.
https://hg.python.org/cpython/rev/1340e298aa7e
msg274006 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-08-31 09:02
Vinay, this patch introduces regressions.

You can either revert this part:

--- a/Lib/distutils/cmd.py
+++ b/Lib/distutils/cmd.py
@@ -329,8 +329,7 @@ class Command:
     # -- External world manipulation -----------------------------------

     def warn(self, msg):
-        log.warn("warning: %s: %s\n" %
-                (self.get_command_name(), msg))
+        log.warn("warning: %s: %s\n", self.get_command_name(), msg)

     def execute(self, func, args, msg=None, level=1):
         util.execute(func, args, msg, dry_run=self.dry_run)

or change the test suites to:

diff -r 1340e298aa7e Lib/distutils/tests/test_build_py.py
--- a/Lib/distutils/tests/test_build_py.py	Wed Aug 31 08:22:29 2016 +0100
+++ b/Lib/distutils/tests/test_build_py.py	Wed Aug 31 16:59:27 2016 +0800
@@ -168,7 +168,8 @@
         finally:
             sys.dont_write_bytecode = old_dont_write_bytecode
 
-        self.assertIn('byte-compiling is disabled', self.logs[0][1])
+        self.assertIn('byte-compiling is disabled',
+                      self.logs[0][1] % self.logs[0][2])
 
 
 def test_suite():
diff -r 1340e298aa7e Lib/distutils/tests/test_install_lib.py
--- a/Lib/distutils/tests/test_install_lib.py	Wed Aug 31 08:22:29 2016 +0100
+++ b/Lib/distutils/tests/test_install_lib.py	Wed Aug 31 16:59:27 2016 +0800
@@ -104,7 +104,8 @@
         finally:
             sys.dont_write_bytecode = old_dont_write_bytecode
 
-        self.assertIn('byte-compiling is disabled', self.logs[0][1])
+        self.assertIn('byte-compiling is disabled',
+                      self.logs[0][1] % self.logs[0][2])
 
 
 def test_suite():
msg274021 - (view) Author: Ville Skyttä (scop) * Date: 2016-08-31 14:11
Here's a patch that fixes the tests.
msg274031 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-08-31 15:40
New changeset 5f6dac170b9b by R David Murray in branch 'default':
#27904: fix distutils tests.
https://hg.python.org/cpython/rev/5f6dac170b9b
msg274032 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-08-31 15:43
Thanks, Ville.
History
Date User Action Args
2022-04-11 14:58:35adminsetgithub: 72091
2016-08-31 16:01:58SilentGhostsetstage: patch review -> resolved
2016-08-31 15:43:24r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg274032

resolution: fixed
2016-08-31 15:40:14python-devsetmessages: + msg274031
2016-08-31 14:11:49scopsetfiles: + logging-regressions.patch

messages: + msg274021
2016-08-31 12:19:19koobssetnosy: + koobs
2016-08-31 09:32:11SilentGhostsetstatus: closed -> open
type: performance -> behavior
resolution: fixed -> (no value)
stage: resolved -> patch review
2016-08-31 09:02:52xiang.zhangsetnosy: + xiang.zhang
messages: + msg274006
2016-08-31 07:22:50python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg274004

resolution: fixed
stage: patch review -> resolved
2016-08-31 06:16:57SilentGhostsetnosy: + vinay.sajip
stage: patch review

versions: + Python 3.6
2016-08-30 21:35:23scopcreate