Changeset 6582b36 in mainline for tools/xstruct.py


Ignore:
Timestamp:
2012-04-01T07:13:03Z (13 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
81475250
Parents:
d9faae91
Message:

Make some scripts work with Python 3.

Arch Linux has already switched so "python" means version 3, so these
scripts don't run otherwise. Only the simplest fixes are made. Note that
automatic int-to-long conversion has existed since at least Python 2.4.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/xstruct.py

    rd9faae91 r6582b36  
    3232
    3333import struct
     34import sys
    3435import types
    3536
     37integer_types = (int, long) if sys.version < '3' else (int,)
     38
    3639ranges = {
    37         'B': ((int, long), 0x00, 0xff),
    38         'H': ((int, long), 0x0000, 0xffff),
    39         'L': ((int, long), 0x00000000, 0xffffffff),
    40         'Q': ((int, long), 0x0000000000000000, 0xffffffffffffffff),
    41         'b': ((int, long), -0x80, 0x7f),
    42         'h': ((int, long), -0x8000, 0x7fff),
    43         'l': ((int, long), -0x80000000, 0x7fffffff) ,
    44         'q': ((int, long), -0x8000000000000000, 0x7fffffffffffffff),
     40        'B': (integer_types, 0x00, 0xff),
     41        'H': (integer_types, 0x0000, 0xffff),
     42        'L': (integer_types, 0x00000000, 0xffffffff),
     43        'Q': (integer_types, 0x0000000000000000, 0xffffffffffffffff),
     44        'b': (integer_types, -0x80, 0x7f),
     45        'h': (integer_types, -0x8000, 0x7fff),
     46        'l': (integer_types, -0x80000000, 0x7fffffff) ,
     47        'q': (integer_types, -0x8000000000000000, 0x7fffffffffffffff),
    4548}
    4649
Note: See TracChangeset for help on using the changeset viewer.