[python-docutils/f15] Fix a unicode traceback https://bugzilla.redhat.com/show_bug.cgi?id=785622

Toshio くらとみ toshio at fedoraproject.org
Tue Jan 31 02:26:28 UTC 2012


commit 2d2a8c126f3a0eab7c6f1cf39cad7708d96c9ffa
Author: Toshio Kuratomi <toshio at fedoraproject.org>
Date:   Mon Jan 30 18:26:18 2012 -0800

    Fix a unicode traceback https://bugzilla.redhat.com/show_bug.cgi?id=785622

 docutils-encoding.patch          |   12 ------------
 docutils-test-exceptions.patch   |   22 ----------------------
 docutils-unicode-traceback.patch |   36 ++++++++++++++++++++++++++++++++++++
 python-docutils.spec             |    7 +++++++
 4 files changed, 43 insertions(+), 34 deletions(-)
---
diff --git a/docutils-unicode-traceback.patch b/docutils-unicode-traceback.patch
new file mode 100644
index 0000000..4553ea2
--- /dev/null
+++ b/docutils-unicode-traceback.patch
@@ -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):
diff --git a/python-docutils.spec b/python-docutils.spec
index a0423a4..e24de4b 100644
--- a/python-docutils.spec
+++ b/python-docutils.spec
@@ -27,6 +27,8 @@ Source0:        http://downloads.sourceforge.net/docutils/%{srcname}-%{version}.
 #Source0:        %{srcname}-%{version}.tar.gz
 # Applied upstream.  Fixes a traceback when invalid input is given on the cli
 Patch0: docutils-missing-import.patch
+# Submitted upstream
+Patch1: docutils-unicode-traceback.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch:       noarch
 
@@ -77,6 +79,8 @@ This package contains the module, ported to run under python3.
 %setup -q -n %{srcname}-%{version}
 
 %patch0 -p0 -b .exc
+%patch1 -p0 -b .enc
+
 # Remove shebang from library files
 for file in docutils/_string_template_compat.py docutils/math/{__init__.py,latex2mathml.py}; do
 sed -i -e '/#! *\/usr\/bin\/.*/{1D}' $file
@@ -177,6 +181,9 @@ rm -rf %{buildroot}
 %{python3_sitelib}/*
 
 %changelog
+* Mon Jan 30 2012 Toshio Kuratomi <toshio at 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 at fedoraproject.org> - 0.8.1-1
 - 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


More information about the scm-commits mailing list