jenkins-bot has submitted this change and it was merged. Change subject: Workaround Python 2.6.5 issue #6906 ......................................................................
Workaround Python 2.6.5 issue #6906 Before Python 2.6.6 Tk set several environment variables using unicode instead of str, which fails on Win32. Update tests.utils.execute to encode these environment variables, and improve the generated TypeError message to include original message. Bug: T108035 Change-Id: I275323c9a0af5d32d023615e5455efedcf6b6496 --- M tests/utils.py 1 file changed, 13 insertions(+), 5 deletions(-) Approvals: John Vandenberg: Looks good to me, but someone else must approve XZise: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/utils.py b/tests/utils.py index ecf02c2..ae5face 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -33,6 +33,7 @@ from pywikibot.site import Namespace from pywikibot.data.api import CachedRequest from pywikibot.data.api import Request as _original_Request +from pywikibot.tools import PYTHON_VERSION from tests import _pwb_py from tests import unittest # noqa @@ -525,6 +526,12 @@ # str() on Python 2. env = os.environ.copy() + # Python issue 6906 + if PYTHON_VERSION < (2, 6, 6): + for var in ('TK_LIBRARY', 'TCL_LIBRARY', 'TIX_LIBRARY'): + if var in env: + env[var] = env[var].encode('mbcs') + # Prevent output by test package; e.g. 'max_retries reduced from x to y' env[str('PYWIKIBOT_TEST_QUIET')] = str('1') @@ -551,21 +558,22 @@ try: p = subprocess.Popen(command, env=env, **options) - except TypeError: + except TypeError as e: # Generate a more informative error if sys.platform == 'win32' and sys.version_info[0] < 3: unicode_env = [(k, v) for k, v in os.environ.items() if not isinstance(k, str) or not isinstance(v, str)] if unicode_env: - raise TypeError('os.environ must contain only str: %r' - % unicode_env) + raise TypeError( + '%s: unicode in os.environ: %r' % (e, unicode_env)) + child_unicode_env = [(k, v) for k, v in env.items() if not isinstance(k, str) or not isinstance(v, str)] if child_unicode_env: - raise TypeError('os.environ must contain only str: %r' - % child_unicode_env) + raise TypeError( + '%s: unicode in child env: %r' % (e, child_unicode_env)) raise if data_in is not None: -- To view, visit https://gerrit.wikimedia.org/r/229400 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I275323c9a0af5d32d023615e5455efedcf6b6496 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: John Vandenberg <jay...@gmail.com> Gerrit-Reviewer: John Vandenberg <jay...@gmail.com> Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl> Gerrit-Reviewer: XZise <commodorefabia...@gmx.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits