This repository has been archived by the owner on Dec 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2to3-status.t2t
202 lines (112 loc) · 4.43 KB
/
2to3-status.t2t
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
Txt2tags conversion to Python 3
Author: João Bernardo
Date: 2010-11-07
%!encoding: UTF-8
%!options: --toc --enum-title
= Problems encountered after running 2to3 script =
(The line numbers may differ)
----------------------------------------------
== Indentation (related to 'Ascii Art'):==
Mixture of tabs with spaces in lines 3744 -> 3753 (FIXED)
----------------------------------------------
== Comparing strings and numbers ==
The test:
``` if t >= 0
But ``t`` was initially set to ``'z'`` as str > int for Python 2.
In Python 3, this comparison is not possible.
lines 3033, 3039, 3046
**Solution:**
'z' replaced by 1000000 in line 3024:
``` t = r = v = 'z'
----------------------------------------------
== SaveFile function (lines 2181 to 2192): ==
Encoding problem as described in http://code.google.com/p/txt2tags/issues/detail?id=57
But the solution proposed in the issue messes with accented chars. My solution was to open the file with ``'w'`` and not ``'wb'``.
**Solution:**
```
# Open file as text, not bin
f = open (file_path, 'w')
```
----------------------------------------------
== Decode unicode string (related to conversion to txt) ==
The encode checking is not needed anymore.
**Solution:**
Commented lines 3224 to 3226, indentation removed from 3227.
----------------------------------------------
== String multiplied by float ==
In line 2068, ``nspace`` is defined by a division by 2 and then multiplies the number of spaces.
Python 2 makes ``10 / 2 = 5``, but Python 3 makes ``10 / 2 = 5.0`` as the symbol for integer division is ``//``.
**Solution:**
``` nspace = int ((length - len_txt - 4) / 2)
-----------------------------------------------
In lines 2079 and 2083 (function aa_header is used when ``-t art`` with ``--slides``), multiplied by ``n``.
**Solution:**
``` int (n) # the two calls
----------------------------------------------
== GUI! ==
2to3 script missed a 'Tkinter'.
In py3K the module was renamed to tkinter.
Fixed line 5552.
----------------------------------------------
== Page Maker (PM6) ==
The character ``\x95`` (bullet) can not be printed in unicode and generates exception to save the file.
In lines 1354 and 1356 this character is used.
**Workaround:**
``\x95\t`` replaced to ``*\t``
I don't know PageMaker format, please check this fix.
----------------------------------------------
== Some idioms were fixed: ==
=== Type Comparison: isinstance ===
The isinstance function checks if an objects is from a class that inherits from the other
``` if type(a) == type(b):
is now:
``` if isinstance(a, type(b)):
some times appeared:
``` if (type(a) == type('')) or (type(a) == type(u'')):
This is deprecated, therefore only unicode string check is made.
``` if isinstance(a, type('')):
**Type comparison should be avoided for performance and compatibility reasons.**
Use that instead (when possible):
```
try:
treat_as_iter_type(my_var)
except:
treat_as_non_iter(my_var)
```
-----------------------------------------------
=== Sorting lists ===
In some places, is made:
```
my_list = 'some random words here'.split()
my_list.sort()
```
To avoid these two operations (because ``[].sort`` doesn't return a list and that would be wasteful), now is used the new ``sorted()`` function
``` my_list = sorted( 'some random words here'.split() )
and that produces the same result
-----------------------------------------------
=== Better use of iterators: ===
Functions like ``range()``, ``map()``, ``'{}.keys()'`` and many others now return iterators.
2to3 script never knows (ok, it knows only when you use ``for i in range(n)``) when it can use an iterator and
changes everything to ``list(function())``.
The new model, when used right, reduces memory use so I refixed many ``list(function())`` made by the script
Fixed lines: 197, 1427, 1980, 2147, 2193, 2290, 2409, 2650, 2694, 2706, 2707, 2769, 2818, 4221, 4367, 4417, 4942, 5402
More lines fixed: 1416, 2417, 2793, 4214
===============================================
= Already been tested: =
- All conversions
- Print to screen - STDOUT
- Read standard input - STDIN
- Enumerate titles
- Table of contents, toc-levels and toc-only
- Remove Header and Footer
- Mask email
- Slides in Ascii Art
- Width and Height in Ascii Art
- Quiet, verbose, help (duh!)
- GUI
- ``%!csv``
- ``%!postproc`` , ``%!preproc``, ``%!options``...
===============================================
= Tests Lacking =
- Style, CSS
- Configuration Files