# -*- coding: iso-8859-15 -*- ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

# -*- coding: iso-8859-15 -*- ?

Leon Espinosa-3
Dear all, I used to put

# -*- coding: iso-8859-15 -*-

at the first line in Jython scripts... but recent versions (IJ2 ?) it don't wants anymore (see bellow) :

Some workaround... ???

Thank you

Leon



org.python.antlr.ParseException: encoding declaration in Unicode string
        at org.python.core.ParserFacade.prepBufReader(ParserFacade.java:275)
        at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:119)
        at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:259)
        at org.scijava.plugins.scripting.jython.JythonScriptEngine.eval(JythonScriptEngine.java:76)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:175)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:167)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
        at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:164)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:695)

org.python.antlr.ParseException: org.python.antlr.ParseException: encoding declaration in Unicode string

        at org.python.core.PyException.fillInStackTrace(PyException.java:70)
        at java.lang.Throwable.<init>(Throwable.java:181)
        at java.lang.Exception.<init>(Exception.java:29)
        at java.lang.RuntimeException.<init>(RuntimeException.java:32)
        at org.python.core.PyException.<init>(PyException.java:46)
        at org.python.core.PyException.<init>(PyException.java:43)
        at org.python.core.Py.JavaError(Py.java:495)
        at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:124)
        at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:259)
        at org.scijava.plugins.scripting.jython.JythonScriptEngine.eval(JythonScriptEngine.java:76)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:175)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:167)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
        at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:164)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:695)
Caused by: org.python.antlr.ParseException: encoding declaration in Unicode string
        at org.python.core.ParserFacade.prepBufReader(ParserFacade.java:275)
        at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:119)
        ... 12 more

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: # -*- coding: iso-8859-15 -*- ?

Marcel
This post was updated on .
Hello,

i guess this has something to do with the ANTLR  parser written for a specific Jython version.
I would guess that the the parser has been changed so that you get a parse exception
because of invalid parsing rules.

Here you can find a related post with an explanation for your declaration:

http://stackoverflow.com/questions/3170211/why-declare-unicode-by-string-in-python


Reply | Threaded
Open this post in threaded view
|

Re: # -*- coding: iso-8859-15 -*- ?

Leon Espinosa-3
Hello, thank you for these informations. I did not really understand the discussion in stackoverflow, but as it was noted the encoding heading was needed in order to allow the code comments (and automatic documentation of the class) with something different than ascii chars (like in French... !).

Anyway, with "old" Fiji distrubution this works perfect :

# -*- coding: iso-8859-15 -*-
class A_Class(object) :
        """Ceci est une classe dont la doc comporte des: é à ç è """


And with the recent versions this works perfect :

class A_Class(object) :
        """Ceci est une classe dont la doc comporte des: é à ç è """

So it seems that we need to make a choice... and migrate to recent version and modify the scripts. But is not trivial to have all the people using the scripts in the lab with the good couple of Fiji-version/Script-version .

Thank you all for the help

Leon





Le 2 sept. 2014 à 10:31, Bio7 a écrit :

> Hello,
>
> i guess this has something to do with the  ANTLR <http://www.antlr.org/>  
> parser written for a specific Jython version.
> I would guess that the the parser has been changed so that you get a parse
> exception
> because of invalid parsing rules.
>
> Here you can find a related post with an explanation for your declaration:
>
> http://stackoverflow.com/questions/3170211/why-declare-unicode-by-string-in-python
>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/coding-iso-8859-15-tp5009414p5009460.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html