Commit Graph

42686 Commits

Author SHA1 Message Date
Christian Heimes d0e31b980f
bpo-32454: socket closefd (#5048)
Add close(fd) function to the socket module

Signed-off-by: Christian Heimes <christian@python.org>
2018-01-27 09:54:13 +01:00
Christian Heimes 2f050c7e1b
bpo-32433: Optimized HMAC digest (#5023)
The hmac module now has hmac.digest(), which provides an optimized HMAC
digest for short messages. hmac.digest() is up to three times faster
than hmac.HMAC().digest().

Signed-off-by: Christian Heimes <christian@python.org>
2018-01-27 09:53:43 +01:00
INADA Naoki a49ac99029
bpo-32677: Add .isascii() to str, bytes and bytearray (GH-5342) 2018-01-27 14:06:21 +09:00
INADA Naoki 37420deb80
bpo-32678: inspect: Import ast lazily (GH-5344) 2018-01-27 10:10:06 +09:00
Yury Selivanov 43c47fe096
bpo-32670: Enforce PEP 479. (#5327) 2018-01-26 15:24:24 -05:00
Nathaniel J. Smith dba976b8a2 bpo-32591: fix abort in _PyErr_WarnUnawaitedCoroutine during shutdown (#5337)
When an unawaited coroutine is collected very late in shutdown --
like, during the final GC at the end of PyImport_Cleanup -- then it
was triggering an interpreter abort, because we'd try to look up the
"warnings" module and not only was it missing (we were prepared for
that), but the entire module system was missing (which we were not
prepared for).

I've tried to fix this at the source, by making the utility function
get_warnings_attr robust against this in general. Note that it already
has the convention that it can return NULL without setting an error,
which is how it signals that the attribute it was asked to fetch is
missing, and that all callers already check for NULL returns.

There's a similar check for being late in shutdown at the top of
warn_explicit, which might be unnecessary after this fix, but I'm not
sure so I'm going to leave it.
2018-01-26 14:28:31 -05:00
Guido van Rossum 95e4d58913 String annotations [PEP 563] (#4390)
* Document `from __future__ import annotations`
* Provide plumbing and tests for `from __future__ import annotations`
* Implement unparsing the AST back to string form

This is required for PEP 563 and as such only implements a part of the
unparsing process that covers expressions.
2018-01-26 08:20:18 -08:00
bennorth d7773d92bd bpo-18533: Avoid RecursionError from repr() of recursive dictview (#4823)
dictview_repr(): Use a Py_ReprEnter() / Py_ReprLeave() pair to check
for recursion, and produce "..." if so.

test_recursive_repr(): Check for the string rather than a
RecursionError.  (Test cannot be any tighter as contents are
implementation-dependent.)

test_deeply_nested_repr(): Add new test, replacing the original
test_recursive_repr().  It checks that a RecursionError is raised in
the case of a non-recursive but deeply nested structure.  (Very
similar to what test_repr_deep() in test/test_dict.py does for a
normal dict.)

OrderedDictTests: Add new test case, to test behavior on OrderedDict
instances containing their own values() or items().
2018-01-26 07:46:01 -08:00
Yury Selivanov 4112c5b97d
bpo-32662: Try making test_asyncio.test_server more reliable (#5338) 2018-01-26 01:30:57 -05:00
mwidjaja 863b1e4d0e bpo-29237: Create enum for pstats sorting options (GH-5103) 2018-01-25 20:49:56 -08:00
INADA Naoki 4666ec597c
bpo-32596: Make lazy-load portable (GH-5316)
Global variables should not used as import target.
Use temporary variable instead.
2018-01-26 10:53:31 +09:00
Bo Bayles 2fc98ae115 bpo-32304: Fix distutils upload for sdists ending with \x0d (GH-5264)
Patch by Bo Bayles.
2018-01-25 19:02:03 -05:00
José Melero Fernández c47dacb690 bpo-32574: Fix leaks in asyncio.Queue.put() and .get() (#5208) 2018-01-25 18:45:43 -05:00
Yury Selivanov c9070d03f5
bpo-32662: Implement Server.start_serving() and Server.serve_forever() (#5312)
* bpo-32662: Implement Server.start_serving() and Server.serve_forever()

New methods:

* Server.start_serving(),
* Server.serve_forever(), and
* Server.is_serving().

Add 'start_serving' keyword parameter to loop.create_server() and
loop.create_unix_server().
2018-01-25 18:08:09 -05:00
Ilya Kulakov 1aa094f740 bpo-29302: Implement contextlib.AsyncExitStack. (#4790) 2018-01-25 15:51:18 -05:00
Victor Stinner b31206a223
bpo-32667: Fix tests when $PATH contains a file (#5322)
Some tests failed when the PATH environment variable contained a path
to an existing file. Fix tests to ignore also NotADirectoryError, not
only FileNotFoundError and PermissionError.
2018-01-25 19:06:05 +01:00
INADA Naoki 2812d3d992
bpo-32360: Remove OrderedDict usage from json.tool (GH-5315)
`object_pairs_hook=OrderedDict` idiom is deprecated.
2018-01-25 19:52:58 +09:00
Victor Stinner 2b822a0bb1
bpo-32652: Defer pymain_set_global_config() call (#5303)
In Py_Main(), don't call pymain_set_global_config() early: only call
it when the whole configuration has been read.

Add an unit test to prevent future regression.
2018-01-25 09:18:36 +01:00
Andrew Svetlov fe133aad52
bpo-32391: Implement StreamWriter.wait_closed() (#5281) 2018-01-25 00:30:30 +02:00
Paul Ganssle 04af5b1ba9 bpo-10381: Add timezone to datetime C API (#5032)
* Add timezone to datetime C API

* Add documentation for timezone C API macros

* Add dedicated tests for datetime type check macros

* Remove superfluous C API test

* Drop support for TimeZoneType in datetime C API

* Expose UTC singleton to the datetime C API

* Update datetime C-API documentation to include links

* Add reference count information for timezone constructors
2018-01-24 17:29:30 -05:00
Bernhard M. Wiedemann ccbe5818af bpo-29708: Setting SOURCE_DATE_EPOCH forces hash-based .pyc files (GH-5200)
To support reproducible builds, the setting of of SOURCE_DATE_EPOCH triggers the py_compile module -- and by extension, compileall -- to forcibly compile with hash-based .pyc files. This eliminates the possibility of timestamp-based .pyc files which vary between builds.
2018-01-24 13:26:18 -08:00
Barry Warsaw 6f6eb35f9b
bpo-32248 - Implement `ResourceReader` and `get_resource_reader()` for zipimport (#5248) 2018-01-24 15:36:21 -05:00
Victor Stinner 789e359f51 bpo-32636: Fix two bugs in test_asyncio (#5302) 2018-01-24 15:15:14 -05:00
Nathaniel J. Smith fb5a7ad421 bpo-32636: Fix @asyncio.coroutine debug mode bug exposed by gh-5250 (#5291) 2018-01-24 15:14:33 -05:00
Andrew Svetlov 0a5e71b4c7
bpo-32410: Improve sock_sendfile tests (#5294)
* Rename sock_sendfile test methods
* Make sock_sendfile tests more stable
2018-01-24 21:40:35 +02:00
Yury Selivanov 22feeb88b4
bpo-32643: Drop support for a few private Task and Future APIs. (#5293)
Specifically, it's not possible to subclass Task/Future classes
and override the following methods:

* Future._schedule_callbacks
* Task._step
* Task._wakeup
2018-01-24 11:31:01 -05:00
Srinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి) 018e1b7aad bpo-32360: unittest.util: Use Counter instead of custom count function (GH-4994) 2018-01-24 16:49:58 +09:00
Bo Bayles 6b273f7f40 bpo-32502: Discard 64-bit (and other invalid) hardware addresses (#5254) 2018-01-23 20:11:44 -05:00
Xiang Zhang 370d04d1dc
bpo-32618: Fix test_mutatingdecodehandler not testing test.mutating (#5269)
* bpo-32618: Fix test_mutatingdecodehandler not testing test.mutating

It should test both test.replacing and test.mutating instead of test test.replacing twice.
2018-01-23 22:50:50 +08:00
Nathaniel J. Smith 6934831e43 bpo-32633: Fix some warnings in test_asyncio.test_tasks (#5280) 2018-01-23 11:09:31 +02:00
Yury Selivanov f23746a934
bpo-32436: Implement PEP 567 (#5027) 2018-01-22 19:11:18 -05:00
Victor Stinner 13ff24582c
bpo-32593: Drop FreeBSD 9 and older support (#5232)
Drop support of FreeBSD 9 and older.
2018-01-22 18:32:50 +01:00
Yury Selivanov b0a7a037b8
bpo-31179: Make dict.copy() up to 5.5 times faster. (#3067) 2018-01-22 11:54:41 -05:00
Ethan Furman a4b1bb4801
bpo-31801: Enum: add _ignore_ as class option (#5237)
* bpo-31801:  Enum:  add _ignore_ as class option

_ignore_ is a list, or white-space seperated str, of names that will not
be candidates for members; these names, and _ignore_ itself, are removed
from the final class.

* bpo-31801:  Enum:  add documentation for _ignore_

* bpo-31801: Enum: remove trailing whitespace

* bpo-31801: Enum: fix bulleted list format

* bpo-31801: add version added for _ignore_
2018-01-22 07:56:37 -08:00
INADA Naoki 579e0b80b9
urllib.request: Remove unused import (GH-5268) 2018-01-22 16:45:31 +09:00
Yury Selivanov a4afcdfa55
bpo-32314: Fix asyncio.run() to cancel runinng tasks on shutdown (#5262) 2018-01-21 14:56:59 -05:00
Nathaniel J. Smith fc2f407829 bpo-32591: Add native coroutine origin tracking (#5250)
* Add coro.cr_origin and sys.set_coroutine_origin_tracking_depth
* Use coroutine origin information in the unawaited coroutine warning
* Stop using set_coroutine_wrapper in asyncio debug mode
* In BaseEventLoop.set_debug, enable debugging in the correct thread
2018-01-21 09:44:07 -05:00
Serhiy Storchaka 1211c9a989
bpo-32503: Avoid creating too small frames in pickles. (#5127) 2018-01-20 16:42:44 +02:00
Christian Heimes bd5c7d238c
bpo-32602: Test ECDSA certs (#5247)
Add test certs and test for ECDSA cert and EC/RSA dual mode.

I'm also adding certs for IDNA 2003/2008 tests and simplify some test
data handling.

Signed-off-by: Christian Heimes <christian@python.org>
2018-01-20 15:16:30 +01:00
Ivan Levkivskyi d911e40e78
bpo-32226: PEP 560: improve typing module (#4906)
This PR re-designs the internal typing API using the new PEP 560 features.
However, there are only few minor changes in the public API.
2018-01-20 11:23:59 +00:00
Sanyam Khurana d57f26c753 bpo-32028: Fix suggestions for indented print statements (GH-4688)
The suggested replacement for print statements previously failed to account
for leading whitespace and hence could end up including unwanted text in
the proposed call to the print builtin.

Patch by Sanyam Khurana.
2018-01-20 13:12:22 +10:00
INADA Naoki 6690bb9f17
bpo-32596: Lazy import concurrent.futures.process and thread (GH-5241) 2018-01-20 09:54:42 +09:00
Andrew Svetlov 7464e87a65
bpo-32410: Make SendfileNotAvailableError exception public (#5243) 2018-01-19 20:04:29 +02:00
Steve Dower 2507e29a9e
bpo-32588: Move _findvs into its own module and add missing _queue module to installer (#5227) 2018-01-19 09:09:36 +11:00
Antoine Pitrou ab74504346
bpo-32576: use queue.SimpleQueue in critical places (#5216)
Where a queue may be invoked from a weakref callback, we need
to use the reentrant SimpleQueue.
2018-01-18 10:38:03 +01:00
Gregory P. Smith 3941499d6c
Use assertCountEqual instead of assertEqual. (#5223)
This test doesn't care about order, the underlying filesystem APIs do not
guarantee directory listings on subsequent calls will be in the same order.
2018-01-17 14:57:57 -08:00
Victor Stinner 7d91c02504
pythoninfo: add time.time and datetime.datetime.now (#5214) 2018-01-17 16:35:45 +01:00
Victor Stinner 3a0cf93179
bpo-32248: Fix test_importlib.test_open() (#5213)
Use the binary.file instead of utf-8.file to avoid issues with
Unix newlines vs Windows newlines.
2018-01-17 15:21:50 +01:00
Paul Ganssle 9f1b7b93f5 bpo-32403: Faster date and datetime constructors (#4993)
* Add tests for date subclass alternate constructors

* Switch over alternate date constructors to fast path

* Switch datetime constructors to fastpath, fix bpo-32404

* Add fast path for datetime in date subclass constructor

* Set fold in constructor in datetime.combine

* Add news entries.
2018-01-16 13:06:31 -05:00
Andrew Svetlov 6b5a27975a
bpo-32410: Implement loop.sock_sendfile() (#4976) 2018-01-16 19:59:34 +02:00