rebane2001/matterport-dl

[Bug]: f-string syntax error

Closed this issue · 4 comments

One or more sample matterport IDs / urls that reproduce the issue

Any

Python version

3.12.6

Steps to reproduce

I'm getting syntax errors with the double quotes in f-strings. Currently Lines 481 and 742.

What went wrong

I'm getting syntax errors in the lines with nested double-quotes within an f-string, which causes the f-string to break.

Workarounds

Line 481

Original
plugPath = f"showcase-sdk/plugins/published/{plugin["name"]}/{plugin["currentVersion"]}/plugin.json"

Fix
plugPath = f"showcase-sdk/plugins/published/{plugin['name']}/{plugin['currentVersion']}/plugin.json"

Line 742

Original
mainMsgLog(f"AdvancedDownload photos: {len(base_node_snapshots["assets"]["photos"])} meshes: {len(base_node["assets"]["meshes"])}, locations: {len(base_node["locations"])}, tileset indexes: {len(base_node["assets"]["tilesets"])}, textures: {len(base_node["assets"]["textures"])}, ")

Fix
mainMsgLog(f"AdvancedDownload photos: {len(base_node_snapshots['assets']['photos'])} meshes: {len(base_node['assets']['meshes'])} locations: {len(base_node['locations'])} tileset indexes: {len(base_node['assets']['tilesets'])} textures: {len(base_node['assets']['textures'])}, ")

These small changes from double to single quotes fixed it for me.

Can you post the exact error? please run this python script:

import platform

dic = {"a":"b"}
print(f"Hi {dic["a"]} is b on python {platform.python_version()}")

technically I am on an older python version and it works for me.

line 475
plugPath = f"showcase-sdk/plugins/published/{plugin["name"]}/{plugin["currentVersion"]}/plugin.json"
___________________________________________________________^^^^
SyntaxError: f-string: unmatched '['

The above was the first traceback error, and when I changed this line to single quotes, then the next line would traceback.

Here is the output from your python script:

Hi b is b on python 3.12.6

so odd, the python script uses the same f string format so I don't get why yours gives the error there.

Just to confirm you are running the script with python matterport-dl.py right and not ./matterport-dl.py, as your system may have .py bound to a different version than the python command (shouldn't but ...)?

Here is the official release notes talking about double quotes allowed in f strings since 3.12. https://docs.python.org/3.13/whatsnew/3.12.html#whatsnew312-pep701

If you pull the newer matterport-dl.py it should give a start string like Started up a download run Running python 3.12.4 on win32 with matterport-dl version: refs/heads/china_server_support_v2 (5a23fa7b453fe31cdd10c03cbda3fa407391f011)
the log file should also now low the entire exception when it happens (run_report.log)

Thanks Mitchcapper. There must have been a weird update glitch in my python installation. After trying and erroring repeatedly. I fully uninstalled and reinstalled python 3.12, and I'm happy to say that I am no longer getting that f-string error.