Skip to content

Python 2.6 Syntax Errors #141

@Vye

Description

@Vye

The README states that Python 2.6 is supported. However, I am getting syntax errors, one of them being a dictionary comprehension which I know isn't supported in 2.6. I'm surprised no one has reported this yet. Did I do something wrong?

Traceback (most recent call last):
  File "/opt/splunk/etc/apps/ExampleApp/bin/downtime.py", line 8, in <module>
    from splunklib.searchcommands import \
  File "/usr/lib/python2.6/site-packages/splunklib/searchcommands/__init__.py", line 146, in <module>
    from .decorators import *
  File "/usr/lib/python2.6/site-packages/splunklib/searchcommands/decorators.py", line 23, in <module>
    from .internals import ConfigurationSettingsType, json_encode_string
  File "/usr/lib/python2.6/site-packages/splunklib/searchcommands/internals.py", line 766
    metadata = str(''.join(self._iterencode_json({n: v for n, v in metadata if v is not None}, 0)))
                                                         ^
SyntaxError: invalid syntax

After fixing the above with self._iterencode_json(dict((n, v) for n, v in metadata if v is not None), 0) I got another syntax error:

Traceback (most recent call last):
  File "/opt/splunk/etc/apps/ExampleApp/bin/downtime.py", line 8, in <module>
    from splunklib.searchcommands import \
  File "/usr/lib/python2.6/site-packages/splunklib/searchcommands/__init__.py", line 149, in <module>
    from .generating_command import GeneratingCommand
  File "/usr/lib/python2.6/site-packages/splunklib/searchcommands/generating_command.py", line 20, in <module>
    from .search_command import SearchCommand
  File "/usr/lib/python2.6/site-packages/splunklib/searchcommands/search_command.py", line 576
    n: ','.join(v) if isinstance(v, (list, tuple)) else v for n, v in self._configuration.iteritems()})
                                                            ^
SyntaxError: invalid syntax

There may be more. Is splunk-sdk supposed to support Python 2.6? If so, can these errors be fixed? You can reproduce with the following code:

from splunklib.searchcommands import dispatch, StreamingCommand, Configuration, Option, validators

My environment:

$ python -V
Python 2.6.6
$ pip freeze | grep splunk
splunk-sdk==1.5.0

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions