gazpacho
gazpacho copied to clipboard
attrs method output is changed when using find
find changes the content of attrs
When using the find method on a Soup object, the content of attrs is overwritten by the parameter attrs in find.
Steps to reproduce the issue
Try the following:
from gazpacho import Soup
div = Soup("<div id='my_id' />").find("div")
print(div.attrs)
div.find("span", {"id": "invalid_id"})
print(div.attrs)
The expected output will be the following, because we twice print the attributes of a:
{'id': 'my_id'}
{'id': 'my_id'}
But instead you actually receive:
{'id': 'my_id'}
{'id': 'invalid_id'}
which is wrong.
Environment:
- OS: Linux
- Version: 1.1
My current workaround is to save the attributes before I execute find.
Good find! Hasn't ever been a problem for me in production, but should definitely be fixed. I've earmarked a week at the end of this quarter to clean up some outstanding issues.. I'll put this one in that work block!