[Python-checkins] CVS: python/dist/src/Lib/test test_b1.py,1.30,1.31 test_extcall.py,1.7,1.8

Fred L. Drake python-dev@python.org
Thu, 04 Jan 2001 14:33:04 -0800


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

Modified Files:
	test_b1.py test_extcall.py 
Log Message:

When a PyCFunction that takes only positional parameters is called with
an empty keywords dictionary (via apply() or the extended call syntax),
the keywords dict should be ignored.  If the keywords dict is not empty,
TypeError should be raised.  (Between the restructuring of the call
machinery and this patch, an empty dict in this situation would trigger
a SystemError via PyErr_BadInternalCall().)

Added regression tests to detect errors for this.


Index: test_b1.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b1.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** test_b1.py	2001/01/04 01:33:41	1.30
--- test_b1.py	2001/01/04 22:33:02	1.31
***************
*** 40,43 ****
--- 40,54 ----
  apply(f3, (1, 2, 3))
  
+ # A PyCFunction that takes only positional parameters should allow an
+ # empty keyword dictionary to pass without a complaint, but raise a
+ # TypeError if the dictionary is non-empty.
+ apply(id, (1,), {})
+ try:
+     apply(id, (1,), {"foo": 1})
+ except TypeError:
+     pass
+ else:
+     raise TestFailed, 'expected TypeError; no exception raised'
+ 
  print 'callable'
  if not callable(len):raise TestFailed, 'callable(len)'

Index: test_extcall.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_extcall.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** test_extcall.py	2000/10/30 17:15:20	1.7
--- test_extcall.py	2001/01/04 22:33:02	1.8
***************
*** 1,3 ****
--- 1,4 ----
  from UserList import UserList
+ from test_support import TestFailed
  
  def f(*a, **k):
***************
*** 162,164 ****
      print err
  
! 
--- 163,174 ----
      print err
  
! # A PyCFunction that takes only positional parameters should allow an
! # empty keyword dictionary to pass without a complaint, but raise a
! # TypeError if the dictionary is non-empty.
! id(1, **{})
! try:
!     id(1, **{"foo": 1})
! except TypeError:
!     pass
! else:
!     raise TestFailed, 'expected TypeError; no exception raised'