Commit Graph

43149 Commits

Author SHA1 Message Date
CtrlZvi c66c342cb4 bpo-33542: Ignore DUID in uuid.get_node on Windows. (GH-6922)
uuid._ipconfig_getnode did not validate the maximum length of the value,
so long as the value had the same type of formatting as a MAC address.
This let it select DUIDs as MAC addresses. It now requires an exact
length match.
2018-05-20 18:03:25 +03:00
Serhiy Storchaka 6655354afc
bpo-33584: Fix several minor bugs in asyncio. (GH-7003)
Fix the following bugs in the C implementation:

* get_future_loop() silenced all exceptions raised when look up the get_loop
  attribute, not just an AttributeError.
* enter_task() silenced all exceptions raised when look up the current task,
  not just a KeyError.
* repr() was called for a borrowed link in enter_task() and task_step_impl().
* str() was used instead of repr() in formatting one error message (in
  Python implementation too).
* There where few reference leaks in error cases.
2018-05-20 16:30:31 +03:00
CtrlZvi 4151061855 bpo-26819: Prevent proactor double read on resume (#6921)
The proactor event loop has a race condition when reading with
pausing/resuming. `resume_reading()` unconditionally schedules the read
function to read from the current future. If `resume_reading()` was
called before the previously scheduled done callback fires, this results
in two attempts to get the data from the most recent read and an
assertion failure. This commit tracks whether or not `resume_reading`
needs to reschedule the callback to restart the loop, preventing a
second attempt to read the data.
2018-05-20 13:21:10 +03:00
Serhiy Storchaka f5e7b1999f
bpo-23722: Raise a RuntimeError for absent __classcell__. (GH-6931)
A DeprecationWarning was emitted in Python 3.6-3.7.
2018-05-20 08:48:12 +03:00
Terry Jan Reedy 6b0d09b8f0
bpo-30928: Update idlelib/NEWS.txt. (#6995) 2018-05-19 21:38:46 -04:00
Cheryl Sabella 654038d896 bpo-32831: IDLE: Add docstrings and tests for codecontext (GH-5638) 2018-05-19 15:34:03 -04:00
Ivan Levkivskyi f65e31fee3
bpo-28556: Don't simplify unions at runtime (GH-6841) 2018-05-18 16:00:38 -07:00
Skip Montanaro 5634331a76 bpo-33556: Remove reference to thread module from docstring (GH-6963) 2018-05-18 13:38:36 -05:00
Terry Jan Reedy d89ca94847
bpo-33564: Add async to IDLE's code context block openers. (GH-6960) 2018-05-17 20:38:41 -04:00
Barry Warsaw 273f51f5ca
Provide a little better debug output (#6940) 2018-05-17 11:54:01 -04:00
Barry Warsaw 0ed66df524
bpo-33537: Add an __all__ to importlib.resources (#6920) 2018-05-17 11:41:53 -04:00
Eric Snow 3ab0136ac5
bpo-32604: Implement force-closing channels. (gh-6937)
This will make it easier to clean up channels (e.g. when used in tests).
2018-05-17 10:27:09 -04:00
Matthias Bussonnier f90f5d5c1d bpo-33549: Remove shim and deprecation warning to access DocumentLS.async. (GH-6924)
`obj.async` is now a syntax error, so the warning/shim is
quasi-unnecessary.
2018-05-17 11:16:12 +03:00
Serhiy Storchaka 64fddc423f bpo-33475: Fix and improve converting annotations to strings. (GH-6774) 2018-05-16 23:17:48 -04:00
Steve Dower e5f41d2f1e
bpo-33522: Enable CI builds on Visual Studio Team Services (#6865) 2018-05-16 17:50:29 -04:00
Eric Snow 6d2cd9036c
bpo-32604: Improve subinterpreter tests. (#6914)
Add more tests for subinterpreters. This patch also fixes a few small defects in the channel implementation.
2018-05-16 15:04:57 -04:00
Nina Zakharenko 2d2d3b170b Fix ClassVar as string fails when getting type hints (GH-6824) 2018-05-16 12:27:03 -04:00
Petr Viktorin 8b94b41ab7
bpo-28167: Remove platform.linux_distribution (GH-6871)
* test_ssl: Remove skip_if_broken_ubuntu_ssl

We no longer support OpenSSL 0.9.8.15.15.

* bpo-28167: Remove platform.linux_distribution
2018-05-16 11:51:18 -04:00
Eric V. Smith 4e81296b18
bpo-33536: Validate make_dataclass() field names. (GH-6906) 2018-05-16 11:31:29 -04:00
Christopher Beacham 5db5c0669e bpo-21475: Support the Sitemap extension in robotparser (GH-6883) 2018-05-16 10:52:07 -04:00
Eric V. Smith 9285835a05
bpo-33534: Remove unneeded test. (GH-6897)
This condition as already tested before this code is called.
2018-05-16 07:24:00 -04:00
Eric V. Smith f8e7549490
Reflow dataclasses comments (GH-6893)
To be more consistent with other code (and so people stop hassling me!), reflow the dataclasses comments to not use a single space indentation when continuing a paragraph of text.
2018-05-16 05:14:53 -04:00
Isaiah Peng 4cc3eb48e1 bpo-32384: Skip test when _testcapi isn't available (GH-4940) 2018-05-16 11:05:17 +03:00
Eric V. Smith 2a7bacbd91
bpo-33453: Handle string type annotations in dataclasses. (GH-6768) 2018-05-15 22:44:27 -04:00
Terry Jan Reedy 038b21f2ca
bpo-30928: Update idlelib/NEWS.txt to 2018-05-14. (#6873) 2018-05-15 17:41:57 -04:00
Victor Stinner b056562860
bpo-33509: Fix _warnings for module_globals=None (#6833)
Don't crash on warnings.warn_explicit() if module_globals is not a dict.
2018-05-15 20:42:12 +02:00
Barry Warsaw 8709b236fc
bpo-33465: Use an unlikely to be built-in C extension in a test (#6797) 2018-05-15 14:41:13 -04:00
Terry Jan Reedy 389a48ede9
bpo-29706: Test that IDLE colors async/await as keywords. (GH-6846)
Added to the eye-verified htest, not to the unittests.
Also remove some stray leftover comments.
2018-05-15 14:20:38 -04:00
Matthias Bussonnier 9eb40bc38d bpo-28167: bump platform.linux_distribution removal to 3.8 (GH-6669)
Also bump PendingDeprecationWarning to DeprecationWarning.
2018-05-15 11:17:00 -04:00
Eric V. Smith 01abc6ec3a
bpo-33517: dataclasses: Add the field type to Field repr (GH-6858) 2018-05-15 08:36:21 -04:00
Segev Finer 735abadd5b bpo-16865: Support arrays >=2GB in ctypes. (GH-3006) 2018-05-15 02:54:29 +03:00
Amber Brown 545c955be9 bpo-33497: Add errors param to cgi.parse_multipart and make an encoding in FieldStorage use the given errors (GH-6804) 2018-05-14 18:11:55 -04:00
Eric V. Smith 3059042410
bpo-33502: dataclass._Dataclassparams repr: use repr of each member. (GH-6812) 2018-05-14 17:16:52 -04:00
Eric V. Smith 2473eea65d
bpo-33494: Change dataclasses.Fields repr to use the repr of each of its members (GH-6798) 2018-05-14 11:37:28 -04:00
Michael Lazar bd08a0af2d bpo-32861: urllib.robotparser fix incomplete __str__ methods. (GH-5711)
The urllib.robotparser's __str__ representation now includes wildcard
entries and the "Crawl-delay" and "Request-rate" fields. Also removes extra
newlines that were being appended to the end of the string.
2018-05-14 17:10:41 +03:00
Anders Kaseorg 5c0d462689 bpo-32601: Let test_expanduser use the same user if no others found. (GH-5246)
This happens in the NixOS build sandbox, for example, where the only
other user is nobody with home directory /.
2018-05-14 17:00:37 +03:00
Miro Hrončok 7ec8f28656 bpo-33455: Pass os.environ in test_posix::test_specify_environment. (GH-6753)
Pass os.environ's copy to new process created at test_posix:
test_specify_environment. Otherwise important variables such as
LD_LIBRARY_PATH are not set and the child process might not work at all
in an environment where such variables are required for Python to function.
2018-05-11 08:40:43 +03:00
Ivan Levkivskyi b551e9f0ff
Fix a bug in Generic.__new__ (GH-6758) 2018-05-10 23:10:10 -04:00
Oren Milman d518d8bc8d bpo-21983: Fix a crash in ctypes.cast() when passed a ctypes structured data type (GH-3859) 2018-05-09 14:38:56 -07:00
sblondon 8cf4b34b36 bpo-33311: Do not display parameters displayed in parentheses for module call. (GH-6677) 2018-05-09 12:39:32 +03:00
jdemeyer ac9240b9be closes bpo-33445: fail properly in test_cprofile() (GH-6727) 2018-05-08 21:16:35 -07:00
Ivan Levkivskyi 43d12a6bd8
bpo-28556: Minor fixes for typing module (GH-6732)
This also fixes https://bugs.python.org/issue33420
2018-05-09 02:23:46 +01:00
Serhiy Storchaka ec1622d56c
bpo-33144: Fix choosing random.Random._randbelow implementation. (GH-6563)
random() takes precedence over getrandbits() if defined later
in the class tree.
2018-05-08 15:45:15 +03:00
Serhiy Storchaka d54cfb160c
bpo-33441: Make the sigset_t converter available in other modules. (GH-6720)
* Expose the sigset_t converter via private API _Py_Sigset_Converter().
* Use Argument Clinic for parsing sigset_t in signalmodule.c.
* Raise ValueError instead OverflowError for integers out of
  the C long range.

Based on patch by Pablo Galindo Salgado.
2018-05-08 07:48:50 +03:00
Serhiy Storchaka a3f19c3f52
Remove mojibake in the locale aliases mapping. (GH-6716) 2018-05-06 10:52:38 +03:00
Serhiy Storchaka cedc9b7420
bpo-20087: Update locale alias mapping with glibc 2.27 supported locales. (ПР-6708) 2018-05-06 08:46:15 +03:00
Andrés Delfino b2043bbe60 bpo-33422: Fix quotation marks getting deleted when looking up byte/string literals on pydoc. (GH-6701)
Also update the list of string prefixes.
2018-05-05 19:07:32 +03:00
Vinay Sajip c4994dc00d
bpo-33400: Clarified documentation to indicate no strict adherence to ISO 8601. (GH-6702) 2018-05-04 22:20:54 +01:00
Antoine Pitrou 9d3627e311
bpo-33332: Add signal.valid_signals() (GH-6581) 2018-05-04 13:00:50 +02:00
Ray Donnelly d06d345f04 bpo-33281: Fix ctypes.util.find_library regression on macOS (GH-6625) 2018-05-01 22:31:36 -04:00
Serhiy Storchaka ef347535f2
bpo-20104: Improve error handling and fix a reference leak in os.posix_spawn(). (#6332) 2018-05-01 16:45:04 +03:00
Michael Selik 47ab15470d bpo-31908: Fix output of cover files for trace module command-line tool. (GH-4205)
Previously emitted cover files only when --missing option was used.
2018-05-01 06:46:52 +03:00
Brett Cannon 3ab9365dca
bpo-33254: do not return an empty list when asking for the contents of a namespace package (GH-6467) 2018-04-30 11:31:45 -07:00
Andrés Delfino c3b7a6dfb9 bpo-33352: Skip test_regrtest test if rt.bat does not exist (GH-6654) 2018-04-30 18:30:53 +02:00
Terry Jan Reedy 5ff3a161c8
bpo-21474: Update IDLE word/identifier definition from ascii to unicode. (GH-6643)
In text and entry boxes, this affects selection by double-click,
movement left/right by control-left/right, and deletion left/right
by control-BACKSPACE/DEL.
2018-04-30 03:08:01 -04:00
sblondon 7d68bfa826 bpo-33256: Replace angle brackets around python object repr to display it in html (GH-6442) 2018-04-29 20:48:33 +03:00
Serhiy Storchaka 70af06cdc4
bpo-31026: Fix test_dbm if dbm.ndbm is build with Berkeley DB. (GH-6632) 2018-04-29 15:45:03 +03:00
Serhiy Storchaka 2e38cc3933
bpo-33383: Fix crash in get() of the dbm.ndbm database object. (#6630) 2018-04-29 12:38:06 +03:00
Zsolt Dollenstein e239650660 bpo-33363: raise SyntaxError for async for/with outside async functions (#6616) 2018-04-27 11:58:56 -04:00
Pablo Galindo 4114846265 bpo-33358: Fix test_embed.test_pre_initialization_sys_options (GH-6612)
Fix test_embed.test_pre_initialization_sys_options() when building with --enable-shared
2018-04-27 14:23:13 +02:00
Cheryl Sabella 0250de4819 bpo-27485: Rename and deprecate undocumented functions in urllib.parse (GH-2205) 2018-04-25 16:51:54 -07:00
Serhiy Storchaka 57faf34887
bpo-33334: Support NOP and EXTENDED_ARG in dis.stack_effect(). (#6566)
Added tests to ensure that all defined opcodes are supported.
2018-04-25 22:04:06 +03:00
Pablo Galindo 0977091dca bpo-33128 Fix duplicated call to importlib._install_external_importers (GH-6273)
External importers were being added in both phases of the import
system initialisation.

They're only supposed to be added in the second phase, after the
import machinery has been appropriately configured.
2018-04-25 12:22:28 +10:00
Chris Bradbury 1d4a733cce bpo-33251: Prevent ConfigParser.items returning items present in vars. (#6446)
* bpo-33251: ConfigParser.items no longer returns items present in vars.

Documentation for `ConfigParser.items()` states:
'Items present in vars no longer appear in the result.'

This fix aligns behaviour to that specified in the documentation.
2018-04-23 12:16:17 -07:00
Łukasz Langa c2d384dbd7
bpo-33338: [tokenize] Minor code cleanup (#6573)
This change contains minor things that make diffing between Lib/tokenize.py and
Lib/lib2to3/pgen2/tokenize.py cleaner.
2018-04-23 01:07:11 -07:00
Berker Peksag d5a2377c3d
bpo-991266: Fix quoting of Comment attribute of SimpleCookie (GH-6555) 2018-04-23 02:48:11 +03:00
Ville Skyttä 61f82e0e33 Spelling fixes to docs, docstrings, and comments (GH-6374) 2018-04-20 16:08:45 -04:00
Paul Moore 0399cf9b5e
bpo-33131: Upgrade ensurepip to bundle pip 10.0.1 (GH-6546)
Upgrade ensurepip to bundle pip 10.0.1
2018-04-20 21:06:51 +01:00
Serhiy Storchaka 69524821a8
bpo-33189: pygettext.py now accepts only literal strings (GH-6364)
as docstrings and translatable strings, and rejects
bytes literals and f-string expressions.
2018-04-19 09:23:03 +03:00
Denis Osipov e3a523a0fa bpo-31583: Fix 2to3 for using with --add-suffix option (GH-3758) 2018-04-18 16:50:25 -07:00
Serhiy Storchaka e5362eaa75
bpo-33308: Fix a crash in the parser module when convert an ST object. (#6519)
Converting with line_info=False and col_info=True crashed before.
2018-04-19 01:55:37 +03:00
Aaron Ang c127a86e18 bpo-11594: Ensure line-endings are respected when using 2to3 (GH-6483) 2018-04-17 14:34:14 -07:00
INADA Naoki 36d56ea826 bpo-33295: Skip test using missing external site (GH-6504)
`test_urllib2net.OtherNetworkTests.test_sites_no_connection_close`
used `http://www.imdb.com/` but it is moved to https so the test is
not valid anymore.  Skip test for the moment to allow CI to proceed.
2018-04-17 11:31:29 -04:00
Wolfgang Maier ba3a87aca3 bpo-33144: random.Random and subclasses: split _randbelow implementation (GH-6291) 2018-04-17 08:16:17 -07:00
jdemeyer 28e8b66d6c Fix spelling typo (GH-6443) 2018-04-17 11:15:44 -04:00
Andrés Delfino 4b685bf719 bpo-33283: Mention PNG as a supported format by Tcl/Tk. (GH-6479) 2018-04-17 08:34:35 +03:00
Łukasz Langa 76618061b9
[lib2to3] Make grammar pickling faster (#6491)
* Now uses pickle protocol 4

* Doesn't wrap the grammar's `__dict__` in ordered dictionaries anymore as
dictionaries in Python 3.6+ are ordered by default

This still produces deterministic pickles (that hash the same with MD5).
Tested with different PYTHONHASHSEED values.
2018-04-16 17:33:59 -07:00
Zsolt Dollenstein 8f37e84664 Add support for all string literals to lib2to3 (#6457) 2018-04-16 14:33:31 -07:00
anentropic b8e21f1289 bpo-31947: remove None default for names param in Enum._create_ (GH-4288) 2018-04-15 20:40:35 -07:00
Alex Gaynor afbbac12a5
Removed a confusing line from a docstring in http.cookies (GH-6482)
There's no reason a cookie should _ever_ contain pickled data. That's just asking for a critical security vulnerability. Back in Python2 there were helpers for doing that, but they're no more in Python3. Now coded_value is used when the value needs to be encoded for any reason.
2018-04-15 17:23:47 -04:00
Nick Coghlan 1a5c4bdb6e
bpo-33185: Improve wording and markup (GH-6477)
Adds some working and markup fixes that I missed
in the initial commit for this issue.

(Follow-up to GH-6419)
2018-04-15 23:32:05 +10:00
Nick Coghlan 82a9481059
bpo-33185: Fix regression in pydoc CLI sys.path handling (GH-6419)
The pydoc CLI assumed -m pydoc would add the empty string
to sys.path, and hence got confused when it switched to
adding the full initial working directory instead.

This refactors the pydoc CLI path manipulation to be
more testable, and ensures it won't accidentally
remove the standard library directory containing
pydoc itself from sys.path.
2018-04-15 21:52:57 +10:00
Antoine Pitrou 480ab05d5f
bpo-33176: Add a toreadonly() method to memoryviews. (GH-6466) 2018-04-14 19:49:21 +02:00
jdemeyer 23ab5ee667 bpo-33265: use an actual method instead of a method-like function in ExitStack (GH-6456)
`MethodType` has the exact semantics that `ExitStack` needs,
so we can avoid creating a Python level closure.
2018-04-13 22:22:46 +10:00
Serhiy Storchaka d08972fdb9
bpo-33260: Regenerate token.py after removing ASYNC and AWAIT. (GH-6447) 2018-04-11 19:15:51 +03:00
Mark Nemec c4b695f85e bpo-33097: Fix submit accepting callable after executor shutdown by interpreter exit (GH-6144)
Executors in concurrent.futures accepted tasks after executor was shutdown by interpreter exit. Tasks were left in PENDING state forever. This fix changes submit to instead raise a RuntimeError.
2018-04-10 19:23:14 +02:00
Serhiy Storchaka c93938b5be
bpo-31920: Fixed handling directories as arguments in the ``pygettext`` script. (GH-6259)
Based on patch by Oleg Krasnikov.
2018-04-09 20:09:17 +03:00
Antoine Pitrou e4679cd644
bpo-32759: Free unused arenas in multiprocessing.heap (GH-5827)
Large shared arrays allocated using multiprocessing would remain allocated
until the process ends.
2018-04-09 17:37:55 +02:00
Serhiy Storchaka 2ef65f346a
Fix misleading docsting of shelve.open(). (GH-6427)
The protocol parameter can be any protocol supported by the
pickle module.
2018-04-09 17:16:01 +03:00
Wolfgang Maier 9c463ec88b Update docstring of tempfile._RandomNameSequence (GH-6414)
When bpo-12015 got resolved by increasing the length of the
random string generated by _RandomNameSequence from six to eight
characters, the docstring of the class was not adjusted accordingly.
2018-04-09 09:42:39 +09:00
Raymond Hettinger 9265dd72e5
Add a prepend() recipe to teach a chain() idiom (GH-6415) 2018-04-08 08:44:20 -07:00
Alex Gaynor c87eb09d2e
bpo-29613: Added support for SameSite cookies (GH-6413)
* bpo-29613: Added support for SameSite cookies

Implemented as per draft
https://tools.ietf.org/html/draft-west-first-party-cookies-07

* Documented SameSite

And suggestions by members.

* Missing space :(

* Updated News and contributors

* Added version changed details.

* Fix in documentation

* fix in documentation

* Clubbed test cases for same attribute into single.

* Updates

* Style nits + expand tests

* review feedback
2018-04-07 16:09:42 -04:00
Brett Cannon 9e2be60634
bpo-33169: Remove values of `None` from sys.path_importer_cache when invalidating caches (GH-6402)
An entry of None in sys.path_importer_cache represents a negative/missing finder for a path, so clearing it out makes sense.
2018-04-06 16:10:18 -07:00
Raymond Hettinger 01b731fc2b
bpo-33224: PEP 479 fix for difflib.mdiff() (GH-6381) 2018-04-05 11:19:57 -07:00
Wolfgang Maier 091e95e900 bpo-33203: Ensure random.choice always raises IndexError on empty sequence (GH-6338) 2018-04-05 08:19:44 -07:00
Eric V. Smith 74940913d2
Clean up and enhance frozen dataclass tests. (GH-6380)
* Add a test for frozen with unhashable field value.
* Improve a comment.
2018-04-05 06:50:18 -04:00
Ivan Levkivskyi 2a363d2930
bpo-32873: Remove a name hack for generic aliases in typing module (GH-6376)
This removes a hack and replaces it with a proper
mapping {'list': 'List', 'dict': 'Dict', ...}.
2018-04-05 01:25:15 +01:00
Ivan Levkivskyi ee566fe526
Call super in Generic.__init_subclass__ (#6356) 2018-04-04 17:00:15 +01:00
Serhiy Storchaka 2eeac269dd
bpo-29922: Add more tests for error messages in 'async with'. (GH-6370)
Different paths are executed for normal exit and for leaving
the 'async with' block with 'break', 'continue' or 'return'.
2018-04-04 18:45:10 +03:00
Łukasz Langa c51d8c9ba6
bpo-23403: Bump pickle.DEFAULT_PROTOCOL to 4 (#6355)
This makes performance better and produces shorter pickles. This change is backwards compatible up to the oldest currently supported version of Python (3.4).
2018-04-03 23:06:53 -07:00
Serhiy Storchaka c869529ea9 bpo-33209: End framing at the end of C implementation of pickle.Pickler.dump(). (GH-6363) 2018-04-03 14:11:27 -07:00
INADA Naoki 629338f140
bpo-32360: Remove object_pairs_hook=OrderedDict examples (GH-5001) 2018-04-03 12:39:47 +09:00
Serhiy Storchaka a68f2f0578
bpo-29922: Improve error messages in 'async with' (GH-6352)
when __aenter__() or __aexit__() return non-awaitable object.
2018-04-03 01:41:38 +03:00
Terry Jan Reedy 55966f3a0d
bpo-33204: IDLE - revise and extend colorizer test. (GH-6347)
Followup to primary PR for the issue, GH-6344.
2018-04-02 11:18:02 -04:00
Terry Jan Reedy da58533ac6
bpo-33204: IDLE: consistently color invalid string prefixes (#6344)
A 'u' string prefix cannot be paired with either 'r' or 'f'.  Consistently
color as much of the prefix, starting at the right, as is valid.
2018-04-02 01:47:46 -04:00
Ivan Levkivskyi 5a7092de12
Allow dynamic creation of generic dataclasses (GH-6319) 2018-03-31 13:41:17 +01:00
Eric V. Smith 521995205a
bpo-33175: dataclasses should look up __set_name__ on class, not instance (GH-6305) 2018-03-29 11:07:48 -04:00
Serhiy Storchaka bac2d5ba30
Fix duplicating words words. (GH-6296)
Most of them have been added in 3.7.
2018-03-28 22:14:26 +03:00
Ned Deily e52ac04597
bpo-32872: Avoid regrtest compatibility issue with namespace packages. (GH-6276) 2018-03-28 01:57:13 -04:00
Sam Dunster 65a34709f6 Fix senfile typo (#6265)
* Also in docs
2018-03-27 17:47:38 -07:00
Ned Deily 8534d53333
bpo-32517: fix test_read_pty_output() hangs on macOS 10.13.2+ (GH-6037) (GH-6113)
test_asyncio hangs indefinitely on macOS 10.13.2+ on `read_pty_output()`
using the KqueueSelector. Closing `proto.transport` (as is done in
`write_pty_output()`) seems to fix it.
(cherry picked from commit 12f74d8608)

Co-authored-by: Nathan Henrie <n8henrie@users.noreply.github.com>

Also, re-enable test_read_pty_output on macOS.
2018-03-27 17:16:49 -04:00
Barry Warsaw 30e507dff4
bpo-33151: Handle submodule resources (GH-6268) 2018-03-27 09:59:38 -07:00
Cheryl Sabella da1734c58d bpo-27212: Modify islice recipe to consume initial values preceding start (GH-6195) 2018-03-26 18:29:33 -07:00
Ivan Levkivskyi 834940375a
bpo-32873: Treat type variables and special typing forms as immutable by copy and pickle (GH-6216)
This also fixes python/typing#512
This also fixes python/typing#511

As was discussed in both issues, some typing forms deserve to be treated
as immutable by copy and pickle modules, so that:
* copy(X) is X
* deepcopy(X) is X
* loads(dumps(X)) is X  # pickled by reference

This PR adds such behaviour to:
* Type variables
* Special forms like Union, Any, ClassVar
* Unsubscripted generic aliases to containers like List, Mapping, Iterable

This not only resolves inconsistencies mentioned in the issues, but also
improves backwards compatibility with previous versions of Python
(including 3.6).

Note that this requires some dances with __module__ for type variables
(similar to NamedTuple) because the class TypeVar itself is define in typing,
while type variables should get module where they were defined.

https://bugs.python.org/issue32873
2018-03-26 23:01:12 +01:00
Alexey Izbyshev 0e7144b064 bpo-32844: Fix a subprocess misredirection of a low fd (GH5689)
bpo-32844: subprocess: Fix a potential misredirection of a low fd to stderr.

When redirecting, subprocess attempts to achieve the following state:
each fd to be redirected to is less than or equal to the fd
it is redirected from, which is necessary because redirection
occurs in the ascending order of destination descriptors.
It fails to do so in a couple of corner cases,
for example, if 1 is redirected to 2 and 0 is closed in the parent.
2018-03-26 12:49:35 -07:00
Eric V. Smith de7a2f04d6
bpo-33141: Have dataclasses.Field pass through __set_name__ to any default argument. (GH-6260)
This is part of PEP 487 and the descriptor protocol.
2018-03-26 13:29:16 -04:00
Oren Milman 7c2d97827f bpo-6986: Add a comment to clarify a test of _json.make_encoder(). (GH-3789) 2018-03-26 18:04:39 +03:00
Garvit Khatri 3ab44c0783 bpo-33096: Fix ttk.Treeview.insert. (GH-6228)
Allow ttk.Treeview.insert to insert iid that has a false boolean value.
Note iid=0 and iid=False would be same.
2018-03-26 10:02:05 +03:00
Eric V. Smith 2b75fc2bc9
Minor fixes to dataclass tests. (GH-6243)
Also, re-enable a test for ClassVars with default_factory.
2018-03-25 20:37:33 -04:00
Nick Coghlan a9e5d0e9ef
bpo-33053: Remove test_cmd_line_script debugging print (GH-6237)
I noticed this had slipped into the original commit when
resolving a merge conflict for the backport to 3.7.
2018-03-25 23:47:54 +10:00
Eric V. Smith 51c9ab42ab
Trivial improvements to dataclasses tests. (GH-6234) 2018-03-25 09:04:32 -04:00
Nick Coghlan d5d9e02dd3
bpo-33053: -m now adds *starting* directory to sys.path (GH-6231)
Historically, -m added the empty string as sys.path
zero, meaning it resolved imports against the current
working directory, the same way -c and the interactive
prompt do.

This changes the sys.path initialisation to add the
*starting* working directory as sys.path[0] instead,
such that changes to the working directory while the
program is running will have no effect on imports
when using the -m switch.
2018-03-25 23:03:10 +10:00
Nick Coghlan bc77eff8b9
bpo-33042: Fix pre-initialization sys module configuration (GH-6157)
- new test case for pre-initialization of sys.warnoptions and sys._xoptions
- restored ability to call these APIs prior to Py_Initialize
- updated the docs for the affected APIs to make it clear they can be
  called before Py_Initialize
- also enhanced the existing embedding test cases
  to check for expected settings in the sys module
2018-03-25 20:44:30 +10:00
Christian Heimes d02ac25ab0
bpo-33136: Harden ssl module against CVE-2018-8970 (GH-6229)
Harden ssl module against LibreSSL CVE-2018-8970.
X509_VERIFY_PARAM_set1_host() is called with an explicit namelen. A new test
ensures that NULL bytes are not allowed.

Signed-off-by: Christian Heimes <christian@python.org>
2018-03-25 12:36:13 +02:00
Xiang Zhang e4ce9fa89c
bpo-32943: Fix confusing error message for rot13 codec (GH-5869) 2018-03-25 12:09:21 +08:00
Eric V. Smith c42e7aa67c
Fix invalid escape sequence: use raw string. (GH-6225) 2018-03-24 23:02:21 -04:00
Eric V. Smith 01d618c560
bpo-33134: dataclasses: use function dispatch table for hash, instead of a string lookup which then is tested with if tests. (GH-6222)
* Change _hash_action to be a function table lookup, instead of a list
of strings which is then tested with if statements.
2018-03-24 22:10:14 -04:00
Eric V. Smith f96ddade00
Trivial dataclass cleanups: (GH-6218)
- When adding a single element to a list, use .append() instead of
  += and creating a new list.
- For consistency, import the copy module, instead of just deepcopy. This
  leaves only a module at the class level, instead of a function.
- Improve some comments.
- Improve some whitespace.
- Use tuples instead of lists.
- Simplify a test.
2018-03-24 17:20:26 -04:00
Christian Heimes e42ae91509
bpo-24334: Remove inaccurate match_hostname call (#6211)
Commit 141c5e8c re-added match_hostname() call. The resurrection of the
function call was never intended and was solely a merge mistake.

Signed-off-by: Christian Heimes <christian@python.org>
2018-03-24 15:36:50 +01:00
Xiang Zhang d8b291a742
bpo-32932: More revealing error message when non-str objects in __all__ (GH-5848) 2018-03-24 18:39:36 +08:00
Julien Palard 8bcfa02e4b
bpo-31639: Use threads in http.server module. (GH-5018) 2018-03-23 17:40:33 +01:00
Serhiy Storchaka 397466dfd9
bpo-30953: Improve error messages and add tests for jumping (GH-6196)
into/out of an except block.
2018-03-23 14:46:45 +02:00
Serhiy Storchaka 702f8f3611
bpo-33041: Rework compiling an "async for" loop. (#6142)
* Added new opcode END_ASYNC_FOR.
* Setting global StopAsyncIteration no longer breaks "async for" loops.
* Jumping into an "async for" loop is now disabled.
* Jumping out of an "async for" loop no longer corrupts the stack.
* Simplify the compiler.
2018-03-23 14:34:35 +02:00
Eric V. Smith 56970b8ce9
bpo-32505: dataclasses: raise TypeError if a member variable is of type Field, but doesn't have a type annotation. (GH-6192)
If a dataclass has a member variable that's of type Field, but it doesn't have a type annotation, raise TypeError.
2018-03-22 16:28:48 -04:00
jab 40472dd42d bpo-33018: Improve issubclass() error checking and message. (GH-5944)
This improves error message for situations when a non-class is
checked w.r.t. an abstract base class.
2018-03-22 11:26:06 +00:00
Donald Stufft d93b5161af
Upgrade pip to v9.0.3 and setuptools to v39.0.1 (#6184) 2018-03-21 22:47:44 -04:00
Eric V. Smith 8e4560a9da
Add 'Field' to dataclasses.__all__. (GH-6182)
- Add missing 'Field' to __all__.
- Improve tests to catch this.
2018-03-21 17:10:22 -04:00
Thomas Moreau dec1c7786f FIX failure on OSX sem_getvalue (#6180) 2018-03-21 18:56:27 +01:00
Thomas Moreau e2f33add63 bpo-33078 - Fix queue size on pickling error (GH-6119) 2018-03-21 16:50:28 +01:00
Eric V. Smith 8f6eccdc64
bpo-32896: Fix error when subclassing a dataclass with a field that uses a default_factory (GH-6170)
Fix the way that new annotations in a class are detected.
2018-03-20 22:00:23 -04:00
Xiang Zhang 10b134a07c
bpo-27683: Fix a regression for host() of ipaddress network objects (GH-6016)
The result of host() was not empty when the network is constructed by a tuple containing an
integer mask and only 1 bit left for addresses.
2018-03-21 08:25:13 +08:00
Cheryl Sabella 5609b78392 bpo-18802: Add more details to ipaddress documentation (GH-6083)
Original patch by Jon Foster and Berker Peksag.
2018-03-21 08:09:15 +08:00
Matt Eaton 2cb4661707 bpo-33034: Improve exception message when cast fails for {Parse,Split}Result.port (GH-6078) 2018-03-20 09:41:37 +03:00
Eric V. Smith 7389fd935c
bpo-33100: Dataclasses now handles __slots__ and default values correctly. (GH-6152)
If the class has a member that's a MemberDescriptorType, it's not a default value, it's from that member being in __slots__.
2018-03-19 21:07:51 -04:00
aetracht 4573820d2a bpo-33061: Add missing 'NoReturn' to __all__ in typing.py (GH-6127) 2018-03-19 18:41:32 +00:00
Eric V. Smith f199bc655e
bpo-32953: Dataclasses: frozen should not be inherited for non-dataclass derived classes (#6147)
If a non-dataclass derives from a frozen dataclass, allow attributes to be set.
Require either all of the dataclasses in a class hierarchy to be frozen, or all non-frozen.
Store `@dataclass` parameters on the class object under `__dataclass_params__`. This is needed to detect frozen base classes.
2018-03-18 20:40:34 -04:00
xdegaye 3fe33043ee bpo-19417: Add test_bdb.py (GH-5217) 2018-03-18 13:02:47 -07:00
Jelle Zijlstra f64aae46da Revert "bpo-30406: Make async and await proper keywords (#1669)" (GH-6143)
This reverts commit ac317700ce.

(Reverts only the lib2to3 part.)
2018-03-18 09:54:33 -07:00
Serhiy Storchaka fe2bbb1869
bpo-32489: Allow 'continue' in 'finally' clause. (GH-5822) 2018-03-18 09:56:52 +02:00
Serhiy Storchaka 134cb01cda
bpo-32056: Improve exceptions in aifc, wave and sunau. (GH-5951) 2018-03-18 09:55:53 +02:00
Serhiy Storchaka bc300ce205
bpo-33041: Add tests for jumps in/out of 'async with' blocks. (#6110) 2018-03-18 09:53:08 +02:00
Aviv Palivoda bbf7bb7a63 bpo-27645: Fix version number in 'database in transaction' fallback (GH-6131)
It was actually fixed in SQLite 3.8.8, not 3.8.7.
2018-03-18 03:48:55 +03:00
Donald Stufft 7f81bb2add
Update pip to 9.0.2 and setuptools to 38.6.1 (#6133) 2018-03-17 11:13:48 -04:00
Marcel Plch c2b0b12d1a bpo-32374: m_traverse may be called with m_state=NULL (GH-5140)
Multi-phase initialized modules allow m_traverse to be called while the
module is still being initialized, so module authors may need to account
for that.
2018-03-17 15:41:20 +10:00
Łukasz Langa 74f56878cd
lib2to3: Add more tests (#6101) 2018-03-13 10:53:22 -07:00
xdegaye b8e9d6c5cd bpo-17288: Prevent jumps from 'return' and 'exception' trace events. (GH-6107)
(cherry picked from commit e32bbaf376)
2018-03-13 19:31:31 +02:00
Łukasz Langa b51f5de711
bpo-33064: lib2to3: support trailing comma after *args and **kwargs (#6096)
New tests also added.

I also made the comments in line with the builtin Grammar/Grammar. PEP 306 was
withdrawn, Kees Blom's railroad program has been lost to the sands of time for
at least 16 years now (I found a python-dev post from people looking for it).
2018-03-13 00:44:49 -07:00
Antoine Pietri 019f5b3e9e bpo-22674: fix test_strsignal on OSX (GH-6085) 2018-03-12 20:03:14 +01:00
Thomas Moreau 095ee415ce bpo-33056 FIX leaking fd in concurrent.futures.ProcessPoolExecutor (#6084) 2018-03-12 19:18:41 +02:00
Antoine Pietri 5d2a27de62 signal: add strsignal() (#6017)
Co-authored-by: Vajrasky Kok <sky.kok@speaklikeaking.com>
2018-03-12 14:42:34 +01:00
Antoine Pitrou e756f66c83
bpo-31804: Fix multiprocessing.Process with broken standard streams (#6079)
In some conditions the standard streams will be None or closed in the child process (for example if using "pythonw" instead of "python" on Windows).  Avoid failing with a non-0 exit code in those conditions.

Report and initial patch by poxthegreat.
2018-03-11 19:21:38 +01:00
Serhiy Storchaka e2732d3e66
bpo-32970: Improve disassembly of the MAKE_FUNCTION instruction. (GH-5937) 2018-03-11 11:07:06 +02:00
Serhiy Storchaka 3f7e9aa2ef
bpo-32925: Optimized iterating and containing test for literal lists (GH-5842)
consisting of non-constants: `x in [a, b]` and `for x in [a, b]`.
The case of all constant elements already was optimized.
2018-03-11 10:54:47 +02:00
Serhiy Storchaka 4e2442505c
bpo-32946: Speed up "from ... import ..." from non-packages. (GH-5873) 2018-03-11 10:52:37 +02:00
Serhiy Storchaka b931bd0a2f
bpo-32338: OrderedDict import is no longer needed in re. (#4891) 2018-03-11 08:38:13 +02:00
Serhiy Storchaka 26c9f565d0
bpo-33026: Fix jumping out of "with" block by setting f_lineno. (#6026) 2018-03-11 08:32:47 +02:00
Berker Peksag 7280a4eef5
bpo-27645: Skip test_bad_target_in_transaction if SQLite == 3.8.7.1 (GH-6067) 2018-03-11 03:38:50 +03:00
Emanuele Gaifas d7aed4102d bpo-27645: Add support for native backup facility of SQLite (GH-4238) 2018-03-11 01:08:31 +03:00
Xiang Zhang c10b288f34
bpo-30249: Improve struct.unpack_from() error messages (GH-6059) 2018-03-11 02:58:52 +08:00
Serhiy Storchaka 24d3201eb7
bpo-33041: Fixed bytecode generation for "async for" with a complex target. (#6052)
A StopAsyncIteration raised on assigning or unpacking will be now propagated
instead of stopping the iteration.
2018-03-10 18:22:34 +02:00
Andrew Svetlov 5e80a71ab6
bpo-33037: Skip sending/receiving after SSL transport closing (GH-6044)
* Skip write()/data_received() if sslpipe is destroyed
2018-03-10 17:48:35 +02:00
INADA Naoki fc7df0e664
bpo-32999: Fix ABC.__subclasscheck__ crash (GH-6002) 2018-03-07 16:27:01 +09:00
Xiang Zhang bc3f2289b9
bpo-32969: Expose some missing constants in zlib and fix the doc (GH-5988) 2018-03-07 13:05:37 +08:00
Yury Selivanov 8a387219bd
bpo-33009: Fix inspect.signature() for single-parameter partialmethods. (GH-6004) 2018-03-06 12:59:45 -05:00
Jason R. Coombs b9650a04a8
bpo-32991: Restore expectation that inspect.getfile raises TypeError on namespace package (GH-5980)
* bpo-32991: Add test capturing expectation.

DocTestFinder.find should return an empty list for doctests in a namespace package.

* bpo-32991: Restore expectation that inspect.getfile on a namespace package raises TypeError.
2018-03-05 18:29:08 -05:00
Steve Dower 6921e73e33
bpo-33001: Prevent buffer overrun in os.symlink (GH-5989) 2018-03-05 14:26:08 -08:00
Terry Jan Reedy 22c82be5df
bpo-32984: IDLE - set __file__ for startup files (GH-5981)
Like Python, IDLE optionally runs one startup file in the Shell window
before presenting the first interactive input prompt.  For IDLE,
option -s runs a file named in environmental variable IDLESTARTUP or
PYTHONSTARTUP; -r file runs file.  Python sets __file__ to the startup
file name before running the file and unsets it before the first
prompt.  IDLE now does the same when run normally, without the -n
option.
2018-03-05 11:02:46 -05:00
Cheryl Sabella 74382a3f17 bpo-32857: Raise error when tkinter after_cancel() is called with None. (GH-5701) 2018-03-04 12:41:47 +02:00
Jamie Davis 0e6c8ee235 bpo-32981: Fix catastrophic backtracking vulns (#5955)
* Prevent low-grade poplib REDOS (CVE-2018-1060)

The regex to test a mail server's timestamp is susceptible to
catastrophic backtracking on long evil responses from the server.

Happily, the maximum length of malicious inputs is 2K thanks
to a limit introduced in the fix for CVE-2013-1752.

A 2KB evil response from the mail server would result in small slowdowns
(milliseconds vs. microseconds) accumulated over many apop calls.
This is a potential DOS vector via accumulated slowdowns.

Replace it with a similar non-vulnerable regex.

The new regex is RFC compliant.
The old regex was non-compliant in edge cases.

* Prevent difflib REDOS (CVE-2018-1061)

The default regex for IS_LINE_JUNK is susceptible to
catastrophic backtracking.
This is a potential DOS vector.

Replace it with an equivalent non-vulnerable regex.

Also introduce unit and REDOS tests for difflib.

Co-authored-by: Tim Peters <tim.peters@gmail.com>
Co-authored-by: Christian Heimes <christian@python.org>
2018-03-03 21:33:32 -08:00
Serhiy Storchaka b21d155f57
bpo-32964: Reuse a testing implementation of the path protocol in tests. (#5930) 2018-03-02 11:53:51 +02:00
Eric V. Smith 5da8cfb838
Fixed incorrect default value for dataclass unsafe_hash. (GH-5949) 2018-03-01 08:01:41 -05:00
Cheryl Sabella f0daa880a4 bpo-32940: IDLE: Simplify StringTranslatePseudoMapping in pyparse (GH-5862)
The new code also runs faster.
2018-02-28 17:23:58 -05:00
Terry Jan Reedy 0954c9e9c8
bpo-30928: Update idlelib/NEWS.txt, possibly for 3.7.0b2 (GH-5932) 2018-02-27 18:36:21 -05:00
Serhiy Storchaka be50a7b627 Revert "bpo-31961: subprocess now accepts path-like args (GH-4329)" (#5912)
* Revert "bpo-31961: subprocess now accepts path-like args (GH-4329)"

This reverts commit dd42cb71f2.
2018-02-27 18:03:46 -05:00
Christian Heimes 698dde16f6
bpo-31453: Add setter for min/max protocol version (#5259)
OpenSSL 1.1 has introduced a new API to set the minimum and maximum
supported protocol version. The API is easier to use than the old
OP_NO_TLS1 option flags, too.

Since OpenSSL has no call to set minimum version to highest supported,
the implementation emulate maximum_version = MINIMUM_SUPPORTED and
minimum_version = MAXIMUM_SUPPORTED by figuring out the minumum and
maximum supported version at compile time.

Signed-off-by: Christian Heimes <christian@python.org>
2018-02-27 11:54:43 +01:00
Christian Heimes 9d50ab563d
bpo-32951: Disable SSLSocket/SSLObject constructor (#5864)
Direct instantiation of SSLSocket and SSLObject objects is now prohibited.
The constructors were never documented, tested, or designed as public
constructors. The SSLSocket constructor had limitations. For example it was
not possible to enabled hostname verification except was
ssl_version=PROTOCOL_TLS_CLIENT with cert_reqs=CERT_REQUIRED.

SSLContext.wrap_socket() and SSLContext.wrap_bio are the recommended API
to construct SSLSocket and SSLObject instances. ssl.wrap_socket() is
also deprecated.

The only test case for direct instantiation was added a couple of days
ago for IDNA testing.

Signed-off-by: Christian Heimes <christian@python.org>
2018-02-27 10:17:30 +01:00
Christian Heimes 05d9fe32a1
bpo-32947: OpenSSL 1.1.1-pre1 / TLS 1.3 fixes (#5663)
* bpo-32947: OpenSSL 1.1.1-pre1 / TLS 1.3 fixes

Misc fixes and workarounds for compatibility with OpenSSL 1.1.1-pre1 and
TLS 1.3 support. With OpenSSL 1.1.1, Python negotiates TLS 1.3 by
default. Some test cases only apply to TLS 1.2. Other tests currently
fail because the threaded or async test servers stop after failure.

I'm going to address these issues when OpenSSL 1.1.1 reaches beta.

OpenSSL 1.1.1 has added a new option OP_ENABLE_MIDDLEBOX_COMPAT for TLS
1.3. The feature is enabled by default for maximum compatibility with
broken middle boxes. Users should be able to disable the hack and CPython's test suite needs
it to verify default options.

Signed-off-by: Christian Heimes <christian@python.org>
2018-02-27 08:55:39 +01:00
Eric V. Smith 2fa6b9eae0
bpo-32960: For dataclasses, disallow inheriting frozen from non-frozen classes and vice-versa, (GH-5919)
This restriction will be relaxed at a future date.
2018-02-26 20:38:33 -05:00
Joffrey F 72d9b2be36 bpo-32713: Fix tarfile.itn for large/negative float values. (GH-5434) 2018-02-27 02:02:21 +02:00
Tobotimus eee72d4778 bpo-32222: Fix pygettext skipping docstrings for funcs with arg typehints (GH-4745) 2018-02-27 00:48:14 +02:00
Sergey Fedoseev 6b5df906af bpo-32147: Improved perfomance of binascii.unhexlify(). (GH-4586) 2018-02-26 22:35:41 +02:00
animalize 19e7d48ce8 bpo-32394: Remove some TCP options on old version Windows. (GH-5523) 2018-02-26 10:10:36 -08:00
Serhiy Storchaka 3f2e6f15d6
Revert unneccessary changes made in bpo-30296 and apply other improvements. (GH-2624) 2018-02-26 16:50:11 +02:00
Serhiy Storchaka 6f600ff173
bpo-32922: dbm.open() now encodes filename with the filesystem encoding. (GH-5832) 2018-02-26 16:02:22 +02:00
Terry Jan Reedy 973cae07d6
Fix 'deecorator' typo in test/test_dataclasses (GH-5899) 2018-02-25 21:38:18 -05:00
Eric V. Smith dbf9cff48a
bpo-32929: Dataclasses: Change the tri-state hash parameter to the boolean unsafe_hash. (#5891)
unsafe_hash=False is now the default. It is the same behavior as the old hash=None parameter. unsafe_hash=True will try to add __hash__. If it already exists, TypeError is raised.
2018-02-25 21:30:17 -05:00
Andrew Svetlov a19fb3c6aa
bpo-32622: Native sendfile on windows (#5565)
* Support sendfile on Windows Proactor event loop naively.
2018-02-25 19:32:14 +03:00
Aaron Gallagher 5fb632e831 Delete a broken threading.local example (#5870)
This code never did anything correct or useful. The class attribute will never be affected, and the condition will never be true.
2018-02-25 10:03:40 -05:00
Christian Heimes b7b9225831
bpo-31809: test secp ECDH curves (#4036)
Add tests to verify connection with secp384r1 ECDH curves.
2018-02-25 09:49:31 +01:00
Christian Heimes 141c5e8c24
bpo-24334: Cleanup SSLSocket (#5252)
* The SSLSocket is no longer implemented on top of SSLObject to
  avoid an extra level of indirection.
* Owner and session are now handled in the internal constructor.
* _ssl._SSLSocket now uses the same method names as SSLSocket and
  SSLObject.
* Channel binding type check is now handled in C code. Channel binding
  is always available.

The patch also changes the signature of SSLObject.__init__(). In my
opinion it's fine. A SSLObject is not a user-constructable object.
SSLContext.wrap_bio() is the only valid factory.
2018-02-24 21:10:57 +01:00