From 80055f6295dd48274ae68d13806c7ee3c5b5882f Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 25 Mar 2008 07:56:27 +0000 Subject: #2355: py3k warning for buffer(). --- Lib/test/test_py3kwarn.py | 5 +++++ Misc/NEWS | 4 +++- Objects/bufferobject.c | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py index 07bcdf9..41ad25b 100644 --- a/Lib/test/test_py3kwarn.py +++ b/Lib/test/test_py3kwarn.py @@ -118,6 +118,11 @@ class TestPy3KWarnings(unittest.TestCase): with catch_warning() as w: self.assertWarning(set(), w, expected) + def test_buffer(self): + expected = 'buffer will be removed in 3.x' + with catch_warning() as w: + self.assertWarning(buffer('a'), w, expected) + def test_main(): run_unittest(TestPy3KWarnings) diff --git a/Misc/NEWS b/Misc/NEWS index 3c42bce..881cc83 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -11,7 +11,9 @@ What's New in Python 2.6 alpha 2? Core and builtins ----------------- - + +- Issue #2355: add Py3k warning for buffer(). + - Issue #1477: With narrow Unicode builds, the unicode escape sequence \Uxxxxxxxx did not accept values outside the Basic Multilingual Plane. This affected raw unicode literals and the 'raw-unicode-escape' codec. Now diff --git a/Objects/bufferobject.c b/Objects/bufferobject.c index e01938c..0a818d6 100644 --- a/Objects/bufferobject.c +++ b/Objects/bufferobject.c @@ -229,6 +229,11 @@ PyBuffer_New(Py_ssize_t size) static PyObject * buffer_new(PyTypeObject *type, PyObject *args, PyObject *kw) { + if (Py_Py3kWarningFlag && + PyErr_WarnEx(PyExc_DeprecationWarning, + "buffer will be removed in 3.x", 1) < 0) + return NULL; + PyObject *ob; Py_ssize_t offset = 0; Py_ssize_t size = Py_END_OF_BUFFER; -- cgit v0.12