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
62b1b001
Commit
62b1b001
authored
Mar 06, 2007
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #1654417: make operator.{get,set,del}slice use the full range
of Py_ssize_t. (backport from rev. 54177)
parent
2230d980
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
13 deletions
+20
-13
Lib/test/test_operator.py
Lib/test/test_operator.py
+6
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/operator.c
Modules/operator.c
+11
-13
No files found.
Lib/test/test_operator.py
View file @
62b1b001
...
@@ -143,6 +143,8 @@ class OperatorTestCase(unittest.TestCase):
...
@@ -143,6 +143,8 @@ class OperatorTestCase(unittest.TestCase):
self
.
failUnlessRaises
(
TypeError
,
operator
.
delslice
,
a
,
None
,
None
)
self
.
failUnlessRaises
(
TypeError
,
operator
.
delslice
,
a
,
None
,
None
)
self
.
failUnless
(
operator
.
delslice
(
a
,
2
,
8
)
is
None
)
self
.
failUnless
(
operator
.
delslice
(
a
,
2
,
8
)
is
None
)
self
.
assert_
(
a
==
[
0
,
1
,
8
,
9
])
self
.
assert_
(
a
==
[
0
,
1
,
8
,
9
])
operator
.
delslice
(
a
,
0
,
test_support
.
MAX_Py_ssize_t
)
self
.
assert_
(
a
==
[])
def
test_div
(
self
):
def
test_div
(
self
):
self
.
failUnlessRaises
(
TypeError
,
operator
.
div
,
5
)
self
.
failUnlessRaises
(
TypeError
,
operator
.
div
,
5
)
...
@@ -170,6 +172,8 @@ class OperatorTestCase(unittest.TestCase):
...
@@ -170,6 +172,8 @@ class OperatorTestCase(unittest.TestCase):
self
.
failUnlessRaises
(
TypeError
,
operator
.
getslice
)
self
.
failUnlessRaises
(
TypeError
,
operator
.
getslice
)
self
.
failUnlessRaises
(
TypeError
,
operator
.
getslice
,
a
,
None
,
None
)
self
.
failUnlessRaises
(
TypeError
,
operator
.
getslice
,
a
,
None
,
None
)
self
.
failUnless
(
operator
.
getslice
(
a
,
4
,
6
)
==
[
4
,
5
])
self
.
failUnless
(
operator
.
getslice
(
a
,
4
,
6
)
==
[
4
,
5
])
b
=
operator
.
getslice
(
a
,
0
,
test_support
.
MAX_Py_ssize_t
)
self
.
assert_
(
b
==
a
)
def
test_indexOf
(
self
):
def
test_indexOf
(
self
):
self
.
failUnlessRaises
(
TypeError
,
operator
.
indexOf
)
self
.
failUnlessRaises
(
TypeError
,
operator
.
indexOf
)
...
@@ -318,6 +322,8 @@ class OperatorTestCase(unittest.TestCase):
...
@@ -318,6 +322,8 @@ class OperatorTestCase(unittest.TestCase):
self
.
failUnlessRaises
(
TypeError
,
operator
.
setslice
,
a
,
None
,
None
,
None
)
self
.
failUnlessRaises
(
TypeError
,
operator
.
setslice
,
a
,
None
,
None
,
None
)
self
.
failUnless
(
operator
.
setslice
(
a
,
1
,
3
,
[
2
,
1
])
is
None
)
self
.
failUnless
(
operator
.
setslice
(
a
,
1
,
3
,
[
2
,
1
])
is
None
)
self
.
assert_
(
a
==
[
0
,
2
,
1
,
3
])
self
.
assert_
(
a
==
[
0
,
2
,
1
,
3
])
operator
.
setslice
(
a
,
0
,
test_support
.
MAX_Py_ssize_t
,
[])
self
.
assert_
(
a
==
[])
def
test_sub
(
self
):
def
test_sub
(
self
):
self
.
failUnlessRaises
(
TypeError
,
operator
.
sub
)
self
.
failUnlessRaises
(
TypeError
,
operator
.
sub
)
...
...
Misc/NEWS
View file @
62b1b001
...
@@ -120,6 +120,9 @@ Core and builtins
...
@@ -120,6 +120,9 @@ Core and builtins
Extension Modules
Extension Modules
-----------------
-----------------
- Patch #1654417: make operator.{get,set,del}slice use the full range
of Py_ssize_t.
- Patch #1646728: datetime.fromtimestamp fails with negative
- Patch #1646728: datetime.fromtimestamp fails with negative
fractional times. With unittest.
fractional times. With unittest.
...
...
Modules/operator.c
View file @
62b1b001
...
@@ -168,43 +168,41 @@ static PyObject*
...
@@ -168,43 +168,41 @@ static PyObject*
op_getslice
(
PyObject
*
s
,
PyObject
*
a
)
op_getslice
(
PyObject
*
s
,
PyObject
*
a
)
{
{
PyObject
*
a1
;
PyObject
*
a1
;
int
a2
,
a3
;
Py_ssize_t
a2
,
a3
;
if
(
!
PyArg_ParseTuple
(
a
,
"Oii:getslice"
,
&
a1
,
&
a2
,
&
a3
))
if
(
!
PyArg_ParseTuple
(
a
,
"Onn:getslice"
,
&
a1
,
&
a2
,
&
a3
))
return
NULL
;
return
NULL
;
return
PySequence_GetSlice
(
a1
,
a2
,
a3
);
return
PySequence_GetSlice
(
a1
,
a2
,
a3
);
}
}
static
PyObject
*
static
PyObject
*
op_setslice
(
PyObject
*
s
,
PyObject
*
a
)
op_setslice
(
PyObject
*
s
,
PyObject
*
a
)
{
{
PyObject
*
a1
,
*
a4
;
PyObject
*
a1
,
*
a4
;
int
a2
,
a3
;
Py_ssize_t
a2
,
a3
;
if
(
!
PyArg_ParseTuple
(
a
,
"OiiO:setslice"
,
&
a1
,
&
a2
,
&
a3
,
&
a4
))
if
(
!
PyArg_ParseTuple
(
a
,
"OnnO:setslice"
,
&
a1
,
&
a2
,
&
a3
,
&
a4
))
return
NULL
;
return
NULL
;
if
(
-
1
==
PySequence_SetSlice
(
a1
,
a2
,
a3
,
a4
))
if
(
-
1
==
PySequence_SetSlice
(
a1
,
a2
,
a3
,
a4
))
return
NULL
;
return
NULL
;
Py_INCREF
(
Py_None
);
Py_RETURN_NONE
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
op_delslice
(
PyObject
*
s
,
PyObject
*
a
)
op_delslice
(
PyObject
*
s
,
PyObject
*
a
)
{
{
PyObject
*
a1
;
PyObject
*
a1
;
int
a2
,
a3
;
Py_ssize_t
a2
,
a3
;
if
(
!
PyArg_ParseTuple
(
a
,
"Oii:delslice"
,
&
a1
,
&
a2
,
&
a3
))
if
(
!
PyArg_ParseTuple
(
a
,
"Onn:delslice"
,
&
a1
,
&
a2
,
&
a3
))
return
NULL
;
return
NULL
;
if
(
-
1
==
PySequence_DelSlice
(
a1
,
a2
,
a3
))
if
(
-
1
==
PySequence_DelSlice
(
a1
,
a2
,
a3
))
return
NULL
;
return
NULL
;
Py_INCREF
(
Py_None
);
Py_RETURN_NONE
;
return
Py_None
;
}
}
#undef spam1
#undef spam1
...
...
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