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
e787bce7
Kaydet (Commit)
e787bce7
authored
Eyl 16, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #18873: IDLE, 2to3, and the findnocoding.py script now detect Python
source code encoding only in comment lines.
üst
74213e4e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
14 deletions
+26
-14
IOBinding.py
Lib/idlelib/IOBinding.py
+7
-6
tokenize.py
Lib/lib2to3/pgen2/tokenize.py
+4
-5
false_encoding.py
Lib/lib2to3/tests/data/false_encoding.py
+2
-0
test_refactor.py
Lib/lib2to3/tests/test_refactor.py
+4
-0
NEWS
Misc/NEWS
+6
-0
findnocoding.py
Tools/scripts/findnocoding.py
+3
-3
No files found.
Lib/idlelib/IOBinding.py
Dosyayı görüntüle @
e787bce7
...
...
@@ -71,7 +71,7 @@ else:
encoding
=
encoding
.
lower
()
coding_re
=
re
.
compile
(
"coding[:=]
\
s*([-
\
w_.]+)"
)
coding_re
=
re
.
compile
(
r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)'
,
re
.
ASCII
)
class
EncodingMessage
(
SimpleDialog
):
"Inform user that an encoding declaration is needed."
...
...
@@ -125,11 +125,12 @@ def coding_spec(str):
Raise LookupError if the encoding is declared but unknown.
"""
# Only consider the first two lines
str
=
str
.
split
(
"
\n
"
)[:
2
]
str
=
"
\n
"
.
join
(
str
)
match
=
coding_re
.
search
(
str
)
if
not
match
:
str
=
str
.
split
(
"
\n
"
,
2
)[:
2
]
for
line
in
lst
:
match
=
coding_re
.
match
(
line
)
if
match
is
not
None
:
break
else
:
return
None
name
=
match
.
group
(
1
)
# Check whether the encoding is known
...
...
Lib/lib2to3/pgen2/tokenize.py
Dosyayı görüntüle @
e787bce7
...
...
@@ -236,7 +236,7 @@ class Untokenizer:
startline
=
False
toks_append
(
tokval
)
cookie_re
=
re
.
compile
(
"coding[:=]
\
s*([-
\
w.]+)"
)
cookie_re
=
re
.
compile
(
r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)'
,
re
.
ASCII
)
def
_get_normal_name
(
orig_enc
):
"""Imitates get_normal_name in tokenizer.c."""
...
...
@@ -281,11 +281,10 @@ def detect_encoding(readline):
line_string
=
line
.
decode
(
'ascii'
)
except
UnicodeDecodeError
:
return
None
matches
=
cookie_re
.
findall
(
line_string
)
if
not
matches
:
match
=
cookie_re
.
match
(
line_string
)
if
not
match
:
return
None
encoding
=
_get_normal_name
(
match
es
[
0
]
)
encoding
=
_get_normal_name
(
match
.
group
(
1
)
)
try
:
codec
=
lookup
(
encoding
)
except
LookupError
:
...
...
Lib/lib2to3/tests/data/false_encoding.py
0 → 100644
Dosyayı görüntüle @
e787bce7
#!/usr/bin/env python
print
'#coding=0'
Lib/lib2to3/tests/test_refactor.py
Dosyayı görüntüle @
e787bce7
...
...
@@ -271,6 +271,10 @@ from __future__ import print_function"""
fn
=
os
.
path
.
join
(
TEST_DATA_DIR
,
"different_encoding.py"
)
self
.
check_file_refactoring
(
fn
)
def
test_false_file_encoding
(
self
):
fn
=
os
.
path
.
join
(
TEST_DATA_DIR
,
"false_encoding.py"
)
data
=
self
.
check_file_refactoring
(
fn
)
def
test_bom
(
self
):
fn
=
os
.
path
.
join
(
TEST_DATA_DIR
,
"bom.py"
)
data
=
self
.
check_file_refactoring
(
fn
)
...
...
Misc/NEWS
Dosyayı görüntüle @
e787bce7
...
...
@@ -183,6 +183,9 @@ Library
Tools
/
Demos
-----------
-
Issue
#
18873
:
2
to3
and
the
findnocoding
.
py
script
now
detect
Python
source
code
encoding
only
in
comment
lines
.
-
Issue
#
18817
:
Fix
a
resource
warning
in
Lib
/
aifc
.
py
demo
.
-
Issue
#
18439
:
Make
patchcheck
work
on
Windows
for
ACKS
,
NEWS
.
...
...
@@ -207,6 +210,9 @@ Build
IDLE
----
- Issue #18873: IDLE now detects Python source code encoding only in comment
lines.
- Issue #18988: The "Tab" key now works when a word is already autocompleted.
- Issue #18489: Add tests for SearchEngine. Original patch by Phil Webster.
...
...
Tools/scripts/findnocoding.py
Dosyayı görüntüle @
e787bce7
...
...
@@ -32,13 +32,13 @@ except ImportError:
"no sophisticated Python source file search will be done."
)
decl_re
=
re
.
compile
(
r
"coding[=:]\s*([-\w.]+)"
)
decl_re
=
re
.
compile
(
r
'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)'
,
re
.
ASCII
)
def
get_declaration
(
line
):
match
=
decl_re
.
sear
ch
(
line
)
match
=
decl_re
.
mat
ch
(
line
)
if
match
:
return
match
.
group
(
1
)
return
''
return
b
''
def
has_correct_encoding
(
text
,
codec
):
try
:
...
...
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