On Sep 2, 2014, at 11:45 PM, Wolfgang Rohdewald <wolfgang....@rohdewald.de> wrote:
> I still do not like "non-class class" because this is a contradiction > in itself. How about "non-class found in class slot when deserializing method object"? > Anyway a non-class class is a class whose objects may not get a > method attached. So far so good, but that was obvious. Uh... no? A non-class in an object which is not a class. The error is when that object is provided as the class associated with a method. > Am Dienstag, 2. September 2014, 16:29:41 schrieb Glyph Lefkowitz: >> Except I think it might be broken in the face of new-style classes; >> ClassType is the old-style class type, 'type' is the new one, so, >> that should probably be fixed > > That is my problem. How do I know if the object is of a non-class class? isinstance(something, (types.ClassType, type)). > As you say, current code does not handle new style classes. Yes, but it could be easily modified to do so. > I cannot check if the object is of type "type" because > int is also of type "type". An int certainly should not get > a method attached. Then we could just as well remove this check. >>> isinstance(object, type) True >>> isinstance(object(), type) False > That is why I proposed to instead exclude a list of basic types > int, float, list, dict, set and so on. I'm not sure I understand the proposal. But in any case - it's not necessary. It's clearly possible to determine if a particular value is a type or not. -glyph _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python