[Jython-checkins] jython: Avoid NPE in imp.java due to encoding null directory name. Fixes #2612.
jeff.allen
jython-checkins at python.org
Sun Aug 27 07:45:40 EDT 2017
https://hg.python.org/jython/rev/39b0bd0dcd01
changeset: 8123:39b0bd0dcd01
user: Jeff Allen <ja.py at farowl.co.uk>
date: Sun Aug 27 12:40:25 2017 +0100
summary:
Avoid NPE in imp.java due to encoding null directory name. Fixes #2612.
This was a regresion caused when trying to deal with non-ascii paths in
the preparation of a log message. Thanks to James Mudd for diagnosing
this. Also https://github.com/jythontools/jython/pull/86.
files:
NEWS | 1 +
src/org/python/core/PyString.java | 2 +-
src/org/python/core/imp.java | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@
Development tip
Bugs fixed
+ - [ 2612 ] NPE while trying to load class
- [ 2609 ] PyType.fromClass publication race (discovered in strptime and re)
- [ 2608 ] Encoding problems with non-ascii host name
- [ 2599 ] Cannot handle network paths under Windows
diff --git a/src/org/python/core/PyString.java b/src/org/python/core/PyString.java
--- a/src/org/python/core/PyString.java
+++ b/src/org/python/core/PyString.java
@@ -316,7 +316,7 @@
* @param quoteChar '"' or '\'' use that, '?' = let Python choose, 0 or anything = no quotes
* @return encoded string (possibly the same string if unchanged)
*/
- public static String encode_UnicodeEscape(String str, char quote) {
+ static String encode_UnicodeEscape(String str, char quote) {
// Choose whether to quote and the actual quote character
boolean use_quotes;
diff --git a/src/org/python/core/imp.java b/src/org/python/core/imp.java
--- a/src/org/python/core/imp.java
+++ b/src/org/python/core/imp.java
@@ -624,7 +624,7 @@
if (caseok(dir, name) && (sourceFile.isFile() || compiledFile.isFile())) {
pkg = true;
} else {
- String printDirName = PyString.encode_UnicodeEscape(displayDirName, '\'');
+ String printDirName = PyString.encode_UnicodeEscape(dir.getPath(), '\'');
Py.warning(Py.ImportWarning, String.format(
"Not importing directory %s: missing __init__.py", printDirName));
}
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list