Commit Graph

23979 Commits

Author SHA1 Message Date
xdegaye cc55e78aca
bpo-32139: test_strftime does not anymore modify the locale (GH-4569) 2017-11-29 11:36:48 +01:00
Serhiy Storchaka 219c2de5ad
bpo-32110: codecs.StreamReader.read(n) now returns not more than n (#4499)
characters/bytes for non-negative n.  This makes it compatible with
read() methods of other file-like objects.
2017-11-29 01:30:00 +02:00
Barry Warsaw 23df2d1304
bpo-32107 - Improve MAC address calculation and fix test_uuid.py (#4600)
``uuid.getnode()`` now preferentially returns universally administered MAC addresses if available, over locally administered MAC addresses.  This makes a better guarantee for global uniqueness of UUIDs returned from ``uuid.uuid1()``.  If only locally administered MAC addresses are available, the first such one found is returned.

Also improve internal code style by being explicit about ``return None`` rather than falling off the end of the function.

Improve the test robustness.
2017-11-28 17:26:04 -05:00
Victor Stinner fe2d5babba
bpo-32159: Remove tools for CVS and Subversion (#4615)
CPython migrated from CVS to Subversion, to Mercurial, and then to
Git. CVS and Subversion are not more used to develop CPython.

* platform module: drop support for sys.subversion. The
  sys.subversion attribute has been removed in Python 3.3.
* Remove Misc/svnmap.txt
* Remove Tools/scripts/svneol.py
* Remove Tools/scripts/treesync.py
2017-11-28 22:29:32 +01:00
Serhiy Storchaka a4a3020abc
bpo-32157: Removed explicit quotes around %r and {!r}. (#4582) 2017-11-28 22:54:42 +02:00
Victor Stinner ac577d7d0b
bpo-32154: Remove asyncio.windows_utils.socketpair (#4609) 2017-11-28 21:33:20 +01:00
Victor Stinner 4271dfd781
bpo-32154: Remove asyncio.selectors (#4605)
* Remove asyncio.selectors and asyncio._overlapped symbols from the
  namespace of the asyncio module
* Replace "from asyncio import selectors" with "import selectors"
* Replace "from asyncio import _overlapped" with "import _overlapped"

asyncio.selectors was added to support Python 3.3, which doesn't have
selectors in its standard library, and Python 3.4 in the same code
base. Same rationale for asyncio._overlapped. Python 3.3 reached its
end of life, and asyncio is no more maintained as a third party
module on PyPI.
2017-11-28 15:19:56 +01:00
Victor Stinner a10dc3efcb
asyncio: use directly socket.socketpair() (#4597)
Since Python 3.5, socket.socketpair() is also available on Windows,
and so can be used directly, rather than using
asyncio.windows_utils.socketpair().
2017-11-28 11:15:26 +01:00
Victor Stinner 92f9339a58
asyncio: Fix BaseSelectorEventLoopTests (#4595)
Currently, two tests fail with PYTHONASYNCIODEBUG=1 (or using -X
dev).
2017-11-28 00:35:55 +01:00
Victor Stinner c9409f7c45
Revert "bpo-32107 - Better merge of #4494 (#4576)" (#4593)
This reverts commit 9522a218f7.
2017-11-28 00:30:21 +01:00
Nick Coghlan 39f0bb5ad0
bpo-32136: Separate embedding tests from C API tests (GH-4567)
Some parts of the C API are only relevant to larger
applications embedding CPython as a runtime engine.

The helpers to test those APIs are already separated
out into Programs/_testembed.c, this update moves
the associated test cases out into their own dedicated
test file.
2017-11-28 08:11:51 +10:00
Barry Warsaw 9522a218f7
bpo-32107 - Better merge of #4494 (#4576)
Improve UUID1 MAC address calculation and related tests.

There are two bits in the MAC address that are relevant to UUID1.  The first is the locally administered vs. universally administered bit (second least significant of the first octet).   Physical network interfaces such as ethernet ports and wireless adapters will always be universally administered, but some interfaces --such as the interface that MacBook Pros communicate with their Touch Bars-- are locally administered.  The former are guaranteed to be globally unique, while the latter are demonstrably *not* globally unique and are in fact the same on every MBP with a Touch Bar.  With this bit is set, the MAC is locally administered; with it unset it is universally administered.

The other bit is the multicast bit (least significant bit of the first octet).  When no other MAC address can be found, RFC 4122 mandates that a random 48-bit number be generated.  This randomly generated number *must* have the multicast bit set.

The improvements in uuid.py include:

* Preferentially return a universally administered MAC address, falling back to a locally administered address if none of the former can be found.
* Improve several coding style issues, such as adding explicit returns of None, using a more readable bitmask pattern, and assuming that the ultimate fallback, random MAC generation will not fail (and propagating any exception there instead of swallowing them).

Improvements in test_uuid.py include:

* Always testing the calculated MAC for universal administration, unless explicitly disabled (i.e. for the random case), or implicitly disabled due to running in the Travis environment.  Travis test machines have *no* universally administered MAC address at the time of this writing.
2017-11-27 14:40:10 -05:00
Victor Stinner c9758784eb
bpo-27535: Fix memory leak with warnings ignore (#4489)
The warnings module doesn't leak memory anymore in the hidden
warnings registry for the "ignore" action of warnings filters.

The warn_explicit() function doesn't add the warning key to the
registry anymore for the "ignore" action.
2017-11-27 16:57:07 +01:00
Victor Stinner 21c7730761
bpo-32089: Use default action for ResourceWarning (#4584)
In development and debug mode, use the "default" action, rather than
the "always" action, for ResourceWarning in the default warnings
filters.
2017-11-27 12:11:55 +01:00
Mandeep Singh ede2ac913e bpo-23033: Improve SSL Certificate handling (GH-937)
Wildcard is now supported in hostname when it is one and only character in
the leftmost segment.
2017-11-26 14:31:27 -08:00
xdegaye a6fba9b827
bpo-32126: Skip asyncio test when sem_open() is not functional (GH-4559) 2017-11-26 10:31:44 +01:00
xdegaye 76fdac4c9f
bpo-26856: Skip test_pwd on Android until issue 32033 is fixed (GH-4561) 2017-11-25 17:32:27 +01:00
Serhiy Storchaka cfa797c068
bpo-24641: Improved error message for JSON unserializible keys. (#4364)
Also updated an example for default() in the module docstring.
Removed quotes around type name in other error messages.
2017-11-25 17:38:20 +02:00
Berker Peksag 8d9bb11d8f
bpo-28334: netrc() now uses expanduser() to find .netrc file (GH-4537)
Previously, netrc.netrc() was raised an exception if $HOME is not set.

Authored-By: Dimitri Merejkowsky <dimitri.merejkowsky@tanker.io>
2017-11-25 13:37:22 +03:00
Victor Stinner 706cb3162e
bpo-32128: Skip test_nntplib.test_article_head_body() (#4552)
The NNTP server currently has troubles with SSL, whereas we don't
have the control on this server. This test blocks all CIs, so disable
it until a fix can be found.
2017-11-25 02:42:18 +01:00
xdegaye 5742f674f7
bpo-28684: Remove useless import added by the previous commit (GH-4547) 2017-11-24 18:56:22 +01:00
xdegaye 0f86cd38f4
bpo-28684: asyncio tests handle PermissionError raised on binding unix sockets (GH-4503)
The test.support.skip_unless_bind_unix_socket() decorator is used to skip
asyncio tests that fail because the platform lacks a functional bind()
function for unix domain sockets (as it is the case for non root users on the
recent Android versions that run now SELinux in enforcing mode).
2017-11-24 17:35:55 +01:00
Berker Peksag 19fb134185
bpo-12239: Make GetProperty() return None for VT_EMPTY (GH-4539)
The previous behavior was to raise an exception

    NotImplementedError: result of type 0

when the value of the property is VT_EMPTY.
2017-11-24 18:11:18 +03:00
Victor Stinner 9e87e7776f
bpo-32096: Remove obj and mem from _PyRuntime (#4532)
bpo-32096, bpo-30860:  Partially revert the commit
2ebc5ce42a8a9e047e790aefbf9a94811569b2b6:

* Move structures back from Include/internal/mem.h to
  Objects/obmalloc.c
* Remove _PyObject_Initialize() and _PyMem_Initialize()
* Remove Include/internal/pymalloc.h
* Add test_capi.test_pre_initialization_api():
   Make sure that it's possible to call Py_DecodeLocale(), and then call
   Py_SetProgramName() with the decoded string, before Py_Initialize().

PyMem_RawMalloc() and Py_DecodeLocale() can be called again before
_PyRuntimeState_Init().

Co-Authored-By: Eric Snow <ericsnowcurrently@gmail.com>
2017-11-24 12:09:24 +01:00
Berker Peksag 4864a619dc
bpo-12382: Make OpenDatabase() raise better exception messages (GH-4528)
Previously, 'msilib.OpenDatabase()' function raised a
cryptical exception message when it couldn't open or
create an MSI file. For example:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    _msi.MSIError: unknown error 6e
2017-11-24 12:53:58 +03:00
Berker Peksag 3df02dbc8e bpo-31325: Fix usage of namedtuple in RobotFileParser.parse() (#4529) 2017-11-23 15:40:26 -08:00
Berker Peksag bdb8315c21
bpo-1102: View.Fetch() now returns None when it's exhausted (GH-4459) 2017-11-23 15:47:30 +03:00
Jesse-Bakker 0784a2e5b1 bpo-10049: Add a "no-op" (null) context manager to contextlib (GH-4464)
Adds a simpler and faster alternative to ExitStack for handling
single optional context managers without having to change the
lexical structure of your code.
2017-11-23 10:23:28 +10:00
Victor Stinner bb11c3c967
bpo-31324: Fix test.support.set_match_tests(None) (#4505) 2017-11-22 20:58:59 +01:00
Victor Stinner 803ddd8ce2
bpo-31324: Optimize support._match_test() (#4421)
* Rename support._match_test() to support.match_test(): make it
  public
* Remove support.match_tests global variable. It is replaced with a
  new support.set_match_tests() function, so match_test() doesn't
  have to check each time if patterns were modified.
* Rewrite match_test(): use different code paths depending on the
  kind of patterns for best performances.

Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
2017-11-21 15:34:02 -08:00
Victor Stinner 09f3a8a124
bpo-32089: Fix warnings filters in dev mode (#4482)
The developer mode (-X dev) now creates all default warnings filters
to order filters in the correct order to always show ResourceWarning
and make BytesWarning depend on the -b option.

Write a functional test to make sure that ResourceWarning is logged
twice at the same location in the developer mode.

Add a new 'dev_mode' field to _PyCoreConfig.
2017-11-20 17:32:40 -08:00
Victor Stinner f39b674876
bpo-32094: Update subprocess for -X dev (#4480)
Modify subprocess._args_from_interpreter_flags() to handle -X dev
option.

Add also unit tests for test.support.args_from_interpreter_flags()
and test.support.optim_args_from_interpreter_flags().
2017-11-20 15:24:56 -08:00
Yury Selivanov 423fd362f8
bpo-32066: Support pathlib.Path in create_unix_connection; sock arg should be optional (#4447) 2017-11-20 17:26:28 -05:00
Victor Stinner 895862aa01 bpo-32088: Display Deprecation in debug mode (#4474)
When Python is build is debug mode (Py_DEBUG), DeprecationWarning,
PendingDeprecationWarning and ImportWarning warnings are now
displayed by default.

test_venv: run "-m pip" and "-m ensurepip._uninstall" with -W
ignore::DeprecationWarning since pip code is not part of Python.
2017-11-20 18:47:03 +01:00
Victor Stinner 44862df2ee
bpo-32047: -X dev enables asyncio debug mode (#4418)
The new -X dev command line option now also enables asyncio debug
mode.
2017-11-20 07:14:07 -08:00
Riccardo Magliocchetti 04dee27208 Remove duplicated import from datetime tests (#4444) 2017-11-20 10:48:56 +02:00
xdegaye ebfaa71c2e
bpo-32031: Fix pydoc `test_mixed_case_module_names_are_lower_cased` (GH-4441)
When there is a symlink in the directory path of the standard library.
2017-11-18 18:20:21 +01:00
xdegaye 9001d1f438
bpo-29184: Skip test_socketserver tests on PermissionError raised by Android (GH-4387) 2017-11-18 18:10:53 +01:00
Andrew Svetlov 51d546ae4d
bpo-32069: Drop legacy SSL transport (#4451)
* Drop legacy SSL transport

* Drop unused import

* Fix Windows tests

* Drop never executed on Python 3.4+ code
2017-11-18 18:54:05 +02:00
Serhiy Storchaka cede8c9edb
bpo-31702: Allow to specify rounds for SHA-2 hashing in crypt.mksalt(). (#4110)
The log_rounds parameter for Blowfish has been replaced with the rounds parameter.
2017-11-16 13:22:51 +02:00
Victor Stinner ccb0442a33
bpo-32043: New "developer mode": "-X dev" option (#4413)
Add a new "developer mode": new "-X dev" command line option to
enable debug checks at runtime.

Changes:

* Add unit tests for -X dev
* test_cmd_line: replace test.support with support.
* Fix _PyRuntimeState_Fini(): Use the same memory allocator
   than _PyRuntimeState_Init().
* Fix _PyMem_GetDefaultRawAllocator()
2017-11-16 03:20:31 -08:00
Serhiy Storchaka 05cb728d68
bpo-30349: Raise FutureWarning for nested sets and set operations (#1553)
in regular expressions.
2017-11-16 12:38:26 +02:00
Serhiy Storchaka 3daaafb700
bpo-32037: Use the INT opcode for 32-bit integers in protocol 0 pickles. (#4407) 2017-11-16 09:44:43 +02:00
Victor Stinner a7368ac636
bpo-32030: Enhance Py_Main() (#4412)
Parse more env vars in Py_Main():

* Add more options to _PyCoreConfig:

  * faulthandler
  * tracemalloc
  * importtime

* Move code to parse environment variables from _Py_InitializeCore()
  to Py_Main(). This change fixes a regression from Python 3.6:
  PYTHONUNBUFFERED is now read before calling pymain_init_stdio().
* _PyFaulthandler_Init() and _PyTraceMalloc_Init() now take an
  argument to decide if the module has to be enabled at startup.
* tracemalloc_start() is now responsible to check the maximum number
  of frames.

Other changes:

* Cleanup Py_Main():

  * Rename some pymain_xxx() subfunctions
  * Add pymain_run_python() subfunction

* Cleanup Py_NewInterpreter()
* _PyInterpreterState_Enable() now reports failure
* init_hash_secret() now considers pyurandom() failure as an "user
  error": don't fail with abort().
* pymain_optlist_append() and pymain_strdup() now sets err on memory
  allocation failure.
2017-11-15 18:11:45 -08:00
Yury Selivanov 43605e6bfa
bpo-32034: Make IncompleteReadError & LimitOverrunError pickleable #4409 2017-11-15 17:14:28 -05:00
Antoine Pitrou 4bd41c9b52
bpo-32025: Add time.thread_time() (#4410)
* bpo-32025: Add time.thread_time()

* Add missing #endif

* Add NEWS blurb

* Add docs and whatsnew

* Address review comments

* Review comments
2017-11-15 22:52:21 +01:00
Dong-hee Na 762b9571c9 bpo-32018: Fix inspect.signature repr to follow PEP 8 (#4408) 2017-11-15 13:30:59 -05:00
Serhiy Storchaka f8a4c03ede
bpo-30399: Get rid of trailing comma in the repr of BaseException. (#1650) 2017-11-15 17:53:28 +02:00
Serhiy Storchaka 00987f6230
bpo-32011: Revert "Issue #15480: Remove the deprecated and unused TYPE_INT64 code from marshal." (#4381)
Simplify the reverted code.

This reverts commit e9bbe8b87b.
2017-11-15 17:41:05 +02:00
Serhiy Storchaka ddbce13786
bpo-32023: Disallow genexprs without parenthesis in class definitions. (#4400) 2017-11-15 17:39:37 +02:00