diff options
author | Sanyam Khurana <sanyam@sanyamkhurana.com> | 2017-08-18 10:37:36 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-08-18 10:37:36 (GMT) |
commit | 5e2eb35bbed3e84079165e576cdb50ef36e13493 (patch) | |
tree | a2f513631279ac12788b04a56f7f61fb63c81068 /Objects/abstract.c | |
parent | ad7eaed54382b346784e51a6f0122ce81e8842b5 (diff) | |
download | cpython-5e2eb35bbed3e84079165e576cdb50ef36e13493.zip cpython-5e2eb35bbed3e84079165e576cdb50ef36e13493.tar.gz cpython-5e2eb35bbed3e84079165e576cdb50ef36e13493.tar.bz2 |
bpo-30721: Show correct syntax hint in Py3 when using Py2 redirection syntax (#2345)
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r-- | Objects/abstract.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index cb026c0..abd9795 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -819,6 +819,21 @@ binary_op(PyObject *v, PyObject *w, const int op_slot, const char *op_name) PyObject *result = binary_op1(v, w, op_slot); if (result == Py_NotImplemented) { Py_DECREF(result); + + if (op_slot == NB_SLOT(nb_rshift) && + PyCFunction_Check(v) && + strcmp(((PyCFunctionObject *)v)->m_ml->ml_name, "print") == 0) + { + PyErr_Format(PyExc_TypeError, + "unsupported operand type(s) for %.100s: " + "'%.100s' and '%.100s'. Did you mean \"print(<message>, " + "file=<output_stream>)\"", + op_name, + v->ob_type->tp_name, + w->ob_type->tp_name); + return NULL; + } + return binop_type_error(v, w, op_name); } return result; |