summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-12-08 19:09:45 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2018-12-08 19:16:09 +0100
commit650ed1c8bd461e0ab30108a755a753c9fd46e7bf (patch)
tree7f061f33b82ecbc5e9f8949d095e62f9c329e272 /giscanner
parent7c770ea4bbd0ddbb4f97551d05e884af4a9f8b21 (diff)
downloadgobject-introspection-650ed1c8bd461e0ab30108a755a753c9fd46e7bf.tar.gz
Drop all Python 2 compat code
We only support 3.4+ now.
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/__init__.py1
-rw-r--r--giscanner/annotationmain.py11
-rw-r--r--giscanner/annotationparser.py6
-rw-r--r--giscanner/ast.py5
-rw-r--r--giscanner/cachestore.py11
-rw-r--r--giscanner/ccompiler.py4
-rw-r--r--giscanner/codegen.py6
-rw-r--r--giscanner/docmain.py5
-rw-r--r--giscanner/docwriter.py5
-rw-r--r--giscanner/dumper.py5
-rw-r--r--giscanner/gdumpparser.py5
-rw-r--r--giscanner/girparser.py5
-rw-r--r--giscanner/girwriter.py6
-rw-r--r--giscanner/introspectablepass.py4
-rw-r--r--giscanner/libtoolimporter.py5
-rw-r--r--giscanner/maintransformer.py5
-rw-r--r--giscanner/message.py5
-rw-r--r--giscanner/scannermain.py5
-rw-r--r--giscanner/sectionparser.py5
-rw-r--r--giscanner/shlibs.py5
-rw-r--r--giscanner/sourcescanner.py6
-rw-r--r--giscanner/testcodegen.py12
-rw-r--r--giscanner/transformer.py5
-rw-r--r--giscanner/utils.py42
-rwxr-xr-xgiscanner/xmlwriter.py17
25 files changed, 7 insertions, 184 deletions
diff --git a/giscanner/__init__.py b/giscanner/__init__.py
index 391d36bd..79c537e8 100644
--- a/giscanner/__init__.py
+++ b/giscanner/__init__.py
@@ -17,7 +17,6 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
import os
builddir = os.environ.get('UNINSTALLED_INTROSPECTION_BUILDDIR')
if builddir is not None:
diff --git a/giscanner/annotationmain.py b/giscanner/annotationmain.py
index 3d2811e9..1f29a827 100644
--- a/giscanner/annotationmain.py
+++ b/giscanner/annotationmain.py
@@ -18,11 +18,6 @@
# 02110-1301, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import sys
import optparse
import codecs
@@ -38,15 +33,11 @@ from giscanner.scannermain import (get_preprocessor_option_group,
@contextmanager
def encode_stdout(encoding):
"""Force stdout into a specific encoding."""
- # Python 2 does not encode stdout writes so wrap it with 'encoding' encoded writer.
# Python 3 uses a io.TextIOBase wrapped stdout with the system default encoding.
# Re-wrap the underlying buffer with a new writer with the given 'encoding'.
# See: https://docs.python.org/3/library/sys.html#sys.stdout
old_stdout = sys.stdout
- if sys.version_info.major < 3:
- binary_stdout = sys.stdout
- else:
- binary_stdout = sys.stdout.buffer
+ binary_stdout = sys.stdout.buffer
sys.stdout = codecs.getwriter(encoding)(binary_stdout)
yield
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 1b82b355..9ab629b3 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -106,12 +106,6 @@ Refer to the `GTK-Doc manual`_ for more detailed usage information.
http://developer.gnome.org/gtk-doc-manual/1.18/documenting.html.en
'''
-
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
import re
import operator
diff --git a/giscanner/ast.py b/giscanner/ast.py
index b24efadb..2daccdfb 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -19,11 +19,6 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import copy
import operator
from itertools import chain
diff --git a/giscanner/cachestore.py b/giscanner/cachestore.py
index 58b3193c..5cfb49a5 100644
--- a/giscanner/cachestore.py
+++ b/giscanner/cachestore.py
@@ -18,11 +18,6 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import errno
import glob
import hashlib
@@ -30,11 +25,7 @@ import os
import shutil
import sys
import tempfile
-
-try:
- import cPickle as pickle
-except ImportError:
- import pickle
+import pickle
import giscanner
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
index d327c581..5db04535 100644
--- a/giscanner/ccompiler.py
+++ b/giscanner/ccompiler.py
@@ -271,10 +271,6 @@ class CCompiler(object):
args.append('dumpbin.exe')
args.append('-symbols')
- # Work around the attempt to resolve m.lib on Python 2.x
- if sys.version_info.major < 3:
- libraries[:] = [lib for lib in libraries if lib != 'm']
-
# When we are not using Visual C++ (i.e. we are using GCC)...
else:
libtool = utils.get_libtool_command(options)
diff --git a/giscanner/codegen.py b/giscanner/codegen.py
index 0d4a8d8b..ce07aaa1 100644
--- a/giscanner/codegen.py
+++ b/giscanner/codegen.py
@@ -18,12 +18,6 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import with_statement
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
from contextlib import contextmanager
from . import ast
diff --git a/giscanner/docmain.py b/giscanner/docmain.py
index 5efcf1fe..6ef1de4e 100644
--- a/giscanner/docmain.py
+++ b/giscanner/docmain.py
@@ -18,11 +18,6 @@
# 02110-1301, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
import argparse
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
index a29ba374..15e68433 100644
--- a/giscanner/docwriter.py
+++ b/giscanner/docwriter.py
@@ -21,11 +21,6 @@
# 02110-1301, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
import re
import sys
diff --git a/giscanner/dumper.py b/giscanner/dumper.py
index 2c668f5a..2b851a53 100644
--- a/giscanner/dumper.py
+++ b/giscanner/dumper.py
@@ -19,11 +19,6 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
import sys
import shlex
diff --git a/giscanner/gdumpparser.py b/giscanner/gdumpparser.py
index cd9d94d2..1730fee5 100644
--- a/giscanner/gdumpparser.py
+++ b/giscanner/gdumpparser.py
@@ -18,11 +18,6 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
import sys
import tempfile
diff --git a/giscanner/girparser.py b/giscanner/girparser.py
index 45246307..3bc4a6f4 100644
--- a/giscanner/girparser.py
+++ b/giscanner/girparser.py
@@ -18,11 +18,6 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
from collections import OrderedDict
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 6bbb054d..91875a2d 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -19,12 +19,6 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import with_statement
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
from . import ast
diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py
index 072494bd..e2056b42 100644
--- a/giscanner/introspectablepass.py
+++ b/giscanner/introspectablepass.py
@@ -16,10 +16,6 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
from . import ast
from . import message
diff --git a/giscanner/libtoolimporter.py b/giscanner/libtoolimporter.py
index 0135bb82..c8501035 100644
--- a/giscanner/libtoolimporter.py
+++ b/giscanner/libtoolimporter.py
@@ -18,11 +18,6 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import imp
import os
import sys
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index e931fcdb..b67dcb7f 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -17,11 +17,6 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import re
from . import ast
diff --git a/giscanner/message.py b/giscanner/message.py
index abbb3dc5..f693af60 100644
--- a/giscanner/message.py
+++ b/giscanner/message.py
@@ -20,11 +20,6 @@
# 02110-1301, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
import sys
import operator
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index ceca66f4..143dd6eb 100644
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -20,11 +20,6 @@
# 02110-1301, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import errno
import optparse
import os
diff --git a/giscanner/sectionparser.py b/giscanner/sectionparser.py
index e8e584d3..ed4660fe 100644
--- a/giscanner/sectionparser.py
+++ b/giscanner/sectionparser.py
@@ -17,11 +17,6 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import re
from . import ast
from .utils import to_underscores
diff --git a/giscanner/shlibs.py b/giscanner/shlibs.py
index f70c54da..8b4924da 100644
--- a/giscanner/shlibs.py
+++ b/giscanner/shlibs.py
@@ -19,11 +19,6 @@
# 02110-1301, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
import platform
import re
diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py
index d867a4e9..5c83992c 100644
--- a/giscanner/sourcescanner.py
+++ b/giscanner/sourcescanner.py
@@ -18,12 +18,6 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import with_statement
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
import tempfile
diff --git a/giscanner/testcodegen.py b/giscanner/testcodegen.py
index 846e1511..e3ffdab9 100644
--- a/giscanner/testcodegen.py
+++ b/giscanner/testcodegen.py
@@ -18,21 +18,11 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
-import sys
+from io import StringIO
from . import ast
from .codegen import CCodeGenerator
-if sys.version_info.major < 3:
- from StringIO import StringIO
-else:
- from io import StringIO
-
DEFAULT_C_VALUES = {ast.TYPE_ANY: 'NULL',
ast.TYPE_STRING: '""',
ast.TYPE_FILENAME: '""',
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index bb0eb3e0..1c406e98 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -18,11 +18,6 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
import sys
import subprocess
diff --git a/giscanner/utils.py b/giscanner/utils.py
index bdb90714..25160c3e 100644
--- a/giscanner/utils.py
+++ b/giscanner/utils.py
@@ -17,12 +17,7 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-import errno
import re
import os
import subprocess
@@ -218,39 +213,6 @@ def which(program):
return None
-def makedirs(name, mode=0o777, exist_ok=False):
- """Super-mkdir; create a leaf directory and all intermediate ones. Works like
- mkdir, except that any intermediate path segment (not just the rightmost)
- will be created if it does not exist. If the target directory already
- exists, raise an OSError if exist_ok is False. Otherwise no exception is
- raised. This is recursive.
-
- Note: This function has been imported from Python 3.4 sources and adapted to work
- with Python 2.X because get_user_cache_dir() uses the exist_ok parameter. It can
- be removed again when Python 2.X support is dropped.
- """
- head, tail = os.path.split(name)
- if not tail:
- head, tail = os.path.split(head)
- if head and tail and not os.path.exists(head):
- try:
- makedirs(head, mode, exist_ok)
- except (IOError, OSError) as e:
- # be happy if someone already created the path
- if e.errno != errno.EEXIST:
- raise
- cdir = os.path.curdir
- if isinstance(tail, bytes):
- cdir = os.path.curdir.encode("ascii")
- if tail == cdir: # xxx/newdir/. exists if xxx/newdir exists
- return
- try:
- os.mkdir(name, mode)
- except (IOError, OSError) as e:
- if not exist_ok or e.errno != errno.EEXIST or not os.path.isdir(name):
- raise
-
-
def get_user_cache_dir(dir=None):
'''
This is a Python reimplemention of `g_get_user_cache_dir()` because we don't want to
@@ -263,7 +225,7 @@ def get_user_cache_dir(dir=None):
if dir is not None:
xdg_cache_home = os.path.join(xdg_cache_home, dir)
try:
- makedirs(xdg_cache_home, mode=0o755, exist_ok=True)
+ os.makedirs(xdg_cache_home, mode=0o755, exist_ok=True)
except EnvironmentError:
# Let's fall back to ~/.cache below
pass
@@ -276,7 +238,7 @@ def get_user_cache_dir(dir=None):
if dir is not None:
cachedir = os.path.join(cachedir, dir)
try:
- makedirs(cachedir, mode=0o755, exist_ok=True)
+ os.makedirs(cachedir, mode=0o755, exist_ok=True)
except EnvironmentError:
return None
else:
diff --git a/giscanner/xmlwriter.py b/giscanner/xmlwriter.py
index 099f9e1b..62d30311 100755
--- a/giscanner/xmlwriter.py
+++ b/giscanner/xmlwriter.py
@@ -18,23 +18,10 @@
# Boston, MA 02111-1307, USA.
#
-from __future__ import with_statement
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
-import sys
-
+from io import StringIO
from contextlib import contextmanager
from xml.sax.saxutils import escape, quoteattr
-if sys.version_info.major < 3:
- from StringIO import StringIO
-else:
- from io import StringIO
- unicode = str
-
def _calc_attrs_length(attributes, indent, self_indent):
if indent == -1:
@@ -141,7 +128,7 @@ class XMLWriter(object):
def write_line(self, line='', indent=True, do_escape=False):
if isinstance(line, bytes):
line = line.decode('utf-8')
- assert isinstance(line, unicode)
+ assert isinstance(line, str)
if do_escape:
line = escape(line)
if indent: