]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #18716: Deprecate the formatter module
authorBrett Cannon <brett@python.org>
Fri, 4 Oct 2013 15:38:59 +0000 (11:38 -0400)
committerBrett Cannon <brett@python.org>
Fri, 4 Oct 2013 15:38:59 +0000 (11:38 -0400)
Doc/library/formatter.rst
Doc/whatsnew/3.4.rst
Lib/formatter.py
Lib/pydoc.py
Misc/NEWS

index 88be11c3c5a563eab8b9d50347315636ce321d96..bdc9e7b0e0406513deea2e0f5589660c903d2a52 100644 (file)
@@ -4,6 +4,10 @@
 .. module:: formatter
    :synopsis: Generic output formatter and device interface.
 
+.. deprecated:: 3.4
+   Due to lack of usage, the formatter module has been deprecated and is slated
+   for removal in Python 3.6.
+
 
 This module supports two interface definitions, each with multiple
 implementations: The *formatter* interface, and the *writer* interface which is
index 2e3cab5898f081394ef4830dc4fa20b92e898e32..81c2d8750c31ee63b6761525c0968facf91d7664 100644 (file)
@@ -516,6 +516,9 @@ Deprecated Python modules, functions and methods
 * The :mod:`imp` module is pending deprecation. To keep compatibility with
   Python 2/3 code bases, the module's removal is currently not scheduled.
 
+* The :mod:`formatter` module is pending deprecation and is slated for removal
+  in Python 3.6.
+
 
 Deprecated functions and types of the C API
 -------------------------------------------
@@ -554,9 +557,9 @@ that may require changes to your code.
 * Import now resets relevant attributes (e.g. ``__name__``, ``__loader__``,
   ``__package__``, ``__file__``, ``__cached__``) unconditionally when reloading.
 
-* Frozen packages no longer set ``__path__`` to a list containg the package name
-  but an empty list instead. Determing if a module is a package should be done
-  using ``hasattr(module, '__path__')``.
+* Frozen packages no longer set ``__path__`` to a list containing the package
+  name but an empty list instead. Determing if a module is a package should be
+  done using ``hasattr(module, '__path__')``.
 
 * :c:func:`PyErr_SetImportError` now sets :exc:`TypeError` when its **msg**
   argument is not set. Previously only ``NULL`` was returned with no exception
index 60e60f116015b35203757a5429d8909dcdd2106c..d8cca52e307feafaef3178c0d8c582ae8be91c9d 100644 (file)
@@ -19,6 +19,9 @@ manage and inserting data into the output.
 """
 
 import sys
+import warnings
+warnings.warn('the formatter module is deprecated and will be removed in '
+              'Python 3.6', PendingDeprecationWarning)
 
 
 AS_IS = None
index bc644070ae7a51e2414777dd83fbac8fd8129179..174311c9a902fe0808dd7ac78bbbeba291623ee0 100755 (executable)
@@ -1915,11 +1915,10 @@ module "pydoc_data.topics" could not be found.
         if more_xrefs:
             xrefs = (xrefs or '') + ' ' + more_xrefs
         if xrefs:
-            import formatter
-            buffer = io.StringIO()
-            formatter.DumbWriter(buffer).send_flowing_data(
-                'Related help topics: ' + ', '.join(xrefs.split()) + '\n')
-            self.output.write('\n%s\n' % buffer.getvalue())
+            import textwrap
+            text = 'Related help topics: ' + ', '.join(xrefs.split()) + '\n'
+            wrapped_text = textwrap.wrap(text, 72)
+            self.output.write('\n%s\n' % ''.join(wrapped_text))
 
     def _gettopic(self, topic, more_xrefs=''):
         """Return unbuffered tuple of (topic, xrefs).
index 72ebe4ddca6571bc8006c7e8744fd912554354c9..07000dd19e77c5f08b86d8aa1ca291303fb9614a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -21,6 +21,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #18716: Deprecate the formatter module.
+
 - Issue #18037: 2to3 now escapes '\u' and '\U' in native strings.
 
 - Issue #17839: base64.decodebytes and base64.encodebytes now accept any