pycdc icon indicating copy to clipboard operation
pycdc copied to clipboard

3.8+ fstring "=" format specifier not detected

Open rocky opened this issue 3 years ago • 0 comments

Python 3.8 adds "=" to its format specifiers. See https://docs.python.org/3/whatsnew/3.8.html#f-strings-support-for-self-documenting-expressions-and-debugging

Here is an example program that can be used for testing:

# Tests new "debug" format new in 3.8.
# RUNNABLE!

"""This program is self-checking!"""
f'{f"{3.1415=:.1f}":*^20}' == '*****3.1415=3.1*****'

# This SEGV's in pycdc
y = 2
def f(x, width):
    return f'x={x*y:{width}}'

assert f('foo', 10) ==  'x=foofoo    '

x = 'bar'
assert f(10, 10), 'x=        20'

rocky avatar Jul 05 '22 12:07 rocky