-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Crash with BeautifulSoup #14548
Labels
Comments
Crashes like this are definitely bugs that we should fix. Could you provide a complete, self-contained code sample that reproduces the error? |
Yes, of course. Sorry I thought the first would suffice. My bad.
Then if you run mypy --strict file_name.py It gives the error on Python3.10 |
@cap-jmk Main issue here in this line: repos.append(repos.append(link["href"])) You are trying to append the result of append call to list. You just need to change your code to: from typing import List
from bs4 import BeautifulSoup
from urllib.request import urlopen
def get_repos(
git_links:List[str]=[
"www.google.com",
"www.bing.com",
],
):
repos = []
print(git_links)
for url in git_links:
soup = BeautifulSoup(urlopen(url), "html.parser")
for link in soup.find_all("a", href=True):
repos.append(link["href"])
if __name__ == "__main__":
get_repos() |
JelleZijlstra
pushed a commit
that referenced
this issue
Jan 29, 2023
Fixes: #14548 Fixed case when untyped list item type resolving can lead to an internal crash. Code to reproduce this issue: ```py arr = [] arr.append(arr.append(1)) ``` Basically, the issue is that after the first resolving of `arr.append` method, `var` is deleted from `partial_types`, and as war as `arr.append` is a nested call we try to delete the same `var` that was already deleted.
hauntsaninja
pushed a commit
to hauntsaninja/mypy
that referenced
this issue
Jan 29, 2023
Fixes: python#14548 Fixed case when untyped list item type resolving can lead to an internal crash. Code to reproduce this issue: ```py arr = [] arr.append(arr.append(1)) ``` Basically, the issue is that after the first resolving of `arr.append` method, `var` is deleted from `partial_types`, and as war as `arr.append` is a nested call we try to delete the same `var` that was already deleted.
hauntsaninja
added a commit
that referenced
this issue
Jan 29, 2023
#14552) (#14553) Fixes: #14548 Fixed case when untyped list item type resolving can lead to an internal crash. Code to reproduce this issue: ```py arr = [] arr.append(arr.append(1)) ``` Basically, the issue is that after the first resolving of `arr.append` method, `var` is deleted from `partial_types`, and as war as `arr.append` is a nested call we try to delete the same `var` that was already deleted. Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The bug produces as internal error when accessing the dict returned from BeautifulSoup.find_all() method:
on: 0.991
Expected Behavior
I would expect some sort of mypy error.
Actual Behavior
Yet, when using the following
The result is
Thus, I am reporting the bug.
Your Environment
mypy.ini
(and other config files): no special configThe text was updated successfully, but these errors were encountered: