Whole file

kellyjonbrazil/jc

The author described this change as Fix broken controller regexp scheme in the bluetoothctl parser (#599). It counts as a record because the check below fails on the code as it stood at 78150ded7 and passes on c5e0642b0, with nothing else changed between the two runs.

Fix saved2024-10-18
Sharing licenceMIT · LICENSE.md
Change size+14 2

What the code was meant to do, written into the code itself as a save note

Fix broken controller regexp scheme in the bluetoothctl parser (#599)

The change

2828 Controller:
2929 [
3030 {
31+ "manufacturer": string,
32+ "version": string,
3133 "name": string,
3234 "is_default": boolean,
3335 "is_public": boolean,
127129 Controller = TypedDict(
128130 "Controller",
129131 {
132+ "manufacturer": str,
133+ "version": str,
130134 "name": str,
131135 "is_default": bool,
132136 "is_public": bool,
175179 _controller_head_pattern = r"Controller (?P<address>([0-9A-F]{2}:){5}[0-9A-F]{2}) (?P<name>.+)"
176180
177181 _controller_line_pattern = (
178- r"(\s*Name:\s*(?P<name>.+)"
182+ r"(\s*Manufacturer:\s*(?P<manufacturer>.+)"
183+ + r"|\s*Version:\s*(?P<version>.+)"
184+ + r"|\s*Name:\s*(?P<name>.+)"
179185 + r"|\s*Alias:\s*(?P<alias>.+)"
180186 + r"|\s*Class:\s*(?P<class>.+)"
181187 + r"|\s*Powered:\s*(?P<powered>.+)"
203209 return None
204210
205211 controller: Controller = {
212+ "manufacturer": '',
213+ "version": '',
206214 "name": '',
207215 "is_default": False,
208216 "is_public": False,
241249
242250 matches = result.groupdict()
243251
244- if matches["name"]:
252+ if matches["manufacturer"]:
253+ controller["manufacturer"] = matches["manufacturer"]
254+ elif matches["version"]:
255+ controller["version"] = matches["version"]
256+ elif matches["name"]:
245257 controller["name"] = matches["name"]
246258 elif matches["alias"]:
247259 controller["alias"] = matches["alias"]

The check that tells the two apart

failpass·tests/test_bluetoothctl.py::BluetoothctlTests::test_bluetoothctl_controller_with_manufacturer

Check file tests/test_bluetoothctl.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 it78150ded70d1068fc0f5a138e8704c57df7c97f9
Broken version dated2024-10-17
Modulejc.parsers.bluetoothctl
Units changed_parse_controller
Fingerprint036dfc0fa9bb5924
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in kellyjonbrazil/jc