WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit 1daff8b1 authored by Tobias Pape's avatar Tobias Pape
Browse files

RPython chokes on dicts with values of different types

this is a problem in the case when we want to "as_str" the pseudo-enum
. So we just filter the int-value part of the dict and, as a small optimization
use a translate-time unrolling of the if-switch.
parent 972fead3
from rpython.rlib.unroll import unrolling_iterable
# Symbol is a 'lightweight' enum, in Python 3.4, we could use Enum as superclass
class Symbol(object):
NONE = -1
......@@ -33,9 +35,16 @@ class Symbol(object):
KeywordSequence = 29
OperatorSequence = 30
def symbol_as_str(symbol):
for key, val in Symbol.__dict__:
symbols = unrolling_iterable(int_constants_of(Symbol))
for (key, val) in symbols:
if val == symbol:
return key
raise ValueError('No Symbol defined for the value %d.' % symbol)
raise ValueError('No Symbol defined for the value %d.' % symbol)
def int_constants_of(cls):
out = {}
for key, value in cls.__dict__.items():
if isinstance(value, int):
out[key] = value
return out
from rpython.rlib.unroll import unrolling_iterable
class Bytecodes(object):
# Bytecodes used by the Simple Object Machine (SOM)
......@@ -76,8 +78,16 @@ def bytecode_as_str(bytecode):
if not isinstance(bytecode, int):
raise ValueError('bytecode is expected to be an integer.')
for key, val in Bytecodes.__dict__.iteritems():
bytecodes = unrolling_iterable(int_constants_of(Bytecodes))
for key, val in bytecodes:
if val == bytecode:
return key.upper()
raise ValueError('No defined defined for the value %d.' % bytecode)
def int_constants_of(cls):
out = {}
for key, value in cls.__dict__.items():
if isinstance(value, int):
out[key] = value
return out
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment