[Python-3000-checkins] r55924 - in python/branches/p3yk/Lib: _strptime.py abc.py ctypes/__init__.py ctypes/_endian.py ctypes/test/test_init.py distutils/tests/support.py plat-mac/plistlib.py random.py string.py test/list_tests.py test/test_array.py test/test_collections.py test/test_list.py test/test_super.py test/test_tuple.py test/test_unittest.py test/test_userlist.py test/test_weakref.py weakref.py

guido.van.rossum python-3000-checkins at python.org
Tue Jun 12 06:20:22 CEST 2007


Author: guido.van.rossum
Date: Tue Jun 12 06:20:05 2007
New Revision: 55924

Modified:
   python/branches/p3yk/Lib/_strptime.py
   python/branches/p3yk/Lib/abc.py
   python/branches/p3yk/Lib/ctypes/__init__.py
   python/branches/p3yk/Lib/ctypes/_endian.py
   python/branches/p3yk/Lib/ctypes/test/test_init.py
   python/branches/p3yk/Lib/distutils/tests/support.py
   python/branches/p3yk/Lib/plat-mac/plistlib.py
   python/branches/p3yk/Lib/random.py
   python/branches/p3yk/Lib/string.py
   python/branches/p3yk/Lib/test/list_tests.py
   python/branches/p3yk/Lib/test/test_array.py
   python/branches/p3yk/Lib/test/test_collections.py
   python/branches/p3yk/Lib/test/test_list.py
   python/branches/p3yk/Lib/test/test_super.py
   python/branches/p3yk/Lib/test/test_tuple.py
   python/branches/p3yk/Lib/test/test_unittest.py
   python/branches/p3yk/Lib/test/test_userlist.py
   python/branches/p3yk/Lib/test/test_weakref.py
   python/branches/p3yk/Lib/weakref.py
Log:
Change all occurrences of super(<thisclass>, <firstarg>) to super().
Seems to have worked, all the tests still pass.
Exception: test_descr and test_descrtut, which have tons of these
and are there to test the various usages.


Modified: python/branches/p3yk/Lib/_strptime.py
==============================================================================
--- python/branches/p3yk/Lib/_strptime.py	(original)
+++ python/branches/p3yk/Lib/_strptime.py	Tue Jun 12 06:20:05 2007
@@ -186,7 +186,7 @@
             self.locale_time = locale_time
         else:
             self.locale_time = LocaleTime()
