|
From: <mi...@us...> - 2012-02-03 12:23:38
|
Revision: 7339
http://docutils.svn.sourceforge.net/docutils/?rev=7339&view=rev
Author: milde
Date: 2012-02-03 12:23:27 +0000 (Fri, 03 Feb 2012)
Log Message:
-----------
Fix [ 3481980 ] Use os.getcwdu() in make_paths_absolute().
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/frontend.py
trunk/docutils/test/test_settings.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2012-02-03 12:22:14 UTC (rev 7338)
+++ trunk/docutils/HISTORY.txt 2012-02-03 12:23:27 UTC (rev 7339)
@@ -29,6 +29,10 @@
- Fix [ 2971827 ] and [ 3442827 ]
extras/roman.py moved to docutils/utils/roman.py
+* docutils/frontend.py
+
+ - Fix [ 3481980 ] Use os.getcwdu() in make_paths_absolute().
+
* docutils/io.py
- Fix [ 3395948 ] (Work around encoding problems in Py3k).
@@ -37,14 +41,17 @@
- docutils.utils is now a package (providing a place for sub-modules)
- .. important:: docutils/math, docutils/error_reporting.py, and
+ .. note:: docutils/math, docutils/error_reporting.py, and
docutils/urischemes.py will move to the utils package in the next
- release, too. Code importing these modules needs to adapt
- (``import docutils.math`` -> ``import docutils.utils.math``, etc.).
+ release, too. See RELEASE-NOTES__
+ __ RELEASE-NOTES.html
+
- DependencyList uses io.FileOutput and 'utf8' encoding to prevent
- errors recording non-ASCII filenames (fixes [ 3434355 ].
+ errors recording non-ASCII filenames (fixes [ 3434355 ]).
+ - Fix relative_path() with source=None and `unicode` target.
+
* docutils/parsers/rst/states.py
- Fix [ 3402314 ] allow non-ASCII whitespace, punctuation
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2012-02-03 12:22:14 UTC (rev 7338)
+++ trunk/docutils/RELEASE-NOTES.txt 2012-02-03 12:23:27 UTC (rev 7339)
@@ -16,6 +16,19 @@
.. contents::
+Future changes
+==============
+
+* docutils/math, docutils/error_reporting.py, and
+ docutils/urischemes.py will move to the utils package
+ Code importing these modules needs to adapt, e.g.::
+
+ try:
+ import docutils.math as math
+ except ImportError:
+ import docutils.utils.math as math
+
+
Release 0.9 (unpublished)
=========================
@@ -31,11 +44,6 @@
- docutils.utils is now a package (providing a place for sub-modules)
- .. important:: docutils/math, docutils/error_reporting.py, and
- docutils/urischemes.py will move to the utils package in the next
- release, too. Code importing these modules needs to adapt
- (``import docutils.math`` -> ``import docutils.utils.math``, etc.).
-
* docutils/writers/html4css1/__init__.py
- change default for `math-output` setting to MathJax
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2012-02-03 12:22:14 UTC (rev 7338)
+++ trunk/docutils/docutils/frontend.py 2012-02-03 12:23:27 UTC (rev 7339)
@@ -184,7 +184,8 @@
`OptionParser.relative_path_settings`.
"""
if base_path is None:
- base_path = os.getcwd()
+ base_path = os.getcwdu() # type(base_path) == unicode
+ # to allow combining non-ASCII cwd with unicode values in `pathdict`
for key in keys:
if key in pathdict:
value = pathdict[key]
@@ -618,8 +619,7 @@
def check_values(self, values, args):
"""Store positional arguments as runtime settings."""
values._source, values._destination = self.check_args(args)
- make_paths_absolute(values.__dict__, self.relative_path_settings,
- os.getcwd())
+ make_paths_absolute(values.__dict__, self.relative_path_settings)
values._config_files = self.config_files
return values
Modified: trunk/docutils/test/test_settings.py
===================================================================
--- trunk/docutils/test/test_settings.py 2012-02-03 12:22:14 UTC (rev 7338)
+++ trunk/docutils/test/test_settings.py 2012-02-03 12:23:27 UTC (rev 7339)
@@ -169,5 +169,29 @@
os.environ = self.orig_environ
+class HelperFunctionsTests(unittest.TestCase):
+
+ pathdict = {'foo': 'hallo', 'ham': u'h\xE4m', 'spam': u'spam'}
+ keys = ['foo', 'ham']
+
+ def test_make_paths_absolute(self):
+ pathdict = self.pathdict.copy()
+ frontend.make_paths_absolute(pathdict, self.keys, base_path='base')
+ self.assertEqual(pathdict['foo'], os.path.abspath('base/hallo'))
+ self.assertEqual(pathdict['ham'], os.path.abspath(u'base/h\xE4m'))
+ # not touched, because key not in keys:
+ self.assertEqual(pathdict['spam'], u'spam')
+
+ def test_make_paths_absolute_cwd(self):
+ # With base_path None, the cwd is used as base path.
+ # Settings values may-be `unicode` instances, therefore
+ # os.getcwdu() is used and the converted path is a unicode instance:
+ pathdict = self.pathdict.copy()
+ frontend.make_paths_absolute(pathdict, self.keys)
+ self.assertEqual(pathdict['foo'], os.path.abspath(u'hallo'))
+ self.assertEqual(pathdict['ham'], os.path.abspath(u'h\xE4m'))
+ # not touched, because key not in keys:
+ self.assertEqual(pathdict['spam'], u'spam')
+
if __name__ == '__main__':
unittest.main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|