Commit Graph

23854 Commits

Author SHA1 Message Date
Gregory P. Smith efb1d0a3c0 bpo-29639: change test.support.HOST to "localhost"
test.support.HOST should be "localhost" as it was in the past. See the bpo-29639.

Tests that need the IP address should use HOSTv4 (added) or the existing HOSTv6 constant.

This changes the definition and fixes tests that needed updating to deal with HOST being
the hostname rather than the hardcoded IP address.

This is only the first step in addressing https://bugs.python.org/issue29639.
2017-09-09 00:30:15 -07:00
Han Lee 829dacce4f bpo-26669: Fix nan arg value error in pytime.c (#3085)
* Fix #26669

* Modify NaN check function and error message

* Fix pytime.c when arg is nan

* fix whitespace
2017-09-08 16:05:05 -07:00
Christian Heimes b3ad0e5127 bpo-28182: Expose OpenSSL verification results (#3412)
The SSL module now raises SSLCertVerificationError when OpenSSL fails to
verify the peer's certificate. The exception contains more information about
the error.

Original patch by Chi Hsuan Yen

Signed-off-by: Christian Heimes <christian@python.org>
2017-09-08 12:00:19 -07:00
Christian Heimes cb5b68abde bpo-29136: Add TLS 1.3 cipher suites and OP_NO_TLSv1_3 (#1363)
* bpo-29136: Add TLS 1.3 support

TLS 1.3 introduces a new, distinct set of cipher suites. The TLS 1.3
cipher suites don't overlap with cipher suites from TLS 1.2 and earlier.
Since Python sets its own set of permitted ciphers, TLS 1.3 handshake
will fail as soon as OpenSSL 1.1.1 is released. Let's enable the common
AES-GCM and ChaCha20 suites.

Additionally the flag OP_NO_TLSv1_3 is added. It defaults to 0 (no op) with
OpenSSL prior to 1.1.1. This allows applications to opt-out from TLS 1.3
now.

Signed-off-by: Christian Heimes <christian@python.org>
2017-09-07 18:07:00 -07:00
Nick Coghlan 5a8516701f bpo-31344: Per-frame control of trace events (GH-3417)
f_trace_lines: enable/disable line trace events
f_trace_opcodes: enable/disable opcode trace events

These are intended primarily for testing of the interpreter
itself, as they make it much easier to emulate signals
arriving at unfortunate times.
2017-09-08 10:14:16 +10:00
Christian Heimes 888bbdc192 bpo-27340: Use memoryview in SSLSocket.sendall() (#3384)
* bpo-27340: Use memoryview in SSLSocket.sendall()

SSLSocket.sendall() now uses memoryview to create slices of data. This fix
support for all bytes-like object. It is also more efficient and avoids
costly copies.

Signed-off-by: Christian Heimes <christian@python.org>

* Cast view to bytes, fix typo

Signed-off-by: Christian Heimes <christian@python.org>
2017-09-07 14:18:21 -07:00
Antoine Pitrou a6a4dc816d bpo-31370: Remove support for threads-less builds (#3385)
* Remove Setup.config
* Always define WITH_THREAD for compatibility.
2017-09-07 18:56:24 +02:00
Łukasz Langa e7c566caf1 bpo-30465: Fix lineno and col_offset in fstring AST nodes (#1800)
For f-string ast nodes, fix the line and columns so that tools such as flake8 can identify them correctly.
2017-09-06 17:27:58 -07:00
R. David Murray 0f6b9d2306 bpo-14191 Add parse_intermixed_args. (#3319)
This adds support for parsing a command line where options and positionals are intermixed as is common in many unix commands. This is paul.j3's patch with a few tweaks.
2017-09-06 20:25:40 -04:00
Zachary Ware 49ce74efe8 Remove all mention of Windows IA-64 support (GH-3389)
It was mostly removed long ago.
2017-09-06 15:45:25 -07:00
caavery effc12f8e9 bpo-27584: New addition of vSockets to the python socket module (#2489)
* bpo-27584: New addition of vSockets to the python socket module

Support for AF_VSOCK on Linux only

* bpo-27584: Fixes for V2

Fixed syntax and naming problems.
Fixed #ifdef AF_VSOCK checking
Restored original aclocal.m4

* bpo-27584: Fixes for V3

Added checking for fcntl and thread modules.

* bpo-27584: Fixes for V4

Fixed white space error

* bpo-27584: Fixes for V5

Added back comma in (CID, port).

* bpo-27584: Fixes for V6

Added news file.
socket.rst now reflects first Linux introduction of AF_VSOCK.
Fixed get_cid in test_socket.py.
Replaced PyLong_FromLong with PyLong_FromUnsignedLong in socketmodule.c
Got rid of extra AF_VSOCK #define.
Added sockaddr_vm to sock_addr.

* bpo-27584: Fixes for V7

Minor cleanup.

* bpo-27584: Fixes for V8

Put back #undef AF_VSOCK as it is  necessary when vm_sockets.h is not installed.
2017-09-06 15:18:10 -07:00
Devin Jeanpierre c5bace2bf7 bpo-29505: Add fuzz tests for float(str), int(str), unicode(str) (#2878)
Add basic fuzz tests for a few common builtin functions.

This is an easy place to start, and these functions are probably safe.
We'll want to add more fuzz tests later.  Lets bootstrap using these.

While the fuzz tests are included in CPython and compiled / tested on a
very basic level inside CPython itself, the actual fuzzing happens as
part of oss-fuzz (https://github.com/google/oss-fuzz). The reason to
include the tests in CPython is to make sure that they're maintained
as part of the CPython project, especially when (as some eventually
will) they use internal implementation details in the test.

(This will be necessary sometimes because e.g. the fuzz test should
never enter Python's interpreter loop, whereas some APIs only expose
themselves publicly as Python functions.)

This particular set of changes is part of testing Python's builtins,
tracked internally at Google by b/37562550.

The _xxtestfuzz module that this change adds need not be shipped with binary distributions of Python.
2017-09-06 11:15:35 -07:00
Ammar Askar 3fc499bca1 bpo-31178: Avoid concatenating bytes with str in subprocess error (#3066)
Avoid concatenating bytes with str in the typically rare subprocess error path (exec failed). Includes a mock based unittest to exercise the codepath.
2017-09-05 23:41:30 -07:00
Christian Heimes 6877111648 bpo-29781: Fix SSLObject.version before handshake (#3364)
SSLObject.version() now correctly returns None when handshake over BIO has
not been performed yet.

Signed-off-by: Christian Heimes <christian@python.org>
2017-09-05 21:55:40 -07:00
Christian Heimes 3463ee3972 Stop test_xmlrpc from writing to sys.stderr (#3359)
One test case of test_xmlrpc uses HTTPServer with a subclass of
BaseHTTPRequestHandler. The BaseRequestHandler class logs to
sys.stderr by default. Override log_message() to not clobber
test output.

Signed-off-by: Christian Heimes <christian@python.org>
2017-09-05 21:43:46 -07:00
Christian Heimes 305e56c27a bpo-31320: No traceback to sys.stderr in test_ssl (#3360)
In case PROTOCOL_TLS_SERVER is used for both client context and server
context, the test thread dies with OSError. Catch OSError to avoid
traceback on sys.stderr

Signed-off-by: Christian Heimes <christian@python.org>
2017-09-05 16:37:09 -07:00
Benjamin Peterson 069306312a remove IRIX support (closes bpo-31341) (#3310)
See PEP 11.
2017-09-04 16:36:05 -07:00
Barry Warsaw ba4279683f bpo-1198569: Allow string.Template braced pattern to be different (#3288)
* bpo-1198569: Allow the braced pattern to be different

``string.Template`` subclasses can optionally define ``braceidpattern`` if
they want to specify different placeholder patterns inside and outside the
braces.  If None (the default) it falls back to ``idpattern``.
2017-09-04 16:32:10 -04:00
Christian Heimes 002d64039b bpo-25674: remove sha256.tbs-internet.com ssl test (#3297)
Signed-off-by: Christian Heimes <christian@python.org>
2017-09-04 22:26:01 +02:00
Zhiming Wang 06de1aeff9 bpo-31281: Fix pathlib.Path incompatibility in fileinput (gh-3208)
Fix fileinput with inplace=True to accept pathlib.Path objects.
2017-09-04 13:37:24 -04:00
Ned Deily 918edc0edb bpo-12383: Also ignore __PYVENV_LAUNCHER__ (#3278)
Used in macOS framework builds.
2017-09-04 00:00:21 -04:00
Antoine Pitrou 2ef37607b7 Fix a c.f.as_completed() refleak previously introduced in bpo-27144 (#3270) 2017-09-03 15:09:23 +02:00
Serhiy Storchaka bca4939d80 bpo-31185: Fixed miscellaneous errors in asyncio speedup module. (#3076) 2017-09-03 08:10:14 +03:00
Victor Stinner 8687101589 bpo-31323: Fix reference leak in test_ssl (#3263)
Store exceptions as string rather than object to prevent reference
cycles which cause leaking dangling threads.
2017-09-02 00:26:17 +02:00
Victor Stinner e8a533fbc7 bpo-31250, test_asyncio: fix EventLoopTestsMixin.tearDown() (#3264)
Call doCleanups() to close the loop after calling
executor.shutdown(wait=True): see TestCase.set_event_loop() of
asyncio.test_utils.

Replace also gc.collect() with support.gc_collect().
2017-09-02 00:25:39 +02:00
Grzegorz Grzywacz 97e1b1c814 bpo-27144: concurrent.futures as_complete and map iterators do not keep reference to returned object (#1560)
* bpo-27144: concurrent.futures as_complie and map iterators do not keep
reference to returned object

* Some nits.  Improve wordings in docstrings and comments, and avoid relying on
sys.getrefcount() in tests.
2017-09-01 18:54:00 +02:00
Victor Stinner 16432beadb bpo-31250, test_asyncio: fix dangling threads (#3252)
* Explicitly call shutdown(wait=True) on executors to wait until all
  threads complete to prevent side effects between tests.
* Fix test_loop_self_reading_exception(): don't mock loop.close().
  Previously, the original close() method was called rather than the
  mock, because how set_event_loop() registered loop.close().
2017-09-01 14:46:06 +02:00
Victor Stinner 6c2feabc5d bpo-31217: Fix regrtest -R for small integer (#3260)
Use a pool of integer objects toprevent false alarm when checking for
memory block leaks. Fill the pool with values in -1000..1000 which
are the most common (reference, memory block, file descriptor)
differences.

Co-Authored-By: Antoine Pitrou <pitrou@free.fr>
2017-09-01 13:05:27 +02:00
Oren Milman 631fdee6e6 bpo-31291: Fixed an assertion failure in zipimport.zipimporter.get_data() (#3226)
if pathname.replace('/', '\\') returns non-string.
2017-08-29 20:40:15 +03:00
Serhiy Storchaka 265fcc5fc2 bpo-31286, bpo-30024: Fixed stack usage in absolute imports with (#3217)
binding a submodule to a name.
2017-08-29 15:47:44 +03:00
Oren Milman ba7d736521 bpo-31243: Fixed PyArg_ParseTuple failure checks. (#3171) 2017-08-29 11:58:27 +03:00
Pier-Yves Lessard a30f6d45ac bpo-30987 - Support for ISO-TP protocol in SocketCAN (#2956)
* Added support for CAN_ISOTP protocol

* Added unit tests for CAN ISOTP

* Updated documentation for ISO-TP protocol

* Removed trailing whitespace in documentation

* Added blurb NEWS.d file

* updated Misc/ACKS

* Fixed broken unit test that was using isotp const outside of skippable section

* Removed dependecy over third party project

* Added implementation for getsockname + unit tests

* Missing newline at end of ACKS file

* Accidentally inserted a type in ACKS file

* Followed tiran changes review #1 recommendations

* Added spaces after comma
2017-08-28 10:32:44 +02:00
Paul Moore 0780bf7578 bpo-31072: Rename the new filter argument for zipapp.create_archive. (#3049)
bpo-31072: Rename the new filter argument for zipapp.create_archive (GH-3049)

* Rename the new argument to "filter"
* Improve tests for the new functionality
* Add a "What's New" entry.
2017-08-26 18:04:12 +01:00
Oren Milman a5b4ea15b6 bpo-31271: Fix an assertion failure in io.TextIOWrapper.write. (#3201) 2017-08-25 21:14:54 +03:00
Gregory P. Smith a3a6df36b6 Skip two tests not intended to pass on Windows. (#3202) 2017-08-24 18:15:02 -07:00
Gregory P. Smith 8621bb5d93 bpo-22536: Set the filename in FileNotFoundError. (#3194)
Have the subprocess module set the filename in the FileNotFoundError
exception raised on POSIX systems when the executable or cwd are missing.
2017-08-24 14:58:25 -07:00
Oren Milman de50360ac2 bpo-29741: Update some methods in the _pyio module to also accept integer types. Patch by Oren Milman. (#560) 2017-08-24 11:33:42 -07:00
Łukasz Langa a5fab17fc1 bpo-23835: Restore legacy defaults= behavior for RawConfigParser (#3191)
The fix for bpo-23835 fixed ConfigParser behavior in defaults= handling.
Unfortunately, it caused a backwards compatibility regression with
RawConfigParser objects which allow for non-string values.

This commit restores the legacy behavior for RawConfigParser only.
2017-08-24 09:43:53 -07:00
Oren Milman bf9075a0c5 bpo-31229: Fixed wrong error messages when too many keyword arguments are received. (#3180) 2017-08-23 21:16:48 +03:00
Martijn Pieters 772d809a63 bpo-31161: only check for parens error for SyntaxError (#3082)
Subclasses such as IndentError and TabError should not have this message
applied.
2017-08-22 13:16:23 -07:00
Victor Stinner 41bbd82b6b bpo-31234: test_threaded_import: fix test_side_effect_import() (#3189)
* Don't leak the module into sys.modules
* Avoid dangling thread
2017-08-22 18:05:32 +02:00
Victor Stinner 830d7d2936 bpo-31234: test_httpservers joins the server thread (#3188) 2017-08-22 18:05:07 +02:00
James Tocknell 44e6ad8734 bpo-23835: Enforce that configparser defaults are strings (#2558)
* Enforce that configparser defaults are strings
* Update test_configparser.py
2017-08-21 15:46:30 -07:00
Victor Stinner 9a83f651f3 Add test_subprocess.test_nonexisting_with_pipes() (#3133)
bpo-30121: Test the Popen failure when Popen was created with pipes.
Create also NONEXISTING_CMD variable in test_subprocess.py.
2017-08-21 23:51:31 +02:00
Victor Stinner 489d91c61d bpo-31249: test_concurrent_futures checks dangling threads (#3167)
Add a BaseTestCase class to test_concurrent_futures to check for
dangling threads and processes on all tests, not only tests using
ExecutorMixin.
2017-08-21 23:24:24 +02:00
Oren Milman 1d1d3e9db8 bpo-28261: Fixed err msgs where PyArg_ParseTuple is used to parse normal tuples. (#3119) 2017-08-20 18:35:36 +03:00
Victor Stinner 3d284c081f bpo-31234: test_threading: fix ref cycle (#3150)
test_bare_raise_in_brand_new_thread() now explicitly breaks a
reference cycle to not leak a dangling thread.
2017-08-19 01:54:42 +02:00
Victor Stinner a7719e27b3 bpo-31235: Fix ResourceWarning in test_logging (#3147) 2017-08-19 00:34:00 +02:00
Victor Stinner 6966960468 bpo-30830: test_logging uses threading_setup/cleanup (#3137)
* bpo-30830: test_logging uses threading_setup/cleanup

Replace @support.reap_threads on some methods with
support.threading_setup() in setUp() and support.threading_cleanup()
in tearDown() in BaseTest.

* bpo-30830: test_logging disables threaded socketserver tests

Disable tests because of socketserver.ThreadingMixIn leaks threads,
whereas leaking threads now makes a test to fail on buildbots.

Disable tests until socketserver is fixed: bpo-31233.

* Skip also setup_via_listener()
2017-08-18 23:47:54 +02:00
Victor Stinner c99d41f9c0 bpo-31234: fork_wait tests now join threads (#3139)
fork_wait.py tests now joins threads, to not leak running threads in
the background.
2017-08-18 23:12:26 +02:00
Segev Finer 4d3851727f bpo-30121: Fix debug assert in subprocess on Windows (#1224)
* bpo-30121: Fix debug assert in subprocess on Windows

This is caused by closing HANDLEs using os.close which is for CRT file
descriptors and not for HANDLEs.

* bpo-30121: Suppress debug assertion in test_subprocess when ran directly
2017-08-18 15:18:13 +02:00
Sanyam Khurana a7c449b8c0 bpo-30721: Add missing '?' to new error message (GH-3131) 2017-08-18 22:18:14 +10:00
Sanyam Khurana 5e2eb35bbe bpo-30721: Show correct syntax hint in Py3 when using Py2 redirection syntax (#2345) 2017-08-18 13:37:36 +03:00
Victor Stinner ad7eaed543 bpo-30871: pythoninfo: more sys, os, time data (#3130)
* bpo-30871: pythoninfo: more sys, os, time data

PythonInfo now converts types other than intger to string by default.

* fix typo
2017-08-18 12:08:47 +02:00
syncosmic fe2b56ab92 bpo-31183: `dis` now handles coroutines & async generators (GH-3077)
Coroutines and async generators use a distinct attribute name for their
code objects, so this updates the `dis` module to correctly disassemble
objects with those attributes.

Due to the increase in the test module length, it also fixes some latent
defects in the tests related to how the displayed source line numbers
are extracted.

https://bugs.python.org/issue31230 is a follow-up issue suggesting we
may want to solve this a different way, by instead giving all these object
types a common `__code__` attribute, avoiding the need for special
casing in the `dis` module.
2017-08-18 12:29:21 +10:00
Victor Stinner f6ebd838f0 bpo-30871: pythoninfo: add expat and _decimal (#3121)
* bpo-30871: pythoninfo: add expat and _decimal

* Remove _decimal.__version__

The string is hardcoded, not really interesting.
2017-08-17 22:13:11 +02:00
Victor Stinner b907abc885 bpo-30871: Add test.pythoninfo (#3075)
* Add Lib/test/pythoninfo.py: script collecting various informations
  about Python to help debugging test failures.
* regrtest: remove sys.hash_info and sys.flags from header.
* Travis CI, Appveyor: run pythoninfo before tests
2017-08-17 16:40:51 +02:00
Adrian Wielgosik 7c17e2304b bpo-24700: Add a fast path for comparing array.array of equal type (#3009) 2017-08-17 14:46:06 +02:00
Antoine Pitrou ee84a60858 bpo-18966: non-daemonic threads created by a multiprocessing.Process should be joined on exit (#3111)
* bpo-18966: non-daemonic threads created by a multiprocessing.Process should be joined on exit

* Add NEWS blurb
2017-08-16 20:53:28 +02:00
Victor Stinner 17657bb945 bpo-31069, test_multiprocessing: Fix dangling process (#3103)
Fix a warning about dangling processes in test_rapid_restart() of
_test_multiprocessing: join the process.
2017-08-16 12:46:04 +02:00
Christian Heimes 7b40cb7293 bpo-30714: ALPN changes for OpenSSL 1.1.0f (#2305)
OpenSSL 1.1.0 to 1.1.0e aborted the handshake when server and client
could not agree on a protocol using ALPN. OpenSSL 1.1.0f changed that.
The most recent version now behaves like OpenSSL 1.0.2 again. The ALPN
callback can pretend to not been set.

See https://github.com/openssl/openssl/pull/3158 for more details

Signed-off-by: Christian Heimes <christian@python.org>
2017-08-15 10:33:43 +02:00
Коренберг Марк d4b93e21c2 bpo-31106: Fix handling of erros in posix_fallocate() and posix_fadvise() (#3000) (#3000) 2017-08-14 06:55:16 -07:00
Victor Stinner 5659a72f48 bpo-31008: Fix asyncio test_wait_for_handle on Windows (#3065) 2017-08-11 01:23:22 +02:00
Victor Stinner 957d0e9b59 bpo-26762: _test_multiprocessing reports dangling (#3064)
_test_multiprocessing now marks the test as ENV_CHANGED on dangling
process or thread.
2017-08-10 17:36:50 +02:00
Victor Stinner b97d99cd7f regrtest: count also env changed as failures in progress (#3061) 2017-08-10 16:19:03 +02:00
Victor Stinner b501147980 Enhance support.reap_children() (#3036)
* reap_children() now sets environment_altered to True to detect bugs
  using python3 -m test --fail-env-changed
* Replace bare "except:" with "except OSError:" in reap_children()
* Write an unit test for reap_children() using a timeout of 60
  seconds
2017-08-10 16:01:47 +02:00
Victor Stinner aa8ec34ad5 bpo-31151: Add socketserver.ForkingMixIn.server_close() (#3057)
* Add socketserver.ForkingMixIn.server_close()

bpo-31151: socketserver.ForkingMixIn.server_close() now waits until
all child processes completed to prevent leaking zombie processes.

* Fix test on Windows which doesn't have ForkingMixIn
2017-08-10 15:28:16 +02:00
Victor Stinner 6c8c2943d9 bpo-31160: test_tempfile: Fix reap_children() warning (#3056)
TestRandomNameSequence.test_process_awareness() now calls
os.waitpid() to avoid leaking a zombie process.
2017-08-10 13:05:06 +02:00
Victor Stinner 7b7c6dcfff bpo-31173: Rewrite WSTOPSIG test of test_subprocess (#3055)
The current test_child_terminated_in_stopped_state() function test
creates a child process which calls ptrace(PTRACE_TRACEME, 0, 0) and
then crash (SIGSEGV). The problem is that calling os.waitpid() in the
parent process is not enough to close the process: the child process
remains alive and so the unit test leaks a child process in a
strange state. Closing the child process requires non-trivial code,
maybe platform specific.

Remove the functional test and replaces it with an unit test which
mocks os.waitpid() using a new _testcapi.W_STOPCODE() function to
test the WIFSTOPPED() path.
2017-08-10 12:37:39 +02:00
Victor Stinner 3ca9f50f96 bpo-31160: test_builtin: don't check waitpid() status (#3050) 2017-08-09 23:08:22 +02:00
Victor Stinner da5e930187 bpo-31160: Fix test_random for zombie process (#3045)
TestModule.test_after_fork() now calls os.waitpid() to read the exit
status of the child process to avoid creating a zombie process.
2017-08-09 17:59:05 +02:00
Victor Stinner e3510d74aa bpo-31160: regrtest now reaps child processes (#3044)
Add a post_test_cleanup() function which currently only calls
support.reap_children().
2017-08-09 17:44:33 +02:00
Victor Stinner 4baca1b0f7 bpo-31160: Fix test_builtin for zombie process (#3043)
PtyTests.run_child() now calls os.waitpid() to read the exit status
of the child process to avoid creating zombie process and leaking
processes in the background.
2017-08-09 17:44:19 +02:00
Jeffrey Rackauckas b811d664de bpo-31072: Add filter to zipapp (#3021)
bpo-31072: Add a filter argument to zipapp.create_archive (GH-3021)

* Add an include_file argument to allow callers to decide which files to include
* Document the new argument
2017-08-09 14:37:17 +01:00
Ammar Askar 88eee44a91 bpo-31150: Wait for child process in test_forkinthread to avoid thread reaped warnings (#3032) 2017-08-09 10:51:43 +02:00
Shane Harvey c4c9866064 bpo-31107: Fix copyreg mangled slot names calculation. (#2989) 2017-08-04 11:45:00 +03:00
Serhiy Storchaka 5075416b8f bpo-30978: str.format_map() now passes key lookup exceptions through. (#2790)
Previously any exception was replaced with a KeyError exception.
2017-08-03 11:45:23 +03:00
Serhiy Storchaka 25e4f779d7 bpo-31071: Avoid masking original TypeError in call with * unpacking (#2957)
when other arguments are passed.
2017-08-03 11:37:15 +03:00
Ville Skyttä 49b2734bf1 Spelling fixes (#2902) 2017-08-03 09:00:59 +03:00
Preston Landers 6ea56d2ebc bpo-31080: Allowed logging.config.fileConfig() to accept both args and kwargs. (GH-2979) 2017-08-02 21:44:28 +01:00
Alexander Mohr de34cbe9cd bpo-31061: fix crash in asyncio speedup module (GH-2966) 2017-08-02 15:31:07 +09:00
Cooper Lees 173ff4a58a bpo-30897: Add is_mount() to pathlib.Path (#2669)
* Add in is_mount() call to pathlib.Path similiar to os.path.ismount(path)
* Add tests for is_mount()
2017-08-01 15:35:45 -07:00
favll adfe3440f6 bpo-31084: QueueHandler now formats messages correctly. (GH-2954) 2017-08-01 19:12:26 +01:00
Alexander Belopolsky 018d353c1c Closes issue bpo-5288: Allow tzinfo objects with sub-minute offsets. (#2896)
* Closes issue bpo-5288: Allow tzinfo objects with sub-minute offsets.

* bpo-5288: Implemented %z formatting of sub-minute offsets.

* bpo-5288: Removed mentions of the whole minute limitation on TZ offsets.

* bpo-5288: Removed one more mention of the whole minute limitation.

Thanks @csabella!

* Fix a formatting error in the docs

* Addressed review comments.

Thanks, @haypo.
2017-07-31 10:26:50 -04:00
Vinay Sajip 2543f50033 bpo-30522: Implemented a method to allow setting a logging.StreamHander's stream. (GH-2921) 2017-07-30 10:41:45 +01:00
Avram Lubkin 78c18a9b9a bpo-30962: Added caching to Logger.isEnabledFor() (GH-2752) 2017-07-30 10:36:33 +01:00
Zackery Spytz ceb93f4540 bpo-31027: Fix test_listcomps failure when run directly (#2939)
Bug appears to be incomplete copy-paste-edit.
2017-07-29 12:05:55 -04:00
Victor Stinner 28ce07ae9e bpo-31066: Fix test_httpservers.test_last_modified() (#2933)
Write the temporary file on disk and then get its modification time.
2017-07-28 18:15:02 +02:00
Victor Stinner cc42c121eb bpo-31067: test_subprocess calls reap_children() (#2931)
test_subprocess now also calls reap_children() in tearDown(), not
only on setUp().
2017-07-28 18:00:22 +02:00
INADA Naoki ba9ddb7eea bpo-29585: fix test fail on macOS Framework build (GH-2928) 2017-07-28 21:28:19 +09:00
Ned Deily c22bd58d93 bpo-28095: Re-enable temporarily disabled part of test_startup_imports on macOS (#2927)
The changes for bpo-29585 eliminate the extra imports on macOS that caused
the original test failure.

This reverts commit 8a2150aae6.
2017-07-28 03:02:10 -04:00
Victor Stinner 12953ffe12 bpo-31044: Skip test_posix.test_makedev() on FreeBSD (#2915)
There is a bug in FreeBSD CURRENT with 64-bit dev_t. Skip the test if
dev_t is larger than 32-bit, until the bug is fixed in FreeBSD
CURRENT.
2017-07-27 16:55:54 +02:00
Victor Stinner fd46561167 bpo-31028: Fix test_pydoc when run directly (#2864)
* bpo-31028: Fix test_pydoc when run directly

Fix get_pydoc_link() of test_pydoc to fix "./python
Lib/test/test_pydoc.py": get the absolute path to __file__ to prevent
relative directories.

* Use realpath() instead of abspath()
2017-07-27 11:21:26 +02:00
INADA Naoki 067931dd95 bpo-30188: fix TypeError in test_nntplib (GH-2892)
fixes regression of 5b4feb7
2017-07-26 23:43:22 +09:00
Utkarsh Upadhyay ede9084476 bpo-31043: fixed test_datetime run twice. (GH-2891) 2017-07-26 19:46:17 +09:00
Utkarsh Upadhyay cc5a65cd90 bpo-30302 Make timedelta.__repr__ more informative. (#1493) 2017-07-25 23:51:33 +02:00
Victor Stinner 830080913c bpo-31034: Reliable signal handler for test_asyncio (#2867)
* bpo-31034: Reliable signal handler for test_asyncio

Don't rely on the current SIGHUP signal handler, make sure that it's
set to the "default" signal handler: SIG_DFL.

* Add comments
2017-07-25 19:19:09 +02:00
Victor Stinner 302bbbe9ba bpo-31009: Fix support.fd_count() on Windows (#2862)
* bpo-31009: Fix support.fd_count() on Windows

On Windows, test.support.fd_count() now calls
msvcrt.CrtSetReportMode() to not kill the process nor log any error
on stderr on os.dup(fd) if the file descriptor is invalid.

* Fix for release mode
2017-07-25 17:45:53 +02:00
Stéphane Wirtel 90addd6d1c bpo-31029: test_tokenize Add missing import unittest (#2865) 2017-07-25 16:33:53 +03:00
Victor Stinner b4c52966c8 bpo-26762: test_multiprocessing close more queues (#2855)
* Close explicitly queues to make sure that we don't leave dangling
  threads
* test_queue_in_process(): remove unused queue
* test_access() joins also the process to fix a random warning
2017-07-25 02:40:55 +02:00
Victor Stinner ffb49408f0 test_multiprocessing detects dangling per test case (#2841)
bpo-26762: test_multiprocessing now detects dangling processes and
threads per test case classes:

* setUpClass()/tearDownClass() of mixin classes now check if
  multiprocessing.process._dangling or threading._dangling was
  modified to detect "dangling" processses and threads.
* ManagerMixin.tearDownClass() now also emits a warning if it still
  has more than one active child process after 5 seconds.
* tearDownModule() now checks for dangling processes and threads
  before sleep 500 ms. And it now only sleeps if there is a least one
  dangling process or thread.
2017-07-25 01:55:54 +02:00
Victor Stinner d7e64d9934 test_multiprocessing: Fix dangling process/thread (#2850)
bpo-26762: Fix more dangling processes and threads in
test_multiprocessing:

* Queue: call close() followed by join_thread()
* Process: call join() or self.addCleanup(p.join)
2017-07-25 00:33:56 +02:00
Nir Soffer c648a93ae3 bpo-30980: Fix double close in asyncore.file_wrapper (#2789)
* bpo-30980: Fix close test to fail

test_close_twice was not considering the fact that file_wrapper is
duping the file descriptor. Closing the original descriptor left the
duped one open, hiding the fact that close protection is not effective.

* bpo-30980: Fix double close protection

Invalidated self.fd before closing, handling correctly the case when
os.close raises.

* bpo-30980: Fix fd leak introduced in the fixed test
2017-07-24 23:18:06 +02:00
Victor Stinner 5b4feb7e86 bpo-30188: test_nntplib catch also ssl.SSLEOFError (#2843)
Catch also ssl.SSLEOFError in NetworkedNNTPTests setUpClass().
EOFError was already catched.
2017-07-24 17:41:02 +02:00
Victor Stinner 06634950c5 bpo-26762: Avoid daemon process in _test_multiprocessing (#2842)
test_level() of _test_multiprocessing._TestLogging now uses regular
processes rather than daemon processes to prevent zombi processes
(to not "leak" processes).
2017-07-24 13:02:20 +02:00
Dong-hee Na 2b1e6e9696 bpo-30119: fix ftplib.FTP.putline() to throw an error for a illegal command (#1214) 2017-07-22 19:20:22 +02:00
Antoine Pitrou 896145d9d2 bpo-26732: fix too many fds in processes started with the "forkserver" method (#2813)
* bpo-26732: fix too many fds in processes started with the "forkserver" method

A child process would inherit as many fds as the number of still-running children.

* Add blurb and test comment
2017-07-22 13:22:54 +02:00
Antoine Pitrou ff92ff5366 Fix test failure without ctypes (#2802) 2017-07-21 13:24:05 +02:00
Gareth Rees 3913bad495 bpo-19896: Add typecodes 'q' and 'Q' to multiprocessing.sharedctypes (#2741)
* bpo-19896: Add typcodes 'q' and 'Q' to multiprocessing.sharedctypes. Patch by Antony Lee.

* Add NEWS entry.

* Slightly tweak NEWS entry

Make it clear this is more of a fix rather than a new feature.
2017-07-21 12:35:33 +02:00
Utkarsh Upadhyay 287c5594ed bpo-30822: Fix testing of datetime module. (#2530) (#2783)
Only C implementation was tested.
2017-07-21 02:14:54 +02:00
Victor Stinner 5b392bbaeb bpo-30822: Exclude tzdata from regrtest --all (#2775)
When running the test suite using --use=all / -u all, exclude tzdata
since it makes test_datetime too slow (15-20 min on some buildbots)
which then times out on some buildbots.

-u tzdata must now be enabled explicitly, -u tzdata or -u all,tzdata,
to run all test_datetime tests.

Fix also regrtest command line parser to allow passing -u
extralargefile to run test_zipfile64.

Travis CI: remove -tzdata. Replace -u all,-tzdata,-cpu with -u all,-cpu since tzdata is now excluded from -u all.
2017-07-20 15:46:32 +02:00
Ammar Askar d81bea6520 Use pythontest.net instead of debian.org in test_urllib2net (GH-2755) 2017-07-19 05:27:24 +03:00
Vitor Pereira ba75af7130 bpo-30794: added kill() method to multiprocessing.Process (#2528)
* bpo-30794: added kill() method to multiprocessing.Process

* Added entries to documentation and NEWS

* Refactored test_terminate and test_kill

* Fix SIGTERM and SIGKILL being used on Windows for the tests

* Added "versionadded" marker to the documentation

* Fix trailing whitespace in doc
2017-07-18 17:34:23 +02:00
Steve Dower 68d663cf85 [bpo-30916] Pre-build OpenSSL and Tcl/Tk for Windows (#2688)
Updates ssl and tkinter projects to use pre-built externals
2017-07-17 11:15:48 +02:00
Serhiy Storchaka 49f6449ef4 bpo-30936: Fix a reference leak in json when fail to sort keys. (#2712) 2017-07-16 07:29:16 +03:00
Nick Coghlan f0b6a261bb bpo-30836: fix test_c_locale_coercion on AIX (GH-2713)
AIX uses iso8859-1 in the C locale, not ASCII

AIX doesn't currently provide any of the locale
coercion locales, but we leave locale coercion
enabled in case one gets added in the future.
2017-07-15 22:51:05 +10:00
Serhiy Storchaka d3aaa2f149 bpo-30911: Add tests for bad boolean arguments for accelerated json (#2690)
encoder and decoder.
2017-07-13 10:14:11 +03:00
Brett Cannon ab025e31ab Fix a spelling mistake and tweak tense of output for test.bisect (GH-2683)
Changed "subbset" to "subset". Also made the sentences read like things were happening instead of stating what the code should do (in other words more descriptive than prescriptive).
2017-07-12 12:04:25 -07:00
Louie Lu 50c9435c9b bpo-30899: Add unittests, 100% coverage, for IDLE's two ConfigParser subclasses. (#2662)
Patch by Louie Lu.
2017-07-12 14:05:32 -04:00
Victor Stinner d1cc037d14 bpo-30908: Fix dangling thread in test_os.TestSendfile (#2680)
tearDown() now clears explicitly the self.server variable to make
sure that the thread is completely cleared when tearDownClass()
checks if all threads have been cleaned up.

Fix the following warning:

$ ./python -m test --fail-env-changed -m test.test_os.TestSendfile.test_keywords -R 3:1 test_os
(...)
Warning -- threading_cleanup() failed to cleanup 0 threads after 3 sec (count: 0, dangling: 2)
(...)
Tests result: ENV CHANGED
2017-07-12 16:05:43 +02:00
Serhiy Storchaka 8a9cd20edc bpo-30876: Relative import from unloaded package now reimports the package (#2639)
instead of failing with SystemError.

Relative import from non-package now fails with ImportError rather than
SystemError.
2017-07-12 06:50:03 +03:00
Serhiy Storchaka 1180e5a518 bpo-30879: os.listdir() and os.scandir() now emit bytes names when (#2634)
called with bytes-like argument.
2017-07-11 06:36:46 +03:00
Sylvain 9648088e6c bpo-30878: Fix error message when keyword arguments are passed (#2635)
to staticmethod() and classmethod().
2017-07-09 06:45:06 +03:00
Nir Soffer aa6a4d6ed8 bpo-29854: Skip history-size test on older readline (GH-2621)
Turns out that history-size was added in readline 6.0. This explain why
this tests fail on FreeBSD when using readline 5.2. We skip now the
history size if readline does not support it.

See https://cnswww.cns.cwru.edu/php/chet/readline/CHANGES for
details.
2017-07-08 17:34:27 +03:00
Victor Stinner 1881befb90 bpo-29854: test_readline logs versions (#2619)
* test_readline logs the versions of libreadline when run in verbose
  mode
* Add also readline._READLINE_LIBRARY_VERSION
2017-07-07 16:06:58 +02:00
Nir Soffer fae8f4a9cb bpo-29854: Fix segfault in call_readline() (GH-728)
If history-length is set in .inputrc, and the history file is double the
history size (or more), history_get(N) returns NULL, and python
segfaults. Fix that by checking for NULL return value.

It seems that the root cause is incorrect handling of bigger history in
readline, but Python should not segfault even if readline returns
unexpected value.

This issue affects only GNU readline. When using libedit emulation
system history size option does not work.
2017-07-07 09:10:46 +03:00
Gregory P. Smith 529746c905 Make test_shutil test_disk_usage not depend on the cwd fs (#2597)
Make test_shutil test_disk_usage not depend on the current working directory's filesystem.
2017-07-06 17:11:27 -07:00
Serhiy Storchaka b4baacee1a bpo-30814: Fixed a race condition when import a submodule from a package. (#2580) 2017-07-06 08:09:03 +03:00
Yury Selivanov 833a3b0d37 bpo-30828: Fix out of bounds write in `asyncio.CFuture.remove_done_callback() (#2569) 2017-07-05 13:32:03 -04:00
Victor Stinner 8207c17486 Revert "bpo-30822: Fix testing of datetime module." (#2588)
* Revert "bpo-30854: Fix compile error when --without-threads (#2581)"

This reverts commit 0c31163093.

* Revert "NEWS for 30777 (#2576)"

This reverts commit aaa917ff38.

* Revert "bpo-21624: IDLE -- minor htest fixes (#2575)"

This reverts commit 2000150c56.

* Revert "bpo-30777: IDLE: configdialog - add docstrings and improve comments (#2440)"

This reverts commit 7eb5883ac5.

* Revert "bpo-30319: socket.close() now ignores ECONNRESET (#2565)"

This reverts commit 67e1478dba.

* Revert "bpo-30789: Use a single memory block for co_extra. (#2555)"

This reverts commit 378ebb6578.

* Revert "bpo-30845: Enhance test_concurrent_futures cleanup (#2564)"

This reverts commit 3df9dec425.

* Revert "bpo-29293: multiprocessing.Condition.notify() lacks parameter `n` (#2480)"

This reverts commit 48350412b7.

* Revert "Remove outdated FOX from GUI FAQ (GH-2538)"

This reverts commit d3ed2877a7.

* Revert "bpo-6691: Pyclbr now reports nested classes and functions. (#2503)"

This reverts commit 246ff3bd00.

* Revert "bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make (#1955)"

This reverts commit 6969eaf468.

* Revert "bpo-30832: Remove own implementation for thread-local storage (#2537)"

This reverts commit aa0aa0492c.

* Revert "bpo-30764: Fix regrtest --fail-env-changed --forever (#2536)"

This reverts commit 5e87592fd1.

* Revert "bpo-30822: Deduplicate ZoneInfoTest classes in test_datetime. (#2534)"

This reverts commit 34b54873b5.

* Revert "bpo-30822: Fix testing of datetime module. (#2530)"

This reverts commit 98b6bc3bf7.
2017-07-05 15:44:52 +02:00
Victor Stinner 3df9dec425 bpo-30845: Enhance test_concurrent_futures cleanup (#2564)
* bpo-30845: reap_children() now logs warnings

* bpo-30845: Enhance test_concurrent_futures cleanup

In setUp() and tearDown() methods of test_concurrent_futures tests,
make sure that tests don't leak threads nor processes. Clear
explicitly the reference to the executor to make it that it's
destroyed (to prevent "dangling threads" warning).
2017-07-04 13:14:04 +02:00
Antoine Pitrou 48350412b7 bpo-29293: multiprocessing.Condition.notify() lacks parameter `n` (#2480)
* bpo-29293: multiprocessing.Condition.notify() lacks parameter `n`

* Add NEWS blurb
2017-07-04 08:59:22 +02:00
csabella 246ff3bd00 bpo-6691: Pyclbr now reports nested classes and functions. (#2503)
Original patch by Guilherme Polo.  Revisions by Cheryl Sabella.
2017-07-03 21:31:25 -04:00
Victor Stinner 5e87592fd1 bpo-30764: Fix regrtest --fail-env-changed --forever (#2536)
--forever now stops if a fail changes the environment.
2017-07-03 11:15:58 +02:00
Serhiy Storchaka 34b54873b5 bpo-30822: Deduplicate ZoneInfoTest classes in test_datetime. (#2534) 2017-07-02 22:36:12 +03:00
Utkarsh Upadhyay 98b6bc3bf7 bpo-30822: Fix testing of datetime module. (#2530)
Only C implementation was tested.
2017-07-02 15:46:04 +03:00
Osvaldo Santana Neto 8a8d28501f bpo-30441: Fix bug when modifying os.environ while iterating over it (#2409) 2017-07-01 20:34:45 +03:00
xdegaye 85f643023f bpo-30695: Add set_nomemory(start, stop) to _testcapi (GH-2406) 2017-07-01 14:14:45 +02:00
Victor Stinner 73528640ff bpo-30818: test_ftplib calls asyncore.close_all() (#2514)
Always clear asyncore socket map using
asyncore.close_all(ignore_all=True) in tearDown() method.

This change should fix this warning:

Warning -- asyncore.socket_map was modified by test_ftplib
  Before: {}
  After:  {4: <test.test_ftplib.DummyTLS_FTPServer 127.0.0.1:0 at 0x805feccf0>}
2017-06-30 17:36:57 +02:00
Victor Stinner 45dba3af50 test_urllib2_localnet: clear server variable (#2510)
Set the server attribute to None in cleanup to avoid dangling
threads.
2017-06-30 17:04:48 +02:00
Victor Stinner 7eebeb8fb8 bpo-30812: Fix test_warnings, restore _showwarnmsg (#2504)
bpo-26568, bpo-30812: Fix test_showwarnmsg_missing(): restore the
attribute after removing it.
2017-06-30 12:58:46 +02:00
Victor Stinner b903067462 bpo-30280: Cleanup threads in ayncio tests (#2501)
* bpo-30280: asyncio now cleans up threads

asyncio base TestCase now uses threading_setup() and
threading_cleanup() of test.support to cleanup threads.

* asyncio: Fix TestBaseSelectorEventLoop cleanup

bpo-30280: TestBaseSelectorEventLoop of
test.test_asyncio.test_selector_events now correctly closes the event
loop: cleanup its executor to not leak threads.

Don't override the close() method of the event loop, only override
the_close_self_pipe() method.
2017-06-30 11:12:33 +02:00
Victor Stinner 21a0a6c9f8 threading_cleanup() failure marks test as ENV_CHANGED (#2500)
If threading_cleanup() fails to cleanup threads, set a a new
support.environment_altered flag to true, flag uses by save_env which
is used by regrtest to check if a test altered the environment. At
the end, the test file fails with ENV_CHANGED instead of SUCCESS, to
report that it altered the environment.
2017-06-30 10:59:52 +02:00
Antoine Pitrou 729780a810 bpo-30807: signal.setitimer() may disable the timer by mistake (#2493)
* bpo-30807: signal.setitimer() may disable the timer by mistake

* Add NEWS blurb
2017-06-30 10:01:05 +02:00
Nick Coghlan 18974c35ad bpo-30647: Check nl_langinfo(CODESET) in locale coercion (GH-2374)
- On some versions of FreeBSD, setting the "UTF-8" locale
  succeeds, but a subsequent "nl_langinfo(CODESET)" fails
- adding a check for this in the coercion logic means that
  coercion will happen on systems where this check succeeds,
  and will be skipped otherwise
- that way CPython should automatically adapt to changes in
  platform behaviour, rather than needing a new release to
  enable coercion at build time
- this also allows UTF-8 to be re-enabled as a coercion
  target, restoring the locale coercion behaviour on Mac OS X
2017-06-30 00:48:14 +10:00
Antoine Pitrou f7d090c165 bpo-30796: Fix failures in signal delivery stress test (#2488)
* bpo-30796: Fix failures in signal delivery stress test

setitimer() can have a poor minimum resolution on some machines,
this would make the test reach its deadline (and a stray signal
could then kill a subsequent test).

* Make sure to clear the itimer after the test
2017-06-29 16:40:14 +02:00
Victor Stinner beeca6e1e5 bpo-30776: regrtest: reduce memleak false positive (#2484)
Only report a leak if each run leaks at least one memory block.
2017-06-29 10:32:49 +02:00
Antoine Pitrou c08177a1cc bpo-30703: Improve signal delivery (#2415)
* Improve signal delivery

Avoid using Py_AddPendingCall from signal handler, to avoid calling signal-unsafe functions.

* Remove unused function

* Improve comments

* Add stress test

* Adapt for --without-threads

* Add second stress test

* Add NEWS blurb

* Address comments @haypo
2017-06-28 23:29:29 +02:00
INADA Naoki a8f8d5b4bd bpo-29585: optimize site.py startup time (GH-136)
Avoid importing `sysconfig` from `site` by copying minimum code.
Python startup is 5% faster on Linux and 30% faster on macOS
2017-06-29 00:31:53 +09:00
Antoine Pitrou 79d37ae979 Clear potential ref cycle between Process and Process target (#2470)
* Clear potential ref cycle between Process and Process target

Besides Process.join() not being called, this was an indirect cause of bpo-30775.
The threading module already does this.

* Add issue reference
2017-06-28 12:29:08 +02:00