Commit Graph

23944 Commits

Author SHA1 Message Date
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
Antoine Pitrou a79f8faccf bpo-30775: Fix refleaks in test_multiprocessing (#2467)
Forgetting to call Process.join() can keep some resources alive.
2017-06-28 11:21:52 +02:00
Serhiy Storchaka f7eae0adfc [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302)
Based on patch by Victor Stinner.

Add private C API function _PyUnicode_AsUnicode() which is similar to
PyUnicode_AsUnicode(), but checks for null characters.
2017-06-28 08:30:06 +03:00
Victor Stinner 84d9d14a1f bpo-29512: Add test.bisect, bisect failing tests (#2452)
Add a new "python3 -m test.bisect" tool to bisect failing tests.

It can be used to find which test method(s) leak references, leak
files, etc.
2017-06-28 02:24:41 +02:00
Victor Stinner 48b5c422ff bpo-30776: reduce regrtest -R false positives (#2422)
* Change the regrtest --huntrleaks checker to decide if a test file
  leaks or not. Require that each run leaks at least 1 reference.
* Warmup runs are now completely ignored: ignored in the checker test
  and not used anymore to compute the sum.
* Add an unit test for a reference leak.

Example of reference differences previously considered a failure
(leak) and now considered as success (success, no leak):

    [3, 0, 0]
    [0, 1, 0]
    [8, -8, 1]
2017-06-27 02:02:04 +02:00
Joel Hillacre b350c22ebc bpo-30532: Fix whitespace folding in certain cases
Leading whitespace was incorrectly dropped during folding of certain lines in the _header_value_parser's folding algorithm.  This makes the whitespace handling code consistent.
2017-06-26 17:41:35 -04:00
Victor Stinner 63f54c6893 bpo-30764: regrtest: add --fail-env-changed option (#2402)
* bpo-30764: regrtest: change exit code on failure

* Exit code 2 if failed tests ("bad")
* Exit code 3 if interrupted

* bpo-30764: regrtest: add --fail-env-changed option

If the option is set, mark a test as failed if it alters the
environment, for example if it creates a file without removing it.
2017-06-26 18:33:19 +02:00
Victor Stinner cdee3f14f7 bpo-30764: test_subprocess uses SuppressCrashReport (#2405)
bpo-30764, bpo-29335: test_child_terminated_in_stopped_state() of
test_subprocess now uses support.SuppressCrashReport() to prevent the
creation of a core dump on FreeBSD.
2017-06-26 17:23:03 +02:00
Victor Stinner ace56d5836 bpo-30523: regrtest --list-cases --match (#2401)
* regrtest --list-cases now supports --match and --match-file options.
  Example: ./python -m test --list-cases -m FileTests test_os
* --list-cases now also sets support.verbose to False to prevent
  messages to stdout when loading test modules.
* Add support._match_test() private function.
2017-06-26 14:18:51 +02:00
Serhiy Storchaka af5392f5c6 bpo-30746: Port more tests for os.spawnvpe() and os.execve() from 2.7. (#2394) 2017-06-25 09:48:54 +03:00
Serhiy Storchaka 77703942c5 bpo-30746: Prohibited the '=' character in environment variable names (#2382)
in `os.putenv()` and `os.spawn*()`.
2017-06-25 07:33:01 +03:00
Antoine Pitrou 13e96cc596 Fix bpo-30596: Add close() method to multiprocessing.Process (#2010)
* Fix bpo-30596: Add close() method to multiprocessing.Process

* Raise ValueError if close() is called before the Process is finished running

* Add docs

* Add NEWS blurb
2017-06-24 19:22:23 +02:00
Serhiy Storchaka d174d24a5d bpo-30730: Prevent environment variables injection in subprocess on Windows. (#2325)
Prevent passing other invalid environment variables and command arguments.
2017-06-23 19:39:27 +03:00
Victor Stinner f87b85f808 bpo-21071: struct.Struct.format type is now str (#845) 2017-06-23 15:11:12 +02:00
Victor Stinner a4b091e135 bpo-30604: Skip CoExtra tests if ctypes is missing (#2356) 2017-06-23 15:08:55 +02:00
Serhiy Storchaka 32cb968a2e bpo-30727: Fix a race condition in test_threading. (#2334) 2017-06-23 13:36:36 +03:00
Benjamin Peterson 279a96206f bpo-30736: upgrade to Unicode 10.0 (#2344)
Straightforward. While we're at it, though, strip trailing whitespace from generated tables.
2017-06-22 22:31:08 -07:00
Gregory P. Smith a3d91b43c2 bpo-29212: Fix the ugly repr() ThreadPoolExecutor thread name. (#2315)
bpo-29212: Fix the ugly ThreadPoolExecutor thread name.

Fixes the newly introduced ugly default thread name for concurrent.futures
thread.ThreadPoolExecutor threads.  They'll now resemble the old <=3.5
threading default Thread-x names by being named ThreadPoolExecutor-y_n.
2017-06-21 23:41:13 -07:00
Dino Viehland f3cffd2b78 bpo-30604: clean up co_extra support (#2144)
bpo-30604: port fix from 3.6 dropping binary compatibility tweaks
2017-06-21 17:44:36 -04:00
Dong-hee Na dcc8ce44c7 bpo-30616: Functional API of enum allows to create empty enums. (#2304)
* bpo-30616: Functional API of enum allows to create empty enums.

* Update NEWS

move addition to avoid conflict
2017-06-21 09:52:32 -07:00
Serhiy Storchaka 26cb4657bc bpo-29755: Fixed the lgettext() family of functions in the gettext module. (#2266)
They now always return bytes.

Updated the gettext documentation.
2017-06-20 17:13:29 +03:00
Sanyam Khurana 3a7f03584a bpo-30597: Show expected input in custom 'print' error message. (#2009) 2017-06-20 16:31:32 +03:00
postmasters 90e01e50ef urllib: Simplify splithost by calling into urlparse. (#1849)
The current regex based splitting produces a wrong result. For example::

  http://abc#@def

Web browsers parse that URL as ``http://abc/#@def``, that is, the host
is ``abc``, the path is ``/``, and the fragment is ``#@def``.
2017-06-20 15:02:44 +02:00
Nick Coghlan eb81795d7d bpo-30565: Add PYTHONCOERCECLOCALE=warn runtime flag (GH-2260)
- removes PY_WARN_ON_C_LOCALE build time flag
- locale coercion and compatibility warnings are now always compiled
  in, but are off by default
- adds PYTHONCOERCECLOCALE=warn runtime option to aid in
  debugging potentially locale related compatibility problems

Due to not-yet-resolved test failures on *BSD systems (including
Mac OS X), this also temporarily disables UTF-8 as a locale coercion
target, and skips testing the interpreter's behavior in the POSIX locale.
2017-06-18 12:29:42 +10:00
Louie Lu b0c58d3c56 bpo-30523: Add --list-cases unittest (#2243)
* bpo-30523: Add --list-cases unittest

* Addressed haypo's request

* Addressed haypo's request
2017-06-16 13:15:28 +02:00
ericvsmith 11e97f2f80 bpo-30682: Removed a too-strict assertion that failed for certain f-strings. (#2232)
This caused a segfault on eval("f'\\\n'") and eval("f'\\\r'") in debug build.
2017-06-16 13:19:32 +03:00
mlouielu a49c935cfd bpo-30523: regrtest: Add --list-cases option (#2238)
* bpo-30523: regrtest: Add --list-cases option

* bpo-30523: Enhance --list-cases

* Add get_abs_module() function, use it in list_cases()
* list_cases() now logs skipped tests into stderr

* Remove unused doctest
2017-06-16 11:36:19 +02:00
Victor Stinner 272d888c7b bpo-29783: Replace codecs.open() with io.open() (#599) 2017-06-16 08:59:01 +02:00
Jonathan Eunice 214f7eed76 bpo-30603: add tests to textwrap.dedent (GH-2206)
* test dedent with declining indent level
* add textwrap.dedent test cases
2017-06-15 19:18:54 -07:00
Sylvain 96c7c06850 bpo-20627: Fix error message when keyword arguments are used (#2115) 2017-06-15 18:05:23 +03:00
Nick Coghlan 7926516ff9 bpo-28180: Standard stream & FS encoding differ on Mac OS X (GH-2208)
In the C locale on Mac OS X, the default filesystem encoding
used for operating system interfaces is UTF-8, but the
default encoding used on the standard streams is still ASCII.

Setting the POSIX locale also behaves differently from setting
other locales on Mac OS X, so skip that in the test suite for now.
2017-06-15 19:11:39 +10:00
Victor Stinner f7e07840d7 bpo-30284: Fix regrtest for out of tree build (#1481)
Use a build/ directory in the build directory, not in the source
directory, since the source directory may be read-only and must not
be modified.

Fallback on the source directory if the build directory is not
available (missing "abs_builddir" sysconfig variable).
2017-06-15 00:44:05 +02:00
Milan Oberkirch 8c3f05e9f0 bpo-30436: Raise ModuleNotFoundError for importlib.util.find_spec() when parent isn't a package (GH-1899)
Previously AttributeError was raised, but that's not very reflective of the fact that the requested module can't be found since the specified parent isn't actually a package.
2017-06-14 14:34:50 -07:00
Victor Stinner b18563da88 bpo-30231: Remove skipped test_imaplib tests (#1419)
The public cyrus.andrew.cmu.edu IMAP server (port 993) doesn't accept
TLS connection using our self-signed x509 certificate. Remove the two
tests which are already skipped.

Write a new test_certfile_arg_warn() unit test for the certfile
deprecation warning.
2017-06-14 18:48:32 +02:00
Victor Stinner 3402f72688 bpo-30649: Revert utime delta in test_os (#2176)
PPC64 Fedora 3.x buildbot requires at least a delta of 14 ms: revert
the utime delta to 20 ms.

I tried 10 ms, but test_os failed on the PPC64 Fedora 3.x buildbot.
2017-06-14 11:55:17 +02:00
Victor Stinner 8f6eeaf21c bpo-30595: Increase test_queue_feeder_donot_stop_onexc() timeout (#2148)
_test_multiprocessing.test_queue_feeder_donot_stop_onexc() now uses a
timeout of 1 second on Queue.get(), instead of 0.1 second, for slow
buildbots.
2017-06-13 23:48:47 +02:00
Victor Stinner c94caca65c bpo-30649: test_os tolerates 50 ms delta for utime (#2156)
On Windows, tolerate a delta of 50 ms instead of 20 ms in
test_utime_current() and test_utime_current_old() of test_os.

On other platforms, reduce the delta from 20 ms to 10 ms.
2017-06-13 23:48:27 +02:00
Jonathan Eunice 601483d3b8 bpo-30603: Add test case to textwrap.dedent (GH-2014) 2017-06-13 12:04:10 -07:00
Sanyam Khurana b9c3da5c89 bpo-24744: Raises error in pkgutil.walk_packages if path is str (#1926)
bpo-24744: Raise error in pkgutil.walk_packages if path is str

Previously an empty result list was accidentallly returned, since the
code iterated over the string as if it were the expected list of paths,
and of course found nothing.
2017-06-13 13:11:14 -04:00
Antoine Pitrou 1eb6c0074d bpo-24484: Avoid race condition in multiprocessing cleanup (#2159)
* bpo-24484: Avoid race condition in multiprocessing cleanup

The finalizer registry can be mutated while inspected by multiprocessing
at process exit.

* Use test.support.start_threads()

* Add Misc/NEWS
2017-06-13 17:10:39 +02:00
Nick Coghlan 4563099d28 bpo-28180: assume UTF-8 for Mac OS X PEP 538 tests (GH-2130) 2017-06-13 22:49:44 +10:00
Victor Stinner 023564bf7d bpo-30635: Fix refleak in test_c_locale_coercion (#2126)
When checking for reference leaks, test_c_locale_coercion is run
multiple times and so _LocaleCoercionTargetsTestCase.setUpClass() is
called multiple times. setUpClass() appends new value at each call,
so it looks like a reference leak.

Moving the setup from setUpClass() to setUpModule() avoids
this, eliminating the false alarm.
2017-06-13 21:32:31 +10:00
Victor Stinner eb52ac8992 bpo-28180: Fix test_capi.test_forced_io_encoding() (#2155)
Don't run Python in an empty environment, but copy the current
environment and set PYTHONIOENCODING. So the test works also on
Python compiled in shared mode (using libpython).
2017-06-13 11:49:44 +02:00
Antoine Pitrou dfd5f34634 Fix bpo-30589: improve Process.exitcode with forkserver (#1989)
* Fix bpo-30589: improve Process.exitcode with forkserver

When the child is killed, Process.exitcode should return -signum, not 255.

* Add Misc/NEWS
2017-06-12 15:28:19 +02:00
mircea-cosbuc b459f74826 [email] bpo-29478: Fix passing max_line_length=None from Compat32 policy (GH-595)
If max_line_length=None is specified while using the Compat32 policy,
it is no longer ignored.
2017-06-11 23:43:41 -07:00
Serhiy Storchaka 3fd54d4a7e bpo-28994: Fixed errors handling in atexit._run_exitfuncs(). (#2034)
The traceback no longer displayed for SystemExit raised in a callback registered by atexit.
2017-06-12 08:25:04 +03:00
Yury Selivanov 09663de203 Revert "bpo-29406: asyncio SSL contexts leak sockets after calling close with certain servers (#409)" (#2111)
This reverts commit a608d2d5a7.
2017-06-11 16:46:35 +02:00
Yury Selivanov 7ce1c6fb57 bpo-30508: Don't log exceptions if Task/Future "cancel()" method called (#2050) 2017-06-11 13:49:18 +00:00
Serhiy Storchaka 1efbf92e90 bpo-11822: Improve disassembly to show embedded code objects. (#1844)
The depth argument limits recursion.
2017-06-11 14:09:39 +03:00
Nick Coghlan 6ea4186de3 bpo-28180: Implementation for PEP 538 (#659)
- new PYTHONCOERCECLOCALE config setting
- coerces legacy C locale to C.UTF-8, C.utf8 or UTF-8 by default
- always uses C.UTF-8 on Android
- uses `surrogateescape` on stdin and stdout in the coercion
  target locales
- configure option to disable locale coercion at build time
- configure option to disable C locale warning at build time
2017-06-11 13:16:15 +10:00
Ivan Levkivskyi 29fda8db16 bpo-28556: Updates to typing module (#2076)
This PR contains two updates to typing module:

- Support ContextManager on all versions (original PR by Jelle Zijlstra).
- Add generic AsyncContextManager.
2017-06-10 12:57:56 -07:00
Victor Stinner c5179f6e2d bpo-30599: Fix test_threaded_import reference leak (#2029)
Mock os.register_at_fork() when importing the random module, since
this function doesn't allow to unregister callbacks and so leaked
memory.
2017-06-10 19:41:24 +02:00
Roy Williams 171b9a354e bpo-30605: Fix compiling binary regexs with BytesWarnings enabled. (#2016)
Running our unit tests with `-bb` enabled triggered this failure.
2017-06-10 08:01:16 +03:00
Sylvain 7445381c60 bpo-30600: Fix error messages (condition order in Argument Clinic) (#2051)
The function '_PyArg_ParseStack()' and
'_PyArg_UnpackStack' were failing (with error
"XXX() takes Y argument (Z given)") before
the function '_PyArg_NoStackKeywords()' was called.
Thus, the latter did not raise its more meaningful
error : "XXX() takes no keyword arguments".
2017-06-10 07:51:48 +03:00
Nikolay Kim a608d2d5a7 bpo-29406: asyncio SSL contexts leak sockets after calling close with certain servers (#409)
* asyncio SSL contexts leak sockets after calling close with certain servers

* cleanup _shutdown_timeout_handle on _fatal_error
2017-06-10 00:04:39 -04:00
Nikolay Kim a0e3d2dd09 Closing transport during handshake process leaks socket (#480) 2017-06-09 17:46:14 -04:00
Giampaolo Rodola fbfaa6fd57 bpo-30014: make poll-like selector's modify() method faster (#1030)
* #30014: make selectors.DefaultSelector.modify() faster by relying on selector's modify() method instead of un/register()ing the fd

* #30014: add unit test

* speedup poll/epoll/devpoll modify() method by using internal modify() call

* update doc

* address PR comments

* update NEWS entries

* use != instead of 'is not'
2017-06-09 22:20:41 +02:00
Mathieu Sornay 894a654a9c Fix waiter cancellation in asyncio.Lock (#1031)
Avoid a deadlock when the waiter who is about to take the lock is
cancelled

Issue #27585
2017-06-09 16:17:40 -04:00
Serhiy Storchaka f9f1ccace3 Fix regression in error message introduced in bpo-29951. (#2028)
* Fix regression in error message introduced in bpo-29951.

* Add test.

* Make the test more strong.
2017-06-09 18:27:06 +02:00
Jelle Zijlstra 57161aac5e bpo-30266: support "= None" pattern in AbstractContextManager (#1448)
contextlib.AbstractContextManager now supports anti-registration
by setting __enter__ = None or __exit__ = None, following the pattern
introduced in bpo-25958.
2017-06-09 08:21:47 -07:00
Victor Stinner 3b5cf85edc bpo-30524: Write unit tests for FASTCALL (#2022)
Test C functions:

* _PyObject_FastCall()
* _PyObject_FastCallDict()
* _PyObject_FastCallKeywords()
2017-06-09 16:48:45 +02:00
Nathaniel J. Smith 59fdf0f3ba Add a test for bad IDNA in ssl server_hostname (#1997)
See discussion:
  https://github.com/python/cpython/pull/1992#issuecomment-307024778
2017-06-09 11:35:16 +02:00
Victor Stinner ef8320cf6f bpo-30540: regrtest: add --matchfile option (#1909)
* Add a new option taking a filename to get a list of test names to
  filter tests.
* support.match_tests becomes a list.
* Modify run_unittest() to accept to match the whole test identifier,
  not just a part of a test identifier.

For example, the following command only runs test_default_timeout()
of the BarrierTests class of test_threading:

$ ./python -m test -v test_threading -m test.test_threading.BarrierTests.test_default_timeout

Remove also some empty lines from test_regrtest.py to make flake8
tool happy.
2017-06-09 10:18:48 +02:00
Serhiy Storchaka 2e9cd5825c bpo-30529: Fix errors for invalid whitespaces in f-string subexpressions. (#1888)
'invalid character in identifier' now is raised instead of
'f-string: empty expression not allowed' if a subexpression contains
only whitespaces and they are not accepted by Python parser.
2017-06-08 23:43:54 +03:00
Lisa Roach 64505a1f6c bpo-30486: Allow setting cell value (#1840)
The cell_contents attribute of the cell object is now writable.
2017-06-08 14:43:26 +03:00
Will Roberts 0ecdc52514 bpo-30537: use PyNumber in itertools.islice instead of PyLong (#1918)
* bpo-30537: use PyNumber in itertools instead of PyLong

* bpo-30537: revert changes except to islice_new

* bpo-30537: test itertools.islice and add entry to Misc/NEWS
2017-06-07 23:03:04 -07:00
Jonathan Eunice 5edf827c80 bpo-30591: Added test for textwrap backtracking. (#1988) 2017-06-07 23:49:13 +03:00
Denis Osipov 897bba7563 bpo-30584: Fix test_os fails on non-English Windows (#1980)
* Fix bpo-30584

* Adding a comment mentionning the bpo and explaining what is the identifier

* Add Denis Osipov to Misc/ACKS
2017-06-07 19:15:26 +02:00
Antoine Pietri add98eb4fe bpo-30177: pathlib: include the full path in resolve(strict=False) (#1893) 2017-06-07 08:29:17 -07:00
Aaron Hall, MBA ff48739ed0 bpo-30463: Add an empty __slots__ to abc.ABC. 2017-06-06 22:34:57 +03:00
Victor Stinner 6a1d84e2b3 bpo-30557: Fix test_faulthandler (#1969)
On Windows 8, 8.1 and 10 at least, the exit code is the exception
code (no bit is cleared).
2017-06-06 10:40:41 -07:00
Serhiy Storchaka 5eb788bf7f bpo-30534: Fixed error messages when pass keyword arguments (#1901)
to functions implemented in C that don't support this.

Also unified error messages for functions that don't take positional or keyword
arguments.
2017-06-06 18:45:22 +03:00
Vinay Sajip 6260d9f203 bpo-30520: Implemented pickling for loggers. (#1956)
Implemented pickling for loggers.
2017-06-06 16:34:29 +01:00
Oz N Tiram 8b7a4cc40e bpo-30095: Make CSS classes used by calendar.HTMLCalendar customizable (GH-1439)
Several class attributes have been added to calendar.HTMLCalendar that allow customization of the CSS classes used in the resulting HTML. This can be done by subclasses HTMLCalendar and overwriting those class attributes (Patch by Oz Tiram).
2017-06-06 11:35:59 +02:00
Steve Dower e6a23c8f9a bpo-30557: faulthandler now correctly filters and displays exception codes on Windows (#1924)
* bpo-30557: faulthandler now correctly filters and displays exception codes on Windows

* Adds test for non-fatal exceptions.

* Adds bpo number to comment.
2017-06-05 15:54:15 -07:00
Antoine Pitrou 3c2817b688 Fix bpo-30526: Add TextIOWrapper.reconfigure() and a TextIOWrapper.write_through attribute (#1922)
* Fix bpo-30526: Add TextIOWrapper.reconfigure()

* Apply Nick's improved wording

* Update Misc/NEWS
2017-06-03 12:32:28 +02:00
Segev Finer 7a99625e0d Fix skipping test_UNC_path on AppVeyor due to a different error being raised (#1920)
We get `ERROR_BAD_NETPATH` (53) on AppVeyor which is translated to
ENOENT (2).
2017-06-02 09:28:16 -07:00
Johan Liu aead53b6ee bpo-30245: Fix possible overflow when organize struct.pack_into error message (#1682) 2017-06-02 14:33:04 +08:00
Xiang Zhang 0b4b57df96 bpo-30378: Fix the problem that SysLogHandler can't handle IPv6 addresses (#1676) 2017-06-01 21:11:56 +08:00
Albert-Jan Nijburg fc354f0785 bpo-25324: copy tok_name before changing it (#1608)
* add test to check if were modifying token

* copy list so import tokenize doesnt have side effects on token

* shorten line

* add tokenize tokens to token.h to get them to show up in token

* move ERRORTOKEN back to its previous location, and fix nitpick

* copy comments from token.h automatically

* fix whitespace and make more pythonic

* change to fix comments from @haypo

* update token.rst and Misc/NEWS

* change wording

* some more wording changes
2017-05-31 16:00:21 +02:00
Gregory P. Smith 85aba238e4 subprocess test_empty_env typo fix. (#1877) 2017-05-30 16:21:47 -07:00
Gregory P. Smith b351248c1f bpo-12383: Refactor subprocess test_empty_env (#1874)
Bugfix: This test wasn't being run because it was skipping based on the
presence of Py_ENABLE_SHARED rather than its value.  It is always present
on POSIX systems but defaults to 0.

Refactoring: Move the environment variables that can be ignored into a
function.  Parse the list from the child process and filter out the ones
to exclude in the parent before checking that the rest is empty.

Feature: Adds always present environment variables to ignore when
running in a Gentoo sandbox so that the test can pass there.
2017-05-30 14:40:37 -07:00
Gregory P. Smith 163468a766 bpo-16500: Don't use string constants for os.register_at_fork() behavior (#1834)
Instead use keyword only arguments to os.register_at_fork for each of the scenarios.
Updates the documentation for clarity.
2017-05-29 10:03:41 -07:00
Antoine Pitrou 346cbd351e bpo-16500: Allow registering at-fork handlers (#1715)
* bpo-16500: Allow registering at-fork handlers

* Address Serhiy's comments

* Add doc for new C API

* Add doc for new Python-facing function

* Add NEWS entry + doc nit
2017-05-27 17:50:54 +02:00
grzgrzgrz3 bc50f03db4 bpo-30414: multiprocessing.Queue._feed do not break from main loop on exc (#1683)
* bpo-30414: multiprocesing.Queue._feed do not break from main loop on exc

Queue background running thread was not handling exceptions correctly.
Any exception occurred inside thread (putting unpickable object) cause
feeder to finish running. After that every message put into queue is
silently ignored.

* bpo-30414: multiprocesing.Queue._feed do not break from main loop on exc

Queue background running thread was not handling exceptions correctly.
Any exception occurred inside thread (putting unpickable object) cause
feeder to finish running. After that every message put into queue is
silently ignored.
2017-05-25 16:22:57 +02:00
Serhiy Storchaka 0cd7a3f196 bpo-29104: Fixed parsing backslashes in f-strings. (#490) 2017-05-25 13:33:55 +03:00
Eric Snow d1c3c13fed bpo-30447: Fix/skip the subinterpreters test on some platforms. (#1791) 2017-05-24 17:19:47 -07:00
Garvit Khatri 94987826e8 bpo-29851: Have importlib.reload() raise ImportError if the module's spec is not found (GH-972) 2017-05-24 15:19:50 -07:00
codedragon 3480ef9dd3 bpo-30445: Allow appended output in RecursionError message
Running under coverage sometimes causes 'in comparison' to be added to the end of the RecursionError message, which is acceptable.

Patched by Maria Mckinley
2017-05-24 16:23:46 -05:00
Kushal Das 1de4705d00 bpo-30442: Skips refcount test in test_xml_etree under coverage (#1767) 2017-05-24 11:46:43 -07:00
Albert-Jan Nijburg c471ca448c bpo-30377: Simplify handling of COMMENT and NL in tokenize.py (#1607) 2017-05-24 14:31:57 +03:00
Stéphane Wirtel a17a2f52c4 bpo-28707: Add the directory parameter to http.server.SimpleHTTPRequestHandler and http.server module (#1776)
* bpo-28707: call the constructor of SimpleHTTPRequestHandler in the test with a mock object

* bpo-28707: Add the directory parameter to http.server.SimpleHTTPRequestHandler and http.server module
2017-05-24 00:29:06 -07:00
Eric Snow bb1c0346b9 Revert an invalid change to a test (from 6b4be19). (#1770) 2017-05-23 16:40:03 -07:00
Steve Dower 9b33bf50da Improves test_underpth_nosite_file to reveal why it fails. (#1763)
* Improves test_underpth_nosite_file to reveal why it fails.

* Enable building with Windows 10 SDK.

* Fix WinSDK detection

* Fix initialization on Windows when a ._pth file exists.

* Fix tabs

* Adds comment about Py_GetPath call.
2017-05-23 16:25:25 -07:00
Gregory P. Smith 56bc3b768c bpo-29335 - apply suggested test_subprocess simplifications from haypo and Zach: (#1757)
use faulthandler._sigsegv() and ctypes.util.find_library('c')
2017-05-23 07:49:13 -07:00
Roy Williams 002665a9da bpo-30432: FileInput doesn't accept PathLike objects for file names (#1732)
* Allow FileInput to accept a single PathLike object as a parameter for `files`

Fixes

bpo-30432: FileInput doesn't accept PathLike objects for file names

* Address comments from @ambv
2017-05-22 22:24:17 -07:00
Eric Snow 6b4be195cd bpo-22257: Small changes for PEP 432. (#1728)
PEP 432 specifies a number of large changes to interpreter startup code, including exposing a cleaner C-API. The major changes depend on a number of smaller changes. This patch includes all those smaller changes.
2017-05-22 21:36:03 -07:00
Thomas Kluyver f9169ce6b4 bpo-25532: Protect against infinite loops in inspect.unwrap() (#1717)
Some objects (like test mocks) auto-generate new objects on
attribute access, which can lead to an infinite loop in
inspect.unwrap().

Ensuring references are retained to otherwise temporary objects
and capping the size of the memo dict turns this case into a
conventional exception instead.
2017-05-23 13:27:52 +10:00
Eric Snow e377416c10 bpo-29102: Add a unique ID to PyInterpreterState. (#1639) 2017-05-22 19:46:40 -07:00
Xiang Zhang 89a5e03244 bpo-30003: Fix handling escape characters in HZ codec (#1556) 2017-05-22 22:42:05 +08:00
Serhiy Storchaka 817554715b bpo-30415: Add new tests for the fnmatch module. (#1684) 2017-05-21 08:57:00 +03:00
Serhiy Storchaka 753bca3934 bpo-27945: Fixed various segfaults with dict. (#1657)
Based on patches by Duane Griffin and Tim Mitchell.
2017-05-20 12:30:02 +03:00
Serhiy Storchaka d896985bb2 bpo-25794: Fix `type.__setattr__()` for non-interned attribute names. (#1652)
Based on patch by Eryk Sun.
2017-05-20 08:48:06 +03:00
Victor Stinner fcdd9b6b7e bpo-27103: regrtest disables -W if -R is used (#1651)
Workaround for a regrtest bug.
2017-05-18 13:03:24 -07:00
Nathaniel J. Smith ab4413a7e9 bpo-30039: Don't run signal handlers while resuming a yield from stack (#1081)
If we have a chain of generators/coroutines that are 'yield from'ing
each other, then resuming the stack works like:

- call send() on the outermost generator
- this enters _PyEval_EvalFrameDefault, which re-executes the
  YIELD_FROM opcode
- which calls send() on the next generator
- which enters _PyEval_EvalFrameDefault, which re-executes the
  YIELD_FROM opcode
- ...etc.

However, every time we enter _PyEval_EvalFrameDefault, the first thing
we do is to check for pending signals, and if there are any then we
run the signal handler. And if it raises an exception, then we
immediately propagate that exception *instead* of starting to execute
bytecode. This means that e.g. a SIGINT at the wrong moment can "break
the chain" – it can be raised in the middle of our yield from chain,
with the bottom part of the stack abandoned for the garbage collector.

The fix is pretty simple: there's already a special case in
_PyEval_EvalFrameEx where it skips running signal handlers if the next
opcode is SETUP_FINALLY. (I don't see how this accomplishes anything
useful, but that's another story.) If we extend this check to also
skip running signal handlers when the next opcode is YIELD_FROM, then
that closes the hole – now the exception can only be raised at the
innermost stack frame.

This shouldn't have any performance implications, because the opcode
check happens inside the "slow path" after we've already determined
that there's a pending signal or something similar for us to process;
the vast majority of the time this isn't true and the new check
doesn't run at all.
2017-05-17 13:33:23 -07:00
Dong-hee Na 378d70642a bpo-30149: Fix partialmethod without explicit self parameter (#1308) 2017-05-17 12:00:51 -07:00
Victor Stinner f8d05b3a24 bpo-30387: Fix warning in test_threading (#1634)
test_is_alive_after_fork() now joins directly the thread to avoid the
following warning added by bpo-30357:

Warning -- threading_cleanup() failed to cleanup 0 threads
after 2 sec (count: 0, dangling: 21)

Use also a different exit code to catch generic exit code 1.
2017-05-17 11:58:50 -07:00
Xiang Zhang 6f75bc003a bpo-30301: Fix AttributeError when using SimpleQueue.empty() (#1601)
Under  *spawn* and *forkserver* start methods, SimpleQueue.empty() could
raise AttributeError due to not setting _poll in __setstate__.
2017-05-17 21:04:00 +08:00
Serhiy Storchaka c7ac7280c3 bpo-30375: Correct the stacklevel of regex compiling warnings. (#1595)
Warnings emitted when compile a regular expression now always point
to the line in the user code.  Previously they could point into inners
of the re module if emitted from inside of groups or conditionals.
2017-05-16 15:16:15 +03:00
Senthil Kumaran 1bd7d299bd Remove unused variable in test_urllibnet. (#1598) 2017-05-15 23:08:07 -07:00
Victor Stinner 7d6320ba47 bpo-30339: test_multiprocessing_main_handling timeout (#1593)
test_multiprocessing_main_handling: increase the test_source timeout
from 10 seconds to 60 seconds, since the test fails randomly on busy
buildbots.
2017-05-15 18:14:42 +02:00
Victor Stinner 79ef7f8e88 bpo-30357: test_thread now uses threading_cleanup() (#1592)
test_thread: setUp() now uses support.threading_setup() and
support.threading_cleanup() to wait until threads complete to avoid
random side effects on following tests.

Co-Authored-By:  Grzegorz Grzywacz <grzegorz.grzywacz@nazwa.pl>
2017-05-15 17:55:32 +02:00
Serhiy Storchaka edef358ed6 bpo-29196: Removed old-deprecated classes Plist, Dict and _InternalDict (#488)
in the plistlib module.  Dict values in the result of functions
readPlist() and readPlistFromBytes() are now exact dicts.
2017-05-15 13:21:31 +03:00
Victor Stinner 89a1c93f04 bpo-9850: Deprecate the macpath module (#1540)
Co-Authored-By: Chi Hsuan Yen <yan12125@gmail.com>.
2017-05-15 11:01:21 +02:00
Xiang Zhang 7c278a5eeb bpo-30110: fix resource leak in test_asyncio.test_events (#1413) 2017-05-15 11:56:40 +08:00
Zachary Ware d48214f22c bpo-29763: Clean up _pth tests (GH-954) 2017-05-14 15:49:46 -05:00
Serhiy Storchaka 4ab6abfca4 bpo-30299: Display a bytecode when compile a regex in debug mode. (#1491)
`re.compile(..., re.DEBUG)` now displays the compiled bytecode in
human readable form.
2017-05-14 09:05:13 +03:00
Serhiy Storchaka 821a9d146b bpo-30340: Enhanced regular expressions optimization. (#1542)
This increased the performance of matching some patterns up to 25 times.
2017-05-14 08:32:33 +03:00
csabella f111fd2e65 bpo-30308: Code coverage for argument in random.shuffle (#1504)
* bpo-30308: Code coverage for argument in random.shuffle

* bpo-30308: Code coverage for argument in random.shuffle

* bpo-30308: Code coverage for argument in random.shuffle
2017-05-11 08:19:35 -07:00
INADA Naoki 991adca012 bpo-30048: asyncio: fix Task.cancel() was ignored. (GH-1097)
when there are no more `await` or `yield (from)` before return in coroutine,
cancel was ignored.

example:

    async def coro():
        asyncio.Task.current_task().cancel()
        return 42
    ...
    res = await coro()  # should raise CancelledError
2017-05-11 21:18:38 +09:00
Serhiy Storchaka 305ccbe27e bpo-30298: Weaken the condition of deprecation warnings for inline modifiers. (#1490)
Now allowed several subsequential inline modifiers at the start of the
pattern (e.g. '(?i)(?s)...').  In verbose mode whitespaces and comments
now are allowed before and between inline modifiers (e.g.
'(?x) (?i) (?s)...').
2017-05-10 06:05:20 +03:00
Victor Stinner 211a392cc1 bpo-30320: test_eintr now uses pthread_sigmask() (#1523)
Rewrite sigwaitinfo() and sigtimedwait() unit tests for EINTR using
pthread_sigmask() to fix a race condition between the child and the
parent process.

Remove the pipe which was used as a weak workaround against the race
condition.

sigtimedwait() is now tested with a child process sending a signal
instead of testing the timeout feature which is more unstable
(especially regarding to clock resolution depending on the platform).
2017-05-10 02:37:42 +02:00
Serhiy Storchaka 6d336a0279 bpo-30285: Optimize case-insensitive matching and searching (#1482)
of regular expressions.
2017-05-09 23:37:14 +03:00
Serhiy Storchaka f93234bb8a bpo-30024: Circular imports involving absolute imports with binding (#1264)
a submodule to a name are now supported.
2017-05-09 22:31:05 +03:00
Victor Stinner 74683fc624 bpo-30258: regrtest: Fix run_tests_multiprocess() (#1479)
If the child process exited with a non-zero code, don't strip the
last line of stdout anymore.

Add also a sanity check in accumulate_result().
2017-05-09 11:34:01 +02:00
Xiang Zhang 9da408d15b bpo-29990: Fix range checking in GB18030 decoder (#1495)
When decoding a 4-byte GB18030 sequence, the first and third byte cannot exceed 0xFE.
2017-05-09 11:38:32 +08:00
Pierre Quentel cc3fa204d3 bpo-29979: Rewrite cgi.parse_multipart to make it consistent with FieldStorage (#991) 2017-05-08 05:08:34 -07:00
Jelle Zijlstra a12df7b7d4 bpo-30218: support path-like objects in shutil.unpack_archive() (GH-1367)
Thanks to Jelle Zijlstra for the patch.
2017-05-05 14:27:12 -07:00
Victor Stinner ef9c0e732f bpo-30264: ExpatParser closes the source on error (#1451)
ExpatParser.parse() of xml.sax.xmlreader now always closes the
source: close the file object or the urllib object if source is a
string (not an open file-like object). The change fixes a
ResourceWarning on parsing error.

Add test_parse_close_source() unit test.
2017-05-05 09:46:47 +02:00
Serhiy Storchaka 7186cc29be bpo-30277: Replace _sre.getlower() with _sre.ascii_tolower() and _sre.unicode_tolower(). (#1468) 2017-05-05 10:42:46 +03:00
Serhiy Storchaka 898ff03e1e bpo-30215: Make re.compile() locale agnostic. (#1361)
Compiled regular expression objects with the re.LOCALE flag no longer
depend on the locale at compile time.  Only the locale at matching
time affects the result of matching.
2017-05-05 08:53:40 +03:00
Victor Stinner 3d0056842c bpo-30263: regrtest: log system load (#1452)
* bpo-30263: regrtest: log system load

* regrtest: log the number of CPUs

Log the number of CPUs in the header. --verbose now imply --header.
2017-05-04 15:21:12 +02:00
Serhiy Storchaka 5f161fd86d bpo-30184: Add tests for invalid use of PyArg_ParseTupleAndKeywords. (#1316) 2017-05-04 00:03:23 +03:00
Xiang Zhang 13f1f423fa bpo-30103: Allow Uuencode in Python using backtick as zero instead of space (#1326) 2017-05-03 11:16:21 +08:00
Antoine Pitrou 0360a9d015 Fix tests: getsockname() can return None on OS X on unbound sockets (#1400) 2017-05-02 23:48:26 +02:00
Jim Fasarakis-Hilliard 094909ad69 Remove outdated tests in test_isinstance (GH-1393)
There is no need to test for new-style classes versus classic classes in Python 3.
2017-05-02 10:17:18 -07:00
Ivan Levkivskyi f06e0218ef bpo-28556: Routine updates to typing (#1366)
- Add NoReturn type
- Use WrapperDescriptorType (original PR by Jim Fasarakis-Hilliard)
- Minor bug-fixes
2017-05-02 10:14:07 -07:00
Antoine Pitrou 495b5021e7 bpo-30205: Fix getsockname() for unbound AF_UNIX sockets on Linux (#1370)
* bpo-30205: Fix getsockname() for unbound AF_UNIX sockets on Linux

* Add NEWS entry
2017-05-02 17:20:00 +02:00
Victor Stinner 1dae7450c6 bpo-30199: test_ssl closes all asyncore channels (#1381)
AsyncoreEchoServer of test_ssl now calls
asyncore.close_all(ignore_all=True) to ensure that
asyncore.socket_map is cleared once the test completes, even if
ConnectionHandler was not correctly unregistered.

Fix the following warning:

Warning -- asyncore.socket_map was modified by test_ssl
  Before: {}
  After:  {6: <test.test_ssl.AsyncoreEchoServer.EchoServer.ConnectionHandler>}
2017-05-02 13:12:02 +02:00
Jelle Zijlstra 2e624690bd bpo-29679: Implement @contextlib.asynccontextmanager (#360) 2017-04-30 18:25:58 -07:00
Serhiy Storchaka 3cc8259b71 bpo-30158: Fix deprecation warnings in test_importlib introduced by bpo-29576. (#1285) 2017-04-29 07:06:49 +03:00
Serhiy Storchaka d1a1def7bf bpo-30197: Enhance functions swap_attr() and swap_item() in test.support. (#1341)
* bpo-30197: Enhance functions swap_attr() and swap_item() in test.support.

They now work when delete replaced attribute or item inside the with
statement.  The old value of the attribute or item (or None if it doesn't
exist) now will be assigned to the target of the "as" clause, if there is
one.

* Update docstrings.
2017-04-28 18:17:26 +02:00
Victor Stinner 5bccca58b9 bpo-30175: Skip client cert tests of test_imaplib (#1320)
* bpo-30175: Skip client cert tests of test_imaplib

The IMAP server cyrus.andrew.cmu.edu doesn't accept our randomly
generated client x509 certificate anymore.

* bpo-30188: Catch EOFError in NetworkedNNTPTests

test_nntplib fails randomly with EOFError in
NetworkedNNTPTests.setUpClass(). Catch EOFError to skip tests in that
case.
2017-04-27 17:30:13 +02:00
Victor Stinner 8ca2f2faef bpo-30131: test_logging now joins queue threads (#1298)
QueueListenerTest of test_logging now closes the multiprocessing
Queue and joins its thread to prevent leaking dangling threads to
following tests.

Add also @support.reap_threads to detect earlier if a test leaks
threads (and try to "cleanup" these threads).
2017-04-26 15:56:25 +02:00
Victor Stinner d819ad9832 bpo-30107: Make SuppressCrashReport quiet on macOS (#1279)
On macOS, SuppressCrashReport now redirects /usr/bin/defaults command
stderr into a pipe to not pollute stderr. It fixes a
test_io.test_daemon_threads_shutdown_stderr_deadlock() failure when
the CrashReporter domain doesn't exists. Message logged into stderr:

2017-04-24 16:57:21.432 defaults[41046:2462851]
The domain/default pair of (com.apple.CrashReporter, DialogType) does not exist
2017-04-26 00:55:08 +02:00
Jim Fasarakis-Hilliard 08c16016e2 bpo:29950: Rename SlotWrapperType to WrapperDescriptorType (GH-926) 2017-04-25 21:26:36 +03:00
Victor Stinner 4bcfa3a236 bpo-30131: Cleanup threads in test_logging (#1275)
* Use @support.reap_threads on unit tests creating threads
* Call TestCase.fail() on thread.join(timeout) failure
2017-04-25 00:41:36 +02:00
Nate fcfe80ec25 bpo-29822: Make inspect.isabstract() work during __init_subclass__. (#678)
At the time when an abstract base class' __init_subclass__ runs,
ABCMeta.__new__ has not yet finished running, so in the presence of
__init_subclass__, inspect.isabstract() can no longer depend only on
TPFLAGS_IS_ABSTRACT.
2017-04-24 20:06:15 +03:00
Serhiy Storchaka 2e576f5aec bpo-30144: Import collections ABC from collections.abc rather than collections. (#1263) 2017-04-24 09:05:00 +03:00
bladebryan 9616a82e78 bpo-29960 _random.Random corrupted on exception in setstate(). (#1019) 2017-04-22 09:10:46 +03:00
Victor Stinner a36e939aeb bpo-30125: disable faulthandler in ctypes test_SEH (#1237)
Disable faulthandler to run test_SEH() of test_ctypes to prevent the
following log with a traceback:

    Windows fatal exception: access violation

Add support.disable_faulthandler() context manager.
2017-04-22 00:31:13 +02:00
Victor Stinner 46c2b81026 bpo-30125: Fix faulthandler.disable() on Windows (#1240)
* bpo-30125: Cleanup faulthandler.c

* Use size_t type for iterators
* Add { ... }

* bpo-30125: Fix faulthandler.disable() on Windows

On Windows, faulthandler.disable() now removes the exception handler
installed by faulthandler.enable().
2017-04-21 18:06:13 +02:00
Victor Stinner 2a1aed04b0 bpo-30107: don't dump core on expected test_io crash (#1235)
test_io has two unit tests which trigger a deadlock:

* test_daemon_threads_shutdown_stdout_deadlock()
* test_daemon_threads_shutdown_stderr_deadlock()

These tests call Py_FatalError() if the expected bug is triggered
which calls abort(). Use test.support.SuppressCrashReport to prevent
the creation on a core dump, to fix the warning:

Warning -- files was modified by test_io
  Before: []
  After:  ['python.core']
2017-04-21 17:59:23 +02:00
Victor Stinner a2c877c398 bpo-30106: Fix test_asyncore.test_quick_connect() (#1234)
test_quick_connect() runs a thread up to 50 seconds, whereas the
socket is connected in 0.2 second and then the thread is expected to
end in less than 3 second. On Linux, the thread ends quickly because
select() seems to always return quickly. On FreeBSD, sometimes
select() fails with timeout and so the thread runs much longer than
expected.

Fix the thread timeout to fix a race condition in the test.
2017-04-21 13:51:53 +02:00
Serhiy Storchaka 40db90c1ce bpo-29802: Fix reference counting in module-level struct functions (#1213)
when pass arguments of wrong type.
2017-04-20 21:19:31 +03:00
Victor Stinner d20324a7fa support.threading_cleanup() log a warning on fail (#1195)
The @reap_threads decorator and the threading_cleanup() function of
test.support now log a warning if they fail to clenaup threads.

Fix also the usage of support.threading_cleanup() in
test_urllib2_localnet.

The log may help to debug such other warning seen on the AMD64
FreeBSD CURRENT Non-Debug 3.x buildbot:

Warning -- threading._dangling was modified by test_logging
2017-04-20 13:40:08 +02:00
Victor Stinner b85c136903 bpo-30108: Restore sys.path in test_site (#1197)
Add setUpModule() and tearDownModule() functions to test_site to
save/restore sys.path at the module level to prevent warning if the
user site directory is created, since site.addsitedir() modifies
sys.path.
2017-04-20 13:39:39 +02:00
Dong-hee Na b4dc6af7a7 bpo-12414: Update code_sizeof() to take in account co_extra memory. (#1168) 2017-04-20 10:31:17 +03:00
Mariatta 58f3c9dc8f bpo-30109: Fix reindent.py (GH-1207)
Skip the file if it has bad encoding.
2017-04-19 22:59:20 -07:00
Victor Stinner 11470b6dcd bpo-30106: Fix tearDown() of test_asyncore (#1194)
Call asyncore.close_all() with ignore_all=True in the tearDown()
method of the test_asyncore base test case. It should prevent keeping
alive sockets in asyncore.socket_map if close() fails with an
unexpected error.

Revert also an unwanted change of my previous commit: remove name
parameter of Thread in test_quick_connect().
2017-04-20 02:55:39 +02:00
Victor Stinner d13d54748d bpo-29887: test_normalization handles PermissionError (#1196)
Skip test_normalization.test_main() if download raises a permission
error.
2017-04-20 02:39:59 +02:00
Victor Stinner ec4b17239d regrtest: always show before/after of modified env (#1192)
Buildbots don't run tests with -vv and so only log "xxx was modified
by test_xxx" which is not enough to debug such random issue. In many
cases, I'm unable to reproduce the warning and so unable to fix it.

Always logging the value before and value after should help to debug
such warning on buildbots.
2017-04-20 00:57:30 +02:00
Victor Stinner 7b9619ae24 Fix/optimize test_asyncore.test_quick_connect() (#1188)
Don't use addCleanup() in test_quick_connect() because it keeps the
Thread object alive and so @reap_threads fails on its timeout of 1
second. "./python -m test -v test_asyncore -m test_quick_connect"
now takes 185 ms, instead of 11 seconds.

Other minor changes:

* Use "with sock:" to close the socket instead of
  try/finally: sock.close()
* Use self.skipTest() in test_quick_connect() to remove one
  indentation level and notice user that the test is specific to
  AF_INET and AF_INET6
2017-04-19 23:42:46 +02:00
Victor Stinner 1e62bf145b bpo-30030: Revert f50354ad (tempfile) (#1187)
Revert f50354adaaafebe95ad09d09b825804a686ea843: it introduced a
regression in test_threadedtempfile.
2017-04-19 22:59:51 +02:00
Serhiy Storchaka 66bffd1663 bpo-30065: Fixed arguments validation in _posixsubprocess.fork_exec(). (#1110) 2017-04-19 21:12:46 +03:00
Serhiy Storchaka a79f4c2195 bpo-30070: Fixed leaks and crashes in errors handling in the parser module. (#1131) 2017-04-19 21:09:21 +03:00
Serhiy Storchaka d90045f319 bpo-22352: Adjust widths in the output of dis.dis() for large line numbers and (#1153)
instruction offsets.

Add tests for widths of opcode names.
2017-04-19 20:36:31 +03:00
Serhiy Storchaka bf623ae884 bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096)
raised an error.

Replace them with using concrete types API that never fails if appropriate.
2017-04-19 20:03:52 +03:00
Victor Stinner c209b70d61 bpo-29925: Skip test_uuid1_safe() on OS X Tiger (#971) 2017-04-19 13:01:03 +02:00
cocoatomo 992ae6444c Fix minor typos (GH-1173) 2017-04-18 17:38:26 -07:00
Eric Appelt d6d344d833 bpo-29514: Check magic number for bugfix release (#54)
* bpo-29514: Check magic number for micro release

Add a dict importlib.util.EXPECTED_MAGIC_NUMBERS which
details the initial and expected pyc magic number for
each minor release. This gives a mechanism for users to
check if the magic number has changed within a release and
for a test to ensure procedure is followed if a change is
necessary.

Add a test to check the current MAGIC_NUMBER against the
expected number for the release if the current release is
at candidate or final level. On test failure, describe to
the developer the procedure for changing the magic number.

* Simplify magic number release test

Simplify the magic number release test by removing
EXPECTED_MAGIC_NUMBERS table and making the expected
magic number self-contained within the test.

BPO: 29514

* Improve magic number test execution and message

Improve the execution of the magic number test by
using skipUnless for alpha and beta releases, and
directly inheriting from unittest.TestCase rather than
using the machinery for the other tests. Also improve
the error message to explain the reason for caution in
changing the magic number.

BPO: 29514
2017-04-17 11:35:43 -07:00
Serhiy Storchaka 55fe1ae970 bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
Serhiy Storchaka fdbd01151d bpo-10076: Compiled regular expression and match objects now are copyable. (#1000) 2017-04-16 10:16:03 +03:00
Serhiy Storchaka baf9f29811 bpo-29839: Raise ValueError rather than OverflowError in len() for negative values. (#701) 2017-04-16 09:37:18 +03:00
Xiang Zhang 026435ce49 bpo-30068: add missing iter(self) in _io._IOBase.readlines when hint is present (#1130) 2017-04-15 12:47:28 +08:00
Antoine Pitrou 685cdb9acc Relax test timing (bpo-29861) to avoid sporadic failures (#1120) 2017-04-14 13:10:00 +02:00
Armin Rigo 22a594a004 bpo-29694: race condition in pathlib mkdir with flags parents=True (GH-1089) 2017-04-13 11:08:15 -07:00
Serhiy Storchaka 5908300e4b bpo-29995: re.escape() now escapes only special characters. (#1007) 2017-04-13 21:06:43 +03:00
Serhiy Storchaka 4c0d9ea995 bpo-30017: Allowed calling the close() method of the zip entry writer object (#1041)
multiple times.  Writing to closed zip entry writer object now always produce
a ValueError.
2017-04-12 16:03:23 +03:00
Serhiy Storchaka f50354adaa Reimplement tempfile._RandomNameSequence using a generator function. (#1075) 2017-04-11 22:45:59 +03:00
svelankar 00c75e9a45 bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError (GH-949)
contextlib._GeneratorContextManager.__exit__ includes a special case to deal with
PEP 479 RuntimeErrors created when `StopIteration` is thrown into the context
manager body.

Previously this check was too permissive, and undid one level of chaining on *all*
RuntimeError instances, not just those that wrapped a StopIteration instance.
2017-04-11 19:11:13 +10:00
Michael Seifert 64c8f705c0 bpo-29951: Include function name for some error messages in `PyArg_ParseTuple*` (#916)
Also changed format specifier for function name from "%s" to "%.200s"
and exception messages should start with lowercase letter.
2017-04-09 10:47:12 +03:00
Serhiy Storchaka b785396ab4 bpo-29998: Pickling and copying ImportError now preserves name and path (#1010)
attributes.
2017-04-08 09:55:07 +03:00
Serhiy Storchaka 205e00c5cf bpo-29914: Fix default implementations of __reduce__ and __reduce_ex__(). (#843)
object.__reduce__() no longer takes arguments, object.__reduce_ex__() now
requires one argument.
2017-04-08 09:52:59 +03:00
Serhiy Storchaka 150cd1916a bpo-29958: Minor improvements to zipfile and tarfile CLI. (#944) 2017-04-07 18:56:12 +03:00
Senthil Kumaran fd0cd07a5a Remove Invalid comment in test_urllib2.py (#1020) 2017-04-07 00:19:08 -07:00
Mark Dickinson a0ce375e10 bpo-29962: add math.remainder (#950)
* Implement math.remainder.

* Fix markup for arguments; use double spaces after period.

* Mark up function reference in what's new entry.

* Add comment explaining the calculation in the final branch.

* Fix out-of-order entry in whatsnew.

* Add comment explaining why it's good enough to compare m with c, in spite of possible rounding error.
2017-04-05 18:34:27 +01:00
Senthil Kumaran 257b980b31 correct parse_qs and parse_qsl test case descriptions. (#968)
* correct parse_qs and parse_qsl test case descriptions.
2017-04-04 21:19:43 -07:00
Andrew Nester f78b119364 bpo-29649: Improve struct.pack_into() boundary error messages (#424) 2017-04-04 13:46:25 +03:00
Victor Stinner 5de85a1702 bpo-29972: Skip tests known to fail on AIX (#979)
* bpo-29972: Fix test_eintr on AIX

On AIX, sigtimedwait(0.2) sleeps 199.8 ms, whereas the test expects
200 ms or longer.

* bpo-29972: Skip some inet_pton() tests on AIX

Skip some inet_pton() tests of test_socket on AIX.

inet_pton() on AIX is less strict than on Linux and doesn't reject
some invalid IP addresses. The unit tests test more the libc than
Python itself.

* bpo-29972: Skip tests known to fail on AIX

* test_locale.test_strcoll_with_diacritic()
* test_locale.test_strxfrm_with_diacritic()
* test_strptime.test_week_of_year_and_day_of_week_calculation()
* test_tools.test_POT_Creation_Date()
2017-04-04 10:35:15 +02:00
Victor Stinner 9acc6a03f1 test_locale now ignores the DeprecationWarning (#977)
Don't fail anymore if test run with python3 -Werror.

Fix also deprecation message: add a space.
2017-04-03 18:09:55 +02:00
Pierre Quentel 351adda54b bpo-29654 : Support If-Modified-Since HTTP header (browser cache) (#298)
Return 304 response if file was not modified.
2017-04-02 13:26:12 +03:00
Senthil Kumaran efbd4ea65d Minor spell fix and formatting fixes in urllib tests. (#959) 2017-04-01 23:47:35 -07:00
Zachary Ware cd815edf01 Revert "bpo-29763: Use unittest cleanup in test_site (GH-841)" (GH-942)
This reverts commit b94d7fd4ef.
2017-04-01 01:29:31 -05:00
s-sanjay 7bd8d3e794 bpo-29931 fix __lt__ check in ipaddress.ip_interface for both v4 and v6. (#879)
the original logic was just comparing the network address
but this is wrong because if the network address is equal then
we need to compare the ip address for breaking the tie

add more ip_interface comparison tests
2017-04-01 09:09:53 +03:00
Senthil Kumaran 1f5425ff69 Add helpful explaination to test_password_manager tests. (#936)
Also uncomment and fix a path test.
2017-03-31 22:27:27 -07:00
Zachary Ware b94d7fd4ef bpo-29763: Use unittest cleanup in test_site (GH-841) 2017-04-01 00:18:23 -05:00
Serhiy Storchaka 314d6fca36 bpo-29953: Fix memory leaks in the replace() method of datetime and time (#927)
objects when pass out of bound fold argument.
2017-03-31 22:48:16 +03:00
Senthil Kumaran ed3dd1c02a Remove catching OSError in ftphandler test. Only URLError is raised in urllib.request module. (#918) 2017-03-30 22:43:05 -07:00
T. Wouters 5466d4af5f bpo-29942: Fix the use of recursion in itertools.chain.from_iterable. (#889)
Fix the use of recursion in itertools.chain.from_iterable. Using recursion
is unnecessary, and can easily cause stack overflows, especially when
building in low optimization modes or with Py_DEBUG enabled.
2017-03-30 09:58:35 -07:00
Serhiy Storchaka 762ec97ea6 bpo-29204: Emit warnings for already deprecated ElementTree features. (#773)
Element.getiterator() and the html parameter of XMLParser() were
deprecated only in the documentation (since Python 3.2 and 3.4 correspondintly).
Now using them emits a deprecation warning.

* Don’t need check_warnings any more.
2017-03-30 18:12:06 +03:00
Victor Stinner 722a3af092 bpo-29887: Test normalization now fails if download fails (#905)
* test_normalization fails if download fails

bpo-29887. The test is still skipped if "-u urlfetch" option is not
passed to regrtest (python3 -m test -u urlfetch test_normalization).

* Fix ResourceWarning in test_normalization

bpo-29887: Fix ResourceWarning in test_normalization if tests are
interrupted by CTRL+c.
2017-03-30 17:06:53 +02:00
Serhiy Storchaka f15c4d374a bpo-20548: Use specific asserts in warnings and exceptions tests (#788) 2017-03-30 18:05:08 +03:00
Serhiy Storchaka 576def096e bpo-27863: Fixed multiple crashes in ElementTree. (#765) 2017-03-30 09:47:31 +03:00
Serhiy Storchaka 918403cfc3 bpo-29816: Shift operation now has less opportunity to raise OverflowError. (#680)
ValueError always is raised rather than OverflowError for negative counts.
Shifting zero with non-negative count always returns zero.
2017-03-30 09:47:07 +03:00
Serhiy Storchaka ea720fe7e9 bpo-25996: Added support of file descriptors in os.scandir() on Unix. (#502)
os.fwalk() is sped up by 2 times by using os.scandir().
2017-03-30 09:12:31 +03:00
Senthil Kumaran e6911a44f6 Remove an unrequired TODO in test_urllib2. (#897) 2017-03-29 23:02:29 -07:00
Xiang Zhang 794623bdb2 bpo-28699: fix abnormal behaviour of pools in multiprocessing.pool (GH-693)
an exception raised at the very first of an iterable would cause pools behave abnormally
(swallow the exception or hang)
2017-03-29 11:58:54 +08:00
Vajrasky Kok ec1f5df46e bpo-19791: Use functions from test support to check the symlink support. (GH-822) 2017-03-28 12:32:35 -07:00
Garvit Khatri 1cf93a76c2 bpo-10379: add 'monetary' to format_string, deprecate format
Add the 'monetary' parameter to format_string so that all
uses of format can be converted to format_string.  Adjust
the documentation accordingly, and add a deprecation
warning when format is used.
2017-03-28 11:43:38 -04:00
Jim Fasarakis-Hilliard d702c50049 bpo-29912: Remove redundant tests in list_tests that are found in seq_tests (GH-847) 2017-03-27 12:35:52 -07:00
Victor Stinner d6debb24e0 bpo-29919: Remove unused imports found by pyflakes (#137)
Make also minor PEP8 coding style fixes on modified imports.
2017-03-27 16:05:26 +02:00
Serhiy Storchaka 604e74c6be bpo-20552: Use specific asserts in bytes tests (#790) 2017-03-27 12:59:07 +02:00
Zachary Ware b8a7daf077 Minor test cleanup (GH-837)
* Remove unused test file

* Remove duplicated text in sndhdrdata README
2017-03-27 00:08:31 -05:00
Serhiy Storchaka 671079ef60 bpo-29894: Deprecate returning an instance of complex subclass from __complex__. (#798)
In a future versions of Python this can be an error.
2017-03-24 21:28:43 +02:00
Serhiy Storchaka af7b9ec5c8 bpo-25803: Avoid incorrect errors raised by Path.mkdir(exist_ok=True) (#805)
when the OS gives priority to errors such as EACCES over EEXIST.
2017-03-24 20:51:53 +02:00
Antoine Pitrou 8988945cdc bpo-29861: release references to multiprocessing Pool tasks (#743)
* bpo-29861: release references to multiprocessing Pool tasks

Release references to tasks, their arguments and their results as soon
as they are finished, instead of keeping them alive until another task
arrives.

* Comments in test
2017-03-24 13:52:11 +01:00
Serhiy Storchaka e304e33c16 bpo-19930: The mode argument of os.makedirs() no longer affects the file (#799)
permission bits of newly-created intermediate-level directories.
2017-03-24 13:27:42 +02:00
Serhiy Storchaka aefa7ebf0f bpo-6532: Make the thread id an unsigned integer. (#781)
* bpo-6532: Make the thread id an unsigned integer.

From C API side the type of results of PyThread_start_new_thread() and
PyThread_get_thread_ident(), the id parameter of
PyThreadState_SetAsyncExc(), and the thread_id field of PyThreadState
changed from "long" to "unsigned long".

* Restore a check in thread_get_ident().
2017-03-23 14:48:39 +01:00
Benjamin Peterson df8280838f bpo-20087: Revert "make the glibc alias table take precedence over the X11 one (#422)" (#713)
This reverts commit 02371e0ed1.
2017-03-19 23:49:43 -07:00
4kir4 e46fb86118 bpo-28876: bool of large range raises OverflowError (#699) 2017-03-20 08:44:46 +02:00
Serhiy Storchaka 24c738a9e9 bpo-29845: Mark tests that use _testcapi as CPython-only (#711) 2017-03-19 20:20:10 +02:00
Serhiy Storchaka a5af6e1af7 bpo-25455: Fixed crashes in repr of recursive buffered file-like objects. (#514) 2017-03-19 19:25:29 +02:00
Serhiy Storchaka bdf6b910f9 bpo-29776: Use decorator syntax for properties. (#585) 2017-03-19 08:40:32 +02:00
Jim Fasarakis-Hilliard cb5297a9e6 bpo-29836: Remove nturl2path from test_sundry and amend the module docstring (GH-694)
The module is implicitly tested through test_urllib.
2017-03-17 11:16:20 -07:00
Marco Buttu 3f2155ffe6 bpo-16355: Clarify when inspect.getcomments() returns None (#428)
Initial patch by Vajrasky Kok.
2017-03-17 11:50:23 +03:00
Nate bd583ef985 bpo-29581: Make ABCMeta.__new__ pass **kwargs to type.__new__ (#527)
Many metaclasses in the standard library don't play nice with
__init_subclass__. This bug makes ABCMeta in particular with
__init_subclass__, which is an 80/20 solution for me personally.
AFAICT, a general solution to this problem requires updating all
metaclasses in the standard library to make sure they pass **kwargs to
type.__new__, whereas this PR only fixes ABCMeta. For context, see
https://bugs.python.org/issue29581.

* added a test combining ABCMeta and __init_subclass__
* Added NEWS item
2017-03-15 11:39:22 -07:00
Daniel Himmelstein b4e9087e7b Fix stderr bug in json.tool test (#346)
See https://github.com/python/cpython/pull/201#discussion_r103229425.
2017-03-15 17:31:06 +03:00
Michael Seifert 6c3d527468 bpo-29800: Fix crashes in partial.__repr__ if the keys of partial.keywords are not strings (#649) 2017-03-15 07:26:33 +02:00
Jim Fasarakis-Hilliard d4914e9041 Add ELLIPSIS and RARROW. Add tests (#666) 2017-03-14 21:16:15 +01:00
Xiang Zhang 7e2a54cdd9 bpo-28856: Let %b format for bytes support objects that follow the buffer protocol (GH-546) 2017-03-14 15:07:15 +08:00
Yury Selivanov b7c9150b68 Fix wrapping into StopIteration of return values in generators and coroutines (#644) 2017-03-12 15:53:07 -04:00
Nikolay Kim 2b27e2e6a3 bpo-29742: asyncio get_extra_info() throws exception (#525) 2017-03-12 15:23:30 -04:00
Serhiy Storchaka f6595983e0 bpo-28692: Deprecate using non-integer value for selecting a plural form in gettext. (#507) 2017-03-12 13:15:01 +02:00
Nick Coghlan d2977a3ae2 bpo-29723: Consistently configure sys.path[0] (#575)
Directory and zipfile execution previously added
the parent directory of the directory or zipfile
as sys.path[0] and then subsequently overwrote
it with the directory or zipfile itself.

This caused problems in isolated mode, as it
overwrote the "stdlib as a zip archive" entry
in sys.path, as the parent directory was
never added.

The attempted fix to that issue in bpo-29319
created the opposite problem in *non*-isolated
mode, by potentially leaving the parent
directory on sys.path instead of overwriting it.

This change fixes the root cause of the problem
by removing the whole "add-and-overwrite" dance
for sys.path[0], and instead simply never adds
the parent directory to sys.path in the first
place.
2017-03-12 20:38:32 +10:00
Zachary Ware 93710c152e bpo-29763: Use support.unlink instead of os.unlink (GH-624)
support.unlink waits for the files to be removed before returning
2017-03-11 22:10:07 -06:00
Serhiy Storchaka 9e6ac83aca bpo-29773: Add more cases for testing string to float conversion errors. (#580) 2017-03-09 20:07:58 +02:00
orenmn 964281af59 bpo-28298: make array 'Q', 'L' and 'I' accept big intables as elements (#570) 2017-03-09 11:35:28 +02:00
Serhiy Storchaka a7cba27aea bpo-29645: Speed up importing the webbrowser module. (#484) 2017-03-08 17:15:54 +02:00
Serhiy Storchaka 8606e9524a bpo-28231: The zipfile module now accepts path-like objects for external paths. (#511) 2017-03-08 14:37:51 +02:00
Serhiy Storchaka c45cd167d4 bpo-28230: Document the pathlib support in tarfile and add tests. (#512) 2017-03-08 10:32:44 +02:00
Benjamin Peterson 21a74312f2 Revert "bpo-29571: Use correct locale encoding in test_re (#149)" (#554)
This reverts commit ace5c0fdd9.
2017-03-07 22:48:09 -08:00
Benjamin Peterson 02371e0ed1 make the glibc alias table take precedence over the X11 one (#422)
bpo-20087
2017-03-07 22:03:13 -08:00
Serhiy Storchaka 9f8ad3f39e bpo-29568: Disable any characters between two percents for escaped percent "%%" in the format string for classic string formatting. (GH-513) 2017-03-08 11:51:19 +08:00
Xiang Zhang c393ee8589 bpo-24329: allow __qualname__ and __classcell__ in __slots__ (GH-495) 2017-03-08 11:18:49 +08:00
Xiang Zhang d5d3249e8a bpo-26915: Test identity first in membership operation in index() and count() methods of collections.abc.Sequence (GH-503) 2017-03-08 11:04:24 +08:00
Serhiy Storchaka 8f6b344d36 bpo-28682: Added support for bytes paths in os.fwalk(). (#489) 2017-03-07 14:33:21 +02:00
Xiang Zhang d36a71637c bpo-28728: clarify possible test failure due to ISP (GH-412) 2017-03-07 11:06:09 +08:00
Serhiy Storchaka d908fd9ee1 bpo-29695: Fixed tests after removing keyword args support in some basic type constructors. (GH-520) 2017-03-06 11:08:59 -08:00
Serhiy Storchaka 2e5642422f bpo-29695: Remove bad keyword parameters in int(), bool(), float(), list() and tuple(). (#518) 2017-03-06 17:01:06 +02:00
Xiang Zhang b76ad5121e bpo-29714: Fix a regression that bytes format may fail when containing zero bytes inside. (GH-499) 2017-03-06 17:17:05 +08:00
Serhiy Storchaka 58d23e6806 bpo-29695: Deprecated using bad named keyword arguments in builtings: (#486)
int(), bool(), float(), list() and tuple().  Specify the value as a
positional argument instead.
2017-03-06 00:53:39 +02:00
Ivan Levkivskyi 7acffa23c9 bpo-29638: Fix spurious refleaks after typing is imported (#469) 2017-03-05 20:15:20 +02:00
Dillon Brock c6b448b36d Change assertRaises to assertRaisesRegex in test_xmlrpc (#481) 2017-03-05 19:27:06 +02:00
Ned Deily de04644627 bpo-28087: Skip test_asyncore and test_eintr poll failures on macOS. (#462)
* bpo-28087: Skip test_asyncore and test_eintr poll failures on macOS

Skip some tests of select.poll when running on macOS due to unresolved
issues with the underlying system poll function on some macOS versions.
2017-03-04 06:00:37 -05:00
Ned Deily 5c4b0d063a bpo-27593: Get SCM build info from git instead of hg. (#446)
sys.version and the platform module python_build(),
python_branch(), and python_revision() functions now use
git information rather than hg when building from a repo.

Based on original patches by Brett Cannon and Steve Dower.
2017-03-04 00:19:55 -05:00
David Ellis 85b8d01c91 bpo-29623: Make PathLike objects work with ConfigParser.read() (#242) 2017-03-03 20:14:27 +03:00
Anish Shah 15aa4c88f6 bpo-29693: Fix for DeprecationWarning in test_import (#421)
Patch by Anish Shah.
2017-03-03 10:12:03 +02:00
Yury Selivanov 84af903f3b bpo-28963: Fix out of bound iteration in asyncio.Future.remove_done_callback/C (#408) 2017-03-02 23:46:56 -05:00
Yury Selivanov 2f15645785 asyncio: Fix trailing whitespace/code style 2017-03-02 23:25:31 -05:00
Seth M. Larson 481cb70a72 bpo-29704: Fix asyncio.SubprocessStreamProtocol closing (#405) 2017-03-02 23:21:18 -05:00
Yury Selivanov 398ff91ac0 bpo-28893: Set __cause__ for errors in async iteration protocol (#407) 2017-03-02 22:20:00 -05:00
Yury Selivanov 8d26aa930c bpo-29271: Fix Task.current_task and Task.all_tasks to accept None. (#406) 2017-03-02 22:16:33 -05:00
Yury Selivanov ba7e1f9a4e bpo-29703: asyncio: Fix creating new event loops in child processes. (#404) 2017-03-02 20:07:11 -05:00
Matthias Bussonnier c643a967dd Add Python version since deprecation in base64 methods. (#33)
Allow developers to not have to either test on N Python versions or
looked through multiple versions of the docs to know whether they can
easily update.
2017-03-02 17:21:26 +03:00
Benjamin Peterson afbb5d1cbd require uuid_generate_time_safe for all tests of it (#390)
The way mocking is written in these tests, we need to have the underlying function around.
2017-03-01 23:34:19 -08:00
Benjamin Peterson 0b8432538a correct check for _uuid_generate_time (#388)
If ctypes is not available, _uuid_generate_time will be None not its restype attribute.
2017-03-01 21:53:14 -08:00
Benjamin Peterson 1e68716fd5 Revert "make the locale_flag fallback code work again (#375)" (#387)
This reverts commit 43f5df5bfa.
2017-03-01 21:53:00 -08:00
Petr Motejlek 3c6314c08d bpo-29615: SimpleXMLRPCDispatcher no longer chains KeyError (#260)
(or any other exception) to exception(s) raised in the dispatched methods.
Patch by Petr Motejlek.
2017-03-01 19:21:28 +02:00
Benjamin Peterson 43f5df5bfa make the locale_flag fallback code work again (#375) 2017-02-28 23:59:12 -08:00
Benjamin Peterson 371963daba use select instead of _opcode for import test (#372) 2017-02-28 23:14:09 -08:00
Benjamin Peterson bee93f2d04 weaken test_from_import_missing_attr_has_name_and_path regular expression (#371)
Windows uses backslashes for separators.
2017-02-28 22:35:00 -08:00
Xiang Zhang 267b9d2fa8 bpo-7769: enable xmlrpc.server.SimpleXMLRPCDispatcher.register_function used as decorator (GH-231) 2017-02-28 17:12:52 +08:00
Xiang Zhang f3a9faba4b bpo-29376: Fix assertion error in threading._DummyThread.is_alive() (GH-236) 2017-02-27 11:01:30 +08:00
Sayan Chowdhury d5c11f7ace bpo-28624: Add a test that checks that cwd parameter of Popen() accepts PathLike objects (#157) 2017-02-26 20:06:10 +03:00
INADA Naoki 5dc33eea53 bpo-29110: add test for Aifc_write. (GH-293)
follow up of GH-162
2017-02-26 21:11:58 +09:00
Subhendu Ghosh ae160bba20 bpo-26128: Added __init__to subprocess.STARTUPINFO (#171)
The Windows-specific subprocess.STARTUPINFO class now accepts
keyword-only arguments to its constructor to set the various
data attributes.

Patch by Subhendu Ghosh.
2017-02-26 00:59:05 +10:00
Ratnadeep Debnath 21024f0662 bpo-16285: Update urllib quoting to RFC 3986 (#173)
* bpo-16285: Update urllib quoting to RFC 3986

urllib.parse.quote is now based on RFC 3986, and hence
includes `'~'` in the set of characters that is not escaped
by default.

Patch by Christian Theune and Ratnadeep Debnath.
2017-02-25 19:00:28 +10:00
Nick Coghlan 56a8eccc43 bpo-24241: Add dedicated webbrowser.register test case (#288) 2017-02-25 18:14:07 +10:00
Ivan Levkivskyi 365cb5bb90 bpo-28556: Fix regression that sneaked into recent typing updates (GH-270) 2017-02-24 09:28:26 -08:00
Matthias Bussonnier 41cea70aa3 bpo-29637: clean docstring only if not None (GH-267) 2017-02-24 15:44:19 +09:00
Ivan Levkivskyi abb3b8ad94 Update to typing: treat subscripted generics as proxies (#265) 2017-02-23 19:03:28 -08:00
INADA Naoki 4c78c527d2 bpo-29622: Make AST constructor to accept less than enough number of positional arguments (GH-249)
bpo-29463 added optional "docstring" field to 4 AST types.
While it is optional, it breaks backward compatibility because AST constructor
requires number of positional argument is same to number of fields.

AST types accepts empty arguments, and incomplete keyword arguments.
But it's not big problem because field can be filled after creation, and checked when compiling.
So stop requiring complete set of fields for positional arguments too.
2017-02-24 02:48:17 +09:00
Martijn Pieters d7e64337ef bpo-28598: Support __rmod__ for RHS subclasses of str in % string formatting operations (#51)
When you use `'%s' % SubClassOfStr()`, where `SubClassOfStr.__rmod__` exists, the reverse operation is ignored as normally such string formatting operations use the `PyUnicode_Format()` fast path. This patch tests for subclasses of `str` first and picks the slow path in that case.

Patch by Martijn Pieters.
2017-02-23 15:38:04 +02:00
INADA Naoki cb41b2766d bpo-29463: Add docstring field to some AST nodes. (#46)
* bpo-29463: Add docstring field to some AST nodes.

ClassDef, ModuleDef, FunctionDef, and AsyncFunctionDef has docstring
field for now.  It was first statement of there body.

* fix document.  thanks travis!

* doc fixes
2017-02-22 16:31:59 +01:00
Matthias Bussonnier 1bc156430b bpo-29546: Improve from-import error message with location (#103)
bpo-29546: Improve from-import error message with location
2017-02-22 10:06:50 -05:00
Anthony Zhang 03f68b60e1 bpo-29110: Fix file object leak in `aifc.open` when given invalid AIFF file. (GH-162) 2017-02-22 16:23:30 +09:00
Mark Dickinson 112ec38c15 bpo-29602: fix signed zero handling in complex constructor. (#203)
* Fix incorrect handling of signed zeros for complex-related classes.

* Add Misc/NEWS entry.
2017-02-20 20:28:15 +00:00
Serhiy Storchaka 9639e4ab6d bpo-29532: Altering a kwarg dictionary passed to functools.partial() (#190)
no longer affects a partial object after creation.
2017-02-20 14:04:30 +02:00
Barry Warsaw 8c130d7f81 bpo-22807: Expose platform UUID generation safety information. (#138)
bpo-22807: Expose platform UUID generation safety information.
2017-02-18 15:45:49 -05:00
Nick Coghlan ace5c0fdd9 bpo-29571: Use correct locale encoding in test_re (#149)
``local.getlocale(locale.LC_CTYPE)`` and
``locale.getpreferredencoding(False)`` may give different answers
in some cases (such as the ``en_IN`` locale).

``re.LOCALE`` uses the latter, so update the test case to match.
2017-02-18 15:01:22 +05:30
matejcik 9764c151c5 update test_socket AEAD test for kernel 4.9 and up (#133) 2017-02-16 14:41:31 +01:00
Matthias Bussonnier 1d4601c2c6 bpo-29576: add explicit deprecation for importlib.abc.find_loader() and find_module() (GH-32) 2017-02-15 18:00:32 -08:00
Matthias Bussonnier bc4bed4405 bpo-29546: Set 'path' on ImportError for ``from ... import ...`` (GH-91) 2017-02-14 16:05:25 -08:00
Andrew Nester 6d1dece06d Fixed #29534 - _decimal difference with _pydecimal (#65) 2017-02-14 18:22:55 +00:00
Ivan Levkivskyi b692dc8475 bpo-28556: Various updates to typing (#28)
various updates from upstream python/typing repo:

- Added typing.Counter and typing.ChainMap generics
- More flexible typing.NamedTuple
- Improved generic ABC caching
- More tests
- Bugfixes
- Other updates

* Add Misc/NEWS entry

* Add issue number
2017-02-13 13:50:14 -08:00
Victor Stinner 109a9fe796 Merge 3.6 2017-02-10 12:38:02 +01:00
Victor Stinner 2a35c939cc Fix test_datetime on Windows
Issue #29100: On Windows, datetime.datetime.fromtimestamp(min_ts) fails with an
OSError in test_timestamp_limits().
2017-02-10 12:37:21 +01:00
Victor Stinner 07547cdad3 Merge 3.6 2017-02-10 11:45:28 +01:00
Victor Stinner 6f37e3645d Fix test_datetime on system with 32-bit time_t
Issue #29100: Catch OverflowError in the new test_timestamp_limits() test.
2017-02-10 11:45:14 +01:00
Victor Stinner 05e218c37d Merge 3.6 2017-02-10 10:34:37 +01:00
Victor Stinner b67f096738 Fix datetime.fromtimestamp(): check bounds
Issue #29100: Fix datetime.fromtimestamp() regression introduced in Python
3.6.0: check minimum and maximum years.
2017-02-10 10:34:02 +01:00
Victor Stinner 331bbe6aaa Issue #29507: Update test_exceptions
test_unraisable() of test_exceptions expects that PyErr_WriteUnraisable(method)
fails on repr(method).

Before the previous change (7b8df4a5d81d), slot_tp_finalize() called
PyErr_WriteUnraisable() with a PyMethodObject. In this case, repr(method) calls
repr(self) which is BrokenRepr.__repr__() and the calls raises a new exception.

After the previous change, slot_tp_finalize() uses an unbound method: repr() is
called on a regular __del__() method which doesn't call repr(self). repr()
doesn't fail anymore.

PyErr_WriteUnraisable() doesn't call __repr__() anymore, so remove BrokenRepr
unit test.
2017-02-09 23:49:50 +01:00
Victor Stinner 3722f1f483 support: temp_dir() and change_cwd() uses repr() in error message
Serhiy Storshaka pointed me that str(path) can emit a BytesWarning: use
repr(path) instead.
2017-02-08 15:49:10 +01:00
Victor Stinner 17a63e2169 Fix regrtest -j0 -R output
Write also dots into stderr, instead of stdout.
2017-02-08 13:06:08 +01:00
Victor Stinner 04054d9ac2 Update test_support for my temp_dir/change_cwd changes 2017-02-08 12:49:02 +01:00
Victor Stinner edb4881441 support: add more info on temp_dir() and change_cwd() failure
Log the OSError exception message.
2017-02-08 12:25:00 +01:00
Steve Dower 18d2c934e3 Issue #28164: Improves test on Windows 7 2017-02-06 14:53:21 -08:00
Steve Dower 2dfa6cb9ff Issue #28164: Improves test on Windows 7 2017-02-06 14:50:17 -08:00
Victor Stinner 5bad70def6 regrtest: don't fail immediately if a child does crash
Issue #29362: Catch a crash of a worker process as a normal failure and
continue to run next tests. It allows to get the usual test summary: single
line result (OK/FAIL), total duration, etc.
2017-02-06 12:42:00 +01:00
Steve Dower 64a2f9e882 Merge from 3.6 2017-02-04 16:46:53 -08:00