Whole file
kellyjonbrazil/jello
The author described this change as “move hasattr __self__ check inside pyquery() and raise a ValueError instead of sys.exit() in main()”. It counts as a record because the check below fails on the code as it stood at 16bc7b1b1 and passes on 300f67690, with nothing else changed between the two runs.
Projectkellyjonbrazil/jello
Fix saved2021-06-10
Sharing licenceMIT · LICENSE
Change size+5 −9
What the code was meant to do, written into the code itself as a save note
move hasattr __self__ check inside pyquery() and raise a ValueError instead of sys.exit() in main()
The change
| 409 | 409 | elif isinstance(output, DotMap): | |
| 410 | 410 | output = output.toDict() | |
| 411 | 411 | ||
| 412 | + | # if DotMap returns a bound function then we know it was a reserved attribute name | |
| 413 | + | if hasattr(output, '__self__'): | |
| 414 | + | raise ValueError('A reserved key name with dotted notation was used in the query. Please use python bracket dict notation to access this key.') | |
| 415 | + | ||
| 412 | 416 | return output | |
| 413 | 417 | ||
| 414 | 418 | ||
| ⋯ | |||
| 541 | 545 | except Exception as e: | |
| 542 | 546 | query = query.replace('\n', '; ') | |
| 543 | 547 | ||
| 548 | + | err_data = '' | |
| 544 | 549 | if len(str(list_dict_data)) > 70: | |
| 545 | 550 | err_data = str(list_dict_data)[0:35] + ' ... ' + str(list_dict_data)[-35:-1] | |
| 546 | 551 | ||
| ⋯ | |||
| 555 | 560 | query: {query} | |
| 556 | 561 | data: {err_data} | |
| 557 | 562 | response: {response} | |
| 558 | - | ''')) | |
| 559 | - | ||
| 560 | - | # if DotMap returns a bound function then we know it was a reserved attribute name | |
| 561 | - | if hasattr(response, '__self__'): | |
| 562 | - | print_error(textwrap.dedent(f'''\ | |
| 563 | - | jello: A reserved key name with dotted notation was used in the query. | |
| 564 | - | Please use python bracket dict notation to access this key. | |
| 565 | - | ||
| 566 | - | query: {query} | |
| 567 | 563 | ''')) | |
| 568 | 564 | ||
| 569 | 565 | set_env_colors() | |
The check that tells the two apart
fail→pass·tests/test_pyquery.py::MyTests::test_ValueError
Check file tests/test_pyquery.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it16bc7b1b1e82bcd25e51e99300b61f797f6579c0
Broken version dated2021-06-10
Modulejello.cli
Units changedmain, pyquery
Fingerprintd9fea647e621ad12
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.