Index: /trunk/Config.kmk
===================================================================
--- /trunk/Config.kmk	(revision 59797)
+++ /trunk/Config.kmk	(revision 59798)
@@ -6474,2 +6474,3 @@
 	$(MAKE) VBOX_QUICK=1
 
+
Index: /trunk/doc/manual/en_US/SDKRef.xml
===================================================================
--- /trunk/doc/manual/en_US/SDKRef.xml	(revision 59797)
+++ /trunk/doc/manual/en_US/SDKRef.xml	(revision 59798)
@@ -781,4 +781,6 @@
         <xref linkend="glue-python"/>.</para>
 
+        <para>The minimum supported Python version is 2.6.</para>
+
         <para>As indicated in <xref linkend="webservice-or-com"/>, the
         COM/XPCOM API gives better performance without the SOAP overhead, and
@@ -788,16 +790,13 @@
         platform<footnote>
             <para>On On Mac OS X only the Python versions bundled with the OS
-            are officially supported. This means Python 2.3 for 10.4, Python
-            2.5 for 10.5 and Python 2.5 and 2.6 for 10.6.</para>
+            are officially supported. This means 2.6 and 2.7 for 10.8 and later.</para>
           </footnote>). On Windows, you can use the Main API from Python if the
           Win32 extensions package for Python<footnote>
             <para>See <ulink
             url="http://sourceforge.net/project/showfiles.php?group_id=78018">http://sourceforge.net/project/showfiles.php?group_id=78018</ulink>.</para>
-          </footnote> is installed. Version of Python Win32 extensions earlier
+          </footnote> is installed. Versions of Python Win32 extensions earlier
           than 2.16 are known to have bugs, leading to issues with VirtualBox
-          Python bindings, and also some early builds of Python 2.5 for Windows
-          have issues with reporting platform name on some Windows versions, so
-          please make sure to use latest available Python and Win32
-          extensions.</para>
+          Python bindings, so please make sure to use latest available Python
+          and Win32 extensions.</para>
 
         <para>The VirtualBox OOWS for Python relies on the Python ZSI SOAP
@@ -1497,4 +1496,6 @@
         the glue layer if you want to use a different Python
         installation.</para>
+
+        <para>The minimum supported Python version is 2.6.</para>
 
         <para>In this layer, the class
Index: /trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
===================================================================
--- /trunk/src/VBox/Frontends/VBoxShell/vboxshell.py	(revision 59797)
+++ /trunk/src/VBox/Frontends/VBoxShell/vboxshell.py	(revision 59798)
@@ -2,4 +2,5 @@
 # -*- coding: utf-8 -*-
 # $Id$
+
 """
 VirtualBox Python Shell.
@@ -19,7 +20,9 @@
 """
 
+from __future__ import print_function
+
 __copyright__ = \
 """
-Copyright (C) 2009-2015 Oracle Corporation
+Copyright (C) 2009-2016 Oracle Corporation
 
 This file is part of VirtualBox Open Source Edition (OSE), as
@@ -34,5 +37,6 @@
 
 
-import os, sys
+import os
+import sys
 import traceback
 import shlex
@@ -42,5 +46,4 @@
 from optparse import OptionParser
 from pprint import pprint
-
 
 
@@ -152,5 +155,5 @@
                             matches.append(word)
 
-            except Exception, e:
+            except Exception as e:
                 printErr(self.ctx, e)
                 if g_fVerbose:
@@ -164,5 +167,5 @@
 
     comps = {}
-    for (key, _value) in cmds.items():
+    for (key, _value) in list(cmds.items()):
         comps[key] = None
     completer = CompleterNG(comps, ctx)
@@ -189,5 +192,5 @@
     try:
         while not progress.completed:
-            print "%s %%\r" % (colored(str(progress.percent), 'red')),
+            print("%s %%\r" % (colored(str(progress.percent), 'red')), end="")
             sys.stdout.flush()
             progress.waitForCompletion(wait)
@@ -197,22 +200,22 @@
         return 1
     except KeyboardInterrupt:
-        print "Interrupted."
+        print("Interrupted.")
         ctx['interrupt'] = True
         if progress.cancelable:
-            print "Canceling task..."
+            print("Canceling task...")
             progress.cancel()
         return 0
 
 def printErr(_ctx, e):
-    oVBoxMgr = _ctx['global'];
+    oVBoxMgr = _ctx['global']
     if oVBoxMgr.errIsOurXcptKind(e):
-        print colored('%s: %s' % (oVBoxMgr.xcptToString(e), oVBoxMgr.xcptGetMessage(e)), 'red');
-    else:
-        print colored(str(e), 'red')
+        print(colored('%s: %s' % (oVBoxMgr.xcptToString(e), oVBoxMgr.xcptGetMessage(e)), 'red'))
+    else:
+        print(colored(str(e), 'red'))
 
 def reportError(_ctx, progress):
     errorinfo = progress.errorInfo
     if errorinfo:
-        print colored("Error in module '%s': %s" % (errorinfo.component, errorinfo.text), 'red')
+        print(colored("Error in module '%s': %s" % (errorinfo.component, errorinfo.text), 'red'))
 
 def colCat(_ctx, strg):
@@ -241,5 +244,5 @@
     mach = vbox.createMachine("", name, [], kind, "")
     mach.saveSettings()
-    print "created machine with UUID", mach.id
+    print("created machine with UUID", mach.id)
     vbox.registerMachine(mach)
     # update cache
@@ -248,5 +251,5 @@
 def removeVm(ctx, mach):
     uuid = mach.id
-    print "removing machine ", mach.name, "with UUID", uuid
+    print("removing machine ", mach.name, "with UUID", uuid)
     cmdClosedVm(ctx, mach, detachVmDevice, ["ALL"])
     disks = mach.unregister(ctx['global'].constants.CleanupMode_Full)
@@ -254,5 +257,5 @@
         progress = mach.deleteConfig(disks)
         if progressBar(ctx, progress, 100) and int(progress.resultCode) == 0:
-            print "Success!"
+            print("Success!")
         else:
             reportError(ctx, progress)
@@ -271,5 +274,5 @@
             try:
                 perf.setup(['*'], [mach], 10, 15)
-            except Exception, e:
+            except Exception as e:
                 printErr(ctx, e)
                 if g_fVerbose:
@@ -324,17 +327,17 @@
         return
     for metric in ctx['perf'].query(["*"], [mach]):
-        print metric['name'], metric['values_as_string']
+        print(metric['name'], metric['values_as_string'])
 
 def guestExec(ctx, machine, console, cmds):
-    exec cmds
+    exec(cmds)
 
 def printMouseEvent(_ctx, mev):
-    print "Mouse : mode=%d x=%d y=%d z=%d w=%d buttons=%x" % (mev.mode, mev.x, mev.y, mev.z, mev.w, mev.buttons)
+    print("Mouse : mode=%d x=%d y=%d z=%d w=%d buttons=%x" % (mev.mode, mev.x, mev.y, mev.z, mev.w, mev.buttons))
 
 def printKbdEvent(ctx, kev):
-    print "Kbd: ", ctx['global'].getArray(kev, 'scancodes')
+    print("Kbd: ", ctx['global'].getArray(kev, 'scancodes'))
 
 def printMultiTouchEvent(ctx, mtev):
-    print "MultiTouch : contacts=%d time=%d" % (mtev.contactCount, mtev.scanTime)
+    print("MultiTouch : contacts=%d time=%d" % (mtev.contactCount, mtev.scanTime))
     xPositions = ctx['global'].getArray(mtev, 'xPositions')
     yPositions = ctx['global'].getArray(mtev, 'yPositions')
@@ -343,22 +346,22 @@
 
     for i in range(0, mtev.contactCount):
-        print "  [%d] %d,%d %d %d" % (i, xPositions[i], yPositions[i], contactIds[i], contactFlags[i])
+        print("  [%d] %d,%d %d %d" % (i, xPositions[i], yPositions[i], contactIds[i], contactFlags[i]))
 
 def monitorSource(ctx, eventSource, active, dur):
     def handleEventImpl(event):
         evtype = event.type
-        print "got event: %s %s" % (str(evtype), asEnumElem(ctx, 'VBoxEventType', evtype))
+        print("got event: %s %s" % (str(evtype), asEnumElem(ctx, 'VBoxEventType', evtype)))
         if evtype == ctx['global'].constants.VBoxEventType_OnMachineStateChanged:
             scev = ctx['global'].queryInterface(event, 'IMachineStateChangedEvent')
             if scev:
-                print "machine state event: mach=%s state=%s" % (scev.machineId, scev.state)
+                print("machine state event: mach=%s state=%s" % (scev.machineId, scev.state))
         elif  evtype == ctx['global'].constants.VBoxEventType_OnSnapshotTaken:
             stev = ctx['global'].queryInterface(event, 'ISnapshotTakenEvent')
             if stev:
-                print "snapshot taken event: mach=%s snap=%s" % (stev.machineId, stev.snapshotId)
+                print("snapshot taken event: mach=%s snap=%s" % (stev.machineId, stev.snapshotId))
         elif  evtype == ctx['global'].constants.VBoxEventType_OnGuestPropertyChanged:
             gpcev = ctx['global'].queryInterface(event, 'IGuestPropertyChangedEvent')
             if gpcev:
-                print "guest property change: name=%s value=%s" % (gpcev.name, gpcev.value)
+                print("guest property change: name=%s value=%s" % (gpcev.name, gpcev.value))
         elif  evtype == ctx['global'].constants.VBoxEventType_OnMousePointerShapeChanged:
             psev = ctx['global'].queryInterface(event, 'IMousePointerShapeChangedEvent')
@@ -366,7 +369,7 @@
                 shape = ctx['global'].getArray(psev, 'shape')
                 if shape is None:
-                    print "pointer shape event - empty shape"
+                    print("pointer shape event - empty shape")
                 else:
-                    print "pointer shape event: w=%d h=%d shape len=%d" % (psev.width, psev.height, len(shape))
+                    print("pointer shape event: w=%d h=%d shape len=%d" % (psev.width, psev.height, len(shape)))
         elif evtype == ctx['global'].constants.VBoxEventType_OnGuestMouse:
             mev = ctx['global'].queryInterface(event, 'IGuestMouseEvent')
@@ -441,5 +444,5 @@
     def handleEventImpl(event):
         evtype = event.type
-        #print "got event: %s %s" % (str(evtype), asEnumElem(ctx, 'VBoxEventType', evtype))
+        #print("got event: %s %s" % (str(evtype), asEnumElem(ctx, 'VBoxEventType', evtype)))
         if evtype == ctx['global'].constants.VBoxEventType_OnGuestMouse:
             mev = ctx['global'].queryInterface(event, 'IGuestMouseEvent')
@@ -489,5 +492,5 @@
 
     header = demo.readline()
-    print "Header is", header
+    print("Header is", header)
     basere = re.compile(r'(?P<s>\d+): (?P<t>[km]) (?P<p>.*)')
     mre = re.compile(r'(?P<a>\d+) (?P<x>-*\d+) (?P<y>-*\d+) (?P<z>-*\d+) (?P<w>-*\d+) (?P<b>-*\d+)')
@@ -515,5 +518,5 @@
             if rtype == 'k':
                 codes = kre.findall(params)
-                #print "KBD:", codes
+                #print("KBD:", codes)
                 kbd.putScancodes(codes)
             elif rtype == 'm':
@@ -523,8 +526,8 @@
                     if mdict['a'] == '1':
                         # absolute
-                        #print "MA: ", mdict['x'], mdict['y'], mdict['z'], mdict['b']
+                        #print("MA: ", mdict['x'], mdict['y'], mdict['z'], mdict['b'])
                         mouse.putMouseEventAbsolute(int(mdict['x']), int(mdict['y']), int(mdict['z']), int(mdict['w']), int(mdict['b']))
                     else:
-                        #print "MR: ", mdict['x'], mdict['y'], mdict['b']
+                        #print("MR: ", mdict['x'], mdict['y'], mdict['b'])
                         mouse.putMouseEvent(int(mdict['x']), int(mdict['y']), int(mdict['z']), int(mdict['w']), int(mdict['b']))
 
@@ -559,5 +562,5 @@
         h = fbh
 
-    print "Saving screenshot (%d x %d) screen %d in %s..." % (w, h, screen, f)
+    print("Saving screenshot (%d x %d) screen %d in %s..." % (w, h, screen, f))
     data = display.takeScreenShotToArray(screen, w, h, ctx['const'].BitmapFormat_RGBA)
     size = (w, h)
@@ -586,5 +589,5 @@
         h = fbh
 
-    print "Saving screenshot (%d x %d) screen %d in %s..." % (w, h, screen, f)
+    print("Saving screenshot (%d x %d) screen %d in %s..." % (w, h, screen, f))
     data = display.takeScreenShotToArray(screen, w, h, ctx['const'].BitmapFormat_PNG)
     pngfile = open(f, 'wb')
@@ -594,5 +597,5 @@
 def teleport(ctx, _session, console, args):
     if args[0].find(":") == -1:
-        print "Use host:port format for teleport target"
+        print("Use host:port format for teleport target")
         return
     (host, port) = args[0].split(":")
@@ -608,8 +611,8 @@
 
     port = int(port)
-    print "Teleporting to %s:%d..." % (host, port)
+    print("Teleporting to %s:%d..." % (host, port))
     progress = console.teleport(host, port, passwd, maxDowntime)
     if progressBar(ctx, progress, 100) and int(progress.resultCode) == 0:
-        print "Success!"
+        print("Success!")
     else:
         reportError(ctx, progress)
@@ -632,8 +635,8 @@
     all_stats = ctx['const'].all_values('GuestStatisticType')
     cpu = 0
-    for s in all_stats.keys():
+    for s in list(all_stats.keys()):
         try:
             val = guest.getStatistic( cpu, all_stats[s])
-            print "%s: %d" % (s, val)
+            print("%s: %d" % (s, val))
         except:
             # likely not implemented
@@ -642,10 +645,10 @@
 def plugCpu(_ctx, machine, _session, args):
     cpu = int(args[0])
-    print "Adding CPU %d..." % (cpu)
+    print("Adding CPU %d..." % (cpu))
     machine.hotPlugCPU(cpu)
 
 def unplugCpu(_ctx, machine, _session, args):
     cpu = int(args[0])
-    print "Removing CPU %d..." % (cpu)
+    print("Removing CPU %d..." % (cpu))
     machine.hotUnplugCPU(cpu)
 
@@ -661,31 +664,31 @@
 
 def printHostUsbDev(ctx, ud):
-    print "  %s: %s (vendorId=%d productId=%d serial=%s) %s" % (ud.id, colored(ud.product, 'blue'), ud.vendorId, ud.productId, ud.serialNumber, asEnumElem(ctx, 'USBDeviceState', ud.state))
+    print("  %s: %s (vendorId=%d productId=%d serial=%s) %s" % (ud.id, colored(ud.product, 'blue'), ud.vendorId, ud.productId, ud.serialNumber, asEnumElem(ctx, 'USBDeviceState', ud.state)))
 
 def printUsbDev(_ctx, ud):
-    print "  %s: %s (vendorId=%d productId=%d serial=%s)" % (ud.id,  colored(ud.product, 'blue'), ud.vendorId, ud.productId, ud.serialNumber)
+    print("  %s: %s (vendorId=%d productId=%d serial=%s)" % (ud.id,  colored(ud.product, 'blue'), ud.vendorId, ud.productId, ud.serialNumber))
 
 def printSf(ctx, sf):
-    print "    name=%s host=%s %s %s" % (sf.name, colPath(ctx, sf.hostPath), cond(sf.accessible, "accessible", "not accessible"), cond(sf.writable, "writable", "read-only"))
+    print("    name=%s host=%s %s %s" % (sf.name, colPath(ctx, sf.hostPath), cond(sf.accessible, "accessible", "not accessible"), cond(sf.writable, "writable", "read-only")))
 
 def ginfo(ctx, console, _args):
     guest = console.guest
     if guest.additionsRunLevel != ctx['const'].AdditionsRunLevelType_None:
-        print "Additions active, version %s" % (guest.additionsVersion)
-        print "Support seamless: %s" % (getFacilityStatus(ctx, guest, ctx['const'].AdditionsFacilityType_Seamless))
-        print "Support graphics: %s" % (getFacilityStatus(ctx, guest, ctx['const'].AdditionsFacilityType_Graphics))
-        print "Balloon size: %d" % (guest.memoryBalloonSize)
-        print "Statistic update interval: %d" % (guest.statisticsUpdateInterval)
-    else:
-        print "No additions"
+        print("Additions active, version %s" % (guest.additionsVersion))
+        print("Support seamless: %s" % (getFacilityStatus(ctx, guest, ctx['const'].AdditionsFacilityType_Seamless)))
+        print("Support graphics: %s" % (getFacilityStatus(ctx, guest, ctx['const'].AdditionsFacilityType_Graphics)))
+        print("Balloon size: %d" % (guest.memoryBalloonSize))
+        print("Statistic update interval: %d" % (guest.statisticsUpdateInterval))
+    else:
+        print("No additions")
     usbs = ctx['global'].getArray(console, 'USBDevices')
-    print "Attached USB:"
+    print("Attached USB:")
     for ud in usbs:
         printUsbDev(ctx, ud)
     rusbs = ctx['global'].getArray(console, 'remoteUSBDevices')
-    print "Remote USB:"
+    print("Remote USB:")
     for ud in rusbs:
         printHostUsbDev(ctx, ud)
-    print "Transient shared folders:"
+    print("Transient shared folders:")
     sfs = rusbs = ctx['global'].getArray(console, 'sharedFolders')
     for sf in sfs:
@@ -698,5 +701,5 @@
         session = ctx['global'].getSessionObject(vbox)
         mach.lockMachine(session, ctx['global'].constants.LockType_Shared)
-    except Exception, e:
+    except Exception as e:
         printErr(ctx, "Session to '%s' not open: %s" % (mach.name, str(e)))
         if g_fVerbose:
@@ -704,5 +707,5 @@
         return
     if session.state != ctx['const'].SessionState_Locked:
-        print "Session to '%s' in wrong state: %s" % (mach.name, session.state)
+        print("Session to '%s' in wrong state: %s" % (mach.name, session.state))
         session.unlockMachine()
         return
@@ -710,5 +713,5 @@
     # in Webservices) functionality
     if ctx['remote'] and cmd == 'some_local_only_command':
-        print 'Trying to use local only functionality, ignored'
+        print('Trying to use local only functionality, ignored')
         session.unlockMachine()
         return
@@ -734,5 +737,5 @@
     except KeyboardInterrupt:
         ctx['interrupt'] = True
-    except Exception, e:
+    except Exception as e:
         printErr(ctx, e)
         if g_fVerbose:
@@ -747,5 +750,5 @@
     try:
         cmd(ctx, mach, args)
-    except Exception, e:
+    except Exception as e:
         save = False
         printErr(ctx, e)
@@ -755,5 +758,5 @@
         try:
             mach.saveSettings()
-        except Exception, e:
+        except Exception as e:
             printErr(ctx, e)
             if g_fVerbose:
@@ -767,5 +770,5 @@
     try:
         cmd(ctx, mach, session.console, args)
-    except Exception, e:
+    except Exception as e:
         save = False
         printErr(ctx, e)
@@ -777,8 +780,5 @@
 
 def machById(ctx, uuid):
-    try:
-        mach = ctx['vb'].getMachine(uuid)
-    except:
-        mach = ctx['vb'].findMachine(uuid)
+    mach = ctx['vb'].findMachine(uuid)
     return mach
 
@@ -899,10 +899,10 @@
 def argsToMach(ctx, args):
     if len(args) < 2:
-        print "usage: %s [vmname|uuid]" % (args[0])
+        print("usage: %s [vmname|uuid]" % (args[0]))
         return None
     uuid = args[1]
     mach = machById(ctx, uuid)
     if mach == None:
-        print "Machine '%s' is unknown, use list command to find available machines" % (uuid)
+        print("Machine '%s' is unknown, use list command to find available machines" % (uuid))
     return mach
 
@@ -912,10 +912,10 @@
     else:
         spec = ""
-    print "    %s: %s%s" % (colored(cmd, 'blue'), h, spec)
+    print("    %s: %s%s" % (colored(cmd, 'blue'), h, spec))
 
 def helpCmd(_ctx, args):
     if len(args) == 1:
-        print "Help page:"
-        names = commands.keys()
+        print("Help page:")
+        names = list(commands.keys())
         names.sort()
         for i in names:
@@ -925,5 +925,5 @@
         c = commands.get(cmd)
         if c == None:
-            print "Command '%s' not known" % (cmd)
+            print("Command '%s' not known" % (cmd))
         else:
             helpSingleCmd(cmd, c[0], c[2])
@@ -932,5 +932,5 @@
 def asEnumElem(ctx, enum, elem):
     enumVals = ctx['const'].all_values(enum)
-    for e in enumVals.keys():
+    for e in list(enumVals.keys()):
         if str(elem) == str(enumVals[e]):
             return colored(e, 'green')
@@ -948,6 +948,6 @@
             else:
                 tele = "    "
-                print "%sMachine '%s' [%s], machineState=%s, sessionState=%s" % (tele, colVm(ctx, mach.name), mach.id, asEnumElem(ctx, "MachineState", mach.state), asEnumElem(ctx, "SessionState", mach.sessionState))
-        except Exception, e:
+                print("%sMachine '%s' [%s], machineState=%s, sessionState=%s" % (tele, colVm(ctx, mach.name), mach.id, asEnumElem(ctx, "MachineState", mach.state), asEnumElem(ctx, "SessionState", mach.sessionState)))
+        except Exception as e:
             printErr(ctx, e)
             if g_fVerbose:
@@ -956,6 +956,6 @@
 
 def infoCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: info [vmname|uuid]"
+    if len(args) < 2:
+        print("usage: info [vmname|uuid]")
         return 0
     mach = argsToMach(ctx, args)
@@ -963,109 +963,109 @@
         return 0
     vmos = ctx['vb'].getGuestOSType(mach.OSTypeId)
-    print " One can use setvar <mach> <var> <value> to change variable, using name in []."
-    print "  Name [name]: %s" % (colVm(ctx, mach.name))
-    print "  Description [description]: %s" % (mach.description)
-    print "  ID [n/a]: %s" % (mach.id)
-    print "  OS Type [via OSTypeId]: %s" % (vmos.description)
-    print "  Firmware [firmwareType]: %s (%s)" % (asEnumElem(ctx, "FirmwareType", mach.firmwareType), mach.firmwareType)
-    print
-    print "  CPUs [CPUCount]: %d" % (mach.CPUCount)
-    print "  RAM [memorySize]: %dM" % (mach.memorySize)
-    print "  VRAM [VRAMSize]: %dM" % (mach.VRAMSize)
-    print "  Monitors [monitorCount]: %d" % (mach.monitorCount)
-    print "  Chipset [chipsetType]: %s (%s)" % (asEnumElem(ctx, "ChipsetType", mach.chipsetType), mach.chipsetType)
-    print
-    print "  Clipboard mode [clipboardMode]: %s (%s)" % (asEnumElem(ctx, "ClipboardMode", mach.clipboardMode), mach.clipboardMode)
-    print "  Machine status [n/a]: %s (%s)" % (asEnumElem(ctx, "SessionState", mach.sessionState), mach.sessionState)
-    print
+    print(" One can use setvar <mach> <var> <value> to change variable, using name in [].")
+    print("  Name [name]: %s" % (colVm(ctx, mach.name)))
+    print("  Description [description]: %s" % (mach.description))
+    print("  ID [n/a]: %s" % (mach.id))
+    print("  OS Type [via OSTypeId]: %s" % (vmos.description))
+    print("  Firmware [firmwareType]: %s (%s)" % (asEnumElem(ctx, "FirmwareType", mach.firmwareType), mach.firmwareType))
+    print()
+    print("  CPUs [CPUCount]: %d" % (mach.CPUCount))
+    print("  RAM [memorySize]: %dM" % (mach.memorySize))
+    print("  VRAM [VRAMSize]: %dM" % (mach.VRAMSize))
+    print("  Monitors [monitorCount]: %d" % (mach.monitorCount))
+    print("  Chipset [chipsetType]: %s (%s)" % (asEnumElem(ctx, "ChipsetType", mach.chipsetType), mach.chipsetType))
+    print()
+    print("  Clipboard mode [clipboardMode]: %s (%s)" % (asEnumElem(ctx, "ClipboardMode", mach.clipboardMode), mach.clipboardMode))
+    print("  Machine status [n/a]: %s (%s)" % (asEnumElem(ctx, "SessionState", mach.sessionState), mach.sessionState))
+    print()
     if mach.teleporterEnabled:
-        print "  Teleport target on port %d (%s)" % (mach.teleporterPort, mach.teleporterPassword)
-        print
+        print("  Teleport target on port %d (%s)" % (mach.teleporterPort, mach.teleporterPassword))
+        print()
     bios = mach.BIOSSettings
-    print "  ACPI [BIOSSettings.ACPIEnabled]: %s" % (asState(bios.ACPIEnabled))
-    print "  APIC [BIOSSettings.IOAPICEnabled]: %s" % (asState(bios.IOAPICEnabled))
+    print("  ACPI [BIOSSettings.ACPIEnabled]: %s" % (asState(bios.ACPIEnabled)))
+    print("  APIC [BIOSSettings.IOAPICEnabled]: %s" % (asState(bios.IOAPICEnabled)))
     hwVirtEnabled = mach.getHWVirtExProperty(ctx['global'].constants.HWVirtExPropertyType_Enabled)
-    print "  Hardware virtualization [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_Enabled, value)]: " + asState(hwVirtEnabled)
+    print("  Hardware virtualization [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_Enabled, value)]: " + asState(hwVirtEnabled))
     hwVirtVPID = mach.getHWVirtExProperty(ctx['const'].HWVirtExPropertyType_VPID)
-    print "  VPID support [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_VPID, value)]: " + asState(hwVirtVPID)
+    print("  VPID support [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_VPID, value)]: " + asState(hwVirtVPID))
     hwVirtNestedPaging = mach.getHWVirtExProperty(ctx['const'].HWVirtExPropertyType_NestedPaging)
-    print "  Nested paging [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_NestedPaging, value)]: " + asState(hwVirtNestedPaging)
-
-    print "  Hardware 3d acceleration [accelerate3DEnabled]: " + asState(mach.accelerate3DEnabled)
-    print "  Hardware 2d video acceleration [accelerate2DVideoEnabled]: " + asState(mach.accelerate2DVideoEnabled)
-
-    print "  Use universal time [RTCUseUTC]: %s" % (asState(mach.RTCUseUTC))
-    print "  HPET [HPETEnabled]: %s" % (asState(mach.HPETEnabled))
+    print("  Nested paging [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_NestedPaging, value)]: " + asState(hwVirtNestedPaging))
+
+    print("  Hardware 3d acceleration [accelerate3DEnabled]: " + asState(mach.accelerate3DEnabled))
+    print("  Hardware 2d video acceleration [accelerate2DVideoEnabled]: " + asState(mach.accelerate2DVideoEnabled))
+
+    print("  Use universal time [RTCUseUTC]: %s" % (asState(mach.RTCUseUTC)))
+    print("  HPET [HPETEnabled]: %s" % (asState(mach.HPETEnabled)))
     if mach.audioAdapter.enabled:
-        print "  Audio [via audioAdapter]: chip %s; host driver %s" % (asEnumElem(ctx, "AudioControllerType", mach.audioAdapter.audioController), asEnumElem(ctx, "AudioDriverType",  mach.audioAdapter.audioDriver))
-    print "  CPU hotplugging [CPUHotPlugEnabled]: %s" % (asState(mach.CPUHotPlugEnabled))
-
-    print "  Keyboard [keyboardHIDType]: %s (%s)" % (asEnumElem(ctx, "KeyboardHIDType", mach.keyboardHIDType), mach.keyboardHIDType)
-    print "  Pointing device [pointingHIDType]: %s (%s)" % (asEnumElem(ctx, "PointingHIDType", mach.pointingHIDType), mach.pointingHIDType)
-    print "  Last changed [n/a]: " + time.asctime(time.localtime(long(mach.lastStateChange)/1000))
+        print("  Audio [via audioAdapter]: chip %s; host driver %s" % (asEnumElem(ctx, "AudioControllerType", mach.audioAdapter.audioController), asEnumElem(ctx, "AudioDriverType",  mach.audioAdapter.audioDriver)))
+    print("  CPU hotplugging [CPUHotPlugEnabled]: %s" % (asState(mach.CPUHotPlugEnabled)))
+
+    print("  Keyboard [keyboardHIDType]: %s (%s)" % (asEnumElem(ctx, "KeyboardHIDType", mach.keyboardHIDType), mach.keyboardHIDType))
+    print("  Pointing device [pointingHIDType]: %s (%s)" % (asEnumElem(ctx, "PointingHIDType", mach.pointingHIDType), mach.pointingHIDType))
+    print("  Last changed [n/a]: " + time.asctime(time.localtime(mach.lastStateChange/1000)))
     # OSE has no VRDE
     try:
-        print "  VRDE server [VRDEServer.enabled]: %s" % (asState(mach.VRDEServer.enabled))
+        print("  VRDE server [VRDEServer.enabled]: %s" % (asState(mach.VRDEServer.enabled)))
     except:
         pass
 
-    print
-    print colCat(ctx, "  USB Controllers:")
+    print()
+    print(colCat(ctx, "  USB Controllers:"))
     for oUsbCtrl in ctx['global'].getArray(mach, 'USBControllers'):
-        print "    '%s': type %s  standard: %#x" \
-            % (oUsbCtrl.name, asEnumElem(ctx, "USBControllerType", oUsbCtrl.type), oUsbCtrl.USBStandard);
-
-    print
-    print colCat(ctx, "  I/O subsystem info:")
-    print "   Cache enabled [IOCacheEnabled]: %s" % (asState(mach.IOCacheEnabled))
-    print "   Cache size [IOCacheSize]: %dM" % (mach.IOCacheSize)
+        print("    '%s': type %s  standard: %#x" \
+            % (oUsbCtrl.name, asEnumElem(ctx, "USBControllerType", oUsbCtrl.type), oUsbCtrl.USBStandard))
+
+    print()
+    print(colCat(ctx, "  I/O subsystem info:"))
+    print("   Cache enabled [IOCacheEnabled]: %s" % (asState(mach.IOCacheEnabled)))
+    print("   Cache size [IOCacheSize]: %dM" % (mach.IOCacheSize))
 
     controllers = ctx['global'].getArray(mach, 'storageControllers')
     if controllers:
-        print
-        print colCat(ctx, "  Storage Controllers:")
+        print()
+        print(colCat(ctx, "  Storage Controllers:"))
     for controller in controllers:
-        print "    '%s': bus %s type %s" % (controller.name, asEnumElem(ctx, "StorageBus", controller.bus), asEnumElem(ctx, "StorageControllerType", controller.controllerType))
+        print("    '%s': bus %s type %s" % (controller.name, asEnumElem(ctx, "StorageBus", controller.bus), asEnumElem(ctx, "StorageControllerType", controller.controllerType)))
 
     attaches = ctx['global'].getArray(mach, 'mediumAttachments')
     if attaches:
-        print
-        print colCat(ctx, "  Media:")
+        print()
+        print(colCat(ctx, "  Media:"))
     for a in attaches:
-        print "   Controller: '%s' port/device: %d:%d type: %s (%s):" % (a.controller, a.port, a.device, asEnumElem(ctx, "DeviceType", a.type), a.type)
+        print("   Controller: '%s' port/device: %d:%d type: %s (%s):" % (a.controller, a.port, a.device, asEnumElem(ctx, "DeviceType", a.type), a.type))
         medium = a.medium
         if a.type == ctx['global'].constants.DeviceType_HardDisk:
-            print "   HDD:"
-            print "    Id: %s" % (medium.id)
-            print "    Location: %s" % (colPath(ctx, medium.location))
-            print "    Name: %s" % (medium.name)
-            print "    Format: %s" % (medium.format)
+            print("   HDD:")
+            print("    Id: %s" % (medium.id))
+            print("    Location: %s" % (colPath(ctx, medium.location)))
+            print("    Name: %s" % (medium.name))
+            print("    Format: %s" % (medium.format))
 
         if a.type == ctx['global'].constants.DeviceType_DVD:
-            print "   DVD:"
+            print("   DVD:")
             if medium:
-                print "    Id: %s" % (medium.id)
-                print "    Name: %s" % (medium.name)
+                print("    Id: %s" % (medium.id))
+                print("    Name: %s" % (medium.name))
                 if medium.hostDrive:
-                    print "    Host DVD %s" % (colPath(ctx, medium.location))
+                    print("    Host DVD %s" % (colPath(ctx, medium.location)))
                     if a.passthrough:
-                        print "    [passthrough mode]"
+                        print("    [passthrough mode]")
                 else:
-                    print "    Virtual image at %s" % (colPath(ctx, medium.location))
-                    print "    Size: %s" % (medium.size)
+                    print("    Virtual image at %s" % (colPath(ctx, medium.location)))
+                    print("    Size: %s" % (medium.size))
 
         if a.type == ctx['global'].constants.DeviceType_Floppy:
-            print "   Floppy:"
+            print("   Floppy:")
             if medium:
-                print "    Id: %s" % (medium.id)
-                print "    Name: %s" % (medium.name)
+                print("    Id: %s" % (medium.id))
+                print("    Name: %s" % (medium.name))
                 if medium.hostDrive:
-                    print "    Host floppy %s" % (colPath(ctx, medium.location))
+                    print("    Host floppy %s" % (colPath(ctx, medium.location)))
                 else:
-                    print "    Virtual image at %s" % (colPath(ctx, medium.location))
-                    print "    Size: %s" % (medium.size)
-
-    print
-    print colCat(ctx, "  Shared folders:")
+                    print("    Virtual image at %s" % (colPath(ctx, medium.location)))
+                    print("    Size: %s" % (medium.size))
+
+    print()
+    print(colCat(ctx, "  Shared folders:"))
     for sf in ctx['global'].getArray(mach, 'sharedFolders'):
         printSf(ctx, sf)
@@ -1075,5 +1075,5 @@
 def startCmd(ctx, args):
     if len(args) < 2:
-        print "usage: start name <frontend>"
+        print("usage: start name <frontend>")
         return 0
     mach = argsToMach(ctx, args)
@@ -1088,6 +1088,6 @@
 
 def createVmCmd(ctx, args):
-    if (len(args) != 3):
-        print "usage: createvm name ostype"
+    if len(args) != 3:
+        print("usage: createvm name ostype")
         return 0
     name = args[1]
@@ -1096,5 +1096,5 @@
         ctx['vb'].getGuestOSType(oskind)
     except Exception:
-        print 'Unknown OS type:', oskind
+        print('Unknown OS type:', oskind)
         return 0
     createVm(ctx, name, oskind)
@@ -1102,6 +1102,6 @@
 
 def ginfoCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: ginfo [vmname|uuid]"
+    if len(args) < 2:
+        print("usage: ginfo [vmname|uuid]")
         return 0
     mach = argsToMach(ctx, args)
@@ -1113,5 +1113,5 @@
 def execInGuest(ctx, console, args, env, user, passwd, tmo, inputPipe=None, outputPipe=None):
     if len(args) < 1:
-        print "exec in guest needs at least program name"
+        print("exec in guest needs at least program name")
         return
     guest = console.guest
@@ -1119,11 +1119,11 @@
     # shall contain program name as argv[0]
     gargs = args
-    print "executing %s with args %s as %s" % (args[0], gargs, user)
+    print("executing %s with args %s as %s" % (args[0], gargs, user))
     flags = 0
     if inputPipe is not None:
         flags = 1 # set WaitForProcessStartOnly
-    print args[0]
+    print(args[0])
     process = guestSession.processCreate(args[0], gargs, env, [], tmo)
-    print "executed with pid %d" % (process.PID)
+    print("executed with pid %d" % (process.PID))
     if pid != 0:
         try:
@@ -1161,10 +1161,10 @@
 
         except KeyboardInterrupt:
-            print "Interrupted."
+            print("Interrupted.")
             ctx['interrupt'] = True
             if progress.cancelable:
                 progress.cancel()
         (_reason, code, _flags) = guest.getProcessStatus(pid)
-        print "Exit code: %d" % (code)
+        print("Exit code: %d" % (code))
         return 0
     else:
@@ -1175,5 +1175,5 @@
     dst = args[1]
     flags = 0
-    print "Copying host %s to guest %s" % (src, dst)
+    print("Copying host %s to guest %s" % (src, dst))
     progress = console.guest.copyToGuest(src, dst, user, passwd, flags)
     progressBar(ctx, progress)
@@ -1196,5 +1196,5 @@
     user = getpass.getuser()
     user_inp = nh_raw_input("User (%s): " % (user))
-    if len (user_inp) > 0:
+    if len(user_inp) > 0:
         user = user_inp
     passwd = getpass.getpass()
@@ -1203,6 +1203,6 @@
 
 def gexecCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: gexec [vmname|uuid] command args"
+    if len(args) < 2:
+        print("usage: gexec [vmname|uuid] command args")
         return 0
     mach = argsToMach(ctx, args)
@@ -1217,6 +1217,6 @@
 
 def gcopyCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: gcopy [vmname|uuid] host_path guest_path"
+    if len(args) < 2:
+        print("usage: gcopy [vmname|uuid] host_path guest_path")
         return 0
     mach = argsToMach(ctx, args)
@@ -1236,6 +1236,6 @@
 
 def gpipeCmd(ctx, args):
-    if (len(args) < 4):
-        print "usage: gpipe [vmname|uuid] hostProgram guestProgram, such as gpipe linux  '/bin/uname -a' '/bin/sh -c \"/usr/bin/tee; /bin/uname -a\"'"
+    if len(args) < 4:
+        print("usage: gpipe [vmname|uuid] hostProgram guestProgram, such as gpipe linux  '/bin/uname -a' '/bin/sh -c \"/usr/bin/tee; /bin/uname -a\"'")
         return 0
     mach = argsToMach(ctx, args)
@@ -1309,6 +1309,6 @@
 
 def guestCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: guest name commands"
+    if len(args) < 3:
+        print("usage: guest name commands")
         return 0
     mach = argsToMach(ctx, args)
@@ -1322,6 +1322,6 @@
 
 def screenshotCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: screenshot vm <file> <width> <height> <monitor>"
+    if len(args) < 2:
+        print("usage: screenshot vm <file> <width> <height> <monitor>")
         return 0
     mach = argsToMach(ctx, args)
@@ -1332,6 +1332,6 @@
 
 def teleportCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: teleport name host:port <password>"
+    if len(args) < 3:
+        print("usage: teleport name host:port <password>")
         return 0
     mach = argsToMach(ctx, args)
@@ -1351,6 +1351,6 @@
 
 def openportalCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: openportal name port <password>"
+    if len(args) < 3:
+        print("usage: openportal name port <password>")
         return 0
     mach = argsToMach(ctx, args)
@@ -1358,5 +1358,5 @@
         return 0
     port = int(args[2])
-    if (len(args) > 3):
+    if len(args) > 3:
         passwd = args[3]
     else:
@@ -1368,6 +1368,6 @@
 
 def closeportalCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: closeportal name"
+    if len(args) < 2:
+        print("usage: closeportal name")
         return 0
     mach = argsToMach(ctx, args)
@@ -1379,6 +1379,6 @@
 
 def gueststatsCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: gueststats name <check interval>"
+    if len(args) < 2:
+        print("usage: gueststats name <check interval>")
         return 0
     mach = argsToMach(ctx, args)
@@ -1392,13 +1392,13 @@
     cpu = args[1]
     if plug:
-        print "Adding CPU %d..." % (cpu)
+        print("Adding CPU %d..." % (cpu))
         mach.hotPlugCPU(cpu)
     else:
-        print "Removing CPU %d..." % (cpu)
+        print("Removing CPU %d..." % (cpu))
         mach.hotUnplugCPU(cpu)
 
 def plugcpuCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: plugcpu name cpuid"
+    if len(args) < 2:
+        print("usage: plugcpu name cpuid")
         return 0
     mach = argsToMach(ctx, args)
@@ -1413,6 +1413,6 @@
 
 def unplugcpuCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: unplugcpu name cpuid"
+    if len(args) < 2:
+        print("usage: unplugcpu name cpuid")
         return 0
     mach = argsToMach(ctx, args)
@@ -1428,10 +1428,10 @@
 def setvar(_ctx, _mach, args):
     expr = 'mach.'+args[0]+' = '+args[1]
-    print "Executing", expr
-    exec expr
+    print("Executing", expr)
+    exec(expr)
 
 def setvarCmd(ctx, args):
-    if (len(args) < 4):
-        print "usage: setvar [vmname|uuid] expr value"
+    if len(args) < 4:
+        print("usage: setvar [vmname|uuid] expr value")
         return 0
     mach = argsToMach(ctx, args)
@@ -1444,10 +1444,10 @@
     key = args[0]
     value = args[1]
-    print "%s: setting %s to %s" % (mach.name, key, value if value else None)
+    print("%s: setting %s to %s" % (mach.name, key, value if value else None))
     mach.setExtraData(key, value)
 
 def setExtraDataCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: setextra [vmname|uuid|global] key <value>"
+    if len(args) < 3:
+        print("usage: setextra [vmname|uuid|global] key <value>")
         return 0
     key = args[2]
@@ -1467,9 +1467,9 @@
 
 def printExtraKey(obj, key, value):
-    print "%s: '%s' = '%s'" % (obj, key, value)
+    print("%s: '%s' = '%s'" % (obj, key, value))
 
 def getExtraDataCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: getextra [vmname|uuid|global] <key>"
+    if len(args) < 2:
+        print("usage: getextra [vmname|uuid|global] <key>")
         return 0
     if len(args) == 3:
@@ -1498,15 +1498,15 @@
 
 def aliasCmd(ctx, args):
-    if (len(args) == 3):
+    if len(args) == 3:
         aliases[args[1]] = args[2]
         return 0
 
-    for (key, value) in aliases.items():
-        print "'%s' is an alias for '%s'" % (key, value)
+    for (key, value) in list(aliases.items()):
+        print("'%s' is an alias for '%s'" % (key, value))
     return 0
 
 def verboseCmd(ctx, args):
     global g_fVerbose
-    if (len(args) > 1):
+    if len(args) > 1:
         g_fVerbose = (args[1]=='on')
     else:
@@ -1516,5 +1516,5 @@
 def colorsCmd(ctx, args):
     global g_fHasColors
-    if (len(args) > 1):
+    if len(args) > 1:
         g_fHasColors = (args[1] == 'on')
     else:
@@ -1525,44 +1525,44 @@
     vbox = ctx['vb']
     try:
-        print "VirtualBox version %s" % (colored(vbox.version, 'blue'))
-    except Exception, e:
+        print("VirtualBox version %s" % (colored(vbox.version, 'blue')))
+    except Exception as e:
         printErr(ctx, e)
         if g_fVerbose:
             traceback.print_exc()
     props = vbox.systemProperties
-    print "Machines: %s" % (colPath(ctx, props.defaultMachineFolder))
-
-    #print "Global shared folders:"
+    print("Machines: %s" % (colPath(ctx, props.defaultMachineFolder)))
+
+    #print("Global shared folders:")
     #for ud in ctx['global'].getArray(vbox, 'sharedFolders'):
     #    printSf(ctx, sf)
     host = vbox.host
     cnt = host.processorCount
-    print colCat(ctx, "Processors:")
-    print "  available/online: %d/%d " % (cnt, host.processorOnlineCount)
+    print(colCat(ctx, "Processors:"))
+    print("  available/online: %d/%d " % (cnt, host.processorOnlineCount))
     for i in range(0, cnt):
-        print "  processor #%d speed: %dMHz %s" % (i, host.getProcessorSpeed(i), host.getProcessorDescription(i))
-
-    print colCat(ctx, "RAM:")
-    print "  %dM (free %dM)" % (host.memorySize, host.memoryAvailable)
-    print colCat(ctx, "OS:")
-    print "  %s (%s)" % (host.operatingSystem, host.OSVersion)
+        print("  processor #%d speed: %dMHz %s" % (i, host.getProcessorSpeed(i), host.getProcessorDescription(i)))
+
+    print(colCat(ctx, "RAM:"))
+    print("  %dM (free %dM)" % (host.memorySize, host.memoryAvailable))
+    print(colCat(ctx, "OS:"))
+    print("  %s (%s)" % (host.operatingSystem, host.OSVersion))
     if host.acceleration3DAvailable:
-        print colCat(ctx, "3D acceleration available")
-    else:
-        print colCat(ctx, "3D acceleration NOT available")
-
-    print colCat(ctx, "Network interfaces:")
+        print(colCat(ctx, "3D acceleration available"))
+    else:
+        print(colCat(ctx, "3D acceleration NOT available"))
+
+    print(colCat(ctx, "Network interfaces:"))
     for ni in ctx['global'].getArray(host, 'networkInterfaces'):
-        print "  %s (%s)" % (ni.name, ni.IPAddress)
-
-    print colCat(ctx, "DVD drives:")
+        print("  %s (%s)" % (ni.name, ni.IPAddress))
+
+    print(colCat(ctx, "DVD drives:"))
     for dd in ctx['global'].getArray(host, 'DVDDrives'):
-        print "  %s - %s" % (dd.name, dd.description)
-
-    print colCat(ctx, "Floppy drives:")
+        print("  %s - %s" % (dd.name, dd.description))
+
+    print(colCat(ctx, "Floppy drives:"))
     for dd in ctx['global'].getArray(host, 'floppyDrives'):
-        print "  %s - %s" % (dd.name, dd.description)
-
-    print colCat(ctx, "USB devices:")
+        print("  %s - %s" % (dd.name, dd.description))
+
+    print(colCat(ctx, "USB devices:"))
     for ud in ctx['global'].getArray(host, 'USBDevices'):
         printHostUsbDev(ctx, ud)
@@ -1570,11 +1570,11 @@
     if ctx['perf']:
         for metric in ctx['perf'].query(["*"], [host]):
-            print metric['name'], metric['values_as_string']
+            print(metric['name'], metric['values_as_string'])
 
     return 0
 
 def monitorGuestCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: monitorGuest name (duration)"
+    if len(args) < 2:
+        print("usage: monitorGuest name (duration)")
         return 0
     mach = argsToMach(ctx, args)
@@ -1589,6 +1589,6 @@
 
 def monitorGuestKbdCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: monitorGuestKbd name (duration)"
+    if len(args) < 2:
+        print("usage: monitorGuestKbd name (duration)")
         return 0
     mach = argsToMach(ctx, args)
@@ -1603,6 +1603,6 @@
 
 def monitorGuestMouseCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: monitorGuestMouse name (duration)"
+    if len(args) < 2:
+        print("usage: monitorGuestMouse name (duration)")
         return 0
     mach = argsToMach(ctx, args)
@@ -1617,6 +1617,6 @@
 
 def monitorGuestMultiTouchCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: monitorGuestMultiTouch name (duration)"
+    if len(args) < 2:
+        print("usage: monitorGuestMultiTouch name (duration)")
         return 0
     mach = argsToMach(ctx, args)
@@ -1631,6 +1631,6 @@
 
 def monitorVBoxCmd(ctx, args):
-    if (len(args) > 2):
-        print "usage: monitorVBox (duration)"
+    if len(args) > 2:
+        print("usage: monitorVBox (duration)")
         return 0
     dur = 5
@@ -1659,6 +1659,6 @@
 
 def portForwardCmd(ctx, args):
-    if (len(args) != 5):
-        print "usage: portForward <vm> <adapter> <hostPort> <guestPort>"
+    if len(args) != 5:
+        print("usage: portForward <vm> <adapter> <hostPort> <guestPort>")
         return 0
     mach = argsToMach(ctx, args)
@@ -1690,6 +1690,6 @@
 
 def showLogCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: showLog vm <num>"
+    if len(args) < 2:
+        print("usage: showLog vm <num>")
         return 0
     mach = argsToMach(ctx, args)
@@ -1698,5 +1698,5 @@
 
     log = 0
-    if (len(args) > 2):
+    if len(args) > 2:
         log = args[2]
 
@@ -1704,5 +1704,5 @@
     while True:
         data = mach.readLog(log, uOffset, 4096)
-        if (len(data) == 0):
+        if len(data) == 0:
             break
         # print adds either NL or space to chunks not ending with a NL
@@ -1713,6 +1713,6 @@
 
 def findLogCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: findLog vm pattern <num>"
+    if len(args) < 3:
+        print("usage: findLog vm pattern <num>")
         return 0
     mach = argsToMach(ctx, args)
@@ -1721,5 +1721,5 @@
 
     log = 0
-    if (len(args) > 3):
+    if len(args) > 3:
         log = args[3]
 
@@ -1729,5 +1729,5 @@
         # to reduce line splits on buffer boundary
         data = mach.readLog(log, uOffset, 512*1024)
-        if (len(data) == 0):
+        if len(data) == 0:
             break
         d = str(data).split("\n")
@@ -1737,5 +1737,5 @@
                 for mt in match:
                     s = s.replace(mt, colored(mt, 'red'))
-                print s
+                print(s)
         uOffset += len(data)
 
@@ -1744,6 +1744,6 @@
 
 def findAssertCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: findAssert vm <num>"
+    if len(args) < 2:
+        print("usage: findAssert vm <num>")
         return 0
     mach = argsToMach(ctx, args)
@@ -1752,5 +1752,5 @@
 
     log = 0
-    if (len(args) > 2):
+    if len(args) > 2:
         log = args[2]
 
@@ -1762,10 +1762,10 @@
         # to reduce line splits on buffer boundary
         data = mach.readLog(log, uOffset, 512*1024)
-        if (len(data) == 0):
+        if len(data) == 0:
             break
         d = str(data).split("\n")
         for s in d:
             if active:
-                print s
+                print(s)
                 if context == 0:
                     active = False
@@ -1777,5 +1777,5 @@
                 active = True
                 context = 50
-                print s
+                print(s)
         uOffset += len(data)
 
@@ -1785,6 +1785,6 @@
     expr = ' '.join(args[1:])
     try:
-        exec expr
-    except Exception, e:
+        exec(expr)
+    except Exception as e:
         printErr(ctx, e)
         if g_fVerbose:
@@ -1799,11 +1799,11 @@
 
 def runScriptCmd(ctx, args):
-    if (len(args) != 2):
-        print "usage: runScript <script>"
+    if len(args) != 2:
+        print("usage: runScript <script>")
         return 0
     try:
         lf = open(args[1], 'r')
-    except IOError, e:
-        print "cannot open:", args[1], ":", e
+    except IOError as e:
+        print("cannot open:", args[1], ":", e)
         return 0
 
@@ -1819,5 +1819,5 @@
                 break
 
-    except Exception, e:
+    except Exception as e:
         printErr(ctx, e)
         if g_fVerbose:
@@ -1827,6 +1827,6 @@
 
 def sleepCmd(ctx, args):
-    if (len(args) != 2):
-        print "usage: sleep <secs>"
+    if len(args) != 2:
+        print("usage: sleep <secs>")
         return 0
 
@@ -1840,6 +1840,6 @@
 
 def shellCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: shell <commands>"
+    if len(args) < 2:
+        print("usage: shell <commands>")
         return 0
     cmd = ' '.join(args[1:])
@@ -1854,23 +1854,23 @@
 
 def connectCmd(ctx, args):
-    if (len(args) > 4):
-        print "usage: connect url <username> <passwd>"
+    if len(args) > 4:
+        print("usage: connect url <username> <passwd>")
         return 0
 
     if ctx['vb'] is not None:
-        print "Already connected, disconnect first..."
-        return 0
-
-    if (len(args) > 1):
+        print("Already connected, disconnect first...")
+        return 0
+
+    if len(args) > 1:
         url = args[1]
     else:
         url = None
 
-    if (len(args) > 2):
+    if len(args) > 2:
         user = args[2]
     else:
         user = ""
 
-    if (len(args) > 3):
+    if len(args) > 3:
         passwd = args[3]
     else:
@@ -1881,6 +1881,6 @@
     ctx['vb'] = vbox
     try:
-        print "Running VirtualBox version %s" % (vbox.version)
-    except Exception, e:
+        print("Running VirtualBox version %s" % (vbox.version))
+    except Exception as e:
         printErr(ctx, e)
         if g_fVerbose:
@@ -1890,10 +1890,10 @@
 
 def disconnectCmd(ctx, args):
-    if (len(args) != 1):
-        print "usage: disconnect"
+    if len(args) != 1:
+        print("usage: disconnect")
         return 0
 
     if ctx['vb'] is None:
-        print "Not connected yet."
+        print("Not connected yet.")
         return 0
 
@@ -1909,5 +1909,5 @@
 def reconnectCmd(ctx, args):
     if ctx['wsinfo'] is None:
-        print "Never connected..."
+        print("Never connected...")
         return 0
 
@@ -1920,6 +1920,6 @@
     ctx['vb'] = ctx['global'].platform.connect(url, user, passwd)
     try:
-        print "Running VirtualBox version %s" % (ctx['vb'].version)
-    except Exception, e:
+        print("Running VirtualBox version %s" % (ctx['vb'].version))
+    except Exception as e:
         printErr(ctx, e)
         if g_fVerbose:
@@ -1929,5 +1929,5 @@
 def exportVMCmd(ctx, args):
     if len(args) < 3:
-        print "usage: exportVm <machine> <path> <format> <license>"
+        print("usage: exportVm <machine> <path> <format> <license>")
         return 0
     mach = argsToMach(ctx, args)
@@ -1935,9 +1935,9 @@
         return 0
     path = args[2]
-    if (len(args) > 3):
+    if len(args) > 3:
         fmt = args[3]
     else:
         fmt = "ovf-1.0"
-    if (len(args) > 4):
+    if len(args) > 4:
         lic = args[4]
     else:
@@ -1949,5 +1949,5 @@
     progress = app.write(fmt, path)
     if (progressBar(ctx, progress) and int(progress.resultCode) == 0):
-        print "Exported to %s in format %s" % (path, fmt)
+        print("Exported to %s in format %s" % (path, fmt))
     else:
         reportError(ctx, progress)
@@ -2053,5 +2053,5 @@
     extCode = extScancodes.get(ch, [])
     if len(extCode) == 0:
-        print "bad ext", ch
+        print("bad ext", ch)
     return extCode
 
@@ -2125,5 +2125,5 @@
 def typeGuestCmd(ctx, args):
     if len(args) < 3:
-        print "usage: typeGuest <machine> <text> <charDelay>"
+        print("usage: typeGuest <machine> <text> <charDelay>")
         return 0
     mach = argsToMach(ctx, args)
@@ -2161,29 +2161,29 @@
         verbose = False
     hdds = ctx['global'].getArray(ctx['vb'], 'hardDisks')
-    print colCat(ctx, "Hard disks:")
+    print(colCat(ctx, "Hard disks:"))
     for hdd in hdds:
         if hdd.state != ctx['global'].constants.MediumState_Created:
             hdd.refreshState()
-        print "   %s (%s)%s %s [logical %s]" % (colPath(ctx, hdd.location), hdd.format, optId(verbose, hdd.id), colSizeM(ctx, asSize(hdd.size, True)), colSizeM(ctx, asSize(hdd.logicalSize, True)))
+        print("   %s (%s)%s %s [logical %s]" % (colPath(ctx, hdd.location), hdd.format, optId(verbose, hdd.id), colSizeM(ctx, asSize(hdd.size, True)), colSizeM(ctx, asSize(hdd.logicalSize, True))))
 
     dvds = ctx['global'].getArray(ctx['vb'], 'DVDImages')
-    print colCat(ctx, "CD/DVD disks:")
+    print(colCat(ctx, "CD/DVD disks:"))
     for dvd in dvds:
         if dvd.state != ctx['global'].constants.MediumState_Created:
             dvd.refreshState()
-        print "   %s (%s)%s %s" % (colPath(ctx, dvd.location), dvd.format, optId(verbose, dvd.id), colSizeM(ctx, asSize(dvd.size, True)))
+        print("   %s (%s)%s %s" % (colPath(ctx, dvd.location), dvd.format, optId(verbose, dvd.id), colSizeM(ctx, asSize(dvd.size, True))))
 
     floppys = ctx['global'].getArray(ctx['vb'], 'floppyImages')
-    print colCat(ctx, "Floppy disks:")
+    print(colCat(ctx, "Floppy disks:"))
     for floppy in floppys:
         if floppy.state != ctx['global'].constants.MediumState_Created:
             floppy.refreshState()
-        print "   %s (%s)%s %s" % (colPath(ctx, floppy.location), floppy.format, optId(verbose, floppy.id), colSizeM(ctx, asSize(floppy.size, True)))
+        print("   %s (%s)%s %s" % (colPath(ctx, floppy.location), floppy.format, optId(verbose, floppy.id), colSizeM(ctx, asSize(floppy.size, True))))
 
     return 0
 
 def listUsbCmd(ctx, args):
-    if (len(args) > 1):
-        print "usage: listUsb"
+    if len(args) > 1:
+        print("usage: listUsb")
         return 0
 
@@ -2202,6 +2202,6 @@
 
 def createHddCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: createHdd sizeM location type"
+    if len(args) < 3:
+        print("usage: createHdd sizeM location type")
         return 0
 
@@ -2216,7 +2216,7 @@
     progress = hdd.createBaseStorage(size, (ctx['global'].constants.MediumVariant_Standard, ))
     if progressBar(ctx,progress) and hdd.id:
-        print "created HDD at %s as %s" % (colPath(ctx,hdd.location), hdd.id)
-    else:
-       print "cannot create disk (file %s exist?)" % (loc)
+        print("created HDD at %s as %s" % (colPath(ctx,hdd.location), hdd.id))
+    else:
+       print("cannot create disk (file %s exist?)" % (loc))
        reportError(ctx,progress)
        return 0
@@ -2225,6 +2225,6 @@
 
 def registerHddCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: registerHdd location"
+    if len(args) < 2:
+        print("usage: registerHdd location")
         return 0
 
@@ -2236,5 +2236,5 @@
     parentId = ""
     hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, False)
-    print "registered HDD as %s" % (hdd.id)
+    print("registered HDD as %s" % (hdd.id))
     return 0
 
@@ -2244,6 +2244,6 @@
 
 def attachHddCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: attachHdd vm hdd controller port:slot"
+    if len(args) < 3:
+        print("usage: attachHdd vm hdd controller port:slot")
         return 0
 
@@ -2256,5 +2256,5 @@
         hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, False)
     except:
-        print "no HDD with path %s registered" % (loc)
+        print("no HDD with path %s registered" % (loc))
         return 0
     if len(args) > 3:
@@ -2279,6 +2279,6 @@
 
 def detachHddCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: detachHdd vm hdd"
+    if len(args) < 3:
+        print("usage: detachHdd vm hdd")
         return 0
 
@@ -2291,5 +2291,5 @@
         hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, False)
     except:
-        print "no HDD with path %s registered" % (loc)
+        print("no HDD with path %s registered" % (loc))
         return 0
 
@@ -2298,11 +2298,11 @@
 
 def unregisterHddCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: unregisterHdd path <vmunreg>"
+    if len(args) < 2:
+        print("usage: unregisterHdd path <vmunreg>")
         return 0
 
     vbox = ctx['vb']
     loc = args[1]
-    if (len(args) > 2):
+    if len(args) > 2:
         vmunreg = int(args[2])
     else:
@@ -2311,5 +2311,5 @@
         hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, False)
     except:
-        print "no HDD with path %s registered" % (loc)
+        print("no HDD with path %s registered" % (loc))
         return 0
 
@@ -2318,8 +2318,8 @@
         try:
             for mach in machs:
-                print "Trying to detach from %s" % (mach)
+                print("Trying to detach from %s" % (mach))
                 detachMedium(ctx, mach, hdd)
-        except Exception, e:
-            print 'failed: ', e
+        except Exception as e:
+            print('failed: ', e)
             return 0
     hdd.close()
@@ -2327,6 +2327,6 @@
 
 def removeHddCmd(ctx, args):
-    if (len(args) != 2):
-        print "usage: removeHdd path"
+    if len(args) != 2:
+        print("usage: removeHdd path")
         return 0
 
@@ -2336,5 +2336,5 @@
         hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, False)
     except:
-        print "no HDD with path %s registered" % (loc)
+        print("no HDD with path %s registered" % (loc))
         return 0
 
@@ -2345,6 +2345,6 @@
 
 def registerIsoCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: registerIso location"
+    if len(args) < 2:
+        print("usage: registerIso location")
         return 0
 
@@ -2352,10 +2352,10 @@
     loc = args[1]
     iso = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, False)
-    print "registered ISO as %s" % (iso.id)
+    print("registered ISO as %s" % (iso.id))
     return 0
 
 def unregisterIsoCmd(ctx, args):
-    if (len(args) != 2):
-        print "usage: unregisterIso path"
+    if len(args) != 2:
+        print("usage: unregisterIso path")
         return 0
 
@@ -2365,15 +2365,15 @@
         dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, False)
     except:
-        print "no DVD with path %s registered" % (loc)
+        print("no DVD with path %s registered" % (loc))
         return 0
 
     progress = dvd.close()
-    print "Unregistered ISO at %s" % (colPath(ctx, loc))
+    print("Unregistered ISO at %s" % (colPath(ctx, loc)))
 
     return 0
 
 def removeIsoCmd(ctx, args):
-    if (len(args) != 2):
-        print "usage: removeIso path"
+    if len(args) != 2:
+        print("usage: removeIso path")
         return 0
 
@@ -2383,10 +2383,10 @@
         dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, False)
     except:
-        print "no DVD with path %s registered" % (loc)
+        print("no DVD with path %s registered" % (loc))
         return 0
 
     progress = dvd.deleteStorage()
     if progressBar(ctx, progress):
-        print "Removed ISO at %s" % (colPath(ctx, dvd.location))
+        print("Removed ISO at %s" % (colPath(ctx, dvd.location)))
     else:
         reportError(ctx, progress)
@@ -2394,6 +2394,6 @@
 
 def attachIsoCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: attachIso vm iso controller port:slot"
+    if len(args) < 3:
+        print("usage: attachIso vm iso controller port:slot")
         return 0
 
@@ -2406,5 +2406,5 @@
         dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, False)
     except:
-        print "no DVD with path %s registered" % (loc)
+        print("no DVD with path %s registered" % (loc))
         return 0
     if len(args) > 3:
@@ -2417,6 +2417,6 @@
 
 def detachIsoCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: detachIso vm iso"
+    if len(args) < 3:
+        print("usage: detachIso vm iso")
         return 0
 
@@ -2429,5 +2429,5 @@
         dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, False)
     except:
-        print "no DVD with path %s registered" % (loc)
+        print("no DVD with path %s registered" % (loc))
         return 0
 
@@ -2436,6 +2436,6 @@
 
 def mountIsoCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: mountIso vm iso controller port:slot"
+    if len(args) < 3:
+        print("usage: mountIso vm iso controller port:slot")
         return 0
 
@@ -2448,5 +2448,5 @@
         dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, False)
     except:
-        print "no DVD with path %s registered" % (loc)
+        print("no DVD with path %s registered" % (loc))
         return 0
 
@@ -2463,6 +2463,6 @@
 
 def unmountIsoCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: unmountIso vm controller port:slot"
+    if len(args) < 2:
+        print("usage: unmountIso vm controller port:slot")
         return 0
 
@@ -2490,6 +2490,6 @@
 
 def attachCtrCmd(ctx, args):
-    if (len(args) < 4):
-        print "usage: attachCtr vm cname bus <type>"
+    if len(args) < 4:
+        print("usage: attachCtr vm cname bus <type>")
         return 0
 
@@ -2497,5 +2497,5 @@
         ctrltype = enumFromString(ctx, 'StorageControllerType', args[4])
         if ctrltype == None:
-            print "Controller type %s unknown" % (args[4])
+            print("Controller type %s unknown" % (args[4]))
             return 0
     else:
@@ -2507,5 +2507,5 @@
     bus = enumFromString(ctx, 'StorageBus', args[3])
     if bus is None:
-        print "Bus type %s unknown" % (args[3])
+        print("Bus type %s unknown" % (args[3]))
         return 0
     name = args[2]
@@ -2514,6 +2514,6 @@
 
 def detachCtrCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: detachCtr vm name"
+    if len(args) < 3:
+        print("usage: detachCtr vm name")
         return 0
 
@@ -2526,5 +2526,5 @@
 
 def usbctr(ctx, mach, console, args):
-    if (args[0]):
+    if args[0]:
         console.attachUSBDevice(args[1], "")
     else:
@@ -2532,6 +2532,6 @@
 
 def attachUsbCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: attachUsb vm deviceuid"
+    if len(args) < 3:
+        print("usage: attachUsb vm deviceuid")
         return 0
 
@@ -2544,6 +2544,6 @@
 
 def detachUsbCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: detachUsb vm deviceuid"
+    if len(args) < 3:
+        print("usage: detachUsb vm deviceuid")
         return 0
 
@@ -2557,6 +2557,6 @@
 
 def guiCmd(ctx, args):
-    if (len(args) > 1):
-        print "usage: gui"
+    if len(args) > 1:
+        print("usage: gui")
         return 0
 
@@ -2572,6 +2572,6 @@
 
 def shareFolderCmd(ctx, args):
-    if (len(args) < 4):
-        print "usage: shareFolder vm path name <writable> <persistent>"
+    if len(args) < 4:
+        print("usage: shareFolder vm path name <writable> <persistent>")
         return 0
 
@@ -2596,6 +2596,6 @@
 
 def unshareFolderCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: unshareFolder vm name"
+    if len(args) < 3:
+        print("usage: unshareFolder vm name")
         return 0
 
@@ -2617,7 +2617,7 @@
 def snapshotCmd(ctx, args):
     if (len(args) < 2 or args[1] == 'help'):
-        print "Take snapshot:    snapshot vm take name <description>"
-        print "Restore snapshot: snapshot vm restore name"
-        print "Merge snapshot:   snapshot vm merge name"
+        print("Take snapshot:    snapshot vm take name <description>")
+        print("Restore snapshot: snapshot vm restore name")
+        print("Merge snapshot:   snapshot vm merge name")
         return 0
 
@@ -2627,9 +2627,9 @@
     cmd = args[2]
     if cmd == 'take':
-        if (len(args) < 4):
-            print "usage: snapshot vm take name <description>"
+        if len(args) < 4:
+            print("usage: snapshot vm take name <description>")
             return 0
         name = args[3]
-        if (len(args) > 4):
+        if len(args) > 4:
             desc = args[4]
         else:
@@ -2639,6 +2639,6 @@
 
     if cmd == 'restore':
-        if (len(args) < 4):
-            print "usage: snapshot vm restore name"
+        if len(args) < 4:
+            print("usage: snapshot vm restore name")
             return 0
         name = args[3]
@@ -2648,6 +2648,6 @@
 
     if cmd == 'restorecurrent':
-        if (len(args) < 4):
-            print "usage: snapshot vm restorecurrent"
+        if len(args) < 4:
+            print("usage: snapshot vm restorecurrent")
             return 0
         snap = mach.currentSnapshot()
@@ -2656,6 +2656,6 @@
 
     if cmd == 'delete':
-        if (len(args) < 4):
-            print "usage: snapshot vm delete name"
+        if len(args) < 4:
+            print("usage: snapshot vm delete name")
             return 0
         name = args[3]
@@ -2664,5 +2664,5 @@
         return 0
 
-    print "Command '%s' is unknown" % (cmd)
+    print("Command '%s' is unknown" % (cmd))
     return 0
 
@@ -2683,5 +2683,5 @@
         first = 0
         msg = ''
-        for aliasmode, aliaskey in alias.iteritems():
+        for aliasmode, aliaskey in list(alias.items()):
             if first == 0:
                 first = 1
@@ -2689,8 +2689,7 @@
                 msg += ', '
             if int(nat.aliasMode) & aliaskey:
-                msg += '%d: %s' % (aliasmode, 'on')
+                msg += '%s: %s' % (aliasmode, 'on')
             else:
-                msg += '%d: %s' % (aliasmode, 'off')
-        msg += ')'
+                msg += '%s: %s' % (aliasmode, 'off')
         return (0, [msg])
     else:
@@ -2698,7 +2697,7 @@
         if 'default' not in args:
             for a in range(1, len(args)):
-                if not alias.has_key(args[a]):
-                    print 'Invalid alias mode: ' + args[a]
-                    print natAlias.__doc__
+                if args[a] not in alias:
+                    print('Invalid alias mode: ' + args[a])
+                    print(natAlias.__doc__)
                     return (1, None)
                 nat.aliasMode = int(nat.aliasMode) | alias[args[a]]
@@ -2723,9 +2722,9 @@
     else:
         if args[1] < 16000:
-            print 'invalid mtu value (%s not in range [65 - 16000])' % (args[1])
+            print('invalid mtu value (%s not in range [65 - 16000])' % (args[1]))
             return (1, None)
         for i in range(2, len(args)):
             if not args[i].isdigit() or int(args[i]) < 8 or int(args[i]) > 1024:
-                print 'invalid %s parameter (%i not in range [8-1024])' % (i, args[i])
+                print('invalid %s parameter (%i not in range [8-1024])' % (i, args[i]))
                 return (1, None)
         a = [args[1]]
@@ -2735,5 +2734,5 @@
         else:
             for i in range(2, len(args)): a.append(args[i])
-        #print a
+        #print(a)
         nat.setNetworkSettings(int(a[0]), int(a[1]), int(a[2]), int(a[3]), int(a[4]))
     return (0, None)
@@ -2786,6 +2785,6 @@
         cmd = args[1]
         if len(args) != 3:
-            print 'invalid args:', args
-            print natTftp.__doc__
+            print('invalid args:', args)
+            print(natTftp.__doc__)
             return (1, None)
         if cmd == 'prefix': nat.TFTPPrefix = args[2]
@@ -2793,5 +2792,5 @@
         elif cmd == 'server': nat.TFTPNextServer = args[2]
         else:
-            print "invalid cmd:", cmd
+            print("invalid cmd:", cmd)
             return (1, None)
     return (0, None)
@@ -2818,13 +2817,13 @@
         pfcmd = {
             'simple': {
-                'validate': lambda: args[1] in pfcmd.keys() and args[2] in proto.keys() and len(args) == 5,
+                'validate': lambda: args[1] in list(pfcmd.keys()) and args[2] in list(proto.keys()) and len(args) == 5,
                 'func':lambda: nat.addRedirect('', proto[args[2]], '', int(args[3]), '', int(args[4]))
             },
             'no_name': {
-                'validate': lambda: args[1] in pfcmd.keys() and args[2] in proto.keys() and len(args) == 7,
+                'validate': lambda: args[1] in list(pfcmd.keys()) and args[2] in list(proto.keys()) and len(args) == 7,
                 'func': lambda: nat.addRedirect('', proto[args[2]], args[3], int(args[4]), args[5], int(args[6]))
             },
             'ex': {
-                'validate': lambda: args[1] in pfcmd.keys() and args[2] in proto.keys() and len(args) == 8,
+                'validate': lambda: args[1] in list(pfcmd.keys()) and args[2] in list(proto.keys()) and len(args) == 8,
                 'func': lambda: nat.addRedirect(args[3], proto[args[2]], args[4], int(args[5]), args[6], int(args[7]))
             },
@@ -2836,6 +2835,6 @@
 
         if not pfcmd[args[1]]['validate']():
-            print 'invalid port-forwarding or args of sub command ', args[1]
-            print natPortForwarding.__doc__
+            print('invalid port-forwarding or args of sub command ', args[1])
+            print(natPortForwarding.__doc__)
             return (1, None)
 
@@ -2856,5 +2855,5 @@
         (addr, mask) = args[1].split('/')
         if addr.count('.') > 3 or int(mask) < 0 or int(mask) > 32:
-            print 'Invalid arguments'
+            print('Invalid arguments')
             return (1, None)
         nat.network = args[1]
@@ -2880,17 +2879,17 @@
     if len(args) < 2 or args[1] == 'help':
         if len(args) > 2:
-            print natcommands[args[2]].__doc__
+            print(natcommands[args[2]].__doc__)
         else:
-            print natCmd.__doc__
+            print(natCmd.__doc__)
         return 0
     if len(args) == 1 or len(args) < 4 or args[3] not in natcommands:
-        print natCmd.__doc__
+        print(natCmd.__doc__)
         return 0
     mach = ctx['argsToMach'](args)
     if mach == None:
-        print "please specify vm"
-        return 0
-    if len(args) < 3 or not args[2].isdigit() or int(args[2]) not in range(0, ctx['vb'].systemProperties.getMaxNetworkAdapters(mach.chipsetType)):
-        print 'please specify adapter num %d isn\'t in range [0-%d]' % (args[2], ctx['vb'].systemProperties.getMaxNetworkAdapters(mach.chipsetType))
+        print("please specify vm")
+        return 0
+    if len(args) < 3 or not args[2].isdigit() or int(args[2]) not in list(range(0, ctx['vb'].systemProperties.getMaxNetworkAdapters(mach.chipsetType))):
+        print('please specify adapter num %d isn\'t in range [0-%d]' % (args[2], ctx['vb'].systemProperties.getMaxNetworkAdapters(mach.chipsetType)))
         return 0
     nicnum = int(args[2])
@@ -2919,5 +2918,5 @@
         for r in report:
             msg ='%s nic%d %s: %s' % (mach.name, nicnum, func, r)
-            print msg
+            print(msg)
     return 0
 
@@ -2930,5 +2929,5 @@
         yesno = {'off' : 0, 'on' : 1}
         if args[1] not in yesno:
-            print '%s isn\'t acceptable, please choose %s' % (args[1], yesno.keys())
+            print('%s isn\'t acceptable, please choose %s' % (args[1], list(yesno.keys())))
             return (1, None)
         adapter.__setattr__(attr, yesno[args[1]])
@@ -2953,6 +2952,6 @@
     else:
         if not args[1].isdigit():
-            print '%s isn\'t a number' % (args[1])
-            print (1, None)
+            print('%s isn\'t a number' % (args[1]))
+            return (1, None)
         adapter.lineSpeed = int(args[1])
     return (0, None)
@@ -2976,5 +2975,5 @@
     if len(args) == 1:
         nictypes = ctx['const'].all_values('NetworkAdapterType')
-        for key in nictypes.keys():
+        for key in list(nictypes.keys()):
             if str(adapter.adapterType) == str(nictypes[key]):
                 return (0, str(key))
@@ -2982,6 +2981,6 @@
     else:
         nictypes = ctx['const'].all_values('NetworkAdapterType')
-        if args[1] not in nictypes.keys():
-            print '%s not in acceptable values (%s)' % (args[1], nictypes.keys())
+        if args[1] not in list(nictypes.keys()):
+            print('%s not in acceptable values (%s)' % (args[1], list(nictypes.keys())))
             return (1, None)
         adapter.adapterType = nictypes[args[1]]
@@ -3002,6 +3001,5 @@
             ctx['global'].constants.NetworkAttachmentType_Generic: ('Generic', ''),
         }
-        import types
-        if type(adapter.attachmentType) != types.IntType:
+        if type(adapter.attachmentType) != int:
             t = str(adapter.attachmentType)
         else:
@@ -3037,9 +3035,9 @@
                 'f': lambda: ctx['global'].constants.NetworkAttachmentType_Generic}
         }
-        if args[1] not in nicAttachmentType.keys():
-            print '%s not in acceptable values (%s)' % (args[1], nicAttachmentType.keys())
+        if args[1] not in list(nicAttachmentType.keys()):
+            print('%s not in acceptable values (%s)' % (args[1], list(nicAttachmentType.keys())))
             return (1, None)
         if not nicAttachmentType[args[1]]['v']():
-            print nicAttachmentType.__doc__
+            print(nicAttachmentType.__doc__)
             return (1, None)
         nicAttachmentType[args[1]]['p']()
@@ -3067,17 +3065,17 @@
         if len(args) == 3 \
            and args[2] in niccomand:
-            print niccomand[args[2]].__doc__
+            print(niccomand[args[2]].__doc__)
         else:
-            print nicCmd.__doc__
+            print(nicCmd.__doc__)
         return 0
 
     vm = ctx['argsToMach'](args)
     if vm is None:
-        print 'please specify vm'
+        print('please specify vm')
         return 0
 
     if    len(args) < 3 \
-       or int(args[2]) not in range(0, ctx['vb'].systemProperties.getMaxNetworkAdapters(vm.chipsetType)):
-        print 'please specify adapter num %d isn\'t in range [0-%d]'% (args[2], ctx['vb'].systemProperties.getMaxNetworkAdapters(vm.chipsetType))
+       or int(args[2]) not in list(range(0, ctx['vb'].systemProperties.getMaxNetworkAdapters(vm.chipsetType))):
+        print('please specify adapter num %d isn\'t in range [0-%d]'% (args[2], ctx['vb'].systemProperties.getMaxNetworkAdapters(vm.chipsetType)))
         return 0
     nicnum = int(args[2])
@@ -3092,5 +3090,5 @@
         vm.saveSettings()
     if report is not None:
-        print '%s nic %d %s: %s' % (vm.name, nicnum, args[3], report)
+        print('%s nic %d %s: %s' % (vm.name, nicnum, args[3], report))
     session.unlockMachine()
     return 0
@@ -3099,5 +3097,5 @@
 def promptCmd(ctx, args):
     if    len(args) < 2:
-        print "Current prompt: '%s'" % (ctx['prompt'])
+        print("Current prompt: '%s'" % (ctx['prompt']))
         return 0
 
@@ -3107,5 +3105,5 @@
 def foreachCmd(ctx, args):
     if len(args) < 3:
-        print "usage: foreach scope command, where scope is XPath-like expression //vms/vm[@CPUCount='2']"
+        print("usage: foreach scope command, where scope is XPath-like expression //vms/vm[@CPUCount='2']")
         return 0
 
@@ -3117,5 +3115,5 @@
             e.apply(cmd)
     except:
-        print "Error executing"
+        print("Error executing")
         traceback.print_exc()
     return 0
@@ -3123,5 +3121,5 @@
 def foreachvmCmd(ctx, args):
     if len(args) < 2:
-        print "foreachvm command <args>"
+        print("foreachvm command <args>")
         return 0
     cmdargs = args[1:]
@@ -3133,6 +3131,6 @@
 
 def recordDemoCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: recordDemo vm filename (duration)"
+    if len(args) < 3:
+        print("usage: recordDemo vm filename (duration)")
         return 0
     mach = argsToMach(ctx, args)
@@ -3147,6 +3145,6 @@
 
 def playbackDemoCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: playbackDemo vm filename (duration)"
+    if len(args) < 3:
+        print("usage: playbackDemo vm filename (duration)")
         return 0
     mach = argsToMach(ctx, args)
@@ -3169,12 +3167,12 @@
     for a in assigned:
         if a.isPhysicalDevice:
-            print "%s: assigned host device %s guest %s" % (colDev(ctx, a.name), pciAddr(ctx, a.hostAddress), pciAddr(ctx, a.guestAddress))
+            print("%s: assigned host device %s guest %s" % (colDev(ctx, a.name), pciAddr(ctx, a.hostAddress), pciAddr(ctx, a.guestAddress)))
 
     atts = ctx['global'].getArray(console, 'attachedPCIDevices')
     for a in atts:
         if a.isPhysicalDevice:
-            print "%s: physical, guest %s, host %s" % (colDev(ctx, a.name), pciAddr(ctx, a.guestAddress), pciAddr(ctx, a.hostAddress))
+            print("%s: physical, guest %s, host %s" % (colDev(ctx, a.name), pciAddr(ctx, a.guestAddress), pciAddr(ctx, a.hostAddress)))
         else:
-            print "%s: virtual, guest %s" % (colDev(ctx, a.name), pciAddr(ctx, a.guestAddress))
+            print("%s: virtual, guest %s" % (colDev(ctx, a.name), pciAddr(ctx, a.guestAddress)))
     return
 
@@ -3188,6 +3186,6 @@
 
 def lspciCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: lspci vm"
+    if len(args) < 2:
+        print("usage: lspci vm")
         return 0
     mach = argsToMach(ctx, args)
@@ -3198,6 +3196,6 @@
 
 def attachpciCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: attachpci vm hostpci <guestpci>"
+    if len(args) < 3:
+        print("usage: attachpci vm hostpci <guestpci>")
         return 0
     mach = argsToMach(ctx, args)
@@ -3206,11 +3204,11 @@
     hostaddr = parsePci(args[2])
     if hostaddr == -1:
-        print "invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[2])
-        return 0
-
-    if (len(args) > 3):
+        print("invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[2]))
+        return 0
+
+    if len(args) > 3:
         guestaddr = parsePci(args[3])
         if guestaddr == -1:
-            print "invalid guest PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[3])
+            print("invalid guest PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[3]))
             return 0
     else:
@@ -3220,6 +3218,6 @@
 
 def detachpciCmd(ctx, args):
-    if (len(args) < 3):
-        print "usage: detachpci vm hostpci"
+    if len(args) < 3:
+        print("usage: detachpci vm hostpci")
         return 0
     mach = argsToMach(ctx, args)
@@ -3228,5 +3226,5 @@
     hostaddr = parsePci(args[2])
     if hostaddr == -1:
-        print "invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[2])
+        print("invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[2]))
         return 0
 
@@ -3235,6 +3233,6 @@
 
 def gotoCmd(ctx, args):
-    if (len(args) < 2):
-        print "usage: goto line"
+    if len(args) < 2:
+        print("usage: goto line")
         return 0
 
@@ -3273,5 +3271,5 @@
             'verbose':['Toggle verbosity', verboseCmd, 0],
             'setvar':['Set VMs variable: setvar Fedora BIOSSettings.ACPIEnabled True', setvarCmd, 0],
-            'eval':['Evaluate arbitrary Python construction: eval \'for m in getMachines(ctx): print m.name, "has", m.memorySize, "M"\'', evalCmd, 0],
+            'eval':['Evaluate arbitrary Python construction: eval \'for m in getMachines(ctx): print(m.name, "has", m.memorySize, "M")\'', evalCmd, 0],
             'quit':['Exits', quitCmd, 0],
             'host':['Show host information', hostCmd, 0],
@@ -3329,5 +3327,5 @@
             'prompt' : ['Control shell prompt', promptCmd, 0],
             'foreachvm' : ['Perform command for each VM', foreachvmCmd, 0],
-            'foreach' : ['Generic "for each" construction, using XPath-like notation: foreach //vms/vm[@OSTypeId=\'MacOS\'] "print obj.name"', foreachCmd, 0],
+            'foreach' : ['Generic "for each" construction, using XPath-like notation: foreach //vms/vm[@OSTypeId=\'MacOS\'] "print(obj.name)"', foreachCmd, 0],
             'recordDemo':['Record demo: recordDemo Win32 file.dmo 10', recordDemoCmd, 0],
             'playbackDemo':['Playback demo: playbackDemo Win32 file.dmo 10', playbackDemoCmd, 0],
@@ -3344,9 +3342,9 @@
     ci = commands.get(c, None)
     if ci == None:
-        print "Unknown command: '%s', type 'help' for list of known commands" % (c)
+        print("Unknown command: '%s', type 'help' for list of known commands" % (c))
         return 0
     if ctx['remote'] and ctx['vb'] is None:
         if c not in ['connect', 'reconnect', 'help', 'quit']:
-            print "First connect to remote server with %s command." % (colored('connect', 'blue'))
+            print("First connect to remote server with %s command." % (colored('connect', 'blue')))
             return 0
     return ci[1](ctx, args)
@@ -3354,5 +3352,5 @@
 
 def runCommand(ctx, cmd):
-    if len(cmd) == 0: return 0
+    if not cmd: return 0
     args = split_no_quotes(cmd)
     if len(args) == 0: return 0
@@ -3364,5 +3362,5 @@
 #
 # def runTestCmd(ctx, args):
-#    print "Testy test", ctx['vb']
+#    print("Testy test", ctx['vb'])
 #    return 0
 #
@@ -3381,11 +3379,11 @@
     d = {}
     try:
-        execfile(filename, d, d)
-        for (k, v) in d['commands'].items():
+        exec(compile(open(filename).read(), filename, 'exec'), d, d)
+        for (k, v) in list(d['commands'].items()):
             if g_fVerbose:
-                print "customize: adding \"%s\" - %s" % (k, v[0])
+                print("customize: adding \"%s\" - %s" % (k, v[0]))
             cmds[k] = [v[0], v[1], filename]
     except:
-        print "Error loading user extensions from %s" % (filename)
+        print("Error loading user extensions from %s" % (filename))
         traceback.print_exc()
 
@@ -3423,6 +3421,6 @@
     if vbox is not None:
         try:
-            print "Running VirtualBox version %s" % (vbox.version)
-        except Exception, e:
+            print("Running VirtualBox version %s" % (vbox.version))
+        except Exception as e:
             printErr(ctx, e)
             if g_fVerbose:
@@ -3461,7 +3459,10 @@
                 cmd = 'runScript %s'% (g_sScriptFile)
             elif g_sCmd is not None:
-                cmd = it.next()
+                cmd = next(it)
             else:
-                cmd = raw_input(ctx['prompt'])
+                if sys.version_info[0] <= 2:
+                    cmd = raw_input(ctx['prompt'])
+                else:
+                    cmd = input(ctx['prompt'])
             done = runCommand(ctx, cmd)
             if done != 0: break
@@ -3469,10 +3470,10 @@
                 break
         except KeyboardInterrupt:
-            print '====== You can type quit or q to leave'
+            print('====== You can type quit or q to leave')
         except StopIteration:
             break
         except EOFError:
             break
-        except Exception, e:
+        except Exception as e:
             printErr(ctx, e)
             if g_fVerbose:
@@ -3536,11 +3537,11 @@
 
     if options.autopath:
-        asLocations = [ os.getcwd(), ];
-        try:    sScriptDir = os.path.dirname(os.path.abspath(__file__));
+        asLocations = [ os.getcwd(), ]
+        try:    sScriptDir = os.path.dirname(os.path.abspath(__file__))
         except: pass; # In case __file__ isn't there.
         else:
             if platform.system() in [ 'SunOS', ]:
-                asLocations.append(os.path.join(sScriptDir, 'amd64'));
-            asLocations.append(sScriptDir);
+                asLocations.append(os.path.join(sScriptDir, 'amd64'))
+            asLocations.append(sScriptDir)
 
 
@@ -3550,8 +3551,8 @@
                 if   os.path.isfile(os.path.join(sCurLoc, "VirtualBox")) \
                   or os.path.isfile(os.path.join(sCurLoc, "VirtualBox.exe")):
-                    print "Autodetected VBOX_PROGRAM_PATH as", sCurLoc
+                    print("Autodetected VBOX_PROGRAM_PATH as", sCurLoc)
                     os.environ["VBOX_PROGRAM_PATH"] = sCurLoc
                     sPath = sCurLoc
-                    break;
+                    break
         if sPath:
             sys.path.append(os.path.join(sPath, "sdk", "installer"))
@@ -3561,15 +3562,15 @@
             for sCurLoc in asLocations:
                 if os.path.isfile(os.path.join(sCurLoc, "sdk", "bindings", "VirtualBox.xidl")):
-                    sCurLoc = os.path.join(sCurLoc, "sdk");
-                    print "Autodetected VBOX_SDK_PATH as", sCurLoc
+                    sCurLoc = os.path.join(sCurLoc, "sdk")
+                    print("Autodetected VBOX_SDK_PATH as", sCurLoc)
                     os.environ["VBOX_SDK_PATH"] = sCurLoc
-                    sPath = sCurLoc;
-                    break;
+                    sPath = sCurLoc
+                    break
         if sPath:
-            sTmp = os.path.join(sCurLoc, 'sdk', 'bindings', 'xpcom', 'python');
+            sTmp = os.path.join(sCurLoc, 'bindings', 'xpcom', 'python')
             if os.path.isdir(sTmp):
-                sys.path.append(sTmp);
-            del sTmp;
-        del sPath, asLocations;
+                sys.path.append(sTmp)
+            del sTmp
+        del sPath, asLocations
 
 
Index: /trunk/src/VBox/Installer/common/vboxapisetup.py
===================================================================
--- /trunk/src/VBox/Installer/common/vboxapisetup.py	(revision 59797)
+++ /trunk/src/VBox/Installer/common/vboxapisetup.py	(revision 59798)
@@ -1,4 +1,4 @@
 """