-        base = super(TimeRE, self)
+        base = super()
         base.__init__({
             # The " \d" part of the regex is to make %c from ANSI C work
             'd': r"(?P<d>3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])",

Modified: python/branches/p3yk/Lib/abc.py
==============================================================================
--- python/branches/p3yk/Lib/abc.py	(original)
+++ python/branches/p3yk/Lib/abc.py	Tue Jun 12 06:20:05 2007
@@ -93,7 +93,7 @@
 
     def __new__(mcls, name, bases, namespace):
         bases = _fix_bases(bases)
-        cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
+        cls = super().__new__(mcls, name, bases, namespace)
         # Compute set of abstract method names
         abstracts = {name
                      for name, value in namespace.items()

Modified: python/branches/p3yk/Lib/ctypes/__init__.py
==============================================================================
--- python/branches/p3yk/Lib/ctypes/__init__.py	(original)
+++ python/branches/p3yk/Lib/ctypes/__init__.py	Tue Jun 12 06:20:05 2007
@@ -149,7 +149,7 @@
     _type_ = "O"
     def __repr__(self):
         try:
-            return super(py_object, self).__repr__()
+            return super().__repr__()
         except ValueError:
             return "%s(<NULL>)" % type(self).__name__
 _check_size(py_object, "P")

Modified: python/branches/p3yk/Lib/ctypes/_endian.py
==============================================================================
--- python/branches/p3yk/Lib/ctypes/_endian.py	(original)
+++ python/branches/p3yk/Lib/ctypes/_endian.py	Tue Jun 12 06:20:05 2007
@@ -29,7 +29,7 @@
                 rest = desc[2:]
                 fields.append((name, _other_endian(typ)) + rest)
             value = fields
-        super(_swapped_meta, self).__setattr__(attrname, value)
+        super().__setattr__(attrname, value)
 
 ################################################################
 

Modified: python/branches/p3yk/Lib/ctypes/test/test_init.py
==============================================================================
--- python/branches/p3yk/Lib/ctypes/test/test_init.py	(original)
+++ python/branches/p3yk/Lib/ctypes/test/test_init.py	Tue Jun 12 06:20:05 2007
@@ -7,7 +7,7 @@
     new_was_called = False
 
     def __new__(cls):
-        result = super(X, cls).__new__(cls)
+        result = super().__new__(cls)
         result.new_was_called = True
         return result
 

Modified: python/branches/p3yk/Lib/distutils/tests/support.py
==============================================================================
--- python/branches/p3yk/Lib/distutils/tests/support.py	(original)
+++ python/branches/p3yk/Lib/distutils/tests/support.py	Tue Jun 12 06:20:05 2007
@@ -9,12 +9,12 @@
 class LoggingSilencer(object):
 
     def setUp(self):
-        super(LoggingSilencer, self).setUp()
+        super().setUp()
         self.threshold = log.set_threshold(log.FATAL)
 
     def tearDown(self):
         log.set_threshold(self.threshold)
-        super(LoggingSilencer, self).tearDown()
+        super().tearDown()
 
 
 class TempdirManager(object):
@@ -24,11 +24,11 @@
     """
 
     def setUp(self):
-        super(TempdirManager, self).setUp()
+        super().setUp()
         self.tempdirs = []
 
     def tearDown(self):
-        super(TempdirManager, self).tearDown()
+        super().tearDown()
         while self.tempdirs:
             d = self.tempdirs.pop()
             shutil.rmtree(d)

Modified: python/branches/p3yk/Lib/plat-mac/plistlib.py
==============================================================================
--- python/branches/p3yk/Lib/plat-mac/plistlib.py	(original)
+++ python/branches/p3yk/Lib/plat-mac/plistlib.py	Tue Jun 12 06:20:05 2007
@@ -320,7 +320,7 @@
         from warnings import warn
         warn("The plistlib.Dict class is deprecated, use builtin dict instead",
              PendingDeprecationWarning)
-        super(Dict, self).__init__(**kwargs)
+        super().__init__(**kwargs)
 
 
 class Plist(_InternalDict):
@@ -333,7 +333,7 @@
         from warnings import warn
         warn("The Plist class is deprecated, use the readPlist() and "
              "writePlist() functions instead", PendingDeprecationWarning)
-        super(Plist, self).__init__(**kwargs)
+        super().__init__(**kwargs)
 
     def fromFile(cls, pathOrFile):
         """Deprecated. Use the readPlist() function instead."""

Modified: python/branches/p3yk/Lib/random.py
==============================================================================
--- python/branches/p3yk/Lib/random.py	(original)
+++ python/branches/p3yk/Lib/random.py	Tue Jun 12 06:20:05 2007
@@ -110,19 +110,19 @@
                 import time
                 a = int(time.time() * 256) # use fractional seconds
 
-        super(Random, self).seed(a)
+        super().seed(a)
         self.gauss_next = None
 
     def getstate(self):
         """Return internal state; can be passed to setstate() later."""
-        return self.VERSION, super(Random, self).getstate(), self.gauss_next
+        return self.VERSION, super().getstate(), self.gauss_next
 
     def setstate(self, state):
         """Restore internal state from object returned by getstate()."""
         version = state[0]
         if version == 2:
             version, internalstate, self.gauss_next = state
-            super(Random, self).setstate(internalstate)
+            super().setstate(internalstate)
         else:
             raise ValueError("state with version %s passed to "
                              "Random.setstate() of version %s" %

Modified: python/branches/p3yk/Lib/string.py
==============================================================================
--- python/branches/p3yk/Lib/string.py	(original)
+++ python/branches/p3yk/Lib/string.py	Tue Jun 12 06:20:05 2007
@@ -103,7 +103,7 @@
     """
 
     def __init__(cls, name, bases, dct):
-        super(_TemplateMetaclass, cls).__init__(name, bases, dct)
+        super().__init__(name, bases, dct)
         if 'pattern' in dct:
             pattern = cls.pattern
         else:

Modified: python/branches/p3yk/Lib/test/list_tests.py
==============================================================================
--- python/branches/p3yk/Lib/test/list_tests.py	(original)
+++ python/branches/p3yk/Lib/test/list_tests.py	Tue Jun 12 06:20:05 2007
@@ -451,7 +451,7 @@
         self.assertEqual(u, list("ham"))
 
     def test_iadd(self):
-        super(CommonTest, self).test_iadd()
+        super().test_iadd()
         u = self.type2test([0, 1])
         u2 = u
         u += [2, 3]

Modified: python/branches/p3yk/Lib/test/test_array.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_array.py	(original)
+++ python/branches/p3yk/Lib/test/test_array.py	Tue Jun 12 06:20:05 2007
@@ -710,7 +710,7 @@
 class StringTest(BaseTest):
 
     def test_setitem(self):
-        super(StringTest, self).test_setitem()
+        super().test_setitem()
         a = array.array(self.typecode, self.example)
         self.assertRaises(TypeError, a.__setitem__, 0, self.example[:2])
 

Modified: python/branches/p3yk/Lib/test/test_collections.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_collections.py	(original)
+++ python/branches/p3yk/Lib/test/test_collections.py	Tue Jun 12 06:20:05 2007
@@ -81,7 +81,7 @@
         # Check direct subclassing
         class H(Hashable):
             def __hash__(self):
-                return super(H, self).__hash__()
+                return super().__hash__()
         self.assertEqual(hash(H()), 0)
         self.failIf(issubclass(int, H))
 
@@ -104,7 +104,7 @@
         # Check direct subclassing
         class I(Iterable):
             def __iter__(self):
-                return super(I, self).__iter__()
+                return super().__iter__()
         self.assertEqual(list(I()), [])
         self.failIf(issubclass(str, I))
 

Modified: python/branches/p3yk/Lib/test/test_list.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_list.py	(original)
+++ python/branches/p3yk/Lib/test/test_list.py	Tue Jun 12 06:20:05 2007
@@ -5,7 +5,7 @@
     type2test = list
 
     def test_truth(self):
-        super(ListTest, self).test_truth()
+        super().test_truth()
         self.assert_(not [])
         self.assert_([42])
 
@@ -13,7 +13,7 @@
         self.assert_([] is not [])
 
     def test_len(self):
-        super(ListTest, self).test_len()
+        super().test_len()
         self.assertEqual(len([]), 0)
         self.assertEqual(len([0]), 1)
         self.assertEqual(len([0, 1, 2]), 3)

Modified: python/branches/p3yk/Lib/test/test_super.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_super.py	(original)
+++ python/branches/p3yk/Lib/test/test_super.py	Tue Jun 12 06:20:05 2007
@@ -1,8 +1,5 @@
 """Unit tests for new super() implementation."""
 
-# XXX Temporarily, we use super() instead of super.  Or maybe we should
-# use this, period?
-
 import sys
 import unittest
 from test import test_support

Modified: python/branches/p3yk/Lib/test/test_tuple.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_tuple.py	(original)
+++ python/branches/p3yk/Lib/test/test_tuple.py	Tue Jun 12 06:20:05 2007
@@ -5,30 +5,30 @@
     type2test = tuple
 
     def test_constructors(self):
-        super(TupleTest, self).test_len()
+        super().test_len()
         # calling built-in types without argument must return empty
         self.assertEqual(tuple(), ())
 
     def test_truth(self):
-        super(TupleTest, self).test_truth()
+        super().test_truth()
         self.assert_(not ())
         self.assert_((42, ))
 
     def test_len(self):
-        super(TupleTest, self).test_len()
+        super().test_len()
         self.assertEqual(len(()), 0)
         self.assertEqual(len((0,)), 1)
         self.assertEqual(len((0, 1, 2)), 3)
 
     def test_iadd(self):
-        super(TupleTest, self).test_iadd()
+        super().test_iadd()
         u = (0, 1)
         u2 = u
         u += (2, 3)
         self.assert_(u is not u2)
 
     def test_imul(self):
-        super(TupleTest, self).test_imul()
+        super().test_imul()
         u = (0, 1)
         u2 = u
         u *= 3

Modified: python/branches/p3yk/Lib/test/test_unittest.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_unittest.py	(original)
+++ python/branches/p3yk/Lib/test/test_unittest.py	Tue Jun 12 06:20:05 2007
@@ -16,23 +16,23 @@
 class LoggingResult(unittest.TestResult):
     def __init__(self, log):
         self._events = log
-        super(LoggingResult, self).__init__()
+        super().__init__()
 
     def startTest(self, test):
         self._events.append('startTest')
-        super(LoggingResult, self).startTest(test)
+        super().startTest(test)
 
     def stopTest(self, test):
         self._events.append('stopTest')
-        super(LoggingResult, self).stopTest(test)
+        super().stopTest(test)
 
     def addFailure(self, *args):
         self._events.append('addFailure')
-        super(LoggingResult, self).addFailure(*args)
+        super().addFailure(*args)
 
     def addError(self, *args):
         self._events.append('addError')
-        super(LoggingResult, self).addError(*args)
+        super().addError(*args)
 
 class TestEquality(object):
     # Check for a valid __eq__ implementation

Modified: python/branches/p3yk/Lib/test/test_userlist.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_userlist.py	(original)
+++ python/branches/p3yk/Lib/test/test_userlist.py	Tue Jun 12 06:20:05 2007
@@ -8,7 +8,7 @@
     type2test = UserList
 
     def test_getslice(self):
-        super(UserListTest, self).test_getslice()
+        super().test_getslice()
         l = [0, 1, 2, 3, 4]
         u = self.type2test(l)
         for i in range(-3, 6):
@@ -30,7 +30,7 @@
         self.assertEqual(u2, list("spameggs"))
 
     def test_iadd(self):
-        super(UserListTest, self).test_iadd()
+        super().test_iadd()
         u = [0, 1]
         u += UserList([0, 1])
         self.assertEqual(u, [0, 1, 0, 1])

Modified: python/branches/p3yk/Lib/test/test_weakref.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_weakref.py	(original)
+++ python/branches/p3yk/Lib/test/test_weakref.py	Tue Jun 12 06:20:05 2007
@@ -651,10 +651,10 @@
         class MyRef(weakref.ref):
             def __init__(self, ob, callback=None, value=42):
                 self.value = value
-                super(MyRef, self).__init__(ob, callback)
+                super().__init__(ob, callback)
             def __call__(self):
                 self.called = True
-                return super(MyRef, self).__call__()
+                return super().__call__()
         o = Object("foo")
         mr = MyRef(o, value=24)
         self.assert_(mr() is o)
@@ -1091,7 +1091,7 @@
 >>> import weakref
 >>> class ExtendedRef(weakref.ref):
 ...     def __init__(self, ob, callback=None, **annotations):
-...         super(ExtendedRef, self).__init__(ob, callback)
+...         super().__init__(ob, callback)
 ...         self.__counter = 0
 ...         for k, v in annotations.items():
 ...             setattr(self, k, v)
@@ -1099,7 +1099,7 @@
 ...         '''Return a pair containing the referent and the number of
 ...         times the reference has been called.
 ...         '''
-...         ob = super(ExtendedRef, self).__call__()
+...         ob = super().__call__()
 ...         if ob is not None:
 ...             self.__counter += 1
 ...             ob = (ob, self.__counter)

Modified: python/branches/p3yk/Lib/weakref.py
==============================================================================
--- python/branches/p3yk/Lib/weakref.py	(original)
+++ python/branches/p3yk/Lib/weakref.py	Tue Jun 12 06:20:05 2007
@@ -204,7 +204,7 @@
         return self
 
     def __init__(self, ob, callback, key):
-        super(KeyedRef,  self).__init__(ob, callback)
+        super().__init__(ob, callback)
 
 
 class WeakKeyDictionary(UserDict.UserDict):


More information about the Python-3000-checkins mailing list