1try:
2    '' % ()
3except TypeError:
4    print("SKIP")
5    raise SystemExit
6
7print("%%" % ())
8print("=%s=" % 1)
9print("=%s=%s=" % (1, 2))
10print("=%s=" % (1,))
11print("=%s=" % [1, 2])
12
13print("=%s=" % "str")
14print("=%r=" % "str")
15
16try:
17    print("=%s=%s=" % 1)
18except TypeError:
19    print("TypeError")
20
21try:
22    print("=%s=%s=%s=" % (1, 2))
23except TypeError:
24    print("TypeError")
25
26try:
27    print("=%s=" % (1, 2))
28except TypeError:
29    print("TypeError")
30
31print("%s" % True)
32print("%s" % 1)
33print("%.1s" % "ab")
34
35print("%r" % True)
36print("%r" % 1)
37
38print("%c" % 48)
39print("%c" % 'a')
40print("%10s" % 'abc')
41print("%-10s" % 'abc')
42
43print('%c' % False)
44print('%c' % True)
45
46# Should be able to print dicts; in this case they aren't used
47# to lookup keywords in formats like %(foo)s
48print('%s' % {})
49print('%s' % ({},))
50
51# Cases when "*" used and there's not enough values total
52try:
53    print("%*s" % 5)
54except TypeError:
55    print("TypeError")
56try:
57    print("%*.*s" % (1, 15))
58except TypeError:
59    print("TypeError")
60
61print("%(foo)s" % {"foo": "bar", "baz": False})
62print("%s %(foo)s %(foo)s" % {"foo": 1})
63try:
64    print("%(foo)s" % {})
65except KeyError:
66    print("KeyError")
67# Using in "*" with dict got to fail
68try:
69    print("%(foo)*s" % {"foo": "bar"})
70except TypeError:
71    print("TypeError")
72
73# When using %(foo)s format the single argument must be a dict
74try:
75    '%(foo)s' % 1
76except TypeError:
77    print('TypeError')
78try:
79    '%(foo)s' % ({},)
80except TypeError:
81    print('TypeError')
82
83try:
84    '%(a' % {'a':1}
85except ValueError:
86    print('ValueError')
87
88try:
89    '%.*d %.*d' % (20, 5)
90except TypeError:
91    print('TypeError')
92
93try:
94    a = '%*' % 1
95except (ValueError):
96    print('ValueError')
97
98try:
99    '%c' % 'aa'
100except TypeError:
101    print('TypeError')
102
103try:
104    '%l' % 1
105except ValueError:
106    print('ValueError')
107
108try:
109    'a%' % 1
110except ValueError:
111    print('ValueError')
112