-Copyright (C) 2009-2015 Oracle Corporation
+Copyright (C) 2009-2016 Oracle Corporation
 
 This file is part of VirtualBox Open Source Edition (OSE), as
@@ -19,5 +19,5 @@
     comCache1 = os.path.join(get_python_lib(), 'win32com', 'gen_py')
     comCache2 = os.path.join(os.environ.get("TEMP", "c:\\tmp"), 'gen_py')
-    print "Cleaning COM cache at",comCache1,"and",comCache2
+    print("Cleaning COM cache at",comCache1,"and",comCache2)
     shutil.rmtree(comCache1, True)
     shutil.rmtree(comCache2, True)
Index: /trunk/src/VBox/Main/glue/vboxapi.py
===================================================================
--- /trunk/src/VBox/Main/glue/vboxapi.py	(revision 59797)
+++ /trunk/src/VBox/Main/glue/vboxapi.py	(revision 59798)
@@ -7,5 +7,5 @@
 __copyright__ = \
     """
-    Copyright (C) 2009-2015 Oracle Corporation
+    Copyright (C) 2009-2016 Oracle Corporation
 
     This file is part of VirtualBox Open Source Edition (OSE), as
@@ -32,62 +32,4 @@
     xrange = range
     long = int
-    import builtins
-    print_ = getattr(builtins, 'print', None)
-elif sys.version_info >= (2, 6):
-    import __builtin__
-    print_ = getattr(__builtin__, 'print', None)
-else:
-    def print_(*args, **kwargs):
-        """The new-style print function for Python 2.4 and 2.5."""
-        fp = kwargs.pop("file", sys.stdout)
-        if fp is None:
-            return
-
-        def write(data):
-            if not isinstance(data, basestring):
-                data = str(data)
-            # If the file has an encoding, encode unicode with it.
-            if isinstance(fp, file) and isinstance(data, unicode) and fp.encoding is not None:
-                errors = getattr(fp, "errors", None)
-                if errors is None:
-                    errors = "strict"
-                data = data.encode(fp.encoding, errors)
-            fp.write(data)
-
-        want_unicode = False
-        sep = kwargs.pop("sep", None)
-        if sep is not None:
-            if isinstance(sep, unicode):
-                want_unicode = True
-            elif not isinstance(sep, str):
-                raise TypeError("sep must be None or a string")
-        end = kwargs.pop("end", None)
-        if end is not None:
-            if isinstance(end, unicode):
-                want_unicode = True
-            elif not isinstance(end, str):
-                raise TypeError("end must be None or a string")
-        if kwargs:
-            raise TypeError("invalid keyword arguments to print()")
-        if not want_unicode:
-            for arg in args:
-                if isinstance(arg, unicode):
-                    want_unicode = True
-                    break
-        if want_unicode:
-            newline = unicode("\n")
-            space = unicode(" ")
-        else:
-            newline = "\n"
-            space = " "
-        if sep is None:
-            sep = space
-        if end is None:
-            end = newline
-        for i, arg in enumerate(args):
-            if i:
-                write(sep)
-            write(arg)
-        write(end)
 
 #
@@ -225,5 +167,5 @@
     # Try case-insensitivity workaround for class attributes (COM methods).
     sAttrLower = sAttr.lower()
-    for k in self.__class__.__dict__.keys():
+    for k in list(self.__class__.__dict__.keys()):
         if k.lower() == sAttrLower:
             setattr(self.__class__, sAttr, self.__class__.__dict__[k])
Index: /trunk/src/VBox/Main/webservice/websrv-python.xsl
===================================================================
--- /trunk/src/VBox/Main/webservice/websrv-python.xsl	(revision 59797)
+++ /trunk/src/VBox/Main/webservice/websrv-python.xsl	(revision 59798)
@@ -193,20 +193,20 @@
       if self.isarray:
           return self.handle.__next()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
    def __size(self):
       if self.isarray:
           return self.handle.__size()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
    def __len__(self):
       if self.isarray:
           return self.handle.__len__()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
    def __getitem__(self, index):
       if self.isarray:
           return <xsl:value-of select="$ifname" />(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
    def __str__(self):
@@ -326,5 +326,5 @@
 
     def <xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="@name"/></xsl:call-template>(self):
-       raise Error, 'setters not supported'
+       raise Error('setters not supported')
     </xsl:for-each>
 
@@ -332,20 +332,20 @@
       if self.isarray:
           return self.handle.__next()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
     def __size(self):
       if self.isarray:
           return self.handle.__size()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
     def __len__(self):
       if self.isarray:
           return self.handle.__len__()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
     def __getitem__(self, index):
       if self.isarray:
           return <xsl:value-of select="$ifname" />(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 <xsl:call-template name="xsltprocNewlineOutputHack"/>
 </xsl:template>
@@ -511,5 +511,5 @@
      c = self.map.get(handle,-1)
      if c == -1:
-        raise Error, 'wrong refcount'
+        raise Error('wrong refcount')
      c = c - 1
      if c == 0:
@@ -533,20 +533,20 @@
       if self.isarray:
           return self.handle.__next()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __size(self):
       if self.isarray:
           return self.handle.__size()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __len__(self):
       if self.isarray:
           return self.handle.__len__()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __getitem__(self, index):
       if self.isarray:
           return String(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __str__(self):
@@ -624,20 +624,20 @@
       if self.isarray:
           return self.handle.__next()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __size(self):
       if self.isarray:
           return self.handle.__size()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __len__(self):
       if self.isarray:
           return self.handle.__len__()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __getitem__(self, index):
       if self.isarray:
           return Boolean(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
 class Number:
@@ -650,15 +650,15 @@
       if self.isarray:
           return self.handle.__next()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __size(self):
       if self.isarray:
           return self.handle.__size()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __len__(self):
       if self.isarray:
           return self.handle.__len__()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __str__(self):
@@ -711,5 +711,5 @@
            self.handle = mgr.decodebase64(handle)
        else:
-           raise TypeError, "only octet arrays"
+           raise TypeError("only octet arrays")
 
   def __getitem__(self, index):
@@ -731,5 +731,5 @@
       if self.isarray:
           return UnsignedInt(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
 
@@ -743,5 +743,5 @@
       if self.isarray:
           return Int(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
 class UnsignedShort(Number):
@@ -754,5 +754,5 @@
       if self.isarray:
           return UnsignedShort(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
 class Short(Number):
@@ -765,5 +765,5 @@
       if self.isarray:
           return Short(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
 class UnsignedLong(Number):
@@ -776,5 +776,5 @@
       if self.isarray:
           return UnsignedLong(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
 class Long(Number):
@@ -787,5 +787,5 @@
       if self.isarray:
           return Long(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
 class Double(Number):
@@ -798,5 +798,5 @@
       if self.isarray:
           return Double(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
 class Float(Number):
@@ -809,5 +809,5 @@
       if self.isarray:
           return Float(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
 class IUnknown:
@@ -826,20 +826,20 @@
       if self.isarray:
           return self.handle.__next()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __size(self):
       if self.isarray:
           return self.handle.__size()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __len__(self):
       if self.isarray:
           return self.handle.__len__()
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __getitem__(self, index):
       if self.isarray:
           return IUnknown(self.mgr, self.handle[index])
-      raise TypeError, "iteration over non-sequence"
+      raise TypeError("iteration over non-sequence")
 
   def __str__(self):
Index: /trunk/src/VBox/ValidationKit/testdriver/vbox.py
===================================================================
--- /trunk/src/VBox/ValidationKit/testdriver/vbox.py	(revision 59797)
+++ /trunk/src/VBox/ValidationKit/testdriver/vbox.py	(revision 59798)
@@ -9,5 +9,5 @@
 __copyright__ = \
 """
-Copyright (C) 2010-2015 Oracle Corporation
+Copyright (C) 2010-2016 Oracle Corporation
 
 This file is part of VirtualBox Open Source Edition (OSE), as
Index: /trunk/src/libs/xpcom18a4/python/Makefile.kmk
===================================================================
--- /trunk/src/libs/xpcom18a4/python/Makefile.kmk	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/Makefile.kmk	(revision 59798)
@@ -5,5 +5,5 @@
 
 #
-# Copyright (C) 2009-2015 Oracle Corporation
+# Copyright (C) 2009-2016 Oracle Corporation
 #
 # This file is part of VirtualBox Open Source Edition (OSE), as
@@ -27,12 +27,8 @@
 #
 # List of supported Python versions, defining a number of
-# VBOX_PYTHON[25|26|27|DEF]_[INC|LIB] variables which get picked up below.
+# VBOX_PYTHON[26|27|31|32|33|34|35|DEF]_[INC|LIB] variables
+# which get picked up below.
 #
 ifeq ($(KBUILD_TARGET),darwin) # Relatively predictable, don't script.
- ifeq ($(KBUILD_TARGET_ARCH),x86)
-  VBOX_PYTHON25_INC = $(VBOX_PATH_MACOSX_SDK)/usr/include/python2.5
-  VBOX_PYTHON25_LIB = $(VBOX_PATH_MACOSX_SDK)/usr/lib/libpython2.5.dylib
-  VBOX_PYTHON25_LIB_X86 = $(VBOX_PYTHON25_LIB)
- endif
  if  !defined(VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_6) \
   && (   !defined(VBOX_OSE) \
@@ -49,4 +45,5 @@
   VBOX_PYTHON27_LIB_X86 = $(VBOX_PYTHON27_LIB)
  endif
+ # No Python 3.x yet as part of OSX versions including El Capitan, 10.11.
 
 else
@@ -115,63 +112,4 @@
 
 
-ifdef VBOX_PYTHON23_INC
-#
-# Python 2.3 version
-#
-DLLS += VBoxPython2_3
-VBoxPython2_3_EXTENDS    = VBoxPythonBase
-VBoxPython2_3_EXTENDS_BY = appending
-VBoxPython2_3_TEMPLATE   = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX104,)
-VBoxPython2_3_INCS       = $(VBOX_PYTHON23_INC)
-VBoxPython2_3_LIBS       = $(VBOX_PYTHON23_LIB)
-
- ifdef VBOX_WITH_32_ON_64_MAIN_API
-DLLS += VBoxPython2_3_x86
-VBoxPython2_3_x86_EXTENDS    = VBoxPythonBase_x86
-VBoxPython2_3_x86_EXTENDS_BY = appending
-VBoxPython2_3_x86_TEMPLATE   = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX104,-x86)
-VBoxPython2_3_x86_INCS       = $(VBOX_PYTHON23_INC)
-VBoxPython2_3_x86_LIBS       = $(VBOX_PYTHON23_LIB_X86)
- endif
-endif
-
-ifdef VBOX_PYTHON24_INC
-#
-# Python 2.4 version
-#
-DLLS += VBoxPython2_4
-VBoxPython2_4_EXTENDS    = VBoxPythonBase
-VBoxPython2_4_EXTENDS_BY = appending
-VBoxPython2_4_INCS       = $(VBOX_PYTHON24_INC)
-VBoxPython2_4_LIBS       = $(VBOX_PYTHON24_LIB)
-
- ifdef VBOX_WITH_32_ON_64_MAIN_API
-DLLS += VBoxPython2_4_x86
-VBoxPython2_4_x86_EXTENDS    = VBoxPythonBase_x86
-VBoxPython2_4_x86_EXTENDS_BY = appending
-VBoxPython2_4_x86_INCS       = $(VBOX_PYTHON24_INC)
-VBoxPython2_4_x86_LIBS       = $(VBOX_PYTHON24_LIB_X86)
- endif
-endif
-
-ifdef VBOX_PYTHON25_INC
-#
-# Python 2.5 version
-#
-DLLS += VBoxPython2_5
-VBoxPython2_5_EXTENDS    = VBoxPythonBase
-VBoxPython2_5_EXTENDS_BY = appending
-VBoxPython2_5_INCS       = $(VBOX_PYTHON25_INC)
-VBoxPython2_5_LIBS       = $(VBOX_PYTHON25_LIB)
-
- ifdef VBOX_WITH_32_ON_64_MAIN_API
-DLLS += VBoxPython2_5_x86
-VBoxPython2_5_x86_EXTENDS    = VBoxPythonBase_x86
-VBoxPython2_5_x86_EXTENDS_BY = appending
-VBoxPython2_5_x86_INCS       = $(VBOX_PYTHON25_INC)
-VBoxPython2_5_x86_LIBS       = $(VBOX_PYTHON25_LIB_X86)
- endif
-endif
-
 ifdef VBOX_PYTHON26_INC
 #
