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
be4c0f56
Kaydet (Commit)
be4c0f56
authored
Ock 04, 2001
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Recognize pyc files even if they don't end in pyc.
Patch #103067 with modifications as discussed in email.
üst
b31d36cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
7 deletions
+41
-7
NEWS
Misc/NEWS
+8
-0
pythonrun.c
Python/pythonrun.c
+33
-7
No files found.
Misc/NEWS
Dosyayı görüntüle @
be4c0f56
...
...
@@ -3,6 +3,14 @@ What's New in Python 2.1 alpha 1?
Core language, builtins, and interpreter
- The interpreter accepts now bytecode files on the command line even
if they do not have a .pyc or .pyo extension. On Linux, after executing
echo ':pyc:M::\x87\xc6\x0d\x0a::/usr/local/bin/python:' > /proc/sys/fs/binfmt_misc/register
any byte code file can be used as an executable (i.e. as an argument
to execve(2)).
- %[xXo] formats of negative Python longs now produce a sign
character. In 1.6 and earlier, they never produced a sign,
and raised an error if the value of the long was too large
...
...
Python/pythonrun.c
Dosyayı görüntüle @
be4c0f56
...
...
@@ -546,6 +546,38 @@ PyRun_SimpleFile(FILE *fp, char *filename)
return
PyRun_SimpleFileEx
(
fp
,
filename
,
0
);
}
/* Check whether a file maybe a pyc file: Look at the extension,
the file type, and, if we may close it, at the first few bytes. */
static
int
maybe_pyc_file
(
FILE
*
fp
,
char
*
filename
,
char
*
ext
,
int
closeit
)
{
if
(
strcmp
(
ext
,
".pyc"
)
==
0
||
strcmp
(
ext
,
".pyo"
)
==
0
)
return
1
;
#ifdef macintosh
/* On a mac, we also assume a pyc file for types 'PYC ' and 'APPL' */
if
(
PyMac_getfiletype
(
filename
)
==
'
PYC
'
||
PyMac_getfiletype
(
filename
)
==
'
APPL
'
)
return
1
;
#endif
/* macintosh */
/* Only look into the file if we are allowed to close it, since
it then should also be seekable. */
if
(
closeit
)
{
/* Read only two bytes of the magic. If the file was opened in
text mode, the bytes 3 and 4 of the magic (\r\n) might not
be read as they are on disk. */
unsigned
int
halfmagic
=
PyImport_GetMagicNumber
()
&
0xFFFF
;
unsigned
char
buf
[
2
];
if
(
fread
(
buf
,
1
,
2
,
fp
)
==
2
&&
(
buf
[
1
]
<<
8
|
buf
[
0
])
==
halfmagic
)
return
1
;
fseek
(
fp
,
0
,
SEEK_SET
);
}
return
0
;
}
int
PyRun_SimpleFileEx
(
FILE
*
fp
,
char
*
filename
,
int
closeit
)
{
...
...
@@ -557,13 +589,7 @@ PyRun_SimpleFileEx(FILE *fp, char *filename, int closeit)
return
-
1
;
d
=
PyModule_GetDict
(
m
);
ext
=
filename
+
strlen
(
filename
)
-
4
;
if
(
strcmp
(
ext
,
".pyc"
)
==
0
||
strcmp
(
ext
,
".pyo"
)
==
0
#ifdef macintosh
/* On a mac, we also assume a pyc file for types 'PYC ' and 'APPL' */
||
PyMac_getfiletype
(
filename
)
==
'
PYC
'
||
PyMac_getfiletype
(
filename
)
==
'
APPL
'
#endif
/* macintosh */
)
{
if
(
maybe_pyc_file
(
fp
,
filename
,
ext
,
closeit
))
{
/* Try to run a pyc file. First, re-open in binary */
if
(
closeit
)
fclose
(
fp
);
...
...
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