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
850e516e
Commit
850e516e
authored
May 20, 2007
by
Walter Dörwald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change range_repr() to use %R for the start/stop/step attributes.
parent
7569dfe1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
30 deletions
+6
-30
Objects/rangeobject.c
Objects/rangeobject.c
+6
-30
No files found.
Objects/rangeobject.c
View file @
850e516e
...
@@ -234,52 +234,28 @@ range_item(rangeobject *r, Py_ssize_t i)
...
@@ -234,52 +234,28 @@ range_item(rangeobject *r, Py_ssize_t i)
static
PyObject
*
static
PyObject
*
range_repr
(
rangeobject
*
r
)
range_repr
(
rangeobject
*
r
)
{
{
PyObject
*
start_str
=
NULL
,
*
stop_str
=
NULL
,
*
step_str
=
NULL
;
PyObject
*
result
=
NULL
;
Py_ssize_t
istart
,
istep
;
Py_ssize_t
istart
,
istep
;
/* We always need the stop value. */
stop_str
=
PyObject_Str
(
r
->
stop
);
if
(
!
stop_str
)
return
NULL
;
/* XXX(nnorwitz): should we use PyObject_Repr instead of str? */
/* Check for special case values for printing. We don't always
/* Check for special case values for printing. We don't always
need the start or step values. We don't care about errors
need the start or step values. We don't care about errors
(it means overflow), so clear the errors. */
(it means overflow), so clear the errors. */
istart
=
PyNumber_AsSsize_t
(
r
->
start
,
NULL
);
istart
=
PyNumber_AsSsize_t
(
r
->
start
,
NULL
);
if
(
istart
!=
0
||
(
istart
==
-
1
&&
PyErr_Occurred
()))
{
if
(
istart
!=
0
||
(
istart
==
-
1
&&
PyErr_Occurred
()))
{
PyErr_Clear
();
PyErr_Clear
();
start_str
=
PyObject_Str
(
r
->
start
);
}
}
istep
=
PyNumber_AsSsize_t
(
r
->
step
,
NULL
);
istep
=
PyNumber_AsSsize_t
(
r
->
step
,
NULL
);
if
(
istep
!=
1
||
(
istep
==
-
1
&&
PyErr_Occurred
()))
{
if
(
istep
!=
1
||
(
istep
==
-
1
&&
PyErr_Occurred
()))
{
PyErr_Clear
();
PyErr_Clear
();
step_str
=
PyObject_Str
(
r
->
step
);
}
}
if
(
istart
==
0
&&
istep
==
1
)
if
(
istart
==
0
&&
istep
==
1
)
result
=
PyUnicode_FromFormat
(
"range(%s)"
,
return
PyUnicode_FromFormat
(
"range(%R)"
,
r
->
stop
);
PyString_AS_STRING
(
stop_str
));
else
if
(
istep
==
1
)
else
if
(
istep
==
1
)
{
return
PyUnicode_FromFormat
(
"range(%R, %R)"
,
r
->
start
,
r
->
stop
);
if
(
start_str
)
else
result
=
PyUnicode_FromFormat
(
"range(%s, %s)"
,
return
PyUnicode_FromFormat
(
"range(%R, %R, %R)"
,
PyString_AS_STRING
(
start_str
),
r
->
start
,
r
->
stop
,
r
->
step
);
PyString_AS_STRING
(
stop_str
));
}
else
if
(
start_str
&&
step_str
)
result
=
PyUnicode_FromFormat
(
"range(%s, %s, %s)"
,
PyString_AS_STRING
(
start_str
),
PyString_AS_STRING
(
stop_str
),
PyString_AS_STRING
(
step_str
));
/* else result is NULL and an error should already be set. */
Py_XDECREF
(
start_str
);
Py_XDECREF
(
stop_str
);
Py_XDECREF
(
step_str
);
return
result
;
}
}
static
PySequenceMethods
range_as_sequence
=
{
static
PySequenceMethods
range_as_sequence
=
{
...
...
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