@@ -213,4 +151,109 @@
 VBoxPython2_7_x86_INCS       = $(VBOX_PYTHON27_INC)
 VBoxPython2_7_x86_LIBS       = $(VBOX_PYTHON27_LIB_X86)
+ endif
+endif
+
+ifdef VBOX_PYTHON31_INC
+#
+# Python 3.1 version
+#
+DLLS += VBoxPython3_1
+VBoxPython3_1_EXTENDS    = VBoxPythonBase
+VBoxPython3_1_EXTENDS_BY = appending
+VBoxPython3_1_TEMPLATE   = XPCOM
+VBoxPython3_1_INCS       = $(VBOX_PYTHON31_INC)
+VBoxPython3_1_LIBS       = $(VBOX_PYTHON31_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython3_1_x86
+VBoxPython3_1_x86_EXTENDS    = VBoxPythonBase_x86
+VBoxPython3_1_x86_EXTENDS_BY = appending
+VBoxPython3_1_x86_TEMPLATE   = XPCOM
+VBoxPython3_1_x86_INCS       = $(VBOX_PYTHON31_INC)
+VBoxPython3_1_x86_LIBS       = $(VBOX_PYTHON31_LIB_X86)
+ endif
+endif
+
+ifdef VBOX_PYTHON32_INC
+#
+# Python 3.2 version
+#
+DLLS += VBoxPython3_2
+VBoxPython3_2_EXTENDS    = VBoxPythonBase
+VBoxPython3_2_EXTENDS_BY = appending
+VBoxPython3_2_TEMPLATE   = XPCOM
+VBoxPython3_2_INCS       = $(VBOX_PYTHON32_INC)
+VBoxPython3_2_LIBS       = $(VBOX_PYTHON32_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython3_2_x86
+VBoxPython3_2_x86_EXTENDS    = VBoxPythonBase_x86
+VBoxPython3_2_x86_EXTENDS_BY = appending
+VBoxPython3_2_x86_TEMPLATE   = XPCOM
+VBoxPython3_2_x86_INCS       = $(VBOX_PYTHON32_INC)
+VBoxPython3_2_x86_LIBS       = $(VBOX_PYTHON32_LIB_X86)
+ endif
+endif
+
+ifdef VBOX_PYTHON33_INC
+#
+# Python 3.3 version
+#
+DLLS += VBoxPython3_3
+VBoxPython3_3_EXTENDS    = VBoxPythonBase
+VBoxPython3_3_EXTENDS_BY = appending
+VBoxPython3_3_TEMPLATE   = XPCOM
+VBoxPython3_3_INCS       = $(VBOX_PYTHON33_INC)
+VBoxPython3_3_LIBS       = $(VBOX_PYTHON33_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython3_3_x86
+VBoxPython3_3_x86_EXTENDS    = VBoxPythonBase_x86
+VBoxPython3_3_x86_EXTENDS_BY = appending
+VBoxPython3_3_x86_TEMPLATE   = XPCOM
+VBoxPython3_3_x86_INCS       = $(VBOX_PYTHON33_INC)
+VBoxPython3_3_x86_LIBS       = $(VBOX_PYTHON33_LIB_X86)
+ endif
+endif
+
+ifdef VBOX_PYTHON34_INC
+#
+# Python 3.4 version
+#
+DLLS += VBoxPython3_4
+VBoxPython3_4_EXTENDS    = VBoxPythonBase
+VBoxPython3_4_EXTENDS_BY = appending
+VBoxPython3_4_TEMPLATE   = XPCOM
+VBoxPython3_4_INCS       = $(VBOX_PYTHON34_INC)
+VBoxPython3_4_LIBS       = $(VBOX_PYTHON34_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython3_4_x86
+VBoxPython3_4_x86_EXTENDS    = VBoxPythonBase_x86
+VBoxPython3_4_x86_EXTENDS_BY = appending
+VBoxPython3_4_x86_TEMPLATE   = XPCOM
+VBoxPython3_4_x86_INCS       = $(VBOX_PYTHON34_INC)
+VBoxPython3_4_x86_LIBS       = $(VBOX_PYTHON34_LIB_X86)
+ endif
+endif
+
+ifdef VBOX_PYTHON35_INC
+#
+# Python 3.5 version
+#
+DLLS += VBoxPython3_5
+VBoxPython3_5_EXTENDS    = VBoxPythonBase
+VBoxPython3_5_EXTENDS_BY = appending
+VBoxPython3_5_TEMPLATE   = XPCOM
+VBoxPython3_5_INCS       = $(VBOX_PYTHON35_INC)
+VBoxPython3_5_LIBS       = $(VBOX_PYTHON35_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython3_5_x86
+VBoxPython3_5_x86_EXTENDS    = VBoxPythonBase_x86
+VBoxPython3_5_x86_EXTENDS_BY = appending
+VBoxPython3_5_x86_TEMPLATE   = XPCOM
+VBoxPython3_5_x86_INCS       = $(VBOX_PYTHON35_INC)
+VBoxPython3_5_x86_LIBS       = $(VBOX_PYTHON35_LIB_X86)
  endif
 endif
Index: /trunk/src/libs/xpcom18a4/python/__init__.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/__init__.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/__init__.py	(revision 59798)
@@ -38,5 +38,11 @@
 
 # The XPCOM (Cross Platform COM) package.
-import exceptions
+from __future__ import print_function
+import sys
+if sys.version_info[0] <= 2:
+    import exceptions
+    XPCOMBaseException = exceptions.Exception
+else:
+    XPCOMBaseException = Exception
 
 # A global "verbose" flag - currently used by the
@@ -48,14 +54,14 @@
 # The standard XPCOM exception object.
 # Instances of this class are raised by the XPCOM extension module.
-class Exception(exceptions.Exception):
+class Exception(XPCOMBaseException):
     def __init__(self, errno, message = None):
         assert int(errno) == errno, "The errno param must be an integer"
         self.errno = errno
         self.msg = message
-        exceptions.Exception.__init__(self, errno)
+        XPCOMBaseException.__init__(self, errno)
     def __str__(self):
         if not hr_map:
-            import nsError
-            for name, val in nsError.__dict__.items():
+            from . import nsError
+            for name, val in list(nsError.__dict__.items()):
                 if type(val)==type(0):
                     hr_map[val] = name
@@ -80,5 +86,5 @@
     def __init__(self, errno=None, *args, **kw):
         if errno is None:
-            import nsError
+            from . import nsError
             errno = nsError.NS_ERROR_FAILURE
         Exception.__init__(self, errno, *args, **kw)
@@ -98,5 +104,5 @@
         pass
     def write(self, msg):
-        import _xpcom
+        import xpcom._xpcom as _xpcom
         _xpcom.LogConsoleMessage(msg)
     def close(self):
@@ -104,5 +110,7 @@
 
 def setupLogging():
-    import sys, os, threading, thread
+    import os
+    if sys.version_info[0] <= 2:
+        import threading, thread
     hdlr = logging.StreamHandler(ConsoleServiceStream())
     fmt = logging.Formatter(logging.BASIC_FORMAT)
@@ -113,6 +121,7 @@
     # Later versions of logging use an RLock, so we detect an "old" style
     # handler and update its lock
-    if type(hdlr.lock) == thread.LockType:
-        hdlr.lock = threading.RLock()
+    if sys.version_info[0] <= 2:
+        if type(hdlr.lock) == thread.LockType:
+            hdlr.lock = threading.RLock()
 
     logger.addHandler(hdlr)
@@ -126,13 +135,13 @@
             # open without buffering so never pending output
             stream = open(filename, "wU", 0)
-        except IOError, why:
-            print >> sys.stderr, "pyxpcom failed to open log file '%s': %s" \
-                                 % (filename, why)
+        except IOError as why:
+            print("pyxpcom failed to open log file '%s': %s"  % (filename, why), file=sys.stderr)
             # stream remains default
 
     hdlr = logging.StreamHandler(stream)
     # see above - fix a deadlock problem on this handler too.
-    if type(hdlr.lock) == thread.LockType:
-        hdlr.lock = threading.RLock()
+    if sys.version_info[0] <= 2:
+        if type(hdlr.lock) == thread.LockType:
+            hdlr.lock = threading.RLock()
 
     fmt = logging.Formatter(logging.BASIC_FORMAT)
Index: /trunk/src/libs/xpcom18a4/python/client/__init__.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/client/__init__.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/client/__init__.py	(revision 59798)
@@ -37,5 +37,5 @@
 
 import os
-import new
+from types import MethodType
 import logging
 from xpcom import xpt, COMException, nsError, logger
@@ -126,7 +126,7 @@
     # Exec the code object
     tempNameSpace = {}
-    exec codeObject in globals(), tempNameSpace
+    exec(codeObject, globals(), tempNameSpace)
     ret = tempNameSpace[name]
-    if not interface_method_cache.has_key(iid):
+    if iid not in interface_method_cache:
         interface_method_cache[iid] = {}
     interface_method_cache[iid][name] = ret
@@ -153,8 +153,8 @@
             if flags & FLAGS_TO_IGNORE == 0:
                 if flags & XPT_MD_SETTER:
-                    param_flags = map(lambda x: (x.param_flags,) + xpt.MakeReprForInvoke(x), m.params)
+                    param_flags = list([(x.param_flags,) + xpt.MakeReprForInvoke(x) for x in m.params])
                     setters[m.name] = m.method_index, param_flags
                 elif flags & XPT_MD_GETTER:
-                    param_flags = map(lambda x: (x.param_flags,) + xpt.MakeReprForInvoke(x), m.params)
+                    param_flags = list([(x.param_flags,) + xpt.MakeReprForInvoke(x) for x in m.params])
                     getters[m.name] = m.method_index, param_flags
                 else:
@@ -220,5 +220,5 @@
             except COMException:
                 pass
-        raise ValueError, "This object does not support automatic numeric conversion to this type"
+        raise ValueError("This object does not support automatic numeric conversion to this type")
 
     def __int__(self):
@@ -281,5 +281,5 @@
                 for nominated_iid in interface_infos:
                     # Interface may appear twice in the class info list, so check this here.
-                    if not self.__dict__['_interface_infos_'].has_key(nominated_iid):
+                    if nominated_iid not in self.__dict__['_interface_infos_']:
                         # Just invoke our QI on the object
                         self.queryInterface(nominated_iid)
@@ -290,5 +290,5 @@
                     contractid_info_cache[real_cid] = contractid_info
             else:
-                for key, val in contractid_info.items():
+                for key, val in list(contractid_info.items()):
                     self.__dict__[key].update(val)
 
@@ -300,8 +300,8 @@
         # rebuild the world for each new object.
         iis = self.__dict__['_interface_infos_']
-        assert not iis.has_key(iid), "Already remembered this interface!"
+        assert iid not in iis, "Already remembered this interface!"
         try:
             method_infos, getters, setters, constants = BuildInterfaceInfo(iid)
-        except COMException, why:
+        except COMException as why:
             # Failing to build an interface info generally isn't a real
             # problem - its probably just that the interface is non-scriptable.
@@ -314,15 +314,15 @@
         iis[iid] = method_infos, getters, setters, constants
         names = self.__dict__['_name_to_interface_iid_']
-        for name in method_infos.keys(): names[name] = iid
-        for name in getters.keys(): names[name] = iid
-        for name in setters.keys(): names[name] = iid
-        for name in constants.keys():  names[name] = iid
+        for name in list(method_infos.keys()): names[name] = iid
+        for name in list(getters.keys()): names[name] = iid
+        for name in list(setters.keys()): names[name] = iid
+        for name in list(constants.keys()):  names[name] = iid
 
     def QueryInterface(self, iid):
-        if self._interfaces_.has_key(iid):
-            assert self._interface_names_.has_key(iid.name), "_interfaces_ has the key, but _interface_names_ does not!"
+        if iid in self._interfaces_:
+            assert iid_name in self._interface_names_, "_interfaces_ has the key, but _interface_names_ does not!"
             return self
         # Haven't seen this before - do a real QI.
-        if not self._interface_infos_.has_key(iid):
+        if iid not in self._interface_infos_:
             self._remember_interface_info(iid)
         iface_info = self._interface_infos_[iid]
@@ -350,5 +350,5 @@
     def __getattr__(self, attr):
         if attr in _special_getattr_names:
-            raise AttributeError, attr
+            raise AttributeError(attr)
         # First allow the interface name to return the "raw" interface
         interface = self.__dict__['_interface_names_'].get(attr, None)
@@ -375,5 +375,5 @@
         # Some interfaces may provide this name via "native" support.
         # Loop over all interfaces, and if found, cache it for next time.
-        for interface in self.__dict__['_interfaces_'].values():
+        for interface in list(self.__dict__['_interfaces_'].values()):
             try:
                 ret = getattr(interface, attr)
@@ -382,5 +382,5 @@
             except AttributeError:
                 pass
-        raise AttributeError, "XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr)
+        raise AttributeError("XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr))
         
     def __setattr__(self, attr, val):
@@ -397,5 +397,5 @@
             setattr(interface, attr, val)
             return
-        raise AttributeError, "XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr)
+        raise AttributeError("XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr))
 
     def _get_classinfo_repr_(self):
@@ -410,5 +410,5 @@
             self.__dict__['_tried_classinfo_'] = 0
 
-        iface_names = self.__dict__['_interface_names_'].keys()
+        iface_names = list(self.__dict__['_interface_names_'].keys())
         try:
             iface_names.remove("nsISupports")
@@ -436,10 +436,10 @@
         self.__dict__.update(constants)
         # We remember the constant names to prevent the user trying to assign to them!
-        self.__dict__['_constant_names_'] = constants.keys()
+        self.__dict__['_constant_names_'] = list(constants.keys())
 
     def __getattr__(self, attr):
         # Allow the underlying interface to provide a better implementation if desired.
         if attr in _special_getattr_names:
-            raise AttributeError, attr
+            raise AttributeError(attr)
 
         ret = getattr(self.__dict__['_comobj_'], attr, None)
@@ -449,5 +449,5 @@
         unbound_method = self.__dict__['_methods_'].get(attr, None)
         if unbound_method is not None:
-            return new.instancemethod(unbound_method, self, self.__class__)
+            return MethodType(unbound_method, self)
 
         getters = self.__dict__['_property_getters_']
@@ -456,5 +456,5 @@
             method_index, param_infos = info
             if len(param_infos)!=1: # Only expecting a retval
-                raise RuntimeError, "Can't get properties with this many args!"
+                raise RuntimeError("Can't get properties with this many args!")
             args = ( param_infos, () )
             return XPTC_InvokeByIndex(self._comobj_, method_index, args)
@@ -467,12 +467,12 @@
             # Cache it locally
             self.__dict__['_methods_'][attr] = unbound_method
-            return new.instancemethod(unbound_method, self, self.__class__)
-
-        raise AttributeError, "XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr)
+            return MethodType(unbound_method, self)
+
+        raise AttributeError("XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr))
 
     def __setattr__(self, attr, val):
         # If we already have a __dict__ item of that name, and its not one of
         # our constants, we just directly set it, and leave.
-        if self.__dict__.has_key(attr) and attr not in self.__dict__['_constant_names_']:
+        if attr in self.__dict__ and attr not in self.__dict__['_constant_names_']:
             self.__dict__[attr] = val
             return
@@ -481,8 +481,8 @@
         info = setters.get(attr)
         if info is None:
-            raise AttributeError, "XPCOM component '%s' can not set attribute '%s'" % (self._object_name_, attr)
+            raise AttributeError("XPCOM component '%s' can not set attribute '%s'" % (self._object_name_, attr))
         method_index, param_infos = info
         if len(param_infos)!=1: # Only expecting a single input val
-            raise RuntimeError, "Can't set properties with this many args!"
+            raise RuntimeError("Can't set properties with this many args!")
         real_param_infos = ( param_infos, (val,) )
         return XPTC_InvokeByIndex(self._comobj_, method_index, real_param_infos)
@@ -527,5 +527,5 @@
         try:
             return Component(self._comobj_.QueryReferent(iid)._comobj_, iid)
-        except COMException, details:
+        except COMException as details:
             if details.errno != nsError.NS_ERROR_NULL_POINTER:
                 raise
Index: /trunk/src/libs/xpcom18a4/python/components.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/components.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/components.py	(revision 59798)
@@ -37,11 +37,11 @@
 
 # This module provides the JavaScript "components" interface
-import xpt
-import xpcom, _xpcom
+from . import xpt
+import xpcom
+import xpcom._xpcom as _xpcom
 import xpcom.client
 import xpcom.server
-import types
-
-StringTypes = [types.StringType, types.UnicodeType]
+
+StringTypes = [bytes, str]
 
 def _get_good_iid(iid):
@@ -79,17 +79,17 @@
         if self._dict_data is None:
             self._dict_data = self._build_dict()
-        return self._dict_data.keys()
+        return list(self._dict_data.keys())
     def items(self):
         if self._dict_data is None:
             self._dict_data = self._build_dict()
-        return self._dict_data.items()
+        return list(self._dict_data.items())
     def values(self):
         if self._dict_data is None:
             self._dict_data = self._build_dict()
-        return self._dict_data.values()
-    def has_key(self, key):
-        if self._dict_data is None:
-            self._dict_data = self._build_dict()
-        return self._dict_data.has_key(key)
+        return list(self._dict_data.values())
+#    def has_key(self, key):
+#        if self._dict_data is None:
+#            self._dict_data = self._build_dict()
+#        return self._dict_data.has_key(key)
 
     def __len__(self):
@@ -99,9 +99,9 @@
 
     def __getattr__(self, attr):
-        if self._dict_data is not None and self._dict_data.has_key(attr):
+        if self._dict_data is not None and attr in self._dict_data:
             return self._dict_data[attr]
         return self._get_one(attr)
     def __getitem__(self, item):
-        if self._dict_data is not None and self._dict_data.has_key(item):
+        if self._dict_data is not None and item in self._dict_data:
             return self._dict_data[item]
         return self._get_one(item)
@@ -120,4 +120,8 @@
         other_iid = getattr(other, "_iidobj_", other)
         return cmp(this_iid, other_iid)
+    def __eq__(self, other):
+        this_iid = self._iidobj_
+        other_iid = getattr(other, "_iidobj_", other)
+        return this_iid == other_iid
     def __hash__(self):
         return hash(self._iidobj_)
@@ -125,9 +129,9 @@
         return str(self._iidobj_)
     def __getitem__(self, item):
-        raise TypeError, "components.interface objects are not subscriptable"
+        raise TypeError("components.interface objects are not subscriptable")
     def __setitem__(self, item, value):
-        raise TypeError, "components.interface objects are not subscriptable"
+        raise TypeError("components.interface objects are not subscriptable")
     def __setattr__(self, attr, value):
-        raise AttributeError, "Can not set attributes on components.Interface objects"
+        raise AttributeError("Can not set attributes on components.Interface objects")
     def __getattr__(self, attr):
         # Support constants as attributes.
@@ -139,7 +143,7 @@
                 c[c_ob.name] = c_ob.value
             _constants_by_iid_map[self._iidobj_] = c
-        if c.has_key(attr):
+        if attr in c:
             return c[attr]
-        raise AttributeError, "'%s' interfaces do not define a constant '%s'" % (self.name, attr)
+        raise AttributeError("'%s' interfaces do not define a constant '%s'" % (self.name, attr))
 
 
@@ -148,7 +152,7 @@
         try:
             item = interfaceInfoManager.GetInfoForName(name)
-        except xpcom.COMException, why:
+        except xpcom.COMException as why:
             # Present a better exception message, and give a more useful error code.
-            import nsError
+            from . import nsError
             raise xpcom.COMException(nsError.NS_ERROR_NO_INTERFACE, "The interface '%s' does not exist" % (name,))
         return _Interface(item.GetName(), item.GetIID())
@@ -180,11 +184,11 @@
             self.clsid = rc
             return rc
-        raise AttributeError, "%s class has no attribute '%s'" % (self.contractid, attr)
+        raise AttributeError("%s class has no attribute '%s'" % (self.contractid, attr))
     def createInstance(self, iid = None):
         import xpcom.client
         try:
             return xpcom.client.Component(self.contractid, _get_good_iid(iid))
-        except xpcom.COMException, details:
-            import nsError
+        except xpcom.COMException as details:
+            from . import nsError
             # Handle "no such component" in a cleaner way for the user.
             if details.errno == nsError.NS_ERROR_FACTORY_NOT_REGISTERED:
@@ -219,5 +223,5 @@
 
 # The ID function
-ID = _xpcom.IID
+ID = _xpcom.ID
 
 # A helper to cleanup our namespace as xpcom shuts down.
Index: /trunk/src/libs/xpcom18a4/python/file.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/file.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/file.py	(revision 59798)
@@ -156,5 +156,5 @@
         self.close()
         if mode != "r":
-            raise ValueError, "only 'r' mode supported'"
+            raise ValueError("only 'r' mode supported")
         io_service = components.classes["@mozilla.org/network/io-service;1"] \
                         .getService(components.interfaces.nsIIOService)
@@ -165,5 +165,5 @@
         # Mozilla asserts and starts saying "NULL POINTER" if this is wrong!
         if not url_ob.scheme:
-            raise ValueError, ("The URI '%s' is invalid (no scheme)" 
+            raise ValueError("The URI '%s' is invalid (no scheme)" 
                                   % (url_ob.spec,))
         self.channel = io_service.newChannelFromURI(url_ob)
@@ -202,5 +202,5 @@
             self.inputStream.init(self.fileIO)
         else:
-            raise ValueError, "Unknown mode"
+            raise ValueError("Unknown mode")
 
     def close(self):
@@ -226,5 +226,5 @@
     got = got + file.read()
     if got != expected:
-        raise RuntimeError, "Reading '%s' failed - got %d bytes, but expected %d bytes" % (file, len(got), len(expected))
+        raise RuntimeError("Reading '%s' failed - got %d bytes, but expected %d bytes" % (file, len(got), len(expected)))
 
 def _DoTestBufferRead(file, expected):
@@ -240,5 +240,5 @@
         got = got + str(buffer[:num])
     if got != expected:
-        raise RuntimeError, "Reading '%s' failed - got %d bytes, but expected %d bytes" % (file, len(got), len(expected))
+        raise RuntimeError("Reading '%s' failed - got %d bytes, but expected %d bytes" % (file, len(got), len(expected)))
 
 def _TestLocalFile():
@@ -266,5 +266,5 @@
         # Open the same file again for writing - this should delete the old one.
         if not os.path.isfile(fname):
-            raise RuntimeError, "The file '%s' does not exist, but we are explicitly testing create semantics when it does" % (fname,)
+            raise RuntimeError("The file '%s' does not exist, but we are explicitly testing create semantics when it does" % (fname,))
         test_file = LocalFile(fname, "w")
         test_file.write(data)
@@ -305,7 +305,7 @@
 def _TestURI(url):
     test_file = URIFile(url)
-    print "Opened file is", test_file
+    print("Opened file is", test_file)
     got = test_file.read()
-    print "Read %d bytes of data from %r" % (len(got), url)
+    print("Read %d bytes of data from %r" % (len(got), url))
     test_file.close()
 
@@ -313,5 +313,5 @@
     import sys
     if len(sys.argv) < 2:
-        print "No URL specified on command line - performing self-test"
+        print("No URL specified on command line - performing self-test")
         _TestAll()
     else:
Index: /trunk/src/libs/xpcom18a4/python/gen_python_deps.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/gen_python_deps.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/gen_python_deps.py	(revision 59798)
@@ -2,5 +2,5 @@
 
 """
-Copyright (C) 2009-2013 Oracle Corporation
+Copyright (C) 2009-2016 Oracle Corporation
 
 This file is part of VirtualBox Open Source Edition (OSE), as
@@ -14,6 +14,7 @@
 
 import os,sys
+from distutils.version import StrictVersion
 
-versions = ["2.3", "2.4", "2.5", "2.6", "2.7",]
+versions = ["2.6", "2.7", "3.1", "3.2", "3.3", "3.4", "3.5"]
 prefixes = ["/usr", "/usr/local", "/opt", "/opt/local"]
 known = {}
@@ -41,10 +42,10 @@
 
 def print_vars(vers, known, sep, bitness_magic):
-    print "VBOX_PYTHON%s_INC=%s%s" %(vers, known[0], sep)
+    print("VBOX_PYTHON%s_INC=%s%s" %(vers, known[0], sep))
     if bitness_magic > 0:
-        print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep)
-        print "VBOX_PYTHON%s_LIB_X86=%s%s" %(vers, known[1], sep)
+        print("VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep))
+        print("VBOX_PYTHON%s_LIB_X86=%s%s" %(vers, known[1], sep))
     else:
-        print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep)
+        print("VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep))
 
 
@@ -91,4 +92,6 @@
 
     for v in versions:
+        if StrictVersion(v) < StrictVersion('2.6'):
+            continue
         for p in prefixes:
             c = checkPair(p, v, dllpre, dllsuff, bitness_magic)
@@ -96,5 +99,5 @@
                 known[v] = c
                 break
-    keys = known.keys()
+    keys = list(known.keys())
     # we want default to be the lowest versioned Python
     keys.sort()
Index: /trunk/src/libs/xpcom18a4/python/primitives.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/primitives.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/primitives.py	(revision 59798)
@@ -35,5 +35,5 @@
         better = _primitives_map[prin.type]
     except KeyError:
-        raise ValueError, "This primitive type (%d) is not supported" % (prin.type,)
+        raise ValueError("This primitive type (%d) is not supported" % (prin.type,))
     prin = prin.QueryInterface(better)
     return prin.data
Index: /trunk/src/libs/xpcom18a4/python/server/__init__.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/server/__init__.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/server/__init__.py	(revision 59798)
@@ -38,5 +38,5 @@
 # The xpcom.server package.
 
-from policy import DefaultPolicy
+from xpcom.server.policy import DefaultPolicy
 from xpcom import _xpcom
 
@@ -80,9 +80,9 @@
 # Python!
 def NS_GetModule( serviceManager, nsIFile ):
-    import loader
+    from . import loader
     iid = _xpcom.IID_nsIModule
     return WrapObject(loader.MakePythonComponentLoaderModule(serviceManager, nsIFile), iid, bWrapClient = 0)
 
 def _shutdown():
-    from policy import _shutdown
+    from server.policy import _shutdown
     _shutdown()
Index: /trunk/src/libs/xpcom18a4/python/server/loader.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/server/loader.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/server/loader.py	(revision 59798)
@@ -38,9 +38,7 @@
 import xpcom
 from xpcom import components, logger
-
-import module
-
-import glob, os, types
-
+from . import module
+import glob
+import os
 from xpcom.client import Component
 
@@ -57,7 +55,7 @@
     # For now, just run over all classes looking for likely candidates.
     comps = []
-    for name, object in py_module.__dict__.items():
+    for name, object in list(py_module.__dict__.items()):
         try:
-            if (type(object) == types.ClassType or issubclass(object, object)) and \
+            if (type(object) == type or issubclass(object, object)) and \
                _has_good_attr(object, "_com_interfaces_") and \
                _has_good_attr(object, "_reg_clsid_") and \
@@ -148,5 +146,5 @@
                     self.autoRegisterComponent(when, entry)
                 # Handle some common user errors
-                except xpcom.COMException, details:
+                except xpcom.COMException as details:
                     from xpcom import nsError
                     # If the interface name does not exist, suppress the traceback
@@ -156,5 +154,5 @@
                     else:
                         logger.exception("Registration of '%s' failed!", entry.leafName)
-                except SyntaxError, details:
+                except SyntaxError as details:
                     # Syntax error in source file - no useful traceback here either.
                     logger.error("Registration of '%s' failed\n %s",
@@ -226,4 +224,4 @@
 
 def MakePythonComponentLoaderModule(serviceManager, nsIFile):
-    import module
+    from . import module
     return module.Module( [PythonComponentLoader] )
Index: /trunk/src/libs/xpcom18a4/python/server/module.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/server/module.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/server/module.py	(revision 59798)
@@ -39,5 +39,5 @@
 from xpcom import nsError
 
-import factory
+from . import factory
 
 import types
@@ -66,7 +66,7 @@
         # void function.
         fname = os.path.basename(location.path)
-        for klass in self.components.values():
+        for klass in list(self.components.values()):
             reg_contractid = klass._reg_contractid_
-            print "Registering '%s' (%s)" % (reg_contractid, fname)
+            print("Registering '%s' (%s)" % (reg_contractid, fname))
             reg_desc = getattr(klass, "_reg_desc_", reg_contractid)
             compMgr = compMgr.queryInterface(components.interfaces.nsIComponentRegistrar)
@@ -85,5 +85,5 @@
     def unregisterSelf(self, compMgr, location, loaderStr):
         # void function.
-        for klass in self.components.values():
+        for klass in list(self.components.values()):
             ok = 1
             try:
@@ -99,7 +99,7 @@
                     ok = 0
             if ok:
-                print "Successfully unregistered", klass.__name__
+                print("Successfully unregistered", klass.__name__)
             else:
-                print "Unregistration of", klass.__name__, "failed. (probably just not already registered)"
+                print("Unregistration of", klass.__name__, "failed. (probably just not already registered)")
         
     def canUnload(self, compMgr):
Index: /trunk/src/libs/xpcom18a4/python/server/policy.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/server/policy.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/server/policy.py	(revision 59798)
@@ -43,4 +43,5 @@
 import types
 import logging
+import sys
 
 
@@ -61,6 +62,9 @@
 _supports_primitives_map_ = {} # Filled on first use.
 
-_interface_sequence_types_ = types.TupleType, types.ListType
-_string_types_ = types.StringType, types.UnicodeType
+_interface_sequence_types_ = tuple, list
+if sys.version_info[0] <= 2:
+    _string_types_ = str, unicode
+else:
+    _string_types_ = bytes, str
 XPTI_GetInterfaceInfoManager = _xpcom.XPTI_GetInterfaceInfoManager
 
@@ -142,5 +146,5 @@
         self._iid_ = iid
         if ni is None:
-            raise ValueError, "The object '%r' can not be used as a COM object" % (instance,)
+            raise ValueError("The object '%r' can not be used as a COM object" % (instance,))
         # This is really only a check for the user
         if __debug__:
@@ -286,5 +290,5 @@
             if logger.isEnabledFor(logging.DEBUG):
                 try:
-                    raise exc_info[0], exc_info[1], exc_info[2]
+                    raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
                 except:
                     logger.debug("'%s' raised COM Exception %s",
@@ -294,5 +298,5 @@
         # As above, trick the logging module to handle Python 2.3
         try:
-            raise exc_info[0], exc_info[1], exc_info[2]
+            raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
         except:
             logger.exception("Unhandled exception calling '%s'", func_name)
@@ -331,7 +335,7 @@
 _supports_primitives_data_ = [
     ("nsISupportsCString", "__str__", str),
-    ("nsISupportsString", "__unicode__", unicode),
-    ("nsISupportsPRUint64", "__long__", long),
-    ("nsISupportsPRInt64", "__long__", long),
+    ("nsISupportsString", "__unicode__", str),
+    ("nsISupportsPRUint64", "__long__", int),
+    ("nsISupportsPRInt64", "__long__", int),
     ("nsISupportsPRUint32", "__int__", int),
     ("nsISupportsPRInt32", "__int__", int),
Index: /trunk/src/libs/xpcom18a4/python/src/PyXPCOM.h
===================================================================
--- /trunk/src/libs/xpcom18a4/python/src/PyXPCOM.h	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/src/PyXPCOM.h	(revision 59798)
@@ -133,4 +133,22 @@
 # endif
 
+# if PY_MAJOR_VERSION >= 3
+#  define PyInt_FromLong(l) PyLong_FromLong(l)
+#  define PyInt_Check(o) PyLong_Check(o)
+#  define PyInt_AsLong(o) PyLong_AsLong(o)
+#  define PyNumber_Int(o) PyNumber_Long(o)
+#  ifndef PyUnicode_AsUTF8
+#   define PyUnicode_AsUTF8(o) _PyUnicode_AsString(o)
+#  endif
+#  ifndef PyUnicode_AsUTF8AndSize
+#   define PyUnicode_AsUTF8AndSize(o,s) _PyUnicode_AsStringAndSize(o,s)
+#  endif
+typedef struct PyMethodChain
+{
+    PyMethodDef *methods;
+    struct PyMethodChain *link;
+} PyMethodChain;
+# endif
+
 #endif /* VBOX_PYXPCOM */
 
@@ -268,4 +286,5 @@
 	static int Py_setattr(PyObject *op, char *name, PyObject *v);
 	static int Py_cmp(PyObject *ob1, PyObject *ob2);
+	static PyObject *Py_richcmp(PyObject *ob1, PyObject *ob2, int op);
 	static long Py_hash(PyObject *self);
 };
@@ -419,5 +438,8 @@
 	/* Python support */
 	static PyObject *PyTypeMethod_getattr(PyObject *self, char *name);
+#if PY_MAJOR_VERSION <= 2
 	static int PyTypeMethod_compare(PyObject *self, PyObject *ob);
+#endif
+	static PyObject *PyTypeMethod_richcompare(PyObject *self, PyObject *ob, int op);
 	static PyObject *PyTypeMethod_repr(PyObject *self);
 	static long PyTypeMethod_hash(PyObject *self);
Index: /trunk/src/libs/xpcom18a4/python/test/test_test_component.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/test/test_test_component.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/test/test_test_component.py	(revision 59798)
@@ -253,5 +253,5 @@
     test_attribute(c, "iid_value", component_iid, new_iid)
     test_attribute(c, "iid_value", component_iid, str(new_iid), new_iid)
-    test_attribute(c, "iid_value", component_iid, xpcom._xpcom.IID(new_iid))
+    test_attribute(c, "iid_value", component_iid, xpcom._xpcom.ID(new_iid))
 
     test_attribute_failure(c, "no_attribute", "boo", AttributeError)
Index: /trunk/src/libs/xpcom18a4/python/vboxxpcom.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/vboxxpcom.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/vboxxpcom.py	(revision 59798)
@@ -1,4 +1,4 @@
 """
-Copyright (C) 2008-2012 Oracle Corporation
+Copyright (C) 2008-2016 Oracle Corporation
 
 This file is part of VirtualBox Open Source Edition (OSE), as
@@ -47,6 +47,6 @@
         _oVBoxPythonMod =  __import__(m)
         break
-    except Exception, x:
-        print 'm=%s x=%s' % (m, x);
+    except Exception as x:
+        print('m=%s x=%s' % (m, x))
     #except:
     #    pass
Index: /trunk/src/libs/xpcom18a4/python/xpt.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/xpt.py	(revision 59797)
+++ /trunk/src/libs/xpcom18a4/python/xpt.py	(revision 59798)
@@ -72,5 +72,5 @@
 import xpcom._xpcom
 
-from xpcom_consts import *
+from .xpcom_consts import *
 
 class Interface:
@@ -100,10 +100,10 @@
             if xpcom.verbose:
                 # The user may be confused as to why this is happening!
-                print "The parent interface of IID '%s' can not be located - assuming nsISupports"
+                print("The parent interface of IID '%s' can not be located - assuming nsISupports")
             return Interface(xpcom._xpcom.IID_nsISupports)
 
     def Describe_Python(self):
         method_reprs = []
-        methods = filter(lambda m: not m.IsNotXPCOM(), self.methods)
+        methods = [m for m in self.methods if not m.IsNotXPCOM()]
         for m in methods:
             method_reprs.append(m.Describe_Python())
@@ -130,5 +130,5 @@
         s = s + '         Scriptable: ' + word + '\n'
         s = s + '      Methods:\n'
-        methods = filter(lambda m: not m.IsNotXPCOM(), self.methods)
+        methods = [m for m in self.methods if not m.IsNotXPCOM()]
         if len(methods):
             for m in methods:
@@ -153,5 +153,5 @@
         except xpcom.Exception:
             if xpcom.verbose:
-                print "** GetMethodCount failed?? - assuming no methods"
+                print("** GetMethodCount failed?? - assuming no methods")
             self.items = []
     def __len__(self):
@@ -252,5 +252,5 @@
 
         def desc(a): return a.Describe()
-        method_desc = string.join(map(desc, self.params), ', ')
+        method_desc = string.join(list(map(desc, self.params)), ', ')
         result_type = TypeDescriber(self.result_desc[0], None)
         return_desc = result_type.Describe()
@@ -329,5 +329,5 @@
         except xpcom.Exception:
             if xpcom.verbose:
-                print "** GetConstantCount failed?? - assuming no constants"
+                print("** GetConstantCount failed?? - assuming no constants")
             self.items = []
     def __len__(self):
@@ -452,11 +452,11 @@
         describer_name = describer_name + "_" + mode.capitalize()
     describer = getattr(interface, describer_name)
-    print describer()
+    print(describer())
 
 if __name__=='__main__':
     if len(sys.argv) == 1:
-        print "Usage: xpt.py [-xptinfo] interface_name, ..."
-        print "  -info: Dump in a style similar to the xptdump tool"
-        print "Dumping nsISupports and nsIInterfaceInfo"
+        print("Usage: xpt.py [-xptinfo] interface_name, ...")
+        print("  -info: Dump in a style similar to the xptdump tool")
+        print("Dumping nsISupports and nsIInterfaceInfo")
         sys.argv.append('nsIInterfaceInfo')
         sys.argv.append('-xptinfo')
