Modify ↓
Opened 15 years ago
Last modified 11 years ago
#580 new defect
[PATCH] bitten master crashes when unittest's method includes a non-ASCII encoding docstring
Reported by: | Xie Yanbo <xieyanbo@…> | Owned by: | |
---|---|---|---|
Priority: | critical | Milestone: | 0.6.1 |
Component: | Build master | Version: | 0.6b2 |
Keywords: | Cc: | tony@… | |
Operating System: | Linux |
Description
If a testcase method includes an utf-8 encoding short description like this:
class Utf8DocstingTestCase(TestCase): def test_something(self): '''test utf-8 Chinese character, 测试汉字''' pass
Bitten will crash with:
Traceback (most recent call last): File "/usr/lib64/python2.5/site-packages/trac/web/main.py", line 450, in _disp atch_request dispatcher.dispatch(req) File "/usr/lib64/python2.5/site-packages/trac/web/main.py", line 206, in dispa tch resp = chosen_handler.process_request(req) File "/usr/lib64/python2.5/site-packages/bitten/master.py", line 130, in proce ss_request return self._process_build_step(req, config, build) File "/usr/lib64/python2.5/site-packages/bitten/master.py", line 324, in _proc ess_build_step report.insert(db=db) File "/usr/lib64/python2.5/site-packages/bitten/model.py", line 936, in insert in item.items()]) File "/usr/lib64/python2.5/site-packages/trac/db/util.py", line 80, in execute many return self.cursor.executemany(sql_escape_percent(sql), args) File "/usr/lib64/python2.5/site-packages/trac/db/sqlite_backend.py", line 64, in executemany args or []) File "/usr/lib64/python2.5/site-packages/trac/db/sqlite_backend.py", line 51, in _rollback_on_error return function(self, *args, **kwargs) ProgrammingError: You must not use 8-bit bytestrings unless you use a text_facto ry that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.
cause sqlite does not accept the utf8 string.
My environment:
- Bitten: 0.6b2
- Python: 2.5
- pysqlite: 2.5.6
- OS: Gentoo Linux
Patch attached.
Attachments (1)
Change History (5)
Changed 15 years ago by Xie Yanbo <xieyanbo@…>
comment:1 Changed 15 years ago by osimons
comment:2 Changed 15 years ago by Xie Yanbo <xieyanbo@…>
you are right, how about this:
-
bitten/master.py
diff -rNu Bitten-0.6b2.orig/bitten/master.py Bitten-0.6b2/bitten/master.py
old new 319 319 item = {'type': item_elem.name} 320 320 item.update(item_elem.attr) 321 321 for child_elem in item_elem.children(): 322 item[child_elem.name] = child_elem.gettext() 322 item[child_elem.name] = child_elem.gettext().decode('utf8') 323 323 report.items.append(item) 324 324 report.insert(db=db)
comment:3 Changed 15 years ago by osimons
Thanks, feels better. A unittest would also be really nice... :-)
comment:4 Changed 11 years ago by Tony Meyer <tony@…>
- Cc tony@… added
Note: See
TracTickets for help on using
tickets.
Thanks for report.
Seems very late to deal with different variations of string when building strings for SQL execute? I think a more correct approach would be to make sure Report.items don't get populated with anything but Unicode strings. That means converting as strings are received from input (ie. xml from slave). Which I kind of thought we did, but this must have slipped through somehow (although I have not verified it myself).