* init commit, with initial tests for from_param and fields __set__ and __get__, and some additions to from_buffer and from_buffer_copy
* added the rest of tests and patches. probably only a first draft.
* removed trailing spaces
* replace ctype with ctypes in error messages
* change back from ctypes instance to ctype instance
(cherry picked from commit 1bea762d9e)
* bpo-29136: Add TLS 1.3 support
TLS 1.3 introduces a new, distinct set of cipher suites. The TLS 1.3
cipher suites don't overlap with cipher suites from TLS 1.2 and earlier.
Since Python sets its own set of permitted ciphers, TLS 1.3 handshake
will fail as soon as OpenSSL 1.1.1 is released. Let's enable the common
AES-GCM and ChaCha20 suites.
Additionally the flag OP_NO_TLSv1_3 is added. It defaults to 0 (no op) with
OpenSSL prior to 1.1.1. This allows applications to opt-out from TLS 1.3
now.
Signed-off-by: Christian Heimes <christian@python.org>.
(cherry picked from commit cb5b68abde)
* bpo-31339: Rewrite time.asctime() and time.ctime()
Backport and adapt the _asctime() function from the master branch to
not depend on the implementation of asctime() and ctime() from the
external C library. This change fixes a bug when Python is run using
the musl C library.
* bound checks for time.asctime()
* bound checks for time.strftime()
* bpo-27448: Work around a gc.disable race condition in subprocess.
This works around a gc.isenabled/gc.disable race condition in the 2.7
subprocess module by using a lock for the critical section. It'll
prevent multiple simultaneous subprocess launches from winding up with
gc remaining disabled but it can't fix the ultimate problem: gc enable
and disable is a global setting and a hack.
Users are *strongly encouraged* to use subprocess32 from PyPI instead
of the 2.7 standard library subprocess module. Mixing threads with
subprocess is a recipie for disaster otherwise even with "fixes" to
ameliorate common issues like this.
* Add a blurb!
[2.7] bpo-10746: Fix ctypes PEP 3118 type codes for c_long, c_bool, c_int (GH-31)
Ctypes currently produces wrong pep3118 type codes for several types.
E.g. memoryview(ctypes.c_long()).format gives "<l" on 64-bit platforms,
but it should be "<q" instead for sizeof(c_long) == 8
The problem is that the '<>' endian specification in the struct syntax
also turns on the "standard size" mode, which makes type characters have
a platform-independent meaning, which does not match with the codes used
internally in ctypes. The struct module format syntax also does not
allow specifying native-size non-native-endian items.
This commit adds a converter function that maps the internal ctypes
codes to appropriate struct module standard-size codes in the pep3118
format strings. The tests are modified to check for this..
(cherry picked from commit 07f1658aa0)
* bpo-30871: Add test.pythoninfo (#3075)
* Add Lib/test/pythoninfo.py: script collecting various informations
about Python to help debugging test failures.
* regrtest: remove sys.hash_info and sys.flags from header.
* Travis CI, Appveyor: run pythoninfo before tests
(cherry picked from commit b907abc885)
* bpo-30871: pythoninfo: add expat and _decimal (#3121)
* bpo-30871: pythoninfo: add expat and _decimal
* Remove _decimal.__version__
The string is hardcoded, not really interesting.
(cherry picked from commit f6ebd838f0)
* bpo-30871: Add "make pythoninfo" (#3120)
(cherry picked from commit a3a01a2fce)
* bpo-30871: pythoninfo: more sys, os, time data (#3130)
* bpo-30871: pythoninfo: more sys, os, time data
PythonInfo now converts types other than intger to string by default.
* fix typo
(cherry picked from commit ad7eaed543)
* bpo-31231: Fix pythoninfo in Travis config (#3134)
bpo-31231, bpo-30871: Replace "./python -m test.pythoninfo" with
"make pythoninfo", since macOS uses ./python.exe.
(cherry picked from commit 92b1f90143)
(cherry picked from commit 29d007bb67)
OpenSSL 1.1.0 to 1.1.0e aborted the handshake when server and client
could not agree on a protocol using ALPN. OpenSSL 1.1.0f changed that.
The most recent version now behaves like OpenSSL 1.0.2 again. The ALPN
callback can pretend to not been set.
See https://github.com/openssl/openssl/pull/3158 for more details
Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit a5c1bab352)
The current test_child_terminated_in_stopped_state() function test
creates a child process which calls ptrace(PTRACE_TRACEME, 0, 0) and
then crash (SIGSEGV). The problem is that calling os.waitpid() in the
parent process is not enough to close the process: the child process
remains alive and so the unit test leaks a child process in a
strange state. Closing the child process requires non-trivial code,
maybe platform specific.
Remove the functional test and replaces it with an unit test which
mocks os.waitpid() using a new _testcapi.W_STOPCODE() function to
test the WIFSTOPPED() path.
(cherry picked from commit 7b7c6dcfff)
* bpo-31160: regrtest now reaps child processes (#3044)
Add a post_test_cleanup() function which currently only calls
support.reap_children().
(cherry picked from commit e3510d74aa)
* bpo-31160: test_tempfile: Fix reap_children() warning (#3056)
TestRandomNameSequence.test_process_awareness() now calls
os.waitpid() to avoid leaking a zombie process.
(cherry picked from commit 6c8c2943d9)
bpo-31135: Call the parent destroy() method even if the used
attribute doesn't exist.
The LabeledScale.destroy() method now also explicitly clears label
and scale attributes to help the garbage collector to destroy all
widgets.
* bpo-31044: Skip test_posix.test_makedev() on FreeBSD (#2915)
There is a bug in FreeBSD CURRENT with 64-bit dev_t. Skip the test if
dev_t is larger than 32-bit, until the bug is fixed in FreeBSD
CURRENT.
(cherry picked from commit 12953ffe12)
* Fix syntax for Python 2.7
* bpo-31028: Fix test_pydoc when run directly
Fix get_pydoc_link() of test_pydoc to fix "./python
Lib/test/test_pydoc.py": get the absolute path to __file__ to prevent
relative directories.
* Use realpath() instead of abspath()
(cherry picked from commit fd46561167)
* bpo-30980: Fix close test to fail
test_close_twice was not considering the fact that file_wrapper is
duping the file descriptor. Closing the original descriptor left the
duped one open, hiding the fact that close protection is not effective.
* bpo-30980: Fix double close protection
Invalidated self.fd before closing, handling correctly the case when
os.close raises.
* bpo-30980: Fix fd leak introduced in the fixed test
multiprocessing.Process.is_alive() now removes the process from the
_children set if the process completed.
The change prevents leaking "dangling" processes.
(cherry picked from commit 2db64823c2)
* bpo-30595: Fix multiprocessing.Queue.get(timeout) (#2027)
multiprocessing.Queue.get() with a timeout now polls its reader in
non-blocking mode if it succeeded to aquire the lock but the acquire
took longer than the timeout.
Co-Authored-By: Grzegorz Grzywacz <grzgrzgrz3@gmail.com>
(cherry picked from commit 1b7863c3b6)
* 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.
(cherry picked from commit 8f6eeaf21c)
(cherry picked from commit e42339d3a0)
bpo-30850: On Windows, test04_lock_timeout2() now tolerates 50 ms
whereas 100 ms is expected. The lock sometimes times out after only
58 ms. Windows clocks have a bad resolution and bad accuracy.
* bpo-30855: Trying to fix test_use on Windows.
Avoid possible weird behavior of WideInt convertion.
"winfo id" always returns string hexadecimal representation.
(cherry picked from commit b9d672491d)
* bpo-30855: Trying to fix test_use on Windows.
(cherry picked from commit 29a2f7c6b3)
(subTest() removed since it was introduced in Python 3)
list_cases() now unload modules, as the test runner does, to prevent
a failure in test_xpickle about test.pickletester loaded after
loading test_cpickle:
./python -m test --list-cases test_cpickle test_xpickle
Copy Lib/test/test_robotparser.py from master to 2.7 and adapt it for
Python 2.7:
* Replace urllib.robotparser with robotparser
* Adjust HTTPServer import
* Replace io.StringIO with StringIO.StringIO
* Remove tests on crawl_delay() and request_rate() since these
methods were added to Python 3
* Remove subTest()
* Add test_main() which explicitly lists all test cases
Patch based on the commit 4da0fd06ce
written by Berker Peksag.
Co-Authored-By: Berker Peksag <berker.peksag@gmail.com>
Sleep 1 ms instead of 0.1 ms to workaround a rounding issue on
Windows. On Windows, time.sleep(0.0001) sleeps 0 ms, so
collect_in_thread() calls gc.collect() in a loop and tests using this
thread takes too long. Sleep 1 ms so time.sleep() sleeps 15.6 ms on
Windows.
I thought I had run the full test suite before the last checkin, but
obviously I didn't. test_multibytecodec_support.py isn't really a test file,
it is a support file that contains a base test class. Rename it to
multibytecodec_support so that regrtest test discovery doesn't think it is a
test file that should be run..
(cherry picked from commit 75d9aca97a)
* bpo-29512, bpo-30764: Backport regrtest enhancements from 3.5 to 2.7
* 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.
* bpo-30764: Fix regrtest --fail-env-changed --forever (#2536) (#2539)
--forever now stops if a fail changes the environment.
* Fix test_bisect: use absolute import
* 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.
(cherry picked from commit 79d37ae979)
* 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.
(cherry picked from commit ace56d5836)
(cherry picked from commit 36946c06a3)
* 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.
(cherry picked from commit 63f54c6893)
(cherry picked from commit 1f33857a36)
* 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]
(cherry picked from commit 48b5c422ff)
(cherry picked from commit e0f8b43a46)
* Add test.support._crash_python() which triggers a crash but uses
test.support.SuppressCrashReport() to prevent a crash report from
popping up.
* Modify test_child_terminated_in_stopped_state() of test_subprocess
and test_crashed() of test_regrtest to use _crash_python().
* Add Windows support to test.support.SuppressCrashReport: call
SetErrorMode() and CrtSetReportMode().
* _testcapi: add CrtSetReportMode() and CrtSetReportFile() functions
and CRT_xxx and CRTDBG_xxx constants needed by SuppressCrashReport.
* bpo-30764: Backport support.SuppressCrashReport
Backport test.support.SuppressCrashReport context-manager from
master. Drop the Windows implementation since it depends on
msvcrt.CrtSetReportMode() which isn't available on Python 2.7.
* 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.
(cherry picked from commit cdee3f14f7)
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``.
(cherry picked from commit 90e01e50ef)
regrtest now warms up caches: create explicitly all internal
singletons which are created on demand to prevent false positives
when checking for reference leaks.
* 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.
(cherry picked from commit 1eb6c0074d)
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.
This ensures that pre-merge CI will automatically pick up
on magic number changes in maintenance releases (and
explain why those are problematic), rather than relying on
all core developers to be aware of the implications of
such changes.
On Windows, subprocess.Popen.communicate() now also ignore EINVAL
on stdin.write() if the child process is still running but closed the
pipe.
(cherry picked from commit d52aa31378)
* 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..
(cherry picked from commit bc50f03db4)
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.
(cherry picked from commit c7ac7280c3)
Running Python with the -3 option now warns about regular expression
syntax that is invalid or has different semantic in Python 3
or will change the behavior in future Python versions.
Running Python with the -3 option now emits deprecation warnings for
getchildren() and getiterator() methods of the Element class in the
xml.etree.cElementTree module and when pass the html argument to
xml.etree.ElementTree.XMLParser().
Fixed a deprecation warning about the doctype() method of the
xml.etree.ElementTree.XMLParser class. Now it is emitted only when
define the doctype() method in the subclass of XMLParser.
Fixed a bug in the test_bug_200708_close test method. An EchoTarget
instance was incorrectly passed to XMLParser() as the html argument and
silently ignored.
Tests no longer failed when use the -m option for running only selected
test methods. Checking warnings now is more specific, warnings are
expected only when use deprecated features.
Catch the Windows socket WSAEINVAL error (code 10022) in imaplib
on shutdown(SHUT_RDWR): An invalid operation was attempted
This error occurs sometimes on SSL connections.
(cherry picked from commit 83a2c28798)
* bpo-30357 each test in test_thread waits until all spawn threads finish
* bpo-30357 each test in test_thread waits until all spawn threads finish
* 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: Victor Stinner <victor.stinner@gmail.com>
* 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: Victor Stinner <victor.stinner@gmail.com>
Also backport new functions temp_dir() and python_is_optimized().
temp_cwd() now accepts None as a name (means using tempfile.mkdtemp).
check_syntax_error() now accepts arguments lineno and offset.
Use more specific error messages in get_attribute().
Fix for bpo-6393: Python crashes on OSX when $LANG is set to some (but
not all) invalid values due to an invalid result from nl_langinfo
(cherry picked from commit 6d77e07196)
* bpo-30283: regrtest: backport test_coverage()
* Add --coverage option, the option was already described in the doc
* When coverage is used, regrtest now pass all options to runtest()
and calls also accumulate_result() (as done when coverage is not
used).
* bpo-25260: Fix coverage on Windows: remove the list of ignored
directories.
* bpo-30283: regrtest: backport test_slow_interrupted()
* Fix regrtest to report interrupted tests as omitted rather than
failed.
* bpo-25260: Fix coverage on Windows: remove the list of ignored
directories.
* bpo-30283: Fix test_regrtest on Visual Studio 2008
Skip Tools\buildbot\test.bat and PCbuild\rt.bat if Python was not
compiled in PCbuild (but compiled in PC\VS9.0\ for example).
Try to fix test_startfile's inability to clean up after itself in
time. Patch by Jeremy Kloth.
Fix the following support.rmtree() error while trying to remove the
temporary working directory used by Python tests:
WindowsError: [Error 32] The process cannot access the file because
it is being used by another process: ...
Original commit: 8a53dbeb7a
* regrtest: add --slowest alias to --slow
* make buildbottest: add --slowest option
* regrtest: add "- " prefix to --slowest output
* regrtest: Fix an outdated comment
* regrtest: replace PermissionError
Replace PermissionError with OSError and check on exc.errno.
PermissionError was added to Python 3.3.
* regrtest: add -3 -tt options to run Python scripts
* regrtest: backport --list-tests option
* regrtest: backport "Tests result: xxx" summary
* regrtest: backport total duration
* regrtest: add timestamp to the progress
* regrtest: describe previous test state
* Add the state of the test: passed, failed, etc.
* If a test took longer than 30 seconds, log its execution time
* regrtest: -jN logs running workers
* regrtest: mention if tests are run in parallel
* regrtest: parallel mode is more verbose during wait
Display running tests every 30 seconds if no test completed in the
meanwhile.
* test_regrtest: fix typo in SubprocessRun
* bpo-30283: regrtest: add --testdir option
* bpo-30283: Backport _testcapi.raise_signal()
Function used by test_regrtest to simulate an interrupted unit test.
* bpo-30283: Backport test_regrtest from master
Fix the following warning when test_inspect.py is compiled to
test_inspect.pyc:
test_inspect.py:505: SyntaxWarning: tuple parameter unpacking has been removed in 3.x
def spam_deref(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h):
Replace also test.test_support import with test.support.
ExpatParser.parse() of xml.sax.xmlreader now closes the source: close
the file object or the urllib object if source is a string (not an
open file-like object).
Add test_parse_close_source() unit test.
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.
(cherry picked from commit b85c136903)
DummyFTPServer now calls del_channel() on bind() error to prevent the
following warning in TestIPv6Environment.setUpClass():
Warning -- asyncore.socket_map was modified by test_ftplib
Before: {}
After: {3: <test.test_ftplib.DummyFTPServer 127.0.0.1:0 at ...>}
Use EnvironGuard on BuildExtTestCase to save/restore os.environ, to fix the
following warning:
Warning -- os.environ was modified by test_distutils
MSVCCompiler.initialize() of distutils.msvc9compiler modifies
os.environ.
Backport the CHILD_ERROR status from master: a test is considered as
failed if a worker process running a test exited with a code
different than zero.
Change also the output: write stdout and stderr of the child process
after the test name, instead of writing it before.
accumulate_result(): don't use time of CHILD_ERROR or INTERRUPTED
results.
Use EnvironGuard on InstallTestCase and UtilTestCase.
Backport fixes from master to prevent the following warning:
Warning -- os.environ was modified by test_distutils
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.
(cherry picked from commit ec4b17239d)
(cherry picked from commit 2298235023)
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>}
(cherry picked from commit 1dae7450c6)
To unify running tests in Python 2.7 and Python 3, the test
package can be run as a script. This is equivalent to running the
test.regrtest module as a script.
To simplify backports from Python 3, the test.test_support module
was converted into a package and renamed to test.support. The
test.script_helper module was moved into the test.support package.
Names test.test_support and test.script_helper are left as aliases to
test.support and test.support.script_helper.
* 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.
(cherry picked from commit de04644627)
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.
(cherry picked from commit 5466d4af5f)
* 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
(cherry picked from commit 8988945cdc)
* Fix Misc/NEWS ?
In urllib, suffixes in no_proxy environment variable with
leading dots could match related hostnames again (e.g. .b.c matches a.b.c).
Patch by Milan Oberkirch.
Improved the documentation and tests for make_archive().
Improved error handling when corresponding compress module is not available.
External zip executable is now used if the zlib module is not available.
system Python site-packages directory, to sys.path for macOS framework builds.
The coupling between the two Python instances often caused confusion and, as
of macOS 10.12, changes to the site-packages layout can cause pip component
installations to fail. This change reverts the effects introduced in 2.7.0
by Issue #4865. If you are using a package with both the Apple system Python
2.7 and a user-installed Python 2.7, you will need to ensure that copies of
the package are installed with both Python instances.