mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Patch #103344: Sort dicts from extcall for easier comparison with Jython.
This commit is contained in:
parent
9e9bcda547
commit
08dabf0a73
2 changed files with 49 additions and 41 deletions
|
|
@ -2,11 +2,19 @@ from test_support import verify, verbose, TestFailed
|
|||
from UserList import UserList
|
||||
import string
|
||||
|
||||
def sortdict(d):
|
||||
keys = d.keys()
|
||||
keys.sort()
|
||||
lst = []
|
||||
for k in keys:
|
||||
lst.append("%r: %r" % (k, d[k]))
|
||||
return "{%s}" % ", ".join(lst)
|
||||
|
||||
def f(*a, **k):
|
||||
print a, k
|
||||
print a, sortdict(k)
|
||||
|
||||
def g(x, *y, **z):
|
||||
print x, y, z
|
||||
print x, y, sortdict(z)
|
||||
|
||||
def h(j=1, a=2, h=3):
|
||||
print j, a, h
|
||||
|
|
@ -81,8 +89,8 @@ d = {'a': 1, 'b': 2, 'c': 3}
|
|||
d2 = d.copy()
|
||||
verify(d == d2)
|
||||
g(1, d=4, **d)
|
||||
print d
|
||||
print d2
|
||||
print sortdict(d)
|
||||
print sortdict(d2)
|
||||
verify(d == d2, "function call modified dictionary")
|
||||
|
||||
# what about willful misconduct?
|
||||
|
|
@ -199,6 +207,6 @@ for name in ['za', 'zade', 'zabk', 'zabdv', 'zabdevk']:
|
|||
for kwargs in ['', 'a', 'd', 'ad', 'abde']:
|
||||
kwdict = {}
|
||||
for k in kwargs: kwdict[k] = k + k
|
||||
print func.func_name, args, kwdict, '->',
|
||||
print func.func_name, args, sortdict(kwdict), '->',
|
||||
try: apply(func, args, kwdict)
|
||||
except TypeError, err: print err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue