beets/beets
ThinkChaos b0caac871a fix: enable tracebacks for "user"/custom sqlite functions
A bit niche but I tried setting my bareasc prefix to an empty string,
and was getting an obtuse error. This should help make clearer what is
happening when queries fail.

The exception is not properly raised up the stack in the first place
because it happens across 2 FFI boundaries: the DB query
(Python -> SQLite), and the custom DB function (SQLite -> Python).
Thus Python cannot forwarded it back to itself through SQLite, and it's
treated as an "unraisable" exception.

We could override `sys.unraisablehook` to not print anything for the
original exception, and store it in a global for the outer Python
interpreter to fetch and raise properly, but that's pretty hacky,
limited to a single DB instance and query at once, and risks swallowing
other "unraisable" exceptions.
Instead we just tell the user to look above for what Python prints.

Sample output:
```
Exception ignored in: <function unidecode_expect_ascii at
0x7f7fa20bb060>
Traceback (most recent call last):
  File "site-packages/unidecode/__init__.py", line 60, in
unidecode_expect_ascii
    bytestring = string.encode('ASCII')
                 ^^^^^^^^^^^^^
AttributeError: 'bytes' object has no attribute 'encode'
Traceback (most recent call last):
  File "site-packages/beets/dbcore/db.py", line 988, in query
    cursor = self.db._connection().execute(statement, subvals)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: user-defined function raised exception

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages/beets/__main__.py", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "site-packages/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "site-packages/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "site-packages/beets/ui/commands.py", line 1599, in list_func
    list_items(lib, decargs(args), opts.album)
  File "site-packages/beets/ui/commands.py", line 1594, in list_items
    for item in lib.items(query):
                ^^^^^^^^^^^^^^^^
  File "site-packages/beets/library.py", line 1695, in items
    return self._fetch(Item, query, sort or
self.get_default_item_sort())

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/beets/library.py", line 1673, in _fetch
    return super()._fetch(model_cls, query, sort)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/beets/dbcore/db.py", line 1301, in _fetch
    rows = tx.query(sql, subvals)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/beets/dbcore/db.py", line 991, in query
    raise DBCustomFunctionError()
beets.dbcore.db.DBCustomFunctionError: beets defined SQLite function
failed; see the other errors above for details
```
2025-09-19 21:11:51 +01:00
..
autotag hooks: Sort Info classes parameters and attr assignments alphabetically 2025-09-07 21:08:42 +01:00
dbcore fix: enable tracebacks for "user"/custom sqlite functions 2025-09-19 21:11:51 +01:00
importer Delegate attribute access to logging 2025-08-30 23:10:21 +01:00
library Delegate attribute access to logging 2025-08-30 23:10:21 +01:00
test Do not use explicit indices for logging args when not needed 2025-08-30 23:10:21 +01:00
ui Define color regex patterns once 2025-09-13 11:24:57 +01:00
util Delegate attribute access to logging 2025-08-30 23:10:21 +01:00
__init__.py Increment version to 2.4.0 2025-09-13 16:47:21 +00:00
__main__.py Reformat the codebase 2024-09-21 11:57:48 +01:00
art.py Delegate attribute access to logging 2025-08-30 23:10:21 +01:00
config_default.yaml Fix diff coloring for added and removed text in field diffs 2025-09-13 11:24:55 +01:00
logging.py Remove some lint exclusions and fix the issues 2024-09-21 11:59:19 +01:00
mediafile.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
metadata_plugins.py fix incorrect matches when album is missing or empty 2025-09-19 17:20:51 +02:00
plugins.py Define MetadataSourcePlugin methods on the subclass only 2025-09-04 12:49:47 +01:00
py.typed Add py.typed marker file to support PEP 561 typing (#5906) 2025-08-09 13:31:55 +02:00
random.py Make a random change for testing 2024-05-07 16:28:28 +01:00
vfs.py Fix legalize_path types 2025-05-04 12:23:22 +01:00