@@ -67,13 +67,8 @@ def b():
6767
6868# In Python 2.1 beta 1, we disallowed setting attributes on unbound methods
6969# (it was already disallowed on bound methods). See the PEP for details.
70- try :
71- F .a .publish = 1
72- except (AttributeError , TypeError ): pass
73- else : raise TestFailed ('expected AttributeError or TypeError' )
74-
75- # But setting it explicitly on the underlying function object is okay.
76- F .a .im_func .publish = 1
70+ # In Python 3.0 unbound methods are gone.
71+ F .a .publish = 1
7772
7873if F .a .publish != 1 :
7974 raise TestFailed ('unbound method attribute not set to expected value' )
@@ -92,30 +87,8 @@ def b():
9287except (AttributeError , TypeError ): pass
9388else : raise TestFailed ('expected AttributeError or TypeError' )
9489
95- # See the comment above about the change in semantics for Python 2.1b1
96- try :
97- F .a .myclass = F
98- except (AttributeError , TypeError ): pass
99- else : raise TestFailed ('expected AttributeError or TypeError' )
100-
101- F .a .im_func .myclass = F
102-
103- f1 .a .myclass
104- f2 .a .myclass
105- f1 .a .myclass
106- F .a .myclass
107-
108- if f1 .a .myclass is not f2 .a .myclass or \
109- f1 .a .myclass is not F .a .myclass :
110- raise TestFailed ('attributes were not the same' )
111-
11290# try setting __dict__
113- try :
114- F .a .__dict__ = (1 , 2 , 3 )
115- except (AttributeError , TypeError ): pass
116- else : raise TestFailed ('expected TypeError or AttributeError' )
117-
118- F .a .im_func .__dict__ = {'one' : 11 , 'two' : 22 , 'three' : 33 }
91+ F .a .__dict__ = {'one' : 11 , 'two' : 22 , 'three' : 33 }
11992
12093if f1 .a .two != 22 :
12194 raise TestFailed ('setting __dict__' )
@@ -315,54 +288,54 @@ def f(): pass
315288def test_im_class ():
316289 class C :
317290 def foo (self ): pass
318- verify (C .foo .im_class is C )
291+ # verify(C.foo.im_class is C)
319292 verify (C ().foo .im_class is C )
320- cantset (C .foo , "im_class" , C )
293+ # cantset(C.foo, "im_class", C)
321294 cantset (C ().foo , "im_class" , C )
322295
323296def test_im_func ():
324297 def foo (self ): pass
325298 class C :
326299 pass
327300 C .foo = foo
328- verify (C .foo .im_func is foo )
301+ # verify(C.foo.im_func is foo)
329302 verify (C ().foo .im_func is foo )
330- cantset (C .foo , "im_func" , foo )
303+ # cantset(C.foo, "im_func", foo)
331304 cantset (C ().foo , "im_func" , foo )
332305
333306def test_im_self ():
334307 class C :
335308 def foo (self ): pass
336- verify (C .foo .im_self is None )
309+ # verify(C.foo.im_self is None)
337310 c = C ()
338- verify (c .foo .im_self is c )
339- cantset (C .foo , "im_self" , None )
340- cantset (c .foo , "im_self" , c )
311+ # verify(c.foo.im_self is c)
312+ # cantset(C.foo, "im_self", None)
313+ # cantset(c.foo, "im_self", c)
341314
342315def test_im_dict ():
343316 class C :
344317 def foo (self ): pass
345318 foo .bar = 42
346319 verify (C .foo .__dict__ == {'bar' : 42 })
347320 verify (C ().foo .__dict__ == {'bar' : 42 })
348- cantset (C .foo , "__dict__" , C .foo .__dict__ )
349- cantset (C ().foo , "__dict__" , C .foo .__dict__ )
321+ # cantset(C.foo, "__dict__", C.foo.__dict__)
322+ # cantset(C().foo, "__dict__", C.foo.__dict__)
350323
351324def test_im_doc ():
352325 class C :
353326 def foo (self ): "hello"
354327 verify (C .foo .__doc__ == "hello" )
355328 verify (C ().foo .__doc__ == "hello" )
356- cantset (C .foo , "__doc__" , "hello" )
357- cantset (C ().foo , "__doc__" , "hello" )
329+ # cantset(C.foo, "__doc__", "hello")
330+ # cantset(C().foo, "__doc__", "hello")
358331
359332def test_im_name ():
360333 class C :
361334 def foo (self ): pass
362335 verify (C .foo .__name__ == "foo" )
363336 verify (C ().foo .__name__ == "foo" )
364- cantset (C .foo , "__name__" , "foo" )
365- cantset (C ().foo , "__name__" , "foo" )
337+ # cantset(C.foo, "__name__", "foo")
338+ # cantset(C().foo, "__name__", "foo")
366339
367340def testmore ():
368341 test_func_closure ()
0 commit comments