Umlaut encoding issue in UncaughtExceptionHandler (windows)

"Niemann, Hartmut" <[email protected]> Fri, 6 Apr 2018 09:36:29 +0000
Newsgroups gmane.comp.lang.jython.user
Message-ID <1AE3002F400CE4498072DFDF74A843CC20F2EBA6@DEFTHW99EH3MSX.ww902.siemens.net>
Hello!

I am using Jython 2.7.0 embedded into a java application, that is: not the jython.exe, on windows.

When an exception parameter or a line in the stack trace contains an Umlaut, there seems to be an exception in the exception handler itself, 
because all I get (if one of the source lines has umlauts) is

	Exception in thread "main"
	Exception: org.python.core.PyException thrown from the UncaughtExceptionHandler in thread "main"

If the string representation of the exception itself contains an umlaut, stack trace and type of the exception are printed, but the argument is missing.

(If run from jython.exe, the output is completely readable, although some garbage characters are printed instead of the umlauts, which is (sort of) to be expected.)

if I catch the exception  like
		except Exception as e:
			print ('Uncaught exception in main: %s' % e)
			print (sys.exc_info())
			import traceback
			traceback.print_tb(sys.exc_info()[2])
i get reasonable output.

---- the snippet from the embedding java function is:
		//start python
		PythonInterpreter.initialize(null, null, argv.toArray(new String[0]));

		PythonInterpreter py;
		py = new PythonInterpreter();

		//exec
		py.exec("import cpsgen_py");

		PyObject ret;
		ret = py.eval("cpsgen_py.main()");

		if (ret instanceof PyInteger) {
			return ((PyInteger) ret).getValue();
		}
--- a simple examle to try is
	s = 'Hallöle'
	assert False, s  # ä

What do I see here? Am I doing something wrong when setting up the interpreter?


Mit freundlichen Grüßen
Dr. Hartmut Niemann

Siemens AG
Mobility Division
Rolling Stock
Standardization, Remote Control, Display
MO RS LM EN CCI SRD
Werner-von-Siemens-Str. 67
91052 Erlangen, Deutschland
Mobil: +49 173 5342327
mailto:[email protected]

www.siemens.com/ingenuityforlife

Siemens Aktiengesellschaft: Vorsitzender des Aufsichtsrats: Jim Hagemann Snabe; Vorstand: Joe Kaeser, Vorsitzender; Roland Busch, Lisa Davis, Klaus Helmrich, Janina Kugel, Cedrik Neike, Michael Sen, Ralf P. Thomas; Sitz der Gesellschaft: Berlin und München, Deutschland; Registergericht: Berlin Charlottenburg, HRB 12300, München, HRB 6684; WEEE-Reg.-Nr. DE 23691322

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot