diff options
author | Armin Rigo <arigo@tunes.org> | 2015-05-16 11:44:50 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2015-05-16 11:44:50 +0200 |
commit | e9eb36247788e807353ff0b9649fae8628a9b828 (patch) | |
tree | ccfec102ac86a20f1d0ad56caa0ac571048d1428 /cffi/cffi_opcode.py | |
parent | 8d1c9bf6507a7cd2a77db2ba62d79c917eb50f62 (diff) | |
download | cffi-e9eb36247788e807353ff0b9649fae8628a9b828.tar.gz |
Array lengths
Diffstat (limited to 'cffi/cffi_opcode.py')
-rw-r--r-- | cffi/cffi_opcode.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cffi/cffi_opcode.py b/cffi/cffi_opcode.py index 1506b1c..8596055 100644 --- a/cffi/cffi_opcode.py +++ b/cffi/cffi_opcode.py @@ -12,7 +12,15 @@ class CffiOp(object): return '_CFFI_OP(_CFFI_OP_%s, %d)' % (classname, self.arg) def as_python_bytes(self): - assert self.op is not None + if self.op is None: + if self.arg.isdigit(): + value = int(self.arg) # non-negative: '-' not in self.arg + if value >= 2**31: + raise OverflowError("cannot emit %r: limited to 2**31-1" + % (self.arg,)) + return format_four_bytes(value) + from .ffiplatform import VerificationError + raise VerificationError("cannot emit to Python: %r" % (self.arg,)) return format_four_bytes((self.arg << 8) | self.op) def __str__(self): |