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
74d5cadd
Commit
74d5cadd
authored
Jan 09, 2010
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify string comparison of from_bytes/to_bytes
parent
5eed9352
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
20 deletions
+6
-20
Objects/longobject.c
Objects/longobject.c
+6
-20
No files found.
Objects/longobject.c
View file @
74d5cadd
...
...
@@ -4325,10 +4325,9 @@ long_to_bytes(PyLongObject *v, PyObject *args, PyObject *kwds)
int
little_endian
;
int
is_signed
;
PyObject
*
bytes
;
static
PyObject
*
little_str
=
NULL
,
*
big_str
=
NULL
;
static
char
*
kwlist
[]
=
{
"length"
,
"byteorder"
,
"signed"
,
NULL
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"n
O
|O:to_bytes"
,
kwlist
,
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"n
U
|O:to_bytes"
,
kwlist
,
&
length
,
&
byteorder_str
,
&
is_signed_obj
))
return
NULL
;
...
...
@@ -4338,16 +4337,10 @@ long_to_bytes(PyLongObject *v, PyObject *args, PyObject *kwds)
"'signed' is a keyword-only argument"
);
return
NULL
;
}
if
(
little_str
==
NULL
)
{
little_str
=
PyUnicode_InternFromString
(
"little"
);
big_str
=
PyUnicode_InternFromString
(
"big"
);
if
(
little_str
==
NULL
||
big_str
==
NULL
)
return
NULL
;
}
if
(
PyObject_RichCompareBool
(
byteorder_str
,
little_str
,
Py_EQ
))
if
(
!
PyUnicode_CompareWithASCIIString
(
byteorder_str
,
"little"
))
little_endian
=
1
;
else
if
(
PyObject_RichCompareBool
(
byteorder_str
,
big_str
,
Py_EQ
))
else
if
(
!
PyUnicode_CompareWithASCIIString
(
byteorder_str
,
"big"
))
little_endian
=
0
;
else
{
PyErr_SetString
(
PyExc_ValueError
,
...
...
@@ -4414,10 +4407,9 @@ long_from_bytes(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject
*
obj
;
PyObject
*
bytes
;
PyObject
*
long_obj
;
static
PyObject
*
little_str
=
NULL
,
*
big_str
=
NULL
;
static
char
*
kwlist
[]
=
{
"bytes"
,
"byteorder"
,
"signed"
,
NULL
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"O
O
|O:from_bytes"
,
kwlist
,
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"O
U
|O:from_bytes"
,
kwlist
,
&
obj
,
&
byteorder_str
,
&
is_signed_obj
))
return
NULL
;
...
...
@@ -4427,16 +4419,10 @@ long_from_bytes(PyTypeObject *type, PyObject *args, PyObject *kwds)
"'signed' is a keyword-only argument"
);
return
NULL
;
}
if
(
little_str
==
NULL
)
{
little_str
=
PyUnicode_InternFromString
(
"little"
);
big_str
=
PyUnicode_InternFromString
(
"big"
);
if
(
little_str
==
NULL
||
big_str
==
NULL
)
return
NULL
;
}
if
(
PyObject_RichCompareBool
(
byteorder_str
,
little_str
,
Py_EQ
))
if
(
!
PyUnicode_CompareWithASCIIString
(
byteorder_str
,
"little"
))
little_endian
=
1
;
else
if
(
PyObject_RichCompareBool
(
byteorder_str
,
big_str
,
Py_EQ
))
else
if
(
!
PyUnicode_CompareWithASCIIString
(
byteorder_str
,
"big"
))
little_endian
=
0
;
else
{
PyErr_SetString
(
PyExc_ValueError
,
...
...
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