-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
TypeError: __init__() got an unexpected keyword argument 'check_hostname' #32544
Comments
Seems like this library sets up imports that aren't expected in Py2, so the compat code thinks it's in Py3. As the linked page says:
So an answer could be to import the compat module before If the |
This worked for now. Thank you! from youtube_dl import compat # noqa: F401 I will have to spend some time re-writing the backport to not use the |
Hmmm. I had to back to the docs to confirm how imports are supposed to work. It seems that when a module is imported, it's loaded and cached in So importing the compat module before However, some code in yt-dl may use the idiom shown above that are not evaluated when importing compat:
Such code may still be confused by the installed aliases.
But only if the project licences could have been made compatible. |
Yes, I believe that is correct. I think the safest approach is that I need to re-write the imports for my backport of |
Checklist
Verbose log
Description
I am using youtube-dl as a python library. In this case, I am only attempting to download the data for a video.
This is the main error I am receiving when running my tests in pytest.
Which corresponds to the
def _create_http_connection(ydl_handler, http_class, is_https, *args, **kwargs):
function in utils.py.The same issue happens on commit 26035bd and commit 66ab081.
This is my test video. https://www.youtube.com/watch?v=dQw4w9WgXcQ
I am on Python 2.7, and from what I can tell the
_check_hostname
is not supposed to be used unless it is Python 3.x.I have determined this is occurring after a new dependency was added which has the following line (for Python 2.7 compatibility). What is interesting is the portion of the code failing the test is not even related to this new library, but simply importing the library anywhere before the test run causes this error.
Given that this library is supposed to support Python 2.7 (and 2.6?) would it be possible to support this install_aliases option? In general this makes it a lot simpler to support Python 2.7 and 3.x.
https://python-future.org/_modules/future/standard_library.html#install_aliases
The text was updated successfully, but these errors were encountered: