Skip to content

Commit 05104ff

Browse files
author
Grégory Starck
committed
Correctly check that the given serie name has the correct type
type(b''.decode()) should give unicode or str depending if on python<3 or python>=3.
1 parent 54eb8bc commit 05104ff

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

influxdb/resultset.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ def __init__(self, series):
1111

1212
def __getitem__(self, key):
1313
"""
14-
:param key: Either a serie name or a 2-tuple(serie_name, tags_dict)
15-
If the given serie name is None then any serie (matching
16-
the eventual given tags) will be given its points one
17-
after the other.
14+
:param key: Either a serie name, or a tags_dict, or
15+
a 2-tuple(serie_name, tags_dict).
16+
If the serie name is None (or not given) then any serie
17+
matching the eventual given tags will be given its points
18+
one after the other.
19+
To get the points of every serie in this resultset then
20+
you have to provide None as key.
1821
:return: A generator yielding `Point`s matching the given key.
1922
NB:
2023
The order in which the points are yielded is actually undefined but
@@ -34,10 +37,8 @@ def __getitem__(self, key):
3437
name = key
3538
tags = None
3639

37-
# TODO(aviau): Fix for python 3.2
38-
# if not isinstance(name, (str, bytes, type(None))) \
39-
# and not isinstance(name, type("".decode("utf-8"))):
40-
# raise TypeError('serie_name must be an str or None')
40+
if not isinstance(name, (bytes, type(b''.decode()), type(None))):
41+
raise TypeError('serie_name must be an str or None')
4142

4243
for serie in self._get_series():
4344
serie_name = serie.get('name', 'results')

0 commit comments

Comments
 (0)