[Python-checkins] r83588 - in python/branches/release26-maint: Lib/calendar.py Lib/ctypes/test/test_callbacks.py Lib/distutils/util.py Lib/io.py Lib/warnings.py

ezio.melotti python-checkins at python.org
Mon Aug 2 23:35:07 CEST 2010


Author: ezio.melotti
Date: Mon Aug  2 23:35:06 2010
New Revision: 83588

Log:
Merged revisions 78757 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78757 | florent.xicluna | 2010-03-07 14:14:25 +0200 (Sun, 07 Mar 2010) | 2 lines
  
  Fix some py3k warnings in the standard library.
........


Modified:
   python/branches/release26-maint/   (props changed)
   python/branches/release26-maint/Lib/calendar.py
   python/branches/release26-maint/Lib/ctypes/test/test_callbacks.py
   python/branches/release26-maint/Lib/distutils/util.py
   python/branches/release26-maint/Lib/io.py
   python/branches/release26-maint/Lib/warnings.py

Modified: python/branches/release26-maint/Lib/calendar.py
==============================================================================
--- python/branches/release26-maint/Lib/calendar.py	(original)
+++ python/branches/release26-maint/Lib/calendar.py	Mon Aug  2 23:35:06 2010
@@ -564,6 +564,10 @@
 firstweekday = c.getfirstweekday
 
 def setfirstweekday(firstweekday):
+    try:
+        firstweekday.__index__
+    except AttributeError:
+        raise IllegalWeekdayError(firstweekday)
     if not MONDAY <= firstweekday <= SUNDAY:
         raise IllegalWeekdayError(firstweekday)
     c.firstweekday = firstweekday

Modified: python/branches/release26-maint/Lib/ctypes/test/test_callbacks.py
==============================================================================
--- python/branches/release26-maint/Lib/ctypes/test/test_callbacks.py	(original)
+++ python/branches/release26-maint/Lib/ctypes/test/test_callbacks.py	Mon Aug  2 23:35:06 2010
@@ -132,7 +132,7 @@
         gc.collect()
         live = [x for x in gc.get_objects()
                 if isinstance(x, X)]
-        self.failUnlessEqual(len(live), 0)
+        self.assertEqual(len(live), 0)
 
 try:
     WINFUNCTYPE
@@ -164,7 +164,7 @@
         result = integrate(0.0, 1.0, CALLBACK(func), 10)
         diff = abs(result - 1./3.)
 
-        self.failUnless(diff < 0.01, "%s not less than 0.01" % diff)
+        self.assertTrue(diff < 0.01, "%s not less than 0.01" % diff)
 
 ################################################################
 

Modified: python/branches/release26-maint/Lib/distutils/util.py
==============================================================================
--- python/branches/release26-maint/Lib/distutils/util.py	(original)
+++ python/branches/release26-maint/Lib/distutils/util.py	Mon Aug  2 23:35:06 2010
@@ -405,7 +405,7 @@
 
     log.info(msg)
     if not dry_run:
-        apply(func, args)
+        func(*args)
 
 
 def strtobool (val):

Modified: python/branches/release26-maint/Lib/io.py
==============================================================================
--- python/branches/release26-maint/Lib/io.py	(original)
+++ python/branches/release26-maint/Lib/io.py	Mon Aug  2 23:35:06 2010
@@ -849,8 +849,8 @@
         if self.closed:
             raise ValueError("seek on closed file")
         try:
-            pos = pos.__index__()
-        except AttributeError as err:
+            pos.__index__
+        except AttributeError:
             raise TypeError("an integer is required") # from err
         if whence == 0:
             if pos < 0:
@@ -874,8 +874,13 @@
             raise ValueError("truncate on closed file")
         if pos is None:
             pos = self._pos
-        elif pos < 0:
-            raise ValueError("negative truncate position %r" % (pos,))
+        else:
+            try:
+                pos.__index__
+            except AttributeError:
+                raise TypeError("an integer is required")
+            if pos < 0:
+                raise ValueError("negative truncate position %r" % (pos,))
         del self._buffer[pos:]
         return pos
 
@@ -1752,6 +1757,10 @@
         if n is None:
             n = -1
         decoder = self._decoder or self._get_decoder()
+        try:
+            n.__index__
+        except AttributeError:
+            raise TypeError("an integer is required")
         if n < 0:
             # Read everything.
             result = (self._get_decoded_chars() +

Modified: python/branches/release26-maint/Lib/warnings.py
==============================================================================
--- python/branches/release26-maint/Lib/warnings.py	(original)
+++ python/branches/release26-maint/Lib/warnings.py	Mon Aug  2 23:35:06 2010
@@ -29,7 +29,7 @@
         file.write(formatwarning(message, category, filename, lineno, line))
     except IOError:
         pass # the file (probably stderr) is invalid - this warning gets lost.
-# Keep a worrking version around in case the deprecation of the old API is
+# Keep a working version around in case the deprecation of the old API is
 # triggered.
 showwarning = _show_warning
 


More information about the Python-checkins mailing list