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
7b07a41e
Commit
7b07a41e
authored
Sep 11, 2001
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The endless 460020 bug.
Disable t[:], t*0, t*1 optimizations when t is of a tuple subclass type.
parent
f0b0f680
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
Lib/test/test_descr.py
Lib/test/test_descr.py
+9
-0
Objects/tupleobject.c
Objects/tupleobject.c
+9
-6
No files found.
Lib/test/test_descr.py
View file @
7b07a41e
...
...
@@ -1417,9 +1417,18 @@ def inherits():
a
=
madtuple
((
1
,
2
,
3
,
4
,
5
))
verify
(
tuple
(
a
)
==
(
1
,
2
,
3
,
4
,
5
))
verify
(
tuple
(
a
).
__class__
is
tuple
)
verify
(
a
[:].
__class__
is
tuple
)
verify
((
a
*
1
).
__class__
is
tuple
)
verify
((
a
*
0
).
__class__
is
tuple
)
verify
((
a
+
()).
__class__
is
tuple
)
a
=
madtuple
(())
verify
(
tuple
(
a
)
==
())
verify
(
tuple
(
a
).
__class__
is
tuple
)
verify
((
a
+
a
).
__class__
is
tuple
)
verify
((
a
*
0
).
__class__
is
tuple
)
verify
((
a
*
1
).
__class__
is
tuple
)
verify
((
a
*
2
).
__class__
is
tuple
)
verify
(
a
[:].
__class__
is
tuple
)
class
madstring
(
str
):
_rev
=
None
...
...
Objects/tupleobject.c
View file @
7b07a41e
...
...
@@ -298,8 +298,7 @@ tupleslice(register PyTupleObject *a, register int ilow, register int ihigh)
ihigh
=
a
->
ob_size
;
if
(
ihigh
<
ilow
)
ihigh
=
ilow
;
if
(
ilow
==
0
&&
ihigh
==
a
->
ob_size
)
{
/* XXX can only do this if tuples are immutable! */
if
(
ilow
==
0
&&
ihigh
==
a
->
ob_size
&&
PyTuple_CheckExact
(
a
))
{
Py_INCREF
(
a
);
return
(
PyObject
*
)
a
;
}
...
...
@@ -366,10 +365,14 @@ tuplerepeat(PyTupleObject *a, int n)
if
(
n
<
0
)
n
=
0
;
if
(
a
->
ob_size
==
0
||
n
==
1
)
{
/* Since tuples are immutable, we can return a shared
copy in this case */
Py_INCREF
(
a
);
return
(
PyObject
*
)
a
;
if
(
PyTuple_CheckExact
(
a
))
{
/* Since tuples are immutable, we can return a shared
copy in this case */
Py_INCREF
(
a
);
return
(
PyObject
*
)
a
;
}
if
(
a
->
ob_size
==
0
)
return
PyTuple_New
(
0
);
}
size
=
a
->
ob_size
*
n
;
if
(
size
/
a
->
ob_size
!=
n
)
...
...
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