[Python-checkins] CVS: python/dist/src/Lib/test test_funcattrs.py,1.10,1.11

Guido van Rossum gvanrossum@users.sourceforge.net
Sun, 21 Oct 2001 19:00:11 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv1010/Lib/test

Modified Files:
	test_funcattrs.py 
Log Message:
Fix for SF bug #472940: can't getattr() attribute shown by dir()

There really isn't a good reason for instance method objects to have
their own __dict__, __doc__ and __name__ properties that just delegate
the request to the function (callable); the default attribute behavior
already does this.

The test suite had to be fixed because the error changes from
TypeError to AttributeError.



Index: test_funcattrs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_funcattrs.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** test_funcattrs.py	2001/09/18 03:55:22	1.10
--- test_funcattrs.py	2001/10/22 02:00:09	1.11
***************
*** 109,114 ****
  try:
      F.a.__dict__ = (1, 2, 3)
! except TypeError: pass
! else: raise TestFailed, 'expected TypeError'
  
  F.a.im_func.__dict__ = {'one': 11, 'two': 22, 'three': 33}
--- 109,114 ----
  try:
      F.a.__dict__ = (1, 2, 3)
! except (AttributeError, TypeError): pass
! else: raise TestFailed, 'expected TypeError or AttributeError'
  
  F.a.im_func.__dict__ = {'one': 11, 'two': 22, 'three': 33}
***************
*** 122,126 ****
  try:
      F.a.__dict__ = d
! except TypeError: pass
  else: raise TestFailed
  
--- 122,126 ----
  try:
      F.a.__dict__ = d
! except (AttributeError, TypeError): pass
  else: raise TestFailed
  
***************
*** 219,223 ****
      try:
          setattr(obj, name, value)
!     except TypeError:
          pass
      else:
--- 219,223 ----
      try:
          setattr(obj, name, value)
!     except (AttributeError, TypeError):
          pass
      else:
***************
*** 225,229 ****
      try:
          delattr(obj, name)
!     except TypeError:
          pass
      else:
--- 225,229 ----
      try:
          delattr(obj, name)
!     except (AttributeError, TypeError):
          pass
      else: