Blob Blame History Raw
diff -up rpmlint-rpmlint-1.9/FilesCheck.py.unicodefix rpmlint-rpmlint-1.9/FilesCheck.py
--- rpmlint-rpmlint-1.9/FilesCheck.py.unicodefix	2016-07-08 10:45:32.988796231 -0400
+++ rpmlint-rpmlint-1.9/FilesCheck.py	2016-07-08 10:47:07.520138612 -0400
@@ -572,8 +572,14 @@ class FilesCheck(AbstractCheck.AbstractC
 
                 chunk = None
                 istext = False
-                if os.access(pkgfile.path, os.R_OK):
-                    (chunk, istext) = peek(pkgfile.path, pkg)
+                res = None
+                try:
+                    res = os.access(pkgfile.path, os.R_OK)
+                except UnicodeError as e:  # e.g. non-ASCII, C locale, python 3
+                    printWarning(pkg, 'inaccessible-filename', f, e)
+                else:
+                    if res:
+                        (chunk, istext) = peek(pkgfile.path, pkg)
 
                 (interpreter, interpreter_args) = script_interpreter(chunk)
 
@@ -1304,6 +1310,11 @@ it in the rpm header indicates that it i
 but it actually is not in the filesystem.  Because of this, some checks will
 be skipped.''',
 
+'inaccessible-filename',
+'''An error occurred while trying to access this file due to some characters
+in its name. Because of this, some checks will be skipped. Access could work
+with some other locale settings.''',
+
 'executable-crontab-file',
 '''This crontab file has executable bit set, which is refused by newer version
 of cron''',
diff -up rpmlint-rpmlint-1.9/Filter.py.unicodefix rpmlint-rpmlint-1.9/Filter.py
--- rpmlint-rpmlint-1.9/Filter.py.unicodefix	2016-07-08 10:43:35.135616091 -0400
+++ rpmlint-rpmlint-1.9/Filter.py	2016-07-08 10:45:25.885845645 -0400
@@ -9,6 +9,7 @@
 
 from __future__ import print_function
 
+import codecs
 import locale
 import sys
 import textwrap
@@ -25,17 +26,20 @@ _diagnostic = list()
 _badness_score = 0
 printed_messages = {"I": 0, "W": 0, "E": 0}
 
-__stdout = sys.stdout
 __preferred_encoding = locale.getpreferredencoding()
 if sys.version_info[0] < 3:
-    import codecs
     __stdout = codecs.getwriter(__preferred_encoding)(sys.stdout, 'replace')
 
+    def __print(s):
+        if isinstance(s, str):
+            s = s.decode(__preferred_encoding, 'replace')
+        print(s, file=__stdout)
+else:
+    __stdout = codecs.getwriter(__preferred_encoding)(
+        sys.stdout.buffer, 'replace')
 
-def __print(s):
-    if isinstance(s, str) and hasattr(s, 'decode'):
-        s = s.decode(__preferred_encoding, 'replace')
-    print(s, file=__stdout)
+    def __print(s):
+        print(s, file=__stdout)
 
 
 def printInfo(pkg, reason, *details):
diff -up rpmlint-rpmlint-1.9/Makefile.unicodefix rpmlint-rpmlint-1.9/Makefile
--- rpmlint-rpmlint-1.9/Makefile.unicodefix	2016-07-08 10:47:23.748025724 -0400
+++ rpmlint-rpmlint-1.9/Makefile	2016-07-08 10:47:38.945919999 -0400
@@ -22,10 +22,6 @@ PYTHON = /usr/bin/python
 # update this variable to create a new release
 VERSION := 1.9
 
-# for the [A-Z]* part
-LC_ALL:=C
-export LC_ALL
-
 all: __version__.py __isocodes__.py
 
 clean:
diff -up rpmlint-rpmlint-1.9/test.sh.unicodefix rpmlint-rpmlint-1.9/test.sh
--- rpmlint-rpmlint-1.9/test.sh.unicodefix	2016-07-08 10:47:52.116828374 -0400
+++ rpmlint-rpmlint-1.9/test.sh	2016-07-08 10:48:34.045536691 -0400
@@ -18,9 +18,14 @@ for i in $TESTPATH/test.*.py; do
 done
 
 echo "Check that rpmlint executes with no unexpected errors"
+echo "...in default locale"
 $PYTHON ./rpmlint -C $(pwd) test/*/*.rpm test/spec/*.spec >/dev/null
 rc=$?
 test $rc -eq 0 -o $rc -eq 64 || exit $rc
+echo "...in the C locale"
+LC_ALL=C $PYTHON ./rpmlint -C $(pwd) test/*/*.rpm test/spec/*.spec >/dev/null
+rc=$?
+test $rc -eq 0 -o $rc -eq 64 || exit $rc
 
 echo "$PYTEST tests"
 $PYTEST -v || exit $?