In _localemodule.c and selectmodule.c, remove dead code that would
cause double decrefs if run.
In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases
where a new list is populated and there is no possibility of an error.
In addition, check if the list changed size in the loop in array_array_fromlist().
(cherry picked from commit 99d56b5356)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* tests: Further validate `wraps` functionality in `unittest.mock.Mock`
Add more tests to validate how `wraps` interacts with other features of
mocks.
* Don't call the wrapped object if `side_effect` is set
When a object is wrapped using `Mock(wraps=...)`, if an user sets a
`side_effect` in one of their methods, return the value of `side_effect`
and don't call the original object.
* Refactor what to be called on `mock_call`
When a `Mock` is called, it should return looking up in the following
order: `side_effect`, `return_value`, `wraps`. If any of the first two
return `mock.DEFAULT`, lookup in the next option.
It makes no sense to check for `wraps` returning default, as it is
supposed to be the original implementation and there is nothing to
fallback to.
(cherry picked from commit f05df0a4b6)
Co-authored-by: Mario Corchero <mariocj89@gmail.com>
Join 3 pools in these tests:
* test.test_multiprocessing_spawn.WithProcessesTestPool.test_context
* test.test_multiprocessing_spawn.WithProcessesTestPool.test_traceback
(cherry picked from commit 388c8c208d)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
Moreover, "python3 -m test test_eintr -v" now avoids redirecting
stdout/stderr to a pipe, the child process inherits stdout/stderr
from the parent.
(cherry picked from commit aa8ae904ad)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
Add a missing word `as` in `as well as an`.
Linkify `threading.Thread`.
(cherry picked from commit 40a61da40d)
Co-authored-by: Matt Wheeler <m@funkyhat.org>
select() calls are retried on EINTR (per PEP 475). However, if a
timeout was provided and the deadline has passed after running the
signal handlers, rlist, wlist and xlist should be cleared since select(2)
left them unmodified.
(cherry picked from commit 7f52415a6d)
Co-authored-by: Oran Avraham <252748+oranav@users.noreply.github.com>
When running test_bdb.py as a script, `import test_module` would be
importing the existing Lib/test/test_modules.py instead of the
tempcwd/test_module.py module which was dynamically created by
test_bdb.py itself.
(cherry picked from commit 54fd45505b)
Co-authored-by: Alex H <1884912+lajarre@users.noreply.github.com>
* posixpath.expanduser() now returns the input path unchanged if
the HOME environment variable is not set and pwd.getpwuid() raises
KeyError (the current user identifier doesn't exist in the password
database).
* Add test_no_home_directory() to test_site.
(cherry picked from commit f2f4555d82)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
On Travis CI, FTP tests of test_urllib2net randomly fail with "425
Security: Bad IP connecting".
test.pythoninfo now also logs TRAVIS environment variable.
(cherry picked from commit c11b3b19a5)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-35296: make install now installs the internal API (GH-10665)
make install now also installs the internal API: Include/internal/*.h
header files.
(cherry picked from commit f653fd4d95)
* Windows installer now also install Include/internal/
The Windows installer (MSI) now also install header files of the
Include/internal/ subdirectory.
The warnings module now suggests to enable tracemalloc if the source
is specified, tracemalloc module is available, but tracemalloc is not
tracing memory allocations.
(cherry picked from commit 2c07c493d2)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
When using link time optimizations, the -flto flag is passed to
BASECFLAGS, which makes it propagate to distutils. Those flags
should be reserved for the interpreter and the stdlib extension
modules only, thus moving those flags to CFLAGS_NODIST.
(cherry picked from commit f92c7aa1ae)
Co-authored-by: stratakis <cstratak@redhat.com>
Fixes `loop.add_writer` and `loop.add_signal_handler` method documentation to correctly reference the callback parameter from method signature.
https://bugs.python.org/issue35395
(cherry picked from commit 1747334794)
Co-authored-by: Naglis <naglis@users.noreply.github.com>
* bpo-35373: Fix PyInit_timezone() error handling
PyInit_timezone() now returns -1 at exit if an exception is raised.
Check also explicitly PyUnicode_DecodeLocale() and Py_BuildValue()
errors.
* bpo-35373: Fix PyInit_time() error handling (GH-10865)
* PyInit_time() now returns NULL if an exception is raised.
* Rename PyInit_timezone() to init_timezone(). "PyInit_" prefix is
a special prefix for function initializing a module.
init_timezone() doesn't initialize a module and the function is not
exported.
(cherry picked from commit 3bb150d814)
Also refactor the call recording imolementation and add some notes
about its limitations.
(cherry picked from commit 8ca0fa9d2f)
Co-authored-by: Chris Withers <chris@withers.org>
* Add create_autospec with partial function returned in getattr
* Use self.assertFalse instead of assert
* Use different names and remove object
(cherry picked from commit c667b094ae)
Co-authored-by: Xtreak <tirkarthi@users.noreply.github.com>