deprecated and will be changed/removed in Python 3.0.
This patch is mostly from Anthony. I tweaked some format and added
a little doc.
on the command line, and is used in 2.2 by ceval.c to make all "/" divisions
true divisions (which they will be in 3.0). */
PyAPI_DATA(int) _Py_QnewFlag;
+/* Warn about 3.x issues */
+PyAPI_DATA(int) Py_Py3kWarningFlag;
/* this is a wrapper around getenv() that pays attention to
Py_IgnoreEnvironmentFlag. It should be used for getting variables like
Core and builtins
-----------------
+- Add -3 option to the interpreter to warn about features that are
+ deprecated and will be changed/removed in Python 3.0.
+
- Patch #1686487: you can now pass any mapping after '**' in function
calls.
-h print this help message and exit
-i Inspect interactively after running script (also PYTHONINSPECT=x) and
force prompts, even if stdin appears not to be a terminal
+-m mod run library module as a script (terminates option list
-O optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)
-OO remove doc-strings in addition to the -O optimizations
-Q arg division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew
-W arg : warning control (arg is action:message:category:module:lineno)
-x Skip first line of source, allowing use of non-unix Forms of #!cmd
-? Help!
+-3 warn about Python 3.x incompatibilities
-c Specify the command to execute (see next section). This terminates the
command option list (following options are passed as arguments to the command).
the name of a python file (.py) to execute read from stdin.
static int orig_argc;
/* command line options */
-#define BASE_OPTS "c:dEhim:OQ:StuUvVW:xX?"
+#define BASE_OPTS "3c:dEhim:OQ:StuUvVW:xX?"
#ifndef RISCOS
#define PROGRAM_OPTS BASE_OPTS
-V : print the Python version number and exit (also --version)\n\
-W arg : warning control; arg is action:message:category:module:lineno\n\
-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
+-3 : warn about Python 3.x incompatibilities\n\
file : program read from script file\n\
- : program read from stdin (default; interactive mode if a tty)\n\
";
Py_DebugFlag++;
break;
+ case '3':
+ Py_Py3kWarningFlag++;
+ break;
+
case 'Q':
if (strcmp(_PyOS_optarg, "old") == 0) {
Py_DivisionWarningFlag = 0;
}
static PyObject *
-dict_has_key(register dictobject *mp, PyObject *key)
+dict_contains(register dictobject *mp, PyObject *key)
{
long hash;
dictentry *ep;
return PyBool_FromLong(ep->me_value != NULL);
}
+static PyObject *
+dict_has_key(register dictobject *mp, PyObject *key)
+{
+ if (Py_Py3kWarningFlag &&
+ PyErr_Warn(PyExc_DeprecationWarning,
+ "dict.has_key() not supported in 3.x") < 0)
+ return NULL;
+ return dict_contains(mp, key);
+}
+
static PyObject *
dict_get(register dictobject *mp, PyObject *args)
{
"D.iteritems() -> an iterator over the (key, value) items of D");
static PyMethodDef mapp_methods[] = {
- {"__contains__",(PyCFunction)dict_has_key, METH_O | METH_COEXIST,
+ {"__contains__",(PyCFunction)dict_contains, METH_O | METH_COEXIST,
contains__doc__},
{"__getitem__", (PyCFunction)dict_subscript, METH_O | METH_COEXIST,
getitem__doc__},
#endif /* Py_REF_DEBUG */
int Py_DivisionWarningFlag;
+int Py_Py3kWarningFlag;
/* Object allocation routines used by NEWOBJ and NEWVAROBJ macros.
These are used by the individual routines for object creation.
PyObject *func, *alist = NULL, *kwdict = NULL;
PyObject *t = NULL, *retval = NULL;
+ if (Py_Py3kWarningFlag &&
+ PyErr_Warn(PyExc_DeprecationWarning,
+ "apply() not supported in 3.x") < 0)
+ return NULL;
+
if (!PyArg_UnpackTuple(args, "apply", 1, 3, &func, &alist, &kwdict))
return NULL;
if (alist != NULL) {