[Python-checkins] cpython: Add a DeprecationWarning on bytes

victor.stinner python-checkins at python.org
Sat Feb 26 02:43:01 CET 2011


victor.stinner pushed 54e4f0934afb to cpython:

http://hg.python.org/cpython/rev/54e4f0934afb
changeset:   68035:54e4f0934afb
tag:         tip
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Sat Feb 26 02:42:51 2011 +0100
summary:
  Add a DeprecationWarning on bytes

files:
  Objects/bytesobject.c

diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -2497,6 +2497,12 @@
     Py_ssize_t size;
     static char *kwlist[] = {"source", "encoding", "errors", 0};
 
+    if (PyErr_WarnEx(PyExc_DeprecationWarning,
+                     "bytes objects are so 20th-century, "
+                     "it's maybe time to upgrade your code to Unicode!",
+                     0))
+        return NULL;
+
     if (type != &PyBytes_Type)
         return str_subtype_new(type, args, kwds);
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:bytes", kwlist, &x,

--
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list