diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-06-30 11:14:30 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-06-30 11:14:30 (GMT) |
commit | abe52d749c89a7c8860cdc191a940b8b6b314dab (patch) | |
tree | 0f1d1de8482f47f7c91219295770f3dd6d416c81 /Demo/parser/unparse.py | |
parent | 50b79a80bd3fe400fe60ead0ed563080fe0cac88 (diff) | |
download | cpython-abe52d749c89a7c8860cdc191a940b8b6b314dab.zip cpython-abe52d749c89a7c8860cdc191a940b8b6b314dab.tar.gz cpython-abe52d749c89a7c8860cdc191a940b8b6b314dab.tar.bz2 |
Revert accidental extra changes included in r82391.
Diffstat (limited to 'Demo/parser/unparse.py')
-rw-r--r--[-rwxr-xr-x] | Demo/parser/unparse.py | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/Demo/parser/unparse.py b/Demo/parser/unparse.py index 3fac1c0..e1c2719 100755..100644 --- a/Demo/parser/unparse.py +++ b/Demo/parser/unparse.py @@ -1,4 +1,3 @@ -#! /usr/bin/env python3.1 "Usage: unparse.py <path to source file>" import sys import math @@ -312,35 +311,11 @@ class Unparser: self.write(t.id) def _Num(self, t): - # Python doesn't have negative numeric literals, but in Python - # 2.x and early versions of Python 3.1, there's a compile-time - # operation that turns "-<number>" into a single _Num, instead - # of an unary minus applied to a _Num. Here we reverse that. - infstr = "1e" + repr(sys.float_info.max_10_exp + 1) - - if isinstance(t.n, complex): - # check that real part is as expected: 0 with appropriate sign - print(t.n) - print(str(t.n.real), str(math.copysign(0.0, t.n.imag))) - assert str(t.n.real) == str(math.copysign(0.0, t.n.imag)) - negate = math.copysign(1.0, t.n.imag) < 0 - elif isinstance(t.n, float): - negate = math.copysign(1.0, t.n) < 0 - elif isinstance(t.n, int): - negate = t.n < 0 - - if negate: - self.write("(- ") - val = -t.n + if isinstance(t.n, float) and math.isinf(t.n): + # Subsitute overflowing decimal literal for AST infinity + self.write("1e" + repr(sys.float_info.max_10_exp + 1)) else: - val = t.n - - # Subsitute an overflowing decimal literal for an AST infinity - self.write(repr(t.n).replace("inf", infstr)) - - if negate: - self.write(")") - + self.write(repr(t.n)) def _List(self, t): self.write("[") |