Ticket #2444 (closed defect: fixed)
TG 2.1a3 dispatcher mistakenly assumes all required positional parameters are provided
| Reported by: | mcfletch | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.1b1 |
| Component: | TurboGears | Version: | 2.1a3 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
At line 145 of dispatcher.py, the code makes the assumption that it can do remainder[i]. If the user provides 1 parameter positionally (i.e. as part of the URL) and the next via keyword argument, the handler raises an exception trying to assign remainder[i]... fix:
for i,var in enumerate(required_vars):
if i < len(remainder):
remainder[i] = params[var] del params[var]
that is, check for i< len(remainder) before attempting to assign to it.
Change History
comment:2 Changed 2 years ago by mcfletch
Sorry, didn't try tip, am in the middle of porting a project for PyCon? and was just wanting to make sure this didn't get lost in the meantime. If it's already fixed, please feel free to close this.
comment:3 Changed 2 years ago by mcfletch
There was still a bug in tip for the handling of positional parameters with defaults. Pull http://bitbucket.org/mcfletch/tg-dev/ to get the fix, test, etc.
did you try tip?
I just fixed this mess.