]> gcc.gnu.org Git - gcc.git/commitdiff
Fix 'contrib/update-copyright.py': 'TypeError: exceptions must derive from BaseException'
authorThomas Schwinge <thomas@codesourcery.com>
Fri, 22 Oct 2021 13:54:42 +0000 (15:54 +0200)
committerThomas Schwinge <thomas@codesourcery.com>
Mon, 8 Nov 2021 10:48:26 +0000 (11:48 +0100)
Running 'contrib/update-copyright.py' currently fails:

    [...]
    Traceback (most recent call last):
      File "contrib/update-copyright.py", line 365, in update_copyright
        canon_form = self.canonicalise_years (dir, filename, filter, years)
      File "contrib/update-copyright.py", line 270, in canonicalise_years
        (min_year, max_year) = self.year_range (years)
      File "contrib/update-copyright.py", line 253, in year_range
        year_list = [self.parse_year (year)
      File "contrib/update-copyright.py", line 253, in <listcomp>
        year_list = [self.parse_year (year)
      File "contrib/update-copyright.py", line 250, in parse_year
        raise self.BadYear (string)
    TypeError: exceptions must derive from BaseException

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "contrib/update-copyright.py", line 796, in <module>
        GCCCmdLine().main()
      File "contrib/update-copyright.py", line 527, in main
        self.copyright.process_tree (dir, filter)
      File "contrib/update-copyright.py", line 458, in process_tree
        self.process_file (dir, filename, filter)
      File "contrib/update-copyright.py", line 421, in process_file
        res = self.update_copyright (dir, filename, filter,
      File "contrib/update-copyright.py", line 366, in update_copyright
        except self.BadYear as e:
    TypeError: catching classes that do not inherit from BaseException is not allowed

Fix up for commit 3b25e83536bcd1b2977659a2c6d9f0f9bf2a3152
"Port update-copyright.py to Python3".

contrib/
* update-copyright.py (class BadYear): Derive from 'Exception'.

contrib/update-copyright.py

index 2b2bb11d2e617d60eb84a20be08f6543c47db384..d13b963a1475c622e49de97acad8604d45fb47ce 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 #
-# Copyright (C) 2013-2020 Free Software Foundation, Inc.
+# Copyright (C) 2013-2021 Free Software Foundation, Inc.
 #
 # This script is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -233,7 +233,7 @@ class Copyright:
     def add_external_author (self, holder):
         self.holders[holder] = None
 
-    class BadYear():
+    class BadYear (Exception):
         def __init__ (self, year):
             self.year = year
 
This page took 0.058115 seconds and 5 git commands to generate.