Commit c2b6a32a authored by Kevin Modzelewski's avatar Kevin Modzelewski

fix up typeRepr handling

parent a1e85219
...@@ -352,6 +352,8 @@ BoxedClass::BoxedClass(BoxedClass* metaclass, BoxedClass* base, gcvisit_func gc_ ...@@ -352,6 +352,8 @@ BoxedClass::BoxedClass(BoxedClass* metaclass, BoxedClass* base, gcvisit_func gc_
memset(&tp_name, 0, (char*)(&tp_version_tag + 1) - (char*)(&tp_name)); memset(&tp_name, 0, (char*)(&tp_version_tag + 1) - (char*)(&tp_name));
tp_basicsize = instance_size; tp_basicsize = instance_size;
tp_flags |= Py_TPFLAGS_HEAPTYPE;
if (metaclass == NULL) { if (metaclass == NULL) {
assert(type_cls == NULL); assert(type_cls == NULL);
} else { } else {
......
...@@ -607,13 +607,14 @@ extern "C" int PySlice_GetIndicesEx(PySliceObject* r, Py_ssize_t length, Py_ssiz ...@@ -607,13 +607,14 @@ extern "C" int PySlice_GetIndicesEx(PySliceObject* r, Py_ssize_t length, Py_ssiz
} }
Box* typeRepr(BoxedClass* self) { Box* typeRepr(BoxedClass* self) {
if (isUserDefined(self)) {
std::ostringstream os; std::ostringstream os;
if ((self->tp_flags & Py_TPFLAGS_HEAPTYPE) && isUserDefined(self))
os << "<class '"; os << "<class '";
else
os << "<type '";
Box* m = self->getattr("__module__"); Box* m = self->getattr("__module__");
RELEASE_ASSERT(m, ""); if (m && m->cls == str_cls) {
if (m->cls == str_cls) {
BoxedString* sm = static_cast<BoxedString*>(m); BoxedString* sm = static_cast<BoxedString*>(m);
os << sm->s << '.'; os << sm->s << '.';
} }
...@@ -627,11 +628,6 @@ Box* typeRepr(BoxedClass* self) { ...@@ -627,11 +628,6 @@ Box* typeRepr(BoxedClass* self) {
os << "'>"; os << "'>";
return boxString(os.str()); return boxString(os.str());
} else {
char buf[80];
snprintf(buf, 80, "<type '%s'>", getNameOfClass(self)->c_str());
return boxStrConstant(buf);
}
} }
Box* typeHash(BoxedClass* self) { Box* typeHash(BoxedClass* self) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment