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
4116f369
Commit
4116f369
authored
May 27, 2008
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up some docstrings and errors in bytesobject.c
parent
74c71f5a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
21 deletions
+18
-21
Objects/bytesobject.c
Objects/bytesobject.c
+18
-21
No files found.
Objects/bytesobject.c
View file @
4116f369
/* String object implementation */
/* XXX This is now called 'bytes' as far as the user is concerned.
Many docstrings and error messages need to be cleaned up. */
/* bytes object implementation */
#define PY_SSIZE_T_CLEAN
...
...
@@ -116,7 +113,7 @@ PyBytes_FromString(const char *str)
size
=
strlen
(
str
);
if
(
size
>
PY_SSIZE_T_MAX
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"
string is too long for a Python stri
ng"
);
"
byte string is too lo
ng"
);
return
NULL
;
}
if
(
size
==
0
&&
(
op
=
nullstring
)
!=
NULL
)
{
...
...
@@ -735,7 +732,7 @@ string_repeat(register PyBytesObject *a, register Py_ssize_t n)
size
=
Py_SIZE
(
a
)
*
n
;
if
(
n
&&
size
/
n
!=
Py_SIZE
(
a
))
{
PyErr_SetString
(
PyExc_OverflowError
,
"repeated
string is
too long"
);
"repeated
bytes are
too long"
);
return
NULL
;
}
if
(
size
==
Py_SIZE
(
a
)
&&
PyBytes_CheckExact
(
a
))
{
...
...
@@ -745,7 +742,7 @@ string_repeat(register PyBytesObject *a, register Py_ssize_t n)
nbytes
=
(
size_t
)
size
;
if
(
nbytes
+
sizeof
(
PyBytesObject
)
<=
nbytes
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"repeated
string is
too long"
);
"repeated
bytes are
too long"
);
return
NULL
;
}
op
=
(
PyBytesObject
*
)
...
...
@@ -799,7 +796,7 @@ static PyObject *
string_item
(
PyBytesObject
*
a
,
register
Py_ssize_t
i
)
{
if
(
i
<
0
||
i
>=
Py_SIZE
(
a
))
{
PyErr_SetString
(
PyExc_IndexError
,
"
string
index out of range"
);
PyErr_SetString
(
PyExc_IndexError
,
"index out of range"
);
return
NULL
;
}
return
PyLong_FromLong
((
unsigned
char
)
a
->
ob_sval
[
i
]);
...
...
@@ -908,7 +905,7 @@ string_subscript(PyBytesObject* self, PyObject* item)
i
+=
PyBytes_GET_SIZE
(
self
);
if
(
i
<
0
||
i
>=
PyBytes_GET_SIZE
(
self
))
{
PyErr_SetString
(
PyExc_IndexError
,
"
string
index out of range"
);
"index out of range"
);
return
NULL
;
}
return
PyLong_FromLong
((
unsigned
char
)
self
->
ob_sval
[
i
]);
...
...
@@ -958,7 +955,7 @@ string_subscript(PyBytesObject* self, PyObject* item)
}
else
{
PyErr_Format
(
PyExc_TypeError
,
"
string
indices must be integers, not %.200s"
,
"
byte
indices must be integers, not %.200s"
,
Py_TYPE
(
item
)
->
tp_name
);
return
NULL
;
}
...
...
@@ -1348,7 +1345,7 @@ rsplit_char(PyBytesObject *self, Py_ssize_t len, char ch, Py_ssize_t maxcount)
}
PyDoc_STRVAR
(
rsplit__doc__
,
"B.rsplit([sep[, maxsplit]]) -> list of
string
s
\n
\
"B.rsplit([sep[, maxsplit]]) -> list of
byte
s
\n
\
\n
\
Return a list of the sections in B, using sep as the delimiter,
\n
\
starting at the end of B and working to the front.
\n
\
...
...
@@ -1482,7 +1479,7 @@ string_join(PyObject *self, PyObject *orig)
sz
+=
seplen
;
if
(
sz
<
old_sz
||
sz
>
PY_SSIZE_T_MAX
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"join() result is too long for
a Python string
"
);
"join() result is too long for
bytes
"
);
Py_DECREF
(
seq
);
return
NULL
;
}
...
...
@@ -2091,13 +2088,13 @@ replace_interleave(PyBytesObject *self,
product
=
count
*
to_len
;
if
(
product
/
to_len
!=
count
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"replace
string is
too long"
);
"replace
ment bytes are
too long"
);
return
NULL
;
}
result_len
=
product
+
self_len
;
if
(
result_len
<
0
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"replace
string is
too long"
);
"replace
ment bytes are
too long"
);
return
NULL
;
}
...
...
@@ -2346,13 +2343,13 @@ replace_single_character(PyBytesObject *self,
product
=
count
*
(
to_len
-
1
);
if
(
product
/
(
to_len
-
1
)
!=
count
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"replace
string is
too long"
);
"replace
ment bytes are
too long"
);
return
NULL
;
}
result_len
=
self_len
+
product
;
if
(
result_len
<
0
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"replac
e string is
too long"
);
"replac
ment bytes are
too long"
);
return
NULL
;
}
...
...
@@ -2416,13 +2413,13 @@ replace_substring(PyBytesObject *self,
product
=
count
*
(
to_len
-
from_len
);
if
(
product
/
(
to_len
-
from_len
)
!=
count
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"replace
string is
too long"
);
"replace
ment bytes are
too long"
);
return
NULL
;
}
result_len
=
self_len
+
product
;
if
(
result_len
<
0
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"replace
string is
too long"
);
"replace
ment bytes are
too long"
);
return
NULL
;
}
...
...
@@ -2620,7 +2617,7 @@ PyDoc_STRVAR(startswith__doc__,
Return True if B starts with the specified prefix, False otherwise.
\n
\
With optional start, test B beginning at that position.
\n
\
With optional end, stop comparing B at that position.
\n
\
prefix can also be a tuple of
string
s to try."
);
prefix can also be a tuple of
byte
s to try."
);
static
PyObject
*
string_startswith
(
PyBytesObject
*
self
,
PyObject
*
args
)
...
...
@@ -2661,7 +2658,7 @@ PyDoc_STRVAR(endswith__doc__,
Return True if B ends with the specified suffix, False otherwise.
\n
\
With optional start, test B beginning at that position.
\n
\
With optional end, stop comparing B at that position.
\n
\
suffix can also be a tuple of
string
s to try."
);
suffix can also be a tuple of
byte
s to try."
);
static
PyObject
*
string_endswith
(
PyBytesObject
*
self
,
PyObject
*
args
)
...
...
@@ -3310,7 +3307,7 @@ PyBytes_Fini(void)
nullstring
=
NULL
;
}
/***********************
Str
Iterator ****************************/
/***********************
Bytes
Iterator ****************************/
typedef
struct
{
PyObject_HEAD
...
...
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