jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/342122 )
Change subject: Fix logging in python3 when deprecated_args decorator is used
......................................................................
Fix logging in python3 when deprecated_args decorator is used
Remove check on record path, which was failing in python 3.
Remove special treatment between python 2 and 3, leaving the default
behaviour for each version.
Logging out put is slightly different in python 3.6 with respect to the
others, as record.pathname is warnings.py.
Leave indication of original caller module:linenno in message.
Bug: T159077
Change-Id: I0c13551406e709d0082874d383962fd514dcae99
---
M pywikibot/tools/_logging.py
1 file changed, 0 insertions(+), 12 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/tools/_logging.py b/pywikibot/tools/_logging.py
index 55d4c7d..b318281 100644
--- a/pywikibot/tools/_logging.py
+++ b/pywikibot/tools/_logging.py
@@ -72,27 +72,15 @@
"""Strip trailing newlines before outputting text to
file."""
# Warnings captured from the warnings system are not processed by
# logoutput(), so the 'context' variables are missing.
- # The same context details are provided by Python 3.X, but need to
- # be extracted from the warning message for Python <= 2.7.
if record.name == 'py.warnings' and 'caller_file' not in
record.__dict__:
assert len(record.args) == 1, \
'Arguments for record is not correctly set'
msg = record.args[0]
- if PY2:
- record.pathname = msg.partition(':')[0]
- record.lineno = msg.partition(':')[2].partition(':')[0]
- record.module =
msg.rpartition('/')[2].rpartition('.')[0]
- else:
- assert msg.startswith(record.pathname + ':'), \
- 'Record argument should start with path'
-
record.__dict__['caller_file'] = record.pathname
record.__dict__['caller_name'] = record.module
record.__dict__['caller_line'] = record.lineno
- # Remove the path and the line number, and strip the extra space
- msg = msg.partition(':')[2].partition(':')[2].lstrip()
record.args = (msg,)
text = logging.handlers.RotatingFileHandler.format(self, record)
--
To view, visit
https://gerrit.wikimedia.org/r/342122
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0c13551406e709d0082874d383962fd514dcae99
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>