Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attrs method output is changed when using find #66

Open
cfrahnow opened this issue Mar 11, 2021 · 1 comment
Open

attrs method output is changed when using find #66

cfrahnow opened this issue Mar 11, 2021 · 1 comment

Comments

@cfrahnow
Copy link

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.

@maxhumber
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants