spacetelescope / pandokia

Regression tests framework.
Other
2 stars 4 forks source link

Flip order of StringIO imports in db_mysqldb.py #21

Closed oiintam closed 6 years ago

oiintam commented 6 years ago

Import module six in pycode.py so that StringIO will work in both python 2 and 3 seamlessly. Since Pandeia (JWST ETC repo) is converting from python 2 to python 3 and will support both versions for a certain period of time, this fix will help Pandeia running tests using Pandokia.

jhunkeler commented 6 years ago

Hi @oiintam, I think this may have been fixed yesterday before @vglaidler sent her email to the group. I ended up realizing while double-checking an issue in the CGI calls, the StringIO imports were in reverse order. Before yesterday, if io.StringIO was imported under 2.7 it would die because that version of StringIO only accepts unicode strings. Of course in 2.7, the strings coming from all of the streams are just str objects. Obviously that didn't work out too well!

Flipping the order so that StringIO gets imported first, rather than io.StringIO allows 2.7 to proceed normally. I did this for every occurrence in the source code.

oiintam commented 6 years ago

Hi @jhunkeler , thank you very much for the fix. I updated your change on my local install and ran tests against Pandeia. There was a great improvement in the result! There is only one more place I found in db_mysqldb.py. Please let me know if there is any problem/question. Thank you again!

jhunkeler commented 6 years ago

Thank you for catching that! :+1: Everything looks good. I'll go ahead and merge this now :grin: