◐ Shell
reader mode source ↗
Skip to content
Merged
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
2 changes: 2 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ What's New in Python 3.7.0 alpha 1?
Core and Builtins
-----------------

- bpo-28856: Fix an oversight that %b format for bytes should support objects
follow the buffer protocol.

27 changes: 17 additions & 10 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -5024,7 +5024,7 @@ import_from(PyObject *v, PyObject *name)
{
PyObject *x;
_Py_IDENTIFIER(__name__);
PyObject *fullmodname, *pkgname, *pkgpath, *pkgname_or_unknown;

x = PyObject_GetAttr(v, name);
if (x != NULL || !PyErr_ExceptionMatches(PyExc_AttributeError))
Expand All @@ -5039,6 +5039,7 @@ import_from(PyObject *v, PyObject *name)
}
fullmodname = PyUnicode_FromFormat("%U.%U", pkgname, name);
if (fullmodname == NULL) {
return NULL;
}
x = PyDict_GetItem(PyImport_GetModuleDict(), fullmodname);
Expand All @@ -5063,17 +5064,23 @@ import_from(PyObject *v, PyObject *name)

if (pkgpath == NULL || !PyUnicode_Check(pkgpath)) {
PyErr_Clear();
PyErr_SetImportError(
PyUnicode_FromFormat("cannot import name %R from %R (unknown location)",
name, pkgname_or_unknown),
pkgname, NULL);
} else {
PyErr_SetImportError(
PyUnicode_FromFormat("cannot import name %R from %R (%S)",
name, pkgname_or_unknown, pkgpath),
pkgname, pkgpath);
}

Py_XDECREF(pkgname_or_unknown);
Py_XDECREF(pkgpath);
return NULL;
Expand Down
Toggle all file notes Toggle all file annotations