ipython / ipython/ipython

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

Ouverte
#12,180 3 commentaires 0 réactions 1 personne assignée Réclamée par @fperez Voir sur GitHub
Langage dominant
Python
Étoiles
16.8k
Forks
4.5k
Merge moyen
1 j 2 h
PR mergées (30 j)
6

Description

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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.