aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi/common.py6
-rw-r--r--scripts/qapi/gen.py6
-rw-r--r--scripts/qapi/parser.py6
3 files changed, 3 insertions, 15 deletions
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index e00dcafce7..ba35abea47 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -12,7 +12,6 @@
# See the COPYING file in the top-level directory.
import re
-import string
# ENUMName -> ENUM_NAME, EnumName1 -> ENUM_NAME1
@@ -43,10 +42,7 @@ def c_enum_const(type_name, const_name, prefix=None):
return camel_to_upper(type_name) + '_' + c_name(const_name, False).upper()
-if hasattr(str, 'maketrans'):
- c_name_trans = str.maketrans('.-', '__')
-else:
- c_name_trans = string.maketrans('.-', '__')
+c_name_trans = str.maketrans('.-', '__')
# Map @name to a valid C identifier.
diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
index a53a705c73..317cd72601 100644
--- a/scripts/qapi/gen.py
+++ b/scripts/qapi/gen.py
@@ -15,7 +15,6 @@
import errno
import os
import re
-import sys
from contextlib import contextmanager
from qapi.common import *
@@ -54,10 +53,7 @@ class QAPIGen:
if e.errno != errno.EEXIST:
raise
fd = os.open(pathname, os.O_RDWR | os.O_CREAT, 0o666)
- if sys.version_info[0] >= 3:
- f = open(fd, 'r+', encoding='utf-8')
- else:
- f = os.fdopen(fd, 'r+')
+ f = open(fd, 'r+', encoding='utf-8')
text = self.get_content()
oldtext = f.read(len(text) + 1)
if text != oldtext:
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index 2e3a3c5d76..cf14e5426c 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -16,7 +16,6 @@
import os
import re
-import sys
from collections import OrderedDict
from qapi.error import QAPIParseError, QAPISemError
@@ -30,10 +29,7 @@ class QAPISchemaParser:
previously_included.add(os.path.abspath(fname))
try:
- if sys.version_info[0] >= 3:
- fp = open(fname, 'r', encoding='utf-8')
- else:
- fp = open(fname, 'r')
+ fp = open(fname, 'r', encoding='utf-8')
self.src = fp.read()
except IOError as e:
raise QAPISemError(incl_info or QAPISourceInfo(None, None, None),