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
7 changes: 3 additions & 4 deletions Doc/library/signal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ The variables defined in the :mod:`signal` module are:
All the signal numbers are defined symbolically. For example, the hangup signal
is defined as :const:`signal.SIGHUP`; the variable names are identical to the
names used in C programs, as found in ``<signal.h>``. The Unix man page for
':c:func:`signal`' lists the existing signals (on some systems this is
'``signal``' lists the existing signals (on some systems this is
:manpage:`signal(2)`, on others the list is in :manpage:`signal(7)`). Note that
not all systems define the same set of signal names; only those names defined by
the system are defined by this module.
Expand Down Expand Up @@ -666,9 +666,8 @@ The :mod:`signal` module defines the following functions:
*sigset*.

The return value is an object representing the data contained in the
:c:type:`siginfo_t` structure, namely: :attr:`si_signo`, :attr:`si_code`,
:attr:`si_errno`, :attr:`si_pid`, :attr:`si_uid`, :attr:`si_status`,
:attr:`si_band`.
``siginfo_t`` structure, namely: ``si_signo``, ``si_code``,
``si_errno``, ``si_pid``, ``si_uid``, ``si_status``, ``si_band``.

.. availability:: Unix.

Expand Down
1 change: 0 additions & 1 deletion Doc/tools/.nitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Doc/library/profile.rst
Doc/library/pyexpat.rst
Doc/library/resource.rst
Doc/library/select.rst
Doc/library/signal.rst
Doc/library/smtplib.rst
Doc/library/socket.rst
Doc/library/ssl.rst
Expand Down
3 changes: 0 additions & 3 deletions Include/internal/pycore_tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ extern PyStatus _PyTuple_InitGlobalObjects(PyInterpreterState *);

#define _PyTuple_ITEMS(op) _Py_RVALUE(_PyTuple_CAST(op)->ob_item)

// Alias for backward compatibility
#define _PyTuple_FromArray PyTuple_FromArray

PyAPI_FUNC(PyObject *)_PyTuple_FromStackRefStealOnSuccess(const union _PyStackRef *, Py_ssize_t);
PyAPI_FUNC(PyObject *)_PyTuple_FromArraySteal(PyObject *const *, Py_ssize_t);

Expand Down
11 changes: 11 additions & 0 deletions Lib/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def _get_exports_list(module):
__all__.append('_exit')
except ImportError:
pass
try:
from posix import _clearenv
__all__.append('_clearenv')
except ImportError:
pass
import posixpath as path

try:
Expand Down Expand Up @@ -768,6 +773,12 @@ def __ror__(self, other):
new.update(self)
return new

if _exists("_clearenv"):
def clear(self):
_clearenv()
self._data.clear()


def _create_environ_mapping():
if name == 'nt':
# Where Env Var Names Must Be UPPERCASE
Expand Down
16 changes: 8 additions & 8 deletions Lib/test/clinic.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -4341,7 +4341,7 @@ test_vararg_and_posonly(PyObject *module, PyObject *const *args, Py_ssize_t narg
goto exit;
}
a = args[0];
__clinic_args = _PyTuple_FromArray(args + 1, nargs - 1);
__clinic_args = PyTuple_FromArray(args + 1, nargs - 1);
if (__clinic_args == NULL) {
goto exit;
}
Expand All @@ -4356,7 +4356,7 @@ test_vararg_and_posonly(PyObject *module, PyObject *const *args, Py_ssize_t narg

static PyObject *
test_vararg_and_posonly_impl(PyObject *module, PyObject *a, PyObject *args)
/*[clinic end generated code: output=0c11c475e240869e input=2c49a482f68545c0]*/
/*[clinic end generated code: output=83cbe9554d04add2 input=2c49a482f68545c0]*/

/*[clinic input]
test_vararg
Expand Down Expand Up @@ -4421,7 +4421,7 @@ test_vararg(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
}
a = fastargs[0];
__clinic_args = nargs > 1
? _PyTuple_FromArray(args + 1, nargs - 1)
? PyTuple_FromArray(args + 1, nargs - 1)
: PyTuple_New(0);
if (__clinic_args == NULL) {
goto exit;
Expand All @@ -4437,7 +4437,7 @@ test_vararg(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject

static PyObject *
test_vararg_impl(PyObject *module, PyObject *a, PyObject *args)
/*[clinic end generated code: output=17ba625cdd0369c1 input=7448995636d9186a]*/
/*[clinic end generated code: output=d773f7b54e61f73a input=7448995636d9186a]*/

/*[clinic input]
test_vararg_with_default
Expand Down Expand Up @@ -4514,7 +4514,7 @@ test_vararg_with_default(PyObject *module, PyObject *const *args, Py_ssize_t nar
}
skip_optional_kwonly:
__clinic_args = nargs > 1
? _PyTuple_FromArray(args + 1, nargs - 1)
? PyTuple_FromArray(args + 1, nargs - 1)
: PyTuple_New(0);
if (__clinic_args == NULL) {
goto exit;
Expand All @@ -4531,7 +4531,7 @@ test_vararg_with_default(PyObject *module, PyObject *const *args, Py_ssize_t nar
static PyObject *
test_vararg_with_default_impl(PyObject *module, PyObject *a, PyObject *args,
int b)
/*[clinic end generated code: output=3f2b06ab08d5d0be input=3a0f9f557ce1f712]*/
/*[clinic end generated code: output=d25e56802c197344 input=3a0f9f557ce1f712]*/

/*[clinic input]
test_vararg_with_only_defaults
Expand Down Expand Up @@ -4612,7 +4612,7 @@ test_vararg_with_only_defaults(PyObject *module, PyObject *const *args, Py_ssize
}
c = fastargs[1];
skip_optional_kwonly:
__clinic_args = _PyTuple_FromArray(args, nargs);
__clinic_args = PyTuple_FromArray(args, nargs);
if (__clinic_args == NULL) {
goto exit;
}
Expand All @@ -4628,7 +4628,7 @@ test_vararg_with_only_defaults(PyObject *module, PyObject *const *args, Py_ssize
static PyObject *
test_vararg_with_only_defaults_impl(PyObject *module, PyObject *args, int b,
PyObject *c)
/*[clinic end generated code: output=f46666f0b1bf86b9 input=6983e66817f82924]*/
/*[clinic end generated code: output=7366943a7df42e05 input=6983e66817f82924]*/

/*[clinic input]
test_paramname_module
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_os/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,14 @@ def test_reload_environ(self):
self.assertNotIn(b'test_env', os.environb)
self.assertNotIn('test_env', os.environ)

def test_clearenv(self):
os.environ['REMOVEME'] = '1'
os.environ.clear()
self.assertEqual(os.environ, {})

self.assertRaises(TypeError, os.environ.clear, None)


class WalkTests(unittest.TestCase):
"""Tests for os.walk()."""
is_fwalk = False
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Optimize :data:`os.environ.clear() <os.environ>` by calling
:manpage:`clearenv(3)` when this function is available.
Patch by Victor Stinner.
2 changes: 1 addition & 1 deletion Modules/_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
}

/* bpo43522 and OpenSSL < 1.1.1l: copy hostflags manually */
#if OPENSSL_VERSION < 0x101010cf
#if OPENSSL_VERSION_NUMBER < 0x101010cf
X509_VERIFY_PARAM *ssl_verification_params = SSL_get0_param(self->ssl);
X509_VERIFY_PARAM *ssl_ctx_verification_params = SSL_CTX_get0_param(ctx);

Expand Down
6 changes: 3 additions & 3 deletions Modules/_testclinic.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pack_arguments_2pos_varpos(PyObject *a, PyObject *b,
PyObject * const *args, Py_ssize_t args_length)
/*[clinic end generated code: output=267032f41bd039cc input=86ee3064b7853e86]*/
{
PyObject *tuple = _PyTuple_FromArray(args, args_length);
PyObject *tuple = PyTuple_FromArray(args, args_length);
if (tuple == NULL) {
return NULL;
}
Expand Down Expand Up @@ -1174,7 +1174,7 @@ varpos_array_impl(PyObject *module, PyObject * const *args,
Py_ssize_t args_length)
/*[clinic end generated code: output=a25f42f39c9b13ad input=97b8bdcf87e019c7]*/
{
return _PyTuple_FromArray(args, args_length);
return PyTuple_FromArray(args, args_length);
}


Expand Down Expand Up @@ -1610,7 +1610,7 @@ _testclinic_TestClass_varpos_array_no_fastcall_impl(PyTypeObject *type,
Py_ssize_t args_length)
/*[clinic end generated code: output=27c9da663e942617 input=9ba5ae1f1eb58777]*/
{
return _PyTuple_FromArray(args, args_length);
return PyTuple_FromArray(args, args_length);
}


Expand Down
34 changes: 17 additions & 17 deletions Modules/clinic/_testclinic.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Modules/clinic/_testclinic_depr.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Modules/clinic/_testclinic_kwds.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading