-
Notifications
You must be signed in to change notification settings - Fork 13
Description
I've found a bug in the way that string filters are handled by the _stringify_filter method of the Collection class in Python 2.7. Using this version of Python, when a string is passed into this function using the following code, no stringified filter is returned.
from jnpr.space import rest
>>> spc = rest.Space(url='http://1.1.1.1', user='user',passwd='passwd')
>>> spc.device_management.devices._stringify_filter('what')
>>>
When I use a dict, it works.
>>> spc.device_management.devices._stringify_filter({'bananas': 'delicious'})
u"filter=((bananas eq 'delicious'))"
Turns out that when a string comes in on the filter_ parameter, it has the type str.
However, you're using from __future__ import unicode_literals, so when you do a type-check on the filter parameter in if isinstance(filter_, str): , you're actually checking if filter_ is an instance of <class 'future.types.newstr.newstr'>.
As a result, the input string is not caught by the first if block in the stringify function and it is also not caught by the second block. No filter is consequently returned for any string passed to the _stringify_filter function in Python 2.7.