Bug 1204940 - coverage annotate chokes on non-ascii
Summary: coverage annotate chokes on non-ascii
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-coverage
Version: 22
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Tom "spot" Callaway
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-23 20:00 UTC by Cole Robinson
Modified: 2015-07-14 08:38 UTC (History)
5 users (show)

Fixed In Version: python-coverage-4.0-0.6.a5.fc22
Clone Of:
Environment:
Last Closed: 2015-04-21 18:41:15 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
test code (47 bytes, text/plain)
2015-03-25 13:21 UTC, Cole Robinson
no flags Details

Description Cole Robinson 2015-03-23 20:00:10 UTC
$ rpm -q python-coverage
python-coverage-4.0-0.3.a3.fc22.x86_64

$ coverage annotate -d covdir
Traceback (most recent call last):
  File "/usr/bin/coverage", line 9, in <module>
    load_entry_point('coverage==4.0a3', 'console_scripts', 'coverage')()
  File "/usr/lib64/python2.7/site-packages/coverage/cmdline.py", line 669, in main
    status = CoverageScript().command_line(argv)
  File "/usr/lib64/python2.7/site-packages/coverage/cmdline.py", line 445, in command_line
    directory=options.directory, **report_args)
  File "/usr/lib64/python2.7/site-packages/coverage/control.py", line 875, in annotate
    reporter.report(morfs, directory=directory)
  File "/usr/lib64/python2.7/site-packages/coverage/annotate.py", line 42, in report
    self.report_files(self.annotate_file, morfs, directory)
  File "/usr/lib64/python2.7/site-packages/coverage/report.py", line 80, in report_files
    report_fn(cu, self.coverage._analyze(cu))
  File "/usr/lib64/python2.7/site-packages/coverage/annotate.py", line 92, in annotate_file
    dest.write(line)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 11: ordinal not in range(128)

This is with virt-manager.git, after running "python setup.py test --coverage". Editing all the virt-manager source files to remove non-ascii text and re-running "coverage annotate" fixes things, but that shouldn't be necessary.

Comment 1 Tom "spot" Callaway 2015-03-25 12:54:27 UTC
Can you test a5:

http://koji.fedoraproject.org/koji/buildinfo?buildID=612239

Comment 2 Cole Robinson 2015-03-25 13:09:55 UTC
Same issue with a5, slightly different line numbers:

Traceback (most recent call last):
  File "/usr/bin/coverage", line 9, in <module>
    load_entry_point('coverage==4.0a5', 'console_scripts', 'coverage')()
  File "/usr/lib64/python2.7/site-packages/coverage/cmdline.py", line 676, in main
    status = CoverageScript().command_line(argv)
  File "/usr/lib64/python2.7/site-packages/coverage/cmdline.py", line 451, in command_line
    directory=options.directory, **report_args)
  File "/usr/lib64/python2.7/site-packages/coverage/control.py", line 924, in annotate
    reporter.report(morfs, directory=directory)
  File "/usr/lib64/python2.7/site-packages/coverage/annotate.py", line 42, in report
    self.report_files(self.annotate_file, morfs, directory)
  File "/usr/lib64/python2.7/site-packages/coverage/report.py", line 80, in report_files
    report_fn(cu, self.coverage._analyze(cu))
  File "/usr/lib64/python2.7/site-packages/coverage/annotate.py", line 92, in annotate_file
    dest.write(line)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 11: ordinal not in range(128)

Comment 3 Cole Robinson 2015-03-25 13:21:09 UTC
Created attachment 1006329 [details]
test code

$ coverage run test.py
foobar

$ coverage annotate -d covdir
Traceback (most recent call last):
  File "/usr/bin/coverage", line 9, in <module>
    load_entry_point('coverage==4.0a5', 'console_scripts', 'coverage')()
  File "/usr/lib64/python2.7/site-packages/coverage/cmdline.py", line 676, in main
    status = CoverageScript().command_line(argv)
  File "/usr/lib64/python2.7/site-packages/coverage/cmdline.py", line 451, in command_line
    directory=options.directory, **report_args)
  File "/usr/lib64/python2.7/site-packages/coverage/control.py", line 924, in annotate
    reporter.report(morfs, directory=directory)
  File "/usr/lib64/python2.7/site-packages/coverage/annotate.py", line 42, in report
    self.report_files(self.annotate_file, morfs, directory)
  File "/usr/lib64/python2.7/site-packages/coverage/report.py", line 80, in report_files
    report_fn(cu, self.coverage._analyze(cu))
  File "/usr/lib64/python2.7/site-packages/coverage/annotate.py", line 92, in annotate_file
    dest.write(line)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 2: ordinal not in range(128)

Comment 4 Fedora Update System 2015-03-31 14:43:45 UTC
python-coverage-4.0-0.5.a5.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/python-coverage-4.0-0.5.a5.fc22

Comment 5 Fedora Update System 2015-04-02 01:43:37 UTC
Package python-coverage-4.0-0.5.a5.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing python-coverage-4.0-0.5.a5.fc22'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-5330/python-coverage-4.0-0.5.a5.fc22
then log in and leave karma (feedback).

Comment 6 Fedora Update System 2015-04-06 13:30:22 UTC
python-coverage-4.0-0.6.a5.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/python-coverage-4.0-0.6.a5.fc22

Comment 7 lnie 2015-04-07 05:53:24 UTC
python-coverage-4.0-0.6.a5.fc22 works

Comment 8 Fedora Update System 2015-04-21 18:41:15 UTC
python-coverage-4.0-0.6.a5.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Vjacheslav Fyodorov 2015-07-14 08:38:27 UTC
This update breaks python3-coverage package:

Please fix or update last line in annotate.py to dest.write(line)

$ uname -a
Linux localhost.localdomain 4.0.6-300.fc22.x86_64 #1 SMP Tue Jun 23 13:58:53 UTC
 2015 x86_64 x86_64 x86_64 GNU/Linux                                           

$ python3 -V
Python 3.4.2

$ dnf info python3-coverage
Last metadata expiration check performed 1:54:12 ago on Mon Jul 13 11:44:10 2015.
Installed Packages
Name        : python3-coverage
Arch        : x86_64
Epoch       : 0
Version     : 4.0
Release     : 0.6.a5.fc22
Size        : 708 k
Repo        : @System
From repo   : fedora
Summary     : Code coverage testing module for Python 3
URL         : http://nedbatchelder.com/code/modules/coverage.html
License     : BSD and (MIT or GPLv2)
Description : Coverage.py is a Python 3 module that measures code coverage
            : during Python execution. It uses the code analysis tools and
            : tracing hooks provided in the Python standard library to determine
            : which lines are executable, and which have been executed.

$ coverage3 help
Coverage.py, version 4.0a5
Measure, collect, and report on code coverage in Python programs.

usage: coverage <command> [options] [args]

Commands:
    annotate    Annotate source files with execution information.
    combine     Combine a number of data files.
    erase       Erase previously collected coverage data.
    help        Get help on using coverage.py.
    html        Create an HTML report.
    report      Report coverage stats on modules.
    run         Run a Python program and measure code execution.
    xml         Create an XML report of coverage results.

Use "coverage help <command>" for detailed help on any command.
For full documentation, see https://coverage.readthedocs.org/en/coverage-4.0a5

$ cat tmp.py
print ('Hello World!')

$ coverage3 run tmp.py
Hello World!

$ coverage3 report
Name     Stmts   Miss  Cover
----------------------------
tmp.py       1      0   100%

$ coverage3 annotate
Traceback (most recent call last):
  File "/usr/bin/coverage3", line 9, in <module>
    load_entry_point('coverage==4.0a5', 'console_scripts', 'coverage')()
  File "/usr/lib64/python3.4/site-packages/coverage/cmdline.py", line 676, in ma
in                                                                             
    status = CoverageScript().command_line(argv)
  File "/usr/lib64/python3.4/site-packages/coverage/cmdline.py", line 451, in co
mmand_line                                                                     
    directory=options.directory, **report_args)
  File "/usr/lib64/python3.4/site-packages/coverage/control.py", line 924, in an
notate                                                                         
    reporter.report(morfs, directory=directory)
  File "/usr/lib64/python3.4/site-packages/coverage/annotate.py", line 42, in re
port                                                                           
    self.report_files(self.annotate_file, morfs, directory)
  File "/usr/lib64/python3.4/site-packages/coverage/report.py", line 80, in repo
rt_files                                                                       
    report_fn(cu, self.coverage._analyze(cu))
  File "/usr/lib64/python3.4/site-packages/coverage/annotate.py", line 92, in an
notate_file                                                                    
    dest.write(line.encode('utf-8'))
TypeError: must be str, not bytes

$


Note You need to log in before you can comment on or make changes to this bug.