.. function:: factorial(x)
- Return *x* factorial. Raises :exc:`ValueError` if *x* is not intergral or
+ Return *x* factorial. Raises :exc:`ValueError` if *x* is not integral or
is negative.
.. function:: floor(x)
# _listener holds the server object doing the listening
_listener = None
-def fileConfig(fname, defaults=None):
+def fileConfig(fname, defaults=None, disable_existing_loggers=1):
"""
Read the logging configuration from a ConfigParser-format file.
del logging._handlerList[:]
# Handlers add themselves to logging._handlers
handlers = _install_handlers(cp, formatters)
- _install_loggers(cp, handlers)
+ _install_loggers(cp, handlers, disable_existing_loggers)
finally:
logging._releaseLock()
return handlers
-def _install_loggers(cp, handlers):
+def _install_loggers(cp, handlers, disable_existing_loggers):
"""Create and install loggers"""
# configure the root first
logger.level = logging.NOTSET
logger.handlers = []
logger.propagate = 1
- else:
+ elif disable_existing_loggers:
logger.disabled = 1
self.assert_(usersite in sys.path)
rc = subprocess.call([sys.executable, '-c',
- 'import sys; sys.exit("%s" in sys.path)' % usersite])
+ 'import sys; sys.exit(%r in sys.path)' % usersite])
self.assertEqual(rc, 1)
rc = subprocess.call([sys.executable, '-s', '-c',
- 'import sys; sys.exit("%s" in sys.path)' % usersite])
+ 'import sys; sys.exit(%r in sys.path)' % usersite])
self.assertEqual(rc, 0)
env = os.environ.copy()
env["PYTHONNOUSERSITE"] = "1"
rc = subprocess.call([sys.executable, '-c',
- 'import sys; sys.exit("%s" in sys.path)' % usersite],
+ 'import sys; sys.exit(%r in sys.path)' % usersite],
env=env)
self.assertEqual(rc, 0)
self.assertEqual(slice(None, None, -1).indices(10), (9, -1, -1))
self.assertEqual(slice(None, None, -2).indices(10), (9, -1, -2))
self.assertEqual(slice(3, None, -2).indices(10), (3, -1, -2))
+ # issue 3004 tests
+ self.assertEqual(slice(None, -9).indices(10), (0, 1, 1))
+ self.assertEqual(slice(None, -10).indices(10), (0, 0, 1))
+ self.assertEqual(slice(None, -11).indices(10), (0, 0, 1))
+ self.assertEqual(slice(None, -10, -1).indices(10), (9, 0, -1))
+ self.assertEqual(slice(None, -11, -1).indices(10), (9, -1, -1))
+ self.assertEqual(slice(None, -12, -1).indices(10), (9, -1, -1))
+ self.assertEqual(slice(None, 9).indices(10), (0, 9, 1))
+ self.assertEqual(slice(None, 10).indices(10), (0, 10, 1))
+ self.assertEqual(slice(None, 11).indices(10), (0, 10, 1))
+ self.assertEqual(slice(None, 8, -1).indices(10), (9, 8, -1))
+ self.assertEqual(slice(None, 9, -1).indices(10), (9, 9, -1))
+ self.assertEqual(slice(None, 10, -1).indices(10), (9, 9, -1))
+
self.assertEqual(
slice(-100, 100 ).indices(10),
slice(None).indices(10)
/* Internal helper used for updating curses.LINES, curses.COLS, _curses.LINES
* and _curses.COLS */
+#if defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)
static int
update_lines_cols(void)
{
Py_DECREF(m);
return 1;
}
+#endif
#ifdef HAVE_CURSES_RESIZETERM
static PyObject *
sum([1e+308, 1e+308, 1e-308]) raises an OverflowError due to the
overflow of the first partial sum.
- Note 3: The itermediate values lo, yr, and hi are declared volatile so
- aggressive compilers won't algebraicly reduce lo to always be exactly 0.0.
+ Note 3: The intermediate values lo, yr, and hi are declared volatile so
+ aggressive compilers won't algebraically reduce lo to always be exactly 0.0.
Also, the volatile declaration forces the values to be stored in memory as
regular doubles instead of extended long precision (80-bit) values. This
- prevents double rounding because any addition or substraction of two doubles
+ prevents double rounding because any addition or subtraction of two doubles
can be resolved exactly into double-sized hi and lo values. As long as the
hi value gets forced into a double before yr and lo are computed, the extra
bits in downstream extended precision operations (x87 for example) will be
error:
Py_DECREF(result);
- Py_XDECREF(iobj);
return NULL;
}
else {
if (!_PyEval_SliceIndex(r->stop, stop)) return -1;
if (*stop < 0) *stop += length;
- if (*stop < 0) *stop = -1;
- if (*stop > length) *stop = length;
+ if (*stop < 0) *stop = (*step < 0) ? -1 : 0;
+ if (*stop >= length)
+ *stop = (*step < 0) ? length - 1 : length;
}
if ((*step < 0 && *stop >= *start)