From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 903B1383308B; Fri, 16 Dec 2022 11:24:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 903B1383308B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671189897; bh=xkPTytYKyy2NHnqauTnW/EUHOef+Xb8uiyRkfkS5hH0=; h=From:To:Subject:Date:From; b=LmSeOsTgxroeLDfELunIGBnaMsXIKBIUjZhMUxjKR8C8ArzUKj1jfXhpYjFtTSiTz 0D3exrVlZaCX3+xvPU214yO13S/RhsBWKs+6VcvfcxHqJPRuPAhCC4Lo2gGqsybBPK t+FJHD7S4wiCwFEw8gQhCESJVcocCtlTo/srrm0g= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4742] gcc-changelog: do not use PatchSet.from_filename X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/heads/master X-Git-Oldrev: 8f2a8be579fc6acadb9fc356701fcb5e7b0feed5 X-Git-Newrev: 66c2f03d4cbfdefa489ba6280d2cbb13efec1ad1 Message-Id: <20221216112457.903B1383308B@sourceware.org> Date: Fri, 16 Dec 2022 11:24:57 +0000 (GMT) List-Id: https://gcc.gnu.org/g:66c2f03d4cbfdefa489ba6280d2cbb13efec1ad1 commit r13-4742-g66c2f03d4cbfdefa489ba6280d2cbb13efec1ad1 Author: Martin Liska Date: Fri Dec 16 12:21:59 2022 +0100 gcc-changelog: do not use PatchSet.from_filename Use rather PatchSet constructor where we can pass properly opened file with newline='\n'. contrib/ChangeLog: * gcc-changelog/git_email.py: Use PatchSet constructor as newline argument is not supported with older unidiff library. Diff: --- contrib/gcc-changelog/git_email.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py index 093c887ba4c..f3773f178ea 100755 --- a/contrib/gcc-changelog/git_email.py +++ b/contrib/gcc-changelog/git_email.py @@ -39,18 +39,15 @@ unidiff_supports_renaming = hasattr(PatchedFile(), 'is_rename') class GitEmail(GitCommit): def __init__(self, filename): self.filename = filename - try: - diff = PatchSet.from_filename(filename, newline='\n') - except TypeError: - # Older versions don't have the newline argument - diff = PatchSet.from_filename(filename) date = None author = None subject = '' subject_last = False - with open(self.filename, 'r') as f: - lines = f.read().splitlines() + with open(self.filename, newline='\n') as f: + data = f.read() + diff = PatchSet(data) + lines = data.splitlines() lines = list(takewhile(lambda line: line != '---', lines)) for line in lines: if line.startswith(DATE_PREFIX):