Core and Builtins
-----------------
-Library
--------
-
-- Issue #25725: Fixed a reference leak in pickle.loads() when unpickling
- invalid data including tuple instructions.
-
-- Issue #25663: In the Readline completer, avoid listing duplicate global
- names, and search the global namespace before searching builtins.
-
-- Issue #25688: Fixed file leak in ElementTree.iterparse() raising an error.
-
-- Issue #23914: Fixed SystemError raised by unpickler on broken pickle data.
-
-- Issue #25691: Fixed crash on deleting ElementTree.Element attributes.
-
-- Issue #25624: ZipFile now always writes a ZIP_STORED header for directory
- entries. Patch by Dingyuan Wang.
-
-
-What's New in Python 3.5.1 final?
-=================================
-
-Release date: 2015-12-06
-
-Core and Builtins
------------------
-
-Library
--------
-
-
-What's New in Python 3.5.1 release candidate 1?
-===============================================
-
-Release date: 2015-11-22
-
-Core and Builtins
------------------
-
+ - Issue #24731: Fixed crash on converting objects with special methods
+ __bytes__, __trunc__, and __float__ returning instances of subclasses of
+ bytes, int, and float to subclasses of bytes, int, and float correspondingly.
+
- Issue #25630: Fix a possible segfault during argument parsing in functions
that accept filesystem paths.
return NULL;
}
+PyObject *
+PyBytes_FromObject(PyObject *x)
+{
+ if (x == NULL) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
+
+ if (PyBytes_CheckExact(x)) {
+ Py_INCREF(x);
+ return x;
+ }
+
+ /* Use the modern buffer interface */
+ if (PyObject_CheckBuffer(x))
+ return _PyBytes_FromBuffer(x);
+
+ if (PyList_CheckExact(x))
+ return _PyBytes_FromList(x);
+
+ if (PyTuple_CheckExact(x))
+ return _PyBytes_FromTuple(x);
+
+ if (PyUnicode_Check(x)) {
+ PyErr_SetString(PyExc_TypeError,
+ "cannot convert unicode object to bytes");
+ return NULL;
+ }
+
+ return _PyBytes_FromIterator(x);
+}
+
static PyObject *
- str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ bytes_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *tmp, *pnew;
Py_ssize_t n;