Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
de8c723d
Kaydet (Commit)
de8c723d
authored
Eki 07, 2011
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merged
üst
7010a07b
c6cfd4aa
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
23 deletions
+39
-23
patcomp.py
Lib/lib2to3/patcomp.py
+2
-1
driver.py
Lib/lib2to3/pgen2/driver.py
+2
-9
test_parser.py
Lib/lib2to3/tests/test_parser.py
+26
-12
test_lib2to3.py
Lib/test/test_lib2to3.py
+2
-1
NEWS
Misc/NEWS
+7
-0
No files found.
Lib/lib2to3/patcomp.py
Dosyayı görüntüle @
de8c723d
...
@@ -11,6 +11,7 @@ The compiler compiles a pattern to a pytree.*Pattern instance.
...
@@ -11,6 +11,7 @@ The compiler compiles a pattern to a pytree.*Pattern instance.
__author__
=
"Guido van Rossum <guido@python.org>"
__author__
=
"Guido van Rossum <guido@python.org>"
# Python imports
# Python imports
import
io
import
os
import
os
# Fairly local imports
# Fairly local imports
...
@@ -32,7 +33,7 @@ class PatternSyntaxError(Exception):
...
@@ -32,7 +33,7 @@ class PatternSyntaxError(Exception):
def
tokenize_wrapper
(
input
):
def
tokenize_wrapper
(
input
):
"""Tokenizes a string suppressing significant whitespace."""
"""Tokenizes a string suppressing significant whitespace."""
skip
=
set
((
token
.
NEWLINE
,
token
.
INDENT
,
token
.
DEDENT
))
skip
=
set
((
token
.
NEWLINE
,
token
.
INDENT
,
token
.
DEDENT
))
tokens
=
tokenize
.
generate_tokens
(
driver
.
generate_lines
(
input
)
.
__next__
)
tokens
=
tokenize
.
generate_tokens
(
io
.
StringIO
(
input
)
.
readline
)
for
quintuple
in
tokens
:
for
quintuple
in
tokens
:
type
,
value
,
start
,
end
,
line_text
=
quintuple
type
,
value
,
start
,
end
,
line_text
=
quintuple
if
type
not
in
skip
:
if
type
not
in
skip
:
...
...
Lib/lib2to3/pgen2/driver.py
Dosyayı görüntüle @
de8c723d
...
@@ -17,6 +17,7 @@ __all__ = ["Driver", "load_grammar"]
...
@@ -17,6 +17,7 @@ __all__ = ["Driver", "load_grammar"]
# Python imports
# Python imports
import
codecs
import
codecs
import
io
import
os
import
os
import
logging
import
logging
import
sys
import
sys
...
@@ -101,18 +102,10 @@ class Driver(object):
...
@@ -101,18 +102,10 @@ class Driver(object):
def
parse_string
(
self
,
text
,
debug
=
False
):
def
parse_string
(
self
,
text
,
debug
=
False
):
"""Parse a string and return the syntax tree."""
"""Parse a string and return the syntax tree."""
tokens
=
tokenize
.
generate_tokens
(
generate_lines
(
text
)
.
__next__
)
tokens
=
tokenize
.
generate_tokens
(
io
.
StringIO
(
text
)
.
readline
)
return
self
.
parse_tokens
(
tokens
,
debug
)
return
self
.
parse_tokens
(
tokens
,
debug
)
def
generate_lines
(
text
):
"""Generator that behaves like readline without using StringIO."""
for
line
in
text
.
splitlines
(
True
):
yield
line
while
True
:
yield
""
def
load_grammar
(
gt
=
"Grammar.txt"
,
gp
=
None
,
def
load_grammar
(
gt
=
"Grammar.txt"
,
gp
=
None
,
save
=
True
,
force
=
False
,
logger
=
None
):
save
=
True
,
force
=
False
,
logger
=
None
):
"""Load the grammar (maybe from a pickle)."""
"""Load the grammar (maybe from a pickle)."""
...
...
Lib/lib2to3/tests/test_parser.py
Dosyayı görüntüle @
de8c723d
...
@@ -14,10 +14,21 @@ from .support import driver, test_dir
...
@@ -14,10 +14,21 @@ from .support import driver, test_dir
# Python imports
# Python imports
import
os
import
os
import
unittest
# Local imports
# Local imports
from
lib2to3.pgen2
import
tokenize
from
lib2to3.pgen2
import
tokenize
from
..pgen2.parse
import
ParseError
from
..pgen2.parse
import
ParseError
from
lib2to3.pygram
import
python_symbols
as
syms
class
TestDriver
(
support
.
TestCase
):
def
test_formfeed
(
self
):
s
=
"""print 1
\n\x0C
print 2
\n
"""
t
=
driver
.
parse_string
(
s
)
self
.
assertEqual
(
t
.
children
[
0
]
.
children
[
0
]
.
type
,
syms
.
print_stmt
)
self
.
assertEqual
(
t
.
children
[
1
]
.
children
[
0
]
.
type
,
syms
.
print_stmt
)
class
GrammarTest
(
support
.
TestCase
):
class
GrammarTest
(
support
.
TestCase
):
...
@@ -147,19 +158,22 @@ class TestParserIdempotency(support.TestCase):
...
@@ -147,19 +158,22 @@ class TestParserIdempotency(support.TestCase):
"""A cut-down version of pytree_idempotency.py."""
"""A cut-down version of pytree_idempotency.py."""
# Issue 13125
@unittest.expectedFailure
def
test_all_project_files
(
self
):
def
test_all_project_files
(
self
):
for
filepath
in
support
.
all_project_files
():
for
filepath
in
support
.
all_project_files
():
with
open
(
filepath
,
"rb"
)
as
fp
:
with
open
(
filepath
,
"rb"
)
as
fp
:
encoding
=
tokenize
.
detect_encoding
(
fp
.
readline
)[
0
]
encoding
=
tokenize
.
detect_encoding
(
fp
.
readline
)[
0
]
self
.
assertTrue
(
encoding
is
not
None
,
self
.
assertTrue
(
encoding
is
not
None
,
"can't detect encoding for
%
s"
%
filepath
)
"can't detect encoding for
%
s"
%
filepath
)
with
open
(
filepath
,
"r"
)
as
fp
:
with
open
(
filepath
,
"r"
,
encoding
=
encoding
)
as
fp
:
source
=
fp
.
read
()
source
=
fp
.
read
()
source
=
source
.
decode
(
encoding
)
try
:
tree
=
driver
.
parse_string
(
source
)
tree
=
driver
.
parse_string
(
source
)
except
ParseError
as
err
:
print
(
'ParseError on file'
,
filepath
,
err
)
continue
new
=
str
(
tree
)
new
=
str
(
tree
)
if
encoding
:
new
=
new
.
encode
(
encoding
)
if
diff
(
filepath
,
new
):
if
diff
(
filepath
,
new
):
self
.
fail
(
"Idempotency failed:
%
s"
%
filepath
)
self
.
fail
(
"Idempotency failed:
%
s"
%
filepath
)
...
@@ -202,14 +216,14 @@ class TestLiterals(GrammarTest):
...
@@ -202,14 +216,14 @@ class TestLiterals(GrammarTest):
self
.
validate
(
s
)
self
.
validate
(
s
)
def
diff
(
fn
,
result
,
encoding
):
def
diff
(
fn
,
result
):
f
=
open
(
"@"
,
"w"
)
try
:
f
.
write
(
result
.
encode
(
encoding
))
finally
:
f
.
close
()
try
:
try
:
with
open
(
'@'
,
'w'
)
as
f
:
f
.
write
(
str
(
result
))
fn
=
fn
.
replace
(
'"'
,
'
\\
"'
)
fn
=
fn
.
replace
(
'"'
,
'
\\
"'
)
return
os
.
system
(
'diff -u "
%
s" @'
%
fn
)
return
os
.
system
(
'diff -u "
%
s" @'
%
fn
)
finally
:
finally
:
os
.
remove
(
"@"
)
try
:
os
.
remove
(
"@"
)
except
OSError
:
pass
Lib/test/test_lib2to3.py
Dosyayı görüntüle @
de8c723d
# Skipping test_parser and test_all_fixers
# Skipping test_parser and test_all_fixers
# because of running
# because of running
from
lib2to3.tests
import
(
test_fixers
,
test_pytree
,
test_util
,
test_refactor
,
from
lib2to3.tests
import
(
test_fixers
,
test_pytree
,
test_util
,
test_refactor
,
test_parser
,
test_main
as
test_main_
)
test_main
as
test_main_
)
import
unittest
import
unittest
from
test.support
import
run_unittest
from
test.support
import
run_unittest
...
@@ -9,7 +10,7 @@ def suite():
...
@@ -9,7 +10,7 @@ def suite():
tests
=
unittest
.
TestSuite
()
tests
=
unittest
.
TestSuite
()
loader
=
unittest
.
TestLoader
()
loader
=
unittest
.
TestLoader
()
for
m
in
(
test_fixers
,
test_pytree
,
test_util
,
test_refactor
,
for
m
in
(
test_fixers
,
test_pytree
,
test_util
,
test_refactor
,
test_main_
):
test_
parser
,
test_
main_
):
tests
.
addTests
(
loader
.
loadTestsFromModule
(
m
))
tests
.
addTests
(
loader
.
loadTestsFromModule
(
m
))
return
tests
return
tests
...
...
Misc/NEWS
Dosyayı görüntüle @
de8c723d
...
@@ -43,6 +43,10 @@ Core and Builtins
...
@@ -43,6 +43,10 @@ Core and Builtins
Library
Library
-------
-------
- Issue #11250: Back port fix from 3.3 branch, so that 2to3 can handle files
with line feeds. This was ported from the sandbox to the 3.3 branch, but
didn't make it into 3.2.
- Issue #7367: Fix pkgutil.walk_paths to skip directories whose
- Issue #7367: Fix pkgutil.walk_paths to skip directories whose
contents cannot be read.
contents cannot be read.
...
@@ -105,6 +109,9 @@ Tests
...
@@ -105,6 +109,9 @@ Tests
- Issue #12821: Fix test_fcntl failures on OpenBSD 5.
- Issue #12821: Fix test_fcntl failures on OpenBSD 5.
- Re-enable lib2to3's test_parser.py tests, though with an expected failure
(see issue 13125).
Extension Modules
Extension Modules
-----------------
-----------------
...
...
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