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
6ec1efb6
Commit
6ec1efb6
authored
Aug 04, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add imp.get_frozen_object()
parent
b7b45627
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
13 deletions
+54
-13
Python/import.c
Python/import.c
+54
-13
No files found.
Python/import.c
View file @
6ec1efb6
...
...
@@ -411,13 +411,13 @@ find_module(name, path, buf, buflen, p_fp)
{
int
i
,
npath
,
len
,
namelen
;
struct
filedescr
*
fdp
;
FILE
*
fp
;
FILE
*
fp
=
NULL
;
if
(
path
==
NULL
)
path
=
sysget
(
"path"
);
if
(
path
==
NULL
||
!
is_listobject
(
path
))
{
err_setstr
(
ImportError
,
"module search path must be
list of directory names"
);
"sys.path must be a
list of directory names"
);
return
NULL
;
}
npath
=
getlistsize
(
path
);
...
...
@@ -528,7 +528,7 @@ init_builtin(name)
if
(
strcmp
(
name
,
inittab
[
i
].
name
)
==
0
)
{
if
(
inittab
[
i
].
initfunc
==
NULL
)
{
err_setstr
(
ImportError
,
"
c
annot re-init internal module"
);
"
C
annot re-init internal module"
);
return
-
1
;
}
if
(
verbose
)
...
...
@@ -544,9 +544,7 @@ init_builtin(name)
}
/* Initialize a frozen module.
Return 1 for succes, 0 if the module is not found, and -1 with
an exception set if the initialization failed. */
/* Frozen modules */
extern
struct
frozen
{
char
*
name
;
...
...
@@ -554,21 +552,50 @@ extern struct frozen {
int
size
;
}
frozen_modules
[];
/* This function is also used from frozenmain.c */
int
init_frozen
(
name
)
static
struct
frozen
*
find_frozen
(
name
)
char
*
name
;
{
struct
frozen
*
p
;
object
*
co
;
object
*
m
;
for
(
p
=
frozen_modules
;
;
p
++
)
{
if
(
p
->
name
==
NULL
)
return
0
;
return
NULL
;
if
(
strcmp
(
p
->
name
,
name
)
==
0
)
break
;
}
return
p
;
}
static
object
*
get_frozen_object
(
name
)
char
*
name
;
{
struct
frozen
*
p
=
find_frozen
(
name
);
if
(
p
==
NULL
)
{
err_setstr
(
ImportError
,
"No such frozen object"
);
return
NULL
;
}
return
rds_object
(
p
->
code
,
p
->
size
);
}
/* Initialize a frozen module.
Return 1 for succes, 0 if the module is not found, and -1 with
an exception set if the initialization failed.
This function is also used from frozenmain.c */
int
init_frozen
(
name
)
char
*
name
;
{
struct
frozen
*
p
=
find_frozen
(
name
);
object
*
co
;
object
*
m
;
if
(
p
==
NULL
)
return
0
;
if
(
verbose
)
fprintf
(
stderr
,
"import %s # frozen
\n
"
,
name
);
co
=
rds_object
(
p
->
code
,
p
->
size
);
...
...
@@ -576,7 +603,7 @@ init_frozen(name)
return
-
1
;
if
(
!
is_codeobject
(
co
))
{
DECREF
(
co
);
err_setstr
(
System
Error
,
"frozen object is not a code object"
);
err_setstr
(
Type
Error
,
"frozen object is not a code object"
);
return
-
1
;
}
m
=
exec_code_module
(
name
,
co
);
...
...
@@ -785,6 +812,19 @@ imp_init_frozen(self, args)
return
m
;
}
static
object
*
imp_get_frozen_object
(
self
,
args
)
object
*
self
;
object
*
args
;
{
char
*
name
;
int
ret
;
object
*
m
;
if
(
!
newgetargs
(
args
,
"s"
,
&
name
))
return
NULL
;
return
get_frozen_object
(
name
);
}
static
object
*
imp_is_builtin
(
self
,
args
)
object
*
self
;
...
...
@@ -928,6 +968,7 @@ imp_new_module(self, args)
}
static
struct
methodlist
imp_methods
[]
=
{
{
"get_frozen_object"
,
imp_get_frozen_object
,
1
},
{
"get_magic"
,
imp_get_magic
,
1
},
{
"get_suffixes"
,
imp_get_suffixes
,
1
},
{
"find_module"
,
imp_find_module
,
1
},
...
...
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