Skip to content
Permalink
Browse files

Fix for Python 2.7

  • Loading branch information...
Thrameos committed Jun 18, 2019
1 parent 75591b1 commit d6e8f24ac520f9e7aa4ce3bc597ea67fce40f0f2
Showing with 32 additions and 26 deletions.
  1. +22 −19 doc/CHANGELOG.rst
  2. +10 −7 jpype/_jclass.py
@@ -6,6 +6,7 @@ This changelog *only* contains changes from the *first* pypi release (0.5.4.3) o
- **Next version - unreleased**

- **0.7.0 - 2019**
- Doc strings are generated for classes and methods.

- Complete rewrite of the core module code to deal unattached threads,
improved hardening, and member management. Massive number of internal
@@ -14,28 +15,30 @@ This changelog *only* contains changes from the *first* pypi release (0.5.4.3) o

- API breakage:

- Java strings no longer convert automatically to Python strings.
The previous behavior was switchable, but only the default
convert to Python was working. Converting to automatically
lead to problems in which is was impossible to work with
classes like StringBuilder in Java. To convert a Java
string use ``str()``.

- Java exceptions are now derived from Python exception. The
old wrapper types have been removed. Catch the exception
with the actual Java exception type rather than ``JException``.
- Java strings conversion behavior has changed. The previous behavior was
switchable, but only the default convert to Python was working.
Converting to automatically lead to problems in which is was impossible
to work with classes like StringBuilder in Java. To convert a Java
string use ``str()``. Therefore, string conversion is currently selected
by a switch at the start of the JVM. The default shall be False
starting in JPype 0.8. New code is encouraged to use the future default
of False. For the transition period the default will be True with a
warning if not policy was selected to encourage developers to pick the
string conversion policy that best applies to their application.

- Java exceptions are now derived from Python exception. The old wrapper
types have been removed. Catch the exception with the actual Java
exception type rather than ``JException``.

- Undocumented exceptions issued from within JPype have
been mapped to the corresponding Python exception types
such as ``TypeError`` and ``ValueError`` appropriately.
Code catching exceptions from previous versions should
be checked to make sure all exception paths are being
- Undocumented exceptions issued from within JPype have been mapped to the
corresponding Python exception types such as ``TypeError`` and
``ValueError`` appropriately. Code catching exceptions from previous
versions should be checked to make sure all exception paths are being
handled.

- Undocumented property import of Java bean pattern
get/set accessors was removed as the default. It is
available with ``import jpype.beans``, but its
use is discouraged.
- Undocumented property import of Java bean pattern get/set accessors was
removed as the default. It is available with ``import jpype.beans``, but
its use is discouraged.

- API rework:

@@ -440,7 +440,7 @@ def _jclassDoc(cls):
Returns:
The doc string for the class.
"""
from textwrap import wrap, indent
from textwrap import TextWrapper
jclass = cls.class_
out = []
out.append("Java class '%s'" % (jclass.getName()))
@@ -455,9 +455,10 @@ def _jclassDoc(cls):
intfs = jclass.getInterfaces()
if intfs:
out.append(" Interfaces:")
words = "".join(
wrap(", ".join([str(i.getCanonicalName()) for i in intfs])))
out.append(indent(words, ' '))
words = ", ".join([str(i.getCanonicalName()) for i in intfs])
wrapper = TextWrapper(initial_indent=' ',
subsequent_indent=' ')
out.extend(wrapper.wrap(words))
out.append("")

ctors = jclass.getDeclaredConstructors()
@@ -522,7 +523,7 @@ def _jmethodDoc(method, cls, overloads):
Returns:
The doc string for the method dispatch.
"""
from textwrap import wrap, indent
from textwrap import TextWrapper
out = []
out.append("Java method dispatch '%s' for '%s'" %
(method.getName(), cls.getName()))
@@ -563,8 +564,10 @@ def _jmethodDoc(method, cls, overloads):

if returns:
out.append(" Returns:")
words = "".join(wrap(", ".join([str(i) for i in set(returns)])))
out.append(indent(words, ' '))
words = ", ".join([str(i) for i in set(returns)])
wrapper = TextWrapper(initial_indent=' ',
subsequent_indent=' ')
out.extend(wrapper.wrap(words))
out.append("")

return "\n".join(out)

0 comments on commit d6e8f24

Please sign in to comment.
You can’t perform that action at this time.