# HG changeset patch # User Paul Boddie # Date 1481667993 -3600 # Node ID e545439a787cdb3ce30430ea12ae363175fdc7cc # Parent 87ba8cc4108297dc58f0595d20f212293ba1728c Eliminate predefined constant name assignments. diff -r 87ba8cc41082 -r e545439a787c translator.py --- a/translator.py Tue Dec 13 22:48:28 2016 +0100 +++ b/translator.py Tue Dec 13 23:26:33 2016 +0100 @@ -205,10 +205,19 @@ "A predefined constant reference." - def __init__(self, value): + def __init__(self, value, expr=None): self.value = value + self.expr = expr def __str__(self): + + # Eliminate predefined constant assignments. + + if self.expr: + return "" + + # Generate the specific constants. + if self.value in ("False", "True"): return encode_path("__builtins__.boolean.%s" % self.value) elif self.value == "None": @@ -1327,7 +1336,7 @@ # Determine whether the name refers to a static external entity. if n.name in predefined_constants: - return PredefinedConstantRef(n.name) + return PredefinedConstantRef(n.name, expr) # Convert literal references, operator function names, and print # function names to references.