diff --git a/sphinx_execute_code/__init__.py b/sphinx_execute_code/__init__.py index 9925521..4e9e2e7 100644 --- a/sphinx_execute_code/__init__.py +++ b/sphinx_execute_code/__init__.py @@ -74,8 +74,15 @@ def execute_code(cls, code): 'foobar' """ - output = StringIO.StringIO() - err = StringIO.StringIO() + # Added by @stephanobryan for python 3 + if sys.version_info.major == 2: + from StringIO import StringIO + output = StringIO.StringIO() + err = StringIO.StringIO() + else: + import io + output = io.StringIO() + err = io.StringIO() sys.stdout = output sys.stderr = err