Date: Fri, 21 Feb 2014 13:42:08 +0000 (UTC) From: Kubilay Kocak <koobs@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r345444 - in head/lang/python31: . files Message-ID: <201402211342.s1LDg8s1075228@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: koobs Date: Fri Feb 21 13:42:08 2014 New Revision: 345444 URL: http://svnweb.freebsd.org/changeset/ports/345444 QAT: https://qat.redports.org/buildarchive/r345444/ Log: lang/python31: Backport fox for Python issue #8168 - Backport Python issue #8168 [1]: python3 py_compile does not ignore UTF-8 BOM characters This causes installation (during bytecode compilation) errors for Python ports with sources that contain BOM characters [2] The issue was fixed [3] in the default branch at the time (3.2) but was not backported to 3.1. Since Python 3.1 is now in security-fix-only mode (no new features or bug fixes), backporting is required. [1] http://bugs.python.org/issue8168 [2] http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/186034 [3] http://hg.python.org/cpython/rev/e15a8a476494/ PR: ports/186034 Reported by: Mark Andrews <marka at isc dot org> Added: head/lang/python31/files/patch-Lib__py_compile.py (contents, props changed) Modified: head/lang/python31/Makefile Modified: head/lang/python31/Makefile ============================================================================== --- head/lang/python31/Makefile Fri Feb 21 13:40:33 2014 (r345443) +++ head/lang/python31/Makefile Fri Feb 21 13:42:08 2014 (r345444) @@ -2,7 +2,7 @@ PORTNAME= python31 PORTVERSION= 3.1.5 -PORTREVISION= 9 +PORTREVISION= 10 CATEGORIES= lang python ipv6 MASTER_SITES= PYTHON MASTER_SITE_SUBDIR= ${PYTHON_MASTER_SITE_SUBDIR} Added: head/lang/python31/files/patch-Lib__py_compile.py ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lang/python31/files/patch-Lib__py_compile.py Fri Feb 21 13:42:08 2014 (r345444) @@ -0,0 +1,49 @@ +# Description: python3 py_compile does not ignore UTF-8 BOM characters +# Issue: http://bugs.python.org/issue8168 +# Commit: http://hg.python.org/cpython/rev/e15a8a476494/ +# PR: ports/186034 + +--- ./Lib/py_compile.py.orig 2014-02-21 23:28:42.491208180 +1100 ++++ ./Lib/py_compile.py 2014-02-21 23:29:22.052513709 +1100 +@@ -7,8 +7,8 @@ + import imp + import marshal + import os +-import re + import sys ++import tokenize + import traceback + + MAGIC = imp.get_magic() +@@ -78,21 +78,6 @@ + (x >> 16) & 0xff, + (x >> 24) & 0xff])) + +-def read_encoding(file, default): +- """Read the first two lines of the file looking for coding: xyzzy.""" +- f = open(file, "rb") +- try: +- for i in range(2): +- line = f.readline() +- if not line: +- break +- m = re.match(br".*\bcoding:\s*(\S+)\b", line) +- if m: +- return m.group(1).decode("ascii") +- return default +- finally: +- f.close() +- + def compile(file, cfile=None, dfile=None, doraise=False): + """Byte-compile one Python source file to Python bytecode. + +@@ -128,7 +113,8 @@ + directories). + + """ +- encoding = read_encoding(file, "utf-8") ++ with open(file, "rb") as f: ++ encoding = tokenize.detect_encoding(f.readline)[0] + f = open(file, 'U', encoding=encoding) + try: + timestamp = int(os.fstat(f.fileno()).st_mtime)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402211342.s1LDg8s1075228>