public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/copyright.py: Convert to Python 3
@ 2020-01-01  9:06 gdb-buildbot
  2020-01-01  9:06 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: gdb-buildbot @ 2020-01-01  9:06 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT 5f4def5cbd12e77075f64a6854fb002f34be8a01 ***

commit 5f4def5cbd12e77075f64a6854fb002f34be8a01
Author:     Joel Brobecker <brobecker@adacore.com>
AuthorDate: Wed Jan 1 10:12:57 2020 +0400
Commit:     Joel Brobecker <brobecker@adacore.com>
CommitDate: Wed Jan 1 10:12:57 2020 +0400

    gdb/copyright.py: Convert to Python 3
    
    gdb/ChangeLog:
    
            * copyright.py: Convert to Python 3.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 02dff2b35a..a570039a88 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2020-01-01  Joel Brobecker  <brobecker@adacore.com>
+
+	* copyright.py: Convert to Python 3.
+
 2020-01-01  Joel Brobecker  <brobecker@adacore.com>
 
 	* copyright.py: Adapt after move of gnulib directory from gdb
diff --git a/gdb/copyright.py b/gdb/copyright.py
index e6feb376a9..2f468441ae 100644
--- a/gdb/copyright.py
+++ b/gdb/copyright.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 
 # Copyright (C) 2011-2019 Free Software Foundation, Inc.
 #
@@ -31,6 +31,7 @@ This removes the bulk of the changes which are most likely to be correct.
 """
 
 import datetime
+import locale
 import os
 import os.path
 import subprocess
@@ -84,7 +85,8 @@ def update_files(update_list):
     update_cmd += update_list
 
     p = subprocess.Popen(update_cmd, stdout=subprocess.PIPE,
-                         stderr=subprocess.STDOUT)
+                         stderr=subprocess.STDOUT,
+                         encoding=locale.getpreferredencoding())
     update_out = p.communicate()[0]
 
     # Process the output.  Typically, a lot of files do not have
@@ -95,20 +97,18 @@ def update_files(update_list):
     # the line out from the output, since there is nothing more to do,
     # short of looking at each file and seeing which notice is appropriate.
     # Too much work! (~4,000 files listed as of 2012-01-03).
-    update_out = update_out.splitlines()
+    update_out = update_out.splitlines(keepends=False)
     warning_string = ': warning: copyright statement not found'
     warning_len = len(warning_string)
 
     for line in update_out:
-        if line.endswith('\n'):
-            line = line[:-1]
         if line.endswith(warning_string):
             filename = line[:-warning_len]
             if may_have_copyright_notice(filename):
-                print line
+                print(line)
         else:
             # Unrecognized file format. !?!
-            print "*** " + line
+            print("*** " + line)
 
 
 def may_have_copyright_notice(filename):
@@ -128,11 +128,15 @@ def may_have_copyright_notice(filename):
     # 50 lines...
     MAX_LINES = 50
 
-    fd = open(filename)
+    # We don't really know what encoding each file might be following,
+    # so just open the file as a byte stream. We only need to search
+    # for a pattern that should be the same regardless of encoding,
+    # so that should be good enough.
+    fd = open(filename, 'rb')
 
     lineno = 1
     for line in fd:
-        if 'Copyright' in line:
+        if b'Copyright' in line:
             return True
         lineno += 1
         if lineno > 50:
@@ -147,7 +151,7 @@ def main ():
 
     if not (os.path.isdir('gdb') and
             os.path.isfile("gnulib/import/extra/update-copyright")):
-        print "Error: This script must be called from the gdb directory."
+        print("Error: This script must be called from the gdb directory.")
         sys.exit(1)
 
     update_list = get_update_list()
@@ -156,19 +160,19 @@ def main ():
     # Remind the user that some files need to be updated by HAND...
 
     if MULTIPLE_COPYRIGHT_HEADERS:
-        print
+        print()
         print("\033[31m"
               "REMINDER: Multiple copyright headers must be updated by hand:"
               "\033[0m")
         for filename in MULTIPLE_COPYRIGHT_HEADERS:
-            print "  ", filename
+            print("  ", filename)
 
     if BY_HAND:
-        print
-        print "\033[31mREMINDER: The following files must be updated by hand." \
-              "\033[0m"
+        print()
+        print("\033[31mREMINDER: The following files must be updated by hand." \
+              "\033[0m")
         for filename in BY_HAND:
-            print "  ", filename
+            print("  ", filename)
 
 ############################################################################
 #


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-01-01 11:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-01  9:06 [binutils-gdb] gdb/copyright.py: Convert to Python 3 gdb-buildbot
2020-01-01  9:06 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot
2020-01-01  9:25 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, " gdb-buildbot
2020-01-01  9:39 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2020-01-01 10:39 ` Failures on Fedora-i686, " gdb-buildbot
2020-01-01 10:48 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2020-01-01 11:11 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2020-01-01 11:20 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2020-01-01 11:31 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2020-01-01 11:41 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2020-01-01 11:43 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2020-01-01 11:56 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).