Skip to content

Conversation

@jfly
Copy link

@jfly jfly commented Dec 29, 2021

Trying to access self._scenes_cache only works after self.scenes()
has been invoked. Normally, the previous line of code (assert scene_name in self.scenes()) would cause an invocation of
self.scenes() (and thereby populate self._scenes_cache), but that
doesn't actually happen if assertions are disabled!

Before this change

$ PYTHONOPTIMIZE=1 python -c 'import rxv; rxv.RXV("http://receiver/YamahaRemoteControl/ctrl").scene = "BD/DVD"; print("success!")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jeremy/src/github.com/wuub/rxv/rxv/rxv.py", line 457, in scene
    scene_number = self._scenes_cache.get(scene_name)
AttributeError: 'NoneType' object has no attribute 'get'

After this change

$ PYTHONOPTIMIZE=1 python -c 'import rxv; rxv.RXV("http://receiver/YamahaRemoteControl/ctrl").scene = "BD/DVD"; print("success!")'
success!

Trying to access `self._scenes_cache` only works after `self.scenes()`
has been invoked. Normally, the previous line of code (`assert
scene_name in self.scenes()`) would cause an invocation of
`self.scenes()` (and thereby populate `self._scenes_cache`), but that
doesn't actually happen if assertions are disabled!

Before this change
==================

    $ PYTHONOPTIMIZE=1 python -c 'import rxv; rxv.RXV("http://receiver/YamahaRemoteControl/ctrl").scene = "BD/DVD"; print("success!")'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/jeremy/src/github.com/wuub/rxv/rxv/rxv.py", line 457, in scene
        scene_number = self._scenes_cache.get(scene_name)
    AttributeError: 'NoneType' object has no attribute 'get'

After this change
=================

    $ PYTHONOPTIMIZE=1 python -c 'import rxv; rxv.RXV("http://receiver/YamahaRemoteControl/ctrl").scene = "BD/DVD"; print("success!")'
    success!
@jfly
Copy link
Author

jfly commented May 4, 2022

@wuub any chance of getting this merged up?

@jfly
Copy link
Author

jfly commented Oct 29, 2023

@wuub quick ping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant