Opened 3 years ago

Closed 3 years ago

#25416 closed defect (fixed)

src/sage/plot/ UnicodeDecodeError in doctesting framework

Reported by: slabbe Owned by:
Priority: major Milestone: sage-8.3
Component: doctest framework Keywords:
Cc: Merged in:
Authors: Sébastien Labbé Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 367373c (Commits, GitHub, GitLab) Commit: 367373c003905fc0da9a313c099ce1f8c7a3eea5
Dependencies: Stopgaps:

Status badges


With 8.3.beta2

sage -t --optional=sage,imagemagick src/sage/plot/ 


Running doctests with ID 2018-05-21-13-12-48-d70ec4f6.
Git branch: develop
Using --optional=imagemagick,sage
Doctesting 1 file.
sage -t --warn-long 82.7 src/sage/plot/
    UnicodeDecodeError in doctesting framework
Tests run before doctest exception:
sage: sines = [plot(c*sin(x), (-2*pi,2*pi), color=Color(c,0,0), ymin=-1, ymax=1) for c in sxrange(0,1,.2)] ## line 32 ##
sage: a = animate(sines) ## line 33 ##
sage: a         # optional -- ImageMagick ## line 34 ##
Animation with 5 frames
sage:  # optional -- ImageMagick ## line 36 ##
sage: f = tmp_filename(ext='.gif') ## line 40 ##


sage: a = animate([sin(x + float(k)) for k in srange(0,2*pi,0.7)],
            xmin=0, xmax=2*pi, ymin=-1, ymax=1, figsize=[2,1]) ## line 559 ##
sage: td = tmp_dir() ## line 561 ##
sage: a.gif(savefile=td + 'my_animation.gif', delay=35, iterations=3)  # optional -- ImageMagick ## line 563 ##
sage: with open(td + 'my_animation.gif', 'rb') as f: print('\x21\xf9\x04\x08\x23\x00') in  # optional -- ImageMagick ## line 564 ##

Traceback (most recent call last):
  File "/home/slabbe/GitBox/sage/local/lib/python2.7/site-packages/sage/doctest/", line 2337, in __call__
    doctests, extras = self._run(runner, options, results)
  File "/home/slabbe/GitBox/sage/local/lib/python2.7/site-packages/sage/doctest/", line 2384, in _run
    result =
  File "/home/slabbe/GitBox/sage/local/lib/python2.7/site-packages/sage/doctest/", line 746, in run
    return self._run(test, compileflags, out)
  File "/home/slabbe/GitBox/sage/local/lib/python2.7/site-packages/sage/doctest/", line 581, in _run
    got = got.decode('utf-8')
  File "/home/slabbe/GitBox/sage/local/lib/python2.7/encodings/", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf9 in position 1: invalid start byte

sage -t --warn-long 82.7 src/sage/plot/  # UnicodeDecodeError in doctesting framework
Total time for all tests: 59.2 seconds
    cpu time: 0.0 seconds
    cumulative wall time: 0.0 seconds

Change History (10)

comment:1 Changed 3 years ago by slabbe

  • Component changed from graphics to doctest framework

comment:2 Changed 3 years ago by chapoton

could you try when adding the first line

# -*- coding: utf-8 -*-

to this file ?

comment:3 Changed 3 years ago by chapoton

and replace the print by print(u'\x21\xf9\x04\x08\x23\x00')

and try replacing the output by the result given by sage

comment:4 Changed 3 years ago by slabbe

It seems to work.

For reference, I get

sage: print('\x21\xf9\x04\x08\x23\x00')
sage: '\x21\xf9\x04\x08\x23\x00'

I will post a branch soon.

comment:5 Changed 3 years ago by slabbe

  • Authors set to Sébastien Labbé
  • Branch set to u/slabbe/25416
  • Commit set to d025205a8722af82cac101723d333ab76d35d0b8
  • Status changed from new to needs_review

Removing the print solves the issue.

utf-8 line is unncessary. Still I added it to the file.

I also remove one utf-8 line in a file where there was 2 of them.

Needs review.

New commits:

d02520525416: fixing doctesting issue because of print

comment:6 Changed 3 years ago by git

  • Commit changed from d025205a8722af82cac101723d333ab76d35d0b8 to 367373c003905fc0da9a313c099ce1f8c7a3eea5

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

367373c25416: fixing doctesting issue because of print

comment:7 Changed 3 years ago by slabbe

I updated my commit. I decided to keep the print and just fix the parenthesis placement instead. The problem was introduced in the following commit where the parenthesis were not added at the good place when moving print to Python 3 style. Now it should be fine.

commit f4589a2ff7090a3b1a1e71b3e3f542ce09c20734
Date:   Tue May 3 17:27:58 2016 +0200

    python3 print in plot

Needs review.

comment:8 Changed 3 years ago by chapoton

  • Reviewers set to Frédéric Chapoton

ok, looks good. If you know that it pass the optional tests, you can set to positive.

comment:9 Changed 3 years ago by slabbe

  • Status changed from needs_review to positive_review

comment:10 Changed 3 years ago by vbraun

  • Branch changed from u/slabbe/25416 to 367373c003905fc0da9a313c099ce1f8c7a3eea5
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.