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
98256aa5
Commit
98256aa5
authored
Dec 24, 1991
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Negative subscript are now allowed as in slices.
Added ImportError.
parent
ed7711b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
Python/ceval.c
Python/ceval.c
+14
-7
No files found.
Python/ceval.c
View file @
98256aa5
...
...
@@ -1511,6 +1511,8 @@ apply_subscript(v, w)
return
NULL
;
}
i
=
getintvalue
(
w
);
if
(
i
<
0
)
i
+=
(
*
tp
->
tp_as_sequence
->
sq_length
)(
v
);
return
(
*
tp
->
tp_as_sequence
->
sq_item
)(
v
,
i
);
}
return
(
*
tp
->
tp_as_mapping
->
mp_subscript
)(
v
,
w
);
...
...
@@ -1584,11 +1586,15 @@ assign_subscript(w, key, v) /* w[key] = v */
(
func
=
sq
->
sq_ass_item
)
!=
NULL
)
{
if
(
!
is_intobject
(
key
))
{
err_setstr
(
TypeError
,
"sequence subscript must be integer
"
);
"sequence subscript must be integer (assign or del)
"
);
return
-
1
;
}
else
return
(
*
func
)(
w
,
(
int
)
getintvalue
(
key
),
v
);
else
{
int
i
=
getintvalue
(
key
);
if
(
i
<
0
)
i
+=
(
*
sq
->
sq_length
)(
v
);
return
(
*
func
)(
w
,
i
,
v
);
}
}
else
if
((
mp
=
tp
->
tp_as_mapping
)
!=
NULL
&&
(
func
=
mp
->
mp_ass_subscript
)
!=
NULL
)
{
...
...
@@ -1726,8 +1732,6 @@ cmp_outcome(op, v, w)
return
v
;
}
/* XXX This function should use dict2 variants (change interface!) */
static
int
import_from
(
locals
,
v
,
name
)
object
*
locals
;
...
...
@@ -1746,7 +1750,7 @@ import_from(locals, v, name)
x
=
dict2lookup
(
w
,
name
);
if
(
x
==
NULL
)
{
/* XXX can't happen? */
err_setstr
(
Name
Error
,
getstringvalue
(
name
));
err_setstr
(
System
Error
,
getstringvalue
(
name
));
return
-
1
;
}
if
(
dict2insert
(
locals
,
name
,
x
)
!=
0
)
...
...
@@ -1757,7 +1761,10 @@ import_from(locals, v, name)
else
{
x
=
dict2lookup
(
w
,
name
);
if
(
x
==
NULL
)
{
err_setstr
(
NameError
,
getstringvalue
(
name
));
char
buf
[
250
];
sprintf
(
buf
,
"cannot import name %s"
,
getstringvalue
(
name
));
err_setstr
(
ImportError
,
buf
);
return
-
1
;
}
else
...
...
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