mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 04:22:16 +00:00
Set __qualname__ for Python >= 3.3
This commit is contained in:
committed by
Stefan Seefeld
parent
8ca8724ad9
commit
58b1a010bb
@@ -502,6 +502,16 @@ namespace objects
|
||||
);
|
||||
}
|
||||
|
||||
str qualname(const char *name)
|
||||
{
|
||||
#if PY_VERSION_HEX >= 0x03030000
|
||||
if (PyObject_HasAttrString(scope().ptr(), "__qualname__")) {
|
||||
return str("%s.%s" % make_tuple(scope().attr("__qualname__"), name));
|
||||
}
|
||||
#endif
|
||||
return str(name);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
// Find a registered class object corresponding to id. Return a
|
||||
@@ -564,6 +574,9 @@ namespace objects
|
||||
|
||||
object m = module_prefix();
|
||||
if (m) d["__module__"] = m;
|
||||
#if PY_VERSION_HEX >= 0x03030000
|
||||
d["__qualname__"] = qualname(name);
|
||||
#endif
|
||||
|
||||
if (doc != 0)
|
||||
d["__doc__"] = doc;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
'X'
|
||||
|
||||
>>> X.Y
|
||||
<class 'nested_ext.Y'>
|
||||
<class 'nested_ext.X.Y'>
|
||||
|
||||
>>> X.Y.__module__
|
||||
'nested_ext'
|
||||
|
||||
Reference in New Issue
Block a user