[Python-checkins] distutils2: #13614: Raises a TypeError now if the RST description is invalid

eric.araujo python-checkins at python.org
Wed May 16 07:07:26 CEST 2012


http://hg.python.org/distutils2/rev/7daa144a7af0
changeset:   1324:7daa144a7af0
parent:      1314:6e5312167b4a
user:        Pierre Paul <info at pierre-paul.com>
date:        Sat May 12 15:02:15 2012 -0400
summary:
  #13614: Raises a TypeError now if the RST description is invalid

files:
  distutils2/metadata.py                              |   2 +-
  distutils2/tests/fake_dists/python-pager-readme.rst |  65 ++++++++++
  distutils2/tests/test_command_register.py           |  18 ++
  3 files changed, 84 insertions(+), 1 deletions(-)


diff --git a/distutils2/metadata.py b/distutils2/metadata.py
--- a/distutils2/metadata.py
+++ b/distutils2/metadata.py
@@ -276,7 +276,7 @@
         document.note_source(source_path, -1)
         try:
             parser.parse(data, document)
-        except AttributeError:
+        except (AttributeError, TypeError):
             reporter.messages.append((-1, 'Could not finish the parsing.',
                                       '', {}))
 
diff --git a/distutils2/tests/fake_dists/python-pager-readme.rst b/distutils2/tests/fake_dists/python-pager-readme.rst
new file mode 100644
--- /dev/null
+++ b/distutils2/tests/fake_dists/python-pager-readme.rst
@@ -0,0 +1,65 @@
+
+Python module to page screen output and get dimensions
+of available console space.
+
+It is meant to be finally included into standard library
+http://bugs.python.org/issue8408
+
+| Author:  anatoly techtonik <techtonik at gmail.com>
+| License: Public Domain (or MIT if a license is required)
+
+
+Status
+------
+
+0.1 (stable)
+ - shows content page by page
+ - allows to get console/terminal dimensions
+ - works on Windows
+ - works on Linux
+
+
+API
+---
+
+..function:: getwidth()
+
+  Return width of available window in characters.  If detection fails,
+  return value of standard width 80.  Coordinate of the last character
+  on a line is -1 from returned value. 
+
+
+..function:: getheight()
+
+  Return available window height in characters or 25 if detection fails.
+  Coordinate of the last line is -1 from returned value. 
+
+
+..function:: getch()
+
+  Wait for keypress and return character in a cross-platform way.
+  Credits: Danny Yoo, Python Cookbook
+
+
+..function:: page(content, [pagecallback=prompt])
+
+  Output `content` iterable, calling `pagecallback` function after each
+  page. Default :func:`prompt` callback shows 'Press any key . . . ' prompt
+  and waits for keypress.
+
+
+References
+----------
+
+Excellent tutorials for Win32 Console by Adrian Worley
+http://www.adrianxw.dk/SoftwareSite/index.html
+Console Reference on MSDN
+http://msdn.microsoft.com/en-us/library/ms682087%28VS.85%29.aspx
+
+Public Domain Curses library maintained by William McBrine
+http://pdcurses.sourceforge.net/
+
+Ioctl (input/output control) introduction from Wikipedia
+http://en.wikipedia.org/wiki/Ioctl
+Linux Programmer's Manual - ioctls for terminals and serial lines
+http://www.kernel.org/doc/man-pages/online/pages/man4/tty_ioctl.4.html
diff --git a/distutils2/tests/test_command_register.py b/distutils2/tests/test_command_register.py
--- a/distutils2/tests/test_command_register.py
+++ b/distutils2/tests/test_command_register.py
@@ -253,6 +253,24 @@
         self.assertEqual(data['metadata_version'], '1.2')
         self.assertEqual(data['requires_dist'], ['lxml'])
 
+    def test_register_invalid_long_description(self):
+        readme_file = os.path.join(os.path.dirname(__file__),
+                'fake_dists', 'python-pager-readme.rst')
+
+        # Contains :func: which break the rst format 
+        data = "".join(open(readme_file).readlines())
+
+        metadata = {'Home-page': 'xxx', 'Author': 'xxx',
+                    'Author-email': 'xxx',
+                    'Name': 'xxx', 'Version': 'xxx'}
+
+        metadata['Description'] = data
+        cmd = self._get_cmd(metadata)
+        cmd.ensure_finalized()
+        cmd.strict = True
+        inputs = Inputs('2', 'tarek', 'tarek at ziade.org')
+        register_module.raw_input = inputs
+        self.assertRaises(PackagingSetupError, cmd.run)
 
 def test_suite():
     return unittest.makeSuite(RegisterTestCase)

-- 
Repository URL: http://hg.python.org/distutils2


More information about the Python-checkins mailing list