comparison src/testdir/test_python3.vim @ 26139:97b4e8c55c1d v8.2.3602

patch 8.2.3602: Python3 test fails with Python 3.10 on MS-Windows Commit: https://github.com/vim/vim/commit/1be7e215830d6ec9aa6200aac4ef34ac0ae85af5 Author: K.Takata <kentkt@csc.jp> Date: Tue Nov 16 13:08:56 2021 +0000 patch 8.2.3602: Python3 test fails with Python 3.10 on MS-Windows Problem: Python3 test fails with Python 3.10 on MS-Windows. Solution: Adjust the expected error. (Ken Takata, closes https://github.com/vim/vim/issues/9118)
author Bram Moolenaar <Bram@vim.org>
date Tue, 16 Nov 2021 14:15:03 +0100
parents eb6e4f0ba31d
children 485c7c4afeb7
comparison
equal deleted inserted replaced
26138:b19a063a7a74 26139:97b4e8c55c1d
23 import re 23 import re
24 24
25 py33_type_error_pattern = re.compile('^__call__\(\) takes (\d+) positional argument but (\d+) were given$') 25 py33_type_error_pattern = re.compile('^__call__\(\) takes (\d+) positional argument but (\d+) were given$')
26 py37_exception_repr = re.compile(r'([^\(\),])(\)+)$') 26 py37_exception_repr = re.compile(r'([^\(\),])(\)+)$')
27 py39_type_error_pattern = re.compile('\w+\.([^(]+\(\) takes)') 27 py39_type_error_pattern = re.compile('\w+\.([^(]+\(\) takes)')
28 py310_type_error_pattern = re.compile('takes (\d+) positional argument but (\d+) were given')
28 29
29 def emsg(ei): 30 def emsg(ei):
30 return ei[0].__name__ + ':' + repr(ei[1].args) 31 return ei[0].__name__ + ':' + repr(ei[1].args)
31 32
32 def ee(expr, g=globals(), l=locals()): 33 def ee(expr, g=globals(), l=locals()):
58 oldmsg2 = '''"Can't convert 'int' object to str implicitly"''' 59 oldmsg2 = '''"Can't convert 'int' object to str implicitly"'''
59 if msg.find(newmsg2) > -1: 60 if msg.find(newmsg2) > -1:
60 msg = msg.replace(newmsg2, oldmsg2) 61 msg = msg.replace(newmsg2, oldmsg2)
61 # Python 3.9 reports errors like "vim.command() takes ..." instead of "command() takes ..." 62 # Python 3.9 reports errors like "vim.command() takes ..." instead of "command() takes ..."
62 msg = py39_type_error_pattern.sub(r'\1', msg) 63 msg = py39_type_error_pattern.sub(r'\1', msg)
64 msg = py310_type_error_pattern.sub(r'takes exactly \1 positional argument (\2 given)', msg)
63 elif sys.version_info >= (3, 5) and e.__class__ is ValueError and str(e) == 'embedded null byte': 65 elif sys.version_info >= (3, 5) and e.__class__ is ValueError and str(e) == 'embedded null byte':
64 msg = repr((TypeError, TypeError('expected bytes with no null'))) 66 msg = repr((TypeError, TypeError('expected bytes with no null')))
65 else: 67 else:
66 msg = repr((e.__class__, e)) 68 msg = repr((e.__class__, e))
67 # Some Python versions say can't, others cannot. 69 # Some Python versions say can't, others cannot.
2637 2639
2638 new 2640 new
2639 py3 cb = vim.current.buffer 2641 py3 cb = vim.current.buffer
2640 2642
2641 py3 << trim EOF 2643 py3 << trim EOF
2644 import os
2642 d = vim.Dictionary() 2645 d = vim.Dictionary()
2643 ned = vim.Dictionary(foo='bar', baz='abcD') 2646 ned = vim.Dictionary(foo='bar', baz='abcD')
2644 dl = vim.Dictionary(a=1) 2647 dl = vim.Dictionary(a=1)
2645 dl.locked = True 2648 dl.locked = True
2646 l = vim.List() 2649 l = vim.List()