diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-05-17 20:09:42 +0000 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-05-17 20:09:42 +0000 |
commit | c6d64ec83fd6bb170725a04409d8383a53559c95 (patch) | |
tree | 5c5432c54cebcaf1da38b605be01585767f68ddf /Python/bltinmodule.c | |
parent | d7943cb71d51bbf0e2ac715b08b8da2208d2800c (diff) | |
download | cpython-git-c6d64ec83fd6bb170725a04409d8383a53559c95.tar.gz |
revert 63425 over Guido's Febuary message about this, that I missed
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 45f4081aa0..0234b6bd80 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1181,29 +1181,22 @@ builtin_hex(PyObject *self, PyObject *v) { PyNumberMethods *nb; PyObject *res; - - nb = Py_TYPE(v)->tp_as_number; - - if (nb != NULL && nb->nb_hex != NULL) { - if (PyErr_WarnPy3k("In 3.x, hex() converts " - "the result of __index__ to hexadecimal.", - 1) < 0) - return NULL; - res = (*nb->nb_hex)(v); - if (res && !PyString_Check(res)) { - PyErr_Format(PyExc_TypeError, - "__hex__ returned non-string (type %.200s)", - res->ob_type->tp_name); - Py_DECREF(res); - return NULL; - } - return res; + + if ((nb = v->ob_type->tp_as_number) == NULL || + nb->nb_hex == NULL) { + PyErr_SetString(PyExc_TypeError, + "hex() argument can't be converted to hex"); + return NULL; } - else if (PyIndex_Check(v)) - return PyNumber_ToBase(v, 16); - PyErr_SetString(PyExc_TypeError, - "hex() argument can't be converted to hex"); - return NULL; + res = (*nb->nb_hex)(v); + if (res && !PyString_Check(res)) { + PyErr_Format(PyExc_TypeError, + "__hex__ returned non-string (type %.200s)", + res->ob_type->tp_name); + Py_DECREF(res); + return NULL; + } + return res; } PyDoc_STRVAR(hex_doc, @@ -1463,11 +1456,6 @@ builtin_oct(PyObject *self, PyObject *v) "oct() argument can't be converted to oct"); return NULL; } - if (PyErr_WarnPy3k("In 3.x, oct() converts the result of __index__ to octal; " - "Use future_builtins.oct for this behavior. " - "Also, note the returned format is different.", - 1) < 0) - return NULL; res = (*nb->nb_oct)(v); if (res && !PyString_Check(res)) { PyErr_Format(PyExc_TypeError, |