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
24c13743
Commit
24c13743
authored
Feb 14, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
call __import__() with 4 args instead of 1
parent
becdbec8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
2 deletions
+56
-2
Python/bltinmodule.c
Python/bltinmodule.c
+5
-1
Python/ceval.c
Python/ceval.c
+51
-1
No files found.
Python/bltinmodule.c
View file @
24c13743
...
...
@@ -47,8 +47,12 @@ builtin___import__(self, args)
object
*
args
;
{
char
*
name
;
object
*
globals
=
NULL
;
object
*
locals
=
NULL
;
object
*
fromlist
=
NULL
;
if
(
!
newgetargs
(
args
,
"s:__import__"
,
&
name
))
if
(
!
newgetargs
(
args
,
"s|OOO:__import__"
,
&
name
,
&
globals
,
&
locals
,
&
fromlist
))
return
NULL
;
return
import_module
(
name
);
}
...
...
Python/ceval.c
View file @
24c13743
...
...
@@ -93,6 +93,7 @@ static int import_from PROTO((object *, object *, object *));
static
object
*
build_class
PROTO
((
object
*
,
object
*
,
object
*
));
static
int
access_statement
PROTO
((
object
*
,
object
*
,
frameobject
*
));
static
int
exec_statement
PROTO
((
object
*
,
object
*
,
object
*
));
static
object
*
find_from_args
PROTO
((
frameobject
*
,
int
));
/* Pointer to current frame, used to link new frames to */
...
...
@@ -1338,7 +1339,19 @@ eval_code(co, globals, locals, owner, arg)
"__import__ not found"
);
break
;
}
w
=
mkvalue
(
"(O)"
,
w
);
if
(
is_methodobject
(
x
))
{
u
=
None
;
INCREF
(
u
);
}
else
{
u
=
find_from_args
(
f
,
INSTR_OFFSET
());
if
(
u
==
NULL
)
{
x
=
u
;
break
;
}
}
w
=
mkvalue
(
"(OOOO)"
,
w
,
f
->
f_globals
,
f
->
f_locals
,
u
);
DECREF
(
u
);
if
(
w
==
NULL
)
{
x
=
NULL
;
break
;
...
...
@@ -1352,6 +1365,7 @@ eval_code(co, globals, locals, owner, arg)
case
IMPORT_FROM
:
w
=
GETNAMEV
(
oparg
);
v
=
TOP
();
fast_2_locals
(
f
);
err
=
import_from
(
f
->
f_locals
,
v
,
w
);
locals_2_fast
(
f
,
0
);
break
;
...
...
@@ -2711,3 +2725,39 @@ exec_statement(prog, globals, locals)
DECREF
(
v
);
return
0
;
}
/* Hack for Ken Manheimer */
static
object
*
find_from_args
(
f
,
nexti
)
frameobject
*
f
;
int
nexti
;
{
int
opcode
;
int
oparg
;
object
*
list
,
*
name
;
unsigned
char
*
next_instr
;
next_instr
=
GETUSTRINGVALUE
(
f
->
f_code
->
co_code
)
+
nexti
;
opcode
=
(
*
next_instr
++
);
if
(
opcode
!=
IMPORT_FROM
)
{
printf
(
"next opcode: %d
\n
"
,
opcode
);
INCREF
(
None
);
return
None
;
}
list
=
newlistobject
(
0
);
if
(
list
==
NULL
)
return
NULL
;
do
{
oparg
=
(
next_instr
+=
2
,
(
next_instr
[
-
1
]
<<
8
)
+
next_instr
[
-
2
]);
name
=
Getnamev
(
f
,
oparg
);
if
(
addlistitem
(
list
,
name
)
<
0
)
{
DECREF
(
list
);
break
;
}
opcode
=
(
*
next_instr
++
);
}
while
(
opcode
==
IMPORT_FROM
);
return
list
;
}
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