Commit Graph

112226 Commits

Author SHA1 Message Date
Victor Stinner 976dec9b3b
bpo-46417: _PyList_Fini() clears indexerr (GH-30815)
_PyList_Fini() now clears the 'indexerr' error message.
2022-01-23 02:20:44 +01:00
Raymond Hettinger bcacab47bf
Minor code rearrangement to group related methods together. (GH-30813)
* Make example more focused with math.prod()
* Move comparison tests to the multiset operations section
2022-01-22 18:47:22 -06:00
Victor Stinner a1444f4358
bpo-46417: Fix _PyStaticType_Dealloc() (GH-30810)
_PyStaticType_Dealloc() now only calls PyObject_ClearWeakRefs()
if the call is not going to fail.
2022-01-23 00:32:05 +01:00
Victor Stinner 12f4ac3bc8
bpo-46417: Clear symtable identifiers at exit (GH-30809)
Add _PySymtable_Fini() function, called by finalize_interp_clear().

Update test_cmd_line.test_showrefcount() to tolerate negative
reference count.
2022-01-23 00:06:56 +01:00
Nikita Sobolev 1ded8ed8e8
bpo-41682: Skip unstable test_asyncio sendfile test on Windows (GH-30801) 2022-01-22 23:52:26 +01:00
Victor Stinner 9c8e490b8f
bpo-46417: Clear _io module static objects at exit (GH-30807)
Add _PyIO_Fini() function, called by finalize_interp_clear(). It
clears static objects used by the _io extension module.
2022-01-22 23:22:20 +01:00
Victor Stinner 1626bf4ac7
bpo-46417: Clear Unicode static types at exit (GH-30806)
Add _PyUnicode_FiniTypes() function, called by
finalize_interp_types(). It clears these static types:

* EncodingMapType
* PyFieldNameIter_Type
* PyFormatterIter_Type

_PyStaticType_Dealloc() now does nothing if tp_subclasses
is not NULL.
2022-01-22 22:55:39 +01:00
Victor Stinner 621a45ccac
bpo-46417: Py_Finalize() clears static exceptioins (GH-30805)
The Py_Finalize() function now clears exceptions implemented as
static types.

Add _PyExc_FiniTypes() function, called by _PyExc_Fini().
2022-01-22 22:31:44 +01:00
Victor Stinner f1bcdeaca6
bpo-46417: Factorize _PyExc_InitTypes() code (GH-30804)
Add 'static_exceptions' list to factorize code between
_PyExc_InitTypes() and _PyBuiltins_AddExceptions().

_PyExc_InitTypes() does nothing if it's not the main interpreter.

Sort exceptions in Lib/test/exception_hierarchy.txt.
2022-01-22 21:48:56 +01:00
Jason R. Coombs a941e5927f
bpo-46126: Disable 'descriptions' when running tests internally. (GH-30194) 2022-01-22 10:49:38 -08:00
Victor Stinner 6cacdb4245
bpo-46417: _PyTypes_FiniTypes() clears object and type (GH-30798) 2022-01-22 19:31:24 +01:00
Victor Stinner ce7d66771e
bpo-45200: GHA Address Sanitizer skips 3 slowest tests (GH-30797)
Skip the 3 slowest tests of the Address Sanitizer CI of GitHub
Actions:

* test_tools
* test_peg_generator
* test_concurrent_futures

These tests take between 5 and 20 minutes on this CI which makes this
CI job the slowest. Making this CI job faster makes the whole Python
workflow faster. These tests are run on all others CIs.

Example of Address Sanitizer output:

    10 slowest tests:
    - test_peg_generator: 17 min 33 sec
    - test_tools: 8 min 27 sec
    - test_concurrent_futures: 5 min 24 sec
    - test_zipfile: 2 min 41 sec
    - test_compileall: 2 min 21 sec
    - test_asyncio: 2 min 17 sec
    - test_gdb: 1 min 43 sec
    - test_weakref: 1 min 35 sec
    - test_pickle: 1 min 18 sec
    - test_subprocess: 1 min 12 sec

Moreover, test_concurrent_futures also seems to be affected by
bpo-45200 bug: libasan dead lock in pthread_create().
2022-01-22 19:15:37 +01:00
Victor Stinner 3a4c15bb98
bpo-46417: Cleanup typeobject.c code (GH-30795)
* Add comment to recurse_down_subclasses() explaining why it's safe
  to use a borrowed reference to tp_subclasses.
* remove_all_subclasses() no longer accept NULL cases
* type_set_bases() now relies on the fact that new_bases is not NULL.
* type_dealloc_common() avoids PyErr_Fetch/PyErr_Restore if tp_bases
  is NULL.
* remove_all_subclasses() makes sure that no exception is raised.
* Don't test at runtime if tp_mro only contains types: rely on
  _PyType_CAST() assertion for that.
* _PyStaticType_Dealloc() no longer clears tp_subclasses which is
  already NULL.
* mro_hierarchy() avoids calling _PyType_GetSubclasses() if
  tp_subclasses is NULL.

Coding style:

* Use Py_NewRef().
* Add braces and move variable declarations to the first variable
  assignement.
* Rename a few variables and parameters to use better names.
2022-01-22 18:56:11 +01:00
Victor Stinner 500c146387
bpo-46417: Clear more static types (GH-30796)
* Move PyContext static types into object.c static_types list.
* Rename PyContextTokenMissing_Type to _PyContextTokenMissing_Type
  and declare it in pycore_context.h.
* _PyHamtItems types are no long exported: replace PyAPI_DATA() with
  extern.
2022-01-22 18:55:48 +01:00
Nikita Sobolev 1f8014c5b4
bpo-46425: fix direct invocation of `test_fileutils` and `test_zoneinfo` (GH-30792) 2022-01-22 18:05:43 +02:00
Nikita Sobolev 57316c52ba
bpo-46425: fix direct invocation of `test_importlib` (GH-30682) 2022-01-22 18:05:05 +02:00
Nikita Sobolev 55f4ec460e
bpo-46425: use absolute imports in `test_sqlite3` (GH-30676) 2022-01-22 18:03:56 +02:00
Nikita Sobolev 101a184d49
bpo-46425: fix direct invocation of `test_traceback` (GH-30746) 2022-01-22 18:03:13 +02:00
Victor Stinner 2d03b73cc9
bpo-46417: remove_subclass() clears tp_subclasses (GH-30793)
The remove_subclass() function now deletes the dictionary when
removing the last subclass (if the dictionary becomes empty) to save
memory: set PyTypeObject.tp_subclasses to NULL. remove_subclass() is
called when a type is deallocated.

_PyType_GetSubclasses() no longer holds a reference to tp_subclasses:
its loop cannot modify tp_subclasses.
2022-01-22 16:53:30 +01:00
Victor Stinner f1c6ae3270
bpo-46417: Fix race condition on setting type __bases__ (GH-30788)
Fix a race condition on setting a type __bases__ attribute: the
internal function add_subclass() now gets the
PyTypeObject.tp_subclasses member after calling PyWeakref_NewRef()
which can trigger a garbage collection which can indirectly modify
PyTypeObject.tp_subclasses.
2022-01-22 15:08:42 +01:00
Jelle Zijlstra c8a536624e
bpo-46468: document that "-m http.server" defaults to port 8000 (GH-30776)
Code link:
70c16468de/Lib/http/server.py (L1270)

It's been this way since at least 3.4.

Also improved some wording in the same section.
2022-01-22 14:31:15 +02:00
Kumar Aditya ea5b96842e
bpo-46469: Make asyncio generic classes return GenericAlias (GH-30777)
* bpo-46469: Make asyncio generic classes return GenericAlias

* 📜🤖 Added by blurb_it.

* Update Misc/NEWS.d/next/Library/2022-01-22-05-05-08.bpo-46469.plUab5.rst

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-01-22 13:28:53 +02:00
Kumar Aditya ab8fe22e5e
fix DeprecationWarning when running asyncio tests (GH-30486) 2022-01-22 13:20:10 +02:00
Nikita Sobolev 5d73524116
bpo-46460: remove duplicated `versionchanged` from `dis.rst` (GH-30752) 2022-01-22 11:15:58 +00:00
Nikita Sobolev 5a5340044c
bpo-46425: fix direct invocation of `asyncio` tests (#30725) 2022-01-22 13:06:27 +02:00
Erlend Egeberg Aasland 38afeb1a33
bpo-46249: Move set lastrowid out of the sqlite3 query loop (GH-30489) 2022-01-22 18:40:22 +09:00
Yellow Dusk 82c53229e1
bpo-46442: improve and rename testExceptionCleanupNames (GH-30758)
The test tested that explicitly deleting the local variable bound to the exception
did not cause problems, but it did not test what it actually claimed to test, i.e.
that the variable is deleted automatically.
2022-01-22 02:09:34 -05:00
Steve Dower 70c16468de
Improve the Windows release build scripts (GH-30771)
Update to windows-2022 image
Promote queue variables to parameters for better UI
Structure build steps using parameters instead of conditions for simpler status display
2022-01-22 01:13:16 +00:00
Victor Stinner cd8de40b3b
bpo-29882: _Py_popcount32() doesn't need 64x64 multiply (GH-30774)
32x32 bits multiply is enough for _Py_popcount32().
2022-01-22 00:54:42 +01:00
Victor Stinner ac1f152421
bpo-46417: Use _PyType_CAST() in Objects directory (GH-30764) 2022-01-21 23:33:43 +01:00
Victor Stinner 7835cbf949
bpo-46417: Use _PyType_CAST() in Python directory (GH-30769) 2022-01-21 23:30:17 +01:00
Victor Stinner 8ee07dda13
bpo-46417: Add _PyType_GetSubclasses() function (GH-30761)
Add a new _PyType_GetSubclasses() function to get type's subclasses.

_PyType_GetSubclasses(type) returns a list which holds strong
refererences to subclasses. It is safer than iterating on
type->tp_subclasses which yields weak references and can be modified
in the loop.

_PyType_GetSubclasses(type) now holds a reference to the tp_subclasses
dict while creating the list of subclasses.

set_collection_flag_recursive() of _abc.c now uses
_PyType_GetSubclasses().
2022-01-21 23:29:10 +01:00
Steve Dower 57d1855682
bpo-46463: Fixes escape4chm.py script used when building the CHM documentation file (GH-30768) 2022-01-21 21:51:15 +00:00
Nikita Sobolev 65b88d5e01
bpo-46445: Cover multiple inheritance of `TypedDict` in `test_typing` (GH-30719) 2022-01-21 13:38:23 -08:00
Weipeng Hong 881a763cfe
bpo-43118: Fix bug in inspect.signature around 'base.__text_signature__' (GH-30285) 2022-01-21 13:24:33 -08:00
Jason R. Coombs 00b2b578bd
bpo-46124: Update zoneinfo to rely on importlib.resources traversable API. (GH-30190)
Automerge-Triggered-By: GH:jaraco
2022-01-21 13:18:31 -08:00
Erlend Egeberg Aasland f1e559b754
Update generated files list and add `diff=generated` attribute (GH-30745)
As a side effect, the list of generated files is relocated after the language aware diff settings.

Closes python/core-workflow#425

Automerge-Triggered-By: GH:zware
2022-01-21 12:59:45 -08:00
Victor Stinner bc67f189fd
bpo-46417: Add _PyType_CAST() macro (GH-30760)
In debug mode, the macro makes sure that its argument is a type using
an assertion.
2022-01-21 21:39:01 +01:00
Tom Sparrow 60705cff70
bpo-46434: Handle missing docstrings in pdb help (GH-30705) 2022-01-21 17:00:48 +00:00
Victor Stinner a1bf329bca
bpo-46417: Add missing types of _PyTypes_InitTypes() (GH-30749)
Add types removed by mistake by the commit adding
_PyTypes_FiniTypes().

Move also PyBool_Type at the end, since it depends on PyLong_Type.

PyBytes_Type and PyUnicode_Type no longer depend explicitly on
PyBaseObject_Type: it's the default of PyType_Ready().
2022-01-21 17:53:13 +01:00
Victor Stinner fda8886498
bpo-46417: Revert remove_subclass() change (GH-30750)
remove_subclass() doesn't clear the tp_subclasses dict if the dict
becomes empty.
2022-01-21 16:45:14 +01:00
Victor Stinner 595225e86d
bpo-46417: Py_Finalize() clears static types (GH-30743)
Add _PyTypes_FiniTypes() best-effort function to clear static types:
don't deallocate a type if it still has subclasses.

remove_subclass() now sets tp_subclasses to NULL when removing the
last subclass.
2022-01-21 13:06:34 +01:00
Victor Stinner ea38e436fe
bpo-46417: Call _PyDebug_PrintTotalRefs() later (GH-30744)
"python -X showrefcount" now shows the total reference count after
clearing and destroyed the main Python interpreter. Previously, it
was shown before.

Py_FinalizeEx() now calls _PyDebug_PrintTotalRefs() after
finalize_interp_delete().
2022-01-21 13:05:26 +01:00
Serhiy Storchaka 54610bb448
bpo-46426: Improve tests for the dir_fd argument (GH-30668)
Ensure that directory file descriptors refer to directories different
from the current directory, and that src_dir_fd and dst_dir_fd refer
to different directories.

Add context manager open_dir_fd() in test.support.os_helper.
2022-01-21 09:54:50 +02:00
Thomas Klausner 40fcd16889
bpo-30512: Add CAN Socket support for NetBSD (GH-30066) 2022-01-21 09:44:05 +02:00
andrei kulakov cfadcc31ea
bpo-21987: Fix TarFile.getmember getting a dir with a trailing slash (GH-30283) 2022-01-21 09:40:32 +02:00
Nikita Sobolev 22f73bd9f1
bpo-46425: Fix direct invocation of `test_contextlib` (GH-30681) 2022-01-21 09:36:19 +02:00
Victor Stinner d013b24135
bpo-46417: signal uses PyStructSequence_NewType() (GH-30735)
The signal module now creates its struct_siginfo type as a heap type
using PyStructSequence_NewType(), rather than using a static type.

Add 'siginfo_type' member to the global signal_state_t structure.
2022-01-21 04:02:38 +01:00
Victor Stinner 1781d55eb3
bpo-46417: _curses uses PyStructSequence_NewType() (GH-30736)
The _curses module now creates its ncurses_version type as a heap
type using PyStructSequence_NewType(), rather than using a static
type.

* Move _PyStructSequence_FiniType() definition to pycore_structseq.h.
* test.pythoninfo: log curses.ncurses_version.
2022-01-21 03:30:20 +01:00
Victor Stinner 17f268a4ae
bpo-46417: time module uses PyStructSequence_NewType() (GH-30734)
The time module now creates its struct_time type as a heap
type using PyStructSequence_NewType(), rather than using a static
type.

* Add a module state to the time module: add traverse, clear and free
  functions.
* Use PyModule_AddType().
* Remove the 'initialized' variable.
2022-01-21 02:52:43 +01:00