Package: python-stringtemplate3 / 3.1-4

python3-compat.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
Description: Add Python 3 compatibility
 This patch was produced using sixer and a bit of manual tweak.
Author: Thomas Goirand <zigo@debian.org>
Forwarded: no
Last-Update: 2018-02-17

--- python-stringtemplate3-3.1.orig/stringtemplate3/grouploaders.py
+++ python-stringtemplate3-3.1/stringtemplate3/grouploaders.py
@@ -109,7 +109,7 @@ class PathGroupLoader(StringTemplateGrou
             finally:
                 fr.close()
 
-        except IOError, ioe:
+        except IOError as ioe:
             self.error("can't load group "+groupName, ioe)
 
         return None
@@ -128,7 +128,7 @@ class PathGroupLoader(StringTemplateGrou
             finally:
                 fr.close()
                 
-        except (IOError, OSError), ioe:
+        except (IOError, OSError) as ioe:
             self.error("can't load interface "+interfaceName, ioe)
 
         return None
--- python-stringtemplate3-3.1.orig/stringtemplate3/groups.py
+++ python-stringtemplate3-3.1/stringtemplate3/groups.py
@@ -30,7 +30,6 @@ import sys
 import traceback
 import imp
 import time
-from StringIO import StringIO
 
 import antlr
 
@@ -50,6 +49,10 @@ from stringtemplate3.templates import (
 from stringtemplate3.writers import AutoIndentWriter
 from stringtemplate3.interfaces import StringTemplateGroupInterface
 
+import six
+from six import StringIO
+
+
 DEFAULT_EXTENSION = '.st'
 
 ## Used to indicate that the template doesn't exist.
@@ -174,13 +177,13 @@ class StringTemplateGroup(object):
         #  default: no refreshing from disk
         #
         self.refreshInterval = sys.maxint/1000
-        self.lastCheckedDisk = 0L
+        self.lastCheckedDisk = 0
         
         if name is not None:
-            assert isinstance(name, basestring)
+            assert isinstance(name, six.string_types)
             self.name = name
 
-            assert rootDir is None or isinstance(rootDir, basestring)
+            assert rootDir is None or isinstance(rootDir, six.string_types)
             self.rootDir = rootDir
             self.lastCheckedDisk = time.time()
             StringTemplateGroup.nameToGroupMap[self.name] = self
@@ -222,7 +225,7 @@ class StringTemplateGroup(object):
         return self.defaultTemplateLexerClass
 
     def setTemplateLexerClass(self, lexer):
-        if isinstance(lexer, basestring):
+        if isinstance(lexer, six.string_types):
             try:
                 self._templateLexerClass = {
                     'default': DefaultTemplateLexer.Lexer,
@@ -258,7 +261,7 @@ class StringTemplateGroup(object):
         if superGroup is None or isinstance(superGroup, StringTemplateGroup):
             self._superGroup = superGroup
             
-        elif isinstance(superGroup, basestring):
+        elif isinstance(superGroup, six.string_types):
             # Called by group parser when ": supergroupname" is found.
             # This method forces the supergroup's lexer to be same as lexer
             # for this (sub) group.
@@ -355,7 +358,7 @@ class StringTemplateGroup(object):
         ST encloses it for error messages.
         """
 
-        assert isinstance(name, basestring)
+        assert isinstance(name, six.string_types)
         assert enclosingInstance is None or isinstance(enclosingInstance, StringTemplate)
         assert attributes is None or isinstance(attributes, dict)
 
@@ -371,7 +374,7 @@ class StringTemplateGroup(object):
         return None
 
     def getEmbeddedInstanceOf(self, name, enclosingInstance):
-        assert isinstance(name, basestring)
+        assert isinstance(name, six.string_types)
         assert enclosingInstance is None or isinstance(enclosingInstance, StringTemplate)
 
         st = None
@@ -402,7 +405,7 @@ class StringTemplateGroup(object):
     #
     #  If I find a template in a super group, copy an instance down here
     def lookupTemplate(self, name, enclosingInstance=None):
-        assert isinstance(name, basestring)
+        assert isinstance(name, six.string_types)
         assert enclosingInstance is None or isinstance(enclosingInstance, StringTemplate)
 
         if name.startswith('super.'):
@@ -467,7 +470,7 @@ class StringTemplateGroup(object):
 
 
     def loadTemplate(self, name, src):
-        if isinstance(src, basestring):
+        if isinstance(src, six.string_types):
             template = None
             try:
                 br = open(src, 'r')
@@ -477,7 +480,7 @@ class StringTemplateGroup(object):
                     br.close()
 
             # FIXME: eek, that's ugly
-            except Exception, e:
+            except Exception as e:
                 raise
             
             return template
@@ -519,13 +522,13 @@ class StringTemplateGroup(object):
             try:
                 try:
                     template = self.loadTemplate(name, br)
-                except IOError, ioe:
+                except IOError as ioe:
                     self.error("Problem reading template file: "+fileName, ioe)
 
             finally:
                 try:
                     br.close()
-                except IOError, ioe2:
+                except IOError as ioe2:
                     self.error('Cannot close template file: ' + pathName, ioe2)
 
             return template
@@ -642,7 +645,7 @@ class StringTemplateGroup(object):
     ## Get the ST for 'name' in this group only
     #
     def getTemplateDefinition(self, name):
-        if self.templates.has_key(name):
+        if name in self.templates:
             return self.templates[name]
 
     ## Is there *any* definition for template 'name' in this template
@@ -725,7 +728,7 @@ class StringTemplateGroup(object):
         if self.userSpecifiedWriter:
             try:
                 stw = self.userSpecifiedWriter(w)
-            except RuntimeError, e: #FIXME Exception, e:
+            except RuntimeError as e: #FIXME Exception, e:
                 self.error('problems getting StringTemplateWriter', e)
 
         if not stw:
@@ -757,7 +760,7 @@ class StringTemplateGroup(object):
             # no renderers; consult super group
             return self.superGroup.getAttributeRenderer(attributeClassType)
 
-        if self.attributeRenderers.has_key(attributeClassType):
+        if attributeClassType in self.attributeRenderers:
             return self.attributeRenderers[attributeClassType]
 
         elif self.superGroup is not None:
@@ -772,7 +775,7 @@ class StringTemplateGroup(object):
                 return None
             return self.superGroup.getMap(name)
         m = None
-        if self.maps.has_key(name):
+        if name in self.maps:
             m = self.maps[name]
         if (not m) and self.superGroup:
             m = self.superGroup.getMap(name)
--- python-stringtemplate3-3.1.orig/stringtemplate3/interfaces.py
+++ python-stringtemplate3-3.1/stringtemplate3/interfaces.py
@@ -26,7 +26,6 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 
-from StringIO import StringIO
 
 from stringtemplate3.language import (
     InterfaceLexer, InterfaceParser
@@ -36,6 +35,9 @@ from stringtemplate3.utils import deprec
 from stringtemplate3.errors import DEFAULT_ERROR_LISTENER
 
 
+from six import StringIO
+
+
 class TemplateDefinition(object):
     """All the info we need to track for a template defined in an interface"""
 
@@ -93,7 +95,7 @@ class StringTemplateGroupInterface(objec
             parser = InterfaceParser.Parser(lexer)
             parser.groupInterface(self)
 
-        except RuntimeError, exc: #FIXME:  Exception
+        except RuntimeError as exc: #FIXME:  Exception
             name = self.name or "<unknown>"
             self.error("problem parsing group "+name+": "+str(exc), exc)
 
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/ASTExpr.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/ASTExpr.py
@@ -1,7 +1,7 @@
 
-from StringIO import StringIO
 import antlr
 
+from six import StringIO
 from stringtemplate3.utils import deprecated
 from stringtemplate3.language.Expr import Expr
 from stringtemplate3.language import ActionEvaluator
@@ -10,6 +10,9 @@ from stringtemplate3.language.CatIterato
 from stringtemplate3.language.FormalArgument import UNKNOWN_ARGS
 import stringtemplate3
 
+import six
+
+
 class IllegalStateException(Exception):
 
     def __init__(self, *args):
@@ -17,7 +20,7 @@ class IllegalStateException(Exception):
 
 
 def isiterable(o):
-    if isinstance(o, (basestring, stringtemplate3.StringTemplate)):
+    if isinstance(o, (six.string_types, stringtemplate3.StringTemplate)):
         # don't consider strings and templates as iterables
         return False
     
@@ -161,7 +164,7 @@ class ASTExpr(Expr):
         try:
             # eval and write out tree
             n = evaluator.action(self.exprTree)
-        except antlr.RecognitionException, re:
+        except antlr.RecognitionException as re:
             this.error('can\'t evaluate tree: ' + self.exprTree.toStringList(),
                        re)
         out.popIndentation()
@@ -411,7 +414,7 @@ class ASTExpr(Expr):
         elif isinstance(o, stringtemplate3.StringTemplate):
             attributes = o.attributes
             if attributes:
-                if attributes.has_key(propertyName): # prevent KeyError...
+                if propertyName in attributes: # prevent KeyError...
                     value = attributes[propertyName]
                 else:
                     value = None
@@ -427,17 +430,17 @@ class ASTExpr(Expr):
                 methodName = 'is' + methodSuffix
                 try:
                     m = getattr(o, methodName)
-                except AttributeError, ae:
+                except AttributeError as ae:
                     # try for a visible field
                     try:
                         try:
                             return getattr(o, propertyName)
-                        except AttributeError, ae2:
+                        except AttributeError as ae2:
                             this.error('Can\'t get property ' + propertyName +
                                        ' using method get/is' + methodSuffix +
                                        ' or direct field access from ' +
                                        o.__class__.__name__ + ' instance', ae2)
-                    except AttributeError, ae:
+                    except AttributeError as ae:
                         this.error('Class ' + o.__class__.__name__ +
                                    ' has no such attribute: ' + propertyName +
                                    ' in template context ' +
@@ -446,7 +449,7 @@ class ASTExpr(Expr):
             if m is not None:
                 try:
                     value = m()
-                except Exception, e:
+                except Exception as e:
                     this.error('Can\'t get property ' + propertyName +
                                ' using method get/is' + methodSuffix +
                                ' or direct field access from ' +
@@ -489,7 +492,7 @@ class ASTExpr(Expr):
         elif b is None:
             return a
 
-        return unicode(a) + unicode(b)
+        return six.text_type(a) + six.text_type(b)
     
     ## Call a string template with args and return result.  Do not convert
     #  to a string yet.  It may need attributes that will be available after
@@ -602,7 +605,7 @@ class ASTExpr(Expr):
                 if renderer is not None:
                     v = renderer.toString(o, self.formatString)
                 else:
-                    v = unicode(o)
+                    v = six.text_type(o)
 
                 if self.wrapString is not None:
                     n = out.write(v, self.wrapString)
@@ -611,7 +614,7 @@ class ASTExpr(Expr):
                     
                 return n
             
-        except IOError, io:
+        except IOError as io:
             this.error('problem writing object: ' + o, io)
         return n
 
@@ -638,7 +641,7 @@ class ASTExpr(Expr):
             try:
                 evaluator.action(expr) # eval tree
 
-            except antlr.RecognitionException, re:
+            except antlr.RecognitionException as re:
                 this.error(
                     "can't evaluate tree: "+self.exprTree.toStringList(), re
                     )
@@ -688,7 +691,7 @@ class ASTExpr(Expr):
             ac = eval_.argList(argumentsAST, this, this.argumentContext)
             this.argumentContext = ac
 
-        except antlr.RecognitionException, re:
+        except antlr.RecognitionException as re:
             this.error('can\'t evaluate tree: ' + argumentsAST.toStringList(),
                        re)
 
@@ -749,7 +752,7 @@ class ASTExpr(Expr):
         if attribute is None:
             yield None
 
-        elif isinstance(attribute, basestring):
+        elif isinstance(attribute, six.string_types):
             # don't iterate over string
             yield attribute
 
@@ -787,7 +790,7 @@ class ASTExpr(Expr):
         if isinstance(attribute, (dict, list)):
             i = len(attribute)
 
-        elif isinstance(attribute, basestring):
+        elif isinstance(attribute, six.string_types):
             # treat strings as atoms
             i = 1
 
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/ActionEvaluator.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/ActionEvaluator.py
@@ -9,11 +9,10 @@ if version < '2.2.1':
 if version < '2.3':
     True = not False
 ### header action >>> 
+from six import StringIO
 from stringtemplate3.language.CatIterator import CatList
 from stringtemplate3.language.StringTemplateAST import StringTemplateAST
 
-from StringIO import StringIO
-
 class NameValuePair(object):
 
    def __init__(self):
@@ -109,7 +108,7 @@ class Walker(antlr.TreeParser):
             _t = self._retTree
             numCharsWritten = self.chunk.writeAttribute(self.this, e, self.out)
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -184,7 +183,7 @@ class Walker(antlr.TreeParser):
                     raise antlr.NoViableAltException(_t)
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -275,7 +274,7 @@ class Walker(antlr.TreeParser):
                     raise antlr.NoViableAltException(_t)
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -376,7 +375,7 @@ class Walker(antlr.TreeParser):
                     raise antlr.NoViableAltException(_t)
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -440,7 +439,7 @@ class Walker(antlr.TreeParser):
             if name:
                value = self.chunk.getTemplateInclude(self.this, name, args)
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -520,7 +519,7 @@ class Walker(antlr.TreeParser):
             _t = _t21
             _t = _t.getNextSibling()
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -582,7 +581,7 @@ class Walker(antlr.TreeParser):
                     raise antlr.NoViableAltException(_t)
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -673,7 +672,7 @@ class Walker(antlr.TreeParser):
             _t = _t26
             _t = _t.getNextSibling()
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -697,7 +696,7 @@ class Walker(antlr.TreeParser):
             _t = _t24
             _t = _t.getNextSibling()
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -738,7 +737,7 @@ class Walker(antlr.TreeParser):
                     raise antlr.NoViableAltException(_t)
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -757,7 +756,7 @@ class Walker(antlr.TreeParser):
             value=self.expr(_t)
             _t = self._retTree
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -814,7 +813,7 @@ class Walker(antlr.TreeParser):
                     raise antlr.NoViableAltException(_t)
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -863,7 +862,7 @@ class Walker(antlr.TreeParser):
                     raise antlr.NoViableAltException(_t)
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -913,7 +912,7 @@ class Walker(antlr.TreeParser):
                self.this.rawSetArgumentAttribute(embedded, \
                    argumentContext, soleArgName, e)
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             if _t:
                 _t = _t.getNextSibling()
@@ -972,6 +971,6 @@ _tokenNames = [
 ### generate bit set
 def mk_tokenSet_0(): 
     ### var1
-    data = [ 60180949680L, 0L]
+    data = [ 60180949680, 0]
     return data
 _tokenSet_0 = antlr.BitSet(mk_tokenSet_0())
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/ActionLexer.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/ActionLexer.py
@@ -176,10 +176,10 @@ class Lexer(antlr.CharScanner) :
                             ### return token to caller
                             return self._returnToken
                         ### handle lexical errors ....
-                        except antlr.RecognitionException, e:
+                        except antlr.RecognitionException as e:
                             raise antlr.TokenStreamRecognitionException(e)
                     ### handle char stream errors ...
-                    except antlr.CharStreamException,cse:
+                    except antlr.CharStreamException as cse:
                         if isinstance(cse, antlr.CharStreamIOException):
                             raise antlr.TokenStreamIOException(cse.io)
                         else:
@@ -351,7 +351,7 @@ class Lexer(antlr.CharScanner) :
             try:
                 pass
                 self.mTEMPLATE_ARGS(False)
-            except antlr.RecognitionException, pe:
+            except antlr.RecognitionException as pe:
                 synPredMatched70 = False
             self.rewind(_m70)
             self.inputState.guessing -= 1
@@ -736,61 +736,61 @@ class Lexer(antlr.CharScanner) :
 
 ### generate bit set
 def mk_tokenSet_0(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-17179869192L
-    data[1] =-268435457L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-17179869192
+    data[1] =-268435457
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_0 = antlr.BitSet(mk_tokenSet_0())
 
 ### generate bit set
 def mk_tokenSet_1(): 
-    data = [0L] * 1025 ### init list
-    data[0] =4294977024L
-    data[1] =576460745995190270L
+    data = [0] * 1025 ### init list
+    data[0] =4294977024
+    data[1] =576460745995190270
     return data
 _tokenSet_1 = antlr.BitSet(mk_tokenSet_1())
 
 ### generate bit set
 def mk_tokenSet_2(): 
-    data = [0L] * 1025 ### init list
-    data[0] =288107235144377856L
-    data[1] =1729382250602037246L
+    data = [0] * 1025 ### init list
+    data[0] =288107235144377856
+    data[1] =1729382250602037246
     return data
 _tokenSet_2 = antlr.BitSet(mk_tokenSet_2())
 
 ### generate bit set
 def mk_tokenSet_3(): 
-    data = [0L] * 1025 ### init list
-    data[0] =4294977024L
+    data = [0] * 1025 ### init list
+    data[0] =4294977024
     return data
 _tokenSet_3 = antlr.BitSet(mk_tokenSet_3())
 
 ### generate bit set
 def mk_tokenSet_4(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-8L
-    data[1] =-2882303761785552897L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-8
+    data[1] =-2882303761785552897
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_4 = antlr.BitSet(mk_tokenSet_4())
 
 ### generate bit set
 def mk_tokenSet_5(): 
-    data = [0L] * 1025 ### init list
-    data[0] =17596481021440L
+    data = [0] * 1025 ### init list
+    data[0] =17596481021440
     return data
 _tokenSet_5 = antlr.BitSet(mk_tokenSet_5())
 
 ### generate bit set
 def mk_tokenSet_6(): 
-    data = [0L] * 1025 ### init list
-    data[0] =17596481021440L
-    data[1] =576460745995190270L
+    data = [0] * 1025 ### init list
+    data[0] =17596481021440
+    data[1] =576460745995190270
     return data
 _tokenSet_6 = antlr.BitSet(mk_tokenSet_6())
     
@@ -803,8 +803,8 @@ if __name__ == '__main__' :
     ### create lexer - shall read from stdin
     try:
         for token in ActionLexer.Lexer():
-            print token
+            print(token)
             
-    except antlr.TokenStreamException, e:
-        print "error: exception caught while lexing: ", e
+    except antlr.TokenStreamException as e:
+        print("error: exception caught while lexing")
 ### __main__ header action <<< 
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/ActionParser.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/ActionParser.py
@@ -143,7 +143,7 @@ class Parser(antlr.LLkParser):
                     raise antlr.NoViableAltException(self.LT(1), self.getFilename())
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -170,7 +170,7 @@ class Parser(antlr.LLkParser):
                 try:
                     pass
                     self.parallelArrayTemplateApplication()
-                except antlr.RecognitionException, pe:
+                except antlr.RecognitionException as pe:
                     synPredMatched10 = False
                 self.rewind(_m10)
                 self.inputState.guessing -= 1
@@ -211,7 +211,7 @@ class Parser(antlr.LLkParser):
                 raise antlr.NoViableAltException(self.LT(1), self.getFilename())
             
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -241,7 +241,7 @@ class Parser(antlr.LLkParser):
                     break
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -279,7 +279,7 @@ class Parser(antlr.LLkParser):
                     raise antlr.NoViableAltException(self.LT(1), self.getFilename())
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -330,7 +330,7 @@ class Parser(antlr.LLkParser):
                 opts[i_AST.getText()] = v
             option_AST = currentAST.root
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -363,7 +363,7 @@ class Parser(antlr.LLkParser):
                 
             expr_AST = currentAST.root
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -415,7 +415,7 @@ class Parser(antlr.LLkParser):
                 currentAST.advanceChildToEnd()
             parallelArrayTemplateApplication_AST = currentAST.root
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -457,7 +457,7 @@ class Parser(antlr.LLkParser):
                 currentAST.advanceChildToEnd()
             template_AST = currentAST.root
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -489,7 +489,7 @@ class Parser(antlr.LLkParser):
                 t_AST.setStringTemplate(anonymous)
             anonymousTemplate_AST = currentAST.root
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -510,7 +510,7 @@ class Parser(antlr.LLkParser):
             self.addASTChild(currentAST, self.returnAST)
             ifAtom_AST = currentAST.root
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -577,7 +577,7 @@ class Parser(antlr.LLkParser):
                     try:
                         pass
                         self.templateInclude()
-                    except antlr.RecognitionException, pe:
+                    except antlr.RecognitionException as pe:
                         synPredMatched25 = False
                     self.rewind(_m25)
                     self.inputState.guessing -= 1
@@ -626,7 +626,7 @@ class Parser(antlr.LLkParser):
                     raise antlr.NoViableAltException(self.LT(1), self.getFilename())
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -688,7 +688,7 @@ class Parser(antlr.LLkParser):
                 currentAST.advanceChildToEnd()
             templateInclude_AST = currentAST.root
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -739,7 +739,7 @@ class Parser(antlr.LLkParser):
                     raise antlr.NoViableAltException(self.LT(1), self.getFilename())
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -770,7 +770,7 @@ class Parser(antlr.LLkParser):
                 eval_AST.setText("value")
             valueExpr_AST = currentAST.root
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -842,7 +842,7 @@ class Parser(antlr.LLkParser):
                 currentAST.advanceChildToEnd()
             function_AST = currentAST.root
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -882,7 +882,7 @@ class Parser(antlr.LLkParser):
             self.match(RBRACK)
             list__AST = currentAST.root
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -919,7 +919,7 @@ class Parser(antlr.LLkParser):
                 
             nonAlternatingTemplateExpr_AST = currentAST.root
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -951,7 +951,7 @@ class Parser(antlr.LLkParser):
                 currentAST.advanceChildToEnd()
             singleArg_AST = currentAST.root
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -1003,7 +1003,7 @@ class Parser(antlr.LLkParser):
                     raise antlr.NoViableAltException(self.LT(1), self.getFilename())
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -1041,7 +1041,7 @@ class Parser(antlr.LLkParser):
                     try:
                         pass
                         self.singleArg()
-                    except antlr.RecognitionException, pe:
+                    except antlr.RecognitionException as pe:
                         synPredMatched52 = False
                     self.rewind(_m52)
                     self.inputState.guessing -= 1
@@ -1079,7 +1079,7 @@ class Parser(antlr.LLkParser):
                     raise antlr.NoViableAltException(self.LT(1), self.getFilename())
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -1120,7 +1120,7 @@ class Parser(antlr.LLkParser):
                     currentAST.child = indirectTemplate_AST
                 currentAST.advanceChildToEnd()
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -1157,7 +1157,7 @@ class Parser(antlr.LLkParser):
                 raise antlr.NoViableAltException(self.LT(1), self.getFilename())
             
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -1200,7 +1200,7 @@ class Parser(antlr.LLkParser):
                     raise antlr.NoViableAltException(self.LT(1), self.getFilename())
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             if not self.inputState.guessing:
                 self.reportError(ex)
                 self.consume()
@@ -1265,140 +1265,140 @@ _tokenNames = [
 ### generate bit set
 def mk_tokenSet_0(): 
     ### var1
-    data = [ 2L, 0L]
+    data = [ 2, 0]
     return data
 _tokenSet_0 = antlr.BitSet(mk_tokenSet_0())
 
 ### generate bit set
 def mk_tokenSet_1(): 
     ### var1
-    data = [ 137390260224L, 0L]
+    data = [ 137390260224, 0]
     return data
 _tokenSet_1 = antlr.BitSet(mk_tokenSet_1())
 
 ### generate bit set
 def mk_tokenSet_2(): 
     ### var1
-    data = [ 274867093504L, 0L]
+    data = [ 274867093504, 0]
     return data
 _tokenSet_2 = antlr.BitSet(mk_tokenSet_2())
 
 ### generate bit set
 def mk_tokenSet_3(): 
     ### var1
-    data = [ 137394094082L, 0L]
+    data = [ 137394094082, 0]
     return data
 _tokenSet_3 = antlr.BitSet(mk_tokenSet_3())
 
 ### generate bit set
 def mk_tokenSet_4(): 
     ### var1
-    data = [ 274867126274L, 0L]
+    data = [ 274867126274, 0]
     return data
 _tokenSet_4 = antlr.BitSet(mk_tokenSet_4())
 
 ### generate bit set
 def mk_tokenSet_5(): 
     ### var1
-    data = [ 163842L, 0L]
+    data = [ 163842, 0]
     return data
 _tokenSet_5 = antlr.BitSet(mk_tokenSet_5())
 
 ### generate bit set
 def mk_tokenSet_6(): 
     ### var1
-    data = [ 131072L, 0L]
+    data = [ 131072, 0]
     return data
 _tokenSet_6 = antlr.BitSet(mk_tokenSet_6())
 
 ### generate bit set
 def mk_tokenSet_7(): 
     ### var1
-    data = [ 524290L, 0L]
+    data = [ 524290, 0]
     return data
 _tokenSet_7 = antlr.BitSet(mk_tokenSet_7())
 
 ### generate bit set
 def mk_tokenSet_8(): 
     ### var1
-    data = [ 137443835906L, 0L]
+    data = [ 137443835906, 0]
     return data
 _tokenSet_8 = antlr.BitSet(mk_tokenSet_8())
 
 ### generate bit set
 def mk_tokenSet_9(): 
     ### var1
-    data = [ 4882434L, 0L]
+    data = [ 4882434, 0]
     return data
 _tokenSet_9 = antlr.BitSet(mk_tokenSet_9())
 
 ### generate bit set
 def mk_tokenSet_10(): 
     ### var1
-    data = [ 137428140032L, 0L]
+    data = [ 137428140032, 0]
     return data
 _tokenSet_10 = antlr.BitSet(mk_tokenSet_10())
 
 ### generate bit set
 def mk_tokenSet_11(): 
     ### var1
-    data = [ 60130590720L, 0L]
+    data = [ 60130590720, 0]
     return data
 _tokenSet_11 = antlr.BitSet(mk_tokenSet_11())
 
 ### generate bit set
 def mk_tokenSet_12(): 
     ### var1
-    data = [ 137494167554L, 0L]
+    data = [ 137494167554, 0]
     return data
 _tokenSet_12 = antlr.BitSet(mk_tokenSet_12())
 
 ### generate bit set
 def mk_tokenSet_13(): 
     ### var1
-    data = [ 137394585600L, 0L]
+    data = [ 137394585600, 0]
     return data
 _tokenSet_13 = antlr.BitSet(mk_tokenSet_13())
 
 ### generate bit set
 def mk_tokenSet_14(): 
     ### var1
-    data = [ 137460613122L, 0L]
+    data = [ 137460613122, 0]
     return data
 _tokenSet_14 = antlr.BitSet(mk_tokenSet_14())
 
 ### generate bit set
 def mk_tokenSet_15(): 
     ### var1
-    data = [ 655360L, 0L]
+    data = [ 655360, 0]
     return data
 _tokenSet_15 = antlr.BitSet(mk_tokenSet_15())
 
 ### generate bit set
 def mk_tokenSet_16(): 
     ### var1
-    data = [ 137394061312L, 0L]
+    data = [ 137394061312, 0]
     return data
 _tokenSet_16 = antlr.BitSet(mk_tokenSet_16())
 
 ### generate bit set
 def mk_tokenSet_17(): 
     ### var1
-    data = [ 274829213696L, 0L]
+    data = [ 274829213696, 0]
     return data
 _tokenSet_17 = antlr.BitSet(mk_tokenSet_17())
 
 ### generate bit set
 def mk_tokenSet_18(): 
     ### var1
-    data = [ 274833571842L, 0L]
+    data = [ 274833571842, 0]
     return data
 _tokenSet_18 = antlr.BitSet(mk_tokenSet_18())
 
 ### generate bit set
 def mk_tokenSet_19(): 
     ### var1
-    data = [ 137439477760L, 0L]
+    data = [ 137439477760, 0]
     return data
 _tokenSet_19 = antlr.BitSet(mk_tokenSet_19())
     
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/AngleBracketTemplateLexer.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/AngleBracketTemplateLexer.py
@@ -9,6 +9,7 @@ if version < '2.2.1':
 if version < '2.3':
     True = not False
 ### header action >>> 
+import six
 import stringtemplate3
 import stringtemplate3.language.TemplateParser
 from stringtemplate3.language.ChunkToken import ChunkToken
@@ -135,10 +136,10 @@ class Lexer(antlr.CharScanner) :
                             ### return token to caller
                             return self._returnToken
                         ### handle lexical errors ....
-                        except antlr.RecognitionException, e:
+                        except antlr.RecognitionException as e:
                             raise antlr.TokenStreamRecognitionException(e)
                     ### handle char stream errors ...
-                    except antlr.CharStreamException,cse:
+                    except antlr.CharStreamException as cse:
                         if isinstance(cse, antlr.CharStreamIOException):
                             raise antlr.TokenStreamIOException(cse.io)
                         else:
@@ -591,7 +592,7 @@ class Lexer(antlr.CharScanner) :
             self.mHEX(True)
             self.text.setLength(_saveIndex)
             d = self._returnToken
-            uc = unichr(int(a.getText()+b.getText()+c.getText()+d.getText(), 16))
+            uc = six.unichr(int(a.getText()+b.getText()+c.getText()+d.getText(), 16))
         else:
             self.raise_NoViableAlt(self.LA(1))
         
@@ -973,133 +974,133 @@ class Lexer(antlr.CharScanner) :
 
 ### generate bit set
 def mk_tokenSet_0(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-1152921504606856194L
-    for x in xrange(1, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-1152921504606856194
+    for x in range(1, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_0 = antlr.BitSet(mk_tokenSet_0())
 
 ### generate bit set
 def mk_tokenSet_1(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-5764607523034234882L
-    for x in xrange(1, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-5764607523034234882
+    for x in range(1, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_1 = antlr.BitSet(mk_tokenSet_1())
 
 ### generate bit set
 def mk_tokenSet_2(): 
-    data = [0L] * 1025 ### init list
-    data[0] =4294967296L
-    data[1] =14707067533131776L
+    data = [0] * 1025 ### init list
+    data[0] =4294967296
+    data[1] =14707067533131776
     return data
 _tokenSet_2 = antlr.BitSet(mk_tokenSet_2())
 
 ### generate bit set
 def mk_tokenSet_3(): 
-    data = [0L] * 1025 ### init list
-    data[0] =4899634919602388992L
-    data[1] =541434314878L
+    data = [0] * 1025 ### init list
+    data[0] =4899634919602388992
+    data[1] =541434314878
     return data
 _tokenSet_3 = antlr.BitSet(mk_tokenSet_3())
 
 ### generate bit set
 def mk_tokenSet_4(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-4611686018427387906L
-    for x in xrange(1, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-4611686018427387906
+    for x in range(1, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_4 = antlr.BitSet(mk_tokenSet_4())
 
 ### generate bit set
 def mk_tokenSet_5(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-2199023255554L
-    for x in xrange(1, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-2199023255554
+    for x in range(1, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_5 = antlr.BitSet(mk_tokenSet_5())
 
 ### generate bit set
 def mk_tokenSet_6(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-4611687117939015682L
-    for x in xrange(1, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-4611687117939015682
+    for x in range(1, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_6 = antlr.BitSet(mk_tokenSet_6())
 
 ### generate bit set
 def mk_tokenSet_7(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-3298534892546L
-    data[1] =-576460752571858945L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-3298534892546
+    data[1] =-576460752571858945
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_7 = antlr.BitSet(mk_tokenSet_7())
 
 ### generate bit set
 def mk_tokenSet_8(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-1152921521786716162L
-    data[1] =-576460752303423489L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-1152921521786716162
+    data[1] =-576460752303423489
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_8 = antlr.BitSet(mk_tokenSet_8())
 
 ### generate bit set
 def mk_tokenSet_9(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-6917537823734113282L
-    data[1] =-576460752571858945L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-6917537823734113282
+    data[1] =-576460752571858945
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_9 = antlr.BitSet(mk_tokenSet_9())
 
 ### generate bit set
 def mk_tokenSet_10(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-2L
-    data[1] =-2882303761785552897L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-2
+    data[1] =-2882303761785552897
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_10 = antlr.BitSet(mk_tokenSet_10())
 
 ### generate bit set
 def mk_tokenSet_11(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-17179869186L
-    data[1] =-268435457L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-17179869186
+    data[1] =-268435457
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_11 = antlr.BitSet(mk_tokenSet_11())
 
 ### generate bit set
 def mk_tokenSet_12(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-3298534883330L
-    data[1] =-268435457L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-3298534883330
+    data[1] =-268435457
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_12 = antlr.BitSet(mk_tokenSet_12())
     
@@ -1112,8 +1113,8 @@ if __name__ == '__main__' :
     ### create lexer - shall read from stdin
     try:
         for token in AngleBracketTemplateLexer.Lexer():
-            print token
+            print(token)
             
-    except antlr.TokenStreamException, e:
-        print "error: exception caught while lexing: ", e
+    except antlr.TokenStreamException as e:
+        print("error: exception caught while lexing")
 ### __main__ header action <<< 
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/CatIterator.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/CatIterator.py
@@ -1,5 +1,6 @@
+from six import StringIO
+
 
-from StringIO import StringIO
 
 ## Given a list of lists, return the combined elements one by one.
 #
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/ConditionalExpr.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/ConditionalExpr.py
@@ -71,7 +71,7 @@ class ConditionalExpr(ASTExpr):
             # with a False value.
             try:
                 includeSubtemplate = evaluator.ifCondition(cond)
-            except KeyError, ke:
+            except KeyError as ke:
                 includeSubtemplate = False
 
             if includeSubtemplate:
@@ -83,7 +83,7 @@ class ConditionalExpr(ASTExpr):
                 for elseIfClause in self.elseIfSubtemplates:
                     try:
                         includeSubtemplate = evaluator.ifCondition(elseIfClause.expr.exprTree)
-                    except KeyError, ke:
+                    except KeyError as ke:
                         includeSubtemplate = False
                     if includeSubtemplate:
                         n = self.writeSubTemplate(this, out, elseIfClause.st)
@@ -95,7 +95,7 @@ class ConditionalExpr(ASTExpr):
                 # failed
                 n = self.writeSubTemplate(this, out, self.elseSubtemplate)
                         
-        except antlr.RecognitionException, re:
+        except antlr.RecognitionException as re:
             this.error(
                 "can't evaluate tree: " + self.exprTree.toStringList(), re
                 )
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/DefaultTemplateLexer.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/DefaultTemplateLexer.py
@@ -9,6 +9,7 @@ if version < '2.2.1':
 if version < '2.3':
     True = not False
 ### header action >>> 
+import six
 import stringtemplate3
 from stringtemplate3.language.ChunkToken import ChunkToken
 from stringtemplate3.language.StringRef import StringRef
@@ -136,10 +137,10 @@ class Lexer(antlr.CharScanner) :
                             ### return token to caller
                             return self._returnToken
                         ### handle lexical errors ....
-                        except antlr.RecognitionException, e:
+                        except antlr.RecognitionException as e:
                             raise antlr.TokenStreamRecognitionException(e)
                     ### handle char stream errors ...
-                    except antlr.CharStreamException,cse:
+                    except antlr.CharStreamException as cse:
                         if isinstance(cse, antlr.CharStreamIOException):
                             raise antlr.TokenStreamIOException(cse.io)
                         else:
@@ -641,7 +642,7 @@ class Lexer(antlr.CharScanner) :
             self.mHEX(True)
             self.text.setLength(_saveIndex)
             d = self._returnToken
-            uc = unichr(int(a.getText()+b.getText()+c.getText()+d.getText(), 16))
+            uc = six.unichr(int(a.getText()+b.getText()+c.getText()+d.getText(), 16))
         else:
             self.raise_NoViableAlt(self.LA(1))
         
@@ -1002,123 +1003,123 @@ class Lexer(antlr.CharScanner) :
 
 ### generate bit set
 def mk_tokenSet_0(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-68719485954L
-    for x in xrange(1, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-68719485954
+    for x in range(1, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_0 = antlr.BitSet(mk_tokenSet_0())
 
 ### generate bit set
 def mk_tokenSet_1(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-68719476738L
-    for x in xrange(1, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-68719476738
+    for x in range(1, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_1 = antlr.BitSet(mk_tokenSet_1())
 
 ### generate bit set
 def mk_tokenSet_2(): 
-    data = [0L] * 1025 ### init list
-    data[0] =4294967296L
-    data[1] =14707067533131776L
+    data = [0] * 1025 ### init list
+    data[0] =4294967296
+    data[1] =14707067533131776
     return data
 _tokenSet_2 = antlr.BitSet(mk_tokenSet_2())
 
 ### generate bit set
 def mk_tokenSet_3(): 
-    data = [0L] * 1025 ### init list
-    data[0] =287948969894477824L
-    data[1] =541434314878L
+    data = [0] * 1025 ### init list
+    data[0] =287948969894477824
+    data[1] =541434314878
     return data
 _tokenSet_3 = antlr.BitSet(mk_tokenSet_3())
 
 ### generate bit set
 def mk_tokenSet_4(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-2199023255554L
-    for x in xrange(1, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-2199023255554
+    for x in range(1, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_4 = antlr.BitSet(mk_tokenSet_4())
 
 ### generate bit set
 def mk_tokenSet_5(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-1168231104514L
-    for x in xrange(1, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-1168231104514
+    for x in range(1, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_5 = antlr.BitSet(mk_tokenSet_5())
 
 ### generate bit set
 def mk_tokenSet_6(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-3298534892546L
-    data[1] =-576460752571858945L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-3298534892546
+    data[1] =-576460752571858945
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_6 = antlr.BitSet(mk_tokenSet_6())
 
 ### generate bit set
 def mk_tokenSet_7(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-1152921521786716162L
-    data[1] =-576460752303423489L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-1152921521786716162
+    data[1] =-576460752303423489
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_7 = antlr.BitSet(mk_tokenSet_7())
 
 ### generate bit set
 def mk_tokenSet_8(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-2305851874026202114L
-    data[1] =-576460752571858945L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-2305851874026202114
+    data[1] =-576460752571858945
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_8 = antlr.BitSet(mk_tokenSet_8())
 
 ### generate bit set
 def mk_tokenSet_9(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-2L
-    data[1] =-2882303761785552897L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-2
+    data[1] =-2882303761785552897
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_9 = antlr.BitSet(mk_tokenSet_9())
 
 ### generate bit set
 def mk_tokenSet_10(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-17179869186L
-    data[1] =-268435457L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-17179869186
+    data[1] =-268435457
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_10 = antlr.BitSet(mk_tokenSet_10())
 
 ### generate bit set
 def mk_tokenSet_11(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-3298534883330L
-    data[1] =-268435457L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-3298534883330
+    data[1] =-268435457
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_11 = antlr.BitSet(mk_tokenSet_11())
     
@@ -1131,8 +1132,8 @@ if __name__ == '__main__' :
     ### create lexer - shall read from stdin
     try:
         for token in DefaultTemplateLexer.Lexer():
-            print token
+            print(token)
             
-    except antlr.TokenStreamException, e:
-        print "error: exception caught while lexing: ", e
+    except antlr.TokenStreamException as e:
+        print("error: exception caught while lexing")
 ### __main__ header action <<< 
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/GroupLexer.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/GroupLexer.py
@@ -172,10 +172,10 @@ class Lexer(antlr.CharScanner) :
                             ### return token to caller
                             return self._returnToken
                         ### handle lexical errors ....
-                        except antlr.RecognitionException, e:
+                        except antlr.RecognitionException as e:
                             raise antlr.TokenStreamRecognitionException(e)
                     ### handle char stream errors ...
-                    except antlr.CharStreamException,cse:
+                    except antlr.CharStreamException as cse:
                         if isinstance(cse, antlr.CharStreamIOException):
                             raise antlr.TokenStreamIOException(cse.io)
                         else:
@@ -627,32 +627,32 @@ class Lexer(antlr.CharScanner) :
 
 ### generate bit set
 def mk_tokenSet_0(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-17179869185L
-    for x in xrange(1, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-17179869185
+    for x in range(1, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_0 = antlr.BitSet(mk_tokenSet_0())
 
 ### generate bit set
 def mk_tokenSet_1(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-17179869185L
-    data[1] =-268435457L
-    for x in xrange(2, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-17179869185
+    data[1] =-268435457
+    for x in range(2, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_1 = antlr.BitSet(mk_tokenSet_1())
 
 ### generate bit set
 def mk_tokenSet_2(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-9217L
-    for x in xrange(1, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-9217
+    for x in range(1, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_2 = antlr.BitSet(mk_tokenSet_2())
     
@@ -665,8 +665,8 @@ if __name__ == '__main__' :
     ### create lexer - shall read from stdin
     try:
         for token in GroupLexer.Lexer():
-            print token
+            print(token)
             
-    except antlr.TokenStreamException, e:
-        print "error: exception caught while lexing: ", e
+    except antlr.TokenStreamException as e:
+        print("error: exception caught while lexing")
 ### __main__ header action <<< 
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/GroupParser.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/GroupParser.py
@@ -157,7 +157,7 @@ class Parser(antlr.LLkParser):
                 
             self.match(EOF_TYPE)
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_0)
@@ -282,7 +282,7 @@ class Parser(antlr.LLkParser):
                 raise antlr.NoViableAltException(self.LT(1), self.getFilename())
             
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_1)
@@ -307,7 +307,7 @@ class Parser(antlr.LLkParser):
             else:
                g.defineMap(name.getText(), m)
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_1)
@@ -329,7 +329,7 @@ class Parser(antlr.LLkParser):
                     break
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_2)
@@ -379,7 +379,7 @@ class Parser(antlr.LLkParser):
             
             st.defineFormalArgument(name.getText(), defaultValue)
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_3)
@@ -394,7 +394,7 @@ class Parser(antlr.LLkParser):
             self.mapPairs(mapping)
             self.match(RBRACK)
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_1)
@@ -439,7 +439,7 @@ class Parser(antlr.LLkParser):
                     raise antlr.NoViableAltException(self.LT(1), self.getFilename())
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_4)
@@ -458,7 +458,7 @@ class Parser(antlr.LLkParser):
             v=self.keyValue()
             mapping[key.getText()] = v
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_5)
@@ -475,7 +475,7 @@ class Parser(antlr.LLkParser):
             v=self.keyValue()
             mapping[stringtemplate3.language.ASTExpr.DEFAULT_MAP_VALUE_NAME] = v
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_4)
@@ -519,7 +519,7 @@ class Parser(antlr.LLkParser):
                     raise antlr.NoViableAltException(self.LT(1), self.getFilename())
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_5)
@@ -563,42 +563,42 @@ _tokenNames = [
 ### generate bit set
 def mk_tokenSet_0(): 
     ### var1
-    data = [ 2L, 0L]
+    data = [ 2, 0]
     return data
 _tokenSet_0 = antlr.BitSet(mk_tokenSet_0())
 
 ### generate bit set
 def mk_tokenSet_1(): 
     ### var1
-    data = [ 1058L, 0L]
+    data = [ 1058, 0]
     return data
 _tokenSet_1 = antlr.BitSet(mk_tokenSet_1())
 
 ### generate bit set
 def mk_tokenSet_2(): 
     ### var1
-    data = [ 8192L, 0L]
+    data = [ 8192, 0]
     return data
 _tokenSet_2 = antlr.BitSet(mk_tokenSet_2())
 
 ### generate bit set
 def mk_tokenSet_3(): 
     ### var1
-    data = [ 8448L, 0L]
+    data = [ 8448, 0]
     return data
 _tokenSet_3 = antlr.BitSet(mk_tokenSet_3())
 
 ### generate bit set
 def mk_tokenSet_4(): 
     ### var1
-    data = [ 1048576L, 0L]
+    data = [ 1048576, 0]
     return data
 _tokenSet_4 = antlr.BitSet(mk_tokenSet_4())
 
 ### generate bit set
 def mk_tokenSet_5(): 
     ### var1
-    data = [ 1048832L, 0L]
+    data = [ 1048832, 0]
     return data
 _tokenSet_5 = antlr.BitSet(mk_tokenSet_5())
     
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/InterfaceLexer.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/InterfaceLexer.py
@@ -141,10 +141,10 @@ class Lexer(antlr.CharScanner) :
                             ### return token to caller
                             return self._returnToken
                         ### handle lexical errors ....
-                        except antlr.RecognitionException, e:
+                        except antlr.RecognitionException as e:
                             raise antlr.TokenStreamRecognitionException(e)
                     ### handle char stream errors ...
-                    except antlr.CharStreamException,cse:
+                    except antlr.CharStreamException as cse:
                         if isinstance(cse, antlr.CharStreamIOException):
                             raise antlr.TokenStreamIOException(cse.io)
                         else:
@@ -370,11 +370,11 @@ class Lexer(antlr.CharScanner) :
 
 ### generate bit set
 def mk_tokenSet_0(): 
-    data = [0L] * 2048 ### init list
-    data[0] =-9217L
-    for x in xrange(1, 1023):
-        data[x] = -1L
-    data[1023] =9223372036854775807L
+    data = [0] * 2048 ### init list
+    data[0] =-9217
+    for x in range(1, 1023):
+        data[x] = -1
+    data[1023] =9223372036854775807
     return data
 _tokenSet_0 = antlr.BitSet(mk_tokenSet_0())
     
@@ -387,8 +387,8 @@ if __name__ == '__main__' :
     ### create lexer - shall read from stdin
     try:
         for token in InterfaceLexer.Lexer():
-            print token
+            print(token)
             
-    except antlr.TokenStreamException, e:
-        print "error: exception caught while lexing: ", e
+    except antlr.TokenStreamException as e:
+        print("error: exception caught while lexing")
 ### __main__ header action <<< 
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/InterfaceParser.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/InterfaceParser.py
@@ -118,7 +118,7 @@ class Parser(antlr.LLkParser):
             if _cnt3 < 1:
                 raise antlr.NoViableAltException(self.LT(1), self.getFilename())
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_0)
@@ -165,7 +165,7 @@ class Parser(antlr.LLkParser):
             templateName = name.getText()
             groupI.defineTemplate(templateName, formalArgs, opt != None)
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_1)
@@ -192,7 +192,7 @@ class Parser(antlr.LLkParser):
                     break
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_2)
@@ -222,21 +222,21 @@ _tokenNames = [
 ### generate bit set
 def mk_tokenSet_0(): 
     ### var1
-    data = [ 2L, 0L]
+    data = [ 2, 0]
     return data
 _tokenSet_0 = antlr.BitSet(mk_tokenSet_0())
 
 ### generate bit set
 def mk_tokenSet_1(): 
     ### var1
-    data = [ 162L, 0L]
+    data = [ 162, 0]
     return data
 _tokenSet_1 = antlr.BitSet(mk_tokenSet_1())
 
 ### generate bit set
 def mk_tokenSet_2(): 
     ### var1
-    data = [ 512L, 0L]
+    data = [ 512, 0]
     return data
 _tokenSet_2 = antlr.BitSet(mk_tokenSet_2())
     
--- python-stringtemplate3-3.1.orig/stringtemplate3/language/TemplateParser.py
+++ python-stringtemplate3-3.1/stringtemplate3/language/TemplateParser.py
@@ -100,7 +100,7 @@ class Parser(antlr.LLkParser):
                         break
                     
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_0)
@@ -240,7 +240,7 @@ class Parser(antlr.LLkParser):
                     raise antlr.NoViableAltException(self.LT(1), self.getFilename())
                 
         
-        except antlr.RecognitionException, ex:
+        except antlr.RecognitionException as ex:
             self.reportError(ex)
             self.consume()
             self.consumeUntil(_tokenSet_1)
@@ -278,14 +278,14 @@ _tokenNames = [
 ### generate bit set
 def mk_tokenSet_0(): 
     ### var1
-    data = [ 1792L, 0L]
+    data = [ 1792, 0]
     return data
 _tokenSet_0 = antlr.BitSet(mk_tokenSet_0())
 
 ### generate bit set
 def mk_tokenSet_1(): 
     ### var1
-    data = [ 8176L, 0L]
+    data = [ 8176, 0]
     return data
 _tokenSet_1 = antlr.BitSet(mk_tokenSet_1())
     
--- python-stringtemplate3-3.1.orig/stringtemplate3/templates.py
+++ python-stringtemplate3-3.1/stringtemplate3/templates.py
@@ -28,7 +28,6 @@
 
 import sys
 import traceback
-from StringIO import StringIO
 from copy import copy
 
 
@@ -127,7 +126,7 @@ class Aggregate(object):
         # Instead of relying on data hiding, we check the type of the
         # master of this aggregate.
         if isinstance(self.master, StringTemplate):
-            if self.properties.has_key(propName):
+            if propName in self.properties:
                 return self.properties[propName]
             return None
         raise AttributeError
@@ -136,7 +135,7 @@ class Aggregate(object):
         # Instead of relying on data hiding, we check the type of the
         # master of this aggregate.
         if isinstance(self.master, StringTemplate):
-            return self.properties.has_key(propName)
+            return propName in self.properties
         raise AttributeError
 
 
@@ -334,7 +333,7 @@ class StringTemplate(object):
         self.regions = set()
 
         if template is not None:
-            assert isinstance(template, basestring)
+            assert isinstance(template, six.string_types)
             self.template = template
 
         if attributes is not None:
@@ -765,14 +764,14 @@ class StringTemplate(object):
 
         # is it here?
         o = None
-        if this.attributes and this.attributes.has_key(attribute):
+        if this.attributes and attribute in this.attributes:
             o = this.attributes[attribute]
             return o
 
         # nope, check argument context in case embedded
         if not o:
             argContext = this.argumentContext
-            if argContext and argContext.has_key(attribute):
+            if argContext and attribute in argContext:
                 o = argContext[attribute]
                 return o
 
@@ -830,7 +829,7 @@ class StringTemplate(object):
             chunkStream.setTokenObjectClass(ChunkToken)
             chunkifier = TemplateParser.Parser(chunkStream)
             chunkifier.template(self)
-        except Exception, e:
+        except Exception as e:
             name = "<unknown>"
             outerName = self.getOutermostName()
             if self.name:
@@ -855,9 +854,9 @@ class StringTemplate(object):
                 else:
                     a = ASTExpr(self, tree, options)
 
-        except antlr.RecognitionException, re:
+        except antlr.RecognitionException as re:
             self.error('Can\'t parse chunk: ' + str(action), re)
-        except antlr.TokenStreamException, tse:
+        except antlr.TokenStreamException as tse:
             self.error('Can\'t parse chunk: ' + str(action), tse)
 
         return a
@@ -958,7 +957,7 @@ class StringTemplate(object):
         return self.formalArguments[name]
 
     def hasFormalArgument(self, name):
-        return self.formalArguments.has_key(name)
+        return name in self.formalArguments
 
     def defineEmptyFormalArgumentList(self):
         self.formalArgumentKeys = []
@@ -967,7 +966,7 @@ class StringTemplate(object):
     def defineFormalArgument(self, names, defaultValue = None):
         if not names:
             return
-        if isinstance(names, basestring):
+        if isinstance(names, six.string_types):
             name = names
             if defaultValue:
                 self.numberOfDefaultArgumentValues += 1
@@ -1324,7 +1323,7 @@ class StringTemplate(object):
         edges = {}
         self.getDependencyGraph(edges, showAttributes)
         # for each source template
-        for src, targetNodes in edges.iteritems():
+        for src, targetNodes in six.iteritems(edges):
             # for each target template
             for trg in targetNodes:
                 graphST.setAttribute("edges.{src,trg}", src, trg)
@@ -1352,7 +1351,7 @@ class StringTemplate(object):
         
         srcNode = self.getTemplateHeaderString(showAttributes)
         if self.attributes is not None:
-            for name, value in self.attributes.iteritems():
+            for name, value in six.iteritems(self.attributes):
                 if isinstance(value, StringTemplate):
                     targetNode = value.getTemplateHeaderString(showAttributes)
                     self.putToMultiValuedMap(edges, srcNode, targetNode)
@@ -1443,7 +1442,7 @@ class StringTemplate(object):
         wr.lineWidth = lineWidth
         try:
             self.write(wr)
-        except IOError, io:
+        except IOError as io:
             self.error("Got IOError writing to writer" + \
                        str(wr.__class__.__name__))
             
@@ -1459,6 +1458,11 @@ class StringTemplate(object):
 
 # initialize here, because of cyclic imports
 from stringtemplate3.groups import StringTemplateGroup
+
+import six
+from six import StringIO
+
+
 StringTemplateGroup.NOT_FOUND_ST = StringTemplate()
 ASTExpr.MAP_KEY_VALUE = StringTemplate()
 
--- python-stringtemplate3-3.1.orig/stringtemplate3/writers.py
+++ python-stringtemplate3-3.1/stringtemplate3/writers.py
@@ -29,6 +29,9 @@
 from stringtemplate3.utils import deprecated
 
 
+import six
+
+
 class AttributeRenderer(object):
     """
     This interface describes an object that knows how to format or otherwise
@@ -197,7 +200,7 @@ class AutoIndentWriter(StringTemplateWri
         before spitting out this str.
         """
 
-        assert isinstance(text, basestring), repr(text)
+        assert isinstance(text, six.string_types), repr(text)
         
         n = 0
         if wrap is not None: