Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Line output does not match traceback output #38

@spacemanspiff2007

Description

@spacemanspiff2007

I've observed a very strange phenomenon today.
Additionally to the prettified traceback I include the normal traceback since the stack data is only generated for some files.
The line numbers were both times the same, but the shown code (the line content) of stack_data was wrong.
I've included an additional assert statement and the python code gets reloaded during runtime with runpy.run_path

What stack_data produces for line 68:

--------------------------------------------------------------------------------
      64 |     i = self.out_rgb
      65 |     r, g, b = self.out_rgb.get_rgb(max_rgb_value=100)
      66 |     self.logger.debug(f'Color: {i.hue:3.0f},{i.saturation:3.0f},{i.brightness:3.0f} ({r:3.0f},{g:3.0f},{b:3.0f})')
 -->  68 | async def leistung_change(self, event: ValueChangeEvent):
      69 |     self.logger.debug(f'{self.power.value:4.1f}W')
    ------------------------------------------------------------

Traceback for line 68:

 Traceback (most recent call last):
   File "/opt/habapp/rules/code.py", line 68, in rgb_out_change
     assert isinstance(value, tuple) or value is 'ON' or value is 'OFF'
 AssertionError

Code that produced the exception (line 68 is the assert statement)

    async def rgb_out_change(self, event: ValueChangeEvent):
        value = event.value
        assert isinstance(value, tuple) or value == 'ON' or value == 'OFF'
        self.out_rgb.oh_send_command(value)

    async def dimmer_rgb_change(self, event: ValueChangeEvent):
        i = self.out_rgb
        r, g, b = i.get_rgb()
        self.logger.debug(f'Color: {i.hue:3.0f},{i.saturation:3.0f},{i.brightness:3.0f} ({r:3.0f},{g:3.0f},{b:3.0f})')

Is there some kine of line cache that stores the line content?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions