[Python-checkins] r68962 - in python/branches/release30-maint: Doc/library/operator.rst Lib/locale.py Lib/test/test_array.py Lib/test/test_bool.pyLib/test/test_operator.pyMisc/NEWS Modules/operator.c

Nick Coghlan ncoghlan at gmail.com
Tue Jan 27 02:36:18 CET 2009


Antoine Pitrou wrote:
>> Modified: python/branches/release30-maint/Lib/test/test_array.py
>> ==============================================================================
>> --- python/branches/release30-maint/Lib/test/test_array.py	(original)
>> +++ python/branches/release30-maint/Lib/test/test_array.py	Mon Jan 26 04:44:49
> 2009
>> @@ -725,8 +725,6 @@
>>          self.assertRaises(BufferError, operator.setitem, a, slice(0, 0), a)
>>          self.assertRaises(BufferError, operator.delitem, a, 0)
>>          self.assertRaises(BufferError, operator.delitem, a, slice(0, 1))
>> -        self.assertRaises(BufferError, operator.irepeat, a, 2)
>> -        self.assertRaises(BufferError, operator.irepeat, a, 0)
> 
> I think these tests should have been written differently, rather than removed.
> While operator.irepeat has disappeared, the operation being tested still exists.

Indeed, irepeat->imul would be a much better change than deleting them.

One thing I was actually wondering was whether or not 2to3 can do
something about these removals?

That is, is it able to make the following transformations?:

operator.isSequenceType(obj) -> isinstance(obj, collections.Sequence)
operator.isMappingType(obj) -> isinstance(obj, collections.Mapping)
operator.isNumberType(obj) -> isinstance(obj, numbers.Number)
operator.repeat(obj, n) -> operator.mul(obj, n)
operator.irepeat(obj, n) -> operator.imul(obj, n)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-checkins mailing list