Attempt further mitigations for encoding problems
MODIFY
runtime/src/jycessing/Runner.java
runtime/src/jycessing/Runner.java
@@ -290,10 +290,18 @@ public class Runner {
// Suppress sys-package-manager output.
props.setProperty("python.verbose", "error");
- // Prevent "Failed to install '': java.nio.charset.UnsupportedCharsetException: cp0."
- props.put("python.console.encoding", "UTF-8");
+
+ // Attempt to prevent "Failed to install '': java.nio.charset.UnsupportedCharsetException: cp0."
+ props.put("python.console.encoding", "utf-8");
+ props.put("python.io.encoding", "utf-8");
+ props.put("python.io.errors", "utf-8");
+
props.put("python.import.site", "false");
+ props.put("python.cachedir.skip", "false");
+ props.put("python.cachedir",
+ new File(System.getProperty("java.io.tmpdir"), "PythonModeCache").getAbsolutePath());
+
// Permit python subclasses to access protect fields, as in Beads.
props.put("python.security.respectJavaAccessibility", "false");

MODIFY
runtime/src/jycessing/mode/run/SketchServiceProcess.java
runtime/src/jycessing/mode/run/SketchServiceProcess.java
@@ -33,8 +33,7 @@ public class SketchServiceProcess {
}
}
- private static final FilenameFilter JARS =
- new FilenameFilter() {
+ private static final FilenameFilter JARS = new FilenameFilter() {
@Override
public boolean accept(final File dir, final String name) {
return name.endsWith(".jar");
@@ -60,8 +59,8 @@ public class SketchServiceProcess {
* This constructor should only be used while instrumenting or debugging the {@link SketchRunner},
* in which case it has already been started in the debugger or such like.
*/
- SketchServiceProcess(
- final PythonMode mode, final PyEditor editor, final SketchService runningService) {
+ SketchServiceProcess(final PythonMode mode, final PyEditor editor,
+ final SketchService runningService) {
this.mode = mode;
this.editor = editor;
this.sketchService = runningService;
@@ -122,27 +121,20 @@ public class SketchServiceProcess {
}
// Attempt to address https://github.com/jdf/Processing.py-Bugs/issues/158
- if (Platform.isWindows()) {
command.add("-Dpython.console.encoding=UTF-8");
- }
if (PythonMode.VERBOSE) {
command.add("-Dverbose=true");
}
- command.add(
- "-Djava.library.path="
- + System.getProperty("java.library.path")
- + File.pathSeparator
- + mode.getContentFile("mode").getAbsolutePath());
+ command.add("-Djava.library.path=" + System.getProperty("java.library.path")
+ + File.pathSeparator + mode.getContentFile("mode").getAbsolutePath());
final List<String> cp = new ArrayList<>();
- cp.addAll(
- filter(
- Arrays.asList(
- System.getProperty("java.class.path").split(Pattern.quote(File.pathSeparator))),
- not(
- or(
+ cp.addAll(filter(
+ Arrays
+ .asList(System.getProperty("java.class.path").split(Pattern.quote(File.pathSeparator))),
+ not(or(
containsPattern(
"(ant|ant-launcher|antlr|netbeans.*|osgi.*|jdi.*|ibm\\.icu.*|jna)\\.jar$"),
containsPattern("/processing/app/(test|lib)/")))));
@@ -179,8 +171,7 @@ public class SketchServiceProcess {
public void runSketch(final PdeSketch sketch) throws SketchException {
// Create a pending request in case of various failure modes.
- pendingSketchRequest =
- new Runnable() {
+ pendingSketchRequest = new Runnable() {
@Override
public void run() {
try {

Attempt further mitigations for encoding problems