Mercurial > p > roundup > code
comparison roundup/cgi/client.py @ 4799:b474adb17fda
Fix case where querying form returns a TypeError
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Mon, 08 Jul 2013 09:57:39 +0200 |
| parents | 6e9b9743de89 |
| children | 3961b2b91568 |
comparison
equal
deleted
inserted
replaced
| 4798:f25a3bf59c2d | 4799:b474adb17fda |
|---|---|
| 599 If the charset is found, and differs from the storage charset, | 599 If the charset is found, and differs from the storage charset, |
| 600 recode all form fields of type 'text/plain' | 600 recode all form fields of type 'text/plain' |
| 601 """ | 601 """ |
| 602 # look for client charset | 602 # look for client charset |
| 603 charset_parameter = 0 | 603 charset_parameter = 0 |
| 604 if '@charset' in self.form: | 604 # Python 2.6 form may raise a TypeError if list in form is None |
| 605 charset = None | |
| 606 try : | |
| 605 charset = self.form['@charset'].value | 607 charset = self.form['@charset'].value |
| 606 if charset.lower() == "none": | 608 if charset.lower() == "none": |
| 607 charset = "" | 609 charset = "" |
| 608 charset_parameter = 1 | 610 charset_parameter = 1 |
| 609 elif 'roundup_charset' in self.cookie: | 611 except (KeyError, TypeError): |
| 612 pass | |
| 613 if charset is None and 'roundup_charset' in self.cookie: | |
| 610 charset = self.cookie['roundup_charset'].value | 614 charset = self.cookie['roundup_charset'].value |
| 611 else: | |
| 612 charset = None | |
| 613 if charset: | 615 if charset: |
| 614 # make sure the charset is recognized | 616 # make sure the charset is recognized |
| 615 try: | 617 try: |
| 616 codecs.lookup(charset) | 618 codecs.lookup(charset) |
| 617 except LookupError: | 619 except LookupError: |
