summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2006-03-15 04:58:47 +0000
committerGuido van Rossum <guido@python.org>2006-03-15 04:58:47 +0000
commit45aecf451a64fb1ebe5e74d0b00965ac8d99dff6 (patch)
treea7edcfb45ceafcffde68a3542aeba67089ea81cb /Python
parentf3175f6341ae207543a0d2d3be36c457349066e6 (diff)
downloadcpython-git-45aecf451a64fb1ebe5e74d0b00965ac8d99dff6.tar.gz
Checkpoint. 218 tests are okay; 53 are failing. Done so far:
- all classes are new-style (but ripping out classobject.[ch] isn't done) - int/int -> float - all exceptions must derive from BaseException - absolute import - 'as' and 'with' are keywords
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c18
-rw-r--r--Python/compile.c23
-rw-r--r--Python/errors.c3
-rw-r--r--Python/future.c6
-rw-r--r--Python/getargs.c11
-rw-r--r--Python/graminit.c17
-rw-r--r--Python/import.c5
-rw-r--r--Python/pythonrun.c4
8 files changed, 30 insertions, 57 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index de2b35b4af..c854fcfe51 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3025,15 +3025,7 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
Py_DECREF(tmp);
}
- if (PyString_CheckExact(type)) {
- /* Raising builtin string is deprecated but still allowed --
- * do nothing. Raising an instance of a new-style str
- * subclass is right out. */
- if (PyErr_Warn(PyExc_DeprecationWarning,
- "raising a string exception is deprecated"))
- goto raise_error;
- }
- else if (PyExceptionClass_Check(type))
+ if (PyExceptionClass_Check(type))
PyErr_NormalizeException(&type, &value, &tb);
else if (PyExceptionInstance_Check(type)) {
@@ -3054,10 +3046,8 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
else {
/* Not something you can raise. You get an exception
anyway, just not what you specified :-) */
- PyErr_Format(PyExc_TypeError,
- "exceptions must be classes, instances, or "
- "strings (deprecated), not %s",
- type->ob_type->tp_name);
+ PyErr_SetString(PyExc_TypeError,
+ "exceptions must derive from BaseException");
goto raise_error;
}
PyErr_Restore(type, value, tb);
@@ -4148,7 +4138,7 @@ build_class(PyObject *methods, PyObject *bases, PyObject *name)
if (g != NULL && PyDict_Check(g))
metaclass = PyDict_GetItemString(g, "__metaclass__");
if (metaclass == NULL)
- metaclass = (PyObject *) &PyClass_Type;
+ metaclass = (PyObject *) &PyType_Type;
Py_INCREF(metaclass);
}
result = PyObject_CallFunction(metaclass, "OOO", name, bases, methods);
diff --git a/Python/compile.c b/Python/compile.c
index baf3989a9d..cfc6ef199e 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -2464,11 +2464,7 @@ compiler_import(struct compiler *c, stmt_ty s)
int r;
PyObject *level;
- if (c->c_flags && (c->c_flags->cf_flags & CO_FUTURE_ABSIMPORT))
- level = PyInt_FromLong(0);
- else
- level = PyInt_FromLong(-1);
-
+ level = PyInt_FromLong(0);
if (level == NULL)
return 0;
@@ -2511,12 +2507,7 @@ compiler_from_import(struct compiler *c, stmt_ty s)
if (!names)
return 0;
- if (s->v.ImportFrom.level == 0 && c->c_flags &&
- !(c->c_flags->cf_flags & CO_FUTURE_ABSIMPORT))
- level = PyInt_FromLong(-1);
- else
- level = PyInt_FromLong(s->v.ImportFrom.level);
-
+ level = PyInt_FromLong(s->v.ImportFrom.level);
if (!level) {
Py_DECREF(names);
return 0;
@@ -2746,10 +2737,7 @@ binop(struct compiler *c, operator_ty op)
case Mult:
return BINARY_MULTIPLY;
case Div:
- if (c->c_flags && c->c_flags->cf_flags & CO_FUTURE_DIVISION)
- return BINARY_TRUE_DIVIDE;
- else
- return BINARY_DIVIDE;
+ return BINARY_TRUE_DIVIDE;
case Mod:
return BINARY_MODULO;
case Pow:
@@ -2809,10 +2797,7 @@ inplace_binop(struct compiler *c, operator_ty op)
case Mult:
return INPLACE_MULTIPLY;
case Div:
- if (c->c_flags && c->c_flags->cf_flags & CO_FUTURE_DIVISION)
- return INPLACE_TRUE_DIVIDE;
- else
- return INPLACE_DIVIDE;
+ return INPLACE_TRUE_DIVIDE;
case Mod:
return INPLACE_MODULO;
case Pow:
diff --git a/Python/errors.c b/Python/errors.c
index 7fc4c97c82..a64900bfd2 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -557,7 +557,8 @@ PyErr_NewException(char *name, PyObject *base, PyObject *dict)
bases = PyTuple_Pack(1, base);
if (bases == NULL)
goto failure;
- result = PyClass_New(bases, dict, classname);
+ result = PyObject_CallFunction((PyObject *) (base->ob_type),
+ "OOO", classname, bases, dict);
failure:
Py_XDECREF(bases);
Py_XDECREF(mydict);
diff --git a/Python/future.c b/Python/future.c
index 4a48ba53e4..1902f1da5d 100644
--- a/Python/future.c
+++ b/Python/future.c
@@ -28,11 +28,11 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename)
} else if (strcmp(feature, FUTURE_GENERATORS) == 0) {
continue;
} else if (strcmp(feature, FUTURE_DIVISION) == 0) {
- ff->ff_features |= CO_FUTURE_DIVISION;
+ continue;
} else if (strcmp(feature, FUTURE_ABSIMPORT) == 0) {
- ff->ff_features |= CO_FUTURE_ABSIMPORT;
+ continue;
} else if (strcmp(feature, FUTURE_WITH_STATEMENT) == 0) {
- ff->ff_features |= CO_FUTURE_WITH_STATEMENT;
+ continue;
} else if (strcmp(feature, "braces") == 0) {
PyErr_SetString(PyExc_SyntaxError,
"not a chance");
diff --git a/Python/getargs.c b/Python/getargs.c
index 8ee7d2fcbb..fac0b6fdef 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -486,15 +486,16 @@ converterr(const char *expected, PyObject *arg, char *msgbuf, size_t bufsize)
#define CONV_UNICODE "(unicode conversion error)"
-/* explicitly check for float arguments when integers are expected. For now
- * signal a warning. Returns true if an exception was raised. */
+/* Explicitly check for float arguments when integers are expected.
+ Return 1 for error, 0 if ok. */
static int
float_argument_error(PyObject *arg)
{
- if (PyFloat_Check(arg) &&
- PyErr_Warn(PyExc_DeprecationWarning,
- "integer argument expected, got float" ))
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
return 1;
+ }
else
return 0;
}
diff --git a/Python/graminit.c b/Python/graminit.c
index 1853ca407d..40f17708ca 100644
--- a/Python/graminit.c
+++ b/Python/graminit.c
@@ -556,9 +556,8 @@ static state states_26[9] = {
static arc arcs_27_0[1] = {
{19, 1},
};
-static arc arcs_27_1[3] = {
+static arc arcs_27_1[2] = {
{78, 2},
- {19, 2},
{0, 1},
};
static arc arcs_27_2[1] = {
@@ -569,16 +568,15 @@ static arc arcs_27_3[1] = {
};
static state states_27[4] = {
{1, arcs_27_0},
- {3, arcs_27_1},
+ {2, arcs_27_1},
{1, arcs_27_2},
{1, arcs_27_3},
};
static arc arcs_28_0[1] = {
{12, 1},
};
-static arc arcs_28_1[3] = {
+static arc arcs_28_1[2] = {
{78, 2},
- {19, 2},
{0, 1},
};
static arc arcs_28_2[1] = {
@@ -589,7 +587,7 @@ static arc arcs_28_3[1] = {
};
static state states_28[4] = {
{1, arcs_28_0},
- {3, arcs_28_1},
+ {2, arcs_28_1},
{1, arcs_28_2},
{1, arcs_28_3},
};
@@ -917,9 +915,8 @@ static state states_40[6] = {
{1, arcs_40_4},
{1, arcs_40_5},
};
-static arc arcs_41_0[2] = {
+static arc arcs_41_0[1] = {
{78, 1},
- {19, 1},
};
static arc arcs_41_1[1] = {
{82, 2},
@@ -928,7 +925,7 @@ static arc arcs_41_2[1] = {
{0, 2},
};
static state states_41[3] = {
- {2, arcs_41_0},
+ {1, arcs_41_0},
{1, arcs_41_1},
{1, arcs_41_2},
};
@@ -1870,7 +1867,7 @@ static dfa dfas[84] = {
{296, "with_stmt", 0, 6, states_40,
"\000\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000"},
{297, "with_var", 0, 3, states_41,
- "\000\000\010\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000"},
{298, "except_clause", 0, 5, states_42,
"\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
{299, "suite", 0, 5, states_43,
diff --git a/Python/import.c b/Python/import.c
index 73051a2060..b64594d898 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -28,7 +28,7 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *);
a .pyc file in text mode the magic number will be wrong; also, the
Apple MPW compiler swaps their values, botching string constants.
- The magic numbers must be spaced apart atleast 2 values, as the
+ The magic numbers must be spaced apart at least 2 values, as the
-U interpeter flag will cause MAGIC+1 being used. They have been
odd numbers for some time now.
@@ -56,9 +56,10 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *);
Python 2.5a0: 62081 (ast-branch)
Python 2.5a0: 62091 (with)
Python 2.5a0: 62092 (changed WITH_CLEANUP opcode)
+ Python 3000: 3000
.
*/
-#define MAGIC (62092 | ((long)'\r'<<16) | ((long)'\n'<<24))
+#define MAGIC (3000 | ((long)'\r'<<16) | ((long)'\n'<<24))
/* Magic word as global; note that _PyImport_Init() can change the
value of this global to accommodate for alterations of how the
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 7b1f26439b..d04d111a44 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -696,9 +696,7 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flag
/* compute parser flags based on compiler flags */
#define PARSER_FLAGS(flags) \
((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \
- PyPARSE_DONT_IMPLY_DEDENT : 0) \
- | ((flags)->cf_flags & CO_FUTURE_WITH_STATEMENT ? \
- PyPARSE_WITH_IS_KEYWORD : 0)) : 0)
+ PyPARSE_DONT_IMPLY_DEDENT : 0)) : 0)
int
PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)