diff options
author | Serge Guelton <sguelton@quarkslab.com> | 2019-01-03 14:26:56 +0000 |
---|---|---|
committer | Serge Guelton <sguelton@quarkslab.com> | 2019-01-03 14:26:56 +0000 |
commit | 903bbb72f3332216c5f8f64dd452d10f52d4eb5c (patch) | |
tree | be839eb0a6186846dbc24e2038ae67a9bd0647cc /bindings | |
parent | ec8c48fb7d4ee1ee940ab3255f3e25b3e289ab8d (diff) | |
download | clang-903bbb72f3332216c5f8f64dd452d10f52d4eb5c.tar.gz |
Portable Python script across Python version
StringIO is obsoleted in Python3, replaced by io.BytesIO or io.StringIO depending on the use.
Differential Revision: https://reviews.llvm.org/D55196
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350318 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/python/tests/cindex/test_translation_unit.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bindings/python/tests/cindex/test_translation_unit.py b/bindings/python/tests/cindex/test_translation_unit.py index b3075eb85d..f3e770a936 100644 --- a/bindings/python/tests/cindex/test_translation_unit.py +++ b/bindings/python/tests/cindex/test_translation_unit.py @@ -6,6 +6,7 @@ if 'CLANG_LIBRARY_PATH' in os.environ: from contextlib import contextmanager import gc import os +import sys import tempfile import unittest @@ -93,10 +94,10 @@ int SOME_DEFINE; self.assertEqual(spellings[-1], 'y') def test_unsaved_files_2(self): - try: - from StringIO import StringIO - except: + if sys.version_info.major >= 3: from io import StringIO + else: + from io import BytesIO as StringIO tu = TranslationUnit.from_source('fake.c', unsaved_files = [ ('fake.c', StringIO('int x;'))]) spellings = [c.spelling for c in tu.cursor.get_children()] |