Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit bd38f28

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 bd38f28

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
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 one
1718
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
@@ -25,7 +28,7 @@ def __getitem__(self, key):
2528
raise TypeError('only 2-tuples allowed')
2629
name = key[0]
2730
tags = key[1]
28-
if not isinstance(tags, dict) and tags is not None:
31+
if not isinstance(tags, dict):
2932
raise TypeError('tags should be a dict')
3033
elif isinstance(key, dict):
3134
name = None
@@ -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)