coverage failing on python 3.2.5 (using

Issue #407 invalid
Former user created an issue

I have seen this on multiple python repos with automated testing using coverage.

  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/coverage/", line 80
    dest.write(u'  ')
SyntaxError: invalid syntax

Comments (16)

  1. SylvainDe

    Out of curiosity, is there any reason for not supporting this particular Python version? Also, is there any way to ensure that pip only install 3.7.1 on Python 3.2 ?

  2. Ned Batchelder repo owner

    Python 3.2 doesn't support u"" strings, which makes it difficult to get Unicode right across a wide span of versions. You can pip install 3.7.1 by pinning that version number in your requirements.

  3. Tai Lee

    Just got hit by this, too. Why not just from future import str and use python_2_unicode_compatible class decorator, instead of using unsightly u'' style strings and breaking 3.2 compatibility?

  4. mansourmoufid

    I came across this error too, on Travis CI. I'll just leave a note for anyone else searching.

    If you need both the coverage package (or pytest-cov) and the system_site_packages configuration on Travis CI, add the line coverage==3.7.1 to your requirements.txt file, as @ned and @hugovk mention above.

    The reason being that the coverage package uses the function PyUnicode_AsUTF8, which is new in Python version 3.3. However, Travis CI only supports the --system-site-packages option of virtualenv for Python up to version 3.2.

  5. Ned Batchelder repo owner

    @mrmachine importing unicode_literals doesn't fix everything: it makes it impossible to produce native strings (str on both py2 and py3). python_2_unicode_compatible is a Django decorator. Pinning to version 3.7.1 will let you keep using Python 3.2.

  6. hugovk

    Tip: for Travis CI with multiple Python versions, one way is for your .travis.yml to look something like this:

      # Coverage 4.0 doesn't support Python 3.2
      - if [ "$TRAVIS_PYTHON_VERSION" == "3.2" ]; then travis_retry pip install coverage==3.7.1; fi
      - if [ "$TRAVIS_PYTHON_VERSION" != "3.2" ]; then travis_retry pip install coverage; fi
  7. Shay Palachy

    @hugovk Your tip on how to get different coverage version for Python 3.2 is still helping people in 2017. Thanks, man!

  8. hugovk

    @shayTennisHead78 Happy to help!

    Here's a slight improvement for .travis.yml, on the off-chance there'll be another Coverage 3.x bugfix release that also supports Python 3.2:

    # Coverage 4.0 doesn't support Python 3.2
    - if [ "$TRAVIS_PYTHON_VERSION" == "3.2" ]; then pip install "coverage<4"; fi
    - if [ "$TRAVIS_PYTHON_VERSION" != "3.2" ]; then pip install coverage; fi
  9. Log in to comment