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
c7eaede2
Kaydet (Commit)
c7eaede2
authored
Agu 09, 2010
tarafından
Florent Xicluna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix ``Tools/scripts/checkpyc.py`` after PEP 3147.
üst
e4a3380b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
17 deletions
+22
-17
NEWS
Misc/NEWS
+2
-0
checkpyc.py
Tools/scripts/checkpyc.py
+20
-17
No files found.
Misc/NEWS
Dosyayı görüntüle @
c7eaede2
...
@@ -150,6 +150,8 @@ Library
...
@@ -150,6 +150,8 @@ Library
Tools/Demos
Tools/Demos
-----------
-----------
- Fix ``Tools/scripts/checkpyc.py`` after PEP 3147.
- Issue #8867: Fix ``Tools/scripts/serve.py`` to work with files containing
- Issue #8867: Fix ``Tools/scripts/serve.py`` to work with files containing
non-ASCII content.
non-ASCII content.
...
...
Tools/scripts/checkpyc.py
Dosyayı görüntüle @
c7eaede2
...
@@ -7,14 +7,17 @@ import os
...
@@ -7,14 +7,17 @@ import os
from
stat
import
ST_MTIME
from
stat
import
ST_MTIME
import
imp
import
imp
# PEP 3147 compatibility (PYC Repository Directories)
cache_from_source
=
(
imp
.
cache_from_source
if
hasattr
(
imp
,
'get_tag'
)
else
lambda
path
:
path
+
'c'
)
def
main
():
def
main
():
silent
=
0
if
len
(
sys
.
argv
)
>
1
:
verbose
=
0
verbose
=
(
sys
.
argv
[
1
]
==
'-v'
)
if
sys
.
argv
[
1
:]:
silent
=
(
sys
.
argv
[
1
]
==
'-s'
)
if
sys
.
argv
[
1
]
==
'-v'
:
else
:
verbose
=
1
verbose
=
silent
=
False
elif
sys
.
argv
[
1
]
==
'-s'
:
silent
=
1
MAGIC
=
imp
.
get_magic
()
MAGIC
=
imp
.
get_magic
()
if
not
silent
:
if
not
silent
:
print
(
'Using MAGIC word'
,
repr
(
MAGIC
))
print
(
'Using MAGIC word'
,
repr
(
MAGIC
))
...
@@ -26,9 +29,8 @@ def main():
...
@@ -26,9 +29,8 @@ def main():
continue
continue
if
not
silent
:
if
not
silent
:
print
(
'Checking '
,
repr
(
dirname
),
'...'
)
print
(
'Checking '
,
repr
(
dirname
),
'...'
)
names
.
sort
()
for
name
in
sorted
(
names
):
for
name
in
names
:
if
name
.
endswith
(
'.py'
):
if
name
[
-
3
:]
==
'.py'
:
name
=
os
.
path
.
join
(
dirname
,
name
)
name
=
os
.
path
.
join
(
dirname
,
name
)
try
:
try
:
st
=
os
.
stat
(
name
)
st
=
os
.
stat
(
name
)
...
@@ -37,30 +39,31 @@ def main():
...
@@ -37,30 +39,31 @@ def main():
continue
continue
if
verbose
:
if
verbose
:
print
(
'Check'
,
repr
(
name
),
'...'
)
print
(
'Check'
,
repr
(
name
),
'...'
)
name_c
=
name
+
'c'
name_c
=
cache_from_source
(
name
)
try
:
try
:
f
=
open
(
name_c
,
'r'
)
with
open
(
name_c
,
'rb'
)
as
f
:
magic_str
=
f
.
read
(
4
)
mtime_str
=
f
.
read
(
4
)
except
IOError
:
except
IOError
:
print
(
'Cannot open'
,
repr
(
name_c
))
print
(
'Cannot open'
,
repr
(
name_c
))
continue
continue
magic_str
=
f
.
read
(
4
)
mtime_str
=
f
.
read
(
4
)
f
.
close
()
if
magic_str
!=
MAGIC
:
if
magic_str
!=
MAGIC
:
print
(
'Bad MAGIC word in ".pyc" file'
,
end
=
' '
)
print
(
'Bad MAGIC word in ".pyc" file'
,
end
=
' '
)
print
(
repr
(
name_c
))
print
(
repr
(
name_c
))
continue
continue
mtime
=
get_long
(
mtime_str
)
mtime
=
get_long
(
mtime_str
)
if
mtime
==
0
or
mtime
==
-
1
:
if
mtime
in
{
0
,
-
1
}
:
print
(
'Bad ".pyc" file'
,
repr
(
name_c
))
print
(
'Bad ".pyc" file'
,
repr
(
name_c
))
elif
mtime
!=
st
[
ST_MTIME
]:
elif
mtime
!=
st
[
ST_MTIME
]:
print
(
'Out-of-date ".pyc" file'
,
end
=
' '
)
print
(
'Out-of-date ".pyc" file'
,
end
=
' '
)
print
(
repr
(
name_c
))
print
(
repr
(
name_c
))
def
get_long
(
s
):
def
get_long
(
s
):
if
len
(
s
)
!=
4
:
if
len
(
s
)
!=
4
:
return
-
1
return
-
1
return
ord
(
s
[
0
])
+
(
ord
(
s
[
1
])
<<
8
)
+
(
ord
(
s
[
2
])
<<
16
)
+
(
ord
(
s
[
3
])
<<
24
)
return
s
[
0
]
+
(
s
[
1
]
<<
8
)
+
(
s
[
2
]
<<
16
)
+
(
s
[
3
]
<<
24
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
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