Pythoscope doesn't handle unicode objects well

Bug #284585 reported by Michal Kwiatkowski on 2008-10-16
2
Affects Status Importance Assigned to Milestone
Pythoscope
High
Michal Kwiatkowski

Bug Description

Minimal example is to have a module with a function that returns a unicode object:

# module.py
def fun():
    return unicode('\xc3\xb3', 'utf-8')

After running a point of entry that called fun() Pythoscope will exit with the following error message:

...
INFO: Generating tests for module module.py.
ERROR: Oops, it seems internal Pythoscope error occured. Please file a bug report at https://bugs.launchpad.net/pythoscope

Traceback (most recent call last):
  File "/usr/bin/pythoscope", line 8, in <module>
    load_entry_point('pythoscope==0.3.2dev', 'console_scripts', 'pythoscope')()
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/__init__.py", line 176, in main
    generate_tests(args, force, template)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/__init__.py", line 105, in generate_tests
    add_tests_to_project(project, modules, template, force)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/generator.py", line 629, in add_tests_to_project
    generator.add_tests_to_project(project, modnames, force)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/generator.py", line 394, in add_tests_to_project
    self._add_tests_for_module(module, project, force)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/generator.py", line 426, in _add_tests_for_module
    for test_case in self._generate_test_cases(module):
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/generator.py", line 431, in _generate_test_cases
    test_case = self._generate_test_case(object, module)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/generator.py", line 437, in _generate_test_case
    method_descriptions = sorted_test_method_descriptions(self._generate_test_method_descriptions(object, module))
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/generator.py", line 295, in sorted_test_method_descriptions
    return sorted(descriptions, key=lambda md: md.name)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/generator.py", line 496, in _method_descriptions_from_function
    name = call2testname(call, function.name)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/generator.py", line 292, in call2testname
    return objcall2testname(object_name, call.input, call.output)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/generator.py", line 249, in objcall2testname
    call_description = object2id(output)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/generator.py", line 193, in object2id
    return string2id(str(object.value))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in position 0: ordinal not in range(128)

Related branches

Changed in pythoscope:
assignee: nobody → ruby
importance: Undecided → High
milestone: none → 0.3.2-more-dynamic-analysis-fixes
status: New → Confirmed
Michal Kwiatkowski (ruby) wrote :

Fixed in trunk r229.

Changed in pythoscope:
status: Confirmed → Fix Committed
Changed in pythoscope:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers