From 7054e5c80b6e98cd44e22d1bc2d7f0a94343089d Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 5 Nov 2018 17:13:50 +0200 Subject: [3.6] bpo-35133: Fix mistakes when concatenate string literals on different lines. (GH-10284) (GH-10335) Two kind of mistakes: 1. Missed space. After concatenating there is no space between words. 2. Missed comma. Causes unintentional concatenating in a list of strings.. (cherry picked from commit 34fd4c20198dea6ab2fe8dc6d32d744d9bde868d) --- Lib/_pydecimal.py | 2 +- Lib/distutils/command/bdist_dumb.py | 2 +- Lib/distutils/command/bdist_msi.py | 4 ++-- Lib/distutils/command/bdist_rpm.py | 2 +- Lib/distutils/command/bdist_wininst.py | 4 ++-- Lib/distutils/command/build_ext.py | 2 +- Lib/email/_header_value_parser.py | 4 ++-- Lib/idlelib/hyperparser.py | 2 +- Lib/idlelib/idle_test/htest.py | 8 ++++---- Lib/idlelib/idle_test/mock_tk.py | 2 +- Lib/test/test_compile.py | 2 +- Lib/test/test_decimal.py | 4 ++-- Lib/test/test_http_cookiejar.py | 6 ++---- Lib/test/test_range.py | 2 +- Lib/test/test_smtplib.py | 2 +- Lib/test/test_strptime.py | 4 ++-- Lib/trace.py | 4 ++-- Lib/unittest/mock.py | 2 +- Modules/_datetimemodule.c | 2 +- Modules/_pickle.c | 4 ++-- Python/import.c | 2 +- Tools/scripts/texi2html.py | 4 ++-- 22 files changed, 34 insertions(+), 36 deletions(-) diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py index 0b40928..e7df67d 100644 --- a/Lib/_pydecimal.py +++ b/Lib/_pydecimal.py @@ -2062,7 +2062,7 @@ class Decimal(object): if not other and not self: return context._raise_error(InvalidOperation, 'at least one of pow() 1st argument ' - 'and 2nd argument must be nonzero ;' + 'and 2nd argument must be nonzero; ' '0**0 is not defined') # compute sign of result diff --git a/Lib/distutils/command/bdist_dumb.py b/Lib/distutils/command/bdist_dumb.py index e9274d9..f0d6b5b 100644 --- a/Lib/distutils/command/bdist_dumb.py +++ b/Lib/distutils/command/bdist_dumb.py @@ -32,7 +32,7 @@ class bdist_dumb(Command): ('skip-build', None, "skip rebuilding everything (for testing/debugging)"), ('relative', None, - "build the archive using relative paths" + "build the archive using relative paths " "(default: false)"), ('owner=', 'u', "Owner name used when creating a tar file" diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py index a4bd5a5..80104c3 100644 --- a/Lib/distutils/command/bdist_msi.py +++ b/Lib/distutils/command/bdist_msi.py @@ -98,14 +98,14 @@ class bdist_msi(Command): ('no-target-compile', 'c', "do not compile .py to .pyc on the target system"), ('no-target-optimize', 'o', - "do not compile .py to .pyo (optimized)" + "do not compile .py to .pyo (optimized) " "on the target system"), ('dist-dir=', 'd', "directory to put final built distributions in"), ('skip-build', None, "skip rebuilding everything (for testing/debugging)"), ('install-script=', None, - "basename of installation script to be run after" + "basename of installation script to be run after " "installation or before deinstallation"), ('pre-install-script=', None, "Fully qualified filename of a script to be run before " diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py index ac46217..02f10dd 100644 --- a/Lib/distutils/command/bdist_rpm.py +++ b/Lib/distutils/command/bdist_rpm.py @@ -58,7 +58,7 @@ class bdist_rpm(Command): "RPM \"vendor\" (eg. \"Joe Blow \") " "[default: maintainer or author from setup script]"), ('packager=', None, - "RPM packager (eg. \"Jane Doe \")" + "RPM packager (eg. \"Jane Doe \") " "[default: vendor]"), ('doc-files=', None, "list of documentation files (space or comma-separated)"), diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py index 0871a4f..fde5675 100644 --- a/Lib/distutils/command/bdist_wininst.py +++ b/Lib/distutils/command/bdist_wininst.py @@ -29,7 +29,7 @@ class bdist_wininst(Command): ('no-target-compile', 'c', "do not compile .py to .pyc on the target system"), ('no-target-optimize', 'o', - "do not compile .py to .pyo (optimized)" + "do not compile .py to .pyo (optimized) " "on the target system"), ('dist-dir=', 'd', "directory to put final built distributions in"), @@ -40,7 +40,7 @@ class bdist_wininst(Command): ('skip-build', None, "skip rebuilding everything (for testing/debugging)"), ('install-script=', None, - "basename of installation script to be run after" + "basename of installation script to be run after " "installation or before deinstallation"), ('pre-install-script=', None, "Fully qualified filename of a script to be run before " diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py index 74de782..8ed4065 100644 --- a/Lib/distutils/command/build_ext.py +++ b/Lib/distutils/command/build_ext.py @@ -365,7 +365,7 @@ class build_ext(Command): ext_name, build_info = ext log.warn("old-style (ext_name, build_info) tuple found in " - "ext_modules for extension '%s'" + "ext_modules for extension '%s' " "-- please convert to Extension instance", ext_name) if not (isinstance(ext_name, str) and diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py index de7ab5d..1fb8cb4 100644 --- a/Lib/email/_header_value_parser.py +++ b/Lib/email/_header_value_parser.py @@ -2210,8 +2210,8 @@ def get_section(value): digits += value[0] value = value[1:] if digits[0] == '0' and digits != '0': - section.defects.append(errors.InvalidHeaderError("section number" - "has an invalid leading 0")) + section.defects.append(errors.InvalidHeaderError( + "section number has an invalid leading 0")) section.number = int(digits) section.append(ValueTerminal(digits, 'digits')) return section, value diff --git a/Lib/idlelib/hyperparser.py b/Lib/idlelib/hyperparser.py index 7581fe27..7e7e0ae 100644 --- a/Lib/idlelib/hyperparser.py +++ b/Lib/idlelib/hyperparser.py @@ -224,7 +224,7 @@ class HyperParser: given index, which is empty if there is no real one. """ if not self.is_in_code(): - raise ValueError("get_expression should only be called" + raise ValueError("get_expression should only be called " "if index is inside a code.") rawtext = self.rawtext diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py index 8c1c24d..583e607 100644 --- a/Lib/idlelib/idle_test/htest.py +++ b/Lib/idlelib/idle_test/htest.py @@ -117,7 +117,7 @@ ConfigDialog_spec = { "font face of the text in the area below it.\nIn the " "'Highlighting' tab, try different color schemes. Clicking " "items in the sample program should update the choices above it." - "\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings" + "\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings " "of interest." "\n[Ok] to close the dialog.[Apply] to apply the settings and " "and [Cancel] to revert all changes.\nRe-run the test to ensure " @@ -152,7 +152,7 @@ GetKeysDialog_spec = { 'msg': "Test for different key modifier sequences.\n" " is invalid.\n" "No modifier key is invalid.\n" - "Shift key with [a-z],[0-9], function key, move key, tab, space" + "Shift key with [a-z],[0-9], function key, move key, tab, space " "is invalid.\nNo validity checking if advanced key binding " "entry is used." } @@ -234,7 +234,7 @@ _percolator_spec = { 'file': 'percolator', 'kwds': {}, 'msg': "There are two tracers which can be toggled using a checkbox.\n" - "Toggling a tracer 'on' by checking it should print tracer" + "Toggling a tracer 'on' by checking it should print tracer " "output to the console or to the IDLE shell.\n" "If both the tracers are 'on', the output from the tracer which " "was switched 'on' later, should be printed first\n" @@ -335,7 +335,7 @@ ViewWindow_spec = { _widget_redirector_spec = { 'file': 'redirector', 'kwds': {}, - 'msg': "Every text insert should be printed to the console." + 'msg': "Every text insert should be printed to the console " "or the IDLE shell." } diff --git a/Lib/idlelib/idle_test/mock_tk.py b/Lib/idlelib/idle_test/mock_tk.py index 6e35129..a54f51f 100644 --- a/Lib/idlelib/idle_test/mock_tk.py +++ b/Lib/idlelib/idle_test/mock_tk.py @@ -260,7 +260,7 @@ class Text: elif op == '!=': return line1 != line2 or char1 != char2 else: - raise TclError('''bad comparison operator "%s":''' + raise TclError('''bad comparison operator "%s": ''' '''must be <, <=, ==, >=, >, or !=''' % op) # The following Text methods normally do something and return None. diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index c9812e4..745ce02 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -285,7 +285,7 @@ if 1: 'from sys import stdin)', 'from sys import stdin, stdout,\nstderr', 'from sys import stdin si', - 'from sys import stdin,' + 'from sys import stdin,', 'from sys import (*)', 'from sys import (stdin,, stdout, stderr)', 'from sys import (stdin, stdout),', diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 45d80ce..8808a67 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -1178,10 +1178,10 @@ class FormatTest(unittest.TestCase): decimal_point = locale.localeconv()['decimal_point'] thousands_sep = locale.localeconv()['thousands_sep'] if decimal_point != '\u066b': - self.skipTest('inappropriate decimal point separator' + self.skipTest('inappropriate decimal point separator ' '({!a} not {!a})'.format(decimal_point, '\u066b')) if thousands_sep != '\u066c': - self.skipTest('inappropriate thousands separator' + self.skipTest('inappropriate thousands separator ' '({!a} not {!a})'.format(thousands_sep, '\u066c')) self.assertEqual(format(Decimal('100000000.123'), 'n'), diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py index 6fee4df..abc625d 100644 --- a/Lib/test/test_http_cookiejar.py +++ b/Lib/test/test_http_cookiejar.py @@ -174,12 +174,10 @@ class DateTimeTests(unittest.TestCase): '1980-01-01 00:61:00', '01-01-1980 00:00:62', '01-01-1980T00:00:62', - '19800101T250000Z' - '1980-01-01 00:00:00 -2500', + '19800101T250000Z', ]: self.assertIsNone(iso2time(test), - "iso2time(%s) is not None\n" - "iso2time(test) %s" % (test, iso2time(test))) + "iso2time(%r)" % test) class HeaderTests(unittest.TestCase): diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py index 679759e..b6f948d 100644 --- a/Lib/test/test_range.py +++ b/Lib/test/test_range.py @@ -40,7 +40,7 @@ class RangeTest(unittest.TestCase): self.fail('{}: unexpected excess element {} at ' 'position {}'.format(test_id, x, i)) else: - self.fail('{}: wrong element at position {};' + self.fail('{}: wrong element at position {}; ' 'expected {}, got {}'.format(test_id, i, y, x)) def test_range(self): diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py index 1811019..8704751 100644 --- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -767,7 +767,7 @@ class SimSMTPChannel(smtpd.SMTPChannel): try: user, hashed_pass = logpass.split() except ValueError as e: - self.push('535 Splitting response {!r} into user and password' + self.push('535 Splitting response {!r} into user and password ' 'failed: {}'.format(logpass, e)) return False valid_hashed_pass = hmac.HMAC( diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 2cf0926..1438487 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -457,7 +457,7 @@ class CalculationTests(unittest.TestCase): self.assertTrue(result.tm_year == self.time_tuple.tm_year and result.tm_mon == self.time_tuple.tm_mon and result.tm_mday == self.time_tuple.tm_mday, - "Calculation of Gregorian date failed;" + "Calculation of Gregorian date failed; " "%s-%s-%s != %s-%s-%s" % (result.tm_year, result.tm_mon, result.tm_mday, self.time_tuple.tm_year, self.time_tuple.tm_mon, @@ -469,7 +469,7 @@ class CalculationTests(unittest.TestCase): result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple), format_string) self.assertTrue(result.tm_wday == self.time_tuple.tm_wday, - "Calculation of day of the week failed;" + "Calculation of day of the week failed; " "%s != %s" % (result.tm_wday, self.time_tuple.tm_wday)) if support.is_android: diff --git a/Lib/trace.py b/Lib/trace.py index d171577..e5fa94f 100755 --- a/Lib/trace.py +++ b/Lib/trace.py @@ -313,7 +313,7 @@ class CoverageResults: try: outfile = open(path, "w", encoding=encoding) except OSError as err: - print(("trace: Could not open %r for writing: %s" + print(("trace: Could not open %r for writing: %s " "- skipping" % (path, err)), file=sys.stderr) return 0, 0 @@ -655,7 +655,7 @@ def main(): grp = parser.add_argument_group('Filters', 'Can be specified multiple times') grp.add_argument('--ignore-module', action='append', default=[], - help='Ignore the given module(s) and its submodules' + help='Ignore the given module(s) and its submodules ' '(if it is a package). Accepts comma separated list of ' 'module names.') grp.add_argument('--ignore-dir', action='append', default=[], diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 86183ad..31b1985 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -1737,7 +1737,7 @@ _all_magics = _magics | _non_defaults _unsupported_magics = { '__getattr__', '__setattr__', - '__init__', '__new__', '__prepare__' + '__init__', '__new__', '__prepare__', '__instancecheck__', '__subclasscheck__', '__del__' } diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index afc865e..b2e0176 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -3158,7 +3158,7 @@ tzinfo_fromutc(PyDateTime_TZInfo *self, PyObject *dt) return result; Inconsistent: - PyErr_SetString(PyExc_ValueError, "fromutc: tz.dst() gave" + PyErr_SetString(PyExc_ValueError, "fromutc: tz.dst() gave " "inconsistent results; cannot convert"); /* fall through to failure */ diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 0a7e20e..6830d93 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -4527,7 +4527,7 @@ Pickler_set_memo(PicklerObject *self, PyObject *obj) } else { PyErr_Format(PyExc_TypeError, - "'memo' attribute must be a PicklerMemoProxy object" + "'memo' attribute must be a PicklerMemoProxy object " "or dict, not %.200s", Py_TYPE(obj)->tp_name); return -1; } @@ -6969,7 +6969,7 @@ Unpickler_set_memo(UnpicklerObject *self, PyObject *obj) } else { PyErr_Format(PyExc_TypeError, - "'memo' attribute must be an UnpicklerMemoProxy object" + "'memo' attribute must be an UnpicklerMemoProxy object " "or dict, not %.200s", Py_TYPE(obj)->tp_name); return -1; } diff --git a/Python/import.c b/Python/import.c index fa0a9e1..db1650a 100644 --- a/Python/import.c +++ b/Python/import.c @@ -715,7 +715,7 @@ remove_module(PyObject *name) if (PyDict_GetItem(modules, name) == NULL) return; if (PyDict_DelItem(modules, name) < 0) - Py_FatalError("import: deleting existing key in" + Py_FatalError("import: deleting existing key in " "sys.modules failed"); } diff --git a/Tools/scripts/texi2html.py b/Tools/scripts/texi2html.py index 9c1e9fe..5565c21 100755 --- a/Tools/scripts/texi2html.py +++ b/Tools/scripts/texi2html.py @@ -1806,7 +1806,7 @@ class HTMLHelp: print('', file=fp) print('', file=fp) print('', file=fp) - print('', file=fp) print('', file=fp) print('', file=fp) @@ -1831,7 +1831,7 @@ class HTMLHelp: print('', file=fp) print('', file=fp) print('', file=fp) - print('', file=fp) print('', file=fp) print('', file=fp) -- cgit v0.12