I don't think that lambda expression did quite what you would normally expect it to do in Python 2, either.
Lambda expressions do not take parentheses around their argument list. The normal way to write it would be lambda k, val: ...
. Python 2 will, however, parse your lambda expression as a function of one argument, which argument it will do tuple unpacking on:
>>> a = lambda(a, b): a + b
>>> a(1, 2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: <lambda>() takes exactly 1 argument (2 given)
>>> a((1, 2))
3
However, tuple argument unpacking was abolished in Python 3, which is why you get a syntax error on that declaration. You'll either have to remove the parentheses and convert the call sites to call the function with two arguments, or use explicit unpacking in the lambda expression itself, kind of like this:
lambda tup: (tup[0], re.sub(..., ..., tup[1]))