VirtualBox

vbox的更動 59795 路徑 trunk/src/VBox/Main


忽略:
時間撮記:
2016-2-24 上午09:13:27 (9 年 以前)
作者:
vboxsync
訊息:

temporarily back out the recent Python 3 changes (r105649, r105645, r105644, r105643, r105641)

位置:
trunk/src/VBox/Main
檔案:
修改 2 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Main/glue/vboxapi.py

    r59769 r59795  
    77__copyright__ = \
    88    """
    9     Copyright (C) 2009-2016 Oracle Corporation
     9    Copyright (C) 2009-2015 Oracle Corporation
    1010
    1111    This file is part of VirtualBox Open Source Edition (OSE), as
     
    3232    xrange = range
    3333    long = int
     34    import builtins
     35    print_ = getattr(builtins, 'print', None)
     36elif sys.version_info >= (2, 6):
     37    import __builtin__
     38    print_ = getattr(__builtin__, 'print', None)
     39else:
     40    def print_(*args, **kwargs):
     41        """The new-style print function for Python 2.4 and 2.5."""
     42        fp = kwargs.pop("file", sys.stdout)
     43        if fp is None:
     44            return
     45
     46        def write(data):
     47            if not isinstance(data, basestring):
     48                data = str(data)
     49            # If the file has an encoding, encode unicode with it.
     50            if isinstance(fp, file) and isinstance(data, unicode) and fp.encoding is not None:
     51                errors = getattr(fp, "errors", None)
     52                if errors is None:
     53                    errors = "strict"
     54                data = data.encode(fp.encoding, errors)
     55            fp.write(data)
     56
     57        want_unicode = False
     58        sep = kwargs.pop("sep", None)
     59        if sep is not None:
     60            if isinstance(sep, unicode):
     61                want_unicode = True
     62            elif not isinstance(sep, str):
     63                raise TypeError("sep must be None or a string")
     64        end = kwargs.pop("end", None)
     65        if end is not None:
     66            if isinstance(end, unicode):
     67                want_unicode = True
     68            elif not isinstance(end, str):
     69                raise TypeError("end must be None or a string")
     70        if kwargs:
     71            raise TypeError("invalid keyword arguments to print()")
     72        if not want_unicode:
     73            for arg in args:
     74                if isinstance(arg, unicode):
     75                    want_unicode = True
     76                    break
     77        if want_unicode:
     78            newline = unicode("\n")
     79            space = unicode(" ")
     80        else:
     81            newline = "\n"
     82            space = " "
     83        if sep is None:
     84            sep = space
     85        if end is None:
     86            end = newline
     87        for i, arg in enumerate(args):
     88            if i:
     89                write(sep)
     90            write(arg)
     91        write(end)
    3492
    3593#
     
    167225    # Try case-insensitivity workaround for class attributes (COM methods).
    168226    sAttrLower = sAttr.lower()
    169     for k in list(self.__class__.__dict__.keys()):
     227    for k in self.__class__.__dict__.keys():
    170228        if k.lower() == sAttrLower:
    171229            setattr(self.__class__, sAttr, self.__class__.__dict__[k])
  • trunk/src/VBox/Main/webservice/websrv-python.xsl

    r59769 r59795  
    193193      if self.isarray:
    194194          return self.handle.__next()
    195       raise TypeError("iteration over non-sequence")
     195      raise TypeError, "iteration over non-sequence"
    196196
    197197   def __size(self):
    198198      if self.isarray:
    199199          return self.handle.__size()
    200       raise TypeError("iteration over non-sequence")
     200      raise TypeError, "iteration over non-sequence"
    201201
    202202   def __len__(self):
    203203      if self.isarray:
    204204          return self.handle.__len__()
    205       raise TypeError("iteration over non-sequence")
     205      raise TypeError, "iteration over non-sequence"
    206206
    207207   def __getitem__(self, index):
    208208      if self.isarray:
    209209          return <xsl:value-of select="$ifname" />(self.mgr, self.handle[index])
    210       raise TypeError("iteration over non-sequence")
     210      raise TypeError, "iteration over non-sequence"
    211211
    212212   def __str__(self):
     
    326326
    327327    def <xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="@name"/></xsl:call-template>(self):
    328        raise Error('setters not supported')
     328       raise Error, 'setters not supported'
    329329    </xsl:for-each>
    330330
     
    332332      if self.isarray:
    333333          return self.handle.__next()
    334       raise TypeError("iteration over non-sequence")
     334      raise TypeError, "iteration over non-sequence"
    335335
    336336    def __size(self):
    337337      if self.isarray:
    338338          return self.handle.__size()
    339       raise TypeError("iteration over non-sequence")
     339      raise TypeError, "iteration over non-sequence"
    340340
    341341    def __len__(self):
    342342      if self.isarray:
    343343          return self.handle.__len__()
    344       raise TypeError("iteration over non-sequence")
     344      raise TypeError, "iteration over non-sequence"
    345345
    346346    def __getitem__(self, index):
    347347      if self.isarray:
    348348          return <xsl:value-of select="$ifname" />(self.mgr, self.handle[index])
    349       raise TypeError("iteration over non-sequence")
     349      raise TypeError, "iteration over non-sequence"
    350350<xsl:call-template name="xsltprocNewlineOutputHack"/>
    351351</xsl:template>
     
    511511     c = self.map.get(handle,-1)
    512512     if c == -1:
    513         raise Error('wrong refcount')
     513        raise Error, 'wrong refcount'
    514514     c = c - 1
    515515     if c == 0:
     
    533533      if self.isarray:
    534534          return self.handle.__next()
    535       raise TypeError("iteration over non-sequence")
     535      raise TypeError, "iteration over non-sequence"
    536536
    537537  def __size(self):
    538538      if self.isarray:
    539539          return self.handle.__size()
    540       raise TypeError("iteration over non-sequence")
     540      raise TypeError, "iteration over non-sequence"
    541541
    542542  def __len__(self):
    543543      if self.isarray:
    544544          return self.handle.__len__()
    545       raise TypeError("iteration over non-sequence")
     545      raise TypeError, "iteration over non-sequence"
    546546
    547547  def __getitem__(self, index):
    548548      if self.isarray:
    549549          return String(self.mgr, self.handle[index])
    550       raise TypeError("iteration over non-sequence")
     550      raise TypeError, "iteration over non-sequence"
    551551
    552552  def __str__(self):
     
    624624      if self.isarray:
    625625          return self.handle.__next()
    626       raise TypeError("iteration over non-sequence")
     626      raise TypeError, "iteration over non-sequence"
    627627
    628628  def __size(self):
    629629      if self.isarray:
    630630          return self.handle.__size()
    631       raise TypeError("iteration over non-sequence")
     631      raise TypeError, "iteration over non-sequence"
    632632
    633633  def __len__(self):
    634634      if self.isarray:
    635635          return self.handle.__len__()
    636       raise TypeError("iteration over non-sequence")
     636      raise TypeError, "iteration over non-sequence"
    637637
    638638  def __getitem__(self, index):
    639639      if self.isarray:
    640640          return Boolean(self.mgr, self.handle[index])
    641       raise TypeError("iteration over non-sequence")
     641      raise TypeError, "iteration over non-sequence"
    642642
    643643class Number:
     
    650650      if self.isarray:
    651651          return self.handle.__next()
    652       raise TypeError("iteration over non-sequence")
     652      raise TypeError, "iteration over non-sequence"
    653653
    654654  def __size(self):
    655655      if self.isarray:
    656656          return self.handle.__size()
    657       raise TypeError("iteration over non-sequence")
     657      raise TypeError, "iteration over non-sequence"
    658658
    659659  def __len__(self):
    660660      if self.isarray:
    661661          return self.handle.__len__()
    662       raise TypeError("iteration over non-sequence")
     662      raise TypeError, "iteration over non-sequence"
    663663
    664664  def __str__(self):
     
    711711           self.handle = mgr.decodebase64(handle)
    712712       else:
    713            raise TypeError("only octet arrays")
     713           raise TypeError, "only octet arrays"
    714714
    715715  def __getitem__(self, index):
     
    731731      if self.isarray:
    732732          return UnsignedInt(self.mgr, self.handle[index])
    733       raise TypeError("iteration over non-sequence")
     733      raise TypeError, "iteration over non-sequence"
    734734
    735735
     
    743743      if self.isarray:
    744744          return Int(self.mgr, self.handle[index])
    745       raise TypeError("iteration over non-sequence")
     745      raise TypeError, "iteration over non-sequence"
    746746
    747747class UnsignedShort(Number):
     
    754754      if self.isarray:
    755755          return UnsignedShort(self.mgr, self.handle[index])
    756       raise TypeError("iteration over non-sequence")
     756      raise TypeError, "iteration over non-sequence"
    757757
    758758class Short(Number):
     
    765765      if self.isarray:
    766766          return Short(self.mgr, self.handle[index])
    767       raise TypeError("iteration over non-sequence")
     767      raise TypeError, "iteration over non-sequence"
    768768
    769769class UnsignedLong(Number):
     
    776776      if self.isarray:
    777777          return UnsignedLong(self.mgr, self.handle[index])
    778       raise TypeError("iteration over non-sequence")
     778      raise TypeError, "iteration over non-sequence"
    779779
    780780class Long(Number):
     
    787787      if self.isarray:
    788788          return Long(self.mgr, self.handle[index])
    789       raise TypeError("iteration over non-sequence")
     789      raise TypeError, "iteration over non-sequence"
    790790
    791791class Double(Number):
     
    798798      if self.isarray:
    799799          return Double(self.mgr, self.handle[index])
    800       raise TypeError("iteration over non-sequence")
     800      raise TypeError, "iteration over non-sequence"
    801801
    802802class Float(Number):
     
    809809      if self.isarray:
    810810          return Float(self.mgr, self.handle[index])
    811       raise TypeError("iteration over non-sequence")
     811      raise TypeError, "iteration over non-sequence"
    812812
    813813class IUnknown:
     
    826826      if self.isarray:
    827827          return self.handle.__next()
    828       raise TypeError("iteration over non-sequence")
     828      raise TypeError, "iteration over non-sequence"
    829829
    830830  def __size(self):
    831831      if self.isarray:
    832832          return self.handle.__size()
    833       raise TypeError("iteration over non-sequence")
     833      raise TypeError, "iteration over non-sequence"
    834834
    835835  def __len__(self):
    836836      if self.isarray:
    837837          return self.handle.__len__()
    838       raise TypeError("iteration over non-sequence")
     838      raise TypeError, "iteration over non-sequence"
    839839
    840840  def __getitem__(self, index):
    841841      if self.isarray:
    842842          return IUnknown(self.mgr, self.handle[index])
    843       raise TypeError("iteration over non-sequence")
     843      raise TypeError, "iteration over non-sequence"
    844844
    845845  def __str__(self):
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette