Commit Graph

43989 Commits

Author SHA1 Message Date
Raymond Hettinger 79fbcc597d bpo-36018: Make __pos__ return a distinct instance of NormDist (GH-12009)
https://bugs.python.org/issue36018
2019-02-23 22:19:01 -08:00
Davin Potts e895de3e7f
bpo-35813: Tests and docs for shared_memory (#11816)
* Added tests for shared_memory submodule.

* Added tests for ShareableList.

* Fix bug in allocationn size during creation of empty ShareableList illuminated by existing test run on Linux.

* Initial set of docs for shared_memory module.

* Added docs for ShareableList, added doctree entry for shared_memory submodule, name refactoring for greater clarity.

* Added examples to SharedMemoryManager docs, for ease of documentation switched away from exclusively registered functions to some explicit methods on SharedMemoryManager.

* Wording tweaks to docs.

* Fix test failures on Windows.

* Added tests around SharedMemoryManager.

* Documentation tweaks.

* Fix inappropriate test on Windows.

* Further documentation tweaks.

* Fix bare exception.

* Removed __copyright__.

* Fixed typo in doc, removed comment.

* Updated SharedMemoryManager preliminary tests to reflect change of not supporting all registered functions on SyncManager.

* Added Sphinx doctest run controls.

* CloseHandle should be in a finally block in case MapViewOfFile fails.

* Missed opportunity to use with statement.

* Switch to self.addCleanup to spare long try/finally blocks and save one indentation, change to use decorator to skip test instead.

* Simplify the posixshmem extension module.

Provide shm_open() and shm_unlink() functions.  Move other
functionality into the shared_memory.py module.

* Added to doc around size parameter of SharedMemory.

* Changed PosixSharedMemory.size to use os.fstat.

* Change SharedMemory.buf to a read-only property as well as NamedSharedMemory.size.

* Marked as provisional per PEP411 in docstring.

* Changed SharedMemoryTracker to be private.

* Removed registered Proxy Objects from SharedMemoryManager.

* Removed shareable_wrap().

* Removed shareable_wrap() and dangling references to it.

* For consistency added __reduce__ to key classes.

* Fix for potential race condition on Windows for O_CREX.

* Remove unused imports.

* Update access to kernel32 on Windows per feedback from eryksun.

* Moved kernel32 calls to _winapi.

* Removed ShareableList.copy as redundant.

* Changes to _winapi use from eryksun feedback.

* Adopt simpler SharedMemory API, collapsing PosixSharedMemory and WindowsNamedSharedMemory into one.

* Fix missing docstring on class, add test for ignoring size when attaching.

* Moved SharedMemoryManager to managers module, tweak to fragile test.

* Tweak to exception in OpenFileMapping suggested by eryksun.

* Mark a few dangling bits as private as suggested by Giampaolo.
2019-02-23 22:08:16 -06:00
Terry Jan Reedy d610116a2e
bpo-24310: Document IDLE settings dialog font tab sample (GH-12007) 2019-02-23 23:04:53 -05:00
Raymond Hettinger 11c7953165
bpo-36018: Add the NormalDist class to the statistics module (GH-11973) 2019-02-23 14:44:07 -08:00
Pablo Galindo 175421b58c bpo-36016: Add generation option to gc.getobjects() (GH-11909) 2019-02-23 12:02:06 +09:00
Stéphane Wirtel a40681dd5d bpo-36019: Use pythontest.net instead of example.com in network tests (GH-11941) 2019-02-22 14:45:36 +01:00
Raymond Hettinger 47d9987247
bpo-35904: Add statistics.fmean() (GH-11892) 2019-02-21 15:06:29 -08:00
Joe Jevnik f36f89257b bpo-36068: Make _tuplegetter objects serializable (GH-11981) 2019-02-21 13:00:40 -08:00
Raymond Hettinger 407c734326
bpo-36057 Update docs and tests for ordering in collections.Counter [no behavior change] (#11962)
* Add tests for Counter order.  No behavior change.

* Update docs and tests

* Fix doctest output and capitalization
2019-02-21 09:19:00 -08:00
Raymond Hettinger 86f093f71a
bpo-36060: Document how collections.ChainMap() determines iteration order (GH-11969) 2019-02-21 09:12:15 -08:00
Stéphane Wirtel 3ad9167305 bpo-36052: Raise a SyntaxError when assigning a value to __debug__ with := (GH-11958)
Trying to assign a value to __debug__ using the assignment operator is supposed to fail, but
a missing check for forbidden names when setting the context in the ast was preventing this behaviour.
2019-02-21 10:11:53 +00:00
Victor Stinner 3ef6344ee5
bpo-36037: Fix test_ssl for strict OpenSSL policy (GH-11940)
Fix test_ssl for strict OpenSSL configuration like RHEL8 strict crypto policy.
Use older TLS version for minimum TLS version of the server SSL context if
needed, to test TLS version older than default minimum TLS version.
2019-02-19 18:06:03 +01:00
Cédric Krier beda52ed36 bpo-35153: Add headers parameter to xmlrpc.client.ServerProxy (GH-10308)
Allow to add HTTP headers to XML-RPC requests sent to the server.
2019-02-19 17:18:50 +01:00
Sanyam Khurana 5105483acb bpo-31506: Clarify error messages for object.__new__ and object.__init__ (GH-11641)
`object.__new__` and `object.__init__` do take one argument each,
they just don't take extra user supplied arguments.

Patch by Sanyam Khurana.
2019-02-19 23:23:48 +10:00
Serhiy Storchaka f522a57ec7
Fix a misnamed test for lists. (GH-11933) 2019-02-19 13:53:07 +02:00
Serhiy Storchaka 8d01eb49fc
Fix syntax warnings in tests introduced in bpo-35942. (GH-11934) 2019-02-19 13:52:35 +02:00
Serhiy Storchaka 8e79e6e56f
Fix syntax warnings in tests introduced in bpo-15248. (GH-11932) 2019-02-19 13:49:09 +02:00
Serhiy Storchaka e7a4bb554e
bpo-35798: Add test.support.check_syntax_warning(). (#11895)
It checks that a SyntaxWarning is raised when compile specified
statement, that it is raised only once, that it is converted to
a SyntaxError when raised as exception, and that both warning and
exception objects have corresponding attributes.
2019-02-19 08:30:15 +02:00
Cheryl Sabella ee0f927bd8 bpo-35689: IDLE: Add docstrings and unittests for colorizer.py (GH-11472) 2019-02-19 00:11:18 -05:00
tjb900 4371c0a9c0 bpo-34572: change _pickle unpickling to use import rather than retrieving from sys.modules (GH-9047)
Fix C implementation of pickle.loads to use importlib's locking mechanisms, and thereby avoid using partially-loaded modules.
2019-02-18 15:30:51 +00:00
animalize 4a7f44a2ed bpo-34294: re module, fix wrong capturing groups in rare cases. (GH-11546)
Need to reset capturing groups between two SRE(match) callings in loops, this fixes wrong capturing groups in rare cases.

Also add a missing index in re.rst.
2019-02-18 15:26:37 +02:00
Michael Felt ef110b1807 bpo-35704: Prevent test_shutil fail result when AIX is 32-bit and MAXDATA < 0x20000000 (GH-11500)
https://bugs.python.org/issue35704
2019-02-18 03:02:44 -08:00
Pablo Galindo 09fbcd6085
bpo-35942: Improve the error message if __fspath__ returns invalid types in path_converter (GH-11831)
The error message emitted when returning invalid types from __fspath__ in interfaces that allow passing PathLike objects has been improved and now it does explain the origin of the error.
2019-02-18 10:46:34 +00:00
Ivan Levkivskyi ac28147e78
bpo-35992: Use PySequence_GetItem only if sq_item is not NULL (GH-11857)
Not using `__class_getitem__()` fallback if there is a non-subcriptable metaclass was caused by a certain asymmetry between how `PySequenceMethods` and `PyMappingMethods` are used in `PyObject_GetItem`. This PR removes this asymmetry. No tests failed, so I assume it was not intentional.
2019-02-17 23:13:46 +00:00
Gregory P. Smith 414c625a7e
bpo-36013: delete fragile interactive shell SIGINT test (GH-11902)
It makes the existing smaller test more readable and robust at the same time.

The execution of a shell in interactive mode from CI and buildbot test automation wasn't working out.  What would work locally in our terminals would only work within a fraction of automation systems.  The integration test was a nice to have.  painful.  deleting. :)
2019-02-16 17:22:39 -08:00
Raymond Hettinger 5382203ae1
Convert range to repeat for choices() (#11889) 2019-02-16 13:30:51 -08:00
Gregory P. Smith 38f11cc3f6
bpo-1054041: Exit properly after an uncaught ^C. (#11862)
* bpo-1054041: Exit properly by a signal after a ^C.

An uncaught KeyboardInterrupt exception means the user pressed ^C and
our code did not handle it.  Programs that install SIGINT handlers are
supposed to reraise the SIGINT signal to the SIG_DFL handler in order
to exit in a manner that their calling process can detect that they
died due to a Ctrl-C.  https://www.cons.org/cracauer/sigint.html

After this change on POSIX systems

 while true; do python -c 'import time; time.sleep(23)'; done

can be stopped via a simple Ctrl-C instead of the shell infinitely
restarting a new python process.

What to do on Windows, or if anything needs to be done there has not
yet been determined.  That belongs in its own PR.

TODO(gpshead): A unittest for this behavior is still needed.

* Do the unhandled ^C check after pymain_free.

* Return STATUS_CONTROL_C_EXIT on Windows.

* Fix ifdef around unistd.h include.

* 📜🤖 Added by blurb_it.

* Add STATUS_CTRL_C_EXIT to the os module on Windows

* Add unittests.

* Don't send CTRL_C_EVENT in the Windows test.

It was causing CI systems to bail out of the entire test suite.

See https://dev.azure.com/Python/cpython/_build/results?buildId=37980
for example.

* Correct posix test (fail on macOS?) check.

* STATUS_CONTROL_C_EXIT must be unsigned.

* Improve the error message.

* test typo :)

* Skip if the bash version is too old.

...and rename the windows test to reflect what it does.

* min bash version is 4.4, detect no bash.

* restore a blank line i didn't mean to delete.

* PyErr_Occurred() before the Py_DECREF(co);

* Don't add os.STATUS_CONTROL_C_EXIT as a constant.

* Update the Windows test comment.

* Refactor common logic into a run_eval_code_obj fn.
2019-02-16 12:57:40 -08:00
Serhiy Storchaka 62e4481238
bpo-15248: Emit a compiler warning when missed a comma before tuple or list. (GH-11757) 2019-02-16 08:12:19 +02:00
Daniel Hahler 4327705cfa bpo-35931: Gracefully handle SyntaxError in pdb debug command (GH-11782)
Previously, `debug print(` would cause the interpreter to exit on a SyntaxError whereas `print(` would properly display the error and return to the pdb prompt.

This patch fixes this by pre-compiling the code before passing it to `Pdb.run`.


https://bugs.python.org/issue35931
2019-02-15 12:52:53 -08:00
pxinwr 3e028b2d40 bpo-35994: add sub dir for sub2_tree in os.walk test if symlink is not supported (GH-11853)
https://bugs.python.org/issue35994
2019-02-14 21:04:47 -08:00
Michael Felt b94d4bed67 bpo-35633: test_lockf() fails with "PermissionError: [Errno 13] Permission denied" on AIX (GH-11424)
[bpo-35633](https://bugs.python.org/issue35633): Fix a test regression introduced with [bpo-35189](https://bugs.python.org/issue35189) (PEP 475: fnctl functions are not retried if interrupted (EINTR)).

Not only a blocking IO error needs to be ignored - permission errors also need to be ignored.

p.s. - iirc as a "test" only correction a NEWS item is not required. If this is not correct - just mention, and I'll add a NEWS blurb.


https://bugs.python.org/issue35633
2019-02-14 10:22:35 -08:00
Susan Su 2bdd5858e3 bpo-35500: align expected and actual calls on mock.assert_called_with error message. (GH-11804) 2019-02-13 18:22:29 -08:00
Nina Zakharenko 1dc5cb9cb3 bpo-35887: Add make regen-importlib step to importlib._bootstrap docstring (GH-11777) 2019-02-13 15:21:17 -08:00
Cheryl Sabella 5680f6546d bpo-18283: Add support for bytes to shutil.which (GH-11818) 2019-02-13 12:25:10 +01:00
Raymond Hettinger cfd31f0af2 Be consistent about the use of from-imports in random module (GH-11837)
Minor code clean-up.
2019-02-13 02:04:17 -08:00
Matěj Cepl 3dc67d0316 bpo-35505: Skip test_imap4_host_default_value if localhost listens on IMAP port (GH-11823)
Make test_imap4_host_default_value independent on whether the 
local IMAP server is running.
2019-02-12 19:30:19 +01:00
Alexey Izbyshev 16f842da3c bpo-35972: _xxsubinterpreters: Fix potential integer truncation on 32-bit in channel_send() (gh-11822) 2019-02-12 09:06:43 -07:00
Christopher Hunt b01786c881 bpo-35960: Fix dataclasses.field throwing away empty metadata. (GH-11815) 2019-02-12 06:50:49 -05:00
Rémi Lapeyre a31f4cc881 bpo-35918: Remove broken has_key method and add test (#11819) 2019-02-11 16:37:24 -08:00
Pablo Galindo 3766f18c52
bpo-35378: Fix multiprocessing.Pool references (GH-11627)
Changes in this commit:

1. Use a _strong_ reference between the Pool and associated iterators
2. Rework PR #8450 to eliminate a cycle in the Pool.

There is no test in this commit because any test that automatically tests this behaviour needs to eliminate the pool before joining the pool to check that the pool object is garbaged collected/does not hang. But doing this will potentially leak threads and processes (see https://bugs.python.org/issue35413).
2019-02-11 17:29:00 +00:00
Eivind Teig 537b6caa56 bpo-22062: Updated docstring and documentation for pathlib (GH-8519)
Original patch by Mike Short


https://bugs.python.org/issue22062
2019-02-11 02:47:09 -08:00
Pablo Galindo 4207907c2b
Fix division by 0 when checking for overflow in math.prod (GH-11808) 2019-02-10 19:56:58 +00:00
Pablo Galindo 7b2a37b728
Make sure the BaseManager in test_multiprocessing is cleaned up correctly (GH-11653) 2019-02-09 17:35:05 +00:00
Pablo Galindo 613f729e5d
Do not retain references to processes and managers in TestSyncManagerTypes (GH-11801)
Keeping references to processes and managers between tests makes them count as dangling processes.
2019-02-09 17:08:49 +00:00
Terry Jan Reedy 8a03ff2ff4
bpo-35833: Revise IDLE doc for control codes sent to Shell. (GH-11799)
Add  a code example block.
2019-02-08 22:51:51 -05:00
Tim Peters 7ab3d1573c Rework tuple hash tests. (GH-10161)
Add tooling that will useful in future updates, paying particular attention to difficult cases where only the upper bits on the input vary.
2019-02-08 13:09:26 -08:00
Raymond Hettinger 64360ada0f Complete and neaten-up namedtuple's replacement of builtin function lookups with derefs (GH-11794) 2019-02-08 10:37:39 -08:00
Fish 96d37dbcd2 bpo-35615: Fix crashes when copying a Weak{Key,Value}Dictionary. (GH-11384)
Protect dict iterations by wrapping them with _IterationGuard in the
following methods:

- WeakValueDictionary.copy()
- WeakValueDictionary.__deepcopy__()
- WeakKeyDictionary.copy()
- WeakKeyDictionary.__deepcopy__()
2019-02-07 19:51:59 +00:00
Pierre Glaser df8d2cde63 bpo-35911: add cell constructor (GH-11771)
Add a cell constructor, expose the cell type in the types module.
2019-02-07 19:36:48 +00:00
Jason R. Coombs f289084c83
bpo-24209: In http.server script, rely on getaddrinfo to bind to preferred address based on the bind parameter. (#11767)
In http.server script, rely on getaddrinfo to bind to preferred address based on the bind parameter.

As a result, now IPv6 is used as the default (including IPv4 on dual-stack systems). Enhanced tests.
2019-02-07 08:22:45 -05:00
Giampaolo Rodola 2848d9d299 bpo-35917: Test multiprocessing manager classes and shareable types (GH-11772)
multiprocessing: provide unittests for manager classes and shareable types
2019-02-07 11:03:11 +00:00
Pablo Galindo bc09851586 bpo-35606: Implement math.prod (GH-11359) 2019-02-06 23:04:02 -08:00
Inada Naoki c95404ff65
email: use dict instead of OrderedDict (GH-11709) 2019-02-05 17:05:43 +09:00
Inada Naoki f345170940
asyncio: use dict instead of OrderedDict (GH-11710) 2019-02-05 17:04:40 +09:00
Steve Dower 85e102a2b0
bpo-35299: Fixed sysconfig and distutils during PGO profiling (GH-11744) 2019-02-04 17:15:13 -08:00
Nina Zakharenko 69091cb497 bpo-35321: Set the spec origin to frozen in frozen modules (#11732)
* bpo-35321: Set the spec origin to frozen in frozen modules

This fix correctly sets the spec origin to
"frozen" for the _frozen_importlib module. Note that the
origin was already correctly set in _frozen_importlib_external.

* 📜🤖 Added by blurb_it.
2019-02-04 16:56:26 -08:00
Paul Ganssle 89427cd0fe bpo-32417: Make timedelta arithmetic respect subclasses (#10902)
* Make timedelta return subclass types

Previously timedelta would always return the `date` and `datetime`
types, regardless of what it is added to. This makes it return
an object of the type it was added to.

* Add tests for timedelta arithmetic on subclasses

* Make pure python timedelta return subclass types

* Add test for fromtimestamp with tz argument

* Add tests for subclass behavior in now

* Add news entry.

Fixes:
bpo-32417
bpo-35364

* More descriptive variable names in tests

Addresses Victor's comments
2019-02-04 14:42:04 -05:00
Łukasz Langa e7afe1ab25 Python 3.8.0a1
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE4/8oOcBIslwITevpsmmV4xAlBWgFAlxW66AACgkQsmmV4xAl
 BWh3QQ//ZMI2a0KicKZ/MTnaW0cpTSQ5MoikOVL98z1Mx2MGDm5k5pzxN7E4qT39
 WPcnUJyK6o6juigq49qwpufaHRDhn/FoscFpQgTwf4POw23f6OB6karzV6xijOW7
 AoxjqKs7QhjIifAsxe76c4KzpR85tUgxJGsN4KHC6hwAbkri5HQ0372bjg+dkis1
 nmjnDwf6ZkzwtNqOwP5aAnm5z6XWXngQk1BHL1xG+ECXeAYTWEHbgjMlJpsc/28E
 rPDeL08BYiJYLuOghV71Yq3T1FSHicLwwKt0+Q61zBGsjwrEmqfRZpB4oOrr65Ca
 0QdqYbNwm9hkfp3/XnNV+JwBnBLJsd+vzEz3Lcu/hPb7YMAD7DMIrIeG6zVHVVEo
 9edurimM8w5QsmHyGFgVVEh4qImiGgmYSDFrU3l/u3SXjnSLnNJM2dGLMSmJ6N14
 komPeq4vg0daPqRPTbWHTZvjt7aidAJlSzrmjg45KOgv6TdJq8X/Sm/v70zopaXL
 gUW9SNHQY84WpHOni3+SKweh4IsmXT+ZagKHUVuf9h9W9U3u43eGYIWXlLbDUOTj
 tSx3scYJK97YIJjpz7RacAMrEcrn5gWrLnJemnlF5Bsv9tekKBP4vaF7hbkZn+0U
 6aPJ56OOSjtCMPrAl6uw9EbEz1ysPVY0wz6Lpcrb6j7dYCn81Ds=
 =g9Mg
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCAAuFiEE4/8oOcBIslwITevpsmmV4xAlBWgFAlxX+EUQHGx1a2FzekBs
 YW5nYS5wbAAKCRCyaZXjECUFaIGiEACDEsoAjSDnlydMqQ94L5lpy+Tk9hOYiXjV
 ZG4JOhTSuWJzbEdjXHuwWf7rnXgu3xjgsct3wfkFkGuH11XxyyQRJ9u32zsCBE6k
 MO2CsNVVCKyFWM0CJ1A0BrILsVMY2N9mr3nmbiaGZt5eaIY7JUhTtpzhjmyrNIVL
 YWL+EfGgU/1xinsYXuhuOJXACBlJnxR8MOtdJ5X2HZb+6RokYj7efKP7Ty84vZIV
 bW7cngQsoac6C7QNalFRP6Z1pO81HoDQHxlAwh2dUU/4vYQTIZ3zNA7K8JbaJnWL
 bcQkUVvPr2OTqDkro2Hj6qKSpdroAu/7LzNjB3ky+iNkEtVonIX6H/sY9EfbwuYx
 3KS88d9ETdDkxVfRThp8pbedPJL8sIFVsR6E/PzUjLKyfqKQGdifKh+vzrfs642u
 3Xz7xJFyvCPT3xSeemRQRPODhWfPf1sd/rfHbk0SLBF5Se3lqFnNZ4/DhKXMr8/D
 BVozJSRD4P1A7xgEy59/jD5oIkkd8M9g6YtDTD5RYvfWxb/geLN+BAIXsIouRtTe
 ANPX0plC56FfY3xZYqeQi05f+C7j/P2FUKKL9tjiuxKJ8UQ3ftaDw39CneyDLMyy
 u/ynrv3H4EAWsV1qFjOeUIwc+k4rjlprcB+LRQguLBbBlFg1vj8MTOO+Kfgui0Lv
 y9Wpvhkeqw==
 =WuSS
 -----END PGP SIGNATURE-----

Merge tag 'v3.8.0a1'

Python 3.8.0a1
2019-02-04 09:30:59 +01:00
Steve Dower a8474d025c
bpo-35872 and bpo-35873: Clears __PYVENV_LAUNCHER__ variable (GH-11745)
After reading __PYVENV_LAUNCHER__ we now set sys._base_executable value for later use.
Make the same changes for macOS to avoid extra platform checks.
2019-02-03 23:19:38 -08:00
Steve Dower 2f6fae6e51
bpo-35692: pathlib no longer raises when checking file and directory existence on drives that are not ready (GH-11746) 2019-02-03 23:08:18 -08:00
Łukasz Langa aab0e57045
[pydoc] Regenerate topics for v3.8.0a1 2019-02-03 14:04:12 +01:00
Mark Becwar b82bfac436 bpo-29734: nt._getfinalpathname handle leak (GH-740)
Make sure that failure paths call CloseHandle outside of the function that failed
2019-02-02 13:08:23 -08:00
Stefan Krah d08ea70464
bpo-35845: Add order={'C', 'F', 'A'} parameter to memoryview.tobytes(). (#11730) 2019-02-02 18:57:41 +01:00
Tzu-ping Chung 2de576e16d bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517)
Add one char to MsiSummaryInfoGetProperty() output
Based on the patch in bpo-1104 by Anthony Tuininga (atuining) and Mark McMahon (markm).
2019-02-02 09:13:23 -08:00
Davin Potts e5ef45b8f5
bpo-35813: Added shared_memory submodule of multiprocessing. (#11664)
Added shared_memory submodule to multiprocessing in time for first alpha with cross-platform tests soon to follow.
2019-02-01 22:52:23 -06:00
Emily Morehouse ac19081c26
bpo-35877: Add test for while loop named expression without parentheses (GH-11726) 2019-02-01 15:27:38 -07:00
Xtreak d4fceaafb8 bpo-35877: Make parenthesis optional for named expression in while statement (GH-11724)
* Add parenthesis optional in named expressions for while statement

* Add NEWS entry
2019-02-01 14:40:16 -07:00
Amador Pahim 85d83ec7c9 bpo-35864: fix namedtuple._asdict() docstring (GH-11720) 2019-02-01 12:38:57 -08:00
Joannah Nanjekye 075de6cf6c bpo-35861: Fix SyntaxWarning in test_named_expressions.py (GH-11722) 2019-02-01 12:58:43 -07:00
Victor Stinner 1e39b83f24
bpo-35537: Skip test_start_new_session() of posix_spawn (GH-11718)
The test fails. Skip the test until a fix can be found.
2019-02-01 11:40:26 +01:00
Joannah Nanjekye 80c5dfe74b bpo-35537: Add setsid parameter to os.posix_spawn() and os.posix_spawnp() (GH-11608) 2019-02-01 11:05:22 +01:00
Raymond Hettinger ffdf1c30ab
Consistently move the misses update to just before the user function call (GH-11715) 2019-01-31 15:03:38 -08:00
Guido van Rossum dcfcd146f8 bpo-35766: Merge typed_ast back into CPython (GH-11645) 2019-01-31 12:40:27 +01:00
Raymond Hettinger 0bb4bdf0d9
bpo-35864: Replace OrderedDict with regular dict in namedtuple() (#11708)
* Change from OrderedDict to a regular dict

* Add blurb
2019-01-31 00:59:50 -08:00
Michael Selik 9f3f0931cf bpo-34003: Use dict instead of OrderedDict in csv.DictReader (GH-8014) 2019-01-31 00:47:53 -08:00
Steve Dower a1f9a3332b
bpo-35854: Fix EnvBuilder and --symlinks in venv on Windows (GH-11700) 2019-01-30 13:49:14 -08:00
Giampaolo Rodola bafa8487f7 subprocess: close pipes/fds by using ExitStack (GH-11686)
Close pipes/fds in subprocess by using ExitStack.

"In case of premature failure on X.Close() or os.close(X) the remaining pipes/fds will remain "open". Perhaps it makes sense to use contextlib.ExitStack."
- Rationale: https://github.com/python/cpython/pull/11575#discussion_r250288394
2019-01-29 13:14:24 -08:00
Raymond Hettinger 808180c206
Fast path for int inputs to math.dist() and math.hypot() (GH-11692) 2019-01-28 13:59:56 -08:00
Gregory P. Smith 81d04bcf21
Fix docstr/comment typos in _use_posix_spawn(). (GH-11684) 2019-01-26 15:19:11 -08:00
Raymond Hettinger d8080c0119
bpo-35780: Fix errors in lru_cache() C code (GH-11623) 2019-01-26 03:02:00 -05:00
Steve Dower 4e02f8f8b4
bpo-35797: Fix default executable used by the multiprocessing module (GH-11676) 2019-01-25 14:59:12 -08:00
Ivan Levkivskyi 62c35a8a8f
bpo-35814: Allow same r.h.s. in annotated assignments as in normal ones (GH-11667) 2019-01-25 01:39:19 +00:00
Emily Morehouse 8f59ee01be
bpo-35224: PEP 572 Implementation (#10497)
* Add tokenization of :=
- Add token to Include/token.h. Add token to documentation in Doc/library/token.rst.
- Run `./python Lib/token.py` to regenerate Lib/token.py.
- Update Parser/tokenizer.c: add case to handle `:=`.

* Add initial usage of := in grammar.

* Update Python.asdl to match the grammar updates. Regenerated Include/Python-ast.h and Python/Python-ast.c

* Update AST and compiler files in Python/ast.c and Python/compile.c. Basic functionality, this isn't scoped properly

* Regenerate Lib/symbol.py using `./python Lib/symbol.py`

* Tests - Fix failing tests in test_parser.py due to changes in token numbers for internal representation

* Tests - Add simple test for := token

* Tests - Add simple tests for named expressions using expr and suite

* Tests - Update number of levels for nested expressions to prevent stack overflow

* Update symbol table to handle NamedExpr

* Update Grammar to allow assignment expressions in if statements.
Regenerate Python/graminit.c accordingly using `make regen-grammar`

* Tests - Add additional tests for named expressions in RoundtripLegalSyntaxTestCase, based on examples and information directly from PEP 572

Note: failing tests are currently commented out (4 out of 24 tests currently fail)

* Tests - Add temporary syntax test failure tests in test_parser.py

Note: There is an outstanding TODO for this -- syntax tests need to be
moved to a different file (presumably test_syntax.py), but this is
covering what needs to be tested at the moment, and it's more convenient
to run a single test for the time being

* Add support for allowing assignment expressions as function argument annotations. Uncomment tests for these cases because they all pass now!

* Tests - Move existing syntax tests out of test_parser.py and into test_named_expressions.py. Refactor syntax tests to use unittest

* Add TargetScopeError exception to extend SyntaxError

Note: This simply creates the TargetScopeError exception, it is not yet
used anywhere

* Tests - Update tests per PEP 572

Continue refactoring test suite:
The named expression test suite now checks for any invalid cases that
throw exceptions (no longer limited to SyntaxErrors), assignment tests
to ensure that variables are properly assigned, and scope tests to
ensure that variable availability and values are correct

Note:
- There are still tests that are marked to skip, as they are not yet
implemented
- There are approximately 300 lines of the PEP that have not yet been
addressed, though these may be deferred

* Documentation - Small updates to XXX/todo comments

- Remove XXX from child description in ast.c
- Add comment with number of previously supported nested expressions for
3.7.X in test_parser.py

* Fix assert in seq_for_testlist()

* Cleanup - Denote "Not implemented -- No keyword args" on failing test case. Fix PEP8 error for blank lines at beginning of test classes in test_parser.py

* Tests - Wrap all file opens in `with...as` to ensure files are closed

* WIP: handle f(a := 1)

* Tests and Cleanup - No longer skips keyword arg test. Keyword arg test now uses a simpler test case and does not rely on an external file. Remove print statements from ast.c

* Tests - Refactor last remaining test case that relied on on external file to use a simpler test case without the dependency

* Tests - Add better description of remaning skipped tests. Add test checking scope when using assignment expression in a function argument

* Tests - Add test for nested comprehension, testing value and scope. Fix variable name in skipped comprehension scope test

* Handle restriction of LHS for named expressions - can only assign to LHS of type NAME. Specifically, restrict assignment to tuples

This adds an alternative set_context specifically for named expressions,
set_namedexpr_context. Thus, context is now set differently for standard
assignment versus assignment for named expressions in order to handle
restrictions.

* Tests - Update negative test case for assigning to lambda to match new error message. Add negative test case for assigning to tuple

* Tests - Reorder test cases to group invalid syntax cases and named assignment target errors

* Tests - Update test case for named expression in function argument - check that result and variable are set correctly

* Todo - Add todo for TargetScopeError based on Guido's comment (2b3acd37bd (r30472562))

* Tests - Add named expression tests for assignment operator in function arguments

Note: One of two tests are skipped, as function arguments are currently treating
an assignment expression inside of parenthesis as one child, which does
not properly catch the named expression, nor does it count arguments
properly

* Add NamedStore to expr_context. Regenerate related code with `make regen-ast`

* Add usage of NamedStore to ast_for_named_expr in ast.c. Update occurances of checking for Store to also handle NamedStore where appropriate

* Add ste_comprehension to _symtable_entry to track if the namespace is a comprehension. Initialize ste_comprehension to 0. Set set_comprehension to 1 in symtable_handle_comprehension

* s/symtable_add_def/symtable_add_def_helper. Add symtable_add_def to handle grabbing st->st_cur and passing it to symtable_add_def_helper. This now allows us to call the original code from symtable_add_def by instead calling symtable_add_def_helper with a different ste.

* Refactor symtable_record_directive to take lineno and col_offset as arguments instead of stmt_ty. This allows symtable_record_directive to be used for stmt_ty and expr_ty

* Handle elevating scope for named expressions in comprehensions.

* Handle error for usage of named expression inside a class block

* Tests - No longer skip scope tests. Add additional scope tests

* Cleanup - Update error message for named expression within a comprehension within a class. Update comments. Add assert for symtable_extend_namedexpr_scope to validate that we always find at least a ModuleScope if we don't find a Class or FunctionScope

* Cleanup - Add missing case for NamedStore in expr_context_name. Remove unused var in set_namedexpr_content

* Refactor - Consolidate set_context and set_namedexpr_context to reduce duplicated code. Special cases for named expressions are handled by checking if ctx is NamedStore

* Cleanup - Add additional use cases for ast_for_namedexpr in usage comment. Fix multiple blank lines in test_named_expressions

* Tests - Remove unnecessary test case. Renumber test case function names

* Remove TargetScopeError for now. Will add back if needed

* Cleanup - Small comment nit for consistency

* Handle positional argument check with named expression

* Add TargetScopeError exception definition. Add documentation for TargetScopeError in c-api docs. Throw TargetScopeError instead of SyntaxError when using a named expression in a comprehension within a class scope

* Increase stack size for parser by 200. This is a minimal change (approx. 5kb) and should not have an impact on any systems. Update parser test to allow 99 nested levels again

* Add TargetScopeError to exception_hierarchy.txt for test_baseexception.py_

* Tests - Major update for named expression tests, both in test_named_expressions and test_parser

- Add test for TargetScopeError
- Add tests for named expressions in comprehension scope and edge cases
- Add tests for named expressions in function arguments (declarations
and call sites)
- Reorganize tests to group them more logically

* Cleanup - Remove unnecessary comment

* Cleanup - Comment nitpicks

* Explicitly disallow assignment expressions to a name inside parentheses, e.g.: ((x) := 0)

- Add check for LHS types to detect a parenthesis then a name (see note)
- Add test for this scenario
- Update tests for changed error message for named assignment to a tuple
(also, see note)

Note: This caused issues with the previous error handling for named assignment
to a LHS that contained an expression, such as a tuple. Thus, the check
for the LHS of a named expression must be changed to be more specific if
we wish to maintain the previous error messages

* Cleanup - Wrap lines more strictly in test file

* Revert "Explicitly disallow assignment expressions to a name inside parentheses, e.g.: ((x) := 0)"

This reverts commit f1531400ca7d7a2d148830c8ac703f041740896d.

* Add NEWS.d entry

* Tests - Fix error in test_pickle.test_exceptions by adding TargetScopeError to list of exceptions

* Tests - Update error message tests to reflect improved messaging convention (s/can't/cannot)

* Remove cases that cannot be reached in compile.c. Small linting update.

* Update Grammar/Tokens to add COLONEQUAL. Regenerate all files

* Update TargetScopeError PRE_INIT and POST_INIT, as this was purposefully left out when fixing rebase conflicts

* Add NamedStore back and regenerate files

* Pass along line number and end col info for named expression

* Simplify News entry

* Fix compiler warning and explicity mark fallthrough
2019-01-24 16:49:56 -07:00
Rémi Lapeyre 1fd06f1eca bpo-35717: Fix KeyError exception raised when using enums and compile (GH-11523)
https://bugs.python.org/issue17467
2019-01-24 11:43:13 -08:00
Jason Fried fd628cf5ad bpo-35767: Fix unittest.loader to allow partials as test_functions (#11600) 2019-01-23 21:57:25 +01:00
Victor Stinner f6243ac1e4
bpo-35537: subprocess can use posix_spawn with pipes (GH-11575)
* subprocess.Popen can now also use os.posix_spawn() with pipes,
  but only if pipe file descriptors are greater than 2.
* Fix Popen._posix_spawn(): set '_child_created' attribute to True.
* Add Popen._close_pipe_fds() helper function to factorize the code.
2019-01-23 19:00:39 +01:00
Manjusaka da6424e96a bpo-35726: Prevented QueueHandler formatting from affecting other handlers (GH-11537)
QueueHandler.prepare() now makes a copy of the record before modifying and enqueueing it, to avoid affecting other handlers in the chain.
2019-01-23 07:08:38 +00:00
Steve Dower 28f6cb34f6
bpo-35683: Improve Azure Pipelines steps (GH-11493) 2019-01-22 10:49:52 -08:00
Ivan Levkivskyi 9932a22897
bpo-33416: Add end positions to Python AST (GH-11605)
The majority of this PR is tediously passing `end_lineno` and `end_col_offset` everywhere. Here are non-trivial points:
* It is not possible to reconstruct end positions in AST "on the fly", some information is lost after an AST node is constructed, so we need two more attributes for every AST node `end_lineno` and `end_col_offset`.
* I add end position information to both CST and AST.  Although it may be technically possible to avoid adding end positions to CST, the code becomes more cumbersome and less efficient.
* Since the end position is not known for non-leaf CST nodes while the next token is added, this requires a bit of extra care (see `_PyNode_FinalizeEndPos`). Unless I made some mistake, the algorithm should be linear.
* For statements, I "trim" the end position of suites to not include the terminal newlines and dedent (this seems to be what people would expect), for example in
  ```python
  class C:
      pass

  pass
  ```
  the end line and end column for the class definition is (2, 8).
* For `end_col_offset` I use the common Python convention for indexing, for example for `pass` the `end_col_offset` is 4 (not 3), so that `[0:4]` gives one the source code that corresponds to the node.
* I added a helper function `ast.get_source_segment()`, to get source text segment corresponding to a given AST node. It is also useful for testing.

An (inevitable) downside of this PR is that AST now takes almost 25% more memory. I think however it is probably justified by the benefits.
2019-01-22 11:18:22 +00:00
Kumar Akshay 2433a2ab70 bpo-35782: Fix error message in randrange (GH-11620)
https://bugs.python.org/issue35782
2019-01-21 11:19:59 -08:00
Pablo Galindo e9b185f2a4
bpo-35794: Catch PermissionError in test_no_such_executable (GH-11635)
PermissionError can be raised if there are directories in the $PATH that are not accessible
when using posix_spawnp.
2019-01-21 14:35:43 +00:00
Victor Stinner b2385458ce
bpo-35772: Fix test_tarfile on ppc64 (GH-11606)
Fix sparse file tests of test_tarfile on ppc64le with the tmpfs
filesystem.

Fix the function testing if the filesystem supports sparse files:
create a file which contains data and "holes", instead of creating a
file which contains no data.

tmpfs effective block size is a page size (tmpfs lives in the page
cache). RHEL uses 64 KiB pages on aarch64, ppc64 and ppc64le, only
s390x and x86_64 use 4 KiB pages, whereas the test punch holes of
4 KiB.

test.pythoninfo: Add resource.getpagesize().
2019-01-21 10:24:12 +01:00
Pablo Galindo 222d303ade bpo-20239: Allow repeated deletion of unittest.mock.Mock attributes (#11057)
* Allow repeated deletion of unittest.mock.Mock attributes

* fixup! Allow repeated deletion of unittest.mock.Mock attributes

* fixup! fixup! Allow repeated deletion of unittest.mock.Mock attributes
2019-01-21 08:57:46 +00:00
Marc Schlaich b2dc4a3313 bpo-35699: fix distuils cannot detect Build Tools 2017 anymore (GH-11495) 2019-01-20 13:47:42 -05:00
Terry Jan Reedy 2cf1ddaff4
bpo-35770: Fix off-by-1 error. (#11618) 2019-01-18 17:05:40 -05:00
Anthony Sottile 7417622617 bpo-35733: Make isinstance(ast.Constant(boolean), ast.Num) be false. (GH-11547) 2019-01-18 21:30:28 +02:00
Terry Jan Reedy 39ed289a35
bpo-35770: IDLE macosx deletes Options => Configure IDLE. (GH-11614)
It previously deleted Window => Zoom Height by mistake.
(Zoom Height is now on the Options menu).  On Mac, the settings
dialog is accessed via Preferences on the IDLE menu.
2019-01-18 14:00:45 -05:00
Christian Heimes 34de2d312b bpo-35045: Accept TLSv1 default in min max test (GH-11510)
Make ssl tests less strict and also accept TLSv1 as system default. The
changes unbreaks test_min_max_version on Fedora 29.

Signed-off-by: Christian Heimes <christian@python.org>
2019-01-18 16:09:30 +01:00
Dong-hee Na 36d9e9a4d5 bpo-35283: Update the docstring of threading.Thread.join method (GH-11596) 2019-01-18 10:50:47 +01:00
Terry Jan Reedy a902239f22
bpo-35769: Change IDLE's name for new files from 'Untitled' to 'untitled' (GH-11602)
'Untitled' violates the PEP 8 standard for .py files
2019-01-18 02:09:53 -05:00