Commit graph

109789 commits

Author SHA1 Message Date
Pablo Galindo 558df90109
bpo-43916: Export the _PyStructSequence_InitType to fix build errors in the curses module (GH-25768) 2021-05-01 02:21:19 +01:00
Ma Lin 251ffa9d2b
bpo-41486: Fix initial buffer size can't > UINT32_MAX in zlib module (GH-25738)
* Fix initial buffer size can't > UINT32_MAX in zlib module

After commit f9bedb630e, in 64-bit build,
if the initial buffer size > UINT32_MAX, ValueError will be raised.

These two functions are affected:
1. zlib.decompress(data, /, wbits=MAX_WBITS, bufsize=DEF_BUF_SIZE)
2. zlib.Decompress.flush([length])

This commit re-allows the size > UINT32_MAX.

* adds curly braces per PEP 7.

* Renames `Buffer_*` to `OutputBuffer_*` for clarity
2021-04-30 16:32:49 -07:00
Erlend Egeberg Aasland e467ec476f
bpo-43995: Fix reference leak in test_grammar (GH-25764) 2021-05-01 00:23:14 +01:00
Mohamed Moselhy e726a902b7
bpo-43971: Add spaces around annotated arg default '=' (GH-25702)
Result: "quantity_on_hand: int = 0".
2021-04-30 19:06:55 -04:00
JT e08c67372d
bpo-43928: Fix 'succesfully' typo in document (GH-25569) 2021-04-30 18:35:07 -04:00
Tarjei Bærland 0048c60f01
bpo-43935: Fix typo in Turtle.back() docstring (GH-25581)
'e ,' to 'e, '.
2021-04-30 18:05:45 -04:00
Ammar Askar 726c931b38
bpo-43888: Remove coverage builds from CI (GH-25679)
The coverage builds were consistently timing out in CI, suggesting that people were not reviewing the uploaded reports.
2021-04-30 14:04:40 -07:00
Dong-hee Na 6143fcdf8b
bpo-43979: Remove unnecessary operation from urllib.parse.parse_qsl (GH-25756)
Automerge-Triggered-By: GH:gpshead
2021-04-30 12:01:55 -07:00
Pablo Galindo 6689e45dfe
bpo-43981: Fix reference leaks in test_squeezer (GH-25758) 2021-04-30 19:34:29 +01:00
Victor Stinner 665c7746fc
bpo-43916: _md5.md5 uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25753)
The following types use Py_TPFLAGS_DISALLOW_INSTANTIATION flag:

* _md5.md5
* _sha1.sha1
* _sha256.sha224
* _sha256.sha256
* _sha512.sha384
* _sha512.sha512
2021-04-30 18:40:30 +02:00
Pablo Galindo e374a40afa
bpo-43901: Fix refleaks in test_module (GH-25754) 2021-04-30 17:26:45 +01:00
Victor Stinner 7dcf0f6db3
bpo-43916: select.devpoll uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25751) 2021-04-30 18:19:57 +02:00
Erlend Egeberg Aasland 9746cda705
bpo-43916: Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to selected types (GH-25748)
Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to the following types:

* _dbm.dbm
* _gdbm.gdbm
* _multibytecodec.MultibyteCodec
* _sre..SRE_Scanner
* _thread._localdummy
* _thread.lock
* _winapi.Overlapped
* array.arrayiterator
* functools.KeyWrapper
* functools._lru_list_elem
* pyexpat.xmlparser
* re.Match
* re.Pattern
* unicodedata.UCD
* zlib.Compress
* zlib.Decompress
2021-04-30 16:04:57 +02:00
Erlend Egeberg Aasland 387397f8a4
bpo-43916: select.poll uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25750) 2021-04-30 15:49:17 +02:00
Mark Shannon 5979e81a21
bpo-43933: Set frame.f_lineno during call to __exit__ (GH-25719)
* Set line number of __exit__ call in a with statement to be that of the with keyword.
2021-04-30 14:32:47 +01:00
Erlend Egeberg Aasland 64141382ec
bpo-43908: check_set_special_type_attr() checks Py_TPFLAGS_IMMUTABLETYPE (GH-25743)
check_set_special_type_attr() and type_set_annotations()
now check for immutable flag (Py_TPFLAGS_IMMUTABLETYPE).

Co-authored-by: Victor Stinner <vstinner@python.org>
2021-04-30 15:25:43 +02:00
Jakub Kulík 9032cf5cb1
bpo-43667: Fix broken Unicode encoding in non-UTF locales on Solaris (GH-25096) 2021-04-30 15:21:42 +02:00
Victor Stinner 4908fae3d5
bpo-43916: PyStdPrinter_Type uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25749)
The PyStdPrinter_Type type now uses the
Py_TPFLAGS_DISALLOW_INSTANTIATION flag to disallow instantiation,
rather than seting a tp_init method which always fail.

Write also unit tests for PyStdPrinter_Type.
2021-04-30 14:56:27 +02:00
Victor Stinner 0cad068ec1
bpo-43916: Remove _disabled_new() function (GH-25745)
posix and _hashlib use the new Py_TPFLAGS_DISALLOW_INSTANTIATION
flag on their heap types, rather than using a custom tp_new function
(_disabled_new).
2021-04-30 14:06:49 +02:00
Victor Stinner 3bb09947ec
bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag (GH-25721)
Add a new Py_TPFLAGS_DISALLOW_INSTANTIATION type flag to disallow
creating type instances: set tp_new to NULL and don't create the
"__new__" key in the type dictionary.

The flag is set automatically on static types if tp_base is NULL or
&PyBaseObject_Type and tp_new is NULL.

Use the flag on the following types:

* _curses.ncurses_version type
* _curses_panel.panel
* _tkinter.Tcl_Obj
* _tkinter.tkapp
* _tkinter.tktimertoken
* _xxsubinterpretersmodule.ChannelID
* sys.flags type
* sys.getwindowsversion() type
* sys.version_info type

Update MyStr example in the C API documentation to use
Py_TPFLAGS_DISALLOW_INSTANTIATION.

Add _PyStructSequence_InitType() function to create a structseq type
with the Py_TPFLAGS_DISALLOW_INSTANTIATION flag set.

type_new() calls _PyType_CheckConsistency() at exit.
2021-04-30 12:46:15 +02:00
Erlend Egeberg Aasland b73b5fb9ea
bpo-43973: object_set_class() checks Py_TPFLAGS_IMMUTABLETYPE (GH-25714)
Use Py_TPFLAGS_IMMUTABLETYPE to check for class assignments.
2021-04-30 12:07:02 +02:00
Mark Shannon 069e81ab3d
bpo-43977: Use tp_flags for collection matching (GH-25723)
* Add Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING, add to all relevant standard builtin classes.

* Set relevant flags on collections.abc.Sequence and Mapping.

* Use flags in MATCH_SEQUENCE and MATCH_MAPPING opcodes.

* Inherit Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING.

* Add NEWS

