The Canon "maker notes" (Exiftool 9.58) reports as "focus distance upper"
- from pic.1 to pic.10 an incremental value from 0.13 mt to 3.83 mt
- pic.11 and pic.12 have 3.83 mt too
- pics from 13 to 23 have all 65.53 mt (but real focus, by pixel peeping, is 0.5 mt or less
)
Other landscape shots that i took (without any chdk use) have a "focus distance upper" of 65.53 mt and real focus to infinite.
I ran your script with MF mode and logging flagged. Attached the log file.