2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-26 06:42:27 +00:00

Backport to Python 2.2

[SVN r15706]
This commit is contained in:
Dave Abrahams
2002-10-04 13:05:57 +00:00
parent 81ffe96c76
commit bd0175c167
2 changed files with 10 additions and 6 deletions

View File

@@ -330,7 +330,7 @@ namespace objects
// rest corresponding to its declared bases.
//
inline object
new_class(char const* name, std::size_t num_types, class_id const* const types)
new_class(char const* name, std::size_t num_types, class_id const* const types, char const* doc)
{
assert(num_types >= 1);
@@ -348,7 +348,12 @@ namespace objects
}
// Call the class metatype to create a new class
object result = object(class_metatype())(module_prefix() + name, bases, dict());
dict d;
if (doc != 0)
d["__doc__"] = doc;
object result = object(class_metatype())(module_prefix() + name, bases, d);
assert(PyType_IsSubtype(result.ptr()->ob_type, &PyType_Type));
if (scope().ptr() != Py_None)
@@ -360,7 +365,7 @@ namespace objects
class_base::class_base(
char const* name, std::size_t num_types, class_id const* const types, char const* doc)
: object(new_class(name, num_types, types))
: object(new_class(name, num_types, types, doc))
{
// Insert the new class object in the registry
converter::registration& converters = const_cast<converter::registration&>(
@@ -368,9 +373,6 @@ namespace objects
// Class object is leaked, for now
converters.class_object = (PyTypeObject*)incref(this->ptr());
if (doc)
this->attr("__doc__") = doc;
}
void class_base::set_instance_size(std::size_t instance_size)

View File

@@ -1,4 +1,6 @@
"""
>>> False = 0 # Python 2.2 needs these
>>> True = 1
>>> from defaults_ext import *
>>> bar(1)