Pythoscope doesn't handle unicode objects well

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

Bug Description

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

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
ERROR: Oops, it seems internal Pythoscope error occured. Please file a bug report at

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/", line 176, in main
    generate_tests(args, force, template)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/", line 105, in generate_tests
    add_tests_to_project(project, modules, template, force)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/", line 629, in add_tests_to_project
    generator.add_tests_to_project(project, modnames, force)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/", line 394, in add_tests_to_project
    self._add_tests_for_module(module, project, force)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/", line 426, in _add_tests_for_module
    for test_case in self._generate_test_cases(module):
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/", line 431, in _generate_test_cases
    test_case = self._generate_test_case(object, module)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/", 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/", line 295, in sorted_test_method_descriptions
    return sorted(descriptions, key=lambda md:
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/", line 496, in _method_descriptions_from_function
    name = call2testname(call,
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/", line 292, in call2testname
    return objcall2testname(object_name, call.input, call.output)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/", line 249, in objcall2testname
    call_description = object2id(output)
  File "/home/ruby/projects/development/pythoscope/trunk/pythoscope/", 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