Index: Lib/calendar.py =================================================================== --- Lib/calendar.py (revision 77953) +++ Lib/calendar.py (working copy) @@ -564,6 +564,10 @@ firstweekday = c.getfirstweekday def setfirstweekday(firstweekday): + try: + firstweekday = firstweekday.__index__() + except AttributeError: + raise IllegalWeekdayError(firstweekday) if not MONDAY <= firstweekday <= SUNDAY: raise IllegalWeekdayError(firstweekday) c.firstweekday = firstweekday Index: Lib/_pyio.py =================================================================== --- Lib/_pyio.py (revision 77953) +++ Lib/_pyio.py (working copy) @@ -864,8 +864,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 = pos.__index__() + except AttributeError as err: + raise TypeError("an integer is required") + if pos < 0: + raise ValueError("negative truncate position %r" % (pos,)) del self._buffer[pos:] return pos @@ -1813,6 +1818,10 @@ if n is None: n = -1 decoder = self._decoder or self._get_decoder() + try: + n = n.__index__() + except AttributeError as err: + raise TypeError("an integer is required") if n < 0: # Read everything. result = (self._get_decoded_chars() + Index: Lib/test/string_tests.py =================================================================== --- Lib/test/string_tests.py (revision 77953) +++ Lib/test/string_tests.py (working copy) @@ -716,7 +716,7 @@ EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby") # Silence Py3k warning - with test_support.check_warnings(): + with test_support.check_py3k_warnings(): ba = buffer('a') bb = buffer('b') EQ("bbc", "abc", "replace", ba, bb) Index: Lib/test/test_calendar.py =================================================================== --- Lib/test/test_calendar.py (revision 77953) +++ Lib/test/test_calendar.py (working copy) @@ -212,11 +212,9 @@ self.assertEqual(calendar.isleap(2003), 0) def test_setfirstweekday(self): - # Silence a py3k warning claiming to affect Lib/calendar.py - with test_support.check_warnings(): - self.assertRaises(ValueError, calendar.setfirstweekday, 'flabber') - self.assertRaises(ValueError, calendar.setfirstweekday, -1) - self.assertRaises(ValueError, calendar.setfirstweekday, 200) + self.assertRaises(ValueError, calendar.setfirstweekday, 'flabber') + self.assertRaises(ValueError, calendar.setfirstweekday, -1) + self.assertRaises(ValueError, calendar.setfirstweekday, 200) orig = calendar.firstweekday() calendar.setfirstweekday(calendar.SUNDAY) self.assertEqual(calendar.firstweekday(), calendar.SUNDAY) Index: Lib/test/test_fileio.py =================================================================== --- Lib/test/test_fileio.py (revision 77953) +++ Lib/test/test_fileio.py (working copy) @@ -391,7 +391,7 @@ self.assertRaises(TypeError, _FileIO, "1", 0, 0) def testWarnings(self): - with check_warnings() as w: + with check_warnings(lazy=True) as w: self.assertEqual(w.warnings, []) self.assertRaises(TypeError, _FileIO, []) self.assertEqual(w.warnings, []) Index: Lib/test/test_index.py =================================================================== --- Lib/test/test_index.py (revision 77953) +++ Lib/test/test_index.py (working copy) @@ -279,16 +279,14 @@ def test_getitem(self): self._getitem_helper(object) - # Silence Py3k warning - with test_support.check_warnings(): + with test_support.check_py3k_warnings(): self._getslice_helper_deprecated(object) def test_getitem_classic(self): class Empty: pass # XXX This test fails (see bug #7532) #self._getitem_helper(Empty) - # Silence Py3k warning - with test_support.check_warnings(): + with test_support.check_py3k_warnings(): self._getslice_helper_deprecated(Empty) def test_sequence_repeat(self): @@ -308,8 +306,7 @@ XRangeTestCase, OverflowTestCase, ) - # Silence Py3k warning - with test_support.check_warnings(): + with test_support.check_py3k_warnings(): test_support.run_unittest( ClassicSeqDeprecatedTestCase, NewSeqDeprecatedTestCase, Index: Lib/test/test_memoryio.py =================================================================== --- Lib/test/test_memoryio.py (revision 77953) +++ Lib/test/test_memoryio.py (working copy) @@ -134,9 +134,7 @@ pos = memio.tell() self.assertEqual(memio.truncate(None), pos) self.assertEqual(memio.tell(), pos) - # Silence a py3k warning - with support.check_warnings(): - self.assertRaises(TypeError, memio.truncate, '0') + self.assertRaises(TypeError, memio.truncate, '0') memio.close() self.assertRaises(ValueError, memio.truncate, 0) @@ -173,9 +171,7 @@ self.assertEqual(type(memio.read()), type(buf)) memio.seek(0) self.assertEqual(memio.read(None), buf) - # Silence a py3k warning - with support.check_warnings(): - self.assertRaises(TypeError, memio.read, '') + self.assertRaises(TypeError, memio.read, '') memio.close() self.assertRaises(ValueError, memio.read) Index: Lib/test/test_random.py =================================================================== --- Lib/test/test_random.py (revision 77953) +++ Lib/test/test_random.py (working copy) @@ -53,8 +53,7 @@ state3 = self.gen.getstate() # s/b distinct from state2 self.assertNotEqual(state2, state3) - # Silence py3k warnings - with test_support.check_warnings(): + with test_support.check_py3k_warnings(lazy=True): self.assertRaises(TypeError, self.gen.jumpahead) # needs an arg self.assertRaises(TypeError, self.gen.jumpahead, "ick") # wrong type self.assertRaises(TypeError, self.gen.jumpahead, 2.3) # wrong type Index: Lib/test/test_unicode.py =================================================================== --- Lib/test/test_unicode.py (revision 77953) +++ Lib/test/test_unicode.py (working copy) @@ -499,8 +499,7 @@ ) if not sys.platform.startswith('java'): - # Silence Py3k warning - with test_support.check_warnings(): + with test_support.check_py3k_warnings(): buf = buffer('character buffers are decoded to unicode') self.assertEqual( unicode(