diff options
author | koobs <koobs@FreeBSD.org> | 2014-02-21 21:42:08 +0800 |
---|---|---|
committer | koobs <koobs@FreeBSD.org> | 2014-02-21 21:42:08 +0800 |
commit | 4267bf83306f97bd3e4c34b4708a833b77aabe24 (patch) | |
tree | 0ea6df1de66751b351f1021403fb1d5babecbe29 /lang | |
parent | 8e3f2473f11f0548f195e8efd3d1002eecf1bf81 (diff) | |
download | freebsd-ports-graphics-4267bf83306f97bd3e4c34b4708a833b77aabe24.tar.gz freebsd-ports-graphics-4267bf83306f97bd3e4c34b4708a833b77aabe24.tar.zst freebsd-ports-graphics-4267bf83306f97bd3e4c34b4708a833b77aabe24.zip |
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>
Diffstat (limited to 'lang')
-rw-r--r-- | lang/python31/Makefile | 2 | ||||
-rw-r--r-- | lang/python31/files/patch-Lib__py_compile.py | 49 |
2 files changed, 50 insertions, 1 deletions
diff --git a/lang/python31/Makefile b/lang/python31/Makefile index 7d9e5e6ce64..9d55555607e 100644 --- a/lang/python31/Makefile +++ b/lang/python31/Makefile @@ -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} diff --git a/lang/python31/files/patch-Lib__py_compile.py b/lang/python31/files/patch-Lib__py_compile.py new file mode 100644 index 00000000000..1eaaca1e569 --- /dev/null +++ b/lang/python31/files/patch-Lib__py_compile.py @@ -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) |