Changeset 67435b1 in mainline for tools/xstruct.py
- Timestamp:
- 2012-05-22T10:31:25Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a58bc8b, df3f85f
- Parents:
- c4b0317
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/xstruct.py
rc4b0317 r67435b1 35 35 import types 36 36 37 # Handle long integer conversions nicely in both Python 2 and Python 3 37 38 integer_types = (int, long) if sys.version < '3' else (int,) 39 40 # Ensure that 's' format for struct receives correct data type depending 41 # on Python version (needed due to different way to encode into bytes) 42 ensure_string = \ 43 (lambda value: value if type(value) is str else bytes(value)) \ 44 if sys.version < '3' else \ 45 (lambda value: bytes(value, 'ascii') if type(value) is str else value) 38 46 39 47 ranges = { … … 77 85 args.append(item) 78 86 else: 87 if (fmt == "s"): 88 value = ensure_string(value) 79 89 check_range(variable, fmt, value) 80 90 args.append(value)
Note:
See TracChangeset
for help on using the changeset viewer.