Skip to content

Commit

Permalink
Fix bug when escaping non-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapz committed Oct 12, 2016
1 parent 3b4acf5 commit d2e94db
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ docs/build
.cache
*.egg-info
.eggs
dist/
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1.0a1'
release = '0.1.0a2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
5 changes: 5 additions & 0 deletions inflow/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import six

__all__ = ['to_comma_separated_string', 'escape']


Expand Down Expand Up @@ -25,6 +27,9 @@ def escape(characters, string):
If a non-string is given to be escaped, we return the non-string without
escaping.
"""
if not isinstance(string, six.string_types):
return string

for char in characters:
string = string.replace(char, '\\' + char)
return string
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='inflow',
version='0.1.0a1',
version='0.1.0a2',
author='Jaap Broekhuizen',
author_email='broekhuizen@baopt.nl',
description='A simple InfluxDB client library.',
Expand Down
5 changes: 5 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from inflow.utils import escape


def test_escape_skip_nonstrings():
assert escape([], 10) == 10

0 comments on commit d2e94db

Please sign in to comment.