Comments (9)
Hello,
I've created a branch with a fix for this in in 96aaccd
I'd appreciate if you could test it, also, see if the issue with double dicts is gone (couldn't reproduce this).
Thanks
/Robert
from pysnow.
Hey Robert,
I don't think that is the intended functionality. I would expect that when iterating over an empty result that it should behave similar to an empty list.
When I change that line 95 in resource.py to pass
it seems to behave as such, but I'm not sure if that is the correct solution.
from pysnow.
Not that it makes a big difference in this particular scenario, but raising StopIteration
here actually signals that there are no further values, which should make it behave just like an empty list.. just like pass
or removing the empty result test altogether.
Some tests using StopIteration (same results as pass
or removing the empty-test):
# convert generator object to list
>>> print(list(response.all()))
[]
# convert to list and check length
>>> print(len(list(response.all())))
0
# list comprehension
>>> print([r for r in response.all()])
[]
If we want a list containing an empty dictionary here then raising StopIteration
is definitely the right way to go imo.. however, I don't think that's what we want.
So, the best solution here is probably to remove the test altogether. Or what do you think?
from pysnow.
Oh, maybe I did not test against the StopIteration
version properly. Sorry about that. If it behaves like your code then that is perfect.
from pysnow.
All right, I'll fix this later today.
from pysnow.
I properly tested this commit, and it fixes the issue. Thanks again.
from pysnow.
Fixed. The new version is available on pypi.
from pysnow.
Quick addendum to this; based on PEP 479 the StopIteration
is deprecated in python 3.5 in favor of return
. The error I received before was actually a warning, apologies for the confusion.
DeprecationWarning: generator 'Response._parse_response' raised StopIteration
from pysnow.
@siddweiker Ah, yes.. you're right. Simply using return
(without a value) should be compatible with both python 2 and 3.
I'll have this fixed in the next version.
Thanks :)
from pysnow.
Related Issues (20)
- requests.exceptions.ConnectionError
- not_contains should be "NOT LIKE", not "NOTLIKE" HOT 2
- Why there isn't a context manager in the client? HOT 4
- Update a change request record using pysnow.response.Response update() fails. HOT 7
- Requests Hang with Network Blips HOT 4
- Pass certificate info while creating Oauth client HOT 2
- Returning display values when using get_multiple HOT 1
- Tag the source
- Passing a string like "2021-12-01 01:00:00: to less_than/greater_than
- Access servicenow's sys_report_template.do report download function HOT 1
- Unable to load the pysnow module HOT 2
- Upgrade pytz to a more recent version HOT 3
- Usage of sysparm_query_category
- Conversion to dataframe, options around "Display_Value"
- Problem in calling Service Now with custom API Name HOT 1
- ResourceWarning in attachment.upload. File not closed.
- Segmentation Fault upon import
- Unable to install pysnow because pytz version dependence HOT 4
- Resource.get() parameters persist for all requests
- Is this still active? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysnow.