Changeset 13537


Ignore:
Timestamp:
Sep 19, 2019 8:58:14 AM (3 months ago)
Author:
randersson
Message:

#5819 Testing changing the exceptions caught from JavaException to JException since Java Throwable is converted to JException since 0.7.0 (JavaException does not exist in jpype 0.7.0). Also changed type of keys when constructing problem nodes since xmlparser have issues with keys being of type str in py3. These changes are not tested yet with py2.

Location:
branches/dev-5819/Python/src/pymodelica
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-5819/Python/src/pymodelica/compiler_logging.py

    r13496 r13537  
    4646            if name == 'value':
    4747                self.attribute = attrs['name'].encode('utf-8')
    48                 self.node[self.attribute] = '';
     48                self.node[self.attribute] = ''
    4949        else:
    5050            if name == "Error":
     
    7878    def characters(self, content):
    7979        if self.node is not None and self.attribute is not None:
    80             self.node[self.attribute] += content;
     80            self.node[self.attribute] += content
    8181   
    8282    def _construct_problem_node(self, node):
    8383        if node['type'] == 'exception':
    84             return CompilationException(node['kind'], node['message'], node['stacktrace'])
     84            return CompilationException(node[b'kind'], node[b'message'], node[b'stacktrace'])
    8585        elif node['type'] == 'error':
    86             return CompilationError(node['identifier'], node['kind'], node['file'], node['line'], \
    87                 node['column'], node['message'])
     86            return CompilationError(node[b'identifier'], node[b'kind'], node[b'file'], node[b'line'], \
     87                node[b'column'], node[b'message'])
    8888        elif node['type'] == 'warning':
    89             return CompilationWarning(node['identifier'], node['kind'], node['file'], node['line'], \
    90                 node['column'], node['message'])
     89            return CompilationWarning(node[b'identifier'], node[b'kind'], node[b'file'], node[b'line'], \
     90                node[b'column'], node[b'message'])
    9191
    9292class KeepLastStream():
     
    112112        if self.last is not None:
    113113            # Count the number of lines in the previous contents
     114            # apparently self.last is of class 'bytes' in py3
     115            # compared to class 'str' in py2
     116            self.last = self.last.decode('utf-8')
    114117            self.line += self.last.count('\n')
    115118            # Get the two last lines
  • branches/dev-5819/Python/src/pymodelica/compiler_wrappers.py

    r13461 r13537  
    4242        try:
    4343            options = ModelicaCompilerInterface.createOptions()
    44         except jpype.JavaException as ex:
     44        except jpype.JException as ex:
    4545            self._handle_exception(ex)
    4646           
     
    9090        try:
    9191            self._compiler.setLogger(log_string)
    92         except jpype.JavaException as ex:
     92        except jpype.JException as ex:
    9393            self._handle_exception(ex)
    9494
     
    129129        try:
    130130            target_obj = self._compiler.createTargetObject(target, version)
    131         except jpype.JavaException as ex:
     131        except jpype.JException as ex:
    132132            self._handle_exception(ex)
    133133        return target_obj
     
    148148        try:
    149149            option = self._compiler.getBooleanOption(key)
    150         except jpype.JavaException as ex:
     150        except jpype.JException as ex:
    151151            self._handle_exception(ex)
    152152        return bool(option)
     
    171171        try:
    172172            self._compiler.setBooleanOption(key, value)
    173         except jpype.JavaException as ex:
     173        except jpype.JException as ex:
    174174            self._handle_exception(ex)
    175175       
     
    189189        try:
    190190            option = self._compiler.getIntegerOption(key)
    191         except jpype.JavaException as ex:
     191        except jpype.JException as ex:
    192192            self._handle_exception(ex)
    193193        return option
     
    212212        try:
    213213            self._compiler.setIntegerOption(key, value)
    214         except jpype.JavaException as ex:
     214        except jpype.JException as ex:
    215215            self._handle_exception(ex)
    216216       
     
    230230        try:
    231231            option = self._compiler.getRealOption(key)
    232         except jpype.JavaException as ex:
     232        except jpype.JException as ex:
    233233            self._handle_exception(ex)
    234234        return option
     
    253253        try:
    254254            self._compiler.setRealOption(key, value)
    255         except jpype.JavaException as ex:
     255        except jpype.JException as ex:
    256256            self._handle_exception(ex)
    257257                   
     
    271271        try:
    272272            option = self._compiler.getStringOption(key)
    273         except jpype.JavaException as ex:
     273        except jpype.JException as ex:
    274274            self._handle_exception(ex)
    275275        return str(option)
     
    294294        try:
    295295            self._compiler.setStringOption(key, value)
    296         except jpype.JavaException as ex:
     296        except jpype.JException as ex:
    297297            self._handle_exception(ex)
    298298       
     
    316316                java_warning.beginColumn(), \
    317317                java_warning.message() \
    318             ));
     318            ))
    319319        return warnings
    320320       
     
    361361            unit = self._compiler.compileUnit(class_name, file_name, target, version, compile_to)
    362362            self._compiler.closeLogger()
    363         except jpype.JavaException as ex:
     363        except jpype.JException as ex:
    364364            self._handle_exception(ex)
    365365        from .compiler import CompilerResult
     
    401401            sr = self._compiler.parseModel(model_file_name)
    402402            return sr       
    403         except jpype.JavaException as ex:
     403        except jpype.JException as ex:
    404404            self._handle_exception(ex)
    405405
     
    439439            ipr = self._compiler.instantiateModel(source_root, model_class_name, target)
    440440            return ipr   
    441         except jpype.JavaException as ex:
     441        except jpype.JException as ex:
    442442            self._handle_exception(ex)
    443443
     
    477477            fclass = self._compiler.flattenModel(inst_class_decl, target, None)
    478478            return fclass   
    479         except jpype.JavaException as ex:
     479        except jpype.JException as ex:
    480480            self._handle_exception(ex)
    481481
     
    507507        try:
    508508            self._compiler.generateCode(fclass, target)
    509         except jpype.JavaException as ex:
     509        except jpype.JException as ex:
    510510            self._handle_exception(ex)
    511511           
     
    625625        try:
    626626            options = OptimicaCompilerInterface.createOptions()
    627         except jpype.JavaException as ex:
     627        except jpype.JException as ex:
    628628            self._handle_exception(ex)
    629629           
     
    651651        try:
    652652            self._compiler.setBooleanOption(key, value)
    653         except jpype.JavaException as ex:
    654             self._handle_exception(ex)
     653        except jpype.JException as ex:
     654            self._handle_exception(ex)
Note: See TracChangeset for help on using the changeset viewer.