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
c127a86e
Kaydet (Commit)
c127a86e
authored
Nis 17, 2018
tarafından
Aaron Ang
Kaydeden (comit)
Łukasz Langa
Nis 17, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-11594: Ensure line-endings are respected when using 2to3 (GH-6483)
üst
36d56ea8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
18 deletions
+35
-18
refactor.py
Lib/lib2to3/refactor.py
+1
-1
crlf.py
Lib/lib2to3/tests/data/crlf.py
+3
-3
test_refactor.py
Lib/lib2to3/tests/test_refactor.py
+30
-14
2018-04-16-08-42-03.bpo-11594.QLo4vv.rst
...S.d/next/Library/2018-04-16-08-42-03.bpo-11594.QLo4vv.rst
+1
-0
No files found.
Lib/lib2to3/refactor.py
Dosyayı görüntüle @
c127a86e
...
...
@@ -314,7 +314,7 @@ class RefactoringTool(object):
encoding
=
tokenize
.
detect_encoding
(
f
.
readline
)[
0
]
finally
:
f
.
close
()
with
io
.
open
(
filename
,
"r"
,
encoding
=
encoding
)
as
f
:
with
io
.
open
(
filename
,
"r"
,
encoding
=
encoding
,
newline
=
''
)
as
f
:
return
f
.
read
(),
encoding
def
refactor_file
(
self
,
filename
,
write
=
False
,
doctests_only
=
False
):
...
...
Lib/lib2to3/tests/data/crlf.py
Dosyayı görüntüle @
c127a86e
print
"hi"
print
"Like bad Windows newlines?"
print
"hi"
print
"Like bad Windows newlines?"
Lib/lib2to3/tests/test_refactor.py
Dosyayı görüntüle @
c127a86e
...
...
@@ -180,32 +180,42 @@ from __future__ import print_function"""
def
check_file_refactoring
(
self
,
test_file
,
fixers
=
_2TO3_FIXERS
,
options
=
None
,
mock_log_debug
=
None
,
actually_write
=
True
):
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
"2to3-test_refactor"
)
self
.
addCleanup
(
shutil
.
rmtree
,
tmpdir
)
# make a copy of the tested file that we can write to
shutil
.
copy
(
test_file
,
tmpdir
)
test_file
=
os
.
path
.
join
(
tmpdir
,
os
.
path
.
basename
(
test_file
))
os
.
chmod
(
test_file
,
0
o644
)
def
read_file
():
with
open
(
test_file
,
"rb"
)
as
fp
:
return
fp
.
read
()
old_contents
=
read_file
()
test_file
=
self
.
init_test_file
(
test_file
)
old_contents
=
self
.
read_file
(
test_file
)
rt
=
self
.
rt
(
fixers
=
fixers
,
options
=
options
)
if
mock_log_debug
:
rt
.
log_debug
=
mock_log_debug
rt
.
refactor_file
(
test_file
)
self
.
assertEqual
(
old_contents
,
read_file
(
))
self
.
assertEqual
(
old_contents
,
self
.
read_file
(
test_file
))
if
not
actually_write
:
return
rt
.
refactor_file
(
test_file
,
True
)
new_contents
=
read_file
(
)
new_contents
=
self
.
read_file
(
test_file
)
self
.
assertNotEqual
(
old_contents
,
new_contents
)
return
new_contents
def
init_test_file
(
self
,
test_file
):
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
"2to3-test_refactor"
)
self
.
addCleanup
(
shutil
.
rmtree
,
tmpdir
)
shutil
.
copy
(
test_file
,
tmpdir
)
test_file
=
os
.
path
.
join
(
tmpdir
,
os
.
path
.
basename
(
test_file
))
os
.
chmod
(
test_file
,
0
o644
)
return
test_file
def
read_file
(
self
,
test_file
):
with
open
(
test_file
,
"rb"
)
as
fp
:
return
fp
.
read
()
def
refactor_file
(
self
,
test_file
,
fixers
=
_2TO3_FIXERS
):
test_file
=
self
.
init_test_file
(
test_file
)
old_contents
=
self
.
read_file
(
test_file
)
rt
=
self
.
rt
(
fixers
=
fixers
)
rt
.
refactor_file
(
test_file
,
True
)
new_contents
=
self
.
read_file
(
test_file
)
return
old_contents
,
new_contents
def
test_refactor_file
(
self
):
test_file
=
os
.
path
.
join
(
FIXER_DIR
,
"parrot_example.py"
)
self
.
check_file_refactoring
(
test_file
,
_DEFAULT_FIXERS
)
...
...
@@ -285,6 +295,12 @@ from __future__ import print_function"""
finally
:
os
.
linesep
=
old_sep
def
test_crlf_unchanged
(
self
):
fn
=
os
.
path
.
join
(
TEST_DATA_DIR
,
"crlf.py"
)
old
,
new
=
self
.
refactor_file
(
fn
)
self
.
assertIn
(
b
"
\r\n
"
,
old
)
self
.
assertIn
(
b
"
\r\n
"
,
new
)
def
test_refactor_docstring
(
self
):
rt
=
self
.
rt
()
...
...
Misc/NEWS.d/next/Library/2018-04-16-08-42-03.bpo-11594.QLo4vv.rst
0 → 100644
Dosyayı görüntüle @
c127a86e
Ensure line-endings are respected when using lib2to3.
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