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
00888934
Kaydet (Commit)
00888934
authored
Mar 18, 2010
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
kill py_compile's homemade encoding detection in favor of tokenize.detect_encoding() (see #8168)
üst
1613ed81
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
17 deletions
+5
-17
py_compile.py
Lib/py_compile.py
+3
-17
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/py_compile.py
Dosyayı görüntüle @
00888934
...
...
@@ -7,8 +7,8 @@ import builtins
import
imp
import
marshal
import
os
import
re
import
sys
import
tokenize
import
traceback
MAGIC
=
imp
.
get_magic
()
...
...
@@ -69,21 +69,6 @@ def wr_long(f, x):
(
x
>>
16
)
&
0xff
,
(
x
>>
24
)
&
0xff
]))
def
read_encoding
(
file
,
default
):
"""Read the first two lines of the file looking for coding: xyzzy."""
f
=
open
(
file
,
"rb"
)
try
:
for
i
in
range
(
2
):
line
=
f
.
readline
()
if
not
line
:
break
m
=
re
.
match
(
br
".*
\b
coding:
\
s*(
\
S+)
\b
"
,
line
)
if
m
:
return
m
.
group
(
1
)
.
decode
(
"ascii"
)
return
default
finally
:
f
.
close
()
def
compile
(
file
,
cfile
=
None
,
dfile
=
None
,
doraise
=
False
):
"""Byte-compile one Python source file to Python bytecode.
...
...
@@ -119,7 +104,8 @@ def compile(file, cfile=None, dfile=None, doraise=False):
directories).
"""
encoding
=
read_encoding
(
file
,
"utf-8"
)
with
open
(
file
,
"rb"
)
as
f
:
encoding
=
tokenize
.
detect_encoding
(
f
.
readline
)[
0
]
with
open
(
file
,
encoding
=
encoding
)
as
f
:
try
:
timestamp
=
int
(
os
.
fstat
(
f
.
fileno
())
.
st_mtime
)
...
...
Misc/NEWS
Dosyayı görüntüle @
00888934
...
...
@@ -283,6 +283,8 @@ C-API
Library
-------
- Issue #8168: py_compile now handles files with utf-8 BOMS.
- ``tokenize.detect_encoding`` now returns ``'utf-8-sig'`` when a UTF-8 BOM is
detected.
...
...
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