Commit Graph

45375 Commits

Author SHA1 Message Date
Victor Stinner c232c9110c
bpo-39502: Skip test_zipfile.test_add_file_after_2107() on AIX (GH-18282)
Skip test_zipfile.test_add_file_after_2107() if time.localtime()
fails with OverflowError. It is the case on AIX 6.1 for example.
2020-01-30 15:47:53 +01:00
damani42 38c878b56c
bpo-39424: Use assertRaisesRegex instead of assertRaisesRegexp. (GH-18277) 2020-01-30 12:26:22 +02:00
Victor Stinner c38fd0df2b
bpo-39353: binascii.crc_hqx() is no longer deprecated (GH-18276)
The binascii.crc_hqx() function is no longer deprecated.
2020-01-30 09:56:40 +01:00
Shantanu 2e6569b669
bpo-39493: Fix definition of IO.closed in typing.py (#18265) 2020-01-29 18:52:36 -08:00
Chris Withers db5e86adbc
Get mock coverage back to 100% (GH-18228)
* use the `: pass` and `: yield` patterns for code that isn't expected to ever be executed.

* The _Call items passed to _AnyComparer are only ever of length two, so assert instead of if/else

* fix typo

* Fix bug, where stop-without-start patching dict blows up with `TypeError: 'NoneType' object is not iterable`, highlighted by lack of coverage of an except branch.

* The fix for bpo-37972 means _Call.count and _Call.index are no longer needed.

* add coverage for calling next() on a mock_open with readline.return_value set.

* __aiter__ is defined on the Mock so the one on _AsyncIterator is never called.
2020-01-29 16:24:54 +00:00
Carl Friedrich Bolz-Tereick a327677905
bpo-39485: fix corner-case in method-detection of mock (GH-18252)
Replace check for whether something is a method in the mock module. The
previous version fails on PyPy, because there no method wrappers exist
(everything looks like a regular Python-defined function). Thus the
isinstance(getattr(result, '__get__', None), MethodWrapperTypes) check
returns True for any descriptor, not just methods.

This condition could also return erroneously True in CPython for
C-defined descriptors.

Instead to decide whether something is a method, just check directly
whether it's a function defined on the class. This passes all tests on
CPython and fixes the bug on PyPy.
2020-01-29 15:43:37 +00:00
Victor Stinner 3cb49b62e6
bpo-39460: Fix test_zipfile.test_add_file_after_2107() (GH-18247)
XFS filesystem is limited to 32-bit timestamp, but the utimensat()
syscall doesn't fail. Moreover, there is a VFS bug which returns
a cached timestamp which is different than the value on disk.

https://bugzilla.redhat.com/show_bug.cgi?id=1795576
https://bugs.python.org/issue39460#msg360952
2020-01-29 15:23:29 +01:00
Bruce Merry d07d9f4c43
bpo-36051: Drop GIL during large bytes.join() (GH-17757)
Improve multi-threaded performance by dropping the GIL in the fast path
of bytes.join. To avoid increasing overhead for small joins, it is only
done if the output size exceeds a threshold.
2020-01-29 16:09:24 +09:00
Rémi Lapeyre 2cca8efe46 bpo-36350: inspect: Replace OrderedDict with dict. (GH-12412) 2020-01-28 21:47:03 +09:00
Adam Meily 0be3246d4f bpo-39439: Fix multiprocessing spawn path in a venv on Windows (GH-18158) 2020-01-28 21:34:23 +11:00
Christoph Reiter c45a2aa9e2 bpo-38883: Don't use POSIX `$HOME` in `pathlib.Path.home/expanduser` on Windows (GH-17961)
In bpo-36264 os.path.expanduser was changed to ignore HOME on Windows.

Path.expanduser/home still honored HOME despite being documented as behaving the same
as os.path.expanduser. This makes them also ignore HOME so that both implementations
behave the same way again.
2020-01-28 20:41:50 +11:00
Brian Quinlan 884eb89d4a
bpo-39205: Tests that highlight a hang on ProcessPoolExecutor shutdown (#18221) 2020-01-27 16:50:37 -08:00
Cheryl Sabella dd023ad161 bpo-30780: Add IDLE configdialog tests (#3592)
Expose dialog buttons to test code and complete their test coverage.
Complete test coverage for highlights and keys tabs.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2020-01-27 17:15:56 -05:00
Victor Stinner 4a46adc774
bpo-39459: test.pythoninfo logs effective uid/gid (GH-18203)
Fix also umask formatting: use octal prefix.
2020-01-27 18:06:42 +01:00
Dong-hee Na 9e1ed518a5 bpo-39453: Add testcase for bpo-39453 (GH-18202)
https://bugs.python.org/issue39453



Automerge-Triggered-By: @pablogsal

Automerge-Triggered-By: @pablogsal
2020-01-27 09:04:25 -08:00
Dong-hee Na 4dbf2d8c67 bpo-39453: Make list.__contains__ hold strong references to avoid crashes (GH-18181) 2020-01-27 15:02:23 +00:00
Chris Withers a46575a8f2
Clarify and fix assertions that mocks have not been awaited (GH-18196)
- The gc.collect is needed for other implementations, such as pypy
- Using context managers over multiple lines will only catch the warning from the first line in the context!
- remove a skip for a test that no longer fails on pypy
2020-01-27 14:55:56 +00:00
Chris Withers c7dd3c7d87
Use relative imports in mock and its tests to help backporting (GH-18197)
* asyncio.run only available in 3.8+

* iscoroutinefunction has important bungfixes in 3.8

* IsolatedAsyncioTestCase only available in 3.8+
2020-01-27 14:11:19 +00:00
Toshio Kuratomi 997443c14c Fix so that test.test_distutils can be executed by unittest and not just regrtest (GH-13480) 2020-01-27 07:08:39 -05:00
Mark Shannon 8a4cd700a7
bpo-39320: Handle unpacking of **values in compiler (GH-18141)
* Add DICT_UPDATE and DICT_MERGE bytecodes. Use them for ** unpacking.

* Remove BUILD_MAP_UNPACK and BUILD_MAP_UNPACK_WITH_CALL, as they are now unused.

* Update magic number for ** unpacking opcodes.

* Update dis.rst to incorporate new bytecodes.

* Add blurb entry.
2020-01-27 09:57:45 +00:00
Karthikeyan Singaravelan 72b1004657 bpo-25597: Ensure wraps' return value is used for magic methods in MagicMock (#16029) 2020-01-27 06:48:15 +00:00
加和 4515a590a4 Fix linecache.py add lazycache to __all__ and use dict.clear to clear the cache (GH-4641) 2020-01-25 21:07:40 -05:00
Vegard Stikbakke aef7dc8987 bpo-38932: Mock fully resets child objects on reset_mock(). (GH-17409) 2020-01-25 15:44:46 +00:00
Łukasz Langa b07ead3411 Python 3.9.0a3
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE4/8oOcBIslwITevpsmmV4xAlBWgFAl4rXBoACgkQsmmV4xAl
 BWid+xAAmRi6rMnpTrJG6V4herWLg4tQg4LaghxXPHtAfcZCgYkbA3kI4nq7SoKy
 7XnJRX6Uk3FhT2rzM2+sg+sPDMNz5ki+G6L0rYrmouZSy+y7/KDBTzh7u8nnAZD1
 t72Zl3LyWFgeg58MVld5LWoCt7+ywAfIAEbeYAFonH4yY1MqK8Q5+kbNtuMBar81
 S44i/UIjV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XEezW3
 i9xJkCaxJUw7xrt808O1MHhkKAC9VFk/s2YDpmhCcmwfF8IR2K4L0XpQRG4+dfwz
 WFPA8xQC2W+BHsHQoXW4XFZJQaCDmXZX2c0SOjl2fwZUyi2h3vvqJPfDxtjIRltN
 TqAZJuaZgJNhtvK9R2BIY6Xr72owczdM8z35Je44K6oiUgFYs4UN9U+6D4sdRkSc
 YBDgRmnGHTb07VWTWxyuzkXmUDiQ458KpdA9xDE47463v+NqkD9scR3EgX/e6OTR
 0+EgUU6dYg==
 =MyW2
 -----END PGP SIGNATURE-----

Merge tag 'v3.9.0a3'

Python 3.9.0a3
2020-01-25 14:52:06 +01:00
Paulo Henrique Silva 40c080934b bpo-37955: correct mock.patch docs with respect to the returned type (GH-15521) 2020-01-25 10:53:54 +00:00
Matthew Kokotovich 62865f4532 bpo-39082: Allow AsyncMock to correctly patch static/class methods (GH-18116) 2020-01-25 10:17:47 +00:00
Cheryl Sabella d0d9fa8c5e bpo-39388: IDLE: Fix bug when cancelling out of configdialog (GH-18068)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2020-01-25 04:00:54 -05:00
Łukasz Langa c33378df39
Python 3.9.0a3 2020-01-24 22:05:07 +01:00
Serhiy Storchaka 9017e0bd5e bpo-39430: Fix race condition in lazy imports in tarfile. (GH-18161)
Use `from ... import ...` to ensure module is fully loaded before accessing its attributes.
2020-01-24 09:55:52 -08:00
mbarkhau 88704334e5 bpo-39390 shutil: fix argument types for ignore callback (GH-18122) 2020-01-24 15:51:16 +01:00
Karthikeyan Singaravelan 66b00a9d3a bpo-38473: Handle autospecced functions and methods used with attach_mock (GH-16784) 2020-01-24 13:14:29 +00:00
Victor Stinner b8d1262e8a
bpo-39395: putenv() and unsetenv() always available (GH-18135)
The os.putenv() and os.unsetenv() functions are now always available.

On non-Windows platforms, Python now requires setenv() and unsetenv()
functions to build.

Remove putenv_dict from posixmodule.c: it's not longer needed.
2020-01-24 14:05:48 +01:00
Victor Stinner 161e7b36b1
bpo-39413: Implement os.unsetenv() on Windows (GH-18163)
The os.unsetenv() function is now also available on Windows.
2020-01-24 11:53:44 +01:00
Mark Dickinson e9652e8d58 bpo-39426: Fix outdated default and highest protocols in docs (GH-18154)
Some portions of the pickle documentation hadn't been updated for the pickle protocol changes in Python 3.8 (new protocol 5, default protocol 4). This PR fixes those docs.


https://bugs.python.org/issue39426
2020-01-24 02:03:22 -08:00
Mario Corchero e131c9720d Fix `mock.patch.dict` to be stopped with `mock.patch.stopall` (#17606)
As the function was not registering in the active patches, the mocks
started by `mock.patch.dict` were not being stopped when
`mock.patch.stopall` was being called.
2020-01-24 08:38:32 +00:00
Emmanuel Arias 1d0c5e16ea bpo-24928: Add test case for patch.dict using OrderedDict (GH -11437)
* add test for path.dict using OrderedDict

Co-authored-by: Yu Tomita nekobon@users.noreply.github.com
2020-01-24 08:14:14 +00:00
Pablo Galindo 99e6c260d6
bpo-17005: Add a class to perform topological sorting to the standard library (GH-11583)
Co-Authored-By: Tim Peters <tim.peters@gmail.com>
2020-01-23 15:29:52 +00:00
Pablo Galindo 79f89e6e5a
bpo-39421: Fix posible crash in heapq with custom comparison operators (GH-18118)
* bpo-39421: Fix posible crash in heapq with custom comparison operators

* fixup! bpo-39421: Fix posible crash in heapq with custom comparison operators

* fixup! fixup! bpo-39421: Fix posible crash in heapq with custom comparison operators
2020-01-23 14:07:05 +00:00
Mark Shannon 13bc13960c
bpo-39320: Handle unpacking of *values in compiler (GH-17984)
* Add three new bytecodes: LIST_TO_TUPLE, LIST_EXTEND, SET_UPDATE. Use them to implement star unpacking expressions.

* Remove four bytecodes BUILD_LIST_UNPACK, BUILD_TUPLE_UNPACK, BUILD_SET_UNPACK and  BUILD_TUPLE_UNPACK_WITH_CALL opcodes as they are now unused.

* Update magic number and dis.rst for new bytecodes.
2020-01-23 09:25:17 +00:00
Terry Jan Reedy f9e07e116c
bpo-32989: IDLE - remove unneeded parameter (GH-18138)
IDLE does not pass a non-default _synchre in any of its calls to
pyparse.find_good_parse_start.
2020-01-22 23:55:07 -05:00
Zackery Spytz 2e43b64c94 bpo-39050: The Help button in IDLE's config menu works again (GH-17611)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2020-01-22 22:54:30 -05:00
William Woodruff dd754caf14 bpo-29435: Allow is_tarfile to take a filelike obj (GH-18090)
`is_tarfile()` now supports `name` being a file or file-like object.
2020-01-22 18:24:16 -08:00
Dino Viehland 9b6fec4651
bpo-39336: Allow packages to not let their child modules be set on them (#18006)
* bpo-39336: Allow setattr to fail on modules which aren't assignable

When attaching a child module to a package if the object in sys.modules raises an AttributeError (e.g. because it is immutable) it causes the whole import to fail.  This now allows immutable packages to exist and an ImportWarning is reported and the AttributeError exception is ignored.
2020-01-22 16:42:38 -08:00
Alex Rebert d3ae95e1e9 bpo-35182: fix communicate() crash after child closes its pipes (GH-17020) (GH-18117)
When communicate() is called in a loop, it crashes when the child process
has already closed any piped standard stream, but still continues to be running

Co-authored-by: Andriy Maletsky <andriy.maletsky@gmail.com>
2020-01-22 15:28:31 -08:00
Dong-hee Na 1f0f102dec bpo-39366: Remove xpath() and xgtitle() methods of NNTP (GH-18035) 2020-01-23 00:59:43 +03:00
Victor Stinner b73dd02ea7
Revert "bpo-39413: Implement os.unsetenv() on Windows (GH-18104)" (GH-18124)
This reverts commit 56cd3710a1.
2020-01-22 21:11:17 +01:00
Victor Stinner beea26b57e
bpo-39353: Deprecate the binhex module (GH-18025)
Deprecate binhex4 and hexbin4 standards. Deprecate the binhex module
and the following binascii functions:

* b2a_hqx(), a2b_hqx()
* rlecode_hqx(), rledecode_hqx()
* crc_hqx()
2020-01-22 20:44:22 +01:00
Victor Stinner 56cd3710a1
bpo-39413: Implement os.unsetenv() on Windows (GH-18104)
The os.unsetenv() function is now also available on Windows.

It is implemented with SetEnvironmentVariableW(name, NULL).
2020-01-21 16:13:09 +01:00
Victor Stinner 59e2d26b25
Move test_math tests (GH-18098)
testPerm() and testComb() belong to MathTests, not to IsCloseTests().

test_nextafter() and test_ulp() now use assertIsNaN().
2020-01-21 12:48:16 +01:00
William Chargin eab3b3f1c6 bpo-39389: gzip: fix compression level metadata (GH-18077)
As described in RFC 1952, section 2.3.1, the XFL (eXtra FLags) byte of a
gzip member header should indicate whether the DEFLATE algorithm was
tuned for speed or compression ratio. Prior to this patch, archives
emitted by the `gzip` module always indicated maximum compression.
2020-01-21 13:25:24 +02:00