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
5ed7bd79
Kaydet (Commit)
5ed7bd79
authored
May 25, 2012
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
simplify and rewrite the zipimport part of 702009f3c0b1 a bit
üst
209e04c2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
51 deletions
+41
-51
zipimport.c
Modules/zipimport.c
+41
-51
No files found.
Modules/zipimport.c
Dosyayı görüntüle @
5ed7bd79
...
@@ -319,13 +319,20 @@ get_module_info(ZipImporter *self, PyObject *fullname)
...
@@ -319,13 +319,20 @@ get_module_info(ZipImporter *self, PyObject *fullname)
return
MI_NOT_FOUND
;
return
MI_NOT_FOUND
;
}
}
typedef
enum
{
fl_error
,
fl_not_found
,
fl_module_found
,
fl_ns_found
}
find_loader_result
;
/* The guts of "find_loader" and "find_module". Return values:
/* The guts of "find_loader" and "find_module". Return values:
-1: error
-1: error
0: no loader or namespace portions found
0: no loader or namespace portions found
1: module/package found
1: module/package found
2: namespace portion found: *namespace_portion will point to the name
2: namespace portion found: *namespace_portion will point to the name
*/
*/
static
in
t
static
find_loader_resul
t
find_loader
(
ZipImporter
*
self
,
PyObject
*
fullname
,
PyObject
**
namespace_portion
)
find_loader
(
ZipImporter
*
self
,
PyObject
*
fullname
,
PyObject
**
namespace_portion
)
{
{
enum
zi_module_info
mi
;
enum
zi_module_info
mi
;
...
@@ -334,7 +341,7 @@ find_loader(ZipImporter *self, PyObject *fullname, PyObject **namespace_portion)
...
@@ -334,7 +341,7 @@ find_loader(ZipImporter *self, PyObject *fullname, PyObject **namespace_portion)
mi
=
get_module_info
(
self
,
fullname
);
mi
=
get_module_info
(
self
,
fullname
);
if
(
mi
==
MI_ERROR
)
if
(
mi
==
MI_ERROR
)
return
-
1
;
return
fl_error
;
if
(
mi
==
MI_NOT_FOUND
)
{
if
(
mi
==
MI_NOT_FOUND
)
{
/* Not a module or regular package. See if this is a directory, and
/* Not a module or regular package. See if this is a directory, and
therefore possibly a portion of a namespace package. */
therefore possibly a portion of a namespace package. */
...
@@ -349,13 +356,13 @@ find_loader(ZipImporter *self, PyObject *fullname, PyObject **namespace_portion)
...
@@ -349,13 +356,13 @@ find_loader(ZipImporter *self, PyObject *fullname, PyObject **namespace_portion)
self
->
archive
,
SEP
,
self
->
archive
,
SEP
,
self
->
prefix
,
fullname
);
self
->
prefix
,
fullname
);
if
(
*
namespace_portion
==
NULL
)
if
(
*
namespace_portion
==
NULL
)
return
-
1
;
return
fl_error
;
return
2
;
return
fl_ns_found
;
}
}
return
0
;
return
fl_not_found
;
}
}
/* This is a module or package. */
/* This is a module or package. */
return
1
;
return
fl_module_found
;
}
}
...
@@ -367,32 +374,26 @@ zipimporter_find_module(PyObject *obj, PyObject *args)
...
@@ -367,32 +374,26 @@ zipimporter_find_module(PyObject *obj, PyObject *args)
ZipImporter
*
self
=
(
ZipImporter
*
)
obj
;
ZipImporter
*
self
=
(
ZipImporter
*
)
obj
;
PyObject
*
path
=
NULL
;
PyObject
*
path
=
NULL
;
PyObject
*
fullname
;
PyObject
*
fullname
;
PyObject
*
namespace_portion
=
NULL
;
PyObject
*
namespace_portion
=
NULL
;
PyObject
*
result
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"U|O:zipimporter.find_module"
,
if
(
!
PyArg_ParseTuple
(
args
,
"U|O:zipimporter.find_module"
,
&
fullname
,
&
path
))
&
fullname
,
&
path
))
return
NULL
;
goto
error
;
switch
(
find_loader
(
self
,
fullname
,
&
namespace_portion
))
{
switch
(
find_loader
(
self
,
fullname
,
&
namespace_portion
))
{
case
-
1
:
/* Error */
case
fl_ns_found
:
goto
error
;
/* A namespace portion is not allowed via find_module, so return None. */
case
0
:
/* Not found, return None */
Py_INCREF
(
Py_None
);
return
Py_None
;
case
1
:
/* Return self */
Py_INCREF
(
self
);
return
(
PyObject
*
)
self
;
case
2
:
/* A namespace portion, but not allowed via
find_module, so return None */
Py_DECREF
(
namespace_portion
);
Py_DECREF
(
namespace_portion
);
Py_INCREF
(
Py_None
);
/* FALL THROUGH */
return
Py_None
;
case
fl_error
:
case
fl_not_found
:
result
=
Py_None
;
break
;
case
fl_module_found
:
result
=
(
PyObject
*
)
self
;
break
;
}
}
/* Can't get here. */
Py_XINCREF
(
result
);
assert
(
0
);
return
NULL
;
error:
Py_XDECREF
(
namespace_portion
);
return
NULL
;
return
NULL
;
}
}
...
@@ -411,35 +412,24 @@ zipimporter_find_loader(PyObject *obj, PyObject *args)
...
@@ -411,35 +412,24 @@ zipimporter_find_loader(PyObject *obj, PyObject *args)
PyObject
*
result
=
NULL
;
PyObject
*
result
=
NULL
;
PyObject
*
namespace_portion
=
NULL
;
PyObject
*
namespace_portion
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"U|O:zipimporter.find_module"
,
if
(
!
PyArg_ParseTuple
(
args
,
"U|O:zipimporter.find_module"
,
&
fullname
,
&
path
))
&
fullname
,
&
path
))
return
NULL
;
goto
error
;
switch
(
find_loader
(
self
,
fullname
,
&
namespace_portion
))
{
switch
(
find_loader
(
self
,
fullname
,
&
namespace_portion
))
{
case
-
1
:
/* Error */
case
fl_error
:
goto
error
;
return
NULL
;
case
0
:
/* Not found, return (None, []) */
case
fl_not_found
:
/* Not found, return (None, []) */
if
(
!
(
result
=
Py_BuildValue
(
"O[]"
,
Py_None
)))
result
=
Py_BuildValue
(
"O[]"
,
Py_None
);
goto
error
;
break
;
return
result
;
case
fl_module_found
:
/* Return (self, []) */
case
1
:
/* Return (self, []) */
result
=
Py_BuildValue
(
"O[]"
,
self
);
if
(
!
(
result
=
Py_BuildValue
(
"O[]"
,
self
)))
break
;
goto
error
;
case
fl_ns_found
:
/* Return (None, [namespace_portion]) */
return
result
;
result
=
Py_BuildValue
(
"O[O]"
,
Py_None
,
namespace_portion
);
case
2
:
/* Return (None, [namespace_portion]) */
if
(
!
(
result
=
Py_BuildValue
(
"O[O]"
,
Py_None
,
namespace_portion
)))
goto
error
;
Py_DECREF
(
namespace_portion
);
Py_DECREF
(
namespace_portion
);
return
result
;
return
result
;
}
}
/* Can't get here. */
return
result
;
assert
(
0
);
return
NULL
;
error:
Py_XDECREF
(
namespace_portion
);
Py_XDECREF
(
result
);
return
NULL
;
}
}
/* Load and return the module named by 'fullname'. */
/* Load and return the module named by 'fullname'. */
...
...
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