Mercurial > python-hglib
changeset 146:8d7bf729a4db
hglib: use io.BytesIO when available (issue4520)
Since cStringIO.StringIO is not available in Python 3, try to use
io.BytesIO when available.
author | Brett Cannon <brett@python.org> |
---|---|
date | Fri, 13 Mar 2015 11:34:52 -0400 |
parents | f3c430afa598 |
children | 98829bf71f10 |
files | hglib/client.py hglib/util.py tests/test-import.py |
diffstat | 3 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hglib/client.py Fri Mar 13 11:31:54 2015 -0400 +++ b/hglib/client.py Fri Mar 13 11:34:52 2015 -0400 @@ -1,5 +1,8 @@ import subprocess, os, struct, re, datetime -from cStringIO import StringIO as BytesIO +try: + from io import BytesIO +except ImportError: + from cStringIO import StringIO as BytesIO import hglib, error, util, templates, merge, context from util import b, cmdbuilder
--- a/hglib/util.py Fri Mar 13 11:31:54 2015 -0400 +++ b/hglib/util.py Fri Mar 13 11:34:52 2015 -0400 @@ -1,5 +1,8 @@ import itertools, error, os, subprocess, sys -from cStringIO import StringIO as BytesIO +try: + from io import BytesIO +except ImportError: + from cStringIO import StringIO as BytesIO if sys.version_info[0] > 2: def b(s):
--- a/tests/test-import.py Fri Mar 13 11:31:54 2015 -0400 +++ b/tests/test-import.py Fri Mar 13 11:34:52 2015 -0400 @@ -1,5 +1,8 @@ import common, os -from cStringIO import StringIO as BytesIO +try: + from io import BytesIO +except ImportError: + from cStringIO import StringIO as BytesIO import hglib from hglib.util import b