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

display.Video function seems broken when passed `filename` argument #12180

Open
fperez opened this issue Mar 10, 2020 · 3 comments
Open

display.Video function seems broken when passed `filename` argument #12180

fperez opened this issue Mar 10, 2020 · 3 comments
Assignees

Comments

@fperez
Copy link
Member

@fperez fperez commented Mar 10, 2020

Calling (assuming the file animation.m4v exists locally) Video("animation.m4v") works just fine:

image

but if I try to pass either explicitly the filename argument or the data one, as per the docs, I get errors. This for filename:

Video(filename="animation.m4v")

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-78db781f0939> in <module>
----> 1 Video(filename="animation.m4v")

~/local/conda/lib/python3.7/site-packages/IPython/core/display.py in __init__(self, data, url, filename, embed, mimetype, width, height)
   1362             url = data
   1363             data = None
-> 1364         elif os.path.exists(data):
   1365             filename = data
   1366             data = None

~/local/conda/lib/python3.7/genericpath.py in exists(path)
     17     """Test whether a path exists.  Returns False for broken symbolic links"""
     18     try:
---> 19         os.stat(path)
     20     except OSError:
     21         return False

TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

and this for data (granted, I'm not sure if I should be doing some unicode handling here, but the docstring says bytes OR strings are OK, so I assumed this was fine:

Video(data=open("animation.m4v", "rb").read())

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-10-1959c93b1077> in <module>
----> 1 Video(data=open("animation.m4v", "rb").read())

~/local/conda/lib/python3.7/site-packages/IPython/core/display.py in __init__(self, data, url, filename, embed, mimetype, width, height)
   1362             url = data
   1363             data = None
-> 1364         elif os.path.exists(data):
   1365             filename = data
   1366             data = None

~/local/conda/lib/python3.7/genericpath.py in exists(path)
     17     """Test whether a path exists.  Returns False for broken symbolic links"""
     18     try:
---> 19         os.stat(path)
     20     except OSError:
     21         return False

ValueError: stat: embedded null character in path

@Carreau, happy to try to fix this so I have a bit of code in IPython after so many years :)

@Carreau

This comment has been minimized.

Copy link
Member

@Carreau Carreau commented Mar 10, 2020

@Carreau, happy to try to fix this so I have a bit of code in IPython after so many years :)

Sure, do you want some guidance ? I think we just need the relevant line in IPython/core/display.py to check that data is true-ish.

@fperez

This comment has been minimized.

Copy link
Member Author

@fperez fperez commented Mar 11, 2020

Just surprised this has been a bug probably forever, and that it wasn't reported... Let me try to find a bit of time to fix it...

@Carreau

This comment has been minimized.

Copy link
Member

@Carreau Carreau commented Mar 11, 2020

Just surprised this has been a bug probably forever

Seem like it, that is to say 2014 when Video was introduced. You know it's those kind of bugs we do introduce just for you, and hind behind if (username == 'fperez') and is_giving_a_talk():

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.