Whole file
robotframework/robotframework
The author described this change as “Fix precision issues with listener priority”. It counts as a record because the checks below fail on the code as it stood at 6ca3aae8d and pass on b6f50b2b5, with nothing else changed between the two runs.
Fix saved2026-03-19
Sharing licenceApache-2.0 · LICENSE.txt
Change size+8 −3
What the code was meant to do, written into the code itself as a save note
Fix precision issues with listener priority
The change
| 26 | 26 | ||
| 27 | 27 | from .logger import LOGGER | |
| 28 | 28 | from .loggerapi import LoggerApi | |
| 29 | - | from .loglevel import LogLevel | |
| 29 | + | from .loglevel import LogLevel, SettableLevel | |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | 32 | class Listeners: | |
| ⋯ | |||
| 35 | 35 | def __init__( | |
| 36 | 36 | self, | |
| 37 | 37 | listeners: Iterable["str|Any"] = (), | |
| 38 | - | log_level: "LogLevel|str" = "INFO", | |
| 38 | + | log_level: "LogLevel|SettableLevel" = "INFO", | |
| 39 | 39 | ): | |
| 40 | 40 | if isinstance(log_level, str): | |
| 41 | 41 | log_level = LogLevel(log_level) | |
| ⋯ | |||
| 137 | 137 | ||
| 138 | 138 | def _get_priority(self, listener): | |
| 139 | 139 | priority = getattr(listener, "ROBOT_LISTENER_PRIORITY", 0) | |
| 140 | + | if isinstance(priority, (int, float)): | |
| 141 | + | return priority | |
| 140 | 142 | try: | |
| 141 | - | return float(priority) | |
| 143 | + | try: | |
| 144 | + | return int(priority) | |
| 145 | + | except ValueError: | |
| 146 | + | return float(priority) | |
| 142 | 147 | except (ValueError, TypeError): | |
| 143 | 148 | raise DataError(f"Invalid listener priority '{priority}'.") | |
| 144 | 149 | ||
The check that tells the two apart
fail→pass·utest/output/test_listeners.py::TestListenerPriority::test_huge_priority
fail→pass·utest/output/test_listeners.py::TestListenerPriority::test_no_priority
fail→pass·utest/output/test_listeners.py::TestListenerPriority::test_priority
Check file utest/output/test_listeners.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 it6ca3aae8d8ee49e52cc16b31de63243ea4a59ae2
Broken version dated2026-03-17
Modulerobot.output.listeners
Units changedListenerFacade, Listeners
Fingerprint176560798c094877
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.