[GRASS-SVN] r71442 - in grass/branches/releasebranch_7_2/lib/python: ctypes/ctypesgencore/parser ctypes/ctypesgencore/printer pygrass/vector pygrass/vector/testsuite script temporal

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 27 21:50:26 PDT 2017


Author: zarch
Date: 2017-08-27 21:50:26 -0700 (Sun, 27 Aug 2017)
New Revision: 71442

Modified:
   grass/branches/releasebranch_7_2/lib/python/ctypes/ctypesgencore/parser/cgrammar.py
   grass/branches/releasebranch_7_2/lib/python/ctypes/ctypesgencore/parser/pplexer.py
   grass/branches/releasebranch_7_2/lib/python/ctypes/ctypesgencore/printer/preamble.py
   grass/branches/releasebranch_7_2/lib/python/pygrass/vector/table.py
   grass/branches/releasebranch_7_2/lib/python/pygrass/vector/testsuite/test_table.py
   grass/branches/releasebranch_7_2/lib/python/script/raster.py
   grass/branches/releasebranch_7_2/lib/python/script/task.py
   grass/branches/releasebranch_7_2/lib/python/script/utils.py
   grass/branches/releasebranch_7_2/lib/python/temporal/core.py
Log:
python.builtins: removed builtins import in python2 (trunk: r71435, r71438)

Modified: grass/branches/releasebranch_7_2/lib/python/ctypes/ctypesgencore/parser/cgrammar.py
===================================================================
--- grass/branches/releasebranch_7_2/lib/python/ctypes/ctypesgencore/parser/cgrammar.py	2017-08-26 18:55:58 UTC (rev 71441)
+++ grass/branches/releasebranch_7_2/lib/python/ctypes/ctypesgencore/parser/cgrammar.py	2017-08-28 04:50:26 UTC (rev 71442)
@@ -10,12 +10,6 @@
   * http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf
 
 '''
-try:
-    from builtins import long
-except ImportError:
-    # python3
-    long = int
-
 __docformat__ = 'restructuredtext'
 
 import operator
@@ -31,6 +25,10 @@
 from . import yacc
 
 
+if sys.version_info.major == 3:
+    long = int
+
+
 tokens = (
     'PP_DEFINE', 'PP_DEFINE_NAME', 'PP_DEFINE_MACRO_NAME', 'PP_MACRO_PARAM',
     'PP_STRINGIFY', 'PP_IDENTIFIER_PASTE', 'PP_END_DEFINE',

Modified: grass/branches/releasebranch_7_2/lib/python/ctypes/ctypesgencore/parser/pplexer.py
===================================================================
--- grass/branches/releasebranch_7_2/lib/python/ctypes/ctypesgencore/parser/pplexer.py	2017-08-26 18:55:58 UTC (rev 71441)
+++ grass/branches/releasebranch_7_2/lib/python/ctypes/ctypesgencore/parser/pplexer.py	2017-08-28 04:50:26 UTC (rev 71442)
@@ -10,14 +10,6 @@
 
 __docformat__ = 'restructuredtext'
 
-try:
-    from builtins import long
-    PY2 = True
-except ImportError:
-    # python3
-    PY2 = False
-    long = int
-
 import os
 import re
 import shlex
@@ -30,6 +22,13 @@
 from . import yacc
 from .lex import TOKEN
 
+
+PY2 = True
+if sys.version_info.major == 3:
+    PY2 = False
+    long = int
+
+
 tokens = (
     'HEADER_NAME', 'IDENTIFIER', 'PP_NUMBER', 'CHARACTER_CONSTANT',
     'STRING_LITERAL', 'OTHER',

Modified: grass/branches/releasebranch_7_2/lib/python/ctypes/ctypesgencore/printer/preamble.py
===================================================================
--- grass/branches/releasebranch_7_2/lib/python/ctypes/ctypesgencore/printer/preamble.py	2017-08-26 18:55:58 UTC (rev 71441)
+++ grass/branches/releasebranch_7_2/lib/python/ctypes/ctypesgencore/printer/preamble.py	2017-08-28 04:50:26 UTC (rev 71442)
@@ -1,14 +1,13 @@
-try:
-    from builtins import long
-except ImportError:
-    long = int
-
 import os
 import sys
 
 import ctypes
 from ctypes import *
 
+if sys.version_info.major == 3:
+    long = int
+
+
 _int_types = (c_int16, c_int32)
 if hasattr(ctypes, 'c_int64'):
     # Some builds of ctypes apparently do not have c_int64

Modified: grass/branches/releasebranch_7_2/lib/python/pygrass/vector/table.py
===================================================================
--- grass/branches/releasebranch_7_2/lib/python/pygrass/vector/table.py	2017-08-26 18:55:58 UTC (rev 71441)
+++ grass/branches/releasebranch_7_2/lib/python/pygrass/vector/table.py	2017-08-28 04:50:26 UTC (rev 71442)
@@ -9,11 +9,9 @@
                         with_statement, print_function, unicode_literals)
 
 import os
+import sys
 
-try:
-    from builtins import long, unicode
-except ImportError:
-    # python3
+if sys.version_info.major == 3:
     long = int
     unicode = str
 

Modified: grass/branches/releasebranch_7_2/lib/python/pygrass/vector/testsuite/test_table.py
===================================================================
--- grass/branches/releasebranch_7_2/lib/python/pygrass/vector/testsuite/test_table.py	2017-08-26 18:55:58 UTC (rev 71441)
+++ grass/branches/releasebranch_7_2/lib/python/pygrass/vector/testsuite/test_table.py	2017-08-28 04:50:26 UTC (rev 71442)
@@ -4,14 +4,9 @@
 
 @author: pietro
 """
-try:
-    from builtins import long
-except ImportError:
-    # python3
-    long = int
-
 import os
 import sqlite3
+import sys
 import tempfile as tmp
 from string import ascii_letters, digits
 from random import choice
@@ -23,6 +18,9 @@
 from grass.pygrass.vector.table import Table, get_path
 
 
+if sys.version_info.major == 3:
+    long = int
+
 # dictionary that generate random data
 COL2VALS = {'INT': lambda n:     np.random.randint(9, size=n),
             'INTEGER': lambda n: np.random.randint(9, size=n),

Modified: grass/branches/releasebranch_7_2/lib/python/script/raster.py
===================================================================
--- grass/branches/releasebranch_7_2/lib/python/script/raster.py	2017-08-26 18:55:58 UTC (rev 71441)
+++ grass/branches/releasebranch_7_2/lib/python/script/raster.py	2017-08-28 04:50:26 UTC (rev 71442)
@@ -20,6 +20,7 @@
 from __future__ import absolute_import
 
 import os
+import sys
 import string
 import time
 
@@ -28,11 +29,7 @@
 from .utils import float_or_dms, parse_key_val
 
 
-try:
-    from builtins import unicode
-    bytes = str
-except ImportError:
-    # python3
+if sys.version_info.major == 3:
     unicode = str
 
 

Modified: grass/branches/releasebranch_7_2/lib/python/script/task.py
===================================================================
--- grass/branches/releasebranch_7_2/lib/python/script/task.py	2017-08-26 18:55:58 UTC (rev 71441)
+++ grass/branches/releasebranch_7_2/lib/python/script/task.py	2017-08-28 04:50:26 UTC (rev 71442)
@@ -18,14 +18,10 @@
 .. sectionauthor:: Martin Landa <landa.martin gmail.com>
 """
 import re
-import types
+import sys
 import string
 
-try:
-    from builtins import unicode
-    bytes = str
-except ImportError:
-    # python3
+if sys.version_info.major == 3:
     unicode = str
 
 try:

Modified: grass/branches/releasebranch_7_2/lib/python/script/utils.py
===================================================================
--- grass/branches/releasebranch_7_2/lib/python/script/utils.py	2017-08-26 18:55:58 UTC (rev 71441)
+++ grass/branches/releasebranch_7_2/lib/python/script/utils.py	2017-08-28 04:50:26 UTC (rev 71442)
@@ -24,6 +24,10 @@
 import shlex
 import re
 
+if sys.version_info.major == 3:
+    unicode = str
+
+
 def float_or_dms(s):
     """Convert DMS to float.
 

Modified: grass/branches/releasebranch_7_2/lib/python/temporal/core.py
===================================================================
--- grass/branches/releasebranch_7_2/lib/python/temporal/core.py	2017-08-26 18:55:58 UTC (rev 71441)
+++ grass/branches/releasebranch_7_2/lib/python/temporal/core.py	2017-08-28 04:50:26 UTC (rev 71442)
@@ -30,17 +30,16 @@
 """
 #import traceback
 import os
+import sys
+
+import grass.script as gscript
 # i18N
 import gettext
 gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'))
 
-try:
-    from builtins import long
-except ImportError:
-    # python3
+if sys.version_info.major == 3:
     long = int
 
-import grass.script as gscript
 from datetime import datetime
 from .c_libraries_interface import *
 from grass.pygrass import messages



More information about the grass-commit mailing list