summaryrefslogtreecommitdiff
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
parent7c770ea4bbd0ddbb4f97551d05e884af4a9f8b21 (diff)
downloadgobject-introspection-650ed1c8bd461e0ab30108a755a753c9fd46e7bf.tar.gz
Drop all Python 2 compat code
We only support 3.4+ now.
-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
-rwxr-xr-xmisc/update-glib-annotations.py5
-rw-r--r--misc/update-gtkdoc-tests.py4
-rwxr-xr-xtests/offsets/gen-gitestoffsets2
-rw-r--r--tests/scanner/annotationparser/test_parser.py15
-rw-r--r--tests/scanner/annotationparser/test_patterns.py15
-rw-r--r--tests/scanner/test_pkgconfig.py9
-rw-r--r--tests/scanner/test_shlibs.py5
-rw-r--r--tests/scanner/test_sourcescanner.py5
-rw-r--r--tests/scanner/test_transformer.py5
-rw-r--r--tests/warn/warningtester.py11
-rwxr-xr-xtools/g-ir-tool-template.in9
36 files changed, 14 insertions, 262 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:
diff --git a/misc/update-glib-annotations.py b/misc/update-glib-annotations.py
index 89e1780c..241439db 100755
--- a/misc/update-glib-annotations.py
+++ b/misc/update-glib-annotations.py
@@ -3,11 +3,6 @@
# e.g.:
# ./update-glib-annotations.py ../../glib ../../glib/_build
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
import sys
diff --git a/misc/update-gtkdoc-tests.py b/misc/update-gtkdoc-tests.py
index 4c1ec138..22098430 100644
--- a/misc/update-gtkdoc-tests.py
+++ b/misc/update-gtkdoc-tests.py
@@ -161,10 +161,6 @@ def parsed2tree(docblock):
if __name__ == '__main__':
- if sys.version_info < (3, 0):
- print('Sorry, update-gtkdoc-tests.py requires Python 3.x')
- sys.exit(1)
-
gi_tests = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'tests', 'scanner', 'annotationparser', 'gtkdoc'))
gtkdoc_tests = None
diff --git a/tests/offsets/gen-gitestoffsets b/tests/offsets/gen-gitestoffsets
index 94a2062d..2e9bc5fb 100755
--- a/tests/offsets/gen-gitestoffsets
+++ b/tests/offsets/gen-gitestoffsets
@@ -19,8 +19,6 @@
# 02110-1301, USA.
#
-from __future__ import print_function
-
# The idea here is that we want to compare offset information two ways:
#
# 1) As generated by the compiler
diff --git a/tests/scanner/annotationparser/test_parser.py b/tests/scanner/annotationparser/test_parser.py
index b676a508..368eb728 100644
--- a/tests/scanner/annotationparser/test_parser.py
+++ b/tests/scanner/annotationparser/test_parser.py
@@ -25,14 +25,8 @@ test_parser.py
Tests ensuring annotationparser.py continues to function correctly.
'''
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import difflib
import os
-import sys
import subprocess
import unittest
import xml.etree.ElementTree as etree
@@ -41,11 +35,6 @@ from giscanner.annotationparser import GtkDocCommentBlockParser, GtkDocCommentBl
from giscanner.ast import Namespace
from giscanner.message import MessageLogger, WARNING, ERROR, FATAL
-if sys.version_info.major < 3:
- encode_name = lambda s: s.encode('ascii')
-else:
- encode_name = lambda s: s
-
XML_NS = 'http://schemas.gnome.org/gobject-introspection/2013/test'
XML_SCHEMA = os.path.abspath(os.path.join(os.path.dirname(__file__), 'tests.xsd'))
@@ -406,7 +395,7 @@ def create_test_case(logger, tests_dir, tests_file):
for counter, test in enumerate(tests_tree.findall(ns('{}test'))):
test_name = 'test_%03d' % (counter + 1)
test_method = TestCommentBlock.__create_test__(logger, test)
- test_method.__name__ = encode_name(test_name)
+ test_method.__name__ = test_name
test_methods[test_name] = test_method
# Dynamically generate a new subclass of TestCommentBlock in TitleCase
@@ -414,7 +403,7 @@ def create_test_case(logger, tests_dir, tests_file):
test_class_name = os.path.relpath(tests_file[:-4], tests_dir)
test_class_name = test_class_name.replace('/', ' ').replace('\\', ' ').replace('.', ' ')
test_class_name = 'Test' + test_class_name.title().replace(' ', '')
- return type(encode_name(test_class_name), (TestCommentBlock,), test_methods)
+ return type(test_class_name, (TestCommentBlock,), test_methods)
def create_test_cases():
diff --git a/tests/scanner/annotationparser/test_patterns.py b/tests/scanner/annotationparser/test_patterns.py
index 0a0e3175..131d6282 100644
--- a/tests/scanner/annotationparser/test_patterns.py
+++ b/tests/scanner/annotationparser/test_patterns.py
@@ -29,12 +29,6 @@ should match, resulting symbolic groups are verified
against the expected output.
'''
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
-import sys
import unittest
from giscanner.annotationparser import (COMMENT_BLOCK_START_RE, COMMENT_BLOCK_END_RE,
@@ -43,11 +37,6 @@ from giscanner.annotationparser import (COMMENT_BLOCK_START_RE, COMMENT_BLOCK_EN
SIGNAL_RE, PARAMETER_RE, TAG_RE,
TAG_VALUE_VERSION_RE, TAG_VALUE_STABILITY_RE)
-if sys.version_info.major < 3:
- encode_name = lambda s: s.encode('ascii')
-else:
- encode_name = lambda s: s
-
comment_start_tests = [
(COMMENT_BLOCK_START_RE, '/**',
@@ -902,10 +891,10 @@ def create_test_case(tests_class_name, testcases):
for counter, test in enumerate(testcases):
test_name = 'test_%03d' % (counter + 1)
test_method = create_test_method(test)
- test_method.__name__ = encode_name(test_name)
+ test_method.__name__ = test_name
test_methods[test_name] = test_method
- return type(encode_name(tests_class_name), (unittest.TestCase,), test_methods)
+ return type(tests_class_name, (unittest.TestCase,), test_methods)
def create_test_cases():
diff --git a/tests/scanner/test_pkgconfig.py b/tests/scanner/test_pkgconfig.py
index e81dedb6..8b654e38 100644
--- a/tests/scanner/test_pkgconfig.py
+++ b/tests/scanner/test_pkgconfig.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 contextlib
import os
import sys
@@ -88,9 +83,7 @@ class PkgConfigTest(unittest.TestCase):
with pkg_config_script(s) as command:
pkgconfig.libs(['a', 'b-42.0'], command=command)
- @unittest.skipIf(
- sys.version_info < (3, 0) or os.name == "nt",
- "Python 2 defaults to ascii encoding in text file I/O and nothing is done to change that")
+ @unittest.skipIf(os.name == "nt", "FIXME")
def test_non_ascii_output(self):
with pkg_config_script("""print("-L'zażółć gęślą jaźń'")""") as command:
flags = pkgconfig.cflags(['test-1.0'], command=command)
diff --git a/tests/scanner/test_shlibs.py b/tests/scanner/test_shlibs.py
index c3e28892..f3fb0d2e 100644
--- a/tests/scanner/test_shlibs.py
+++ b/tests/scanner/test_shlibs.py
@@ -1,8 +1,3 @@
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import unittest
from giscanner.shlibs import resolve_from_ldd_output
diff --git a/tests/scanner/test_sourcescanner.py b/tests/scanner/test_sourcescanner.py
index 831af486..3963683d 100644
--- a/tests/scanner/test_sourcescanner.py
+++ b/tests/scanner/test_sourcescanner.py
@@ -1,8 +1,3 @@
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import unittest
import tempfile
import os
diff --git a/tests/scanner/test_transformer.py b/tests/scanner/test_transformer.py
index c0fb2d6f..27bfad58 100644
--- a/tests/scanner/test_transformer.py
+++ b/tests/scanner/test_transformer.py
@@ -1,8 +1,3 @@
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import unittest
import tempfile
import os
diff --git a/tests/warn/warningtester.py b/tests/warn/warningtester.py
index be5aec13..8f441879 100644
--- a/tests/warn/warningtester.py
+++ b/tests/warn/warningtester.py
@@ -1,16 +1,7 @@
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
import sys
import difflib
-
-if sys.version_info.major < 3:
- import __builtin__ as builtins
-else:
- import builtins
+import builtins
path = os.getenv('UNINSTALLED_INTROSPECTION_SRCDIR', None)
assert path is not None
diff --git a/tools/g-ir-tool-template.in b/tools/g-ir-tool-template.in
index b9cf0911..3b33f75d 100755
--- a/tools/g-ir-tool-template.in
+++ b/tools/g-ir-tool-template.in
@@ -18,19 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 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 sysconfig
+import builtins
-if sys.version_info.major < 3:
- import __builtin__ as builtins
-else:
- import builtins
debug = os.getenv('GI_SCANNER_DEBUG')
if debug: