Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
abe52d74
Commit
abe52d74
authored
Jun 30, 2010
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert accidental extra changes included in r82391.
parent
50b79a80
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
42 deletions
+5
-42
Demo/parser/test_unparse.py
Demo/parser/test_unparse.py
+1
-13
Demo/parser/unparse.py
Demo/parser/unparse.py
+4
-29
No files found.
Demo/parser/test_unparse.py
View file @
abe52d74
...
...
@@ -123,8 +123,6 @@ class UnparseTestCase(ASTTestCase):
def
test_unary_parens
(
self
):
self
.
check_roundtrip
(
"(-1)**7"
)
self
.
check_roundtrip
(
"(-1.)**8"
)
self
.
check_roundtrip
(
"(-1j)**6"
)
self
.
check_roundtrip
(
"not True or False"
)
self
.
check_roundtrip
(
"True or not False"
)
...
...
@@ -134,16 +132,6 @@ class UnparseTestCase(ASTTestCase):
def
test_huge_float
(
self
):
self
.
check_roundtrip
(
"1e1000"
)
self
.
check_roundtrip
(
"-1e1000"
)
self
.
check_roundtrip
(
"1e1000j"
)
self
.
check_roundtrip
(
"-1e1000j"
)
def
test_min_int
(
self
):
self
.
check_roundtrip
(
str
(
-
2
**
31
))
self
.
check_roundtrip
(
str
(
-
2
**
63
))
def
test_imag_literals
(
self
):
self
.
check_roundtrip
(
"7j"
)
self
.
check_roundtrip
(
"-7j"
)
def
test_lambda_parentheses
(
self
):
self
.
check_roundtrip
(
"(lambda: int)()"
)
...
...
@@ -213,7 +201,7 @@ class DirectoryTestCase(ASTTestCase):
# test directories, relative to the root of the distribution
test_directories
=
'Lib'
,
os
.
path
.
join
(
'Lib'
,
'test'
)
def
X
test_files
(
self
):
def
test_files
(
self
):
# get names of files to test
dist_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
os
.
pardir
,
os
.
pardir
)
...
...
Demo/parser/unparse.py
100755 → 100644
View file @
abe52d74
#! /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
(
"["
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment