Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Lib/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from test import test_support as support
from test.script_helper import assert_python_ok
import asyncore
# import unittest.mock
from mock import Mock
from test import support
import re
import socket
Expand Down Expand Up @@ -3577,8 +3575,8 @@ def test_keylog_filename(self):
"test is not compatible with ignore_environment")
def test_keylog_env(self):
self.addCleanup(support.unlink, support.TESTFN)
with mock.patch.dict(os.environ):
os.environ['SSLKEYLOGFILE'] = support.TESTFN
with support.EnvironmentVarGuard() as env:
env['SSLKEYLOGFILE'] = support.TESTFN
self.assertEqual(os.environ['SSLKEYLOGFILE'], support.TESTFN)

ctx = ssl.SSLContext(ssl.PROTOCOL_TLS)
Expand Down
2 changes: 2 additions & 0 deletions Modules/_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3472,7 +3472,9 @@ _servername_callback(SSL *s, int *al, void *args)
Py_INCREF(sni_cb);

if (ssl->ssl_sock == NULL) {
/* The error path below releases ssl_socket. */
ssl_socket = Py_None;
Py_INCREF(ssl_socket);
} else {
ssl_socket = PyWeakref_GetObject(ssl->ssl_sock);
Py_INCREF(ssl_socket);
Expand Down
5 changes: 4 additions & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,14 @@ extern int lstat(const char *, struct stat *);
#include <malloc.h>
#include <windows.h>
#include <shellapi.h> /* for ShellExecute() */
#include <sddl.h> /* for ConvertStringSecurityDescriptorToSecurityDescriptorW() */
#define popen _popen
#define pclose _pclose
#endif /* _MSC_VER */

#ifdef MS_WINDOWS
#include <sddl.h> /* for ConvertStringSecurityDescriptorToSecurityDescriptorW() */
#endif

#if defined(PYCC_VACPP) && defined(PYOS_OS2)
#include <io.h>
#endif /* OS2 */
Expand Down
41 changes: 0 additions & 41 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1836,47 +1836,6 @@ PyDoc_STRVAR(getblocking_doc,
Returns True if socket is in blocking mode, or False if it\n\
is in non-blocking mode.");

static int
socket_parse_timeout(_PyTime_t *timeout, PyObject *timeout_obj)
{
#ifdef MS_WINDOWS
struct timeval tv;
#endif
#ifndef HAVE_POLL
_PyTime_t ms;
#endif
int overflow = 0;

if (timeout_obj == Py_None) {
*timeout = _PyTime_FromSeconds(-1);
return 0;
}

if (_PyTime_FromSecondsObject(timeout,
timeout_obj, _PyTime_ROUND_TIMEOUT) < 0)
return -1;

if (*timeout < 0) {
PyErr_SetString(PyExc_ValueError, "Timeout value out of range");
return -1;
}

#ifdef MS_WINDOWS
overflow |= (_PyTime_AsTimeval(*timeout, &tv, _PyTime_ROUND_TIMEOUT) < 0);
#endif
#ifndef HAVE_POLL
ms = _PyTime_AsMilliseconds(*timeout, _PyTime_ROUND_TIMEOUT);
overflow |= (ms > INT_MAX);
#endif
if (overflow) {
PyErr_SetString(PyExc_OverflowError,
"timeout doesn't fit into C timeval");
return -1;
}

return 0;
}

/* s.settimeout(timeout) method. Argument:
None -- no timeout, blocking mode; same as setblocking(True)
0.0 -- non-blocking mode; same as setblocking(False)
Expand Down