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
FileUpload does not work on 2.7 #2533
Comments
I see the error too in python 2.7 when uploading a binary file (uploading a text file seems okay). It seems like the problematic lines are ipywidgets/ipywidgets/widgets/widget.py Line 654 in c592184
It's odd - I would have imagined that the lines above it that strip out the binary buffers would have taken care of the issue. Here's a theory: in python 2, strings are the same as binary buffers, so the binary buffers don't get stripped out. However, the json dumps function expects a utf-8 string. So when you transfer a binary buffer from the client to the kernel, it doesn't get stripped out in this check function, so we ask the json library to dump the state, which includes the binary buffer (aka string). That then causes the issue. If that theory is right, we'd see the same issues with any client-side widget transferring a binary value to the kernel (e.g., images, etc.). I'm not sure a good way around this. We'd need to distinguish between binary buffers and real strings, and that is exactly one of the major reasons for python 3. |
It looks like our code is looking for these types in python 2 to strip out: https://github.com/jupyter-widgets/ipywidgets/blob/master/ipywidgets/widgets/widget.py#L59 I'm assuming the problematic thing here is the file's value. If so, why is the file's value not a bytearray or memoryview in python 2? |
Anyway, hopefully that is some context for whoever wants to dig into this. We do plan to release ipywidgets 8 before the end of the year, which will be python 3 only. |
ipywidgets still supports 2.7, but the FileUpload widget does not work due to what looks like unicode vs. byte differences.
When I upload any file, I see:
Is it possible to fix this?
The text was updated successfully, but these errors were encountered: