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
0aed07ad
Commit
0aed07ad
authored
Mar 17, 2008
by
Eric Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added PEP 3127 support to tokenize (with tests); added PEP 3127 to NEWS.
parent
6f778cfb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
Lib/test/test_tokenize.py
Lib/test/test_tokenize.py
+10
-2
Lib/tokenize.py
Lib/tokenize.py
+3
-2
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/test/test_tokenize.py
View file @
0aed07ad
...
...
@@ -4,7 +4,7 @@ Tests for the tokenize module.
>>> import glob, random, sys
The tests can be really simple. Given a small fragment of source
code, print out a table with t
h
okens. The ENDMARK is omitted for
code, print out a table with tokens. The ENDMARK is omitted for
brevity.
>>> dump_tokens("1 + 1")
...
...
@@ -106,7 +106,7 @@ Some error-handling code
... "else: print 'Loaded'
\
\
n")
True
Balancing cont
u
nuation
Balancing cont
i
nuation
>>> roundtrip("a = (3,4,
\
\
n"
... "5,6)
\
\
n"
...
...
@@ -126,6 +126,14 @@ Ordinary integers and binary operators
NUMBER '0xff' (1, 0) (1, 4)
OP '<=' (1, 5) (1, 7)
NUMBER '255' (1, 8) (1, 11)
>>> dump_tokens("0b10 <= 255")
NUMBER '0b10' (1, 0) (1, 4)
OP '<=' (1, 5) (1, 7)
NUMBER '255' (1, 8) (1, 11)
>>> dump_tokens("0o123 <= 0123")
NUMBER '0o123' (1, 0) (1, 5)
OP '<=' (1, 6) (1, 8)
NUMBER '0123' (1, 9) (1, 13)
>>> dump_tokens("01234567 > ~0x15")
NUMBER '01234567' (1, 0) (1, 8)
OP '>' (1, 9) (1, 10)
...
...
Lib/tokenize.py
View file @
0aed07ad
...
...
@@ -51,9 +51,10 @@ Ignore = Whitespace + any(r'\\\r?\n' + Whitespace) + maybe(Comment)
Name
=
r'[a-zA-Z_]\
w*
'
Hexnumber = r'
0
[
xX
][
\
da
-
fA
-
F
]
+
[
lL
]
?
'
Octnumber = r'
0
[
0
-
7
]
*
[
lL
]
?
'
Octnumber = r'
(
0
[
oO
][
0
-
7
]
+
)
|
(
0
[
0
-
7
]
*
)[
lL
]
?
'
Binnumber = r'
0
[
bB
][
01
]
+
[
lL
]
?
'
Decnumber = r'
[
1
-
9
]
\
d
*
[
lL
]
?
'
Intnumber = group(Hexnumber, Octnumber, Decnumber)
Intnumber = group(Hexnumber,
Binnumber,
Octnumber, Decnumber)
Exponent = r'
[
eE
][
-+
]
?
\
d
+
'
Pointfloat = group(r'
\
d
+
\
.
\
d
*
', r'
\
.
\
d
+
') + maybe(Exponent)
Expfloat = r'
\
d
+
' + Exponent
...
...
Misc/NEWS
View file @
0aed07ad
...
...
@@ -12,6 +12,10 @@ What's New in Python 2.6 alpha 2?
Core and builtins
-----------------
- PEP 3127: octal literals now start with "0o". Old-style octal literals
are still valid. There are binary literals with a prefix of "0b".
This also affects int(x, 0).
- Issue #1779871: Gnu gcc can now build Python on OS X because the
flags -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd are no
longer passed.
...
...
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