Skip to content

Logpoint with F-string format specifier :.2f causes "invalid decimal literal" error #1933

@Acamal1

Description

@Acamal1

Type: Bug

When attempting to use an f-string format specifier like :.2f within a VS Code Python Logpoint, the debugger throws an "invalid decimal literal" error. The logpoint itself does not output the expected formatted string.

=> Log Message : After period {i+1}: Balance = {balance:.2f}

compound_interest.py

def calculate_compound_interest(principal, annual_rate, years, compound_frequency):
balance = principal
rate_per_period = annual_rate / compound_frequency
total_periods = years * compound_frequency

for i in range(total_periods):
    interest = balance * rate_per_period
    balance += interest
    # Breakpoint/Logpoint set on this line
return balance

if name == "main":
initial_principal = 1000
annual_interest_rate = 0.05 # 5%
investment_years = 3
compounding_frequency = 4 # Quarterly

final_amount = calculate_compound_interest(
    initial_principal,
    annual_interest_rate,
    investment_years,
    compounding_frequency
)

print(f"Final balance: ${final_amount:.2f}")

Expected Behavior:

The "DEBUG CONSOLE" should display messages for each iteration of the loop, showing the balance formatted to two decimal places, e.g.:

After period 1: Balance = 1012.50
After period 2: Balance = 1025.16
...
Actual Behavior:

The "DEBUG CONSOLE" outputs the error "invalid decimal literal" for each iteration, with a (xN) indicator (x12)), instead of the formatted log message.

Workaround :

The issue can be bypassed by pre-formatting the variable into a string within the Python code before the logpoint:

Python

    for i in range(total_periods):
        interest = balance * rate_per_period
        balance += interest
        formatted_bal_str = f"{balance:.2f}" # Added this line
        # Logpoint now points here:

And then setting the Logpoint as: After period {i+1}: Balance = ${formatted_bal_str}. This workaround functions as expected, confirming the issue is specific to the debugger's evaluation of the format specifier within the logpoint string itself.

VS Code version: Code 1.102.1 (7adae6a56e34cb64d08899664b814cf620465925, 2025-07-15T16:41:17.147Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2808)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.82GB (3.59GB free)
Process Argv --crash-reporter-id c5feca41-0464-404f-b46a-ab3126b07fc6
Screen Reader no
VM 0%
Extensions (6)
Extension Author (truncated) Version
prettier-vscode esb 11.0.0
copilot Git 1.344.0
copilot-chat Git 0.29.1
rainbow-csv mec 3.20.0
debugpy ms- 2025.10.0
python ms- 2025.10.0
A/B Experiments
vsliv368:30146709
binariesv615:30325510
962ge761:31350689
h48ei257:31000450
nativeloc1:31344060
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
hdaa2157:31222309
copilot_t_ci:31333650
e5gg6876:31282496
pythoneinst12:31285622
c7cif404:31314491
pythonpulldiag:31343502
996jf627:31283433
pythonrdcb7:31342333
usemplatestapi:31297334
0aa6g176:31307128
jjjhb125:31275178
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
pylancequickfixf:31350060
9d2cg352:31346308
convertlamdaf:31350062
usemarketplace:31343026
nesew2to5:31336538
agentclaude:31350858
nes-diff-11:31337487
replacestringexc:31350595
nes-set-on:31350020
6abeh943:31336334
yijiwantestdri0626-t:31336930
0927b901:31350571
ji9b5146:31348712
0cj2b977:31350606
cab2h891-first:31350623

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions