summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.3.569
blob: 435733feea07222b7f439b2ecd92a94cbf79a672 (plain) (blame)
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
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
To: vim_dev@googlegroups.com
Subject: Patch 7.3.569
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.569
Problem:    Evaluating Vim expression in Python is insufficient.
Solution:   Add vim.bindeval().  Also add pyeval() and py3eval(). (ZyX)
Files:	    runtime/doc/eval.txt, runtime/doc/if_pyth.txt, src/eval.c,
	    src/if_lua.c, src/if_py_both.h, src/if_python.c, src/if_python3.c,
	    src/proto/eval.pro, src/proto/if_python.pro,
	    src/proto/if_python3.pro, src/testdir/Make_amiga.mak,
	    src/testdir/Make_dos.mak, src/testdir/Make_ming.mak,
	    src/testdir/Make_os2.mak, src/testdir/Makefile,
	    src/testdir/test86.in, src/testdir/test86.ok,
	    src/testdir/test87.in, src/testdir/test87.ok


*** ../vim-7.3.568/runtime/doc/eval.txt	2012-03-07 19:16:49.000000000 +0100
--- runtime/doc/eval.txt	2012-06-20 18:01:02.000000000 +0200
***************
*** 1836,1844 ****
  localtime()			Number	current time
  log( {expr})			Float	natural logarithm (base e) of {expr}
  log10( {expr})			Float	logarithm of Float {expr} to base 10
  map( {expr}, {string})		List/Dict  change each item in {expr} to {expr}
  maparg( {name}[, {mode} [, {abbr} [, {dict}]]])
! 				String	rhs of mapping {name} in mode {mode}
  mapcheck( {name}[, {mode} [, {abbr}]])
  				String	check for mappings matching {name}
  match( {expr}, {pat}[, {start}[, {count}]])
--- 1847,1857 ----
  localtime()			Number	current time
  log( {expr})			Float	natural logarithm (base e) of {expr}
  log10( {expr})			Float	logarithm of Float {expr} to base 10
+ luaeval( {expr}[, {expr}])	any	evaluate |Lua| expression
  map( {expr}, {string})		List/Dict  change each item in {expr} to {expr}
  maparg( {name}[, {mode} [, {abbr} [, {dict}]]])
! 				String or Dict
! 					rhs of mapping {name} in mode {mode}
  mapcheck( {name}[, {mode} [, {abbr}]])
  				String	check for mappings matching {name}
  match( {expr}, {pat}[, {start}[, {count}]])
***************
*** 1867,1872 ****
--- 1880,1887 ----
  prevnonblank( {lnum})		Number	line nr of non-blank line <= {lnum}
  printf( {fmt}, {expr1}...)	String	format text
  pumvisible()			Number	whether popup menu is visible
+ pyeval( {expr})			any	evaluate |Python| expression
+ py3eval( {expr})		any	evaluate |python3| expression
  range( {expr} [, {max} [, {stride}]])
  				List	items from {expr} to {max}
  readfile( {fname} [, {binary} [, {max}]])
***************
*** 3980,3985 ****
--- 4003,4022 ----
  <			-2.0
  		{only available when compiled with the |+float| feature}
  		
+ luaeval({expr}[, {expr}])					*luaeval()*
+ 		Evaluate Lua expression {expr} and return its result converted 
+ 		to Vim data structures. Second {expr} may hold additional 
+ 		argument accessible as _A inside first {expr}.
+ 		Strings are returned as they are.
+ 		Boolean objects are converted to numbers.
+ 		Numbers are converted to |Float| values if vim was compiled 
+ 		with |+float| and to numbers otherwise.
+ 		Dictionaries and lists obtained by vim.eval() are returned 
+ 		as-is.
+ 		Other objects are returned as zero without any errors.
+ 		See |lua-luaeval| for more details.
+ 		{only available when compiled with the |+lua| feature}
+ 
  map({expr}, {string})					*map()*
  		{expr} must be a |List| or a |Dictionary|.
  		Replace each item in {expr} with the result of evaluating
***************
*** 4574,4579 ****
--- 4612,4640 ----
  		This can be used to avoid some things that would remove the
  		popup menu.
  
+ 							*E860* *E861*
+ py3eval({expr})						*py3eval()*
+ 		Evaluate Python expression {expr} and return its result
+ 		converted to Vim data structures.
+ 		Numbers and strings are returned as they are (strings are 
+ 		copied though, unicode strings are additionally converted to 
+ 		'encoding').
+ 		Lists are represented as Vim |List| type.
+ 		Dictionaries are represented as Vim |Dictionary| type with 
+ 		keys converted to strings.
+ 		{only available when compiled with the |+python3| feature}
+ 
+ 							*E858* *E859*
+ pyeval({expr})						*pyeval()*
+ 		Evaluate Python expression {expr} and return its result
+ 		converted to Vim data structures.
+ 		Numbers and strings are returned as they are (strings are 
+ 		copied though).
+ 		Lists are represented as Vim |List| type.
+ 		Dictionaries are represented as Vim |Dictionary| type with 
+ 		keys converted to strings.
+ 		{only available when compiled with the |+python| feature}
+ 
  							*E726* *E727*
  range({expr} [, {max} [, {stride}]])				*range()*
  		Returns a |List| with Numbers:
***************
*** 4807,4812 ****
--- 4868,4877 ----
  		Search for regexp pattern {pattern}.  The search starts at the
  		cursor position (you can use |cursor()| to set it).
  
+ 		If there is no match a 0 is returned and the cursor doesn't
+ 		move.  No error message is given.
+ 		When a match has been found its line number is returned.
+ 
  		{flags} is a String, which can contain these character flags:
  		'b'	search backward instead of forward
  		'c'	accept a match at the cursor position
*** ../vim-7.3.568/runtime/doc/if_pyth.txt	2010-08-15 21:57:12.000000000 +0200
--- runtime/doc/if_pyth.txt	2012-06-20 18:01:02.000000000 +0200
***************
*** 1,4 ****
! *if_pyth.txt*   For Vim version 7.3.  Last change: 2010 Aug 13
  
  
  		  VIM REFERENCE MANUAL    by Paul Moore
--- 1,4 ----
! *if_pyth.txt*   For Vim version 7.3.  Last change: 2012 Feb 04
  
  
  		  VIM REFERENCE MANUAL    by Paul Moore
***************
*** 6,18 ****
  
  The Python Interface to Vim				*python* *Python*
  
! 1. Commands			|python-commands|
! 2. The vim module		|python-vim|
! 3. Buffer objects		|python-buffer|
! 4. Range objects		|python-range|
! 5. Window objects		|python-window|
! 6. Dynamic loading		|python-dynamic|
! 7. Python 3			|python3|
  
  {Vi does not have any of these commands}
  
--- 6,19 ----
  
  The Python Interface to Vim				*python* *Python*
  
! 1. Commands					|python-commands|
! 2. The vim module				|python-vim|
! 3. Buffer objects				|python-buffer|
! 4. Range objects				|python-range|
! 5. Window objects				|python-window|
! 6. pyeval(), py3eval() Vim functions		|python-pyeval|
! 7. Dynamic loading				|python-dynamic|
! 8. Python 3					|python3|
  
  {Vi does not have any of these commands}
  
***************
*** 150,155 ****
--- 151,172 ----
  	[{'cmd': '/^eval_expr(arg, nextcmd)$/', 'static': 0, 'name':
  	'eval_expr', 'kind': 'f', 'filename': './src/eval.c'}]
  
+ vim.bindeval(str)					*python-bindeval*
+ 	Like |python-eval|, but
+ 	1. if expression evaluates to |List| or |Dictionary| it is returned as 
+ 	   vimlist or vimdictionary python type that are connected to original 
+ 	   list or dictionary. Thus modifications to these objects imply 
+ 	   modifications of the original.
+ 	2. if expression evaluates to a function reference, then it returns 
+ 	   callable vimfunction object. Use self keyword argument to assign 
+ 	   |self| object for dictionary functions.
+ 
+ 	Note: this function has the same behavior as |lua-eval| (except that 
+ 	      lua does not support running vim functions), |python-eval| is 
+ 	      kept for backwards compatibility in order not to make scripts 
+ 	      relying on outputs of vim.eval() being a copy of original or 
+ 	      vim.eval("1") returning a string.
+ 
  
  
  Error object of the "vim" module
***************
*** 222,229 ****
  	- from indexing vim.buffers (|python-buffers|)
  	- from the "buffer" attribute of a window (|python-window|)
  
! Buffer objects have one read-only attribute - name - the full file name for
! the buffer.  They also have three methods (append, mark, and range; see below).
  
  You can also treat buffer objects as sequence objects.  In this context, they
  act as if they were lists (yes, they are mutable) of strings, with each
--- 239,247 ----
  	- from indexing vim.buffers (|python-buffers|)
  	- from the "buffer" attribute of a window (|python-window|)
  
! Buffer objects have two read-only attributes - name - the full file name for
! the buffer, and number - the buffer number.  They also have three methods
! (append, mark, and range; see below).
  
  You can also treat buffer objects as sequence objects.  In this context, they
  act as if they were lists (yes, they are mutable) of strings, with each
***************
*** 318,324 ****
  The width attribute is writable only if the screen is split vertically.
  
  ==============================================================================
! 6. Dynamic loading					*python-dynamic*
  
  On MS-Windows the Python library can be loaded dynamically.  The |:version|
  output then includes |+python/dyn|.
--- 336,348 ----
  The width attribute is writable only if the screen is split vertically.
  
  ==============================================================================
! 6. pyeval() and py3eval() Vim functions			*python-pyeval*
! 
! To facilitate bi-directional interface, you can use |pyeval()| and |py3eval()| 
! functions to evaluate Python expressions and pass their values to VimL.
! 
! ==============================================================================
! 7. Dynamic loading					*python-dynamic*
  
  On MS-Windows the Python library can be loaded dynamically.  The |:version|
  output then includes |+python/dyn|.
***************
*** 335,347 ****
  sure edit "gvim.exe" and search for "python\d*.dll\c".
  
  ==============================================================================
! 7. Python 3						*python3*
  
  							*:py3* *:python3*
  The |:py3| and |:python3| commands work similar to |:python|.
  							*:py3file*
  The |:py3file| command works similar to |:pyfile|.
  
  Vim can be built in four ways (:version output):
  1. No Python support	    (-python, -python3)
  2. Python 2 support only    (+python or +python/dyn, -python3)
--- 359,372 ----
  sure edit "gvim.exe" and search for "python\d*.dll\c".
  
  ==============================================================================
! 8. Python 3						*python3*
  
  							*:py3* *:python3*
  The |:py3| and |:python3| commands work similar to |:python|.
  							*:py3file*
  The |:py3file| command works similar to |:pyfile|.
  
+ 
  Vim can be built in four ways (:version output):
  1. No Python support	    (-python, -python3)
  2. Python 2 support only    (+python or +python/dyn, -python3)
***************
*** 355,361 ****
  When doing this on Linux/Unix systems and importing global symbols, this leads
  to a crash when the second Python version is used.  So either global symbols
  are loaded but only one Python version is activated, or no global symbols are
! loaded. The latter makes Python's "import" fail on libaries that expect the
  symbols to be provided by Vim.
  							*E836* *E837*
  Vim's configuration script makes a guess for all libraries based on one
--- 380,386 ----
  When doing this on Linux/Unix systems and importing global symbols, this leads
  to a crash when the second Python version is used.  So either global symbols
  are loaded but only one Python version is activated, or no global symbols are
! loaded. The latter makes Python's "import" fail on libraries that expect the
  symbols to be provided by Vim.
  							*E836* *E837*
  Vim's configuration script makes a guess for all libraries based on one
***************
*** 377,382 ****
--- 402,419 ----
  3. You undefine PY_NO_RTLD_GLOBAL in auto/config.h after configuration.  This
     may crash Vim though.
  
+ 							*has-python*
+ You can test what Python version is available with: >
+ 	if has('python')
+ 	  echo 'there is Python 2.x'
+   	elseif has('python3')
+ 	  echo 'there is Python 3.x'
+ 	endif
+ 
+ Note however, that when Python 2 and 3 are both available and loaded
+ dynamically, these has() calls will try to load them.  If only one can be
+ loaded at a time, just checking if Python 2 or 3 are available will prevent
+ the other one from being available.
  
  ==============================================================================
   vim:tw=78:ts=8:ft=help:norl:
*** ../vim-7.3.568/src/eval.c	2012-06-20 14:13:02.000000000 +0200
--- src/eval.c	2012-06-20 18:29:15.000000000 +0200
***************
*** 424,453 ****
  static int get_lit_string_tv __ARGS((char_u **arg, typval_T *rettv, int evaluate));
  static int get_list_tv __ARGS((char_u **arg, typval_T *rettv, int evaluate));
  static int rettv_list_alloc __ARGS((typval_T *rettv));
- static listitem_T *listitem_alloc __ARGS((void));
  static void listitem_free __ARGS((listitem_T *item));
- static void listitem_remove __ARGS((list_T *l, listitem_T *item));
  static long list_len __ARGS((list_T *l));
  static int list_equal __ARGS((list_T *l1, list_T *l2, int ic, int recursive));
  static int dict_equal __ARGS((dict_T *d1, dict_T *d2, int ic, int recursive));
  static int tv_equal __ARGS((typval_T *tv1, typval_T *tv2, int ic, int recursive));
- static listitem_T *list_find __ARGS((list_T *l, long n));
  static long list_find_nr __ARGS((list_T *l, long idx, int *errorp));
  static long list_idx_of_item __ARGS((list_T *l, listitem_T *item));
- static void list_append __ARGS((list_T *l, listitem_T *item));
  static int list_append_number __ARGS((list_T *l, varnumber_T n));
- static int list_insert_tv __ARGS((list_T *l, typval_T *tv, listitem_T *item));
  static int list_extend __ARGS((list_T	*l1, list_T *l2, listitem_T *bef));
  static int list_concat __ARGS((list_T *l1, list_T *l2, typval_T *tv));
  static list_T *list_copy __ARGS((list_T *orig, int deep, int copyID));
- static void list_remove __ARGS((list_T *l, listitem_T *item, listitem_T *item2));
  static char_u *list2string __ARGS((typval_T *tv, int copyID));
  static int list_join_inner __ARGS((garray_T *gap, list_T *l, char_u *sep, int echo_style, int copyID, garray_T *join_gap));
  static int list_join __ARGS((garray_T *gap, list_T *l, char_u *sep, int echo, int copyID));
  static int free_unref_items __ARGS((int copyID));
- static void set_ref_in_ht __ARGS((hashtab_T *ht, int copyID));
- static void set_ref_in_list __ARGS((list_T *l, int copyID));
- static void set_ref_in_item __ARGS((typval_T *tv, int copyID));
  static int rettv_dict_alloc __ARGS((typval_T *rettv));
  static void dict_free __ARGS((dict_T *d, int recurse));
  static dictitem_T *dictitem_copy __ARGS((dictitem_T *org));
--- 424,444 ----
***************
*** 654,659 ****
--- 645,656 ----
  static void f_prevnonblank __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_printf __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_pumvisible __ARGS((typval_T *argvars, typval_T *rettv));
+ #ifdef FEAT_PYTHON3
+ static void f_py3eval __ARGS((typval_T *argvars, typval_T *rettv));
+ #endif
+ #ifdef FEAT_PYTHON
+ static void f_pyeval __ARGS((typval_T *argvars, typval_T *rettv));
+ #endif
  static void f_range __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_readfile __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_reltime __ARGS((typval_T *argvars, typval_T *rettv));
***************
*** 824,831 ****
  static char_u *autoload_name __ARGS((char_u *name));
  static void cat_func_name __ARGS((char_u *buf, ufunc_T *fp));
  static void func_free __ARGS((ufunc_T *fp));
- static void func_unref __ARGS((char_u *name));
- static void func_ref __ARGS((char_u *name));
  static void call_user_func __ARGS((ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rettv, linenr_T firstline, linenr_T lastline, dict_T *selfdict));
  static int can_free_funccal __ARGS((funccall_T *fc, int copyID)) ;
  static void free_funccal __ARGS((funccall_T *fc, int free_val));
--- 821,826 ----
***************
*** 5927,5933 ****
  /*
   * Allocate a list item.
   */
!     static listitem_T *
  listitem_alloc()
  {
      return (listitem_T *)alloc(sizeof(listitem_T));
--- 5922,5928 ----
  /*
   * Allocate a list item.
   */
!     listitem_T *
  listitem_alloc()
  {
      return (listitem_T *)alloc(sizeof(listitem_T));
***************
*** 5947,5953 ****
  /*
   * Remove a list item from a List and free it.  Also clears the value.
   */
!     static void
  listitem_remove(l, item)
      list_T  *l;
      listitem_T *item;
--- 5942,5948 ----
  /*
   * Remove a list item from a List and free it.  Also clears the value.
   */
!     void
  listitem_remove(l, item)
      list_T  *l;
      listitem_T *item;
***************
*** 6123,6129 ****
   * A negative index is counted from the end; -1 is the last item.
   * Returns NULL when "n" is out of range.
   */
!     static listitem_T *
  list_find(l, n)
      list_T	*l;
      long	n;
--- 6118,6124 ----
   * A negative index is counted from the end; -1 is the last item.
   * Returns NULL when "n" is out of range.
   */
!     listitem_T *
  list_find(l, n)
      list_T	*l;
      long	n;
***************
*** 6265,6271 ****
  /*
   * Append item "item" to the end of list "l".
   */
!     static void
  list_append(l, item)
      list_T	*l;
      listitem_T	*item;
--- 6260,6266 ----
  /*
   * Append item "item" to the end of list "l".
   */
!     void
  list_append(l, item)
      list_T	*l;
      listitem_T	*item;
***************
*** 6378,6384 ****
   * If "item" is NULL append at the end.
   * Return FAIL when out of memory.
   */
!     static int
  list_insert_tv(l, tv, item)
      list_T	*l;
      typval_T	*tv;
--- 6373,6379 ----
   * If "item" is NULL append at the end.
   * Return FAIL when out of memory.
   */
!     int
  list_insert_tv(l, tv, item)
      list_T	*l;
      typval_T	*tv;
***************
*** 6523,6529 ****
   * Remove items "item" to "item2" from list "l".
   * Does not free the listitem or the value!
   */
!     static void
  list_remove(l, item, item2)
      list_T	*l;
      listitem_T	*item;
--- 6518,6524 ----
   * Remove items "item" to "item2" from list "l".
   * Does not free the listitem or the value!
   */
!     void
  list_remove(l, item, item2)
      list_T	*l;
      listitem_T	*item;
***************
*** 6785,6790 ****
--- 6780,6793 ----
      set_ref_in_lua(copyID);
  #endif
  
+ #ifdef FEAT_PYTHON
+     set_ref_in_python(copyID);
+ #endif
+ 
+ #ifdef FEAT_PYTHON3
+     set_ref_in_python3(copyID);
+ #endif
+ 
      /*
       * 2. Free lists and dictionaries that are not referenced.
       */
***************
*** 6870,6876 ****
  /*
   * Mark all lists and dicts referenced through hashtab "ht" with "copyID".
   */
!     static void
  set_ref_in_ht(ht, copyID)
      hashtab_T	*ht;
      int		copyID;
--- 6873,6879 ----
  /*
   * Mark all lists and dicts referenced through hashtab "ht" with "copyID".
   */
!     void
  set_ref_in_ht(ht, copyID)
      hashtab_T	*ht;
      int		copyID;
***************
*** 6890,6896 ****
  /*
   * Mark all lists and dicts referenced through list "l" with "copyID".
   */
!     static void
  set_ref_in_list(l, copyID)
      list_T	*l;
      int		copyID;
--- 6893,6899 ----
  /*
   * Mark all lists and dicts referenced through list "l" with "copyID".
   */
!     void
  set_ref_in_list(l, copyID)
      list_T	*l;
      int		copyID;
***************
*** 6904,6910 ****
  /*
   * Mark all lists and dicts referenced through typval "tv" with "copyID".
   */
!     static void
  set_ref_in_item(tv, copyID)
      typval_T	*tv;
      int		copyID;
--- 6907,6913 ----
  /*
   * Mark all lists and dicts referenced through typval "tv" with "copyID".
   */
!     void
  set_ref_in_item(tv, copyID)
      typval_T	*tv;
      int		copyID;
***************
*** 7986,7991 ****
--- 7989,8000 ----
      {"prevnonblank",	1, 1, f_prevnonblank},
      {"printf",		2, 19, f_printf},
      {"pumvisible",	0, 0, f_pumvisible},
+ #ifdef FEAT_PYTHON3
+     {"py3eval",		1, 1, f_py3eval},
+ #endif
+ #ifdef FEAT_PYTHON
+     {"pyeval",		1, 1, f_pyeval},
+ #endif
      {"range",		1, 3, f_range},
      {"readfile",	1, 3, f_readfile},
      {"reltime",		0, 2, f_reltime},
***************
*** 9150,9155 ****
--- 9159,9203 ----
  #endif
  }
  
+     int
+ func_call(name, args, selfdict, rettv)
+     char_u	*name;
+     typval_T	*args;
+     dict_T	*selfdict;
+     typval_T	*rettv;
+ {
+     listitem_T	*item;
+     typval_T	argv[MAX_FUNC_ARGS + 1];
+     int		argc = 0;
+     int		dummy;
+     int		r = 0;
+ 
+     for (item = args->vval.v_list->lv_first; item != NULL;
+ 							 item = item->li_next)
+     {
+ 	if (argc == MAX_FUNC_ARGS)
+ 	{
+ 	    EMSG(_("E699: Too many arguments"));
+ 	    break;
+ 	}
+ 	/* Make a copy of each argument.  This is needed to be able to set
+ 	 * v_lock to VAR_FIXED in the copy without changing the original list.
+ 	 */
+ 	copy_tv(&item->li_tv, &argv[argc++]);
+     }
+ 
+     if (item == NULL)
+ 	r = call_func(name, (int)STRLEN(name), rettv, argc, argv,
+ 				 curwin->w_cursor.lnum, curwin->w_cursor.lnum,
+ 						      &dummy, TRUE, selfdict);
+ 
+     /* Free the arguments. */
+     while (argc > 0)
+ 	clear_tv(&argv[--argc]);
+ 
+     return r;
+ }
+ 
  /*
   * "call(func, arglist)" function
   */
***************
*** 9159,9168 ****
      typval_T	*rettv;
  {
      char_u	*func;
-     typval_T	argv[MAX_FUNC_ARGS + 1];
-     int		argc = 0;
-     listitem_T	*item;
-     int		dummy;
      dict_T	*selfdict = NULL;
  
      if (argvars[1].v_type != VAR_LIST)
--- 9207,9212 ----
***************
*** 9190,9217 ****
  	selfdict = argvars[2].vval.v_dict;
      }
  
!     for (item = argvars[1].vval.v_list->lv_first; item != NULL;
! 							 item = item->li_next)
!     {
! 	if (argc == MAX_FUNC_ARGS)
! 	{
! 	    EMSG(_("E699: Too many arguments"));
! 	    break;
! 	}
! 	/* Make a copy of each argument.  This is needed to be able to set
! 	 * v_lock to VAR_FIXED in the copy without changing the original list.
! 	 */
! 	copy_tv(&item->li_tv, &argv[argc++]);
!     }
! 
!     if (item == NULL)
! 	(void)call_func(func, (int)STRLEN(func), rettv, argc, argv,
! 				 curwin->w_cursor.lnum, curwin->w_cursor.lnum,
! 						      &dummy, TRUE, selfdict);
! 
!     /* Free the arguments. */
!     while (argc > 0)
! 	clear_tv(&argv[--argc]);
  }
  
  #ifdef FEAT_FLOAT
--- 9234,9240 ----
  	selfdict = argvars[2].vval.v_dict;
      }
  
!     (void)func_call(func, &argvars[1], selfdict, rettv);
  }
  
  #ifdef FEAT_FLOAT
***************
*** 14424,14429 ****
--- 14447,14486 ----
  #endif
  }
  
+ #ifdef FEAT_PYTHON3
+ /*
+  * "py3eval()" function
+  */
+     static void
+ f_py3eval(argvars, rettv)
+     typval_T	*argvars;
+     typval_T	*rettv;
+ {
+     char_u	*str;
+     char_u	buf[NUMBUFLEN];
+ 
+     str = get_tv_string_buf(&argvars[0], buf);
+     do_py3eval(str, rettv);
+ }
+ #endif
+ 
+ #ifdef FEAT_PYTHON
+ /*
+  * "pyeval()" function
+  */
+     static void
+ f_pyeval(argvars, rettv)
+     typval_T	*argvars;
+     typval_T	*rettv;
+ {
+     char_u	*str;
+     char_u	buf[NUMBUFLEN];
+ 
+     str = get_tv_string_buf(&argvars[0], buf);
+     do_pyeval(str, rettv);
+ }
+ #endif
+ 
  /*
   * "range()" function
   */
***************
*** 22139,22145 ****
   * Unreference a Function: decrement the reference count and free it when it
   * becomes zero.  Only for numbered functions.
   */
!     static void
  func_unref(name)
      char_u	*name;
  {
--- 22196,22202 ----
   * Unreference a Function: decrement the reference count and free it when it
   * becomes zero.  Only for numbered functions.
   */
!     void
  func_unref(name)
      char_u	*name;
  {
***************
*** 22163,22169 ****
  /*
   * Count a reference to a Function.
   */
!     static void
  func_ref(name)
      char_u	*name;
  {
--- 22220,22226 ----
  /*
   * Count a reference to a Function.
   */
!     void
  func_ref(name)
      char_u	*name;
  {
*** ../vim-7.3.568/src/if_lua.c	2012-04-06 14:30:55.000000000 +0200
--- src/if_lua.c	2012-06-20 18:16:33.000000000 +0200
***************
*** 199,207 ****
  lua_Number (*dll_lua_tonumberx) (lua_State *L, int idx, int *isnum);
  lua_Integer (*dll_lua_tointegerx) (lua_State *L, int idx, int *isnum);
  void (*dll_lua_callk) (lua_State *L, int nargs, int nresults, int ctx,
!         lua_CFunction k);
  int (*dll_lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
!         int ctx, lua_CFunction k);
  void (*dll_lua_getglobal) (lua_State *L, const char *var);
  void (*dll_lua_setglobal) (lua_State *L, const char *var);
  #endif
--- 199,207 ----
  lua_Number (*dll_lua_tonumberx) (lua_State *L, int idx, int *isnum);
  lua_Integer (*dll_lua_tointegerx) (lua_State *L, int idx, int *isnum);
  void (*dll_lua_callk) (lua_State *L, int nargs, int nresults, int ctx,
! 	lua_CFunction k);
  int (*dll_lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
! 	int ctx, lua_CFunction k);
  void (*dll_lua_getglobal) (lua_State *L, const char *var);
  void (*dll_lua_setglobal) (lua_State *L, const char *var);
  #endif
***************
*** 394,400 ****
  luaL_typeerror (lua_State *L, int narg, const char *tname)
  {
      const char *msg = lua_pushfstring(L, "%s expected, got %s",
!             tname, luaL_typename(L, narg));
      return luaL_argerror(L, narg, msg);
  }
  #endif
--- 394,400 ----
  luaL_typeerror (lua_State *L, int narg, const char *tname)
  {
      const char *msg = lua_pushfstring(L, "%s expected, got %s",
! 	    tname, luaL_typename(L, narg));
      return luaL_argerror(L, narg, msg);
  }
  #endif
***************
*** 646,786 ****
  	return 1; \
      }
  
- 
- /* adapted from eval.c */
- 
- #define listitem_alloc() (listitem_T *)alloc(sizeof(listitem_T))
- 
-     static listitem_T *
- list_find (list_T *l, long n)
- {
-     listitem_T *li;
-     if (l == NULL || n < -l->lv_len || n >= l->lv_len)
- 	return NULL;
-     if (n < 0) /* search backward? */
- 	for (li = l->lv_last; n < -1; li = li->li_prev)
- 	    n++;
-     else /* search forward */
- 	for (li = l->lv_first; n > 0; li = li->li_next)
- 	    n--;
-     return li;
- }
- 
-     static void
- list_remove (list_T *l, listitem_T *li)
- {
-     listwatch_T *lw;
-     --l->lv_len;
-     /* fix watchers */
-     for (lw = l->lv_watch; lw != NULL; lw = lw->lw_next)
- 	if (lw->lw_item == li)
- 	    lw->lw_item = li->li_next;
-     /* fix list pointers */
-     if (li->li_next == NULL) /* last? */
- 	l->lv_last = li->li_prev;
-     else
- 	li->li_next->li_prev = li->li_prev;
-     if (li->li_prev == NULL) /* first? */
- 	l->lv_first = li->li_next;
-     else
- 	li->li_prev->li_next = li->li_next;
-     l->lv_idx_item = NULL;
- }
- 
-     static void
- list_append(list_T *l, listitem_T *item)
- {
-     if (l->lv_last == NULL) /* empty list? */
- 	l->lv_first = item;
-     else
- 	l->lv_last->li_next = item;
-     item->li_prev = l->lv_last;
-     item->li_next = NULL;
-     l->lv_last = item;
-     ++l->lv_len;
- }
- 
-     static int
- list_insert_tv(list_T *l, typval_T *tv, listitem_T *item)
- {
-     listitem_T	*ni = listitem_alloc();
- 
-     if (ni == NULL)
- 	return FAIL;
-     copy_tv(tv, &ni->li_tv);
-     if (item == NULL)
- 	list_append(l, ni);
-     else
-     {
- 	ni->li_prev = item->li_prev;
- 	ni->li_next = item;
- 	if (item->li_prev == NULL)
- 	{
- 	    l->lv_first = ni;
- 	    ++l->lv_idx;
- 	}
- 	else
- 	{
- 	    item->li_prev->li_next = ni;
- 	    l->lv_idx_item = NULL;
- 	}
- 	item->li_prev = ni;
- 	++l->lv_len;
-     }
-     return OK;
- }
- 
- /* set references */
- 
- static void set_ref_in_tv (typval_T *tv, int copyID);
- 
-     static void
- set_ref_in_dict(dict_T *d, int copyID)
- {
-     hashtab_T *ht = &d->dv_hashtab;
-     int n = ht->ht_used;
-     hashitem_T *hi;
-     for (hi = ht->ht_array; n > 0; ++hi)
- 	if (!HASHITEM_EMPTY(hi))
- 	{
- 	    dictitem_T *di = dict_lookup(hi);
- 	    set_ref_in_tv(&di->di_tv, copyID);
- 	    --n;
- 	}
- }
- 
-     static void
- set_ref_in_list(list_T *l, int copyID)
- {
-     listitem_T *li;
-     for (li = l->lv_first; li != NULL; li = li->li_next)
- 	set_ref_in_tv(&li->li_tv, copyID);
- }
- 
-     static void
- set_ref_in_tv(typval_T *tv, int copyID)
- {
-     if (tv->v_type == VAR_LIST)
-     {
- 	list_T *l = tv->vval.v_list;
- 	if (l != NULL && l->lv_copyID != copyID)
- 	{
- 	    l->lv_copyID = copyID;
- 	    set_ref_in_list(l, copyID);
- 	}
-     }
-     else if (tv->v_type == VAR_DICT)
-     {
- 	dict_T *d = tv->vval.v_dict;
- 	if (d != NULL && d->dv_copyID != copyID)
- 	{
- 	    d->dv_copyID = copyID;
- 	    set_ref_in_dict(d, copyID);
- 	}
-     }
- }
- 
- 
  /* =======   List type   ======= */
  
      static luaV_List *
--- 646,651 ----
***************
*** 876,882 ****
      if (li == NULL) return 0;
      if (lua_isnil(L, 3)) /* remove? */
      {
! 	list_remove(l, li);
  	clear_tv(&li->li_tv);
  	vim_free(li);
      }
--- 741,747 ----
      if (li == NULL) return 0;
      if (lua_isnil(L, 3)) /* remove? */
      {
! 	list_remove(l, li, li);
  	clear_tv(&li->li_tv);
  	vim_free(li);
      }
***************
*** 904,911 ****
  	typval_T v;
  	lua_settop(L, 2);
  	luaV_totypval(L, 2, &v);
! 	copy_tv(&v, &li->li_tv);
! 	list_append(l, li);
      }
      lua_settop(L, 1);
      return 1;
--- 769,775 ----
  	typval_T v;
  	lua_settop(L, 2);
  	luaV_totypval(L, 2, &v);
! 	list_append_tv(l, &v);
      }
      lua_settop(L, 1);
      return 1;
***************
*** 1682,1688 ****
  	    tv.vval.v_dict = (dict_T *) lua_touserdata(L, 4); /* key */
  	}
  	lua_pop(L, 2); /* metatable and value */
! 	set_ref_in_tv(&tv, copyID);
      }
      return 0;
  }
--- 1546,1552 ----
  	    tv.vval.v_dict = (dict_T *) lua_touserdata(L, 4); /* key */
  	}
  	lua_pop(L, 2); /* metatable and value */
! 	set_ref_in_item(&tv, copyID);
      }
      return 0;
  }
*** ../vim-7.3.568/src/if_py_both.h	2012-04-20 13:31:16.000000000 +0200
--- src/if_py_both.h	2012-06-29 12:03:52.000000000 +0200
***************
*** 1,4 ****
! /* vi:set ts=8 sts=4 sw=4:
   *
   * VIM - Vi IMproved	by Bram Moolenaar
   *
--- 1,4 ----
! /* vi:set ts=8 sts=4 sw=4 noet:
   *
   * VIM - Vi IMproved	by Bram Moolenaar
   *
***************
*** 105,111 ****
  	return NULL;
      Py_INCREF(list);
  
!     if (!PyList_Check(list)) {
  	PyErr_SetString(PyExc_TypeError, _("writelines() requires list of strings"));
  	Py_DECREF(list);
  	return NULL;
--- 105,112 ----
  	return NULL;
      Py_INCREF(list);
  
!     if (!PyList_Check(list))
!     {
  	PyErr_SetString(PyExc_TypeError, _("writelines() requires list of strings"));
  	Py_DECREF(list);
  	return NULL;
***************
*** 119,125 ****
  	char *str = NULL;
  	PyInt len;
  
! 	if (!PyArg_Parse(line, "et#", ENC_OPT, &str, &len)) {
  	    PyErr_SetString(PyExc_TypeError, _("writelines() requires list of strings"));
  	    Py_DECREF(list);
  	    return NULL;
--- 120,127 ----
  	char *str = NULL;
  	PyInt len;
  
! 	if (!PyArg_Parse(line, "et#", ENC_OPT, &str, &len))
! 	{
  	    PyErr_SetString(PyExc_TypeError, _("writelines() requires list of strings"));
  	    Py_DECREF(list);
  	    return NULL;
***************
*** 297,303 ****
  {
      PyObject	*result;
      PyObject	*newObj;
!     char	ptrBuf[NUMBUFLEN];
  
      /* Avoid infinite recursion */
      if (depth > 100)
--- 299,305 ----
  {
      PyObject	*result;
      PyObject	*newObj;
!     char	ptrBuf[sizeof(void *) * 2 + 3];
  
      /* Avoid infinite recursion */
      if (depth > 100)
***************
*** 312,320 ****
      if ((our_tv->v_type == VAR_LIST && our_tv->vval.v_list != NULL)
  	    || (our_tv->v_type == VAR_DICT && our_tv->vval.v_dict != NULL))
      {
! 	sprintf(ptrBuf, PRINTF_DECIMAL_LONG_U,
! 		our_tv->v_type == VAR_LIST ? (long_u)our_tv->vval.v_list
! 					   : (long_u)our_tv->vval.v_dict);
  	result = PyDict_GetItemString(lookupDict, ptrBuf);
  	if (result != NULL)
  	{
--- 314,322 ----
      if ((our_tv->v_type == VAR_LIST && our_tv->vval.v_list != NULL)
  	    || (our_tv->v_type == VAR_DICT && our_tv->vval.v_dict != NULL))
      {
! 	sprintf(ptrBuf, "%p",
! 		our_tv->v_type == VAR_LIST ? (void *)our_tv->vval.v_list
! 					   : (void *)our_tv->vval.v_dict);
  	result = PyDict_GetItemString(lookupDict, ptrBuf);
  	if (result != NULL)
  	{
***************
*** 374,509 ****
  	    hashitem_T	*hi;
  	    dictitem_T	*di;
  
! 	    PyDict_SetItemString(lookupDict, ptrBuf, result);
  
! 	    for (hi = ht->ht_array; todo > 0; ++hi)
  	    {
! 		if (!HASHITEM_EMPTY(hi))
! 		{
! 		    --todo;
! 
! 		    di = dict_lookup(hi);
! 		    newObj = VimToPython(&di->di_tv, depth + 1, lookupDict);
! 		    PyDict_SetItemString(result, (char *)hi->hi_key, newObj);
! 		    Py_DECREF(newObj);
! 		}
  	    }
  	}
      }
!     else
      {
! 	Py_INCREF(Py_None);
! 	result = Py_None;
      }
  
!     return result;
  }
- #endif
  
      static PyObject *
! VimEval(PyObject *self UNUSED, PyObject *args UNUSED)
  {
! #ifdef FEAT_EVAL
!     char	*expr;
!     typval_T	*our_tv;
!     PyObject	*result;
!     PyObject    *lookup_dict;
  
!     if (!PyArg_ParseTuple(args, "s", &expr))
  	return NULL;
  
!     Py_BEGIN_ALLOW_THREADS
!     Python_Lock_Vim();
!     our_tv = eval_expr((char_u *)expr, NULL);
! 
!     Python_Release_Vim();
!     Py_END_ALLOW_THREADS
! 
!     if (our_tv == NULL)
      {
! 	PyErr_SetVim(_("invalid expression"));
  	return NULL;
      }
  
-     /* Convert the Vim type into a Python type.  Create a dictionary that's
-      * used to check for recursive loops. */
      lookup_dict = PyDict_New();
!     result = VimToPython(our_tv, 1, lookup_dict);
      Py_DECREF(lookup_dict);
  
! 
!     Py_BEGIN_ALLOW_THREADS
!     Python_Lock_Vim();
!     free_tv(our_tv);
!     Python_Release_Vim();
!     Py_END_ALLOW_THREADS
! 
!     return result;
! #else
!     PyErr_SetVim(_("expressions disabled at compile time"));
!     return NULL;
! #endif
  }
  
! /*
!  * Vim module - Definitions
!  */
! 
! static struct PyMethodDef VimMethods[] = {
!     /* name,	     function,		calling,    documentation */
!     {"command",	     VimCommand,	1,	    "Execute a Vim ex-mode command" },
!     {"eval",	     VimEval,		1,	    "Evaluate an expression using Vim evaluator" },
!     { NULL,	     NULL,		0,	    NULL }
  };
  
  typedef struct
  {
      PyObject_HEAD
!     buf_T *buf;
! }
! BufferObject;
  
! #define INVALID_BUFFER_VALUE ((buf_T *)(-1))
! 
! /*
!  * Buffer list object - Implementation
!  */
  
!     static PyInt
! BufListLength(PyObject *self UNUSED)
  {
!     buf_T	*b = firstbuf;
!     PyInt	n = 0;
  
!     while (b)
      {
! 	++n;
! 	b = b->b_next;
      }
! 
!     return n;
  }
  
      static PyObject *
! BufListItem(PyObject *self UNUSED, PyInt n)
  {
!     buf_T *b;
  
!     for (b = firstbuf; b; b = b->b_next, --n)
      {
! 	if (n == 0)
! 	    return BufferNew(b);
      }
  
!     PyErr_SetString(PyExc_IndexError, _("no such buffer"));
!     return NULL;
  }
  
! typedef struct
! {
!     PyObject_HEAD
!     win_T	*win;
! } WindowObject;
  
  #define INVALID_WINDOW_VALUE ((win_T *)(-1))
  
--- 376,1325 ----
  	    hashitem_T	*hi;
  	    dictitem_T	*di;
  
! 	    PyDict_SetItemString(lookupDict, ptrBuf, result);
! 
! 	    for (hi = ht->ht_array; todo > 0; ++hi)
! 	    {
! 		if (!HASHITEM_EMPTY(hi))
! 		{
! 		    --todo;
! 
! 		    di = dict_lookup(hi);
! 		    newObj = VimToPython(&di->di_tv, depth + 1, lookupDict);
! 		    PyDict_SetItemString(result, (char *)hi->hi_key, newObj);
! 		    Py_DECREF(newObj);
! 		}
! 	    }
! 	}
!     }
!     else
!     {
! 	Py_INCREF(Py_None);
! 	result = Py_None;
!     }
! 
!     return result;
! }
! #endif
! 
!     static PyObject *
! VimEval(PyObject *self UNUSED, PyObject *args UNUSED)
! {
! #ifdef FEAT_EVAL
!     char	*expr;
!     typval_T	*our_tv;
!     PyObject	*result;
!     PyObject    *lookup_dict;
! 
!     if (!PyArg_ParseTuple(args, "s", &expr))
! 	return NULL;
! 
!     Py_BEGIN_ALLOW_THREADS
!     Python_Lock_Vim();
!     our_tv = eval_expr((char_u *)expr, NULL);
! 
!     Python_Release_Vim();
!     Py_END_ALLOW_THREADS
! 
!     if (our_tv == NULL)
!     {
! 	PyErr_SetVim(_("invalid expression"));
! 	return NULL;
!     }
! 
!     /* Convert the Vim type into a Python type.  Create a dictionary that's
!      * used to check for recursive loops. */
!     lookup_dict = PyDict_New();
!     result = VimToPython(our_tv, 1, lookup_dict);
!     Py_DECREF(lookup_dict);
! 
! 
!     Py_BEGIN_ALLOW_THREADS
!     Python_Lock_Vim();
!     free_tv(our_tv);
!     Python_Release_Vim();
!     Py_END_ALLOW_THREADS
! 
!     return result;
! #else
!     PyErr_SetVim(_("expressions disabled at compile time"));
!     return NULL;
! #endif
! }
! 
! static PyObject *ConvertToPyObject(typval_T *);
! 
!     static PyObject *
! VimEvalPy(PyObject *self UNUSED, PyObject *args UNUSED)
! {
! #ifdef FEAT_EVAL
!     char	*expr;
!     typval_T	*our_tv;
!     PyObject	*result;
! 
!     if (!PyArg_ParseTuple(args, "s", &expr))
! 	return NULL;
! 
!     Py_BEGIN_ALLOW_THREADS
!     Python_Lock_Vim();
!     our_tv = eval_expr((char_u *)expr, NULL);
! 
!     Python_Release_Vim();
!     Py_END_ALLOW_THREADS
! 
!     if (our_tv == NULL)
!     {
! 	PyErr_SetVim(_("invalid expression"));
! 	return NULL;
!     }
! 
!     result = ConvertToPyObject(our_tv);
!     Py_BEGIN_ALLOW_THREADS
!     Python_Lock_Vim();
!     free_tv(our_tv);
!     Python_Release_Vim();
!     Py_END_ALLOW_THREADS
! 
!     return result;
! #else
!     PyErr_SetVim(_("expressions disabled at compile time"));
!     return NULL;
! #endif
! }
! 
!     static PyObject *
! VimStrwidth(PyObject *self UNUSED, PyObject *args)
! {
!     char	*expr;
! 
!     if (!PyArg_ParseTuple(args, "s", &expr))
! 	return NULL;
! 
!     return PyLong_FromLong(mb_string2cells((char_u *)expr, STRLEN(expr)));
! }
! 
! /*
!  * Vim module - Definitions
!  */
! 
! static struct PyMethodDef VimMethods[] = {
!     /* name,	     function,		calling,    documentation */
!     {"command",	     VimCommand,	1,	    "Execute a Vim ex-mode command" },
!     {"eval",	     VimEval,		1,	    "Evaluate an expression using Vim evaluator" },
!     {"bindeval",     VimEvalPy,         1,          "Like eval(), but returns objects attached to vim ones"},
!     {"strwidth",     VimStrwidth,       1,          "Screen string width, counts <Tab> as having width 1"},
!     { NULL,	     NULL,		0,	    NULL }
! };
! 
! typedef struct
! {
!     PyObject_HEAD
!     buf_T *buf;
! } BufferObject;
! 
! #define INVALID_BUFFER_VALUE ((buf_T *)(-1))
! 
! /*
!  * Buffer list object - Implementation
!  */
! 
!     static PyInt
! BufListLength(PyObject *self UNUSED)
! {
!     buf_T	*b = firstbuf;
!     PyInt	n = 0;
! 
!     while (b)
!     {
! 	++n;
! 	b = b->b_next;
!     }
! 
!     return n;
! }
! 
!     static PyObject *
! BufListItem(PyObject *self UNUSED, PyInt n)
! {
!     buf_T *b;
! 
!     for (b = firstbuf; b; b = b->b_next, --n)
!     {
! 	if (n == 0)
! 	    return BufferNew(b);
!     }
! 
!     PyErr_SetString(PyExc_IndexError, _("no such buffer"));
!     return NULL;
! }
! 
! typedef struct
! {
!     PyObject_HEAD
!     win_T	*win;
! } WindowObject;
! 
! static int ConvertFromPyObject(PyObject *, typval_T *);
! static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
! 
! typedef struct pylinkedlist_S {
!     struct pylinkedlist_S	*pll_next;
!     struct pylinkedlist_S	*pll_prev;
!     PyObject			*pll_obj;
! } pylinkedlist_T;
! 
! static pylinkedlist_T *lastdict = NULL;
! static pylinkedlist_T *lastlist = NULL;
! 
!     static void
! pyll_remove(pylinkedlist_T *ref, pylinkedlist_T **last)
! {
!     if (ref->pll_prev == NULL)
!     {
! 	if (ref->pll_next == NULL)
! 	{
! 	    *last = NULL;
! 	    return;
! 	}
!     }
!     else
! 	ref->pll_prev->pll_next = ref->pll_next;
! 
!     if (ref->pll_next == NULL)
! 	*last = ref->pll_prev;
!     else
! 	ref->pll_next->pll_prev = ref->pll_prev;
! }
! 
!     static void
! pyll_add(PyObject *self, pylinkedlist_T *ref, pylinkedlist_T **last)
! {
!     if (*last == NULL)
! 	ref->pll_prev = NULL;
!     else
!     {
! 	(*last)->pll_next = ref;
! 	ref->pll_prev = *last;
!     }
!     ref->pll_next = NULL;
!     ref->pll_obj = self;
!     *last = ref;
! }
! 
! static PyTypeObject DictionaryType;
! 
! typedef struct
! {
!     PyObject_HEAD
!     dict_T	*dict;
!     pylinkedlist_T	ref;
! } DictionaryObject;
! 
!     static PyObject *
! DictionaryNew(dict_T *dict)
! {
!     DictionaryObject	*self;
! 
!     self = PyObject_NEW(DictionaryObject, &DictionaryType);
!     if (self == NULL)
! 	return NULL;
!     self->dict = dict;
!     ++dict->dv_refcount;
! 
!     pyll_add((PyObject *)(self), &self->ref, &lastdict);
! 
!     return (PyObject *)(self);
! }
! 
!     static int
! pydict_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
! {
!     dict_T	*d;
!     char_u	*key;
!     dictitem_T	*di;
!     PyObject	*keyObject;
!     PyObject	*valObject;
!     Py_ssize_t	iter = 0;
! 
!     d = dict_alloc();
!     if (d == NULL)
!     {
! 	PyErr_NoMemory();
! 	return -1;
!     }
! 
!     tv->v_type = VAR_DICT;
!     tv->vval.v_dict = d;
! 
!     while (PyDict_Next(obj, &iter, &keyObject, &valObject))
!     {
! 	DICTKEY_DECL
! 
! 	if (keyObject == NULL)
! 	    return -1;
! 	if (valObject == NULL)
! 	    return -1;
! 
! 	DICTKEY_GET(-1)
! 
! 	di = dictitem_alloc(key);
! 
! 	DICTKEY_UNREF
! 
! 	if (di == NULL)
! 	{
! 	    PyErr_NoMemory();
! 	    return -1;
! 	}
! 	di->di_tv.v_lock = 0;
! 
! 	if (_ConvertFromPyObject(valObject, &di->di_tv, lookupDict) == -1)
! 	{
! 	    vim_free(di);
! 	    return -1;
! 	}
! 	if (dict_add(d, di) == FAIL)
! 	{
! 	    vim_free(di);
! 	    PyErr_SetVim(_("failed to add key to dictionary"));
! 	    return -1;
! 	}
!     }
!     return 0;
! }
! 
!     static int
! pymap_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
! {
!     dict_T	*d;
!     char_u	*key;
!     dictitem_T	*di;
!     PyObject	*list;
!     PyObject	*litem;
!     PyObject	*keyObject;
!     PyObject	*valObject;
!     Py_ssize_t	lsize;
! 
!     d = dict_alloc();
!     if (d == NULL)
!     {
! 	PyErr_NoMemory();
! 	return -1;
!     }
! 
!     tv->v_type = VAR_DICT;
!     tv->vval.v_dict = d;
! 
!     list = PyMapping_Items(obj);
!     lsize = PyList_Size(list);
!     while (lsize--)
!     {
! 	DICTKEY_DECL
! 
! 	litem = PyList_GetItem(list, lsize);
! 	if (litem == NULL)
! 	{
! 	    Py_DECREF(list);
! 	    return -1;
! 	}
! 
! 	keyObject = PyTuple_GetItem(litem, 0);
! 	if (keyObject == NULL)
! 	{
! 	    Py_DECREF(list);
! 	    Py_DECREF(litem);
! 	    return -1;
! 	}
! 
! 	DICTKEY_GET(-1)
! 
! 	valObject = PyTuple_GetItem(litem, 1);
! 	if (valObject == NULL)
! 	{
! 	    Py_DECREF(list);
! 	    Py_DECREF(litem);
! 	    return -1;
! 	}
! 
! 	di = dictitem_alloc(key);
! 
! 	DICTKEY_UNREF
! 
! 	if (di == NULL)
! 	{
! 	    Py_DECREF(list);
! 	    Py_DECREF(litem);
! 	    PyErr_NoMemory();
! 	    return -1;
! 	}
! 	di->di_tv.v_lock = 0;
! 
! 	if (_ConvertFromPyObject(valObject, &di->di_tv, lookupDict) == -1)
! 	{
! 	    vim_free(di);
! 	    Py_DECREF(list);
! 	    Py_DECREF(litem);
! 	    return -1;
! 	}
! 	if (dict_add(d, di) == FAIL)
! 	{
! 	    vim_free(di);
! 	    Py_DECREF(list);
! 	    Py_DECREF(litem);
! 	    PyErr_SetVim(_("failed to add key to dictionary"));
! 	    return -1;
! 	}
! 	Py_DECREF(litem);
!     }
!     Py_DECREF(list);
!     return 0;
! }
! 
!     static PyInt
! DictionaryLength(PyObject *self)
! {
!     return ((PyInt) ((((DictionaryObject *)(self))->dict->dv_hashtab.ht_used)));
! }
! 
!     static PyObject *
! DictionaryItem(PyObject *self, PyObject *keyObject)
! {
!     char_u	*key;
!     dictitem_T	*val;
!     DICTKEY_DECL
! 
!     DICTKEY_GET(NULL)
! 
!     val = dict_find(((DictionaryObject *) (self))->dict, key, -1);
! 
!     DICTKEY_UNREF
! 
!     return ConvertToPyObject(&val->di_tv);
! }
! 
!     static PyInt
! DictionaryAssItem(PyObject *self, PyObject *keyObject, PyObject *valObject)
! {
!     char_u	*key;
!     typval_T	tv;
!     dict_T	*d = ((DictionaryObject *)(self))->dict;
!     dictitem_T	*di;
!     DICTKEY_DECL
! 
!     if (d->dv_lock)
!     {
! 	PyErr_SetVim(_("dict is locked"));
! 	return -1;
!     }
! 
!     DICTKEY_GET(-1)
! 
!     di = dict_find(d, key, -1);
! 
!     if (valObject == NULL)
!     {
! 	if (di == NULL)
! 	{
! 	    PyErr_SetString(PyExc_IndexError, _("no such key in dictionary"));
! 	    return -1;
! 	}
! 	hashitem_T	*hi = hash_find(&d->dv_hashtab, di->di_key);
! 	hash_remove(&d->dv_hashtab, hi);
! 	dictitem_free(di);
! 	return 0;
!     }
! 
!     if (ConvertFromPyObject(valObject, &tv) == -1)
!     {
! 	return -1;
!     }
! 
!     if (di == NULL)
!     {
! 	di = dictitem_alloc(key);
! 	if (di == NULL)
! 	{
! 	    PyErr_NoMemory();
! 	    return -1;
! 	}
! 	di->di_tv.v_lock = 0;
! 
! 	if (dict_add(d, di) == FAIL)
! 	{
! 	    vim_free(di);
! 	    PyErr_SetVim(_("failed to add key to dictionary"));
! 	    return -1;
! 	}
!     }
!     else
! 	clear_tv(&di->di_tv);
! 
!     DICTKEY_UNREF
! 
!     copy_tv(&tv, &di->di_tv);
!     return 0;
! }
! 
!     static PyObject *
! DictionaryListKeys(PyObject *self)
! {
!     dict_T	*dict = ((DictionaryObject *)(self))->dict;
!     long_u	todo = dict->dv_hashtab.ht_used;
!     Py_ssize_t	i = 0;
!     PyObject	*r;
!     hashitem_T	*hi;
! 
!     r = PyList_New(todo);
!     for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi)
!     {
! 	if (!HASHITEM_EMPTY(hi))
! 	{
! 	    PyList_SetItem(r, i, PyBytes_FromString((char *)(hi->hi_key)));
! 	    --todo;
! 	    ++i;
! 	}
!     }
!     return r;
! }
! 
! static struct PyMethodDef DictionaryMethods[] = {
!     {"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""},
!     { NULL,	    NULL,		0,	    NULL }
! };
! 
! static PyTypeObject ListType;
! 
! typedef struct
! {
!     PyObject_HEAD
!     list_T	*list;
!     pylinkedlist_T	ref;
! } ListObject;
! 
!     static PyObject *
! ListNew(list_T *list)
! {
!     ListObject	*self;
! 
!     self = PyObject_NEW(ListObject, &ListType);
!     if (self == NULL)
! 	return NULL;
!     self->list = list;
!     ++list->lv_refcount;
! 
!     pyll_add((PyObject *)(self), &self->ref, &lastlist);
! 
!     return (PyObject *)(self);
! }
! 
!     static int
! list_py_concat(list_T *l, PyObject *obj, PyObject *lookupDict)
! {
!     Py_ssize_t	i;
!     Py_ssize_t	lsize = PySequence_Size(obj);
!     PyObject	*litem;
!     listitem_T	*li;
! 
!     for(i=0; i<lsize; i++)
!     {
! 	li = listitem_alloc();
! 	if (li == NULL)
! 	{
! 	    PyErr_NoMemory();
! 	    return -1;
! 	}
! 	li->li_tv.v_lock = 0;
! 
! 	litem = PySequence_GetItem(obj, i);
! 	if (litem == NULL)
! 	    return -1;
! 	if (_ConvertFromPyObject(litem, &li->li_tv, lookupDict) == -1)
! 	    return -1;
! 
! 	list_append(l, li);
!     }
!     return 0;
! }
! 
!     static int
! pyseq_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
! {
!     list_T	*l;
! 
!     l = list_alloc();
!     if (l == NULL)
!     {
! 	PyErr_NoMemory();
! 	return -1;
!     }
! 
!     tv->v_type = VAR_LIST;
!     tv->vval.v_list = l;
! 
!     if (list_py_concat(l, obj, lookupDict) == -1)
! 	return -1;
! 
!     return 0;
! }
! 
!     static int
! pyiter_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
! {
!     PyObject	*iterator = PyObject_GetIter(obj);
!     PyObject	*item;
!     list_T	*l;
!     listitem_T	*li;
! 
!     l = list_alloc();
! 
!     if (l == NULL)
!     {
! 	PyErr_NoMemory();
! 	return -1;
!     }
! 
!     tv->vval.v_list = l;
!     tv->v_type = VAR_LIST;
! 
! 
!     if (iterator == NULL)
! 	return -1;
! 
!     while ((item = PyIter_Next(obj)))
!     {
! 	li = listitem_alloc();
! 	if (li == NULL)
! 	{
! 	    PyErr_NoMemory();
! 	    return -1;
! 	}
! 	li->li_tv.v_lock = 0;
! 
! 	if (_ConvertFromPyObject(item, &li->li_tv, lookupDict) == -1)
! 	    return -1;
! 
! 	list_append(l, li);
! 
! 	Py_DECREF(item);
!     }
! 
!     Py_DECREF(iterator);
!     return 0;
! }
! 
!     static PyInt
! ListLength(PyObject *self)
! {
!     return ((PyInt) (((ListObject *) (self))->list->lv_len));
! }
! 
!     static PyObject *
! ListItem(PyObject *self, Py_ssize_t index)
! {
!     listitem_T	*li;
! 
!     if (index>=ListLength(self))
!     {
! 	PyErr_SetString(PyExc_IndexError, "list index out of range");
! 	return NULL;
!     }
!     li = list_find(((ListObject *) (self))->list, (long) index);
!     if (li == NULL)
!     {
! 	PyErr_SetVim(_("internal error: failed to get vim list item"));
! 	return NULL;
!     }
!     return ConvertToPyObject(&li->li_tv);
! }
! 
! #define PROC_RANGE \
!     if (last < 0) {\
! 	if (last < -size) \
! 	    last = 0; \
! 	else \
! 	    last += size; \
!     } \
!     if (first < 0) \
! 	first = 0; \
!     if (first > size) \
! 	first = size; \
!     if (last > size) \
! 	last = size;
! 
!     static PyObject *
! ListSlice(PyObject *self, Py_ssize_t first, Py_ssize_t last)
! {
!     PyInt	i;
!     PyInt	size = ListLength(self);
!     PyInt	n;
!     PyObject	*list;
!     int		reversed = 0;
! 
!     PROC_RANGE
!     if (first >= last)
! 	first = last;
! 
!     n = last-first;
!     list = PyList_New(n);
!     if (list == NULL)
! 	return NULL;
! 
!     for (i = 0; i < n; ++i)
!     {
! 	PyObject	*item = ListItem(self, i);
! 	if (item == NULL)
! 	{
! 	    Py_DECREF(list);
! 	    return NULL;
! 	}
! 
! 	if ((PyList_SetItem(list, ((reversed)?(n-i-1):(i)), item)))
! 	{
! 	    Py_DECREF(item);
! 	    Py_DECREF(list);
! 	    return NULL;
! 	}
!     }
! 
!     return list;
! }
! 
!     static int
! ListAssItem(PyObject *self, Py_ssize_t index, PyObject *obj)
! {
!     typval_T	tv;
!     list_T	*l = ((ListObject *) (self))->list;
!     listitem_T	*li;
!     Py_ssize_t	length = ListLength(self);
! 
!     if (l->lv_lock)
!     {
! 	PyErr_SetVim(_("list is locked"));
! 	return -1;
!     }
!     if (index>length || (index==length && obj==NULL))
!     {
! 	PyErr_SetString(PyExc_IndexError, "list index out of range");
! 	return -1;
!     }
! 
!     if (obj == NULL)
!     {
! 	li = list_find(l, (long) index);
! 	list_remove(l, li, li);
! 	clear_tv(&li->li_tv);
! 	vim_free(li);
! 	return 0;
!     }
! 
!     if (ConvertFromPyObject(obj, &tv) == -1)
! 	return -1;
! 
!     if (index == length)
!     {
! 	if (list_append_tv(l, &tv) == FAIL)
! 	{
! 	    PyErr_SetVim(_("Failed to add item to list"));
! 	    return -1;
! 	}
!     }
!     else
!     {
! 	li = list_find(l, (long) index);
! 	clear_tv(&li->li_tv);
! 	copy_tv(&tv, &li->li_tv);
!     }
!     return 0;
! }
! 
!     static int
! ListAssSlice(PyObject *self, Py_ssize_t first, Py_ssize_t last, PyObject *obj)
! {
!     PyInt	size = ListLength(self);
!     Py_ssize_t	i;
!     Py_ssize_t	lsize;
!     PyObject	*litem;
!     listitem_T	*li;
!     listitem_T	*next;
!     typval_T	v;
!     list_T	*l = ((ListObject *) (self))->list;
! 
!     if (l->lv_lock)
!     {
! 	PyErr_SetVim(_("list is locked"));
! 	return -1;
!     }
! 
!     PROC_RANGE
  
!     if (first == size)
! 	li = NULL;
!     else
!     {
! 	li = list_find(l, (long) first);
! 	if (li == NULL)
! 	{
! 	    PyErr_SetVim(_("internal error: no vim list item"));
! 	    return -1;
! 	}
! 	if (last > first)
! 	{
! 	    i = last - first;
! 	    while (i-- && li != NULL)
  	    {
! 		next = li->li_next;
! 		listitem_remove(l, li);
! 		li = next;
  	    }
  	}
      }
! 
!     if (obj == NULL)
! 	return 0;
! 
!     if (!PyList_Check(obj))
      {
! 	PyErr_SetString(PyExc_TypeError, _("can only assign lists to slice"));
! 	return -1;
      }
  
!     lsize = PyList_Size(obj);
! 
!     for(i=0; i<lsize; i++)
!     {
! 	litem = PyList_GetItem(obj, i);
! 	if (litem == NULL)
! 	    return -1;
! 	if (ConvertFromPyObject(litem, &v) == -1)
! 	    return -1;
! 	if (list_insert_tv(l, &v, li) == FAIL)
! 	{
! 	    PyErr_SetVim(_("internal error: failed to add item to list"));
! 	    return -1;
! 	}
!     }
!     return 0;
  }
  
      static PyObject *
! ListConcatInPlace(PyObject *self, PyObject *obj)
  {
!     list_T	*l = ((ListObject *) (self))->list;
!     PyObject	*lookup_dict;
  
!     if (l->lv_lock)
!     {
! 	PyErr_SetVim(_("list is locked"));
  	return NULL;
+     }
  
!     if (!PySequence_Check(obj))
      {
! 	PyErr_SetString(PyExc_TypeError, _("can only concatenate with lists"));
  	return NULL;
      }
  
      lookup_dict = PyDict_New();
!     if (list_py_concat(l, obj, lookup_dict) == -1)
!     {
! 	Py_DECREF(lookup_dict);
! 	return NULL;
!     }
      Py_DECREF(lookup_dict);
  
!     Py_INCREF(self);
!     return self;
  }
  
! static struct PyMethodDef ListMethods[] = {
!     {"extend", (PyCFunction)ListConcatInPlace, METH_O, ""},
!     { NULL,	    NULL,		0,	    NULL }
  };
  
  typedef struct
  {
      PyObject_HEAD
!     char_u	*name;
! } FunctionObject;
  
! static PyTypeObject FunctionType;
  
!     static PyObject *
! FunctionNew(char_u *name)
  {
!     FunctionObject	*self;
  
!     self = PyObject_NEW(FunctionObject, &FunctionType);
!     if (self == NULL)
! 	return NULL;
!     self->name = PyMem_New(char_u, STRLEN(name) + 1);
!     if (self->name == NULL)
      {
! 	PyErr_NoMemory();
! 	return NULL;
      }
!     STRCPY(self->name, name);
!     func_ref(name);
!     return (PyObject *)(self);
  }
  
      static PyObject *
! FunctionCall(PyObject *self, PyObject *argsObject, PyObject *kwargs)
  {
!     FunctionObject	*this = (FunctionObject *)(self);
!     char_u	*name = this->name;
!     typval_T	args;
!     typval_T	selfdicttv;
!     typval_T	rettv;
!     dict_T	*selfdict = NULL;
!     PyObject	*selfdictObject;
!     PyObject	*result;
!     int		error;
  
!     if (ConvertFromPyObject(argsObject, &args) == -1)
! 	return NULL;
! 
!     if (kwargs != NULL)
      {
! 	selfdictObject = PyDict_GetItemString(kwargs, "self");
! 	if (selfdictObject != NULL)
! 	{
! 	    if (!PyDict_Check(selfdictObject))
! 	    {
! 		PyErr_SetString(PyExc_TypeError, _("'self' argument must be a dictionary"));
! 		clear_tv(&args);
! 		return NULL;
! 	    }
! 	    if (ConvertFromPyObject(selfdictObject, &selfdicttv) == -1)
! 		return NULL;
! 	    selfdict = selfdicttv.vval.v_dict;
! 	}
      }
  
!     error = func_call(name, &args, selfdict, &rettv);
!     if (error != OK)
!     {
! 	result = NULL;
! 	PyErr_SetVim(_("failed to run function"));
!     }
!     else
! 	result = ConvertToPyObject(&rettv);
! 
!     /* FIXME Check what should really be cleared. */
!     clear_tv(&args);
!     clear_tv(&rettv);
!     /*
!      * if (selfdict!=NULL)
!      *     clear_tv(selfdicttv);
!      */
! 
!     return result;
  }
  
! static struct PyMethodDef FunctionMethods[] = {
!     {"__call__",    (PyCFunction)FunctionCall, METH_VARARGS|METH_KEYWORDS, ""},
!     { NULL,	    NULL,		0,	    NULL }
! };
  
  #define INVALID_WINDOW_VALUE ((win_T *)(-1))
  
***************
*** 1567,1569 ****
--- 2383,2638 ----
      { NULL,	    NULL,		0,	    NULL }
  };
  
+     static void
+ set_ref_in_py(const int copyID)
+ {
+     pylinkedlist_T	*cur;
+     dict_T	*dd;
+     list_T	*ll;
+ 
+     if (lastdict != NULL)
+ 	for(cur = lastdict ; cur != NULL ; cur = cur->pll_prev)
+ 	{
+ 	    dd = ((DictionaryObject *) (cur->pll_obj))->dict;
+ 	    if (dd->dv_copyID != copyID)
+ 	    {
+ 		dd->dv_copyID = copyID;
+ 		set_ref_in_ht(&dd->dv_hashtab, copyID);
+ 	    }
+ 	}
+ 
+     if (lastlist != NULL)
+ 	for(cur = lastlist ; cur != NULL ; cur = cur->pll_prev)
+ 	{
+ 	    ll = ((ListObject *) (cur->pll_obj))->list;
+ 	    if (ll->lv_copyID != copyID)
+ 	    {
+ 		ll->lv_copyID = copyID;
+ 		set_ref_in_list(ll, copyID);
+ 	    }
+ 	}
+ }
+ 
+     static int
+ set_string_copy(char_u *str, typval_T *tv)
+ {
+     tv->vval.v_string = vim_strsave(str);
+     if (tv->vval.v_string == NULL)
+     {
+ 	PyErr_NoMemory();
+ 	return -1;
+     }
+     return 0;
+ }
+ 
+ #ifdef FEAT_EVAL
+ typedef int (*pytotvfunc)(PyObject *, typval_T *, PyObject *);
+ 
+     static int
+ convert_dl(PyObject *obj, typval_T *tv,
+ 				    pytotvfunc py_to_tv, PyObject *lookupDict)
+ {
+     PyObject	*capsule;
+     char	hexBuf[sizeof(void *) * 2 + 3];
+ 
+     sprintf(hexBuf, "%p", obj);
+ 
+     capsule = PyDict_GetItemString(lookupDict, hexBuf);
+     if (capsule == NULL)
+     {
+ 	capsule = PyCapsule_New(tv, NULL, NULL);
+ 	PyDict_SetItemString(lookupDict, hexBuf, capsule);
+ 	Py_DECREF(capsule);
+ 	if (py_to_tv(obj, tv, lookupDict) == -1)
+ 	{
+ 	    tv->v_type = VAR_UNKNOWN;
+ 	    return -1;
+ 	}
+ 	/* As we are not using copy_tv which increments reference count we must
+ 	 * do it ourself. */
+ 	switch(tv->v_type)
+ 	{
+ 	    case VAR_DICT: ++tv->vval.v_dict->dv_refcount; break;
+ 	    case VAR_LIST: ++tv->vval.v_list->lv_refcount; break;
+ 	}
+     }
+     else
+     {
+ 	typval_T	*v = PyCapsule_GetPointer(capsule, NULL);
+ 	copy_tv(v, tv);
+     }
+     return 0;
+ }
+ 
+     static int
+ ConvertFromPyObject(PyObject *obj, typval_T *tv)
+ {
+     PyObject	*lookup_dict;
+     int		r;
+ 
+     lookup_dict = PyDict_New();
+     r = _ConvertFromPyObject(obj, tv, lookup_dict);
+     Py_DECREF(lookup_dict);
+     return r;
+ }
+ 
+     static int
+ _ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookupDict)
+ {
+     if (obj->ob_type == &DictionaryType)
+     {
+ 	tv->v_type = VAR_DICT;
+ 	tv->vval.v_dict = (((DictionaryObject *)(obj))->dict);
+ 	++tv->vval.v_dict->dv_refcount;
+     }
+     else if (obj->ob_type == &ListType)
+     {
+ 	tv->v_type = VAR_LIST;
+ 	tv->vval.v_list = (((ListObject *)(obj))->list);
+ 	++tv->vval.v_list->lv_refcount;
+     }
+     else if (obj->ob_type == &FunctionType)
+     {
+ 	if (set_string_copy(((FunctionObject *) (obj))->name, tv) == -1)
+ 	    return -1;
+ 
+ 	tv->v_type = VAR_FUNC;
+ 	func_ref(tv->vval.v_string);
+     }
+ #if PY_MAJOR_VERSION >= 3
+     else if (PyBytes_Check(obj))
+     {
+ 	char_u	*result = (char_u *) PyBytes_AsString(obj);
+ 
+ 	if (result == NULL)
+ 	    return -1;
+ 
+ 	if (set_string_copy(result, tv) == -1)
+ 	    return -1;
+ 
+ 	tv->v_type = VAR_STRING;
+     }
+     else if (PyUnicode_Check(obj))
+     {
+ 	PyObject	*bytes;
+ 	char_u	*result;
+ 
+ 	bytes = PyString_AsBytes(obj);
+ 	if (bytes == NULL)
+ 	    return -1;
+ 
+ 	result = (char_u *) PyBytes_AsString(bytes);
+ 	if (result == NULL)
+ 	    return -1;
+ 
+ 	if (set_string_copy(result, tv) == -1)
+ 	{
+ 	    Py_XDECREF(bytes);
+ 	    return -1;
+ 	}
+ 	Py_XDECREF(bytes);
+ 
+ 	tv->v_type = VAR_STRING;
+     }
+ #else
+     else if (PyUnicode_Check(obj))
+     {
+ 	PyObject	*bytes;
+ 	char_u	*result;
+ 
+ 	bytes = PyUnicode_AsEncodedString(obj, (char *)ENC_OPT, NULL);
+ 	if (bytes == NULL)
+ 	    return -1;
+ 
+ 	result=(char_u *) PyString_AsString(bytes);
+ 	if (result == NULL)
+ 	    return -1;
+ 
+ 	if (set_string_copy(result, tv) == -1)
+ 	{
+ 	    Py_XDECREF(bytes);
+ 	    return -1;
+ 	}
+ 	Py_XDECREF(bytes);
+ 
+ 	tv->v_type = VAR_STRING;
+     }
+     else if (PyString_Check(obj))
+     {
+ 	char_u	*result = (char_u *) PyString_AsString(obj);
+ 
+ 	if (result == NULL)
+ 	    return -1;
+ 
+ 	if (set_string_copy(result, tv) == -1)
+ 	    return -1;
+ 
+ 	tv->v_type = VAR_STRING;
+     }
+     else if (PyInt_Check(obj))
+     {
+ 	tv->v_type = VAR_NUMBER;
+ 	tv->vval.v_number = (varnumber_T) PyInt_AsLong(obj);
+     }
+ #endif
+     else if (PyLong_Check(obj))
+     {
+ 	tv->v_type = VAR_NUMBER;
+ 	tv->vval.v_number = (varnumber_T) PyLong_AsLong(obj);
+     }
+     else if (PyDict_Check(obj))
+ 	return convert_dl(obj, tv, pydict_to_tv, lookupDict);
+ #ifdef FEAT_FLOAT
+     else if (PyFloat_Check(obj))
+     {
+ 	tv->v_type = VAR_FLOAT;
+ 	tv->vval.v_float = (float_T) PyFloat_AsDouble(obj);
+     }
+ #endif
+     else if (PyIter_Check(obj))
+ 	return convert_dl(obj, tv, pyiter_to_tv, lookupDict);
+     else if (PySequence_Check(obj))
+ 	return convert_dl(obj, tv, pyseq_to_tv, lookupDict);
+     else if (PyMapping_Check(obj))
+ 	return convert_dl(obj, tv, pymap_to_tv, lookupDict);
+     else
+     {
+ 	PyErr_SetString(PyExc_TypeError, _("unable to convert to vim structure"));
+ 	return -1;
+     }
+     return 0;
+ }
+ 
+     static PyObject *
+ ConvertToPyObject(typval_T *tv)
+ {
+     if (tv == NULL)
+     {
+ 	PyErr_SetVim(_("NULL reference passed"));
+ 	return NULL;
+     }
+     switch (tv->v_type)
+     {
+ 	case VAR_STRING:
+ 	    return PyBytes_FromString((char *) tv->vval.v_string);
+ 	case VAR_NUMBER:
+ 	    return PyLong_FromLong((long) tv->vval.v_number);
+ #ifdef FEAT_FLOAT
+ 	case VAR_FLOAT:
+ 	    return PyFloat_FromDouble((double) tv->vval.v_float);
+ #endif
+ 	case VAR_LIST:
+ 	    return ListNew(tv->vval.v_list);
+ 	case VAR_DICT:
+ 	    return DictionaryNew(tv->vval.v_dict);
+ 	case VAR_FUNC:
+ 	    return FunctionNew(tv->vval.v_string);
+ 	case VAR_UNKNOWN:
+ 	    Py_INCREF(Py_None);
+ 	    return Py_None;
+ 	default:
+ 	    PyErr_SetVim(_("internal error: invalid value type"));
+ 	    return NULL;
+     }
+ }
+ #endif
*** ../vim-7.3.568/src/if_python.c	2011-08-28 16:00:14.000000000 +0200
--- src/if_python.c	2012-06-29 12:47:48.000000000 +0200
***************
*** 1,4 ****
! /* vi:set ts=8 sts=4 sw=4:
   *
   * VIM - Vi IMproved	by Bram Moolenaar
   *
--- 1,4 ----
! /* vi:set ts=8 sts=4 sw=4 noet:
   *
   * VIM - Vi IMproved	by Bram Moolenaar
   *
***************
*** 56,61 ****
--- 56,63 ----
  
  static void init_structs(void);
  
+ #define PyBytes_FromString PyString_FromString
+ 
  /* No-op conversion functions, use with care! */
  #define PyString_AsBytes(obj) (obj)
  #define PyString_FreeBytes(obj)
***************
*** 122,132 ****
--- 124,136 ----
  /* This makes if_python.c compile without warnings against Python 2.5
   * on Win32 and Win64. */
  # undef PyRun_SimpleString
+ # undef PyRun_String
  # undef PyArg_Parse
  # undef PyArg_ParseTuple
  # undef Py_BuildValue
  # undef Py_InitModule4
  # undef Py_InitModule4_64
+ # undef PyObject_CallMethod
  
  /*
   * Wrapper defines
***************
*** 134,139 ****
--- 138,144 ----
  # define PyArg_Parse dll_PyArg_Parse
  # define PyArg_ParseTuple dll_PyArg_ParseTuple
  # define PyMem_Free dll_PyMem_Free
+ # define PyMem_Malloc dll_PyMem_Malloc
  # define PyDict_SetItemString dll_PyDict_SetItemString
  # define PyErr_BadArgument dll_PyErr_BadArgument
  # define PyErr_Clear dll_PyErr_Clear
***************
*** 150,172 ****
--- 155,202 ----
  # endif
  # define PyInt_AsLong dll_PyInt_AsLong
  # define PyInt_FromLong dll_PyInt_FromLong
+ # define PyLong_AsLong dll_PyLong_AsLong
+ # define PyLong_FromLong dll_PyLong_FromLong
  # define PyInt_Type (*dll_PyInt_Type)
+ # define PyLong_Type (*dll_PyLong_Type)
  # define PyList_GetItem dll_PyList_GetItem
  # define PyList_Append dll_PyList_Append
  # define PyList_New dll_PyList_New
  # define PyList_SetItem dll_PyList_SetItem
  # define PyList_Size dll_PyList_Size
  # define PyList_Type (*dll_PyList_Type)
+ # define PySequence_Check dll_PySequence_Check
+ # define PySequence_Size dll_PySequence_Size
+ # define PySequence_GetItem dll_PySequence_GetItem
+ # define PyTuple_Size dll_PyTuple_Size
+ # define PyTuple_GetItem dll_PyTuple_GetItem
+ # define PyTuple_Type (*dll_PyTuple_Type)
  # define PyImport_ImportModule dll_PyImport_ImportModule
  # define PyDict_New dll_PyDict_New
  # define PyDict_GetItemString dll_PyDict_GetItemString
+ # define PyDict_Next dll_PyDict_Next
+ # ifdef PyMapping_Items
+ #  define PY_NO_MAPPING_ITEMS
+ # else
+ #  define PyMapping_Items dll_PyMapping_Items
+ # endif
+ # define PyObject_CallMethod dll_PyObject_CallMethod
+ # define PyMapping_Check dll_PyMapping_Check
+ # define PyIter_Next dll_PyIter_Next
  # define PyModule_GetDict dll_PyModule_GetDict
  # define PyRun_SimpleString dll_PyRun_SimpleString
+ # define PyRun_String dll_PyRun_String
  # define PyString_AsString dll_PyString_AsString
  # define PyString_FromString dll_PyString_FromString
  # define PyString_FromStringAndSize dll_PyString_FromStringAndSize
  # define PyString_Size dll_PyString_Size
  # define PyString_Type (*dll_PyString_Type)
+ # define PyUnicode_Type (*dll_PyUnicode_Type)
+ # define PyUnicodeUCS4_AsEncodedString (*dll_PyUnicodeUCS4_AsEncodedString)
+ # define PyFloat_AsDouble dll_PyFloat_AsDouble
+ # define PyFloat_FromDouble dll_PyFloat_FromDouble
+ # define PyFloat_Type (*dll_PyFloat_Type)
+ # define PyImport_AddModule (*dll_PyImport_AddModule)
  # define PySys_SetObject dll_PySys_SetObject
  # define PySys_SetArgv dll_PySys_SetArgv
  # define PyType_Type (*dll_PyType_Type)
***************
*** 179,186 ****
--- 209,218 ----
  # define Py_Finalize dll_Py_Finalize
  # define Py_IsInitialized dll_Py_IsInitialized
  # define _PyObject_New dll__PyObject_New
+ # define _PyObject_NextNotImplemented (*dll__PyObject_NextNotImplemented)
  # define _Py_NoneStruct (*dll__Py_NoneStruct)
  # define PyObject_Init dll__PyObject_Init
+ # define PyObject_GetIter dll_PyObject_GetIter
  # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02020000
  #  define PyType_IsSubtype dll_PyType_IsSubtype
  # endif
***************
*** 188,193 ****
--- 220,227 ----
  #  define PyObject_Malloc dll_PyObject_Malloc
  #  define PyObject_Free dll_PyObject_Free
  # endif
+ # define PyCapsule_New dll_PyCapsule_New
+ # define PyCapsule_GetPointer dll_PyCapsule_GetPointer
  
  /*
   * Pointers for dynamic link
***************
*** 195,200 ****
--- 229,235 ----
  static int(*dll_PyArg_Parse)(PyObject *, char *, ...);
  static int(*dll_PyArg_ParseTuple)(PyObject *, char *, ...);
  static int(*dll_PyMem_Free)(void *);
+ static void* (*dll_PyMem_Malloc)(size_t);
  static int(*dll_PyDict_SetItemString)(PyObject *dp, char *key, PyObject *item);
  static int(*dll_PyErr_BadArgument)(void);
  static void(*dll_PyErr_Clear)(void);
***************
*** 208,233 ****
  # ifdef PY_CAN_RECURSE
  static PyGILState_STATE	(*dll_PyGILState_Ensure)(void);
  static void (*dll_PyGILState_Release)(PyGILState_STATE);
! #endif
  static long(*dll_PyInt_AsLong)(PyObject *);
  static PyObject*(*dll_PyInt_FromLong)(long);
  static PyTypeObject* dll_PyInt_Type;
  static PyObject*(*dll_PyList_GetItem)(PyObject *, PyInt);
  static PyObject*(*dll_PyList_Append)(PyObject *, PyObject *);
  static PyObject*(*dll_PyList_New)(PyInt size);
  static int(*dll_PyList_SetItem)(PyObject *, PyInt, PyObject *);
  static PyInt(*dll_PyList_Size)(PyObject *);
  static PyTypeObject* dll_PyList_Type;
  static PyObject*(*dll_PyImport_ImportModule)(const char *);
  static PyObject*(*dll_PyDict_New)(void);
  static PyObject*(*dll_PyDict_GetItemString)(PyObject *, const char *);
  static PyObject*(*dll_PyModule_GetDict)(PyObject *);
  static int(*dll_PyRun_SimpleString)(char *);
  static char*(*dll_PyString_AsString)(PyObject *);
  static PyObject*(*dll_PyString_FromString)(const char *);
  static PyObject*(*dll_PyString_FromStringAndSize)(const char *, PyInt);
  static PyInt(*dll_PyString_Size)(PyObject *);
  static PyTypeObject* dll_PyString_Type;
  static int(*dll_PySys_SetObject)(char *, PyObject *);
  static int(*dll_PySys_SetArgv)(int, char **);
  static PyTypeObject* dll_PyType_Type;
--- 243,290 ----
  # ifdef PY_CAN_RECURSE
  static PyGILState_STATE	(*dll_PyGILState_Ensure)(void);
  static void (*dll_PyGILState_Release)(PyGILState_STATE);
! # endif
  static long(*dll_PyInt_AsLong)(PyObject *);
  static PyObject*(*dll_PyInt_FromLong)(long);
+ static long(*dll_PyLong_AsLong)(PyObject *);
+ static PyObject*(*dll_PyLong_FromLong)(long);
  static PyTypeObject* dll_PyInt_Type;
+ static PyTypeObject* dll_PyLong_Type;
  static PyObject*(*dll_PyList_GetItem)(PyObject *, PyInt);
  static PyObject*(*dll_PyList_Append)(PyObject *, PyObject *);
  static PyObject*(*dll_PyList_New)(PyInt size);
  static int(*dll_PyList_SetItem)(PyObject *, PyInt, PyObject *);
  static PyInt(*dll_PyList_Size)(PyObject *);
  static PyTypeObject* dll_PyList_Type;
+ static int (*dll_PySequence_Check)(PyObject *);
+ static PyInt(*dll_PySequence_Size)(PyObject *);
+ static PyObject*(*dll_PySequence_GetItem)(PyObject *, PyInt);
+ static PyInt(*dll_PyTuple_Size)(PyObject *);
+ static PyObject*(*dll_PyTuple_GetItem)(PyObject *, PyInt);
+ static PyTypeObject* dll_PyTuple_Type;
  static PyObject*(*dll_PyImport_ImportModule)(const char *);
  static PyObject*(*dll_PyDict_New)(void);
  static PyObject*(*dll_PyDict_GetItemString)(PyObject *, const char *);
+ static int (*dll_PyDict_Next)(PyObject *, Py_ssize_t *, PyObject **, PyObject **);
+ # ifndef PY_NO_MAPPING_ITEMS
+ static PyObject* (*dll_PyMapping_Items)(PyObject *);
+ # endif
+ static PyObject* (*dll_PyObject_CallMethod)(PyObject *, char *, PyObject *);
+ static int (*dll_PyMapping_Check)(PyObject *);
+ static PyObject* (*dll_PyIter_Next)(PyObject *);
  static PyObject*(*dll_PyModule_GetDict)(PyObject *);
  static int(*dll_PyRun_SimpleString)(char *);
+ static PyObject *(*dll_PyRun_String)(char *, int, PyObject *, PyObject *);
  static char*(*dll_PyString_AsString)(PyObject *);
  static PyObject*(*dll_PyString_FromString)(const char *);
  static PyObject*(*dll_PyString_FromStringAndSize)(const char *, PyInt);
  static PyInt(*dll_PyString_Size)(PyObject *);
  static PyTypeObject* dll_PyString_Type;
+ static PyTypeObject* dll_PyUnicode_Type;
+ static PyObject *(*PyUnicodeUCS4_AsEncodedString)(PyObject *, char *, char *);
+ static double(*dll_PyFloat_AsDouble)(PyObject *);
+ static PyObject*(*dll_PyFloat_FromDouble)(double);
+ static PyTypeObject* dll_PyFloat_Type;
  static int(*dll_PySys_SetObject)(char *, PyObject *);
  static int(*dll_PySys_SetArgv)(int, char **);
  static PyTypeObject* dll_PyType_Type;
***************
*** 235,246 ****
--- 292,306 ----
  static PyObject*(*dll_Py_BuildValue)(char *, ...);
  static PyObject*(*dll_Py_FindMethod)(struct PyMethodDef[], PyObject *, char *);
  static PyObject*(*dll_Py_InitModule4)(char *, struct PyMethodDef *, char *, PyObject *, int);
+ static PyObject*(*dll_PyImport_AddModule)(char *);
  static void(*dll_Py_SetPythonHome)(char *home);
  static void(*dll_Py_Initialize)(void);
  static void(*dll_Py_Finalize)(void);
  static int(*dll_Py_IsInitialized)(void);
  static PyObject*(*dll__PyObject_New)(PyTypeObject *, PyObject *);
  static PyObject*(*dll__PyObject_Init)(PyObject *, PyTypeObject *);
+ static PyObject* (*dll_PyObject_GetIter)(PyObject *);
+ static iternextfunc dll__PyObject_NextNotImplemented;
  static PyObject* dll__Py_NoneStruct;
  # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02020000
  static int (*dll_PyType_IsSubtype)(PyTypeObject *, PyTypeObject *);
***************
*** 249,254 ****
--- 309,316 ----
  static void* (*dll_PyObject_Malloc)(size_t);
  static void (*dll_PyObject_Free)(void*);
  # endif
+ static PyObject* (*dll_PyCapsule_New)(void *, char *, PyCapsule_Destructor);
+ static void* (*dll_PyCapsule_GetPointer)(PyObject *, char *);
  
  static HINSTANCE hinstPython = 0; /* Instance of python.dll */
  
***************
*** 278,283 ****
--- 340,346 ----
      {"PyArg_Parse", (PYTHON_PROC*)&dll_PyArg_Parse},
      {"PyArg_ParseTuple", (PYTHON_PROC*)&dll_PyArg_ParseTuple},
      {"PyMem_Free", (PYTHON_PROC*)&dll_PyMem_Free},
+     {"PyMem_Malloc", (PYTHON_PROC*)&dll_PyMem_Malloc},
      {"PyDict_SetItemString", (PYTHON_PROC*)&dll_PyDict_SetItemString},
      {"PyErr_BadArgument", (PYTHON_PROC*)&dll_PyErr_BadArgument},
      {"PyErr_Clear", (PYTHON_PROC*)&dll_PyErr_Clear},
***************
*** 294,316 ****
--- 357,402 ----
  # endif
      {"PyInt_AsLong", (PYTHON_PROC*)&dll_PyInt_AsLong},
      {"PyInt_FromLong", (PYTHON_PROC*)&dll_PyInt_FromLong},
+     {"PyLong_AsLong", (PYTHON_PROC*)&dll_PyLong_AsLong},
+     {"PyLong_FromLong", (PYTHON_PROC*)&dll_PyLong_FromLong},
      {"PyInt_Type", (PYTHON_PROC*)&dll_PyInt_Type},
+     {"PyLong_Type", (PYTHON_PROC*)&dll_PyLong_Type},
      {"PyList_GetItem", (PYTHON_PROC*)&dll_PyList_GetItem},
      {"PyList_Append", (PYTHON_PROC*)&dll_PyList_Append},
      {"PyList_New", (PYTHON_PROC*)&dll_PyList_New},
      {"PyList_SetItem", (PYTHON_PROC*)&dll_PyList_SetItem},
      {"PyList_Size", (PYTHON_PROC*)&dll_PyList_Size},
      {"PyList_Type", (PYTHON_PROC*)&dll_PyList_Type},
+     {"PySequence_GetItem", (PYTHON_PROC*)&dll_PySequence_GetItem},
+     {"PySequence_Size", (PYTHON_PROC*)&dll_PySequence_Size},
+     {"PySequence_Check", (PYTHON_PROC*)&dll_PySequence_Check},
+     {"PyTuple_GetItem", (PYTHON_PROC*)&dll_PyTuple_GetItem},
+     {"PyTuple_Size", (PYTHON_PROC*)&dll_PyTuple_Size},
+     {"PyTuple_Type", (PYTHON_PROC*)&dll_PyTuple_Type},
      {"PyImport_ImportModule", (PYTHON_PROC*)&dll_PyImport_ImportModule},
      {"PyDict_GetItemString", (PYTHON_PROC*)&dll_PyDict_GetItemString},
+     {"PyDict_Next", (PYTHON_PROC*)&dll_PyDict_Next},
      {"PyDict_New", (PYTHON_PROC*)&dll_PyDict_New},
+ # ifndef PY_NO_MAPPING_ITEMS
+     {"PyMapping_Items", (PYTHON_PROC*)&dll_PyMapping_Items},
+ # endif
+     {"PyObject_CallMethod", (PYTHON_PROC*)&dll_PyObject_CallMethod},
+     {"PyMapping_Check", (PYTHON_PROC*)&dll_PyMapping_Check},
+     {"PyIter_Next", (PYTHON_PROC*)&dll_PyIter_Next},
      {"PyModule_GetDict", (PYTHON_PROC*)&dll_PyModule_GetDict},
      {"PyRun_SimpleString", (PYTHON_PROC*)&dll_PyRun_SimpleString},
+     {"PyRun_String", (PYTHON_PROC*)&dll_PyRun_String},
      {"PyString_AsString", (PYTHON_PROC*)&dll_PyString_AsString},
      {"PyString_FromString", (PYTHON_PROC*)&dll_PyString_FromString},
      {"PyString_FromStringAndSize", (PYTHON_PROC*)&dll_PyString_FromStringAndSize},
      {"PyString_Size", (PYTHON_PROC*)&dll_PyString_Size},
      {"PyString_Type", (PYTHON_PROC*)&dll_PyString_Type},
+     {"PyUnicode_Type", (PYTHON_PROC*)&dll_PyUnicode_Type},
+     {"PyUnicodeUCS4_AsEncodedString", (PYTHON_PROC*)&dll_PyUnicodeUCS4_AsEncodedString},
+     {"PyFloat_Type", (PYTHON_PROC*)&dll_PyFloat_Type},
+     {"PyFloat_AsDouble", (PYTHON_PROC*)&dll_PyFloat_AsDouble},
+     {"PyFloat_FromDouble", (PYTHON_PROC*)&dll_PyFloat_FromDouble},
+     {"PyImport_AddModule", (PYTHON_PROC*)&dll_PyImport_AddModule},
      {"PySys_SetObject", (PYTHON_PROC*)&dll_PySys_SetObject},
      {"PySys_SetArgv", (PYTHON_PROC*)&dll_PySys_SetArgv},
      {"PyType_Type", (PYTHON_PROC*)&dll_PyType_Type},
***************
*** 328,333 ****
--- 414,421 ----
      {"Py_IsInitialized", (PYTHON_PROC*)&dll_Py_IsInitialized},
      {"_PyObject_New", (PYTHON_PROC*)&dll__PyObject_New},
      {"PyObject_Init", (PYTHON_PROC*)&dll__PyObject_Init},
+     {"PyObject_GetIter", (PYTHON_PROC*)&dll_PyObject_GetIter},
+     {"_PyObject_NextNotImplemented", (PYTHON_PROC*)&dll__PyObject_NextNotImplemented},
      {"_Py_NoneStruct", (PYTHON_PROC*)&dll__Py_NoneStruct},
  # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02020000
      {"PyType_IsSubtype", (PYTHON_PROC*)&dll_PyType_IsSubtype},
***************
*** 336,341 ****
--- 424,431 ----
      {"PyObject_Malloc", (PYTHON_PROC*)&dll_PyObject_Malloc},
      {"PyObject_Free", (PYTHON_PROC*)&dll_PyObject_Free},
  # endif
+     {"PyCapsule_New", (PYTHON_PROC*)&dll_PyCapsule_New},
+     {"PyCapsule_GetPointer", (PYTHON_PROC*)&dll_PyCapsule_GetPointer},
      {"", NULL},
  };
  
***************
*** 434,443 ****
--- 524,548 ----
  
  static PyObject *BufferNew (buf_T *);
  static PyObject *WindowNew(win_T *);
+ static PyObject *DictionaryNew(dict_T *);
  static PyObject *LineToString(const char *);
  
  static PyTypeObject RangeType;
  
+ static int initialised = 0;
+ #define PYINITIALISED initialised
+ 
+ /* Add conversion from PyInt? */
+ #define DICTKEY_GET(err) \
+     if (!PyString_Check(keyObject)) \
+     { \
+ 	PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
+ 	return err; \
+     } \
+     key = (char_u *) PyString_AsString(keyObject);
+ #define DICTKEY_UNREF
+ #define DICTKEY_DECL
+ 
  /*
   * Include the code shared with if_python3.c
   */
***************
*** 451,456 ****
--- 556,563 ----
  static PyInt RangeStart;
  static PyInt RangeEnd;
  
+ static PyObject *globals;
+ 
  static void PythonIO_Flush(void);
  static int PythonIO_Init(void);
  static int PythonMod_Init(void);
***************
*** 466,473 ****
   * 1. Python interpreter main program.
   */
  
- static int initialised = 0;
- 
  #if PYTHON_API_VERSION < 1007 /* Python 1.4 */
  typedef PyObject PyThreadState;
  #endif
--- 573,578 ----
***************
*** 581,586 ****
--- 686,693 ----
  	if (PythonMod_Init())
  	    goto fail;
  
+ 	globals = PyModule_GetDict(PyImport_AddModule("__main__"));
+ 
  	/* Remove the element from sys.path that was added because of our
  	 * argv[0] value in PythonMod_Init().  Previously we used an empty
  	 * string, but dependinding on the OS we then get an empty entry or
***************
*** 609,615 ****
   * External interface
   */
      static void
! DoPythonCommand(exarg_T *eap, const char *cmd)
  {
  #ifndef PY_CAN_RECURSE
      static int		recursive = 0;
--- 716,722 ----
   * External interface
   */
      static void
! DoPythonCommand(exarg_T *eap, const char *cmd, typval_T *rettv)
  {
  #ifndef PY_CAN_RECURSE
      static int		recursive = 0;
***************
*** 639,646 ****
      if (Python_Init())
  	goto theend;
  
!     RangeStart = eap->line1;
!     RangeEnd = eap->line2;
      Python_Release_Vim();	    /* leave vim */
  
  #if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
--- 746,761 ----
      if (Python_Init())
  	goto theend;
  
!     if (rettv == NULL)
!     {
! 	RangeStart = eap->line1;
! 	RangeEnd = eap->line2;
!     }
!     else
!     {
! 	RangeStart = (PyInt) curwin->w_cursor.lnum;
! 	RangeEnd = RangeStart;
!     }
      Python_Release_Vim();	    /* leave vim */
  
  #if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
***************
*** 658,664 ****
  
      Python_RestoreThread();	    /* enter python */
  
!     PyRun_SimpleString((char *)(cmd));
  
      Python_SaveThread();	    /* leave python */
  
--- 773,795 ----
  
      Python_RestoreThread();	    /* enter python */
  
!     if (rettv == NULL)
! 	PyRun_SimpleString((char *)(cmd));
!     else
!     {
! 	PyObject	*r;
! 
! 	r = PyRun_String((char *)(cmd), Py_eval_input, globals, globals);
! 	if (r == NULL)
! 	    EMSG(_("E858: Eval did not return a valid python object"));
! 	else
! 	{
! 	    if (ConvertFromPyObject(r, rettv) == -1)
! 		EMSG(_("E859: Failed to convert returned python object to vim value"));
! 	    Py_DECREF(r);
! 	}
! 	PyErr_Clear();
!     }
  
      Python_SaveThread();	    /* leave python */
  
***************
*** 680,686 ****
  #ifndef PY_CAN_RECURSE
      --recursive;
  #endif
!     return;	    /* keeps lint happy */
  }
  
  /*
--- 811,817 ----
  #ifndef PY_CAN_RECURSE
      --recursive;
  #endif
!     return;
  }
  
  /*
***************
*** 695,703 ****
      if (!eap->skip)
      {
  	if (script == NULL)
! 	    DoPythonCommand(eap, (char *)eap->arg);
  	else
! 	    DoPythonCommand(eap, (char *)script);
      }
      vim_free(script);
  }
--- 826,834 ----
      if (!eap->skip)
      {
  	if (script == NULL)
! 	    DoPythonCommand(eap, (char *)eap->arg, NULL);
  	else
! 	    DoPythonCommand(eap, (char *)script, NULL);
      }
      vim_free(script);
  }
***************
*** 743,749 ****
      *p++ = '\0';
  
      /* Execute the file */
!     DoPythonCommand(eap, buffer);
  }
  
  /******************************************************
--- 874,880 ----
      *p++ = '\0';
  
      /* Execute the file */
!     DoPythonCommand(eap, buffer, NULL);
  }
  
  /******************************************************
***************
*** 765,778 ****
      static int
  OutputSetattr(PyObject *self, char *name, PyObject *val)
  {
!     if (val == NULL) {
  	PyErr_SetString(PyExc_AttributeError, _("can't delete OutputObject attributes"));
  	return -1;
      }
  
      if (strcmp(name, "softspace") == 0)
      {
! 	if (!PyInt_Check(val)) {
  	    PyErr_SetString(PyExc_TypeError, _("softspace must be an integer"));
  	    return -1;
  	}
--- 896,911 ----
      static int
  OutputSetattr(PyObject *self, char *name, PyObject *val)
  {
!     if (val == NULL)
!     {
  	PyErr_SetString(PyExc_AttributeError, _("can't delete OutputObject attributes"));
  	return -1;
      }
  
      if (strcmp(name, "softspace") == 0)
      {
! 	if (!PyInt_Check(val))
! 	{
  	    PyErr_SetString(PyExc_TypeError, _("softspace must be an integer"));
  	    return -1;
  	}
***************
*** 800,805 ****
--- 933,941 ----
   * 3. Implementation of the Vim module for Python
   */
  
+ static PyObject *ConvertToPyObject(typval_T *);
+ static int ConvertFromPyObject(PyObject *, typval_T *);
+ 
  /* Window type - Implementation functions
   * --------------------------------------
   */
***************
*** 1441,1446 ****
--- 1577,1748 ----
      return result;
  }
  
+ static void DictionaryDestructor(PyObject *);
+ static PyObject *DictionaryGetattr(PyObject *, char*);
+ 
+ static PyMappingMethods DictionaryAsMapping = {
+     (PyInquiry)		DictionaryLength,
+     (binaryfunc)	DictionaryItem,
+     (objobjargproc)	DictionaryAssItem,
+ };
+ 
+ static PyTypeObject DictionaryType = {
+     PyObject_HEAD_INIT(0)
+     0,
+     "vimdictionary",
+     sizeof(DictionaryObject),
+     0,
+ 
+     (destructor)  DictionaryDestructor,
+     (printfunc)   0,
+     (getattrfunc) DictionaryGetattr,
+     (setattrfunc) 0,
+     (cmpfunc)     0,
+     (reprfunc)    0,
+ 
+     0,			    /* as number */
+     0,			    /* as sequence */
+     &DictionaryAsMapping,   /* as mapping */
+ 
+     (hashfunc)    0,
+     (ternaryfunc) 0,
+     (reprfunc)    0,
+ };
+ 
+     static void
+ DictionaryDestructor(PyObject *self)
+ {
+     DictionaryObject	*this = ((DictionaryObject *) (self));
+ 
+     pyll_remove(&this->ref, &lastdict);
+     dict_unref(this->dict);
+ 
+     Py_DECREF(self);
+ }
+ 
+     static PyObject *
+ DictionaryGetattr(PyObject *self, char *name)
+ {
+     return Py_FindMethod(DictionaryMethods, self, name);
+ }
+ 
+ static void ListDestructor(PyObject *);
+ static PyObject *ListGetattr(PyObject *, char *);
+ 
+ static PySequenceMethods ListAsSeq = {
+     (PyInquiry)			ListLength,
+     (binaryfunc)		0,
+     (PyIntArgFunc)		0,
+     (PyIntArgFunc)		ListItem,
+     (PyIntIntArgFunc)		ListSlice,
+     (PyIntObjArgProc)		ListAssItem,
+     (PyIntIntObjArgProc)	ListAssSlice,
+     (objobjproc)		0,
+ #if PY_MAJOR_VERSION >= 2
+     (binaryfunc)		ListConcatInPlace,
+     0,
+ #endif
+ };
+ 
+ static PyTypeObject ListType = {
+     PyObject_HEAD_INIT(0)
+     0,
+     "vimlist",
+     sizeof(ListObject),
+     0,
+ 
+     (destructor)  ListDestructor,
+     (printfunc)   0,
+     (getattrfunc) ListGetattr,
+     (setattrfunc) 0,
+     (cmpfunc)     0,
+     (reprfunc)    0,
+ 
+     0,			    /* as number */
+     &ListAsSeq,		    /* as sequence */
+     0,			    /* as mapping */
+ 
+     (hashfunc)    0,
+     (ternaryfunc) 0,
+     (reprfunc)    0,
+ };
+ 
+     static void
+ ListDestructor(PyObject *self)
+ {
+     ListObject	*this = ((ListObject *) (self));
+ 
+     pyll_remove(&this->ref, &lastlist);
+     list_unref(this->list);
+ 
+     Py_DECREF(self);
+ }
+ 
+     static PyObject *
+ ListGetattr(PyObject *self, char *name)
+ {
+     return Py_FindMethod(ListMethods, self, name);
+ }
+ 
+ static void FunctionDestructor(PyObject *);
+ static PyObject *FunctionGetattr(PyObject *, char *);
+ 
+ static PyTypeObject FunctionType = {
+     PyObject_HEAD_INIT(0)
+     0,
+     "vimfunction",
+     sizeof(FunctionObject),
+     0,
+ 
+     (destructor)  FunctionDestructor,
+     (printfunc)   0,
+     (getattrfunc) FunctionGetattr,
+     (setattrfunc) 0,
+     (cmpfunc)     0,
+     (reprfunc)    0,
+ 
+     0,			    /* as number */
+     0,			    /* as sequence */
+     0,			    /* as mapping */
+ 
+     (hashfunc)    0,
+     (ternaryfunc) FunctionCall,
+     (reprfunc)    0,
+ };
+ 
+     static void
+ FunctionDestructor(PyObject *self)
+ {
+     FunctionObject	*this = (FunctionObject *) (self);
+ 
+     func_unref(this->name);
+     PyMem_Del(this->name);
+ 
+     Py_DECREF(self);
+ }
+ 
+     static PyObject *
+ FunctionGetattr(PyObject *self, char *name)
+ {
+     FunctionObject	*this = (FunctionObject *)(self);
+ 
+     if (strcmp(name, "name") == 0)
+ 	return PyString_FromString((char *)(this->name));
+     else
+ 	return Py_FindMethod(FunctionMethods, self, name);
+ }
+ 
+     void
+ do_pyeval (char_u *str, typval_T *rettv)
+ {
+     DoPythonCommand(NULL, (char *) str, rettv);
+     switch(rettv->v_type)
+     {
+ 	case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break;
+ 	case VAR_LIST: ++rettv->vval.v_list->lv_refcount; break;
+ 	case VAR_FUNC: func_ref(rettv->vval.v_string);    break;
+     }
+ }
  
  /* Don't generate a prototype for the next function, it generates an error on
   * newer Python versions. */
***************
*** 1453,1458 ****
--- 1755,1766 ----
  }
  #endif /* Python 1.4 */
  
+     void
+ set_ref_in_python (int copyID)
+ {
+     set_ref_in_py(copyID);
+ }
+ 
      static void
  init_structs(void)
  {
*** ../vim-7.3.568/src/if_python3.c	2012-02-04 20:17:21.000000000 +0100
--- src/if_python3.c	2012-06-29 11:54:10.000000000 +0200
***************
*** 77,83 ****
  
  #define PyInt Py_ssize_t
  #define PyString_Check(obj) PyUnicode_Check(obj)
! #define PyString_AsBytes(obj) PyUnicode_AsEncodedString(obj, (char *)ENC_OPT, CODEC_ERROR_HANDLER);
  #define PyString_FreeBytes(obj) Py_XDECREF(bytes)
  #define PyString_AsString(obj) PyBytes_AsString(obj)
  #define PyString_Size(obj) PyBytes_GET_SIZE(bytes)
--- 77,83 ----
  
  #define PyInt Py_ssize_t
  #define PyString_Check(obj) PyUnicode_Check(obj)
! #define PyString_AsBytes(obj) PyUnicode_AsEncodedString(obj, (char *)ENC_OPT, CODEC_ERROR_HANDLER)
  #define PyString_FreeBytes(obj) Py_XDECREF(bytes)
  #define PyString_AsString(obj) PyBytes_AsString(obj)
  #define PyString_Size(obj) PyBytes_GET_SIZE(bytes)
***************
*** 109,114 ****
--- 109,115 ----
  # undef PyArg_ParseTuple
  # define PyArg_ParseTuple py3_PyArg_ParseTuple
  # define PyMem_Free py3_PyMem_Free
+ # define PyMem_Malloc py3_PyMem_Malloc
  # define PyDict_SetItemString py3_PyDict_SetItemString
  # define PyErr_BadArgument py3_PyErr_BadArgument
  # define PyErr_Clear py3_PyErr_Clear
***************
*** 128,141 ****
--- 129,155 ----
  # define PyList_New py3_PyList_New
  # define PyList_SetItem py3_PyList_SetItem
  # define PyList_Size py3_PyList_Size
+ # define PySequence_Check py3_PySequence_Check
+ # define PySequence_Size py3_PySequence_Size
+ # define PySequence_GetItem py3_PySequence_GetItem
+ # define PyTuple_Size py3_PyTuple_Size
+ # define PyTuple_GetItem py3_PyTuple_GetItem
  # define PySlice_GetIndicesEx py3_PySlice_GetIndicesEx
  # define PyImport_ImportModule py3_PyImport_ImportModule
+ # define PyImport_AddModule py3_PyImport_AddModule
  # define PyObject_Init py3__PyObject_Init
  # define PyDict_New py3_PyDict_New
  # define PyDict_GetItemString py3_PyDict_GetItemString
+ # define PyDict_Next py3_PyDict_Next
+ # define PyMapping_Check py3_PyMapping_Check
+ # define PyMapping_Items py3_PyMapping_Items
+ # define PyIter_Next py3_PyIter_Next
+ # define PyObject_GetIter py3_PyObject_GetIter
  # define PyModule_GetDict py3_PyModule_GetDict
  #undef PyRun_SimpleString
  # define PyRun_SimpleString py3_PyRun_SimpleString
+ #undef PyRun_String
+ # define PyRun_String py3_PyRun_String
  # define PySys_SetObject py3_PySys_SetObject
  # define PySys_SetArgv py3_PySys_SetArgv
  # define PyType_Type (*py3_PyType_Type)
***************
*** 147,152 ****
--- 161,167 ----
  # define Py_Finalize py3_Py_Finalize
  # define Py_IsInitialized py3_Py_IsInitialized
  # define _Py_NoneStruct (*py3__Py_NoneStruct)
+ # define _PyObject_NextNotImplemented (*py3__PyObject_NextNotImplemented)
  # define PyModule_AddObject py3_PyModule_AddObject
  # define PyImport_AppendInittab py3_PyImport_AppendInittab
  # define _PyUnicode_AsString py3__PyUnicode_AsString
***************
*** 154,161 ****
--- 169,181 ----
  # define PyUnicode_AsEncodedString py3_PyUnicode_AsEncodedString
  # undef PyBytes_AsString
  # define PyBytes_AsString py3_PyBytes_AsString
+ # undef PyBytes_FromString
+ # define PyBytes_FromString py3_PyBytes_FromString
+ # define PyFloat_FromDouble py3_PyFloat_FromDouble
+ # define PyFloat_AsDouble py3_PyFloat_AsDouble
  # define PyObject_GenericGetAttr py3_PyObject_GenericGetAttr
  # define PySlice_Type (*py3_PySlice_Type)
+ # define PyFloat_Type (*py3_PyFloat_Type)
  # define PyErr_NewException py3_PyErr_NewException
  # ifdef Py_DEBUG
  #  define _Py_NegativeRefcount py3__Py_NegativeRefcount
***************
*** 174,179 ****
--- 194,202 ----
  # define PyUnicode_FromString py3_PyUnicode_FromString
  # undef PyUnicode_Decode
  # define PyUnicode_Decode py3_PyUnicode_Decode
+ # define PyType_IsSubtype py3_PyType_IsSubtype
+ # define PyCapsule_New py3_PyCapsule_New
+ # define PyCapsule_GetPointer py3_PyCapsule_GetPointer
  
  # ifdef Py_DEBUG
  #  undef PyObject_NEW
***************
*** 194,215 ****
--- 217,250 ----
  static int (*py3_PySys_SetObject)(char *, PyObject *);
  static PyObject* (*py3_PyList_Append)(PyObject *, PyObject *);
  static Py_ssize_t (*py3_PyList_Size)(PyObject *);
+ static int (*py3_PySequence_Check)(PyObject *);
+ static Py_ssize_t (*py3_PySequence_Size)(PyObject *);
+ static PyObject* (*py3_PySequence_GetItem)(PyObject *, Py_ssize_t);
+ static Py_ssize_t (*py3_PyTuple_Size)(PyObject *);
+ static PyObject* (*py3_PyTuple_GetItem)(PyObject *, Py_ssize_t);
+ static int (*py3_PyMapping_Check)(PyObject *);
+ static PyObject* (*py3_PyMapping_Items)(PyObject *);
  static int (*py3_PySlice_GetIndicesEx)(PyObject *r, Py_ssize_t length,
  		     Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength);
  static PyObject* (*py3_PyErr_NoMemory)(void);
  static void (*py3_Py_Finalize)(void);
  static void (*py3_PyErr_SetString)(PyObject *, const char *);
  static int (*py3_PyRun_SimpleString)(char *);
+ static PyObject* (*py3_PyRun_String)(char *, int, PyObject *, PyObject *);
  static PyObject* (*py3_PyList_GetItem)(PyObject *, Py_ssize_t);
  static PyObject* (*py3_PyImport_ImportModule)(const char *);
+ static PyObject* (*py3_PyImport_AddModule)(const char *);
  static int (*py3_PyErr_BadArgument)(void);
  static PyTypeObject* py3_PyType_Type;
  static PyObject* (*py3_PyErr_Occurred)(void);
  static PyObject* (*py3_PyModule_GetDict)(PyObject *);
  static int (*py3_PyList_SetItem)(PyObject *, Py_ssize_t, PyObject *);
  static PyObject* (*py3_PyDict_GetItemString)(PyObject *, const char *);
+ static int (*py3_PyDict_Next)(PyObject *, Py_ssize_t *, PyObject **, PyObject **);
  static PyObject* (*py3_PyLong_FromLong)(long);
  static PyObject* (*py3_PyDict_New)(void);
+ static PyObject* (*py3_PyIter_Next)(PyObject *);
+ static PyObject* (*py3_PyObject_GetIter)(PyObject *);
  static PyObject* (*py3_Py_BuildValue)(char *, ...);
  static int (*py3_PyType_Ready)(PyTypeObject *type);
  static int (*py3_PyDict_SetItemString)(PyObject *dp, char *key, PyObject *item);
***************
*** 224,244 ****
--- 259,287 ----
  static int (*py3_PyArg_Parse)(PyObject *, char *, ...);
  static int (*py3_PyArg_ParseTuple)(PyObject *, char *, ...);
  static int (*py3_PyMem_Free)(void *);
+ static void* (*py3_PyMem_Malloc)(size_t);
  static int (*py3_Py_IsInitialized)(void);
  static void (*py3_PyErr_Clear)(void);
  static PyObject*(*py3__PyObject_Init)(PyObject *, PyTypeObject *);
+ static iternextfunc py3__PyObject_NextNotImplemented;
  static PyObject* py3__Py_NoneStruct;
  static int (*py3_PyModule_AddObject)(PyObject *m, const char *name, PyObject *o);
  static int (*py3_PyImport_AppendInittab)(const char *name, PyObject* (*initfunc)(void));
  static char* (*py3__PyUnicode_AsString)(PyObject *unicode);
  static PyObject* (*py3_PyUnicode_AsEncodedString)(PyObject *unicode, const char* encoding, const char* errors);
  static char* (*py3_PyBytes_AsString)(PyObject *bytes);
+ static PyObject* (*py3_PyBytes_FromString)(char *str);
+ static PyObject* (*py3_PyFloat_FromDouble)(double num);
+ static double (*py3_PyFloat_AsDouble)(PyObject *);
  static PyObject* (*py3_PyObject_GenericGetAttr)(PyObject *obj, PyObject *name);
  static PyObject* (*py3_PyModule_Create2)(struct PyModuleDef* module, int module_api_version);
  static PyObject* (*py3_PyType_GenericAlloc)(PyTypeObject *type, Py_ssize_t nitems);
  static PyObject* (*py3_PyType_GenericNew)(PyTypeObject *type, PyObject *args, PyObject *kwds);
  static PyTypeObject* py3_PySlice_Type;
+ static PyTypeObject* py3_PyFloat_Type;
  static PyObject* (*py3_PyErr_NewException)(char *name, PyObject *base, PyObject *dict);
+ static PyObject* (*py3_PyCapsule_New)(void *, char *, PyCapsule_Destructor);
+ static void* (*py3_PyCapsule_GetPointer)(PyObject *, char *);
  # ifdef Py_DEBUG
      static void (*py3__Py_NegativeRefcount)(const char *fname, int lineno, PyObject *op);
      static Py_ssize_t* py3__Py_RefTotal;
***************
*** 249,254 ****
--- 292,298 ----
      static void (*py3_PyObject_Free)(void*);
      static void* (*py3_PyObject_Malloc)(size_t);
  # endif
+ static int (*py3_PyType_IsSubtype)(PyTypeObject *, PyTypeObject *);
  
  static HINSTANCE hinstPy3 = 0; /* Instance of python.dll */
  
***************
*** 280,304 ****
--- 324,361 ----
      {"Py_Initialize", (PYTHON_PROC*)&py3_Py_Initialize},
      {"PyArg_ParseTuple", (PYTHON_PROC*)&py3_PyArg_ParseTuple},
      {"PyMem_Free", (PYTHON_PROC*)&py3_PyMem_Free},
+     {"PyMem_Malloc", (PYTHON_PROC*)&py3_PyMem_Malloc},
      {"PyList_New", (PYTHON_PROC*)&py3_PyList_New},
      {"PyGILState_Ensure", (PYTHON_PROC*)&py3_PyGILState_Ensure},
      {"PyGILState_Release", (PYTHON_PROC*)&py3_PyGILState_Release},
      {"PySys_SetObject", (PYTHON_PROC*)&py3_PySys_SetObject},
      {"PyList_Append", (PYTHON_PROC*)&py3_PyList_Append},
      {"PyList_Size", (PYTHON_PROC*)&py3_PyList_Size},
+     {"PySequence_Check", (PYTHON_PROC*)&py3_PySequence_Check},
+     {"PySequence_Size", (PYTHON_PROC*)&py3_PySequence_Size},
+     {"PySequence_GetItem", (PYTHON_PROC*)&py3_PySequence_GetItem},
+     {"PyTuple_Size", (PYTHON_PROC*)&py3_PyTuple_Size},
+     {"PyTuple_GetItem", (PYTHON_PROC*)&py3_PyTuple_GetItem},
      {"PySlice_GetIndicesEx", (PYTHON_PROC*)&py3_PySlice_GetIndicesEx},
      {"PyErr_NoMemory", (PYTHON_PROC*)&py3_PyErr_NoMemory},
      {"Py_Finalize", (PYTHON_PROC*)&py3_Py_Finalize},
      {"PyErr_SetString", (PYTHON_PROC*)&py3_PyErr_SetString},
      {"PyRun_SimpleString", (PYTHON_PROC*)&py3_PyRun_SimpleString},
+     {"PyRun_String", (PYTHON_PROC*)&py3_PyRun_String},
      {"PyList_GetItem", (PYTHON_PROC*)&py3_PyList_GetItem},
      {"PyImport_ImportModule", (PYTHON_PROC*)&py3_PyImport_ImportModule},
+     {"PyImport_AddModule", (PYTHON_PROC*)&py3_PyImport_AddModule},
      {"PyErr_BadArgument", (PYTHON_PROC*)&py3_PyErr_BadArgument},
      {"PyType_Type", (PYTHON_PROC*)&py3_PyType_Type},
      {"PyErr_Occurred", (PYTHON_PROC*)&py3_PyErr_Occurred},
      {"PyModule_GetDict", (PYTHON_PROC*)&py3_PyModule_GetDict},
      {"PyList_SetItem", (PYTHON_PROC*)&py3_PyList_SetItem},
      {"PyDict_GetItemString", (PYTHON_PROC*)&py3_PyDict_GetItemString},
+     {"PyDict_Next", (PYTHON_PROC*)&py3_PyDict_Next},
+     {"PyMapping_Check", (PYTHON_PROC*)&py3_PyMapping_Check},
+     {"PyMapping_Items", (PYTHON_PROC*)&py3_PyMapping_Items},
+     {"PyIter_Next", (PYTHON_PROC*)&py3_PyIter_Next},
+     {"PyObject_GetIter", (PYTHON_PROC*)&py3_PyObject_GetIter},
      {"PyLong_FromLong", (PYTHON_PROC*)&py3_PyLong_FromLong},
      {"PyDict_New", (PYTHON_PROC*)&py3_PyDict_New},
      {"Py_BuildValue", (PYTHON_PROC*)&py3_Py_BuildValue},
***************
*** 311,316 ****
--- 368,374 ----
      {"PyEval_SaveThread", (PYTHON_PROC*)&py3_PyEval_SaveThread},
      {"PyArg_Parse", (PYTHON_PROC*)&py3_PyArg_Parse},
      {"Py_IsInitialized", (PYTHON_PROC*)&py3_Py_IsInitialized},
+     {"_PyObject_NextNotImplemented", (PYTHON_PROC*)&py3__PyObject_NextNotImplemented},
      {"_Py_NoneStruct", (PYTHON_PROC*)&py3__Py_NoneStruct},
      {"PyErr_Clear", (PYTHON_PROC*)&py3_PyErr_Clear},
      {"PyObject_Init", (PYTHON_PROC*)&py3__PyObject_Init},
***************
*** 318,328 ****
--- 376,390 ----
      {"PyImport_AppendInittab", (PYTHON_PROC*)&py3_PyImport_AppendInittab},
      {"_PyUnicode_AsString", (PYTHON_PROC*)&py3__PyUnicode_AsString},
      {"PyBytes_AsString", (PYTHON_PROC*)&py3_PyBytes_AsString},
+     {"PyBytes_FromString", (PYTHON_PROC*)&py3_PyBytes_FromString},
+     {"PyFloat_FromDouble", (PYTHON_PROC*)&py3_PyFloat_FromDouble},
+     {"PyFloat_AsDouble", (PYTHON_PROC*)&py3_PyFloat_AsDouble},
      {"PyObject_GenericGetAttr", (PYTHON_PROC*)&py3_PyObject_GenericGetAttr},
      {"PyModule_Create2", (PYTHON_PROC*)&py3_PyModule_Create2},
      {"PyType_GenericAlloc", (PYTHON_PROC*)&py3_PyType_GenericAlloc},
      {"PyType_GenericNew", (PYTHON_PROC*)&py3_PyType_GenericNew},
      {"PySlice_Type", (PYTHON_PROC*)&py3_PySlice_Type},
+     {"PyFloat_Type", (PYTHON_PROC*)&py3_PyFloat_Type},
      {"PyErr_NewException", (PYTHON_PROC*)&py3_PyErr_NewException},
  # ifdef Py_DEBUG
      {"_Py_NegativeRefcount", (PYTHON_PROC*)&py3__Py_NegativeRefcount},
***************
*** 334,339 ****
--- 396,404 ----
      {"PyObject_Malloc", (PYTHON_PROC*)&py3_PyObject_Malloc},
      {"PyObject_Free", (PYTHON_PROC*)&py3_PyObject_Free},
  # endif
+     {"PyType_IsSubtype", (PYTHON_PROC*)&py3_PyType_IsSubtype},
+     {"PyCapsule_New", (PYTHON_PROC*)&py3_PyCapsule_New},
+     {"PyCapsule_GetPointer", (PYTHON_PROC*)&py3_PyCapsule_GetPointer},
      {"", NULL},
  };
  
***************
*** 472,482 ****
--- 537,577 ----
  
  static PyTypeObject RangeType;
  
+ static int py3initialised = 0;
+ 
+ #define PYINITIALISED py3initialised
+ 
+ /* Add conversion from PyInt? */
+ #define DICTKEY_GET(err) \
+     if (PyBytes_Check(keyObject)) \
+ 	key = (char_u *) PyBytes_AsString(keyObject); \
+     else if (PyUnicode_Check(keyObject)) \
+     { \
+ 	bytes = PyString_AsBytes(keyObject); \
+ 	if (bytes == NULL) \
+ 	    return err; \
+ 	key = (char_u *) PyBytes_AsString(bytes); \
+ 	if (key == NULL) \
+ 	    return err; \
+     } \
+     else \
+     { \
+ 	PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
+ 	return err; \
+     }
+ #define DICTKEY_UNREF \
+     if (bytes != NULL) \
+ 	Py_XDECREF(bytes);
+ 
+ #define DICTKEY_DECL PyObject *bytes = NULL;
+ 
  /*
   * Include the code shared with if_python.c
   */
  #include "if_py_both.h"
  
+ #define PY3OBJ_DELETED(obj) (obj->ob_base.ob_refcnt<=0)
+ 
      static void
  call_PyObject_Free(void *p)
  {
***************
*** 506,511 ****
--- 601,608 ----
  static Py_ssize_t RangeStart;
  static Py_ssize_t RangeEnd;
  
+ static PyObject *globals;
+ 
  static int PythonIO_Init(void);
  static void PythonIO_Fini(void);
  PyMODINIT_FUNC Py3Init_vim(void);
***************
*** 514,521 ****
   * 1. Python interpreter main program.
   */
  
- static int py3initialised = 0;
- 
  static PyGILState_STATE pygilstate = PyGILState_UNLOCKED;
  
      void
--- 611,616 ----
***************
*** 593,598 ****
--- 688,695 ----
  
  	PyImport_AppendInittab("vim", Py3Init_vim);
  
+ 	globals = PyModule_GetDict(PyImport_AddModule("__main__"));
+ 
  	/* Remove the element from sys.path that was added because of our
  	 * argv[0] value in Py3Init_vim().  Previously we used an empty
  	 * string, but dependinding on the OS we then get an empty entry or
***************
*** 629,635 ****
   * External interface
   */
      static void
! DoPy3Command(exarg_T *eap, const char *cmd)
  {
  #if defined(MACOS) && !defined(MACOS_X_UNIX)
      GrafPtr		oldPort;
--- 726,732 ----
   * External interface
   */
      static void
! DoPy3Command(exarg_T *eap, const char *cmd, typval_T *rettv)
  {
  #if defined(MACOS) && !defined(MACOS_X_UNIX)
      GrafPtr		oldPort;
***************
*** 649,656 ****
      if (Python3_Init())
  	goto theend;
  
!     RangeStart = eap->line1;
!     RangeEnd = eap->line2;
      Python_Release_Vim();	    /* leave vim */
  
  #if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
--- 746,761 ----
      if (Python3_Init())
  	goto theend;
  
!     if (rettv == NULL)
!     {
! 	RangeStart = eap->line1;
! 	RangeEnd = eap->line2;
!     }
!     else
!     {
! 	RangeStart = (PyInt) curwin->w_cursor.lnum;
! 	RangeEnd = RangeStart;
!     }
      Python_Release_Vim();	    /* leave vim */
  
  #if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
***************
*** 674,680 ****
  					(char *)ENC_OPT, CODEC_ERROR_HANDLER);
      cmdbytes = PyUnicode_AsEncodedString(cmdstr, "utf-8", CODEC_ERROR_HANDLER);
      Py_XDECREF(cmdstr);
!     PyRun_SimpleString(PyBytes_AsString(cmdbytes));
      Py_XDECREF(cmdbytes);
  
      PyGILState_Release(pygilstate);
--- 779,802 ----
  					(char *)ENC_OPT, CODEC_ERROR_HANDLER);
      cmdbytes = PyUnicode_AsEncodedString(cmdstr, "utf-8", CODEC_ERROR_HANDLER);
      Py_XDECREF(cmdstr);
!     if (rettv == NULL)
! 	PyRun_SimpleString(PyBytes_AsString(cmdbytes));
!     else
!     {
! 	PyObject	*r;
! 
! 	r = PyRun_String(PyBytes_AsString(cmdbytes), Py_eval_input,
! 			 globals, globals);
! 	if (r == NULL)
! 	    EMSG(_("E860: Eval did not return a valid python 3 object"));
! 	else
! 	{
! 	    if (ConvertFromPyObject(r, rettv) == -1)
! 		EMSG(_("E861: Failed to convert returned python 3 object to vim value"));
! 	    Py_DECREF(r);
! 	}
! 	PyErr_Clear();
!     }
      Py_XDECREF(cmdbytes);
  
      PyGILState_Release(pygilstate);
***************
*** 709,717 ****
      if (!eap->skip)
      {
  	if (script == NULL)
! 	    DoPy3Command(eap, (char *)eap->arg);
  	else
! 	    DoPy3Command(eap, (char *)script);
      }
      vim_free(script);
  }
--- 831,839 ----
      if (!eap->skip)
      {
  	if (script == NULL)
! 	    DoPy3Command(eap, (char *)eap->arg, NULL);
  	else
! 	    DoPy3Command(eap, (char *)script, NULL);
      }
      vim_free(script);
  }
***************
*** 772,778 ****
  
  
      /* Execute the file */
!     DoPy3Command(eap, buffer);
  }
  
  /******************************************************
--- 894,900 ----
  
  
      /* Execute the file */
!     DoPy3Command(eap, buffer, NULL);
  }
  
  /******************************************************
***************
*** 802,815 ****
      if (PyUnicode_Check(nameobj))
  	name = _PyUnicode_AsString(nameobj);
  
!     if (val == NULL) {
  	PyErr_SetString(PyExc_AttributeError, _("can't delete OutputObject attributes"));
  	return -1;
      }
  
      if (strcmp(name, "softspace") == 0)
      {
! 	if (!PyLong_Check(val)) {
  	    PyErr_SetString(PyExc_TypeError, _("softspace must be an integer"));
  	    return -1;
  	}
--- 924,939 ----
      if (PyUnicode_Check(nameobj))
  	name = _PyUnicode_AsString(nameobj);
  
!     if (val == NULL)
!     {
  	PyErr_SetString(PyExc_AttributeError, _("can't delete OutputObject attributes"));
  	return -1;
      }
  
      if (strcmp(name, "softspace") == 0)
      {
! 	if (!PyLong_Check(val))
! 	{
  	    PyErr_SetString(PyExc_TypeError, _("softspace must be an integer"));
  	    return -1;
  	}
***************
*** 1030,1049 ****
      static PyObject *
  BufferSubscript(PyObject *self, PyObject* idx)
  {
!     if (PyLong_Check(idx)) {
  	long _idx = PyLong_AsLong(idx);
  	return BufferItem(self,_idx);
!     } else if (PySlice_Check(idx)) {
  	Py_ssize_t start, stop, step, slicelen;
  
  	if (PySlice_GetIndicesEx((PyObject *)idx,
  	      (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
  	      &start, &stop,
! 	      &step, &slicelen) < 0) {
  	    return NULL;
  	}
  	return BufferSlice(self, start, stop);
!     } else {
  	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  	return NULL;
      }
--- 1154,1178 ----
      static PyObject *
  BufferSubscript(PyObject *self, PyObject* idx)
  {
!     if (PyLong_Check(idx))
!     {
  	long _idx = PyLong_AsLong(idx);
  	return BufferItem(self,_idx);
!     } else if (PySlice_Check(idx))
!     {
  	Py_ssize_t start, stop, step, slicelen;
  
  	if (PySlice_GetIndicesEx((PyObject *)idx,
  	      (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
  	      &start, &stop,
! 	      &step, &slicelen) < 0)
! 	{
  	    return NULL;
  	}
  	return BufferSlice(self, start, stop);
!     }
!     else
!     {
  	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  	return NULL;
      }
***************
*** 1052,1075 ****
      static Py_ssize_t
  BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val)
  {
!     if (PyLong_Check(idx)) {
  	long n = PyLong_AsLong(idx);
  	return RBAsItem((BufferObject *)(self), n, val, 1,
  		    (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
  		    NULL);
!     } else if (PySlice_Check(idx)) {
  	Py_ssize_t start, stop, step, slicelen;
  
  	if (PySlice_GetIndicesEx((PyObject *)idx,
  	      (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
  	      &start, &stop,
! 	      &step, &slicelen) < 0) {
  	    return -1;
  	}
  	return RBAsSlice((BufferObject *)(self), start, stop, val, 1,
  			  (PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count,
  			  NULL);
!     } else {
  	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  	return -1;
      }
--- 1181,1209 ----
      static Py_ssize_t
  BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val)
  {
!     if (PyLong_Check(idx))
!     {
  	long n = PyLong_AsLong(idx);
  	return RBAsItem((BufferObject *)(self), n, val, 1,
  		    (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
  		    NULL);
!     } else if (PySlice_Check(idx))
!     {
  	Py_ssize_t start, stop, step, slicelen;
  
  	if (PySlice_GetIndicesEx((PyObject *)idx,
  	      (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
  	      &start, &stop,
! 	      &step, &slicelen) < 0)
! 	{
  	    return -1;
  	}
  	return RBAsSlice((BufferObject *)(self), start, stop, val, 1,
  			  (PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count,
  			  NULL);
!     }
!     else
!     {
  	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  	return -1;
      }
***************
*** 1142,1161 ****
      static PyObject *
  RangeSubscript(PyObject *self, PyObject* idx)
  {
!     if (PyLong_Check(idx)) {
  	long _idx = PyLong_AsLong(idx);
  	return RangeItem(self,_idx);
!     } else if (PySlice_Check(idx)) {
  	Py_ssize_t start, stop, step, slicelen;
  
  	if (PySlice_GetIndicesEx((PyObject *)idx,
  		((RangeObject *)(self))->end-((RangeObject *)(self))->start+1,
  		&start, &stop,
! 		&step, &slicelen) < 0) {
  	    return NULL;
  	}
  	return RangeSlice(self, start, stop);
!     } else {
  	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  	return NULL;
      }
--- 1276,1300 ----
      static PyObject *
  RangeSubscript(PyObject *self, PyObject* idx)
  {
!     if (PyLong_Check(idx))
!     {
  	long _idx = PyLong_AsLong(idx);
  	return RangeItem(self,_idx);
!     } else if (PySlice_Check(idx))
!     {
  	Py_ssize_t start, stop, step, slicelen;
  
  	if (PySlice_GetIndicesEx((PyObject *)idx,
  		((RangeObject *)(self))->end-((RangeObject *)(self))->start+1,
  		&start, &stop,
! 		&step, &slicelen) < 0)
! 	{
  	    return NULL;
  	}
  	return RangeSlice(self, start, stop);
!     }
!     else
!     {
  	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  	return NULL;
      }
***************
*** 1164,1183 ****
      static Py_ssize_t
  RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val)
  {
!     if (PyLong_Check(idx)) {
  	long n = PyLong_AsLong(idx);
  	return RangeAsItem(self, n, val);
!     } else if (PySlice_Check(idx)) {
  	Py_ssize_t start, stop, step, slicelen;
  
  	if (PySlice_GetIndicesEx((PyObject *)idx,
  		((RangeObject *)(self))->end-((RangeObject *)(self))->start+1,
  		&start, &stop,
! 		&step, &slicelen) < 0) {
  	    return -1;
  	}
  	return RangeAsSlice(self, start, stop, val);
!     } else {
  	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  	return -1;
      }
--- 1303,1327 ----
      static Py_ssize_t
  RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val)
  {
!     if (PyLong_Check(idx))
!     {
  	long n = PyLong_AsLong(idx);
  	return RangeAsItem(self, n, val);
!     } else if (PySlice_Check(idx))
!     {
  	Py_ssize_t start, stop, step, slicelen;
  
  	if (PySlice_GetIndicesEx((PyObject *)idx,
  		((RangeObject *)(self))->end-((RangeObject *)(self))->start+1,
  		&start, &stop,
! 		&step, &slicelen) < 0)
! 	{
  	    return -1;
  	}
  	return RangeAsSlice(self, start, stop, val);
!     }
!     else
!     {
  	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  	return -1;
      }
***************
*** 1390,1395 ****
--- 1534,1680 ----
      }
  }
  
+ /* Dictionary object - Definitions
+  */
+ 
+ static PyInt DictionaryLength(PyObject *);
+ 
+ static PyMappingMethods DictionaryAsMapping = {
+     /* mp_length	*/ (lenfunc) DictionaryLength,
+     /* mp_subscript     */ (binaryfunc) DictionaryItem,
+     /* mp_ass_subscript */ (objobjargproc) DictionaryAssItem,
+ };
+ 
+ static PyTypeObject DictionaryType;
+ 
+     static void
+ DictionaryDestructor(PyObject *self)
+ {
+     DictionaryObject *this = (DictionaryObject *)(self);
+ 
+     pyll_remove(&this->ref, &lastdict);
+     dict_unref(this->dict);
+ 
+     Py_TYPE(self)->tp_free((PyObject*)self);
+ }
+ 
+ /* List object - Definitions
+  */
+ 
+ static PyInt ListLength(PyObject *);
+ static PyObject *ListItem(PyObject *, Py_ssize_t);
+ 
+ static PySequenceMethods ListAsSeq = {
+     (lenfunc)		ListLength,	 /* sq_length,	  len(x)   */
+     (binaryfunc)	0,		 /* RangeConcat, sq_concat,  x+y   */
+     (ssizeargfunc)	0,		 /* RangeRepeat, sq_repeat,  x*n   */
+     (ssizeargfunc)	ListItem,	 /* sq_item,	  x[i]	   */
+     (void *)		0,		 /* was_sq_slice,     x[i:j]   */
+     (ssizeobjargproc)	ListAssItem,	 /* sq_as_item,  x[i]=v   */
+     (void *)		0,		 /* was_sq_ass_slice, x[i:j]=v */
+     0,					 /* sq_contains */
+     (binaryfunc)	ListConcatInPlace,/* sq_inplace_concat */
+     0,					 /* sq_inplace_repeat */
+ };
+ 
+ static PyObject *ListSubscript(PyObject *, PyObject *);
+ static Py_ssize_t ListAsSubscript(PyObject *, PyObject *, PyObject *);
+ 
+ static PyMappingMethods ListAsMapping = {
+     /* mp_length	*/ (lenfunc) ListLength,
+     /* mp_subscript     */ (binaryfunc) ListSubscript,
+     /* mp_ass_subscript */ (objobjargproc) ListAsSubscript,
+ };
+ 
+ static PyTypeObject ListType;
+ 
+     static PyObject *
+ ListSubscript(PyObject *self, PyObject* idxObject)
+ {
+     if (PyLong_Check(idxObject))
+     {
+ 	long idx = PyLong_AsLong(idxObject);
+ 	return ListItem(self, idx);
+     }
+     else if (PySlice_Check(idxObject))
+     {
+ 	Py_ssize_t start, stop, step, slicelen;
+ 
+ 	if (PySlice_GetIndicesEx(idxObject, ListLength(self), &start, &stop,
+ 				 &step, &slicelen) < 0)
+ 	    return NULL;
+ 	return ListSlice(self, start, stop);
+     }
+     else
+     {
+ 	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
+ 	return NULL;
+     }
+ }
+ 
+     static Py_ssize_t
+ ListAsSubscript(PyObject *self, PyObject *idxObject, PyObject *obj)
+ {
+     if (PyLong_Check(idxObject))
+     {
+ 	long idx = PyLong_AsLong(idxObject);
+ 	return ListAssItem(self, idx, obj);
+     }
+     else if (PySlice_Check(idxObject))
+     {
+ 	Py_ssize_t start, stop, step, slicelen;
+ 
+ 	if (PySlice_GetIndicesEx(idxObject, ListLength(self), &start, &stop,
+ 				 &step, &slicelen) < 0)
+ 	    return -1;
+ 	return ListAssSlice(self, start, stop, obj);
+     }
+     else
+     {
+ 	PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
+ 	return -1;
+     }
+ }
+ 
+     static void
+ ListDestructor(PyObject *self)
+ {
+     ListObject *this = (ListObject *)(self);
+ 
+     pyll_remove(&this->ref, &lastlist);
+     list_unref(this->list);
+ 
+     Py_TYPE(self)->tp_free((PyObject*)self);
+ }
+ 
+ /* Function object - Definitions
+  */
+ 
+     static void
+ FunctionDestructor(PyObject *self)
+ {
+     FunctionObject	*this = (FunctionObject *) (self);
+ 
+     func_unref(this->name);
+     PyMem_Del(this->name);
+ 
+     Py_TYPE(self)->tp_free((PyObject*)self);
+ }
+ 
+     static PyObject *
+ FunctionGetattro(PyObject *self, PyObject *nameobj)
+ {
+     FunctionObject	*this = (FunctionObject *)(self);
+     char	*name = "";
+     if (PyUnicode_Check(nameobj))
+ 	name = _PyUnicode_AsString(nameobj);
+ 
+     if (strcmp(name, "name") == 0)
+ 	return PyUnicode_FromString((char *)(this->name));
+ 
+     return PyObject_GenericGetAttr(self, nameobj);
+ }
+ 
  /* External interface
   */
  
***************
*** 1449,1454 ****
--- 1734,1742 ----
      PyType_Ready(&BufListType);
      PyType_Ready(&WinListType);
      PyType_Ready(&CurrentType);
+     PyType_Ready(&DictionaryType);
+     PyType_Ready(&ListType);
+     PyType_Ready(&FunctionType);
  
      /* Set sys.argv[] to avoid a crash in warn(). */
      PySys_SetArgv(1, argv);
***************
*** 1517,1522 ****
--- 1805,1828 ----
      return result;
  }
  
+     void
+ do_py3eval (char_u *str, typval_T *rettv)
+ {
+     DoPy3Command(NULL, (char *) str, rettv);
+     switch(rettv->v_type)
+     {
+ 	case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break;
+ 	case VAR_LIST: ++rettv->vval.v_list->lv_refcount; break;
+ 	case VAR_FUNC: func_ref(rettv->vval.v_string);    break;
+     }
+ }
+ 
+     void
+ set_ref_in_python3 (int copyID)
+ {
+     set_ref_in_py(copyID);
+ }
+ 
      static void
  init_structs(void)
  {
***************
*** 1598,1603 ****
--- 1904,1938 ----
      CurrentType.tp_flags = Py_TPFLAGS_DEFAULT;
      CurrentType.tp_doc = "vim current object";
  
+     vim_memset(&DictionaryType, 0, sizeof(DictionaryType));
+     DictionaryType.tp_name = "vim.dictionary";
+     DictionaryType.tp_basicsize = sizeof(DictionaryObject);
+     DictionaryType.tp_dealloc = DictionaryDestructor;
+     DictionaryType.tp_as_mapping = &DictionaryAsMapping;
+     DictionaryType.tp_flags = Py_TPFLAGS_DEFAULT;
+     DictionaryType.tp_doc = "dictionary pushing modifications to vim structure";
+     DictionaryType.tp_methods = DictionaryMethods;
+ 
+     vim_memset(&ListType, 0, sizeof(ListType));
+     ListType.tp_name = "vim.list";
+     ListType.tp_dealloc = ListDestructor;
+     ListType.tp_basicsize = sizeof(ListObject);
+     ListType.tp_as_sequence = &ListAsSeq;
+     ListType.tp_as_mapping = &ListAsMapping;
+     ListType.tp_flags = Py_TPFLAGS_DEFAULT;
+     ListType.tp_doc = "list pushing modifications to vim structure";
+     ListType.tp_methods = ListMethods;
+ 
+     vim_memset(&FunctionType, 0, sizeof(FunctionType));
+     FunctionType.tp_name = "vim.list";
+     FunctionType.tp_basicsize = sizeof(FunctionObject);
+     FunctionType.tp_getattro = FunctionGetattro;
+     FunctionType.tp_dealloc = FunctionDestructor;
+     FunctionType.tp_call = FunctionCall;
+     FunctionType.tp_flags = Py_TPFLAGS_DEFAULT;
+     FunctionType.tp_doc = "object that calls vim function";
+     FunctionType.tp_methods = FunctionMethods;
+ 
      vim_memset(&vimmodule, 0, sizeof(vimmodule));
      vimmodule.m_name = "vim";
      vimmodule.m_doc = vim_module_doc;
*** ../vim-7.3.568/src/proto/eval.pro	2011-09-14 16:52:02.000000000 +0200
--- src/proto/eval.pro	2012-06-20 18:20:28.000000000 +0200
***************
*** 46,57 ****
--- 46,66 ----
  list_T *list_alloc __ARGS((void));
  void list_unref __ARGS((list_T *l));
  void list_free __ARGS((list_T *l, int recurse));
+ listitem_T *listitem_alloc __ARGS((void));
+ void listitem_remove __ARGS((list_T *l, listitem_T *item));
  dictitem_T *dict_lookup __ARGS((hashitem_T *hi));
+ listitem_T *list_find __ARGS((list_T *l, long n));
  char_u *list_find_str __ARGS((list_T *l, long idx));
+ void list_append __ARGS((list_T *l, listitem_T *item));
  int list_append_tv __ARGS((list_T *l, typval_T *tv));
  int list_append_dict __ARGS((list_T *list, dict_T *dict));
  int list_append_string __ARGS((list_T *l, char_u *str, int len));
+ int list_insert_tv __ARGS((list_T *l, typval_T *tv, listitem_T *item));
+ void list_remove __ARGS((list_T *l, listitem_T *item, listitem_T *item2));
  int garbage_collect __ARGS((void));
+ void set_ref_in_ht __ARGS((hashtab_T *ht, int copyID));
+ void set_ref_in_list __ARGS((list_T *l, int copyID));
+ void set_ref_in_item __ARGS((typval_T *tv, int copyID));
  dict_T *dict_alloc __ARGS((void));
  void dict_unref __ARGS((dict_T *d));
  dictitem_T *dictitem_alloc __ARGS((char_u *key));
***************
*** 64,69 ****
--- 73,79 ----
  long get_dict_number __ARGS((dict_T *d, char_u *key));
  char_u *get_function_name __ARGS((expand_T *xp, int idx));
  char_u *get_expr_name __ARGS((expand_T *xp, int idx));
+ int func_call __ARGS((char_u *name, typval_T *args, dict_T *selfdict, typval_T *rettv));
  long do_searchpair __ARGS((char_u *spat, char_u *mpat, char_u *epat, int dir, char_u *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long time_limit));
  void set_vim_var_nr __ARGS((int idx, long val));
  long get_vim_var_nr __ARGS((int idx));
***************
*** 94,99 ****
--- 104,111 ----
  void func_dump_profile __ARGS((FILE *fd));
  char_u *get_user_func_name __ARGS((expand_T *xp, int idx));
  void ex_delfunction __ARGS((exarg_T *eap));
+ void func_unref __ARGS((char_u *name));
+ void func_ref __ARGS((char_u *name));
  void ex_return __ARGS((exarg_T *eap));
  int do_return __ARGS((exarg_T *eap, int reanimate, int is_cmd, void *rettv));
  void discard_pending_return __ARGS((void *rettv));
*** ../vim-7.3.568/src/proto/if_python.pro	2010-08-15 21:57:28.000000000 +0200
--- src/proto/if_python.pro	2012-06-20 18:23:06.000000000 +0200
***************
*** 6,9 ****
--- 6,11 ----
  void ex_pyfile __ARGS((exarg_T *eap));
  void python_buffer_free __ARGS((buf_T *buf));
  void python_window_free __ARGS((win_T *win));
+ void do_pyeval __ARGS((char_u *str, typval_T *rettv));
+ void set_ref_in_python __ARGS((int copyID));
  /* vim: set ft=c : */
*** ../vim-7.3.568/src/proto/if_python3.pro	2010-08-15 21:57:28.000000000 +0200
--- src/proto/if_python3.pro	2012-06-20 18:34:26.000000000 +0200
***************
*** 6,9 ****
--- 6,11 ----
  void ex_py3file __ARGS((exarg_T *eap));
  void python3_buffer_free __ARGS((buf_T *buf));
  void python3_window_free __ARGS((win_T *win));
+ void do_py3eval __ARGS((char_u *str, typval_T *rettv));
+ void set_ref_in_python3 __ARGS((int copyID));
  /* vim: set ft=c : */
*** ../vim-7.3.568/src/testdir/Make_amiga.mak	2012-04-05 16:56:38.000000000 +0200
--- src/testdir/Make_amiga.mak	2012-06-20 18:43:05.000000000 +0200
***************
*** 14,19 ****
--- 14,20 ----
  # test27	can't edit file with "*"
  # test52	only for Win32
  # test85	no Lua interface
+ # test86, 87	no Python interface
  
  SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
  		test7.out test8.out test9.out \
*** ../vim-7.3.568/src/testdir/Make_dos.mak	2012-04-13 19:11:16.000000000 +0200
--- src/testdir/Make_dos.mak	2012-06-20 18:43:45.000000000 +0200
***************
*** 30,36 ****
  		test68.out test69.out test71.out test72.out test73.out \
  		test74.out test75.out test76.out test77.out test78.out \
  		test79.out test80.out test81.out test82.out test83.out \
! 		test84.out test85.out
  
  SCRIPTS32 =	test50.out test70.out
  
--- 30,36 ----
  		test68.out test69.out test71.out test72.out test73.out \
  		test74.out test75.out test76.out test77.out test78.out \
  		test79.out test80.out test81.out test82.out test83.out \
! 		test84.out test85.out test86.out test87.out
  
  SCRIPTS32 =	test50.out test70.out
  
*** ../vim-7.3.568/src/testdir/Make_ming.mak	2012-04-13 19:11:16.000000000 +0200
--- src/testdir/Make_ming.mak	2012-06-20 18:44:12.000000000 +0200
***************
*** 50,56 ****
  		test68.out test69.out test71.out test72.out test73.out \
  		test74.out test75.out test76.out test77.out test78.out \
  		test79.out test80.out test81.out test82.out test83.out \
! 		test84.out test85.out
  
  SCRIPTS32 =	test50.out test70.out
  
--- 50,56 ----
  		test68.out test69.out test71.out test72.out test73.out \
  		test74.out test75.out test76.out test77.out test78.out \
  		test79.out test80.out test81.out test82.out test83.out \
! 		test84.out test85.out test86.out test87.out
  
  SCRIPTS32 =	test50.out test70.out
  
*** ../vim-7.3.568/src/testdir/Make_os2.mak	2012-04-05 16:56:38.000000000 +0200
--- src/testdir/Make_os2.mak	2012-06-20 18:44:32.000000000 +0200
***************
*** 14,19 ****
--- 14,20 ----
  # test27	can't edit file with "*" in file name
  # test52	only for Win32
  # test85	no Lua interface
+ # test86, 87	no Python interface
  
  SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
  		test7.out test8.out test9.out \
*** ../vim-7.3.568/src/testdir/Makefile	2012-04-05 16:56:38.000000000 +0200
--- src/testdir/Makefile	2012-06-29 11:56:00.000000000 +0200
***************
*** 27,33 ****
  		test69.out test70.out test71.out test72.out test73.out \
  		test74.out test75.out test76.out test77.out test78.out \
  		test79.out test80.out test81.out test82.out test83.out \
! 		test84.out test85.out
  
  SCRIPTS_GUI = test16.out
  
--- 27,33 ----
  		test69.out test70.out test71.out test72.out test73.out \
  		test74.out test75.out test76.out test77.out test78.out \
  		test79.out test80.out test81.out test82.out test83.out \
! 		test84.out test85.out test86.out test87.out
  
  SCRIPTS_GUI = test16.out
  
*** ../vim-7.3.568/src/testdir/test86.in	2012-06-20 20:19:31.000000000 +0200
--- src/testdir/test86.in	2012-06-20 18:01:02.000000000 +0200
***************
*** 0 ****
--- 1,211 ----
+ Tests for various python features.     vim: set ft=vim :
+ 
+ STARTTEST
+ :so small.vim
+ :if !has('python') | e! test.ok | wq! test.out | endif
+ :py import vim
+ :fun Test()
+ :let l = []
+ :py l=vim.bindeval('l')
+ :py f=vim.bindeval('function("strlen")')
+ :" Extending List directly with different types
+ :py l.extend([1, "as'd", [1, 2, f, {'a': 1}]])
+ :$put =string(l)
+ :$put =string(l[-1])
+ :try
+ :  $put =string(l[-4])
+ :catch
+ :  $put =v:exception[:13]
+ :endtry
+ :" List assignment
+ :py l[0]=0
+ :$put =string(l)
+ :py l[-2]=f
+ :$put =string(l)
+ :"
+ :" Extending Dictionary directly with different types
+ :let d = {}
+ :py d=vim.bindeval('d')
+ :py d['1']='asd'
+ :py d['b']=[1, 2, f]
+ :py d['-1']={'a': 1}
+ :let dkeys = []
+ :py dk=vim.bindeval('dkeys')
+ :py dkeys=d.keys()
+ :py dkeys.sort()
+ :py dk.extend(dkeys)
+ :$put =string(dkeys)
+ :for [key, val] in sort(items(d))
+ :  $put =string(key) . ' : ' . string(val)
+ :  unlet key val
+ :endfor
+ :"
+ :" removing items with del
+ :py del l[2]
+ :$put =string(l)
+ :let l = range(8)
+ :py l=vim.bindeval('l')
+ :try
+ :   py del l[:3]
+ :   py del l[1:]
+ :catch
+ :   $put =v:exception
+ :endtry
+ :$put =string(l)
+ :"
+ :py del d['-1']
+ :$put =string(d)
+ :"
+ :" removing items out of range: silently skip items that don't exist
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :" The following two ranges delete nothing as they match empty list:
+ :py del l[2:1]
+ :$put =string(l)
+ :py del l[2:2]
+ :$put =string(l)
+ :py del l[2:3]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py del l[2:4]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py del l[2:5]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py del l[2:6]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :" The following two ranges delete nothing as they match empty list:
+ :py del l[-1:2]
+ :$put =string(l)
+ :py del l[-2:2]
+ :$put =string(l)
+ :py del l[-3:2]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py del l[-4:2]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py del l[-5:2]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py del l[-6:2]
+ :$put =string(l)
+ :"
+ :" Slice assignment to a list
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py l[0:0]=['a']
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py l[1:2]=['b']
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py l[2:4]=['c']
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py l[4:4]=['d']
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py l[-1:2]=['e']
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py l[-10:2]=['f']
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :py l[2:-10]=['g']
+ :$put =string(l)
+ :let l = []
+ :py l=vim.bindeval('l')
+ :py l[0:0]=['h']
+ :$put =string(l)
+ :"
+ :" Locked variables
+ :let l = [0, 1, 2, 3]
+ :py l=vim.bindeval('l')
+ :lockvar! l
+ :py l[2]='i'
+ :$put =string(l)
+ :unlockvar! l
+ :"
+ :" Function calls
+ :function New(...)
+ :return ['NewStart']+a:000+['NewEnd']
+ :endfunction
+ :function DictNew(...) dict
+ :return ['DictNewStart']+a:000+['DictNewEnd', self]
+ :endfunction
+ :let l=[function('New'), function('DictNew')]
+ :py l=vim.bindeval('l')
+ :py l.extend(list(l[0](1, 2, 3)))
+ :$put =string(l)
+ :py l.extend(list(l[1](1, 2, 3, self={'a': 'b'})))
+ :$put =string(l)
+ :py l.extend([l[0].name])
+ :$put =string(l)
+ :try
+ :   py l[1](1, 2, 3)
+ :catch
+ :   $put =v:exception[:16]
+ :endtry
+ :delfunction New
+ :try
+ :   py l[0](1, 2, 3)
+ :catch
+ :   $put =v:exception[:16]
+ :endtry
+ :if has('float')
+ :   let l=[0.0]
+ :   py l=vim.bindeval('l')
+ :   py l.extend([0.0])
+ :   $put =string(l)
+ :else
+ :   $put ='[0.0, 0.0]'
+ :endif
+ :"
+ :" pyeval()
+ :let l=pyeval('range(3)')
+ :$put =string(l)
+ :let d=pyeval('{"a": "b", "c": 1, "d": ["e"]}')
+ :$put =sort(items(d))
+ :try
+ :   let undef=pyeval('undefined_name')
+ :catch
+ :   $put =v:exception[:13]
+ :endtry
+ :try
+ :   let vim=pyeval('vim')
+ :catch
+ :   $put =v:exception[:13]
+ :endtry
+ :if has('float')
+ :   let f=pyeval('0.0')
+ :   $put =string(f)
+ :else
+ :   $put ='0.0'
+ :endif
+ :endfun
+ :"
+ :call Test()
+ :"
+ :delfunc Test
+ :call garbagecollect(1)
+ :"
+ :/^start:/,$wq! test.out
+ ENDTEST
+ 
+ start:
*** ../vim-7.3.568/src/testdir/test86.ok	2012-06-20 20:19:31.000000000 +0200
--- src/testdir/test86.ok	2012-06-20 18:01:02.000000000 +0200
***************
*** 0 ****
--- 1,47 ----
+ start:
+ [1, 'as''d', [1, 2, function('strlen'), {'a': 1}]]
+ [1, 2, function('strlen'), {'a': 1}]
+ Vim(put):E684:
+ [0, 'as''d', [1, 2, function('strlen'), {'a': 1}]]
+ [0, function('strlen'), [1, 2, function('strlen'), {'a': 1}]]
+ ['-1', '1', 'b']
+ '-1' : {'a': 1}
+ '1' : 'asd'
+ 'b' : [1, 2, function('strlen')]
+ [0, function('strlen')]
+ [3]
+ {'1': 'asd', 'b': [1, 2, function('strlen')]}
+ [0, 1, 2, 3]
+ [0, 1, 2, 3]
+ [0, 1, 3]
+ [0, 1]
+ [0, 1]
+ [0, 1]
+ [0, 1, 2, 3]
+ [0, 1, 2, 3]
+ [0, 2, 3]
+ [2, 3]
+ [2, 3]
+ [2, 3]
+ ['a', 0, 1, 2, 3]
+ [0, 'b', 2, 3]
+ [0, 1, 'c']
+ [0, 1, 2, 3, 'd']
+ [0, 1, 2, 'e', 3]
+ ['f', 2, 3]
+ [0, 1, 'g', 2, 3]
+ ['h']
+ [0, 1, 2, 3]
+ [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd']
+ [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}]
+ [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}, 'New']
+ Vim(python):E725:
+ Vim(python):E117:
+ [0.0, 0.0]
+ [0, 1, 2]
+ ['a', 'b']
+ ['c', 1]
+ ['d', ['e']]
+ Vim(let):E858:
+ Vim(let):E859:
+ 0.0
*** ../vim-7.3.568/src/testdir/test87.in	2012-06-20 20:19:31.000000000 +0200
--- src/testdir/test87.in	2012-06-20 18:01:02.000000000 +0200
***************
*** 0 ****
--- 1,211 ----
+ Tests for various python features.     vim: set ft=vim :
+ 
+ STARTTEST
+ :so small.vim
+ :if !has('python3') | e! test.ok | wq! test.out | endif
+ :py3 import vim
+ :fun Test()
+ :let l = []
+ :py3 l=vim.bindeval('l')
+ :py3 f=vim.bindeval('function("strlen")')
+ :" Extending List directly with different types
+ :py3 l+=[1, "as'd", [1, 2, f, {'a': 1}]]
+ :$put =string(l)
+ :$put =string(l[-1])
+ :try
+ :  $put =string(l[-4])
+ :catch
+ :  $put =v:exception[:13]
+ :endtry
+ :" List assignment
+ :py3 l[0]=0
+ :$put =string(l)
+ :py3 l[-2]=f
+ :$put =string(l)
+ :"
+ :" Extending Dictionary directly with different types
+ :let d = {}
+ :py3 d=vim.bindeval('d')
+ :py3 d['1']='asd'
+ :py3 d['b']=[1, 2, f]
+ :py3 d['-1']={'a': 1}
+ :let dkeys = []
+ :py3 dk=vim.bindeval('dkeys')
+ :py3 dkeys=d.keys()
+ :py3 dkeys.sort()
+ :py3 dk+=dkeys
+ :$put =string(dkeys)
+ :for [key, val] in sort(items(d))
+ :  $put =string(key) . ' : ' . string(val)
+ :  unlet key val
+ :endfor
+ :"
+ :" removing items with del
+ :py3 del l[2]
+ :$put =string(l)
+ :let l = range(8)
+ :py3 l=vim.bindeval('l')
+ :try
+ :   py3 del l[:3]
+ :   py3 del l[1:]
+ :catch
+ :   $put =v:exception
+ :endtry
+ :$put =string(l)
+ :"
+ :py3 del d['-1']
+ :$put =string(d)
+ :"
+ :" removing items out of range: silently skip items that don't exist
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :" The following two ranges delete nothing as they match empty list:
+ :py3 del l[2:1]
+ :$put =string(l)
+ :py3 del l[2:2]
+ :$put =string(l)
+ :py3 del l[2:3]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 del l[2:4]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 del l[2:5]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 del l[2:6]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :" The following two ranges delete nothing as they match empty list:
+ :py3 del l[-1:2]
+ :$put =string(l)
+ :py3 del l[-2:2]
+ :$put =string(l)
+ :py3 del l[-3:2]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 del l[-4:2]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 del l[-5:2]
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 del l[-6:2]
+ :$put =string(l)
+ :"
+ :" Slice assignment to a list
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 l[0:0]=['a']
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 l[1:2]=['b']
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 l[2:4]=['c']
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 l[4:4]=['d']
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 l[-1:2]=['e']
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 l[-10:2]=['f']
+ :$put =string(l)
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :py3 l[2:-10]=['g']
+ :$put =string(l)
+ :let l = []
+ :py3 l=vim.bindeval('l')
+ :py3 l[0:0]=['h']
+ :$put =string(l)
+ :"
+ :" Locked variables
+ :let l = [0, 1, 2, 3]
+ :py3 l=vim.bindeval('l')
+ :lockvar! l
+ :py3 l[2]='i'
+ :$put =string(l)
+ :unlockvar! l
+ :"
+ :" Function calls
+ :function New(...)
+ :return ['NewStart']+a:000+['NewEnd']
+ :endfunction
+ :function DictNew(...) dict
+ :return ['DictNewStart']+a:000+['DictNewEnd', self]
+ :endfunction
+ :let l=[function('New'), function('DictNew')]
+ :py3 l=vim.bindeval('l')
+ :py3 l.extend(list(l[0](1, 2, 3)))
+ :$put =string(l)
+ :py3 l.extend(list(l[1](1, 2, 3, self={'a': 'b'})))
+ :$put =string(l)
+ :py3 l+=[l[0].name]
+ :$put =string(l)
+ :try
+ :   py3 l[1](1, 2, 3)
+ :catch
+ :   $put =v:exception[:13]
+ :endtry
+ :delfunction New
+ :try
+ :   py3 l[0](1, 2, 3)
+ :catch
+ :   $put =v:exception[:13]
+ :endtry
+ :if has('float')
+ :   let l=[0.0]
+ :   py3 l=vim.bindeval('l')
+ :   py3 l.extend([0.0])
+ :   $put =string(l)
+ :else
+ :   $put ='[0.0, 0.0]'
+ :endif
+ :"
+ :" py3eval()
+ :let l=py3eval('[0, 1, 2]')
+ :$put =string(l)
+ :let d=py3eval('{"a": "b", "c": 1, "d": ["e"]}')
+ :$put =sort(items(d))
+ :try
+ :   let undef=py3eval('undefined_name')
+ :catch
+ :   $put =v:exception[:13]
+ :endtry
+ :try
+ :   let vim=py3eval('vim')
+ :catch
+ :   $put =v:exception[:13]
+ :endtry
+ :if has('float')
+ :   let f=py3eval('0.0')
+ :   $put =string(f)
+ :else
+ :   $put ='0.0'
+ :endif
+ :endfun
+ :"
+ :call Test()
+ :"
+ :delfunc Test
+ :call garbagecollect(1)
+ :"
+ :/^start:/,$wq! test.out
+ ENDTEST
+ 
+ start:
*** ../vim-7.3.568/src/testdir/test87.ok	2012-06-20 20:19:31.000000000 +0200
--- src/testdir/test87.ok	2012-06-20 18:01:02.000000000 +0200
***************
*** 0 ****
--- 1,47 ----
+ start:
+ [1, 'as''d', [1, 2, function('strlen'), {'a': 1}]]
+ [1, 2, function('strlen'), {'a': 1}]
+ Vim(put):E684:
+ [0, 'as''d', [1, 2, function('strlen'), {'a': 1}]]
+ [0, function('strlen'), [1, 2, function('strlen'), {'a': 1}]]
+ ['-1', '1', 'b']
+ '-1' : {'a': 1}
+ '1' : 'asd'
+ 'b' : [1, 2, function('strlen')]
+ [0, function('strlen')]
+ [3]
+ {'1': 'asd', 'b': [1, 2, function('strlen')]}
+ [0, 1, 2, 3]
+ [0, 1, 2, 3]
+ [0, 1, 3]
+ [0, 1]
+ [0, 1]
+ [0, 1]
+ [0, 1, 2, 3]
+ [0, 1, 2, 3]
+ [0, 2, 3]
+ [2, 3]
+ [2, 3]
+ [2, 3]
+ ['a', 0, 1, 2, 3]
+ [0, 'b', 2, 3]
+ [0, 1, 'c']
+ [0, 1, 2, 3, 'd']
+ [0, 1, 2, 'e', 3]
+ ['f', 2, 3]
+ [0, 1, 'g', 2, 3]
+ ['h']
+ [0, 1, 2, 3]
+ [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd']
+ [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}]
+ [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}, 'New']
+ Vim(py3):E725:
+ Vim(py3):E117:
+ [0.0, 0.0]
+ [0, 1, 2]
+ ['a', 'b']
+ ['c', 1]
+ ['d', ['e']]
+ Vim(let):E860:
+ Vim(let):E861:
+ 0.0
*** ../vim-7.3.568/src/version.c	2012-06-29 12:35:40.000000000 +0200
--- src/version.c	2012-06-29 12:47:03.000000000 +0200
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     569,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
69. Yahoo welcomes you with your own start page

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///