Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
965a8a1c
Commit
965a8a1c
authored
Oct 18, 2010
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert r85699 and r85701 (zipimport): fullname is a module name, not a path
UTF-8 is just fine for module names.
parent
8c8ed0a7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
42 deletions
+18
-42
Modules/zipimport.c
Modules/zipimport.c
+18
-42
No files found.
Modules/zipimport.c
View file @
965a8a1c
...
...
@@ -255,13 +255,13 @@ enum zi_module_info {
/* Return some information about a module. */
static
enum
zi_module_info
get_module_info
(
ZipImporter
*
self
,
PyObject
*
fullname
)
get_module_info
(
ZipImporter
*
self
,
char
*
fullname
)
{
char
*
subname
,
path
[
MAXPATHLEN
+
1
];
int
len
;
struct
st_zip_searchorder
*
zso
;
subname
=
get_subname
(
PyBytes_AS_STRING
(
fullname
)
);
subname
=
get_subname
(
fullname
);
len
=
make_filename
(
self
->
prefix
,
subname
,
path
,
sizeof
(
path
));
if
(
len
<
0
)
...
...
@@ -286,15 +286,14 @@ zipimporter_find_module(PyObject *obj, PyObject *args)
{
ZipImporter
*
self
=
(
ZipImporter
*
)
obj
;
PyObject
*
path
=
NULL
;
PyObject
*
fullname
;
char
*
fullname
;
enum
zi_module_info
mi
;
if
(
!
PyArg_ParseTuple
(
args
,
"
O&
|O:zipimporter.find_module"
,
PyUnicode_FSConverter
,
&
fullname
,
&
path
))
if
(
!
PyArg_ParseTuple
(
args
,
"
s
|O:zipimporter.find_module"
,
&
fullname
,
&
path
))
return
NULL
;
mi
=
get_module_info
(
self
,
fullname
);
Py_DECREF
(
fullname
);
if
(
mi
==
MI_ERROR
)
return
NULL
;
if
(
mi
==
MI_NOT_FOUND
)
{
...
...
@@ -399,45 +398,27 @@ zipimporter_get_filename(PyObject *obj, PyObject *args)
return
modpath
;
}
static
void
cant_find_module
(
PyObject
*
bytes
)
{
PyObject
*
unicode
=
PyUnicode_DecodeFSDefaultAndSize
(
PyBytes_AS_STRING
(
bytes
),
PyBytes_GET_SIZE
(
bytes
));
if
(
unicode
!=
NULL
)
{
PyErr_Format
(
ZipImportError
,
"can't find module %U"
,
unicode
);
Py_DECREF
(
unicode
);
}
else
PyErr_Format
(
ZipImportError
,
"can't find module"
);
}
/* Return a bool signifying whether the module is a package or not. */
static
PyObject
*
zipimporter_is_package
(
PyObject
*
obj
,
PyObject
*
args
)
{
ZipImporter
*
self
=
(
ZipImporter
*
)
obj
;
PyObject
*
fullname
;
char
*
fullname
;
enum
zi_module_info
mi
;
if
(
!
PyArg_ParseTuple
(
args
,
"
O&
:zipimporter.is_package"
,
PyUnicode_FSConverter
,
&
fullname
))
if
(
!
PyArg_ParseTuple
(
args
,
"
s
:zipimporter.is_package"
,
&
fullname
))
return
NULL
;
mi
=
get_module_info
(
self
,
fullname
);
if
(
mi
==
MI_ERROR
)
goto
error
;
return
NULL
;
if
(
mi
==
MI_NOT_FOUND
)
{
cant_find_module
(
fullname
);
goto
error
;
PyErr_Format
(
ZipImportError
,
"can't find module '%.200s'"
,
fullname
);
return
NULL
;
}
Py_DECREF
(
fullname
);
return
PyBool_FromLong
(
mi
==
MI_PACKAGE
);
error:
Py_DECREF
(
fullname
);
return
NULL
;
}
static
PyObject
*
...
...
@@ -509,29 +490,24 @@ zipimporter_get_source(PyObject *obj, PyObject *args)
{
ZipImporter
*
self
=
(
ZipImporter
*
)
obj
;
PyObject
*
toc_entry
;
PyObject
*
fullname
;
char
*
subname
,
path
[
MAXPATHLEN
+
1
];
char
*
fullname
,
*
subname
,
path
[
MAXPATHLEN
+
1
];
int
len
;
enum
zi_module_info
mi
;
if
(
!
PyArg_ParseTuple
(
args
,
"O&:zipimporter.get_source"
,
PyUnicode_FSConverter
,
&
fullname
))
if
(
!
PyArg_ParseTuple
(
args
,
"s:zipimporter.get_source"
,
&
fullname
))
return
NULL
;
mi
=
get_module_info
(
self
,
fullname
);
if
(
mi
==
MI_ERROR
)
{
Py_DECREF
(
fullname
);
if
(
mi
==
MI_ERROR
)
return
NULL
;
}
if
(
mi
==
MI_NOT_FOUND
)
{
cant_find_module
(
fullname
);
Py_DECREF
(
fullname
);
PyErr_Format
(
ZipImportError
,
"can't find module '%.200s'"
,
fullname
);
return
NULL
;
}
subname
=
get_subname
(
PyBytes_AS_STRING
(
fullname
)
);
subname
=
get_subname
(
fullname
);
len
=
make_filename
(
self
->
prefix
,
subname
,
path
,
sizeof
(
path
));
Py_DECREF
(
fullname
);
if
(
len
<
0
)
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