Changeset 13583


Ignore:
Timestamp:
Sep 24, 2019 9:24:38 AM (3 months ago)
Author:
randersson
Message:

#5819 Updates to code after review comments. Now all the 'is python 3' flags are imported from pyfmi.

Location:
branches/dev-5819/Python/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-5819/Python/src/pyjmi/log/tree.py

    r13505 r13583  
    2121"""
    2222from sys import version_info
     23from pyfmi import common
    2324class Comment(object):
    2425    """Log comment node.
     
    8485        types may be a string or list of strings.
    8586        """
    86         if isinstance(types, str if version_info > (3, 0) else basestring):
     87        if isinstance(types, str if python3_flag else basestring):
    8788            types = [types]
    8889
  • branches/dev-5819/Python/src/pymodelica/compiler_interface.py

    r13517 r13583  
    3030# note that startJVM() fails after shutdownJVM(), hence, only one start
    3131if not jpype.isJVMStarted():
    32     _jvm_args = str.split(pym.environ['JVM_ARGS'],' ')
     32    _jvm_args = pym.environ['JVM_ARGS'].split(' ')
    3333    _jvm_class_path = pym.environ['COMPILER_JARS']
    3434    _jvm_ext_dirs = pym.environ['BEAVER_PATH']
  • branches/dev-5819/Python/src/pymodelica/compiler_wrappers.py

    r13566 r13583  
    2828from sys import version_info
    2929
     30# import python_3_flag from pyfmi
     31from pyfmi import common
     32
    3033
    3134class ModelicaCompiler(object):
     
    4144        Modelica models. A compiler instance can be used multiple times.
    4245        """
    43         if version_info > (3, 0):
    44             self._is_python3 = True
    45             self._java_exception = jpype.JException
    46         else:
    47             self._is_python3 = False
    48             self._java_exception = jpype.JavaException
     46        self._java_exception = jpype.JException if python3_flag else jpype.JavaException
    4947       
    5048        try:
     
    529527            #  we need to compare the raised exception with the reference exception
    530528            #  in different ways.
    531             return type(raised_ex) is ref_ex if self._is_python3 else raised_ex.javaClass() is ref_ex
    532 
    533         #print("ex.message() = {}".format(ex.message()))
    534         #print("ex.args = {}".format(ex.args))
    535         #print("ex.stacktrace() = {}".format(ex.stacktrace()))
    536         #print("str(ex) = {}".format(str(ex)))
    537         #import sys; sys.exit()
    538         #raise ex
    539         #ex.message=ex.message()
    540         #raise ex doesnt work because they are different in py2 and py3
    541         #raise ex
     529            return type(raised_ex) is ref_ex if python3_flag else raised_ex.javaClass() is ref_ex
     530
    542531        if _py_handle_exception(ex, CompilerException):
    543532            arraylist = ex.__javaobject__.getProblems()
Note: See TracChangeset for help on using the changeset viewer.