VirtualBox

Changeset 90595 in vbox


Ignore:
Timestamp:
Aug 10, 2021 12:49:53 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
146206
Message:

ValKit: More Python 3.9 API changes needed (array.array.tostring() -> .tobytes()) bugref:10079

Location:
trunk/src/VBox/ValidationKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testdriver/reporter.py

    r84921 r90595  
    12231223            if isinstance(sText, array.array):
    12241224                try:
    1225                     sText = sText.tostring();
     1225                    if sys.version_info < (3, 9, 0):
     1226                        # Removed since Python 3.9.
     1227                        sText.tostring(); # pylint: disable=no-member
     1228                    else:
     1229                        sText.tobytes();
    12261230                except:
    12271231                    pass;
     
    12831287        if not utils.isString(sText):
    12841288            if isinstance(sText, array.array):
    1285                 try:    sText = sText.tostring();
    1286                 except: pass;
     1289                try:
     1290                    if sys.version_info < (3, 9, 0):
     1291                        # Removed since Python 3.9.
     1292                        sText = sText.tostring(); # pylint: disable=no-member
     1293                    else:
     1294                        sText = sText.tobytes();
     1295                except:
     1296                    pass;
    12871297            if hasattr(sText, 'decode'):
    12881298                try:    sText = sText.decode('utf-8', 'ignore');
  • trunk/src/VBox/ValidationKit/testdriver/txsclient.py

    r90594 r90595  
    307307        cbMsg   = getU32(abHdr, 0);
    308308        uCrc32  = getU32(abHdr, 4);
    309         sOpcode = abHdr[8:16].tostring().decode('ascii');
     309
     310        if sys.version_info < (3, 9, 0):
     311            # Removed since Python 3.9.
     312            sOpcode = abHdr[8:16].tostring(); # pylint: disable=no-member
     313        else:
     314            sOpcode = abHdr[8:16].tobytes();
     315        sOpcode = sOpcode.decode('ascii');
    310316
    311317        if cbMsg < 16:
     
    12701276                # Finally, push the data to the file.
    12711277                try:
    1272                     oLocalFile.write(abPayload[4:].tostring());
     1278                    if sys.version_info < (3, 9, 0):
     1279                        # Removed since Python 3.9.
     1280                        abData = abPayload[4:].tostring();
     1281                    else:
     1282                        abData = abPayload[4:].tobytes();
     1283                    oLocalFile.write(abData);
    12731284                except:
    12741285                    reporter.errorXcpt('I/O error writing to "%s"' % (sRemoteFile));
  • trunk/src/VBox/ValidationKit/testmanager/batch/virtual_test_sheriff.py

    r86891 r90595  
    272272                try:
    273273                    oHash = hashlib.sha256();
    274                     oHash.update(oImage.tostring());
     274                    if sys.version_info < (3, 9, 0):
     275                        # Removed since Python 3.9.
     276                        oHash.update(oImage.tostring()); # pylint: disable=no-member
     277                    else:
     278                        oHash.update(oImage.tobytes());
    275279                except Exception as oXcpt:
    276280                    self.oSheriff.vprint(u'Error hashing the uncompressed image bytes for "%s": %s' % (oFile.sFile, oXcpt,))
     
    17531757if __name__ == '__main__':
    17541758    sys.exit(VirtualTestSheriff().main());
    1755 
  • trunk/src/VBox/ValidationKit/tests/storage/remoteexecutor.py

    r82968 r90595  
    6464        if isinstance(sText, array.array):
    6565            try:
    66                 return str(sText.tostring()); # tostring() returns bytes with python3.
     66                if sys.version_info < (3, 9, 0):
     67                    # Removed since Python 3.9.
     68                    return str(sText.tostring()); # pylint: disable=no-member
     69                else:
     70                    return str(sText.tobytes());
    6771            except:
    6872                pass;
     
    301305
    302306        return fRc;
    303 
Note: See TracChangeset for help on using the changeset viewer.

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