ipython / ipython/ipython

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

Aperta
#12,180 3 commenti 0 reazioni 1 assegnatario Rivendicata da @fperez Vedi su GitHub
Lingua principale
Python
Stelle
16.8k
Fork
4.5k
Merge medio
1g 2h
PR unite (30g)
6

Descrizione

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

![image](https://user-images.githubusercontent.com/57394/76286463-7f935a80-625f-11ea-8a93-8d5e34ee1504.png)

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)
in
----> 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)
in
----> 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 :)

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.