Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit 0ab2f4f

Browse files
committed
Fix discrepencies in build.py results between Python versions
1 parent aa374ed commit 0ab2f4f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

build.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@
2222
def pythonic_name(name):
2323
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
2424
name = re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
25-
if hasattr(builtin, name) is True or name in ['global']:
25+
if hasattr(builtin, name) is True or name in ['global', 'file', 'apply']:
2626
name += "_p"
2727
return name
2828

2929

30+
def to_string(value):
31+
if isinstance(value, str):
32+
return value
33+
return value.decode('utf-8')
34+
35+
3036
LIB_IMPORTS = """\
3137
# A Pythonic VirtalBox Main API
3238
#
@@ -762,11 +768,11 @@ def main(virtualbox_xidl='VirtualBox.xidl',
762768
uuid = library.getAttribute('uuid')
763769
version = library.getAttribute('version')
764770
xidl_hash = hashlib.md5(xidl).hexdigest()
765-
lib_meta = LIB_META % dict(vbox_version=vbox_version,
766-
uuid=uuid,
767-
version=version,
768-
app_uuid=app_uuid,
769-
xidl_hash=xidl_hash)
771+
lib_meta = LIB_META % dict(vbox_version=to_string(vbox_version),
772+
uuid=to_string(uuid),
773+
version=to_string(version),
774+
app_uuid=to_string(app_uuid),
775+
xidl_hash=to_string(xidl_hash))
770776

771777
code = []
772778
code.append(LIB_IMPORTS)
@@ -777,7 +783,7 @@ def main(virtualbox_xidl='VirtualBox.xidl',
777783
code.extend(source['enum'])
778784
code.extend(source['interface'])
779785
code = b"\n".join([c.encode('utf-8') if not isinstance(c, bytes) else c for c in code])
780-
print(" vbox version : %s" % vbox_version)
786+
print(" vbox version : %s" % to_string(vbox_version))
781787
print(" xidl hash : %s" % xidl_hash)
782788
print(" version : %s" % version)
783789
print(" line count : %s" % code.count(b"\n"))

0 commit comments

Comments
 (0)