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
44c6c155
Commit
44c6c155
authored
Aug 09, 2010
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #9425: Create load_builtin() subfunction
Just move the code and some variables.
parent
e43f9d0e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
30 deletions
+40
-30
Python/import.c
Python/import.c
+40
-30
No files found.
Python/import.c
View file @
44c6c155
...
...
@@ -2013,15 +2013,52 @@ find_init_module(char *buf)
static
int
init_builtin
(
char
*
);
/* Forward */
static
PyObject
*
load_builtin
(
char
*
name
,
char
*
pathname
,
int
type
)
{
PyObject
*
m
,
*
modules
;
int
err
;
if
(
pathname
!=
NULL
&&
pathname
[
0
]
!=
'\0'
)
name
=
pathname
;
if
(
type
==
C_BUILTIN
)
err
=
init_builtin
(
name
);
else
err
=
PyImport_ImportFrozenModule
(
name
);
if
(
err
<
0
)
return
NULL
;
if
(
err
==
0
)
{
PyErr_Format
(
PyExc_ImportError
,
"Purported %s module %.200s not found"
,
type
==
C_BUILTIN
?
"builtin"
:
"frozen"
,
name
);
return
NULL
;
}
modules
=
PyImport_GetModuleDict
();
m
=
PyDict_GetItemString
(
modules
,
name
);
if
(
m
==
NULL
)
{
PyErr_Format
(
PyExc_ImportError
,
"%s module %.200s not properly initialized"
,
type
==
C_BUILTIN
?
"builtin"
:
"frozen"
,
name
);
return
NULL
;
}
Py_INCREF
(
m
);
return
m
;
}
/* Load an external module using the default search path and return
its module object WITH INCREMENTED REFERENCE COUNT */
static
PyObject
*
load_module
(
char
*
name
,
FILE
*
fp
,
char
*
pathname
,
int
type
,
PyObject
*
loader
)
{
PyObject
*
modules
;
PyObject
*
m
;
int
err
;
/* First check that there's an open file (if we need one) */
switch
(
type
)
{
...
...
@@ -2057,34 +2094,7 @@ load_module(char *name, FILE *fp, char *pathname, int type, PyObject *loader)
case
C_BUILTIN
:
case
PY_FROZEN
:
if
(
pathname
!=
NULL
&&
pathname
[
0
]
!=
'\0'
)
name
=
pathname
;
if
(
type
==
C_BUILTIN
)
err
=
init_builtin
(
name
);
else
err
=
PyImport_ImportFrozenModule
(
name
);
if
(
err
<
0
)
return
NULL
;
if
(
err
==
0
)
{
PyErr_Format
(
PyExc_ImportError
,
"Purported %s module %.200s not found"
,
type
==
C_BUILTIN
?
"builtin"
:
"frozen"
,
name
);
return
NULL
;
}
modules
=
PyImport_GetModuleDict
();
m
=
PyDict_GetItemString
(
modules
,
name
);
if
(
m
==
NULL
)
{
PyErr_Format
(
PyExc_ImportError
,
"%s module %.200s not properly initialized"
,
type
==
C_BUILTIN
?
"builtin"
:
"frozen"
,
name
);
return
NULL
;
}
Py_INCREF
(
m
);
m
=
load_builtin
(
name
,
pathname
,
type
);
break
;
case
IMP_HOOK
:
{
...
...
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