• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision99033a63c7ba0997ef737392eef15337d6783078 (tree)
l'heure2022-10-26 17:56:40
AuteurMike Frysinger <vapier@gent...>
CommiterMike Frysinger

Message de Log

gdb: copyright: make file header scan a bit more pythonic

Should be functionally the same, but uses more pythonic idioms to get
fewer lines of code, and to make sure to not leak open file handles.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Change Summary

Modification

--- a/gdb/copyright.py
+++ b/gdb/copyright.py
@@ -148,15 +148,12 @@ def may_have_copyright_notice(filename):
148148 # so just open the file as a byte stream. We only need to search
149149 # for a pattern that should be the same regardless of encoding,
150150 # so that should be good enough.
151- fd = open(filename, "rb")
152-
153- lineno = 1
154- for line in fd:
155- if b"Copyright" in line:
156- return True
157- lineno += 1
158- if lineno > 50:
159- return False
151+ with open(filename, "rb") as fd:
152+ for lineno, line in enumerate(fd, start=1):
153+ if b"Copyright" in line:
154+ return True
155+ if lineno > MAX_LINES:
156+ break
160157 return False
161158
162159