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
3403f158
Kaydet (Commit)
3403f158
authored
Ock 09, 2008
tarafından
Christian Heimes
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #1776. __import__() no longer imports modules by file name
üst
195b883b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
1 deletion
+25
-1
test_import.py
Lib/test/test_import.py
+11
-1
NEWS
Misc/NEWS
+4
-0
import.c
Python/import.c
+10
-0
No files found.
Lib/test/test_import.py
Dosyayı görüntüle @
3403f158
from
test.test_support
import
TESTFN
,
run_unittest
,
catch_warning
from
test.test_support
import
TESTFN
,
run_unittest
,
catch_warning
import
unittest
import
os
...
...
@@ -223,6 +223,16 @@ class ImportTest(unittest.TestCase):
warnings
.
simplefilter
(
'error'
,
ImportWarning
)
self
.
assertRaises
(
ImportWarning
,
__import__
,
"site-packages"
)
def
test_importbyfilename
(
self
):
path
=
os
.
path
.
abspath
(
TESTFN
)
try
:
__import__
(
path
)
except
ImportError
,
err
:
self
.
assertEqual
(
"Import by filename is not supported."
,
err
.
args
[
0
])
else
:
self
.
fail
(
"import by path didn't raise an exception"
)
class
PathsTests
(
unittest
.
TestCase
):
path
=
TESTFN
...
...
Misc/NEWS
Dosyayı görüntüle @
3403f158
...
...
@@ -12,6 +12,10 @@ What's New in Python 2.6 alpha 1?
Core and builtins
-----------------
- Bug #1776: __import__ must not accept filenames. Python 2.6 does no longer
support module loading by filename. It worked on some system by coincident
but it was never intended to work.
- Patch #1668: renamed THREADDEBUG envvar to PYTHONTHREADDEBUG.
- Patch #602345: Add -B command line option, PYTHONDONTWRITEBYTECODE envvar
...
...
Python/import.c
Dosyayı görüntüle @
3403f158
...
...
@@ -2055,6 +2055,16 @@ import_module_level(char *name, PyObject *globals, PyObject *locals,
Py_ssize_t
buflen
=
0
;
PyObject
*
parent
,
*
head
,
*
next
,
*
tail
;
if
(
strchr
(
name
,
'/'
)
!=
NULL
#ifdef MS_WINDOWS
||
strchr
(
name
,
'\\'
)
!=
NULL
#endif
)
{
PyErr_SetString
(
PyExc_ImportError
,
"Import by filename is not supported."
);
return
NULL
;
}
parent
=
get_parent
(
globals
,
buf
,
&
buflen
,
level
);
if
(
parent
==
NULL
)
return
NULL
;
...
...
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