[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torspec/master] proposals: Update reindex.py for Python 3



commit ec92bbba5dbb9733f26c0f5887702ec73f76f566
Author: teor <teor@xxxxxxxxxxxxxx>
Date:   Thu Feb 6 10:53:45 2020 +1000

    proposals: Update reindex.py for Python 3
    
    Add the standard future statements, so Python 2 will use some
    Python 3 features.
    
    Open files as UTF-8. As a consequence of this change, proposals
    must be encoded in UTF-8.
    
    Closes ticket 33164.
---
 proposals/reindex.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/proposals/reindex.py b/proposals/reindex.py
index c66ec24..1f52466 100755
--- a/proposals/reindex.py
+++ b/proposals/reindex.py
@@ -1,6 +1,11 @@
 #!/usr/bin/env python
 
-import re, os
+# Future imports for Python 2.7, mandatory in 3.0
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
+import codecs, re, os
 class Error(Exception): pass
 
 STATUSES = """DRAFT NEEDS-REVISION NEEDS-RESEARCH OPEN ACCEPTED META FINISHED
@@ -23,7 +28,7 @@ def indexed(seq):
 
 def readProposal(fn):
     fields = { }
-    f = open(fn, 'r')
+    f = codecs.open(fn, 'r', encoding='utf-8')
     lastField = None
     try:
         for lineno, line in indexed(f):

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits