Fix a unicode traceback https://bugzilla.redhat.com/show_bug.cgi?id=785622
This commit is contained in:
parent
18a18b8325
commit
2d2a8c126f
@ -1,12 +0,0 @@
|
|||||||
Index: docutils-0.8/test/test_functional.py
|
|
||||||
===================================================================
|
|
||||||
--- docutils-0.8.orig/test/test_functional.py
|
|
||||||
+++ docutils-0.8/test/test_functional.py
|
|
||||||
@@ -175,7 +175,6 @@ expected output and check it in:
|
|
||||||
f = open(expected_path, 'r')
|
|
||||||
else: # samples are UTF8 encoded. 'rb' leads to errors with Python 3!
|
|
||||||
f = open(expected_path, 'r', encoding='utf-8')
|
|
||||||
- f = open(expected_path, 'r')
|
|
||||||
# Normalize line endings:
|
|
||||||
expected = '\n'.join(f.read().splitlines())
|
|
||||||
f.close()
|
|
@ -1,22 +0,0 @@
|
|||||||
Index: docutils-0.8/test/test_error_reporting.py
|
|
||||||
===================================================================
|
|
||||||
--- docutils-0.8.orig/test/test_error_reporting.py
|
|
||||||
+++ docutils-0.8/test/test_error_reporting.py
|
|
||||||
@@ -236,7 +236,7 @@ class SafeStringTests_locale(unittest.Te
|
|
||||||
except UnicodeEncodeError:
|
|
||||||
try:
|
|
||||||
open(u'\xfc'.encode(sys.getfilesystemencoding(), 'replace'))
|
|
||||||
- except IOError:
|
|
||||||
+ except IOError, e:
|
|
||||||
uioe = e
|
|
||||||
try:
|
|
||||||
os.chdir(b('\xfc'))
|
|
||||||
@@ -249,7 +249,7 @@ class SafeStringTests_locale(unittest.Te
|
|
||||||
except UnicodeEncodeError:
|
|
||||||
try:
|
|
||||||
os.chdir(u'\xfc'.encode(sys.getfilesystemencoding(), 'replace'))
|
|
||||||
- except OSError:
|
|
||||||
+ except OSError, e:
|
|
||||||
uose = e
|
|
||||||
# wrapped test data:
|
|
||||||
wbioe = SafeString(bioe)
|
|
36
docutils-unicode-traceback.patch
Normal file
36
docutils-unicode-traceback.patch
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
Index: docutils-0.8.1/docutils/frontend.py
|
||||||
|
===================================================================
|
||||||
|
--- docutils-0.8.1.orig/docutils/frontend.py
|
||||||
|
+++ docutils-0.8.1/docutils/frontend.py
|
||||||
|
@@ -193,7 +193,31 @@ def make_paths_absolute(pathdict, keys,
|
||||||
|
value = make_one_path_absolute(base_path, value)
|
||||||
|
pathdict[key] = value
|
||||||
|
|
||||||
|
+def _bytes_path_to_unicode(path):
|
||||||
|
+ '''Change a byte str path segment into unicode
|
||||||
|
+
|
||||||
|
+ Note that this is arguably wrong for Unix systems. Unix filesystem paths
|
||||||
|
+ are bytes that programs interpret as characters. Filesystem paths are in
|
||||||
|
+ no way guaranteed to be decodable into unicode. So this could traceback
|
||||||
|
+ if the locale_encoding can't deal with any byte string and it could give
|
||||||
|
+ wrong values if the locale_encoding does not match the encoding of
|
||||||
|
+ a single one of the path component's values.
|
||||||
|
+
|
||||||
|
+ However, the rest of docutils is turning command line args containing
|
||||||
|
+ filenames into unicode so switching to unicode is more inline with the
|
||||||
|
+ strategy taken by the rest of docutils.
|
||||||
|
+ '''
|
||||||
|
+ # converting to Unicode (Python 3 does this automatically):
|
||||||
|
+ if sys.version_info < (3,0):
|
||||||
|
+ # TODO: make this failsafe and reversible
|
||||||
|
+ path = unicode(path, locale_encoding)
|
||||||
|
+ return path
|
||||||
|
+
|
||||||
|
def make_one_path_absolute(base_path, path):
|
||||||
|
+ if isinstance(base_path, unicode) and not isinstance(path, unicode):
|
||||||
|
+ path = _bytes_path_to_unicode(path)
|
||||||
|
+ elif isinstance(path, unicode) and not isinstance(base_path, unicode):
|
||||||
|
+ base_path = _bytes_path_to_unicode(base_path)
|
||||||
|
return os.path.abspath(os.path.join(base_path, path))
|
||||||
|
|
||||||
|
def filter_settings_spec(settings_spec, *exclude, **replace):
|
@ -27,6 +27,8 @@ Source0: http://downloads.sourceforge.net/docutils/%{srcname}-%{version}.
|
|||||||
#Source0: %{srcname}-%{version}.tar.gz
|
#Source0: %{srcname}-%{version}.tar.gz
|
||||||
# Applied upstream. Fixes a traceback when invalid input is given on the cli
|
# Applied upstream. Fixes a traceback when invalid input is given on the cli
|
||||||
Patch0: docutils-missing-import.patch
|
Patch0: docutils-missing-import.patch
|
||||||
|
# Submitted upstream
|
||||||
|
Patch1: docutils-unicode-traceback.patch
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
@ -77,6 +79,8 @@ This package contains the module, ported to run under python3.
|
|||||||
%setup -q -n %{srcname}-%{version}
|
%setup -q -n %{srcname}-%{version}
|
||||||
|
|
||||||
%patch0 -p0 -b .exc
|
%patch0 -p0 -b .exc
|
||||||
|
%patch1 -p0 -b .enc
|
||||||
|
|
||||||
# Remove shebang from library files
|
# Remove shebang from library files
|
||||||
for file in docutils/_string_template_compat.py docutils/math/{__init__.py,latex2mathml.py}; do
|
for file in docutils/_string_template_compat.py docutils/math/{__init__.py,latex2mathml.py}; do
|
||||||
sed -i -e '/#! *\/usr\/bin\/.*/{1D}' $file
|
sed -i -e '/#! *\/usr\/bin\/.*/{1D}' $file
|
||||||
@ -177,6 +181,9 @@ rm -rf %{buildroot}
|
|||||||
%{python3_sitelib}/*
|
%{python3_sitelib}/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Jan 30 2012 Toshio Kuratomi <toshio@fedoraproject.org> - 0.8.1-2
|
||||||
|
- Fix a unicode traceback https://bugzilla.redhat.com/show_bug.cgi?id=785622
|
||||||
|
|
||||||
* Thu Jan 5 2012 Toshio Kuratomi <toshio@fedoraproject.org> - 0.8.1-1
|
* Thu Jan 5 2012 Toshio Kuratomi <toshio@fedoraproject.org> - 0.8.1-1
|
||||||
- Update to new upstream that has properly licensed files and a few bugfixes
|
- Update to new upstream that has properly licensed files and a few bugfixes
|
||||||
- Add a patch to fix tracebacks when wrong values are given to CLI apps
|
- Add a patch to fix tracebacks when wrong values are given to CLI apps
|
||||||
|
Loading…
Reference in New Issue
Block a user