Whole file

sanic-org/sanic-routing

The author described this change as Fix routing with multiple routes contain 'path' params (#49). It counts as a record because the check below fails on the code as it stood at 0c6c860ef and passes on 4df3d82b4, with nothing else changed between the two runs.

Fix saved2021-11-04
Sharing licenceMIT · LICENSE
Change size+3 1

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

Fix routing with multiple routes contain 'path' params (#49)

The change

423423 "regex_routes" if group.regex else "dynamic_routes"
424424 )
425425 route_idx: t.Union[str, int] = 0
426+ holder: t.List[Line] = []
426427
427428 if len(group.routes) > 1:
428429 route_idx = "route_idx"
429- Node._inject_method_check(src, 1, group)
430+ Node._inject_method_check(holder, 2, group)
430431
431432 src.extend(
432433 [
438439 1,
439440 ),
440441 Line("if match:", 1),
442+ *holder,
441443 Line("basket['__params__'] = match.groupdict()", 2),
442444 Line(
443445 (

The check that tells the two apart

failpass·tests/test_routing.py::test_identical_path_routes_with_different_methods_similar_urls[a-random-path]

Check file tests/test_routing.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 it0c6c860ef8507f77eba7d039fbc713ab2a7f0e56
Broken version dated2021-07-01
Modulesanic_routing.router
Units changedBaseRouter
Fingerprinte21d218202558db5
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 sanic-org/sanic-routing