* Remove interpreter-state map_abc and seq_abc fields.
2021-04-30 09:50:28 +01:00
Zackery Spytz 2abbd8f2ad
bpo-43954: Fix a missing word in the unittest docs (GH-25672) 2021-04-30 09:32:19 +02:00
larryhastings 74613a46fc
bpo-43817: Add inspect.get_annotations(). (#25522)
Add inspect.get_annotations, which safely computes the annotations defined on an object.  It works around the quirks of accessing the annotations from various types of objects, and makes very few assumptions about the object passed in. inspect.get_annotations can also correctly un-stringize stringized annotations.

inspect.signature, inspect.from_callable, and inspect.from_function now call inspect.get_annotations to retrieve annotations.  This means inspect.signature and inspect.from_callable can now un-stringize stringized annotations, too.
2021-04-29 21:16:28 -07:00
Terry Jan Reedy a62e424de0
bpo-43981: Fix error in idle-test leak test (GH-25739)
Remove call to macosx.setupApp, which calls macosc.overrideRootMenu, which modifies
the menus, which results in two failures in the second round of the leak test.
2021-04-29 23:52:47 -04:00
larryhastings 175a54b2d8
Two minor fixes for accessing a module's name. (#25658)
While working on another issue, I noticed two minor nits in the C implementation of the module object.  Both are related to getting a module's name.

First, the C function module_dir() (module.__dir__) starts by ensuring the module dict is valid.  If the module dict is invalid, it wants to format an exception using the name of the module, which it gets from PyModule_GetName().  However, PyModule_GetName() gets the name of the module from the dict.  So getting the name in this circumstance will never succeed.

When module_dir() wants to format the error but can't get the name, it knows that PyModule_GetName() must have already raised an exception.  So it leaves that exception alone and returns an error.  The end result is that the exception raised here is kind of useless and misleading: dir(module) on a module with no __dict__ raises SystemError("nameless module").  I changed the code to actually raise the exception it wanted to raise, just without a real module name: TypeError("<module>.__dict__ is not a dictionary").  This seems more useful, and would do a better job putting the programmer who encountered this on the right track of figuring out what was going on.

Second, the C API function PyModule_GetNameObject() checks to see if the module has a dict.  If m->md_dict is not NULL, it calls _PyDict_GetItemIdWithError().  However, it's possible for m->md_dict to be None.  And if you call _PyDict_GetItemIdWithError(Py_None, ...) it will *crash*.

Unfortunately, this crash was due to my own bug in the other branch.  Fixing my code made the crash go away.  I assert that this is still possible at the API level.

The fix is easy: add a PyDict_Check() to PyModule_GetNameObject().

Unfortunately, I don't know how to add a unit test for this.  Having changed module_dir() above, I can't find any other interfaces callable from Python that eventually call PyModule_GetNameObject().  So I don't know how to trick the runtime into reproducing this error.

Since both these changes are minor--each entails only a small edit to only one line--I didn't bother with a news item.
2021-04-29 20:13:25 -07:00
larryhastings 2f2b69855d
bpo-43901: Lazy-create an empty annotations dict in all unannotated user classes and modules (#25623)
Change class and module objects to lazy-create empty annotations dicts on demand.  The annotations dicts are stored in the object's `__dict__` for backwards compatibility.
2021-04-29 20:09:08 -07:00
Brandt Bucher dbe60ee09d
bpo-43892: Validate the first term of complex literal value patterns (GH-25735) 2021-04-29 17:19:28 -07:00
Steve Dower 87655e2cf5
bpo-42800: Rename AUDIT_READ to PY_AUDIT_READ (GH-25736) 2021-04-30 01:08:55 +01:00
Ryan Hileman 9a2c2a9ec3
bpo-42800: add audit hooks for f_code and tb_frame (GH-24182)
Accessing the following attributes will now fire PEP 578 style audit hooks as ("object.__getattr__", obj, name):
* PyTracebackObject: tb_frame
* PyFrameObject: f_code
* PyGenObject: gi_code, gi_frame
* PyCoroObject: cr_code, cr_frame
* PyAsyncGenObject: ag_code, ag_frame
Add an AUDIT_READ attribute flag aliased to READ_RESTRICTED.
Update obsolete flag documentation.
2021-04-30 00:15:55 +01:00
Mark Shannon 088a15c49d
bpo-43933: Show frame.f_lineno as None, rather than -1, if there is no line number. (GH-25717) 2021-04-29 19:28:50 +01:00
sblondon 2fd928c8c1
bpo-42589: Change URL for 'from' link when used in a raised exception (GH-23872)
Links for 'raise Exception from x' target to 'The raise statement' (7.8) section instead of 'The import statement' (7.11) section.

There are more modified links than in the bug report because I searched some other ones which can get the same improvement.
2021-04-29 11:02:40 -07:00
Senthil Kumaran 76cd81d603
bpo-43882 - urllib.parse should sanitize urls containing ASCII newline and tabs. (GH-25595)
* issue43882 - urllib.parse should sanitize urls containing ASCII newline and tabs.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2021-04-29 10:16:50 -07:00
Petr Viktorin 14fc2bdfab
bpo-28254: Add PyGC_ functions to the stable ABI manifest (GH-25720)
Co-authored-by: Senthil Kumaran <senthil@uthcode.com>
Co-authored-by: scoder <stefan_ml@behnel.de>
2021-04-29 15:46:48 +02:00
Mark Shannon c76da79b37
bpo-42739: Don't use sentinels to mark end of line table. (GH-25657)
* Add length parameter to PyLineTable_InitAddressRange and doen't use sentinel values at end of table. Makes the line number table more robust.

* Update PyCodeAddressRange to match PEP 626.
2021-04-29 13:12:51 +01:00
Inada Naoki 53dd6c99b3
bpo-43651: Fix test_logging (GH-25715) 2021-04-29 20:37:32 +09:00
Victor Stinner abfd6388cd
bpo-43774: Enhance debug build documentation (GH-25712)
* Add also references to --with-trace-refs option.
* Move _ob_next and _ob_prev at the end, since they don't exist by
  default and are related to debug.
2021-04-29 13:06:59 +02:00
Terry Jan Reedy 8ec2f0dc0c
bpo-37892: Use space indents in IDLE Shell (GH-25678)
Adding a newline to the prompt moves it out of the way of
user code input, which now starts at the left margin,
along with continuation lines.
2021-04-29 06:48:18 -04:00
Petr Viktorin f6ee4dad58
bpo-43795: Generate python3dll.c and doc data from manifest (PEP 652) (GH-25315) 2021-04-29 11:33:14 +02:00
Victor Stinner 645ed62fb4
bpo-43774: Remove unused PYMALLOC_DEBUG macro (GH-25711)
Enhance also the documentation of debug hooks on memory allocators.
2021-04-29 10:47:47 +02:00
Victor Stinner b1f413e6cf
bpo-28254: Cleanup test_subprocess.test_preexec_gc_module_failure() (GH-25709)
Saving/restoring gc.disable and gc.isenabled is no longer needed.
2021-04-29 10:26:53 +02:00
Victor Stinner 5bd0619533
bpo-43908: Document Static Types in the C API (GH-25710)
Update also PyTypeObject structure definition in the doc.
2021-04-29 10:26:34 +02:00
Erlend Egeberg Aasland c6ad03fddf
bpo-43908: Make array.array type immutable (GH-25696)
Co-authored-by: Victor Stinner <vstinner@python.org>
2021-04-29 08:47:48 +02:00
Erlend Egeberg Aasland 5daf70b22e
bpo-43908: Make re types immutable (GH-25697)
Co-authored-by: Victor Stinner <vstinner@python.org>
2021-04-29 08:47:11 +02:00
Nick Coghlan 1e7b858575
bpo-43892: Make match patterns explicit in the AST (GH-25585)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
2021-04-28 22:58:44 -07:00
Inada Naoki e52ab42ced
bpo-41139: Deprecate cgi.log() (GH-25625) 2021-04-29 11:36:04 +09:00
Inada Naoki a69256527f
bpo-43651: Fix EncodingWarning in os.fdopen() and test_os (GH-25654) 2021-04-29 11:35:36 +09:00
Inada Naoki fa51c0c448
bpo-43651: Fix EncodingWarning in tests. (GH-25655)
* test_httplib
* test_httpservers
* test_logging
2021-04-29 11:34:56 +09:00
Hristo Venev 8557edbfa8
bpo-24275: Don't downgrade unicode-only dicts to mixed on lookups (GH-25186) 2021-04-29 11:06:03 +09:00
Andre Delfino 69a733bda3
[doc] Be more clear on super() regarding multiple base classes methods (GH-21789) 2021-04-28 18:12:15 -07:00