Skip to content

Commit a306616

Browse files
committed
extract_README.py works with both python2 and python3
Thanks to Sandro Tosi for the patch!
1 parent 5ef4bba commit a306616

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

extract_README.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424

2525
import inspect
2626
import re
27-
import StringIO
27+
try:
28+
from StringIO import StringIO ## for Python 2
29+
except ImportError:
30+
from io import StringIO ## for Python 3
31+
2832

2933
def dirmod():
3034
r'''Same as dir(mod), but returns only functions, in the definition order'''
@@ -69,7 +73,7 @@ def write(s, verbatim):
6973

7074
prev_indented = False
7175

72-
sio = StringIO.StringIO(s)
76+
sio = StringIO(s)
7377
for l in sio:
7478

7579
# handle links

0 commit comments

Comments
 (0)