Uploaded image for project: 'PyLucene'
  1. PyLucene
  2. PYLUCENE-36

Python exception when handling a Java error

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Labels:
      None
    • Environment:
      Python 3.5, Ubuntu 16.04, Java 8
    • Flags:
      Patch

      Description

      When handling a Java exception via the JavaError class, Python 3.5 generates an exception due to the call to unicode (which does not exist in Python 3), hence masking the actual Java exception with a Python NameError exception.

      I guess this is a consequence of PYLUCENE-35. That one fixed the problem with Unicode characters in Java exceptions for Python 2, but it shouldn't be applied to Python 3 (since in Python 3 the str type is natively Unicode).

      The attached small patch (applied only to the Python 3 branch) fixes it for me.

        Activity

        Hide
        vajda Andi Vajda added a comment -

        Thank you for your patch, I just integrated it !

        Show
        vajda Andi Vajda added a comment - Thank you for your patch, I just integrated it !
        Hide
        vajda Andi Vajda added a comment -

        merged, thanks !

        Show
        vajda Andi Vajda added a comment - merged, thanks !
        Hide
        olindaspider Patrick J. McNerthney added a comment - - edited

        A nit-pick on the Python 3 purity of the generated code. The u prefix on string constants is only supported in Python 3 to make it easy for the same code to run in both Python 2 and 3. Since this is generating Python 3 specific code, the changed line should remove the u"..." string constants, resulting in:

            line(out, 2, 'return "\\n".join((str(super(JavaError, self)), "    Java stacktrace:", str(writer)))')
        
        Show
        olindaspider Patrick J. McNerthney added a comment - - edited A nit-pick on the Python 3 purity of the generated code. The u prefix on string constants is only supported in Python 3 to make it easy for the same code to run in both Python 2 and 3. Since this is generating Python 3 specific code, the changed line should remove the u"..." string constants, resulting in: line(out, 2, 'return "\\n".join((str(super(JavaError, self)), " Java stacktrace:", str(writer)))')
        Hide
        vajda Andi Vajda added a comment -

        Done.

        Show
        vajda Andi Vajda added a comment - Done.

          People

          • Assignee:
            Unassigned
            Reporter:
            paulovn Paulo Villegas
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development