File: fix-ascii-encoding.patch

package info (click to toggle)
python-pattern 2.6%2Bgit20150109-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 78,672 kB
  • sloc: python: 53,865; xml: 11,965; ansic: 2,318; makefile: 94
file content (17 lines) | stat: -rw-r--r-- 894 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Index: pattern-820cccf33c6ac4a4f1564a273137171cfa6ab7cb/pattern/text/__init__.py
===================================================================
--- pattern-820cccf33c6ac4a4f1564a273137171cfa6ab7cb.orig/pattern/text/__init__.py
+++ pattern-820cccf33c6ac4a4f1564a273137171cfa6ab7cb/pattern/text/__init__.py
@@ -305,7 +305,11 @@ def _read(path, encoding="utf-8", commen
         strippping comments and decoding each line to Unicode.
     """
     if path:
-        if isinstance(path, basestring) and os.path.exists(path):
+        try:
+            from_file_path = isinstance(path, basestring) and os.path.exists(path)
+        except UnicodeEncodeError:
+            from_file_path = isinstance(path, basestring) and os.path.exists(encode_utf8(path))
+        if from_file_path:
             # From file path.
             f = open(path, "rb")
         elif isinstance(path, basestring):