[pypy-svn] r18627 - in pypy/dist/pypy: interpreter objspace/std

adim at codespeak.net adim at codespeak.net
Sat Oct 15 15:13:57 CEST 2005


Author: adim
Date: Sat Oct 15 15:13:55 2005
New Revision: 18627

Modified:
   pypy/dist/pypy/interpreter/function.py
   pypy/dist/pypy/objspace/std/typeobject.py
Log:
(arre, adim)
- fixed some __slots__ uncaught errors (still doens't work completely)
- fixed bound/unbound messages 



Modified: pypy/dist/pypy/interpreter/function.py
==============================================================================
--- pypy/dist/pypy/interpreter/function.py	(original)
+++ pypy/dist/pypy/interpreter/function.py	Sat Oct 15 15:13:55 2005
@@ -267,10 +267,11 @@
             w_class = self.w_class
         typename = w_class.getname(self.space, '?')
         if self.w_instance is None:
-            s = "<method '%s' of '%s' objects>" %(name, typename)
+            s = "<unbound method %s.%s>" % (typename, name)
             return space.wrap(s)
         else:
-            info = "method %s of %s object" % (name, typename)
+            info = 'bound method %s.%s' % (typename, name)
+            # info = "method %s of %s object" % (name, typename)
             return self.w_instance.getrepr(self.space, info)
 
     def descr_method_getattribute(self, w_attr):

Modified: pypy/dist/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typeobject.py	(original)
+++ pypy/dist/pypy/objspace/std/typeobject.py	Sat Oct 15 15:13:55 2005
@@ -138,11 +138,26 @@
 
                 w_slots = dict_w['__slots__']
                 if space.is_true(space.isinstance(w_slots, space.w_str)):
+                    if space.int_w(space.len(w_slots)) == 0:
+                        raise OperationError(space.w_TypeError,
+                                             space.wrap('__slots__ must be identifiers'))
                     slot_names_w = [w_slots]
                 else:
                     slot_names_w = space.unpackiterable(w_slots)
                 for w_slot_name in slot_names_w:
                     slot_name = space.str_w(w_slot_name)
+                    # slot_name should be a valid identifier
+                    if len(slot_name) == 0:
+                        raise OperationError(space.w_TypeError,
+                                             space.wrap('__slots__ must be identifiers'))
+                    first_char = slot_name[0]
+                    if not first_char.isalpha() and first_char != '_':
+                        raise OperationError(space.w_TypeError,
+                                             space.wrap('__slots__ must be identifiers'))                        
+                    for c in slot_name:
+                        if not c.isalnum() and c!= '_':
+                            raise OperationError(space.w_TypeError,
+                                                 space.wrap('__slots__ must be identifiers'))
                     if slot_name == '__dict__':
                         if wantdict or w_self.hasdict:
                             raise OperationError(space.w_TypeError,



More information about the Pypy-commit mailing list