Author martin.panter
Recipients benjamin.peterson, malthe, martin.panter, r.david.murray
Date 2016-09-24.03:28:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1474687686.85.0.805606501051.issue28143@psf.upfronthosting.co.za>
In-reply-to
Content
That would get the patch mostly working with 2.6+. Is it okay to break Python < 2.6 support? I know there was an OS X Tiger buildbot using 2.5 until recently; see Issue 28039.

Personally, I would rather focus on the problems with make dependencies, build configuration, etc, rather than changing what versions of Python the code runs on.

Regarding CRLFs on Windows: the existing code opens files in binary mode (wb), so Windows will not translate \n into CRLF. Changing this behaviour is separate to the goal of Python 3 compatibility. IMO the build process should not change the contents of checked-in files, regardless of whether there is a version control system like Mercurial or Git in use or not. See also Issue 27425.

On the other hand, the Python 3 code does use text mode with CRLF translation, so maybe it is not a big deal. (I never built Python on Windows, so I don’t know.)

+++ b/Parser/spark.py
@@ -171,7 +171,7 @@ class GenericParser:
-    rules = string.split(doc)
+    rules = str.split(doc)

This would read better as doc.split(); see <http://svn.python.org/view?view=revision&revision=55143>.

@@ -825,15 +828,15 @@ class GenericASTMatcher(GenericParser):
-    print '\t', item
+    print('\t', item)
     for (lhs, rhs), pos in states[item[0]].items:
-        print '\t\t', lhs, '::=',
+        print('\t\t', lhs, '::=', end=" ")
. . .
+        print(string.join(rhs[:pos]), end=" ")
+        print('.', end=" ")
+        print(string.join(rhs[pos:]))

The string quoting is inconsistent. Also, I suspect string.join() is not right for Python 3. And you are adding an extra space after the '\t' characters.

For what it’s worth, here are some similar changes made to the Py 3 branch:

r57749: raise syntax
r51578: `. . .` → repr()
http://svn.python.org/view?view=revision&revision=55329: Unpack tuples inside functions (Malthe’s patch unpacks as the function is called instead); map() → list comprehension
http://svn.python.org/view?view=revision&revision=55143: Various Py 3 changes
r59154: Write files in text mode
r53189: Avoid has_key()
http://svn.python.org/view?view=revision&revision=55167: xrange() → range()
History
Date User Action Args
2016-09-24 03:28:06martin.pantersetrecipients: + martin.panter, benjamin.peterson, r.david.murray, malthe
2016-09-24 03:28:06martin.pantersetmessageid: <1474687686.85.0.805606501051.issue28143@psf.upfronthosting.co.za>
2016-09-24 03:28:06martin.panterlinkissue28143 messages
2016-09-24 03:28:04martin.pantercreate