diff options
author | Benjamin Peterson <benjamin@python.org> | 2013-08-21 22:39:12 -0500 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2013-08-21 22:39:12 -0500 |
commit | 8b07e9e61e0766af5d692e15f65bca896d514f6e (patch) | |
tree | 22312334bfb3cf09b9d4c8f4032b691a3ee217a1 | |
parent | 80683ea7553450b27d3132bd402e039a0b2d9fc9 (diff) | |
parent | 7d0bed5db1e264a1dad0c5d444cee42c232b4105 (diff) | |
download | six-8b07e9e61e0766af5d692e15f65bca896d514f6e.tar.gz |
Merged in jaraco/six (pull request #12)
Add 'patch_with_metaclass' which provides a more complete interface for supporting metaclass-based classes across Python versions.
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | documentation/index.rst | 182 | ||||
-rw-r--r-- | six.py | 2 | ||||
-rw-r--r-- | test_six.py | 15 |
4 files changed, 114 insertions, 91 deletions
@@ -6,6 +6,10 @@ This file lists the changes in each six version. Development version ------------------- +- Add six.moves.zip_longest and six.moves.filterfalse, which correspond + respectively to itertools.izip_longest and itertools.ifilterfalse on Python 2 + and itertools.zip_longest and itertools.filterfalse on Python 3. + - Issue #25: Add the unichr function, which returns a string for a Unicode codepoint. @@ -75,7 +79,6 @@ Development version - Issue #3: Add six.moves mappings for filter, map, and zip. - 1.0.0 ----- @@ -83,7 +86,6 @@ Development version - Expose an API for adding mappings to six.moves. - 1.0 beta 1 ---------- diff --git a/documentation/index.rst b/documentation/index.rst index 7fa200f..6d43163 100644 --- a/documentation/index.rst +++ b/documentation/index.rst @@ -439,95 +439,99 @@ Python 2 and the merged module in Python 3. Supported renames: -+------------------------------+-------------------------------------+---------------------------------+ -| Name | Python 2 name | Python 3 name | -+==============================+=====================================+=================================+ -| ``builtins`` | :mod:`py2:__builtin__` | :mod:`py3:builtins` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``configparser`` | :mod:`py2:ConfigParser` | :mod:`py3:configparser` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``copyreg`` | :mod:`py2:copy_reg` | :mod:`py3:copyreg` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``cPickle`` | :mod:`py2:cPickle` | :mod:`py3:pickle` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``cStringIO`` | :func:`py2:cStringIO.StringIO` | :class:`py3:io.StringIO` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``email_mime_multipart`` | :mod:`py2:email.MIMEMultipart` | :mod:`py3:email.mime.multipart` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``email_mime_text`` | :mod:`py2:email.MIMEText` | :mod:`py3:email.mime.text` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``email_mime_base`` | :mod:`py2:email.MIMEBase` | :mod:`py3:email.mime.base` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``filter`` | :func:`py2:itertools.ifilter` | :func:`py3:filter` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``http_cookiejar`` | :mod:`py2:cookielib` | :mod:`py3:http.cookiejar` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``http_cookies`` | :mod:`py2:Cookie` | :mod:`py3:http.cookies` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``html_entities`` | :mod:`py2:htmlentitydefs` | :mod:`py3:html.entities` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``html_parser`` | :mod:`py2:HTMLParser` | :mod:`py3:html.parser` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``http_client`` | :mod:`py2:httplib` | :mod:`py3:http.client` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``BaseHTTPServer`` | :mod:`py2:BaseHTTPServer` | :mod:`py3:http.server` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``CGIHTTPServer`` | :mod:`py2:CGIHTTPServer` | :mod:`py3:http.server` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``SimpleHTTPServer`` | :mod:`py2:SimpleHTTPServer` | :mod:`py3:http.server` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``input`` | :func:`py2:raw_input` | :func:`py3:input` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``map`` | :func:`py2:itertools.imap` | :func:`py3:map` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``queue`` | :mod:`py2:Queue` | :mod:`py3:queue` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``range`` | :func:`py2:xrange` | :func:`py3:range` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``reduce`` | :func:`py2:reduce` | :func:`py3:functools.reduce` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``reload_module`` | :func:`py2:reload` | :func:`py3:imp.reload` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``reprlib`` | :mod:`py2:repr` | :mod:`py3:reprlib` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``socketserver`` | :mod:`py2:SocketServer` | :mod:`py3:socketserver` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter`` | :mod:`py2:Tkinter` | :mod:`py3:tkinter` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_dialog`` | :mod:`py2:Dialog` | :mod:`py3:tkinter.dialog` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_filedialog`` | :mod:`py2:FileDialog` | :mod:`py3:tkinter.FileDialog` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_scrolledtext`` | :mod:`py2:ScrolledText` | :mod:`py3:tkinter.scolledtext` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_simpledialog`` | :mod:`py2:SimpleDialog` | :mod:`py2:tkinter.simpledialog` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_tix`` | :mod:`py2:Tix` | :mod:`py3:tkinter.tix` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_constants`` | :mod:`py2:Tkconstants` | :mod:`py3:tkinter.constants` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_dnd`` | :mod:`py2:Tkdnd` | :mod:`py3:tkinter.dnd` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_colorchooser`` | :mod:`py2:tkColorChooser` | :mod:`py3:tkinter.colorchooser` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_commondialog`` | :mod:`py2:tkCommonDialog` | :mod:`py3:tkinter.commondialog` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_tkfiledialog`` | :mod:`py2:tkFileDialog` | :mod:`py3:tkinter.filedialog` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_font`` | :mod:`py2:tkFont` | :mod:`py3:tkinter.font` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_messagebox`` | :mod:`py2:tkMessageBox` | :mod:`py3:tkinter.messagebox` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``tkinter_tksimpledialog`` | :mod:`py2:tkSimpleDialog` | :mod:`py3:tkinter.simpledialog` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``urllib_robotparser`` | :mod:`py2:robotparser` | :mod:`py3:urllib.robotparser` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``winreg`` | :mod:`py2:_winreg` | :mod:`py3:winreg` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``xrange`` | :func:`py2:xrange` | :func:`py3:range` | -+------------------------------+-------------------------------------+---------------------------------+ -| ``zip`` | :func:`py2:itertools.izip` | :func:`py3:zip` | -+------------------------------+-------------------------------------+---------------------------------+ ++------------------------------+-------------------------------------+-----------------------------------+ +| Name | Python 2 name | Python 3 name | ++==============================+=====================================+===================================+ +| ``builtins`` | :mod:`py2:__builtin__` | :mod:`py3:builtins` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``configparser`` | :mod:`py2:ConfigParser` | :mod:`py3:configparser` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``copyreg`` | :mod:`py2:copy_reg` | :mod:`py3:copyreg` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``cPickle`` | :mod:`py2:cPickle` | :mod:`py3:pickle` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``cStringIO`` | :func:`py2:cStringIO.StringIO` | :class:`py3:io.StringIO` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``email_mime_multipart`` | :mod:`py2:email.MIMEMultipart` | :mod:`py3:email.mime.multipart` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``email_mime_text`` | :mod:`py2:email.MIMEText` | :mod:`py3:email.mime.text` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``email_mime_base`` | :mod:`py2:email.MIMEBase` | :mod:`py3:email.mime.base` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``filter`` | :func:`py2:itertools.ifilter` | :func:`py3:filter` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``filterfalse`` | :func:`py2:itertools.ifilterfalse` | :func:`py3:itertools.filterfalse` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``http_cookiejar`` | :mod:`py2:cookielib` | :mod:`py3:http.cookiejar` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``http_cookies`` | :mod:`py2:Cookie` | :mod:`py3:http.cookies` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``html_entities`` | :mod:`py2:htmlentitydefs` | :mod:`py3:html.entities` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``html_parser`` | :mod:`py2:HTMLParser` | :mod:`py3:html.parser` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``http_client`` | :mod:`py2:httplib` | :mod:`py3:http.client` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``BaseHTTPServer`` | :mod:`py2:BaseHTTPServer` | :mod:`py3:http.server` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``CGIHTTPServer`` | :mod:`py2:CGIHTTPServer` | :mod:`py3:http.server` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``SimpleHTTPServer`` | :mod:`py2:SimpleHTTPServer` | :mod:`py3:http.server` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``input`` | :func:`py2:raw_input` | :func:`py3:input` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``map`` | :func:`py2:itertools.imap` | :func:`py3:map` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``queue`` | :mod:`py2:Queue` | :mod:`py3:queue` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``range`` | :func:`py2:xrange` | :func:`py3:range` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``reduce`` | :func:`py2:reduce` | :func:`py3:functools.reduce` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``reload_module`` | :func:`py2:reload` | :func:`py3:imp.reload` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``reprlib`` | :mod:`py2:repr` | :mod:`py3:reprlib` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``socketserver`` | :mod:`py2:SocketServer` | :mod:`py3:socketserver` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter`` | :mod:`py2:Tkinter` | :mod:`py3:tkinter` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_dialog`` | :mod:`py2:Dialog` | :mod:`py3:tkinter.dialog` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_filedialog`` | :mod:`py2:FileDialog` | :mod:`py3:tkinter.FileDialog` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_scrolledtext`` | :mod:`py2:ScrolledText` | :mod:`py3:tkinter.scolledtext` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_simpledialog`` | :mod:`py2:SimpleDialog` | :mod:`py2:tkinter.simpledialog` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_tix`` | :mod:`py2:Tix` | :mod:`py3:tkinter.tix` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_constants`` | :mod:`py2:Tkconstants` | :mod:`py3:tkinter.constants` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_dnd`` | :mod:`py2:Tkdnd` | :mod:`py3:tkinter.dnd` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_colorchooser`` | :mod:`py2:tkColorChooser` | :mod:`py3:tkinter.colorchooser` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_commondialog`` | :mod:`py2:tkCommonDialog` | :mod:`py3:tkinter.commondialog` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_tkfiledialog`` | :mod:`py2:tkFileDialog` | :mod:`py3:tkinter.filedialog` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_font`` | :mod:`py2:tkFont` | :mod:`py3:tkinter.font` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_messagebox`` | :mod:`py2:tkMessageBox` | :mod:`py3:tkinter.messagebox` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``tkinter_tksimpledialog`` | :mod:`py2:tkSimpleDialog` | :mod:`py3:tkinter.simpledialog` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``urllib_robotparser`` | :mod:`py2:robotparser` | :mod:`py3:urllib.robotparser` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``winreg`` | :mod:`py2:_winreg` | :mod:`py3:winreg` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``xrange`` | :func:`py2:xrange` | :func:`py3:range` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``zip`` | :func:`py2:itertools.izip` | :func:`py3:zip` | ++------------------------------+-------------------------------------+-----------------------------------+ +| ``zip_longest`` | :func:`py2:itertools.izip_longest` | :func:`py3:itertools.zip_longest` | ++------------------------------+-------------------------------------+-----------------------------------+ Advanced - Customizing renames <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -146,6 +146,8 @@ _moved_attributes = [ MovedAttribute("StringIO", "StringIO", "io"), MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), + MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"), + MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"), MovedModule("builtins", "__builtin__"), MovedModule("configparser", "ConfigParser"), diff --git a/test_six.py b/test_six.py index ca6857b..12d3a06 100644 --- a/test_six.py +++ b/test_six.py @@ -104,6 +104,13 @@ def test_filter(): assert six.advance_iterator(f) == 1 +def test_filter_false(): + from six.moves import filterfalse + f = filterfalse(lambda x: x % 3, range(10)) + assert six.advance_iterator(f) == 0 + assert six.advance_iterator(f) == 3 + assert six.advance_iterator(f) == 6 + def test_map(): from six.moves import map assert six.advance_iterator(map(lambda x: x + 1, range(2))) == 1 @@ -114,6 +121,14 @@ def test_zip(): assert six.advance_iterator(zip(range(2), range(2))) == (0, 0) +def test_zip_longest(): + from six.moves import zip_longest + it = zip_longest(range(2), range(1)) + + assert six.advance_iterator(it) == (0, 0) + assert six.advance_iterator(it) == (1, None) + + class TestCustomizedMoves: def teardown_method(self, meth): |