Thanks for the patch, and sorry I haven't had time to review yet. It probably won't be until next week until I'm freed up. In the meantime, if you'd like to take a peek at the relevant parts of Armin Ronacher's work/writings on py3k porting, and update the pull request accordingly (if there are any changes you'd like to make after reading), it could speed up this patch getting accepted:
Regarding the print-as-a-function future import, I recommend against using it to avoid confusion. Especially because all editors are currently highlighting it as a keyword it can become confusing quickly. Generally if things behave differently in different files it's a good idea to avoid these things if possible. The great aspect of the print change is that it can be reliably converted with 2to3, so there is really no reason to use the print_function future import.
Just had a chance to review. Could you please make the following changes before I apply?
separate the single try/except wrapping the builtin and StringIO imports into two different try/excepts
import the newer spelling of each and fall back on the older one instead of vice versa
don't drop trying the cStringIO import before falling back on the StringIO import
In testing this with non-ascii characters, I noticed an inconsistency in the TraceTracker behavior across python2 and python3 due to python3's changes in string printing behavior (example). For instance, if you apply this patch, the tests fail in python2 but pass in python3. Would you like to expand your patch to include better doctest coverage demonstrating expected usage and fixes for additional issues discovered?
Thanks again for contributing, it's awesome to have you!
* separate the single try/except wrapping the builtin and StringIO imports into two different try/excepts
* import the newer spelling of each and fall back on the older one instead of vice versa
* don't drop trying the cStringIO import before falling back on the StringIO import
I had misunderstood that it's imported the cStringIO module inside of StringIO, so I changed. Though I gathered importing modules in try/expect syntax, dividing try/expect is also OK. Additionally, it's depend on you (maintainer) which we use new spelling or old one.
About the difference of repr() is really annoying. :(
Python 3 repr() behavior is user-friendly, but to implement the same behavior in Python 2.x is needed some complex changes since it should be converted between encoded string and unicode. Instead, I tried to use ascii() for compatibility, I couldn't get a simple solution.
Pull request accepted. I reorganized the imports to try the newer spellings before the older ones in 5a3ce7bda056 as well as defining a next() global to unbreak python2.5.
Re repr, I guess everything's actually fine in the Minimock code itself regardless of Python 2 or 3. You'd only hit this when writing a test with non-ascii characters that has to pass in both Python 2 and 3, so I think it's ok to leave this up to the user.