~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Python/bltinmodule.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
224
224
builtin_callable(PyObject *self, PyObject *v)
225
225
{
226
226
        if (PyErr_WarnPy3k("callable() not supported in 3.x; "
227
 
                           "use hasattr(o, '__call__')", 1) < 0)
 
227
                           "use isinstance(x, collections.Callable)", 1) < 0)
228
228
                return NULL;
229
229
        return PyBool_FromLong((long)PyCallable_Check(v));
230
230
}
465
465
        int mode = -1;
466
466
        int dont_inherit = 0;
467
467
        int supplied_flags = 0;
 
468
        int is_ast;
468
469
        PyCompilerFlags cf;
469
470
        PyObject *result = NULL, *cmd, *tmp = NULL;
470
471
        Py_ssize_t length;
504
505
                return NULL;
505
506
        }
506
507
 
507
 
        if (PyAST_Check(cmd)) {
 
508
        is_ast = PyAST_Check(cmd);
 
509
        if (is_ast == -1)
 
510
                return NULL;
 
511
        if (is_ast) {
508
512
                if (supplied_flags & PyCF_ONLY_AST) {
509
513
                        Py_INCREF(cmd);
510
514
                        result = cmd;
2120
2124
static PyObject *
2121
2125
builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
2122
2126
{
2123
 
        double number;
 
2127
        double number, abs_number, abs_result;
2124
2128
        double f;
2125
2129
        int ndigits = 0;
2126
2130
        int i;
2137
2141
                number /= f;
2138
2142
        else
2139
2143
                number *= f;
2140
 
        if (number >= 0.0)
2141
 
                number = floor(number + 0.5);
2142
 
        else
2143
 
                number = ceil(number - 0.5);
 
2144
 
 
2145
        /* round `number` to nearest integer, rounding halves away from zero */
 
2146
        abs_number = fabs(number);
 
2147
        abs_result = floor(abs_number);
 
2148
        if (abs_number - abs_result >= 0.5)
 
2149
                abs_result += 1.0;
 
2150
        number = copysign(abs_result, number);
 
2151
 
2144
2152
        if (ndigits < 0)
2145
2153
                number *= f;
2146
2154
        else