Commit Graph

25046 Commits

Author SHA1 Message Date
Joannah Nanjekye 92b8322e7e bpo-35674: Add os.posix_spawnp() (GH-11554)
Add a new os.posix_spawnp() function.
2019-01-16 14:29:26 +01:00
Victor Stinner 9daecf37a5
bpo-35537: subprocess uses os.posix_spawn in some cases (GH-11452)
The subprocess module can now use the os.posix_spawn() function
in some cases for better performance. Currently, it is only used on macOS
and Linux (using glibc 2.24 or newer) if all these conditions are met:

* executable path contains a directory
* close_fds=False
* preexec_fn, pass_fds, cwd, stdin, stdout, stderr
  and start_new_session parameters are not set

Co-authored-by: Joannah Nanjekye <nanjekyejoannah@gmail.com>
2019-01-16 00:02:35 +01:00
Christian Heimes a37f52436f bpo-35746: Fix segfault in ssl's cert parser (GH-11569)
Fix a NULL pointer deref in ssl module. The cert parser did not handle CRL
distribution points with empty DP or URI correctly. A malicious or buggy
certificate can result into segfault.

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



https://bugs.python.org/issue35746
2019-01-15 14:47:42 -08:00
Serhiy Storchaka 3607ef43c4
bpo-35742: Fix test_envar_unimportable in test_builtin. (GH-11561)
Handle the case of an empty module name in PYTHONBREAKPOINT.

Fixes a regression introduced in bpo-34756.
2019-01-15 13:26:38 +02:00
Serhiy Storchaka efcf82f945
bpo-35619: Improve support of custom data descriptors in help() and pydoc. (GH-11366) 2019-01-15 10:53:18 +02:00
MichaelSaah 454b3d4ea2 bpo-35066: _dateime.datetime.strftime copies trailing '%' (GH-10692)
Previously, calling the strftime() method on a datetime object with a
trailing '%' in the format string would result in an exception. However,
this only occured when the datetime C module was being used; the python
implementation did not match this behavior. Datetime is now PEP-399
compliant, and will not throw an exception on a trailing '%'.
2019-01-14 11:23:39 +01:00
Anthony Sottile 995d9b9297 bpo-16806: Fix `lineno` and `col_offset` for multi-line string tokens (GH-10021) 2019-01-13 13:05:13 +09:00
Serhiy Storchaka f1ec3cefad
bpo-35634: Raise an error when first passed kwargs contains duplicated keys. (GH-11438) 2019-01-12 10:12:24 +02:00
Serhiy Storchaka 58159ef856
bpo-35494: Improve syntax error messages for unbalanced parentheses in f-string. (GH-11161) 2019-01-12 09:46:50 +02:00
Serhiy Storchaka 44cc4822bb
bpo-33817: Fix _PyBytes_Resize() for empty bytes object. (GH-11516)
Add also tests for PyUnicode_FromFormat() and PyBytes_FromFormat()
with empty result.
2019-01-12 09:22:29 +02:00
Ammar Askar cb08a71c5c bpo-34838: Use subclass_of for math.dist. (GH-9659)
Argument clinic now generates fast inline code for
positional parsing, so the manually implemented type
check in math.dist can be removed.
2019-01-12 08:23:41 +02:00
Serhiy Storchaka 2a39d251f0
bpo-35582: Argument Clinic: Optimize the "all boring objects" case. (GH-11520)
Use _PyArg_CheckPositional() and inlined code instead of
PyArg_UnpackTuple() and _PyArg_UnpackStack() if all parameters
are positional and use the "object" converter.
2019-01-11 18:01:42 +02:00
Serhiy Storchaka 4fa9591025
bpo-35582: Argument Clinic: inline parsing code for positional parameters. (GH-11313) 2019-01-11 16:01:14 +02:00
Pablo Galindo c5dc60ea85 bpo-24746: Fix doctest failures when running the testsuite with -R (#11501) 2019-01-10 06:29:40 -08:00
Sanyam Khurana cbb1645993 bpo-24746: Avoid stripping trailing whitespace in doctest fancy diff (#10639) 2019-01-09 05:38:38 -08:00
Vladimir Matveev c24c6c2c93 bpo-35568: add 'raise_signal' function (GH-11335)
As in title, expose C `raise` function as `raise_function` in `signal` module. Also drop existing `raise_signal` in `_testcapi` module and replace all usages with new function.


https://bugs.python.org/issue35568
2019-01-08 01:58:25 -08:00
Victor Stinner ddd7c422fd
bpo-33717: pythoninfo logs information of all clocks (GH-11460)
test.pythoninfo now logs information of all clocks, not only time.time() and
time.perf_counter().
2019-01-08 01:27:27 +01:00
Victor Stinner df8e1fb4e3
bpo-32710: test_asyncio: test_sendfile reset policy (GH-11461)
test_asyncio/test_sendfile.py now resets the event loop policy using
tearDownModule() as done in other tests, to prevent a warning when
running tests on Windows.
2019-01-07 23:55:57 +01:00
Raymond Hettinger 2d53bed79c
bpo-35664: Optimize operator.itemgetter (GH-11435) 2019-01-07 09:38:41 -07:00
Xtreak 3f7983a25a bpo-35560: Remove assertion from format(float, "n") (GH-11288)
Fix an assertion error in format() in debug build for floating point
formatting with "n" format, zero padding and small width. Release build is
not impacted. Patch by Karthikeyan Singaravelan.
2019-01-07 16:09:14 +01:00
cclauss a0bb51e44c test_threading_local: add missing "import sys" (GH-8049) 2019-01-06 23:10:55 +01:00
Anthony Shaw 83da926b89 bpo-35488: Add tests for ** glob matching in pathlib (GH-11171) 2019-01-06 12:31:29 -08:00
Vladimir Matveev 67ba547cf0 bpo-23057: Use 'raise' to emulate ctrl-c in proactor tests (#11274) 2019-01-05 22:44:59 +02:00
Serhiy Storchaka 830ddc74c4
Revert "bpo-35603: Escape table header of make_table output that can cause potential XSS. (GH-11341)" (GH-11356)
This reverts commit 78de01198b.
2019-01-02 14:49:25 +02:00
Stefan Behnel 3a374e0c5a bpo-35588: Speed up mod, divmod and floordiv operations for Fraction type (#11322)
* bpo-35588: Implement mod and divmod operations for Fraction type by spelling out the numerator/denominator calculation, instead of instantiating and normalising Fractions along the way. This speeds up '%' and divmod() by 2-3x.

* bpo-35588: Also reimplement Fraction.__floordiv__() using integer operations to make it ~4x faster.

* Improve code formatting.

Co-Authored-By: scoder <stefan_ml@behnel.de>

* bpo-35588: Fix return type of divmod(): the result of the integer division should be an integer.

* bpo-35588: Further specialise __mod__() and inline the original helper function _flat_divmod() since it's no longer reused.

* bpo-35588: Add some tests with large numerators and/or denominators.

* bpo-35588: Use builtin "divmod()" function for implementing __divmod__() in order to simplify the implementation, even though performance results are mixed.

* Rremove accidentally added empty line.

* bpo-35588: Try to provide more informative output on test failures.

* bpo-35588: Improve wording in News entry.

Co-Authored-By: scoder <stefan_ml@behnel.de>

* Remove stray space.
2019-01-02 14:22:06 +02:00
Serhiy Storchaka 052b2dfdc9
bpo-32492: Tweak _collections._tuplegetter. (GH-11367)
* Replace the docstrings cache with sys.intern().
* Improve tests.
* Unify names of tp_descr_get and tp_descr_set functions.
2018-12-31 14:15:16 +02:00
sth 7108aab49c Fix typo in test module usage message (GH-11374)
A minor typo in the output of `python -m test -h`.
A space was missing in between two words.
howmuch -> how much
2018-12-30 21:41:39 -08:00
Sanyam Khurana b539cef31c bpo-35614: Fix pydoc help() on metaclasses (#11357) 2018-12-31 15:14:47 +10:00
Gregory P. Smith e5796c42c6
bpo-35214: Skip test_io tests that'd cause a huge malloc under msan (#11385)
* skip test_constructor under msan.

* fix the others as well.

* reuse existing related news entry.

* typo fix
2018-12-30 20:17:57 -08:00
Gregory P. Smith d6f45b23a5
Fix typos in test_faulthandler skipIfs for ubsan. (GH-11386) 2018-12-30 20:15:41 -08:00
Gregory P. Smith 30e023256a
Cleanup test_faulthandler sanitizer skip logic. (GH-11381)
Also skip the same tests when using the undefined behavior sanitizer
as they much with the output.

Updates a regex in another test to use multi-line mode so that the ubsan
buildbot should pass again rather than also adding a skip to that one.
2018-12-30 18:09:26 -08:00
Gregory P. Smith b474e6774d
bpo-35214: MSan workarounds for socket, time, and test_faulthandler. (GH-11375)
Add Clang Memory Sanitizer build instrumentation to work around
false positives from the socket and time modules as well as skipping
a couple test_faulthandler tests.
2018-12-30 17:05:36 -08:00
Pablo Galindo 3f5fc70c62 bpo-32492: 1.6x speed up in namedtuple attribute access using C fast-path (#10495)
* bpo-32492: 2.5x speed up in namedtuple attribute access using C fast path

* Add News entry

* fixup! bpo-32492: 2.5x speed up in namedtuple attribute access using C fast path

* Check for tuple in the __get__ of the new descriptor and don't cache the descriptor itself

* Don't inherit from property. Implement GC methods to handle __doc__

* Add a test for the docstring substitution in descriptors

* Update NEWS entry to reflect time against 3.7 branch

* Simplify implementation with argument clinic, better error messages, only __new__

* Use positional-only parameters for the __new__

* Use PyTuple_GET_SIZE and PyTuple_GET_ITEM to tighter the implementation of tuplegetterdescr_get

* Implement __set__ to make tuplegetter a data descriptor

* Use Py_INCREF now that we inline PyTuple_GetItem

* Apply the valid_index() function, saving one test

* Move Py_None test out of the critical path.
2018-12-30 01:24:03 -08:00
Pablo Galindo d51324a2f5
bpo-35602: Make sure the transport is always closed in SelectorEventLoopUnixSockSendfileTests (GH-11338)
There is a race condition in SelectorEventLoopUnixSockSendfileTests that causes the prepare() method return a non connected server protocol, making the cleanup() method skips the correct handling of the transport. This commit makes prepare() always return a connected server protocol that can always be cleaned up correctly.
2018-12-29 19:18:38 +00:00
Xtreak 78de01198b bpo-35603: Escape table header of make_table output that can cause potential XSS. (GH-11341) 2018-12-29 10:53:14 +02:00
Pablo Galindo 1f511e1af0
Make sure file object is close if socket.create_connection fails (GH-11334)
The problem affects _testWithTimeoutTriggeredSend in test_socket.py.
2018-12-29 01:42:16 +00:00
Pablo Galindo 5471420faa
bpo-35601: Alleviate race condition when waiting for SIGALRM in test_asyncio (GH-11337)
There is a race condition regarding signal delivery in test_signal_handling_args for
test_asyncio.test_events.KqueueEventLoopTests. The signal can be received at any moment outside the time window provided in the test. The fix is to wait for the signal to be received instead with a bigger timeout.
2018-12-29 01:40:21 +00:00
jab 9e00d9e88f bpo-20849: add dirs_exist_ok arg to shutil.copytree (patch by Josh Bronson) 2018-12-28 19:03:40 +01:00
Michael Felt e2926b7248 bpo-34373: fix test_mktime and test_pthread_getcpuclickid tests on AIX (GH-8726)
* Fix test_mktime on AIX by adding code to get mktime to behave the
  same way as it does on other *nix systems
* Fix test_pthread_getcpuclickid in AIX by adjusting the test case
  expectations when running on AIX in 32-bit mode

Patch by Michael Felt.
2018-12-28 23:57:37 +10:00
Michael Felt 259c159fc1 bpo-34897: avoid distutils test error when CXX is not set (GH-9706)
Depending on system config, a missing candidate compiler name may be
reported as the empty string rather than as None, so adjust the test
helper accordingly.
2018-12-26 15:45:19 +10:00
Michael Felt 5661459f5f bpo-11192: Skip unsupported cases in test_socket on AIX (GH-8954)
* use platform.system() as runtime test, rather than sys.platform() build-time test
* IPv6 zone id support on AIX is limited to inet_pton6_zone(), so skip related
  getaddrinfo() and getnameinfo() tests as not supported
2018-12-26 13:34:37 +10:00
Raymond Hettinger b6af23ebf9
Revert "bpo-35565: Add detail to assertion failure message in wsgiref" (GH-11317)
* Revert part of "bpo-35565:  Remove incorrect test and one that wasn't needed for the fix.
2018-12-25 15:59:07 -08:00
Cheryl Sabella 5ef4fc241a bpo-35565: Add detail to assertion failure message in wsgiref (GH-11293) 2018-12-25 15:19:11 -08:00
Serhiy Storchaka 32d96a2b5b
bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689) 2018-12-25 13:23:47 +02:00
Serhiy Storchaka 65ce60aef1
bpo-20180: Simplify char_converter in Argument Clinic. (GH-9828)
Fix also handling non-ascii default values.
2018-12-25 11:10:05 +02:00
Serhiy Storchaka 837c7dc1ed
bpo-35578: Add an example file for testing Argument Clinic converters. (GH-11306) 2018-12-25 10:17:28 +02:00
leodema 63d152232e bpo-30561: Sync-up expovariate() and gammavariate code (GH-1934) 2018-12-23 22:54:25 -08:00
Serhiy Storchaka 8ac658114d
bpo-30455: Generate all token related code and docs from Grammar/Tokens. (GH-10370)
"Include/token.h", "Lib/token.py" (containing now some data moved from
"Lib/tokenize.py") and new files "Parser/token.c" (containing the code
moved from "Parser/tokenizer.c") and "Doc/library/token-list.inc" (included
in "Doc/library/token.rst") are now generated from "Grammar/Tokens" by
"Tools/scripts/generate_token.py". The script overwrites files only if
needed and can be used on the read-only sources tree.

"Lib/symbol.py" is now generated by "Tools/scripts/generate_symbol_py.py"
instead of been executable itself.

Added new make targets "regen-token" and "regen-symbol" which are now
dependencies of "regen-all".

The documentation contains now strings for operators and punctuation tokens.
2018-12-22 11:18:40 +02:00
Xtreak 6326278e8a bpo-34193: Fix pluralization in getargs.c and test cases. (GH-8438) 2018-12-21 16:45:13 +02:00
Victor Stinner 9a8d1d7562
bpo-35424: emit ResourceWarning at multiprocessing.Pool destruction (GH-10974)
multiprocessing.Pool destructor now emits ResourceWarning
if the pool is still running.
2018-12-20 20:33:51 +01:00
Serhiy Storchaka b13a20f507
bpo-5438: Update memory requirements and optimize test_bigmem.py. (GH-11123) 2018-12-20 09:34:51 +02:00
stratakis cf10a750f4 bpo-35257: Avoid leaking LTO linker flags into distutils (GH-10900)
When compiling 3rd party C extensions, the linker flags used by the
compiler for the interpreter and the stdlib modules, will get
leaked into distutils. In order to avoid that, the PY_CORE_LDFLAGS
and PY_LDFLAGS_NODIST are introduced to keep those flags separated.
2018-12-19 18:19:01 +01:00
Victor Stinner 6cdce3ddef
bpo-35424: Fix test_multiprocessing_main_handling (GH-11223)
Fix test_multiprocessing_main_handling: use multiprocessing.Pool with
a context manager and then explicitly join the pool.
2018-12-18 23:54:33 +01:00
Victor Stinner 05c9d31eb6
bpo-31731: Fix test_io.check_interrupted_write() (GH-11225)
Fix a race condition in check_interrupted_write() of test_io:
create directly the thread with SIGALRM signal blocked,
rather than blocking the signal later from the thread. Previously, it
was possible that the thread gets the signal before the signal is
blocked.
2018-12-18 23:52:39 +01:00
Vladimir Matveev b5c8cfa1da bpo-23057: add loop self socket as wakeup fd for signals (#11135) 2018-12-18 23:56:17 +02:00
Serhiy Storchaka d2a75c6783
bpo-35502: Fix reference leaks in ElementTree.TreeBuilder. (GH-11170) 2018-12-18 22:29:14 +02:00
Victor Stinner 62a68b762a
bpo-31784: Use time.time_ns() in uuid.uuid1() (GH-11189)
uuid.uuid1() now calls time.time_ns() rather than
int(time.time() * 1e9). Replace also int(nanoseconds/100)
with nanoseconds // 100. Add an unit test.
2018-12-18 11:45:13 +01:00
Victor Stinner 1dd035954b
bpo-35519: Rename test.bisect to test.bisect_cmd (GH-11200)
Rename test.bisect module to test.bisect_cmd to avoid conflict with
bisect module when running directly a test like
"./python Lib/test/test_xmlrpc.py".
2018-12-17 22:06:10 +01:00
Serhiy Storchaka 94cf308ee2
bpo-33306: Improve SyntaxError messages for unbalanced parentheses. (GH-6516) 2018-12-17 17:34:14 +02:00
Zackery Spytz 842acaab13 bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175) 2018-12-17 16:52:45 +02:00
Serhiy Storchaka e2af34fcf8
bpo-35504: Fix a SystemError when delete the characters_written attribute of an OSError. (GH-11172) 2018-12-17 16:43:14 +02:00
Vajrasky Kok fae95874b7 bpo-18799: Resurrect test_404 in test_xmlrpc. (GH-11196) 2018-12-17 16:16:24 +02:00
Dima Tisnek e991270363 bpo-35415: validate fileno argument to socket.socket (GH-10917)
https://bugs.python.org/issue35415
2018-12-17 05:07:55 -08:00
Victor Stinner 8db5b54463
bpo-35513, unittest: TextTestRunner uses time.perf_counter() (GH-11180)
TextTestRunner of unittest.runner now uses time.perf_counter() rather
than time.time() to measure the execution time of a test: time.time()
can go backwards, whereas time.perf_counter() is monotonic.

Similar change made in libregrtest, pprint and random.
2018-12-17 11:30:34 +01:00
Victor Stinner 2cf4c202ff
bpo-35513: Replace time.time() with time.monotonic() in tests (GH-11182)
Replace time.time() with time.monotonic() in tests to measure time
delta.

test_zipfile64: display progress every minute (60 secs) rather than
every 5 minutes (5*60 seconds).
2018-12-17 09:36:36 +01:00
Victor Stinner d7538dd5e3
bpo-35471: Remove the macpath module (GH-11129)
Python 2.4 dropped MacOS 9 support. The macpath module was deprecated
in Python 3.7. This change removes it.
2018-12-14 13:37:26 +01:00
Victor Stinner 3a8f4fef4a
bpo-34279: regrtest consider that skipped tests are ran (GH-11132)
bpo-34279, bpo-35412: support.run_unittest() no longer raises
TestDidNotRun if a test result contains skipped tests. The
exception is now only raised if no test have been run and no test
have been skipped.
2018-12-14 13:06:50 +01:00
Victor Stinner 08c2ba0717
bpo-35477: multiprocessing.Pool.__enter__() fails if called twice (GH-11134)
multiprocessing.Pool.__enter__() now fails if the pool is not
running: "with pool:" fails if used more than once.
2018-12-13 02:15:30 +01:00
Victor Stinner 502fe19b10
bpo-35412: Add testcase to test_future4 (GH-11131)
Add testcase to test_future4: check unicode literal.
2018-12-12 18:38:34 +01:00
Xiang Zhang 4fb0b8bc25
bpo-33106: change dbm key deletion error for readonly file from KeyError to dbm.error (#6295) 2018-12-12 20:46:55 +08:00
Andrew Svetlov 5344501ad1
bpo-35394: Add empty slots to abstract asyncio protocols (#10889)
* bpo-35394: Add empty slots to abstract asyncio protocols

* Add missing test file
2018-12-11 19:07:05 +02:00
Pablo Galindo 2ab2afd387
bpo-35426: Eliminate race condition in test_interprocess_signal (GH-11087)
The test only except SIGUSR1Exception inside wait_signal(), but the signal can be sent during subprocess_send_signal() call.
2018-12-11 11:32:12 +00:00
Pablo Galindo a932d0b496
bpo-35412: Skip test_multiprocessing_fork and test_multiprocessing_forkserver on Windows (GH-11086)
Forkserver and fork are not available on Windows and therefore these test must be skipped.
2018-12-11 11:31:16 +00:00
Victor Stinner dc525f4315
bpo-35458: Fix test_shutil.test_disk_usage() (GH-11111)
The following test fails if a different process creates or removes
a file on the same disk partition between the two lines:

    usage = shutil.disk_usage(os.path.dirname(__file__))
    self.assertEqual(usage, shutil.disk_usage(__file__))

Only test that disk_usage() succeed on a filename, but don't check
the result. Add also tests on the fields type (must be int).
2018-12-11 12:05:21 +01:00
Steve Dower 0cd6391fd8
bpo-34977: Add Windows App Store package (GH-11027)
Also adds the PC/layout script for generating layouts on Windows.
2018-12-10 18:52:57 -08:00
Steve Dower 1c3de541e6
bpo-34977: Use venv redirector instead of original python.exe on Windows (GH-11029) 2018-12-10 08:11:21 -08:00
Christian Heimes 2eb6ad8578 bpo-35050: AF_ALG length check off-by-one error (GH-10058)
The length check for AF_ALG salg_name and salg_type had a off-by-one
error. The code assumed that both values are not necessarily NULL
terminated. However the Kernel code for alg_bind() ensures that the last
byte of both strings are NULL terminated.

Signed-off-by: Christian Heimes <christian@python.org>
2018-12-10 11:22:37 +01:00
Victor Stinner 8e04186889
bpo-35052: Fix handler on xml.dom.minidom.cloneNode() (GH-11061)
Fix xml.dom.minidom cloneNode() on a document with an entity: pass
the correct arguments to the user data handler of an entity (fix an
old copy/paste mistake).

Bug spotted and fix proposed by Charalampos Stratakis, initial
reproducer written by Petr Viktorin.

Co-Authored-By: Charalampos Stratakis <cstratak@redhat.com>
Co-Authored-By: Petr Viktorin <encukou@gmail.com>
2018-12-10 11:12:53 +01:00
Ned Deily ac218bc5db
bpo-33725: skip test_multiprocessing_fork on macOS (GH-11043) 2018-12-09 01:50:15 -05:00
Victor Stinner cb0b78a070
Revert "bpo-34977: Add Windows App Store package (GH-10245)" (GH-11019)
This reverts commit 468a15aaf9.
2018-12-07 12:57:43 +01:00
Serhiy Storchaka 8452ca15f4
bpo-22005: Fixed unpickling instances of datetime classes pickled by Python 2. (GH-11017)
encoding='latin1' should be used for successful decoding.
2018-12-07 13:42:10 +02:00
Victor Stinner 3a521f0b61
bpo-35346, platform: replace os.popen() with subprocess (GH-10786)
Replace os.popen() with subprocess.check_output() in the platform module:

* platform.uname() (its _syscmd_ver() helper function) now redirects
  stderr to DEVNULL.
* Remove platform.DEV_NULL.
* _syscmd_uname() and _syscmd_file() no longer catch AttributeError.
  The "except AttributeError:" was only needed in Python 2, when
  os.popen() was not always available. In Python 3,
  subprocess.check_output() is always available.
2018-12-07 11:10:33 +01:00
Steve Dower 468a15aaf9
bpo-34977: Add Windows App Store package (GH-10245) 2018-12-06 21:09:20 -08:00
Serhiy Storchaka 42b1d6127b
bpo-33023: Fix NotImplemented to NotImplementedError. (GH-10934) 2018-12-06 22:36:55 +02:00
Victor Stinner 0644b33821
bpo-35363: test_eintr uses print(flush=True) (GH-10990) 2018-12-06 14:16:21 +01:00
Victor Stinner 388c8c208d
bpo-35424: test_multiprocessing: join 3 pools (GH-10986)
Join 3 pools in these tests:

* test.test_multiprocessing_spawn.WithProcessesTestPool.test_context
* test.test_multiprocessing_spawn.WithProcessesTestPool.test_traceback
2018-12-06 11:56:52 +01:00
Victor Stinner 9dfc754d61
Revert "bpo-34172: multiprocessing.Pool leaks resources after being deleted (GH-8450)" (GH-10971)
This reverts commit 97bfe8d3eb.
2018-12-06 08:51:47 +01:00
native-api 8752dfbd1f bpo-33709: test_ntpath and test_posixpath fail in Windows with ACP!=1252. (GH-7278) 2018-12-06 09:04:35 +02:00
Victor Stinner aa8ae904ad
bpo-35363: test_eintr runs eintr_tester.py in verbose mode (GH-10965)
Moreover, "python3 -m test test_eintr -v" now avoids redirecting
stdout/stderr to a pipe, the child process inherits stdout/stderr
from the parent.
2018-12-06 00:18:30 +01:00
Victor Stinner 848acf7249
bpo-35389: test.pythoninfo logs platform.libc_ver (GH-10951) 2018-12-05 23:21:54 +01:00
Victor Stinner ea0ca218b0
bpo-35344: platform.platform() uses mac_ver() on macOS (GH-10780)
On macOS, platform.platform() now uses mac_ver(), if it returns a
non-empty release string, to get the macOS version rather than darwin
version.
2018-12-05 22:41:52 +01:00
Alex H 54fd45505b bpo-34185: Fix test module collision in test_bdb when ran as script. (GH-8537)
When running test_bdb.py as a script, `import test_module` would be
importing the existing Lib/test/test_modules.py instead of the
tempcwd/test_module.py module which was dynamically created by
test_bdb.py itself.
2018-12-05 21:32:16 +02:00
Victor Stinner f2f4555d82
bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919)
* posixpath.expanduser() now returns the input path unchanged if
  the HOME environment variable is not set and pwd.getpwuid() raises
  KeyError (the current user identifier doesn't exist in the password
  database).
* Add test_no_home_directory() to test_site.
2018-12-05 16:49:35 +01:00
Victor Stinner 476b113ed8
bpo-35389: platform.libc_ver() uses os.confstr() (GH-10891)
platform.libc_ver() now uses os.confstr('CS_GNU_LIBC_VERSION') if
available and the *executable* parameter is not set. The default
value of the libc_ver() *executable* parameter becomes None.

Quick benchmark on Fedora 29:

python3 -m perf command ./python -S -c 'import platform; platform.libc_ver()'
94.9 ms +- 4.3 ms -> 33.2 ms +- 1.4 ms: 2.86x faster (-65%)
2018-12-05 14:04:52 +01:00
Victor Stinner c11b3b19a5
bpo-35411: Skip test_urllib2net FTP tests on Travis CI (GH-10907)
On Travis CI, FTP tests of test_urllib2net randomly fail with "425
Security: Bad IP connecting".

test.pythoninfo now also logs TRAVIS environment variable.
2018-12-05 01:58:31 +01:00
Victor Stinner 4752e65250
bpo-35363, test_eintr: skip test_open() on macOS (GH-10896) 2018-12-04 17:13:33 +01:00
Andrew Svetlov 3bc0ebab17
bpo-35380: Enable TCP_NODELAY for proactor event loop (#10867) 2018-12-03 21:08:13 +02:00
Serhiy Storchaka 4013c17911
bpo-35372: Fix the code page decoder for input > 2 GiB. (GH-10848) 2018-12-03 10:36:45 +02:00
Ismo Toijala 68b56d02ef bpo-35341: Add generic version of OrderedDict to typing (GH-10850) 2018-12-02 15:53:14 +00:00
Serhiy Storchaka 32bc11c33c
bpo-35371: Fix possible crash in os.utime() on Windows. (GH-10844) 2018-12-01 14:30:20 +02:00
Victor Stinner 7212148c95
bpo-35352: Cleanup test_asyncio/utils.py (GH-10831)
'here' variable is no longer needed.
2018-11-30 18:30:09 +01:00
stratakis b062ba77b6 bpo-35352: test_asyncio uses the certificate set from the test directory (GH-10826)
Modify asyncio tests to utilize the certificates from the test directory
instead of its own set, as they are the same and with each update they had
to be updated as well.
2018-11-30 17:56:56 +01:00
Victor Stinner 304315d251
bpo-35347: Cleanup test_socket.NonBlockingTCPTests (GH-10818)
* Replace testInheritFlags() with two tests:
  testInheritFlagsBlocking() and testInheritFlagsTimeout()
  to test different default socket timeout. Moreover, the test now
  checks sock.gettimeout() rather than a functional test on recv().
* Replace time.time() with time.monotonic()
* Add socket_setdefaulttimeout() context manager to restore the
  default timeout when the test completes.
* Remove testConnect(): accept() wasn't blocking and testAccept()
  already tests non-blocking accept().
* Remove accept() functional test from testInitNonBlocking():
  already tested by testAccept()
* Rewrite testSetBlocking() with a new assert_sock_timeout() method
* Use addCleanup() and context manager to close sockets
* Replace assertTrue(x < y) with assertLess(x, y)
2018-11-30 13:22:44 +01:00
Victor Stinner ebd5d6d6e6
bpo-35347: Fix test_socket.NonBlockingTCPTests (GH-10791)
testAccept() and testRecv() of test_socket.NonBlockingTCPTests have a
race condition: time.sleep() is used as a weak synchronization
primitive and the tests fail randomly on slow buildbots.

Use a reliable threading.Event to fix these tests.

Other changes:

* Replace send() with sendall()
* Expect specific BlockingIOError rather than generic OSError
* Add a timeout to select() in testAccept() and testRecv()
* Use addCleanup() to close sockets
* Use assertRaises()
2018-11-30 12:29:25 +01:00
Victor Stinner 55e498058f
bpo-35336: Fix PYTHONCOERCECLOCALE=1 (GH-10806)
Fix PYTHONCOERCECLOCALE=1 environment variable: only coerce the C
locale if the LC_CTYPE locale is "C".
2018-11-30 11:34:47 +01:00
Pablo Galindo 9724348b43 bpo-34279, regrtest: Issue a warning if no tests have been executed (GH-10150) 2018-11-29 18:17:44 +01:00
Victor Stinner 73104fa1e6
bpo-35345: Remove platform.popen() (GH-10781)
Remove platform.popen() function, it was deprecated since Python 3.3:
use os.popen() instead.

Rename also the "Removed" section to "API and Feature Removals"
of What's New in Python 3.8.
2018-11-29 09:58:20 +01:00
Victor Stinner 2956bffbc0
bpo-35189, bpo-35316: Make test_eintr less strict (GH-10782)
test_eintr no longer fails if the signal handler has not been called.
2018-11-29 01:34:51 +01:00
Victor Stinner 48498dd57f
bpo-33723: Remove busy loop from test_time (GH-10773)
The "busy loops" of test_process_time() and test_thread_time() are
not reliable and fail randomly on Windows: remove them.
2018-11-28 18:30:10 +01:00
INADA Naoki f7e4d3642f bpo-34100: compile: Re-enable frozenset merging (GH-10760)
This reverts commit 1005c84535.
2018-11-28 16:58:46 +01:00
Victor Stinner bde9d6bbb4
bpo-34523, bpo-35322: Fix unicode_encode_locale() (GH-10759)
Fix memory leak in PyUnicode_EncodeLocale() and
PyUnicode_EncodeFSDefault() on error handling.

Changes:

* Fix unicode_encode_locale() error handling
* Fix test_codecs.LocaleCodecTest
2018-11-28 10:26:20 +01:00
Victor Stinner b7278736b3
bpo-33676: Fix dangling thread in _test_multiprocessing (GH-10755)
Fix WithThreadsTestPool.test_wrapped_exception()
of test_multiprocessing_fork: join the pool.

WithThreadsTestPool.test_del_pool() is now also decorated
with @support.reap_threads.
2018-11-28 01:14:31 +01:00
Victor Stinner 1005c84535
bpo-34100: Partially revert merge_consts_recursive() (GH-10743)
Partically revert commit c2e1607a51 to
fix a reference leak.
2018-11-27 15:12:47 +01:00
Victor Stinner cfaafda8e3
bpo-35317: Fix mktime() error in test_email (GH-10721)
Fix mktime() overflow error in test_email: run
test_localtime_daylight_true_dst_true() and
test_localtime_daylight_false_dst_true() with a specific timezone.
2018-11-27 12:40:50 +01:00
Serhiy Storchaka b619b09792
bpo-31241: Fix AST node position for list and generator comprehensions. (GH-10633)
The lineno and col_offset attributes of AST nodes for list comprehensions,
generator expressions and tuples are now point to the opening parenthesis or
square brace. For tuples without parenthesis they point to the position
of the first item.
2018-11-27 09:40:29 +02:00
Zackery Spytz d1cbc6f8a0 Include the highest pickle protocol in a couple of tests. (GH-10735)
test_reduce_ex() in test_array.py and
test_reversevaluesiterator_pickling() in test_dict.py weren't using
the highest pickle protocol.
2018-11-27 07:40:49 +02:00
Zhiming Wang 8c281ed403 bpo-35308: Fix regression where BROWSER env var is not respected. (GH-10693)
Regression introduced in e3ce695 and 25b804a, where the old parameter
update_tryorder to _synthesize was first ignored, then given the opposite
value in the attempt to fix bpo-31014.
2018-11-26 23:29:45 +02:00
Victor Stinner 65c216e74f
bpo-33723: Fix test_time.test_thread_time() (GH-10724)
Tolerate up to 30 ms, instead of 15 min, in other threads.
2018-11-26 21:19:29 +01:00
Lisa Roach 433433fa6d
Adds IPv6 support when invoking http.server directly. (GH-10595) 2018-11-26 10:43:38 -08:00
Victor Stinner 282c03d45d
pythoninfo: log more environment variable (GH-10719)
Log TZ to debug a timezone issue... and a few more :-)
2018-11-26 17:03:16 +01:00
INADA Naoki c2e1607a51 bpo-34100: Merge constants recursively (GH-8341)
There are some same consts in a module.  This commit merges them into
single instance.  It reduces number of objects in memory after loading modules.


https://bugs.python.org/issue34100
2018-11-26 04:23:22 -08:00
Victor Stinner f0b366a8d7
bpo-35313: Cleanup test_embed.py (GH-10716)
* Remove an unused import.
* Move get_expected_config() call to check_config() to ease backport
  to Python 3.7.
2018-11-26 12:37:34 +01:00
Victor Stinner a6537fb7c2
bpo-35313: Fix test_embed when run from venv (GH-10713)
test_embed.InitConfigTests now gets the expected configuration from
a child process run with -S to not run the site module.
2018-11-26 11:54:12 +01:00
Dustin Spicuzza 1d817e4c82 bpo-29877: compileall: import ProcessPoolExecutor only when needed (GH-4856)
Importing ProcessPoolExecutor may hang or cause an error when the import
accesses urandom on a low resource platform


https://bugs.python.org/issue29877
2018-11-23 09:06:55 -08:00
Victor Stinner 9de3632715
bpo-34812: subprocess._args_from_interpreter_flags(): add isolated (GH-10675)
The "-I" command line option (run Python in isolated mode) is now
also copied by the multiprocessing and distutils modules when
spawning child processes. Previously, only -E and -s options (enabled
by -I) were copied.

subprocess._args_from_interpreter_flags() now copies the -I flag.
2018-11-23 17:54:20 +01:00
nierob b409ffa848 bpo-35189: Retry fnctl calls on EINTR (GH-10413)
Modify the following fnctl function to retry if interrupted by a signal
(EINTR): flock, lockf, fnctl.
2018-11-23 16:46:12 +01:00
Victor Stinner f1d002c1e0
bpo-35059: Enhance _PyObject_AssertFailed() (GH-10642)
Enhance _PyObject_AssertFailed()

* Exchange 'expr' and 'msg' parameters
* 'expr' and 'func' arguments can now be NULL
2018-11-21 23:53:44 +01:00
Victor Stinner aac1f81eef
bpo-35189: Fix eintr_tester.py (GH-10637)
Call setitimer() before each test method, instead of once per test
case, to ensure that signals are sent in each test method.
Previously, only the first method of a testcase class got signals.

Changes:

* Replace setUpClass() with setUp() and replace tearDownClass() with
  tearDown().
* tearDown() now ensures that at least one signal has been sent.
* Replace support.run_unittest() with unittest.main() which has
  a nicer CLI and automatically discover test cases.
2018-11-21 16:33:13 +01:00
Victor Stinner 7c2d5702d1
bpo-35290: Add debug info to test_c_locale_coercion (GH-10631)
In verbose mode, test_c_locale_coercion now dumps global variables at
startup.
2018-11-21 12:21:25 +01:00
Serhiy Storchaka 3ec0f49516
bpo-35021: Fix assertion failures in _datetimemodule.c. (GH-10039)
Fixes assertion failures in _datetimemodule.c
introduced in the previous fix (see bpo-31752).

Rather of trying to handle an int subclass as exact int,
let it to use overridden special methods, but check the
result of divmod().
2018-11-20 20:41:09 +02:00
Serhiy Storchaka 97f1efb606
bpo-35169: Improve error messages for forbidden assignments. (GH-10342) 2018-11-20 19:27:16 +02:00
Steve Dower 38df97a03c
Add --tempdir option for test run (GH-10322) 2018-11-17 04:14:36 -08:00
Srinivas Thatiparthy (శ్రీనివాస్ తాటిపర్తి) 90d0cfb222 bpo-35202: Remove unused imports in tests. (GH-10561) 2018-11-16 17:32:58 +02:00
Victor Stinner 37cd982df0
bpo-35239: _PySys_EndInit() copies module_search_path (GH-10532)
* The _PySys_EndInit() function now copies the
  config->module_search_path list, so config is longer modified when
  sys.path is updated.
* config->warnoptions list and config->xoptions dict are also copied
* test_embed: InitConfigTests now also tests
  main_config['module_search_path']
* Fix _Py_InitializeMainInterpreter(): don't use config->warnoptions
   but sys.warnoptions to decide if the warnings module should
   be imported at startup.
2018-11-16 11:55:35 +01:00
Srinivas Thatiparthy (శ్రీనివాస్ తాటిపర్తి) 70f61b933f bpo-35202: Remove unused imports in Lib directory (GH-10450) 2018-11-15 21:59:19 +09:00
Victor Stinner 01de89cb59
bpo-35233: InitConfigTests tests more config vars (GH-10541)
test_embed.InitConfigTests tests more configuration variables.

Changes:

* InitConfigTests tests more core configuration variables:

  * base_exec_prefix
  * base_prefix
  * exec_prefix
  * home
  * legacy_windows_fs_encoding
  * legacy_windows_stdio
  * module_search_path_env
  * prefix

* "_testembed init_from_config" tests more variables:

  * argv
  * warnoptions
  * xoptions

* InitConfigTests: add check_global_config(), check_core_config() and
  check_main_config() subfunctions to cleanup the code. Move also
  constants at the class level (ex: COPY_MAIN_CONFIG).
* Fix _PyCoreConfig_AsDict(): don't set stdio_encoding twice
* Use more macros in _PyCoreConfig_AsDict() and
  _PyMainInterpreterConfig_AsDict() to reduce code duplication.
* Other minor cleanups.
2018-11-14 17:39:45 +01:00
Victor Stinner 7ddd56f4d8
bpo-35233: Rewrite test_embed.InitConfigTests (GH-10524)
* Fix _PyCoreConfig_SetGlobalConfig(): set also Py_FrozenFlag
* Fix _PyCoreConfig_AsDict(): export also xoptions
* Add _Py_GetGlobalVariablesAsDict() and _testcapi.get_global_config()
* test.pythoninfo: dump also global configuration variables
* _testembed now serializes global, core and main configurations
  using JSON to reuse _Py_GetGlobalVariablesAsDict(),
  _PyCoreConfig_AsDict() and _PyMainInterpreterConfig_AsDict(),
  rather than duplicating code.
* test_embed.InitConfigTests now test much more configuration
  variables
2018-11-14 00:24:28 +01:00
Victor Stinner 00b137c72f
bpo-35233: Fix _PyMainInterpreterConfig_Copy() (GH-10519)
* Fix _PyMainInterpreterConfig_Copy():
   copy 'install_signal_handlers' attribute
* Add _PyMainInterpreterConfig_AsDict()
* Add unit tests on the main interpreter configuration
  to test_embed.InitConfigTests
* test.pythoninfo: log also main_config
2018-11-13 19:59:26 +01:00
Victor Stinner f966e5397e
bpo-29564:_PyMem_DumpTraceback() suggests enabling tracemalloc (GH-10510)
If tracemalloc is not tracing Python memory allocations,
_PyMem_DumpTraceback() now suggests to enable tracemalloc
to get the traceback where the memory block has been allocated.
2018-11-13 15:14:58 +01:00
Victor Stinner 2c07c493d2
bpo-29564: warnings suggests to enable tracemalloc (GH-10486)
The warnings module now suggests to enable tracemalloc if the source
is specified, tracemalloc module is available, but tracemalloc is not
tracing memory allocations.
2018-11-13 02:41:00 +01:00
Andrew Svetlov 7438792607
bpo-30064: Refactor sock_* asyncio API (#10419) 2018-11-12 19:00:22 +02:00
Srinivas Thatiparthy (శ్రీనివాస్ తాటిపర్తి) b9498e2367 bpo-35202: Remove unused imports in Lib directory. (GH-10446) 2018-11-10 09:22:02 +02:00
Gregory P. Smith 49fa4a9f1e
bpo-35193: Fix an off by one error in the RETURN_VALUE case. (GH-10418)
Fix an off by one error in the peephole optimizer when checking for unreachable code beyond a return.

Do a bounds check within find_op so it can return before going past the end as a safety measure.

7db3c48833 (diff-a33329ae6ae0bb295d742f0caf93c137)
introduced this off by one error while fixing another one nearby.

This bug was shipped in all Python 3.6 and 3.7 releases.

The included unittest won't fail unless you do a clang msan build.
2018-11-08 17:55:07 -08:00
Vincent Michel fd512d7645 bpo-35065: Remove `StreamReaderProtocol._untrack_reader` (#10212)
The call to `_untrack_reader` is performed too soon, causing the protocol
to forget about the reader before `connection_lost` can run and feed the
EOF to the reader. See bpo-35065.
2018-11-08 14:21:47 +02:00
Serhiy Storchaka a44d34e179
bpo-34966: Improve support of method aliases in pydoc. (GH-9823)
Pydoc now does not duplicate docstrings for aliases of inherited methods.
2018-11-08 08:48:11 +02:00
Pablo Galindo b93925047a
Fix the construction of subprocess.CalledProcessError in test_venv (GH-10400)
The constructor of subprocess.CalledProcessError in the check_output function had an extra None in it.
2018-11-07 22:21:17 +00:00
Elvis Pranskevichus a6e956bcb0 bpo-34726: Fix handling of hash-based pycs in zipimport. (GH-10327)
Current support for hash-based bytecode files in `zipimport` is rather
sparse, which leads to test failures when the test suite is ran with
the ``SOURCE_DATE_EPOCH`` environment variable set.

This teaches zipimport to handle hash-based pycs properly.
2018-11-07 20:34:59 +02:00
Cheryl Sabella 637a33b996 bpo-2504: Add pgettext() and variants to gettext. (GH-7253) 2018-11-07 16:12:20 +02:00
Diego Rojas 5598cc90c7 bpo-34160: Preserve order of attributes in minidom. (GH-10219) 2018-11-07 16:09:04 +02:00
HongWeipeng f194479949 bpo-31553: add --json-lines option to json.tool (#10051)
* add jsonlines option to json.tool

* code review

* fix:avoid read infile after it close

* improve doc in whatsnew 3.8
2018-11-07 12:09:32 +02:00