Don't compare `stream_id` to zero, and don't do identity checking on `has_stream`. This would be better as:

```python
if ((self.has_stream and not self.stream_id) or
    (self.stream_id and not self.has_stream)):
```