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
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
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)
################################################################
log.info(msg)
if not dry_run:
- apply(func, args)
+ func(*args)
def strtobool (val):
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:
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
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() +
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