Skip to content

Commit b9de11d

Browse files
author
Shakeel Mohamed
committed
Searchcommands: add full support for unicode
Python's cstringio doesn't support unicode characters, when encountering them Exceptions are raised. We've decided to use stringio instead, trading potential performance improvements for full unicode support. In Python 2, this may lead to a slight performance hit since we're no longer explicitly using the native version. However, in Python 3 stringio will automatically use the native version if available and there should be no noticeable performance changes.
1 parent f989819 commit b9de11d

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

splunklib/searchcommands/internals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from collections import OrderedDict # must be python 2.7
2323
except ImportError:
2424
from ..ordereddict import OrderedDict
25-
from splunklib.six.moves import cStringIO as StringIO
25+
from splunklib.six.moves import StringIO
2626
from itertools import chain
2727
from splunklib.six.moves import map as imap
2828
from json import JSONDecoder, JSONEncoder

splunklib/searchcommands/search_command.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
except ImportError:
2828
from ..ordereddict import OrderedDict
2929
from copy import deepcopy
30-
from splunklib.six.moves import cStringIO as StringIO
30+
from splunklib.six.moves import StringIO
3131
from itertools import chain, islice
3232
from splunklib.six.moves import filter as ifilter, map as imap, zip as izip
3333
from splunklib import six
@@ -850,7 +850,6 @@ def _execute(self, ifile, process):
850850

851851
@staticmethod
852852
def _read_chunk(ifile):
853-
854853
# noinspection PyBroadException
855854
try:
856855
header = ifile.readline()

splunklib/searchcommands/validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from json.encoder import encode_basestring_ascii as json_encode_string
2020
from collections import namedtuple
21-
from splunklib.six.moves import cStringIO as StringIO
21+
from splunklib.six.moves import StringIO
2222
from io import open
2323
import csv
2424
import os

tests/searchcommands/test_search_command.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# coding=utf-8
23
#
34
# Copyright 2011-2015 Splunk, Inc.
45
#
@@ -22,7 +23,7 @@
2223
from splunklib.searchcommands.search_command import SearchCommand
2324
from splunklib.client import Service
2425

25-
from splunklib.six.moves import cStringIO as StringIO
26+
from splunklib.six.moves import StringIO
2627
from splunklib.six.moves import zip as izip
2728
from json.encoder import encode_basestring as encode_string
2829
from unittest import main, TestCase
@@ -388,7 +389,7 @@ def test_process_scpv2(self):
388389
'"required_option_1=value_1",'
389390
'"required_option_2=value_2"'
390391
'],'
391-
'"search": "%7C%20inputlookup%20tweets%20%7C%20countmatches%20fieldname%3Dword_count%20pattern%3D%22%5Cw%2B%22%20text%20record%3Dt%20%7C%20export%20add_timestamp%3Df%20add_offset%3Dt%20format%3Dcsv%20segmentation%3Draw",'
392+
'"search": "%7C%20inputlookup%20tweets%20%7C%20countmatches%20fieldname%3Dword_count%20pattern%3D%22%5Cw%2B%22%20text%20record%3Dt%20%7C%20export%20add_timestamp%3Df%20add_offset%3Dt%20format%3Dcsv%20segmentation%3Draw",'
392393
'"earliest_time": "0",'
393394
'"session_key": "0JbG1fJEvXrL6iYZw9y7tmvd6nHjTKj7ggaE7a4Jv5R0UIbeYJ65kThn^3hiNeoqzMT_LOtLpVR3Y8TIJyr5bkHUElMijYZ8l14wU0L4n^Oa5QxepsZNUIIQCBm^",'
394395
'"owner": "admin",'

0 commit comments

Comments
 (0)