ndokter / dsmr_parser

Library to parse Dutch Smart Meter Requirements (DSMR) telegrams.
MIT License
110 stars 64 forks source link

"TypeError: 'str' object is not callable" in filereader.py #127

Open gsaviane opened 1 year ago

gsaviane commented 1 year ago

I'm using FileReader to read telegrams from stdin. If a telegram has a checksum error it throws an exception, but the exception handling throws this:

Traceback (most recent call last):

File "/home/pi/dsmr2mqtt.py", line 101, in for telegram in telegrams: File "/home/pi/.local/lib/python3.9/site-packages/dsmr_parser/clients/filereader.py", line 126, in read_as_object logger.warning(str(e)) TypeError: 'str' object is not callable

I'm not a Pyhon expert, but it seems the str object gets overridden (lines 116-128 of filereader.py):

    with fileinput.input(mode='rb') as file_handle:
        while True:
            data = file_handle.readline()
            str = data.decode()
            self.telegram_buffer.append(str)

            for telegram in self.telegram_buffer.get_all():
                try:
                    yield Telegram(telegram, self.telegram_parser, self.telegram_specification)
                except InvalidChecksumError as e:
                    logger.warning(str(e))
                except ParseError as e:
                    logger.error('Failed to parse telegram: %s', e)
ndokter commented 1 year ago

Thank you for bringing this up. This however is caused by the same issue as #122

Im currently almost done with changes in https://github.com/ndokter/dsmr_parser/pull/121 which should also fix this issue

ndokter commented 1 year ago

I'm sorry, i misread. This should indeed be fixed