From 230014608571c2ad88b740455f4ffe1b963cad22 Mon Sep 17 00:00:00 2001 From: Ievgenii Meshcheriakov Date: Wed, 7 Jul 2021 13:23:12 +0200 Subject: [PATCH] locale_database: Don't attempt to access property 'message' of IOError IOError does not have property 'message' in Python 3. Instead of attempting to access it, just use the string representation of the exception object. This produces the error message possibly combined with additional arguments in both Python 2 and Python 3. Task-number: QTBUG-83488 Pick-to: 6.2 Change-Id: Icb198a409e7f80b832e474d8390b770fdeacc6c2 Reviewed-by: Edward Welbourne --- util/locale_database/cldr2qtimezone.py | 4 ++-- util/locale_database/qlocalexml2cpp.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/util/locale_database/cldr2qtimezone.py b/util/locale_database/cldr2qtimezone.py index c5eb61c2a84..1e783b6add6 100755 --- a/util/locale_database/cldr2qtimezone.py +++ b/util/locale_database/cldr2qtimezone.py @@ -363,7 +363,7 @@ def main(args, out, err): dict((name, ind) for ind, name in enumerate((x[0] for x in windowsIdList), 1))) except IOError as e: usage(err, name, - 'Failed to open common/supplemental/windowsZones.xml: ' + (e.message or e.args[1])) + 'Failed to open common/supplemental/windowsZones.xml: ' + str(e)) return 1 except Error as e: err.write('\n'.join(textwrap.wrap( @@ -375,7 +375,7 @@ def main(args, out, err): try: writer = ZoneIdWriter(dataFilePath, qtPath) except IOError as e: - err.write('Failed to open files to transcribe: {}'.format(e.message or e.args[1])) + err.write('Failed to open files to transcribe: {}'.format(e)) return 1 try: diff --git a/util/locale_database/qlocalexml2cpp.py b/util/locale_database/qlocalexml2cpp.py index 60d0e692286..8194b157553 100755 --- a/util/locale_database/qlocalexml2cpp.py +++ b/util/locale_database/qlocalexml2cpp.py @@ -552,7 +552,7 @@ def main(args, out, err): 'qlocale_data_p.h'), qtsrcdir, reader.cldrVersion) except IOError as e: - err.write('Failed to open files to transcribe locale data: ' + (e.message or e.args[1])) + err.write('Failed to open files to transcribe locale data: ' + str(e)) return 1 try: @@ -582,7 +582,7 @@ def main(args, out, err): qtsrcdir, reader.cldrVersion) except IOError as e: err.write('Failed to open files to transcribe ' + calendar - + ' data ' + (e.message or e.args[1])) + + ' data ' + str(e)) return 1 try: @@ -599,7 +599,7 @@ def main(args, out, err): writer = LocaleHeaderWriter(os.path.join(qtsrcdir, 'src', 'corelib', 'text', 'qlocale.h'), qtsrcdir, reader.dupes) except IOError as e: - err.write('Failed to open files to transcribe qlocale.h: ' + (e.message or e.args[1])) + err.write('Failed to open files to transcribe qlocale.h: ' + str(e)) return 1 try: @@ -618,7 +618,7 @@ def main(args, out, err): writer = Transcriber(os.path.join(qtsrcdir, 'src', 'corelib', 'text', 'qlocale.qdoc'), qtsrcdir) except IOError as e: - err.write('Failed to open files to transcribe qlocale.qdoc: ' + (e.message or e.args[1])) + err.write('Failed to open files to transcribe qlocale.qdoc: ' + str(e)) return 1 DOCSTRING = " QLocale's data is based on Common Locale Data Repository "