File: setup.py-read-README-utf-8

package info (click to toggle)
elasticsearch-curator 5.8.1-4.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,100 kB
  • sloc: python: 17,468; sh: 464; makefile: 160
file content (33 lines) | stat: -rw-r--r-- 1,123 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From cf948409b776e10fe2c576f8e5b6e2a5379a312d Mon Sep 17 00:00:00 2001
From: Apollon Oikonomopoulos <apoikos@debian.org>
Date: Thu, 8 Oct 2015 09:00:30 -0700
Subject: Properly read unicode data from README.md for Python 3

 README.md contains non-ASCII characters and Python 3 errors out since it was
 not instructed to read unicode data from the file. Fix this by opening the
 file with a utf-8 encoding for Python 3.

Forwarded: no
Last-Update: 2015-02-02
Patch-Name: setup.py-read-README-utf-8
---
 setup.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 9d0bf67..ee13a6e 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,11 @@ from setuptools import setup
 
 # Utility function to read from file.
 def fread(fname):
-    return open(os.path.join(os.path.dirname(__file__), fname)).read()
+    try:
+        text = open(os.path.join(os.path.dirname(__file__), fname), encoding='utf-8').read()
+    except TypeError:
+        text = open(os.path.join(os.path.dirname(__file__), fname)).read()
+    return text
 
 def get_version():
     VERSIONFILE="curator/_version.py"