Commit graph

22484 commits

Author SHA1 Message Date
Serhiy Storchaka c3ea41e9bf
bpo-36917: Add default implementation of ast.NodeVisitor.visit_Constant(). (GH-15490)
It emits a deprecation warning and calls corresponding method
visit_Num(), visit_Str(), etc.
2019-08-26 10:13:19 +03:00
Dong-hee Na 44cd86bbdd bpo-37805: Add tests for json.dump(..., skipkeys=True) (GH-15489)
https://bugs.python.org/issue37805



Automerge-Triggered-By: @methane
2019-08-26 00:04:35 -07:00
Terry Jan Reedy 1039f39c9c
bpo-37824: Properly handle user input warnings in IDLE shell. (GH-15500)
Cease turning SyntaxWarnings into SyntaxErrors.
2019-08-26 02:27:56 -04:00
Flavian Hautbois da27d9b9dc bpo-29553: Fix ArgumentParser.format_usage() for mutually exclusive groups (GH-14976)
Co-authored-by: Andrew Nester <andrew.nester.dev@gmail.com>
2019-08-25 22:06:45 +03:00
Nick Coghlan 5dbe0f59b7
bpo-37757: Disallow PEP 572 cases that expose implementation details (GH-15131)
- drop TargetScopeError in favour of raising SyntaxError directly
  as per the updated PEP 572
- comprehension iteration variables are explicitly local, but
  named expression targets in comprehensions are nonlocal or
  global. Raise SyntaxError as specified in PEP 572
- named expression targets in the outermost iterable of a
  comprehension have an ambiguous target scope. Avoid resolving
  that question now by raising SyntaxError. PEP 572
  originally required this only for cases where the bound name
  conflicts with the iteration variable in the comprehension,
  but CPython can't easily restrict the exception to that case
  (as it doesn't know the target variable names when visiting
  the outermost iterator expression)
2019-08-25 23:45:40 +10:00
Zackery Spytz ce6a070414 bpo-34880: Add the LOAD_ASSERTION_ERROR opcode. (GH-15073)
Fix assert statement misbehavior if AssertionError is shadowed.
2019-08-25 12:44:09 +03:00
Tal Einat d4b4c00b57
bpo-37929: IDLE: avoid Squeezer-related config dialog crashes (GH-15452)
These were caused by keeping around a reference to the Squeezer
instance and calling it's load_font() upon config changes, which
sometimes happened even if the shell window no longer existed.

This change completely removes that mechanism, instead having the
editor window properly update its width attribute, which can then
be used by Squeezer.
2019-08-25 08:52:58 +03:00
Raymond Hettinger aef9ad82f7
bpo-37942: Improve argument clinic float converter (GH-15470) 2019-08-24 19:10:39 -07:00
Berker Peksag 805f8f9afe bpo-19072: Make @classmethod support chained decorators (GH-8405) 2019-08-24 15:37:25 -07:00
Terry Jan Reedy 0dfc025ccc
Fix typo and rearrange words in IDLE news item (GH-15471)
Redo of #15402 by GeeTransit and Kyle Stanley.
2019-08-24 17:32:33 -04:00
Terry Jan Reedy fa7a6f5e35
Revert "(TH-15402)" (#15468)
This reverts commit a50f0a4c2b.
2019-08-24 14:10:04 -04:00
Dong-hee Na 8ad22a4226 bpo-37798: Test both Python and C versions in test_statistics.py (GH-15453) 2019-08-24 10:51:20 -07:00
Greg Price 5e63ab05f1 bpo-37812: Convert CHECK_SMALL_INT macro to a function so the return is explicit. (GH-15216) 2019-08-24 10:19:37 -07:00
GeeTransit a50f0a4c2b (TH-15402) 2019-08-24 13:01:36 -04:00
shireenrao a4e2991bdc bpo-37772: fix zipfile.Path.iterdir() outputs (GH-15170)
* fix Path._add_implied_dirs to include all implied directories

* fix Path._add_implied_dirs to include all implied directories

* Optimize code by using sets instead of lists

* 📜🤖 Added by blurb_it.

* fix Path._add_implied_dirs to include all implied directories

* Optimize code by using sets instead of lists

* 📜🤖 Added by blurb_it.

* Add tests to zipfile.Path.iterdir() fix

* Update test for zipfile.Path.iterdir()

* remove whitespace from test file

* Rewrite NEWS blurb to describe the user-facing impact and avoid implementation details.

* remove redundant [] within set comprehension

* Update to use unique_everseen to maintain order and other suggestions in review

* remove whitespace and add back add_dirs in tests

* Add new standalone function parents using posixpath to get parents of a directory

* removing whitespace (sorry)

* Remove import pathlib from zipfile.py

* Rewrite _parents as a slice on a generator of the ancestry of a path.

* Remove check for '.' and '/', now that parents no longer returns those.

* Separate calculation of implied dirs from adding those

* Re-use _implied_dirs in tests for generating zipfile with dir entries.

* Replace three fixtures (abcde, abcdef, abde) with one representative example alpharep.

* Simplify implementation of _implied_dirs by collapsing the generation of parent directories for each name.
2019-08-24 11:26:41 -04:00
Serhiy Storchaka ef61c524dd
bpo-37830: Fix compilation of break and continue in finally. (GH-15320)
Fix compilation of "break" and "continue" in the
"finally" block when the corresponding "try" block
contains "return" with a non-constant value.
2019-08-24 13:11:52 +03:00
Serhiy Storchaka e9c90aa431
bpo-29535: Remove promize about hash randomization of datetime objects. (GH-15269) 2019-08-24 12:49:27 +03:00
Dong-hee Na 0a18ee4be7 bpo-37798: Add C fastpath for statistics.NormalDist.inv_cdf() (GH-15266) 2019-08-23 15:20:30 -07:00
Zackery Spytz 5be666010e bpo-37549: os.dup() fails for standard streams on Windows 7 (GH-15389) 2019-08-23 11:38:41 -07:00
Raymond Hettinger 8f080b0995
bpo-26589: Add http status code 451 (GH-15413) 2019-08-23 10:19:15 -07:00
Victor Stinner 120b707a6d
bpo-36763: PyConfig_Read() handles PySys_AddXOption() (GH-15431)
PyConfig_Read() is now responsible to handle early calls to
PySys_AddXOption() and PySys_AddWarnOption().

Options added by PySys_AddXOption() are now handled the same way than
PyConfig.xoptions and command line -X options.

For example, PySys_AddXOption(L"faulthandler") enables faulthandler
as expected.
2019-08-23 18:03:08 +01:00
Stefan Behnel b5d3ceea48
bpo-14465: Add an indent() function to xml.etree.ElementTree to pretty-print XML trees (GH-15200) 2019-08-23 16:44:25 +02:00
Victor Stinner c48682509d
bpo-37926: Fix PySys_SetArgvEx(0, NULL, 0) crash (GH-15415)
empty_argv is no longer static in Python 3.8, but it is declared in
a temporary scope, whereas argv keeps a reference to it.
empty_argv memory (allocated on the stack) is reused by
make_sys_argv() code which is inlined when using gcc -O3.

Define empty_argv in PySys_SetArgvEx() body, to ensure
that it remains valid for the whole lifetime of
the PySys_SetArgvEx() call.
2019-08-23 11:04:16 +01:00
Pablo Galindo 4be11c009a bpo-37915: Fix comparison between tzinfo objects and timezone objects (GH-15390)
https://bugs.python.org/issue37915



Automerge-Triggered-By: @pablogsal
2019-08-22 12:24:25 -07:00
Raymond Hettinger d0cdeaab76
bpo-32554: Deprecate hashing arbitrary types in random.seed() (GH-15382) 2019-08-22 09:19:36 -07:00
Steve Dower 7ebdda0dbe
bpo-36311: Fixes decoding multibyte characters around chunk boundaries and improves decoding performance (GH-15083) 2019-08-21 16:22:33 -07:00
bsiem df0c21ff46 bpo-37482: Fix email address name with encoded words and special chars (GH-14561)
Special characters in email address header display names are normally
put within double quotes. However, encoded words (=?charset?x?...?=) are
not allowed withing double quotes. When the header contains a word with
special characters and another word that must be encoded, the first one
must also be encoded.

In the next example, the display name in the From header is quoted and
therefore the comma is allowed; in the To header, the comma is not
within quotes and not encoded, which is not allowed and therefore
rejected by some mail servers.

From: "Foo Bar, France" <foo@example.com>
To: Foo Bar, =?utf-8?q?Espa=C3=B1a?= <foo@example.com>





https://bugs.python.org/issue37482
2019-08-21 16:00:39 -07:00
Brett Cannon 48ede6b8f6
bpo-37663: have venv activation scripts all consistently use __VENV_PROMPT__ for prompt customization (GH-14941)
The activation scripts generated by venv were inconsistent in how they changed the shell's prompt. Some used `__VENV_PROMPT__` exclusively, some used `__VENV_PROMPT__` if it was set even though by default `__VENV_PROMPT__` is always set and the fallback matched the default, and one ignored `__VENV_PROMPT__` and used `__VENV_NAME__` instead (and even used a differing format to the default prompt). This change now has all activation scripts use `__VENV_PROMPT__` only and relies on the fact that venv sets that value by default.

The color of the customization is also now set in fish to the blue from the Python logo for as hex color support is built into that shell (much like PowerShell where the built-in green color is used).
2019-08-21 15:58:01 -07:00
Steve Dower df2d4a6f3d
bpo-37834: Normalise handling of reparse points on Windows (GH-15231)
bpo-37834: Normalise handling of reparse points on Windows
* ntpath.realpath() and nt.stat() will traverse all supported reparse points (previously was mixed)
* nt.lstat() will let the OS traverse reparse points that are not name surrogates (previously would not traverse any reparse point)
* nt.[l]stat() will only set S_IFLNK for symlinks (previous behaviour)
* nt.readlink() will read destinations for symlinks and junction points only

bpo-1311: os.path.exists('nul') now returns True on Windows
* nt.stat('nul').st_mode is now S_IFCHR (previously was an error)
2019-08-21 15:27:33 -07:00
Steve Dower 75e064962e
bpo-9949: Enable symlink traversal for ntpath.realpath (GH-15287) 2019-08-21 13:43:06 -07:00
Anthony Sottile e1c638da6a Fix difflib ? hint in diff output when dealing with tabs (#15201) 2019-08-21 13:59:25 -05:00
Jordon Xu 20f59fe1f7 bpo-37751: Fix codecs.lookup() normalization (GH-15092)
Fix codecs.lookup() to normalize the encoding name the same way
than encodings.normalize_encoding(), except that codecs.lookup()
also converts the name to lower case.
2019-08-21 14:26:20 +01:00
Victor Stinner d8c5adf6f8
bpo-37851: faulthandler allocates its stack on demand (GH-15358)
The faulthandler module no longer allocates its alternative stack at
Python startup. Now the stack is only allocated at the first
faulthandler usage.

faulthandler no longer ignores memory allocation failure when
allocating the stack. sigaltstack() failure now raises an OSError
exception, rather than being ignored.

The alternative stack is no longer used if sigaction() is
not available. In practice, sigaltstack() should only be available
when sigaction() is avaialble, so this change should have no effect
in practice.

faulthandler.dump_traceback_later() internal locks are now only
allocated at the first dump_traceback_later() call, rather than
always being allocated at Python startup.
2019-08-21 13:40:42 +01:00
Victor Stinner de2d9eed8b
bpo-37531: Enhance regrtest multiprocess timeout (GH-15345)
* Write a message when killing a worker process
* Put a timeout on the second popen.communicate() call
  (after killing the process)
* Put a timeout on popen.wait() call
* Catch popen.kill() and popen.wait() exceptions
2019-08-21 10:59:20 +01:00
Greg Price 9ece4a5057 Unmark files as executable that can't actually be executed. (GH-15353)
There are plenty of legitimate scripts in the tree that begin with a
`#!`, but also a few that seem to be marked executable by mistake.

Found them with this command -- it gets executable files known to Git,
filters to the ones that don't start with a `#!`, and then unmarks
them as executable:

    $ git ls-files --stage \
      | perl -lane 'print $F[3] if (!/^100644/)' \
      | while read f; do
          head -c2 "$f" | grep -qxF '#!' \
          || chmod a-x "$f"; \
        done

Looking at the list by hand confirms that we didn't sweep up any
files that should have the executable bit after all.  In particular

 * The `.psd` files are images from Photoshop.

 * The `.bat` files sure look like things that can be run.
   But we have lots of other `.bat` files, and they don't have
   this bit set, so it must not be needed for them.



Automerge-Triggered-By: @benjaminp
2019-08-20 21:53:59 -07:00
Zackery Spytz 46a7564578 bpo-32793: Fix a duplicate debug message in smtplib (GH-15341)
_get_socket() already prints a debug message for the host and port.



https://bugs.python.org/issue32793



Automerge-Triggered-By: @maxking
2019-08-20 10:52:25 -07:00
Joannah Nanjekye 9e66aba999 bpo-15913: Implement PyBuffer_SizeFromFormat() (GH-13873)
Implement PyBuffer_SizeFromFormat() function (previously
documented but not implemented): call struct.calcsize().
2019-08-20 15:46:36 +01:00
Eric V. Smith b0f4dab873
bpo-37868: Improve is_dataclass for instances. (GH-15325) 2019-08-20 01:40:28 -04:00
Antoine d3c8d73514 Minor documentation fixes on library/enum (GH-15234)
* Minor documentation fixes on library/enum
2019-08-19 18:41:31 -07:00
Victor Stinner d11c2c6077
Revert "bpo-37788: Fix a reference leak if a thread is not joined (GH-15228)" (GH-15338)
This reverts commit d3dcc92778.
2019-08-20 00:47:07 +01:00
Victor Stinner d3dcc92778
bpo-37788: Fix a reference leak if a thread is not joined (GH-15228)
Add threading.Thread.__del__() method to ensure that the thread state
lock is removed from the _shutdown_locks list when a thread
completes.
2019-08-19 23:37:17 +01:00
shireenrao 24fe46081b bpo-36266: Add module name in ImportError when DLL not found on Windows (GH-15180) 2019-08-17 13:50:39 -07:00
Jeroen Demeyer 0567786d26 bpo-37540: vectorcall: keyword names must be strings (GH-14682)
The fact that keyword names are strings is now part of the vectorcall and `METH_FASTCALL` protocols. The biggest concrete change is that `_PyStack_UnpackDict` now checks that and raises `TypeError` if not.

CC @markshannon @vstinner 


https://bugs.python.org/issue37540
2019-08-16 03:41:27 -07:00
Raymond Hettinger f3cb68f2e4
bpo-37863: Optimize Fraction.__hash__() (#15298) 2019-08-15 20:58:26 -07:00
Jeroen Demeyer 37806f404f bpo-37207: enable vectorcall for type.__call__ (GH-14588)
Base PR for other PRs that want to play with `type.__call__` such as #13930 and #14589.

The author is really @markshannon I just made the PR.


https://bugs.python.org/issue37207



Automerge-Triggered-By: @encukou
2019-08-15 08:49:46 -07:00
Victor Stinner ac827edc49
bpo-21131: Fix faulthandler.register(chain=True) stack (GH-15276)
faulthandler now allocates a dedicated stack of SIGSTKSZ*2 bytes,
instead of just SIGSTKSZ bytes. Calling the previous signal handler
in faulthandler signal handler uses more than SIGSTKSZ bytes of stack
memory on some platforms.
2019-08-14 23:35:27 +02:00
Artem Khramov 2814620657 bpo-37811: FreeBSD, OSX: fix poll(2) usage in sockets module (GH-15202)
FreeBSD implementation of poll(2) restricts the timeout argument to be
either zero, or positive, or equal to INFTIM (-1).

Unless otherwise overridden, socket timeout defaults to -1. This value
is then converted to milliseconds (-1000) and used as argument to the
poll syscall. poll returns EINVAL (22), and the connection fails.

This bug was discovered during the EINTR handling testing, and the
reproduction code can be found in
https://bugs.python.org/issue23618 (see connect_eintr.py,
attached). On GNU/Linux, the example runs as expected.

This change is trivial:
If the supplied timeout value is negative, truncate it to -1.
2019-08-14 23:21:48 +02:00
Tal Einat 71662dc2f1 bpo-37849: IDLE: fix completion window positioning above line (GH-15267) 2019-08-14 13:06:06 -04:00
Victor Stinner b0c8369c60
bpo-37531: Fix regrtest timeout for subprocesses (GH-15072)
Co-Authored-By: Joannah Nanjekye <joannah.nanjekye@ibm.com>
2019-08-14 14:18:51 +02:00
Victor Stinner 077af8c2c9
bpo-37738: Fix curses addch(str, color_pair) (GH-15071)
Fix the implementation of curses addch(str, color_pair): pass the
color pair to setcchar(), instead of always passing 0 as the color
pair.
2019-08-14 12:31:43 +02:00