[tor-commits] [stem/master] Fix: Don't overwrite type in ConnectionBandwidthEvent. Otherwise listeners for the event don't work. Add new conn_type attribute.
atagar at torproject.org
atagar at torproject.org
Fri Mar 31 17:15:28 UTC 2017
commit 8851a5a5c73d5f4998faf1d2fde617d3f61530cf
Author: Timon Hackenjos <timon.hackenjos at student.kit.edu>
Date: Sun Mar 19 17:10:07 2017 +0100
Fix: Don't overwrite type in ConnectionBandwidthEvent. Otherwise listeners for the event don't work. Add new conn_type attribute.
---
stem/response/events.py | 10 +++++-----
test/unit/response/events.py | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/stem/response/events.py b/stem/response/events.py
index 320e6e9..1691ebf 100644
--- a/stem/response/events.py
+++ b/stem/response/events.py
@@ -1113,14 +1113,14 @@ class ConnectionBandwidthEvent(Event):
.. versionadded:: 1.2.0
:var str id: connection identifier
- :var stem.ConnectionType type: connection type
+ :var stem.ConnectionType conn_type: connection type
:var long read: bytes received by tor that second
:var long written: bytes sent by tor that second
"""
_KEYWORD_ARGS = {
'ID': 'id',
- 'TYPE': 'type',
+ 'TYPE': 'conn_type',
'READ': 'read',
'WRITTEN': 'written',
}
@@ -1130,8 +1130,8 @@ class ConnectionBandwidthEvent(Event):
def _parse(self):
if not self.id:
raise stem.ProtocolError('CONN_BW event is missing its id')
- elif not self.type:
- raise stem.ProtocolError('CONN_BW event is missing its type')
+ elif not self.conn_type:
+ raise stem.ProtocolError('CONN_BW event is missing its connection type')
elif not self.read:
raise stem.ProtocolError('CONN_BW event is missing its read value')
elif not self.written:
@@ -1144,7 +1144,7 @@ class ConnectionBandwidthEvent(Event):
self.read = int_type(self.read)
self.written = int_type(self.written)
- self._log_if_unrecognized('type', stem.ConnectionType)
+ self._log_if_unrecognized('conn_type', stem.ConnectionType)
class CircuitBandwidthEvent(Event):
diff --git a/test/unit/response/events.py b/test/unit/response/events.py
index 908ec57..8a95156 100644
--- a/test/unit/response/events.py
+++ b/test/unit/response/events.py
@@ -1416,7 +1416,7 @@ class TestEvents(unittest.TestCase):
self.assertTrue(isinstance(event, stem.response.events.ConnectionBandwidthEvent))
self.assertEqual(CONN_BW.lstrip('650 '), str(event))
self.assertEqual('11', event.id)
- self.assertEqual(stem.ConnectionType.DIR, event.type)
+ self.assertEqual(stem.ConnectionType.DIR, event.conn_type)
self.assertEqual(272, event.read)
self.assertEqual(817, event.written)
More information about the tor-commits
mailing list