Six

Expose `six.moves` API for writing custom moves

Bug #653383 reported by Sridhar Ratnakumar
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Six
Fix Released
Undecided
Unassigned

Bug Description

I added a xmlrpclib move without changing the six source code like this:

>>> import six.moves
>>> from six._moves import _Module, MovedItems
>>> m = _Module('xmlrpc_client', 'xmlrpclib', 'xmlrpc.client')
>>> setattr(MovedItems, m.name, m)
>>> six.moves.xmlrpc_client
<module 'xmlrpclib' from 'C:\Python27\lib\xmlrpclib.pyc'>

I am not fully confident as to using these internal names (that start with underscore). Wouldn't it be helpful to expose this as a supported API so others could build on top of six.moves?

Revision history for this message
Benjamin Peterson (benjaminp) wrote :

I think a better idea would be to add names which are missing. :) six tries to have a pretty minimalistic API, and I don't want to cloud it with non-Python2/3 related things.

Revision history for this message
Sridhar Ratnakumar (srid) wrote : Re: [Bug 653383] Re: Expose `six.moves` API for writing custom moves

On Mon, Oct 4, 2010 at 12:14 PM, Benjamin Peterson <
<email address hidden>> wrote:

> I think a better idea would be to add names which are missing. :)

Well, the thing is there are so many custom moves that are project-specific.
Apart from xmlrpc_client and urlparse, do you think six can officially
support all of the following moves?
    _Module('xmlrpc_client', 'xmlrpclib', 'xmlrpc.client'),
    _Attribute('HTTPError', 'urllib2', 'urllib.error'),
    _Attribute('URLError', 'urllib2', 'urllib.error'),
    _Attribute('Request', 'urllib2', 'urllib.request'),
    _Attribute('urlopen', 'urllib2', 'urllib.request'),
    _Attribute('urllib_version', 'urllib2', 'urllib.request',
'__version__'),
    _Attribute('urlparse', 'urlparse', 'urllib.parse'),

Revision history for this message
Benjamin Peterson (benjaminp) wrote :

This is now implemented in hg.

Changed in python-six:
status: New → Fix Committed
Changed in python-six:
status: Fix Committed → Fix Released
status: Fix Released → Fix Committed
Changed in python-six:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.