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
509d7370
Commit
509d7370
authored
Nov 21, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make read() and certificate() return bytes instead of bytearray instances.
parent
745dcea6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
31 deletions
+23
-31
Modules/_ssl.c
Modules/_ssl.c
+23
-31
No files found.
Modules/_ssl.c
View file @
509d7370
...
@@ -977,7 +977,7 @@ PySSL_peercert(PySSLObject *self, PyObject *args)
...
@@ -977,7 +977,7 @@ PySSL_peercert(PySSLObject *self, PyObject *args)
return
NULL
;
return
NULL
;
}
}
/* this is actually an immutable bytes sequence */
/* this is actually an immutable bytes sequence */
retval
=
Py
Bytes
_FromStringAndSize
retval
=
Py
String
_FromStringAndSize
((
const
char
*
)
bytes_buf
,
len
);
((
const
char
*
)
bytes_buf
,
len
);
OPENSSL_free
(
bytes_buf
);
OPENSSL_free
(
bytes_buf
);
return
retval
;
return
retval
;
...
@@ -1281,13 +1281,8 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
...
@@ -1281,13 +1281,8 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
Py_DECREF
(
buf
);
Py_DECREF
(
buf
);
return
NULL
;
return
NULL
;
}
else
if
(
sockstate
==
SOCKET_HAS_BEEN_CLOSED
)
{
}
else
if
(
sockstate
==
SOCKET_HAS_BEEN_CLOSED
)
{
/* should contain a zero-length string */
count
=
0
;
if
(
!
buf_passed
)
{
goto
done
;
PyBytes_Resize
(
buf
,
0
);
return
buf
;
}
else
{
return
PyInt_FromLong
(
0
);
}
}
}
}
}
do
{
do
{
...
@@ -1312,12 +1307,8 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
...
@@ -1312,12 +1307,8 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
(
SSL_get_shutdown
(
self
->
ssl
)
==
(
SSL_get_shutdown
(
self
->
ssl
)
==
SSL_RECEIVED_SHUTDOWN
))
SSL_RECEIVED_SHUTDOWN
))
{
{
if
(
!
buf_passed
)
{
count
=
0
;
PyBytes_Resize
(
buf
,
0
);
goto
done
;
return
buf
;
}
else
{
return
PyInt_FromLong
(
0
);
}
}
else
{
}
else
{
sockstate
=
SOCKET_OPERATION_OK
;
sockstate
=
SOCKET_OPERATION_OK
;
}
}
...
@@ -1338,11 +1329,12 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
...
@@ -1338,11 +1329,12 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
}
}
return
PySSL_SetError
(
self
,
count
,
__FILE__
,
__LINE__
);
return
PySSL_SetError
(
self
,
count
,
__FILE__
,
__LINE__
);
}
}
done:
if
(
!
buf_passed
)
{
if
(
!
buf_passed
)
{
if
(
count
!=
len
)
{
PyObject
*
res
=
PyString_FromStringAndSize
(
PyBytes_
Resize
(
buf
,
count
);
PyBytes_
AS_STRING
(
buf
)
,
count
);
}
Py_DECREF
(
buf
);
return
buf
;
return
res
;
}
else
{
}
else
{
return
PyInt_FromLong
(
count
);
return
PyInt_FromLong
(
count
);
}
}
...
...
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