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

IOError: cannot identify image file #17940

Closed
gagern mannequin opened this issue Mar 12, 2015 · 14 comments
Closed

IOError: cannot identify image file #17940

gagern mannequin opened this issue Mar 12, 2015 · 14 comments

Comments

@gagern
Copy link
Mannequin

gagern mannequin commented Mar 12, 2015

With Sage 6.6 beta 3 and using Sage Notebook I get a backtrace when I want to see a sphere:

sage: sphere()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_3.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("c3BoZXJlKCk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpWqCNEl/___code___.py", line 2, in <module>
    exec compile(u'sphere()
  File "", line 1, in <module>
    
  File "sage/local/lib/python2.7/site-packages/sage/repl/rich_output/display_manager.py", line 716, in displayhook
    return self._backend.displayhook(plain_text, rich_output)
  File "sage/local/lib/python2.7/site-packages/sage/repl/rich_output/backend_base.py", line 432, in displayhook
    return self.display_immediately(plain_text, rich_output)
  File "sage/local/lib/python2.7/site-packages/sage/repl/rich_output/backend_sagenb.py", line 361, in display_immediately
    rich_output.embed()
  File "sage/local/lib/python2.7/site-packages/sage/repl/rich_output/backend_sagenb.py", line 258, in embed
    self.save_preview()
  File "sage/local/lib/python2.7/site-packages/sage/repl/rich_output/backend_sagenb.py", line 237, in save_preview
    self.preview_png.save_as(self.preview_filename())
  File "sage/misc/cachefunc.pyx", line 2209, in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (build/cythonized/sage/misc/cachefunc.c:13699)
  File "sage/local/lib/python2.7/site-packages/sage/repl/rich_output/backend_sagenb.py", line 189, in preview_filename
    directory, filename = os.path.split(self._base_filename())
  File "sage/misc/cachefunc.pyx", line 2209, in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (build/cythonized/sage/misc/cachefunc.c:13699)
  File "sage/local/lib/python2.7/site-packages/sage/repl/rich_output/backend_sagenb.py", line 147, in _base_filename
    filename = self.sagenb_launch_script_filename()
  File "sage/misc/cachefunc.pyx", line 2209, in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (build/cythonized/sage/misc/cachefunc.c:13699)
  File "sage/local/lib/python2.7/site-packages/sage/repl/rich_output/backend_sagenb.py", line 122, in sagenb_launch_script_filename
    width, height = PIL.Image.open(StringIO(self.preview_png.get())).size
  File "build/bdist.linux-x86_64/egg/PIL/Image.py", line 2006, in open
IOError: cannot identify image file

Using strace I can see access to some preview.png and looking at that file I notice that it appears to be a regular PNG, concatenated with a Jmol script. So apparently two outputs ended up in the same data stream. This is likely a consequence of #17234.

Upstream: Workaround found; Bug reported upstream.

CC: @vbraun

Component: user interface

Keywords: strange

Author: Martin von Gagern

Branch/Commit: 3818998

Reviewer: Volker Braun

Issue created by migration from https://trac.sagemath.org/ticket/17940

@gagern gagern mannequin added this to the sage-6.6 milestone Mar 12, 2015
@gagern gagern mannequin added c: user interface labels Mar 12, 2015
@vbraun
Copy link
Member

vbraun commented Mar 12, 2015

comment:1

Works for me. Can you post your strace output? Can PIL open a PNG at all on your system?

@gagern
Copy link
Mannequin Author

gagern mannequin commented Mar 12, 2015

Replying to @gagern:

Using strace I can see access to some preview.png and looking at that file I notice that it appears to be a regular PNG, concatenated with a Jmol script. So apparently two outputs ended up in the same data stream. This is likely a consequence of #17234.

It seems I was misled: apparently JMol attaching its script to the generated PNG is normal behavior. The PNG file is apparently broken at some other point. Looking at the PNG chunks as reported by the pngchunks tool, I see that the IDAT chunk appears to be off by one byte. The chunk before that is an iTXt chunk stating the creation date. It does so in a locale-dependent manner, and in my case that means using the German abbreviation for March, which is Mär. So I'd say JMol is counting UTF-16 code units when it should be counting UTF-8 code units. This is a bug in JMol, and probably can be reproduced at least this month by using a German locale.

I'll try to see whether we can work around this issue by forcing the locale to C, like LC_ALL=C or some Java-specific analogon to this.

@gagern
Copy link
Mannequin Author

gagern mannequin commented Mar 12, 2015

Branch: u/gagern/ticket/17940

@gagern
Copy link
Mannequin Author

gagern mannequin commented Mar 12, 2015

Commit: 3818998

@gagern
Copy link
Mannequin Author

gagern mannequin commented Mar 12, 2015

Author: Martin von Gagern

@gagern
Copy link
Mannequin Author

gagern mannequin commented Mar 12, 2015

comment:4

Setting the locale to C works as expected.


New commits:

3818998Trac #17940: Execute JMol in C locale.

@gagern gagern mannequin added the s: needs review label Mar 12, 2015
@vbraun
Copy link
Member

vbraun commented Mar 12, 2015

Reviewer: Volker Braun

@vbraun
Copy link
Member

vbraun commented Mar 12, 2015

comment:5

Good detective job ;-)

Did you report it upstream?

@gagern
Copy link
Mannequin Author

gagern mannequin commented Mar 12, 2015

comment:6

Replying to @vbraun:

Did you report it upstream?

Did so now: https://sourceforge.net/p/jmol/bugs/570/

@gagern
Copy link
Mannequin Author

gagern mannequin commented Mar 12, 2015

Upstream: Workaround found; Bug reported upstream.

@jdemeyer
Copy link

comment:7

A bug which happens only in March :-)

This should be added to the "strange bug list" together with #10609 and #12221.

@gagern
Copy link
Mannequin Author

gagern mannequin commented Mar 12, 2015

Changed keywords from none to strange

@gagern
Copy link
Mannequin Author

gagern mannequin commented Mar 12, 2015

comment:8

Replying to @jdemeyer:

This should be added to the "strange bug list" together with #10609 and #12221.

Done here, shoudl I do the others as well?

@vbraun
Copy link
Member

vbraun commented Mar 12, 2015

Changed branch from u/gagern/ticket/17940 to 3818998

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

No branches or pull requests

2 participants