patch 9.1.0784: there are several problems with python 3.13
Problem: there are several problems with python 3.13
Solution: fix the problems in the python3 interface (Boris Staletic)
This commit does the following things:
1) Since python 3.13.0b1, all statically defined objects are "immortal".
Besides never getting garbage collected, this also affects reference
counting:
- Immportal objects have a reference count of 2^32-1.
- Reference counting is a no-op.
All this is considered implementation details by cpython, so
documentation is next to non-existent.
Relevant CPython source code:
https://github.com/python/cpython/blob/v3.13.0/Include/object.h#L62-L107
https://github.com/python/cpython/blob/v3.13.0/Include/object.h#L389-L391
2) Opt-out of ANSI-painted python stack traces
3) Make python error message severity more consistent
fixes: #15838
closes: #15842
Signed-off-by: Boris Staletic <boris.staletic@protonmail.com>
Signed-off-by: puremourning <puremourning@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_python3.vim b/src/testdir/test_python3.vim
index 7f04f11..3178cff 100644
--- a/src/testdir/test_python3.vim
+++ b/src/testdir/test_python3.vim
@@ -4029,30 +4029,34 @@
v = create_list()
base_ref_count = sys.getrefcount(v)
for el in v:
- vim.vars['list_iter_ref_count_increase'] = sys.getrefcount(v) - base_ref_count
+ vim.vars['list_iter_ref_count_increase'] = sys.getrefcount(v) - base_ref_count
create_dict = vim.Function('Create_vim_dict')
v = create_dict()
base_ref_count = sys.getrefcount(v)
for el in v:
- vim.vars['dict_iter_ref_count_increase'] = sys.getrefcount(v) - base_ref_count
+ vim.vars['dict_iter_ref_count_increase'] = sys.getrefcount(v) - base_ref_count
v = vim.buffers
base_ref_count = sys.getrefcount(v)
for el in v:
- vim.vars['bufmap_iter_ref_count_increase'] = sys.getrefcount(v) - base_ref_count
+ vim.vars['bufmap_iter_ref_count_increase'] = sys.getrefcount(v) - base_ref_count
v = vim.options
base_ref_count = sys.getrefcount(v)
for el in v:
- vim.vars['options_iter_ref_count_increase'] = sys.getrefcount(v) - base_ref_count
+ vim.vars['options_iter_ref_count_increase'] = sys.getrefcount(v) - base_ref_count
test_python3_iter_ref()
EOF
call assert_equal(1, g:list_iter_ref_count_increase)
call assert_equal(1, g:dict_iter_ref_count_increase)
- call assert_equal(1, g:bufmap_iter_ref_count_increase)
+ if py3eval('sys.version_info[:2] < (3, 13)')
+ call assert_equal(1, g:bufmap_iter_ref_count_increase)
+ else
+ call assert_equal(0, g:bufmap_iter_ref_count_increase)
+ endif
call assert_equal(1, g:options_iter_ref_count_increase)
endfunc