[GRASS-dev] python script utils encoding/decoding overriding unicode with python-future

Moritz Lennert mlennert at club.worldonline.be
Fri Aug 25 08:14:04 PDT 2017


On 25/08/17 17:06, Pietro wrote:
> Unfortunately builtins is used also in other files, and I’m afraid
> that I should also fix these:

I think that this would be better, yes.

Is this in grass72 as well, or only trunk ?

Moritz

> 
> $ rg "builtins" . -B 1 -A 5
> script/task.py
> 24-try:
> 25:    from builtins import unicode
> 26-    bytes = str
> 27-except ImportError:
> 28-    # python3
> 29-    unicode = str
> 30-
> 
> temporal/core.py
> 38-try:
> 39:    from builtins import long
> 40-except ImportError:
> 41-    # python3
> 42-    long = int
> 43-
> 44-from .c_libraries_interface import *
> 
> script/vector.py
> 27-    # python3
> 28:    import builtins as __builtin__
> 29-    unicode = str
> 30-
> 31-from .utils import parse_key_val
> 32-from .core import *
> 33-from grass.exceptions import CalledModuleError
> 
> script/temporal_script_utils_encoding.diff
> 10-+try:
> 11:+    from builtins import unicode
> 12-+except ImportError:
> 13-+    # python3
> 14-+    unicode = str
> 15-+
> 16-+
> 
> script/raster.py
> 31-try:
> 32:    from builtins import unicode
> 33-    bytes = str
> 34-except ImportError:
> 35-    # python3
> 36-    unicode = str
> 37-
> 
> gunittest/utils.py
> 59-    except ImportError:
> 60:        import builtins as __builtin__
> 61-    __builtin__._ = new_translator
> 62-
> 63-
> 64-_MAX_LENGTH = 80
> 65-
> 
> pygrass/vector/table.py
> 13-try:
> 14:    from builtins import long, unicode
> 15-except ImportError:
> 16-    # python3
> 17-    long = int
> 18-    unicode = str
> 19-
> 
> script/core.py
> 43-    # python3
> 44:    import builtins as __builtin__
> 45-    from os import environb as environ
> 46-    unicode = str
> 47-__builtin__.__dict__['_'] = __builtin__.__dict__['_'].__self__.lgettext
> 48-
> 49-
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/temporal.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/cluster.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/ogsf.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/proj.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/vector.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/stats.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/arraystats.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/vedit.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/rowio.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/display.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/date.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/raster3d.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/segment.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/gis.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/nviz.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/gmath.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/rtree.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/raster.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/dbmi.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes/OBJ.x86_64-pc-linux-gnu/imagery.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    long = int
> 17-
> 18-import os
> 19-import sys
> 
> ctypes_pregit/ctypesgencore/processor/operations.py
> 97-def fix_conflicting_names(data, opts):
> 98:    """If any descriptions from the C code would overwrite Python builtins or
> 99-    other important names, fix_conflicting_names() adds underscores
> to resolve
> 100-    the name conflict."""
> 101-
> 102-    # This is the order of priority for names
> 103-    descriptions = data.functions + data.variables + data.structs + \
> --
> 124-        important_names[name] = "a name needed by ctypes or ctypesgen"
> 125:    for name in dir(__builtins__):
> 126-        important_names[name] = "a Python builtin"
> 127-    for name in opts.other_known_names:
> 128-        important_names[name] = "a name from an included Python module"
> 129-    for name in keyword.kwlist:
> 130-        important_names[name] = "a Python keyword"
> 
> ctypes/ctypesgencore/printer/preamble.py
> 1-try:
> 2:    from builtins import long
> 3-except ImportError:
> 4-    long = int
> 5-
> 6-import os
> 7-import sys
> 
> ctypes/ctypesgencore/parser/lex.py
> 31-try:
> 32:    from builtins import bytes
> 33-    PY3 = True
> 34-except ImportError:
> 35-    # python2
> 36-    bytes = str
> 37-    PY3 = False
> 
> ctypes/ctypesgencore/parser/cgrammar.py
> 13-try:
> 14:    from builtins import long
> 15-except ImportError:
> 16-    # python3
> 17-    long = int
> 18-
> 19-__docformat__ = 'restructuredtext'
> 
> ctypes/ctypesgencore/processor/operations.py
> 97-def fix_conflicting_names(data, opts):
> 98:    """If any descriptions from the C code would overwrite Python builtins or
> 99-    other important names, fix_conflicting_names() adds underscores
> to resolve
> 100-    the name conflict."""
> 101-
> 102-    # This is the order of priority for names
> 103-    descriptions = data.functions + data.variables + data.structs + \
> --
> 124-        important_names[name] = "a name needed by ctypes or ctypesgen"
> 125:    for name in dir(__builtins__):
> 126-        important_names[name] = "a Python builtin"
> 127-    for name in opts.other_known_names:
> 128-        important_names[name] = "a name from an included Python module"
> 129-    for name in keyword.kwlist:
> 130-        important_names[name] = "a Python keyword"
> 
> pygrass/vector/testsuite/test_table.py
> 7-try:
> 8:    from builtins import long
> 9-except ImportError:
> 10-    # python3
> 11-    long = int
> 12-
> 13-import os
> --
> 25-try:
> 26:    from builtins import long
> 27-except ImportError:
> 28-    long = int
> 29-
> 30-# dictionary that generate random data
> 31-COL2VALS = {'INT': lambda n:     np.random.randint(9, size=n),
> 
> ctypes/ctypesgencore/parser/pplexer.py
> 13-try:
> 14:    from builtins import long
> 15-    PY2 = True
> 16-except ImportError:
> 17-    # python3
> 18-    PY2 = False
> 19-    long = int
> 




More information about the grass-dev mailing list