SourceForge has been redesigned. Learn more.

#79 Fixes for running tests with python-3.2


Under python-3.2, docutils does not pass its unittests. I needed the following changes to make it work:

1) sed -i 's/Günter/Gunter/' tools/

This appears to be a bug in python-3.2's distutils ( )and is supposed to be fixed in python-3.2.1. If this is still a problem with python-3.2.1.

2) The attached patch which makes two changes:
2a) Names an exception when catching it so that it can be referenced later (docutils/test/
2b) Uses an explicit encoding when opening a file in text mode. Without this, decoding from ascii was attempted for 6 tests. Note that there's a comment here about python3 breakage when using 'rb' mode to open the file so this might bear more looking at (docutils/test/


  • Toshio Kuratomi

    Toshio Kuratomi - 2011-05-18

    A note since it may be relevant: Our build system sets certain environment variables when it builds packages. LANG=C is one of those. It may be that python-3.2's behaviour has changed to use that variable when it opens files in mode 'r'. it could be that there's a way to set surrogateescape as the error handler for open() and that may be what we want here or we may want to use 'rb' and do the decoding ourselves. The comment in the source code about 'rb' makes me unsure of this.

  • Günter Milde

    Günter Milde - 2011-05-19
    • status: open --> closed-fixed
  • Günter Milde

    Günter Milde - 2011-05-19

    The sample files in test/functional/expected are utf-8 encoded text files that will be compared to a str() instance.
    Hence it is the right thing to use the encoding='utf-8' argument when opening in Python 3.

    Thanks for the report and patch.


Log in to post a comment.