Skip to content

Commit f411a3c

Browse files
committed
patch 8.0.0422: Python test fails with Python 3.6
Problem: Python test fails with Python 3.6. Solution: Convert new exception messages to old ones. (closes #1359)
1 parent f58a847 commit f411a3c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/testdir/test87.in

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,26 @@ def ee(expr, g=globals(), l=locals()):
230230
cb.append(expr + ':' + repr((e.__class__, AttributeError(str(e)[str(e).rfind(" '") + 2:-1]))))
231231
elif sys.version_info >= (3, 3) and e.__class__ is ImportError and str(e).find('No module named \'') >= 0:
232232
cb.append(expr + ':' + repr((e.__class__, ImportError(str(e).replace("'", '')))))
233+
elif sys.version_info >= (3, 6) and e.__class__ is ModuleNotFoundError:
234+
# Python 3.6 gives ModuleNotFoundError, change it to an ImportError
235+
cb.append(expr + ':' + repr((ImportError, ImportError(str(e).replace("'", '')))))
233236
elif sys.version_info >= (3, 3) and e.__class__ is TypeError:
234237
m = py33_type_error_pattern.search(str(e))
235238
if m:
236239
msg = '__call__() takes exactly {0} positional argument ({1} given)'.format(m.group(1), m.group(2))
237240
cb.append(expr + ':' + repr((e.__class__, TypeError(msg))))
238241
else:
239-
cb.append(expr + ':' + repr((e.__class__, e)))
242+
msg = repr((e.__class__, e))
243+
# Messages changed with Python 3.6, change new to old.
244+
newmsg1 = """'argument must be str, bytes or bytearray, not None'"""
245+
oldmsg1 = '''"Can't convert 'NoneType' object to str implicitly"'''
246+
if msg.find(newmsg1) > -1:
247+
msg = msg.replace(newmsg1, oldmsg1)
248+
newmsg2 = """'argument must be str, bytes or bytearray, not int'"""
249+
oldmsg2 = '''"Can't convert 'int' object to str implicitly"'''
250+
if msg.find(newmsg2) > -1:
251+
msg = msg.replace(newmsg2, oldmsg2)
252+
cb.append(expr + ':' + msg)
240253
elif sys.version_info >= (3, 5) and e.__class__ is ValueError and str(e) == 'embedded null byte':
241254
cb.append(expr + ':' + repr((TypeError, TypeError('expected bytes with no null'))))
242255
else:

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
422,
767769
/**/
768770
421,
769771
/**/

0 commit comments

Comments
 (0)