Skip to content

Commit e37d449

Browse files
committedAug 22, 2024
Switch to log.warning instead of log.warn
log.warn is removed in Python 3.13 Close #1098
1 parent 7bc85b3 commit e37d449

13 files changed

+95
-94
lines changed
 

‎autobahn/asyncio/component.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def start(self, loop=None):
304304
"""
305305

306306
if loop is None:
307-
self.log.warn("Using default loop")
307+
self.log.warning("Using default loop")
308308
loop = asyncio.get_event_loop()
309309

310310
return self._start(loop=loop)

‎autobahn/asyncio/rawsocket.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def _on_handshake_complete(self):
303303
self._session.onOpen(self)
304304
except Exception as e:
305305
# Exceptions raised in onOpen are fatal ..
306-
self.log.warn("WampRawSocketProtocol: ApplicationSession constructor / onOpen raised ({err})", err=e)
306+
self.log.warning("WampRawSocketProtocol: ApplicationSession constructor / onOpen raised ({err})", err=e)
307307
self.abort()
308308
else:
309309
self.log.info("ApplicationSession started.")
@@ -316,11 +316,11 @@ def stringReceived(self, payload):
316316
self._session.onMessage(msg)
317317

318318
except ProtocolError as e:
319-
self.log.warn("WampRawSocketProtocol: WAMP Protocol Error ({err}) - aborting connection", err=e)
319+
self.log.warning("WampRawSocketProtocol: WAMP Protocol Error ({err}) - aborting connection", err=e)
320320
self.abort()
321321

322322
except Exception as e:
323-
self.log.warn("WampRawSocketProtocol: WAMP Internal Error ({err}) - aborting connection", err=e)
323+
self.log.warning("WampRawSocketProtocol: WAMP Internal Error ({err}) - aborting connection", err=e)
324324
self.abort()
325325

326326
def send(self, msg):
@@ -360,7 +360,7 @@ def _on_connection_lost(self, exc):
360360
self._session.onClose(wasClean)
361361
except Exception as e:
362362
# silently ignore exceptions raised here ..
363-
self.log.warn("WampRawSocketProtocol: ApplicationSession.onClose raised ({err})", err=e)
363+
self.log.warning("WampRawSocketProtocol: ApplicationSession.onClose raised ({err})", err=e)
364364
self._session = None
365365

366366
def close(self):

‎autobahn/twisted/choosereactor.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ def install_optimal_reactor(require_optimal_reactor=True):
9494
from twisted.internet import kqreactor
9595
kqreactor.install()
9696
except:
97-
log.warn('Running on *BSD or MacOSX, but cannot install kqueue Twisted reactor: {tb}', tb=traceback.format_exc())
97+
log.warning('Running on *BSD or MacOSX, but cannot install kqueue Twisted reactor: {tb}', tb=traceback.format_exc())
9898
else:
9999
log.debug('Running on *BSD or MacOSX and optimal reactor (kqueue) was installed.')
100100
else:
101-
log.warn('Running on *BSD or MacOSX, but cannot install kqueue Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor)
101+
log.warning('Running on *BSD or MacOSX, but cannot install kqueue Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor)
102102
if require_optimal_reactor:
103103
raise ReactorAlreadyInstalledError()
104104
else:
@@ -114,11 +114,11 @@ def install_optimal_reactor(require_optimal_reactor=True):
114114
from twisted.internet.iocpreactor import reactor as iocpreactor
115115
iocpreactor.install()
116116
except:
117-
log.warn('Running on Windows, but cannot install IOCP Twisted reactor: {tb}', tb=traceback.format_exc())
117+
log.warning('Running on Windows, but cannot install IOCP Twisted reactor: {tb}', tb=traceback.format_exc())
118118
else:
119119
log.debug('Running on Windows and optimal reactor (ICOP) was installed.')
120120
else:
121-
log.warn('Running on Windows, but cannot install IOCP Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor)
121+
log.warning('Running on Windows, but cannot install IOCP Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor)
122122
if require_optimal_reactor:
123123
raise ReactorAlreadyInstalledError()
124124
else:
@@ -134,11 +134,11 @@ def install_optimal_reactor(require_optimal_reactor=True):
134134
from twisted.internet import epollreactor
135135
epollreactor.install()
136136
except:
137-
log.warn('Running on Linux, but cannot install Epoll Twisted reactor: {tb}', tb=traceback.format_exc())
137+
log.warning('Running on Linux, but cannot install Epoll Twisted reactor: {tb}', tb=traceback.format_exc())
138138
else:
139139
log.debug('Running on Linux and optimal reactor (epoll) was installed.')
140140
else:
141-
log.warn('Running on Linux, but cannot install Epoll Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor)
141+
log.warning('Running on Linux, but cannot install Epoll Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor)
142142
if require_optimal_reactor:
143143
raise ReactorAlreadyInstalledError()
144144
else:
@@ -156,11 +156,11 @@ def install_optimal_reactor(require_optimal_reactor=True):
156156
# from twisted.internet import default as defaultreactor
157157
# defaultreactor.install()
158158
except:
159-
log.warn('Running on "{platform}", but cannot install Select Twisted reactor: {tb}', tb=traceback.format_exc(), platform=sys.platform)
159+
log.warning('Running on "{platform}", but cannot install Select Twisted reactor: {tb}', tb=traceback.format_exc(), platform=sys.platform)
160160
else:
161161
log.debug('Running on "{platform}" and optimal reactor (Select) was installed.', platform=sys.platform)
162162
else:
163-
log.warn('Running on "{platform}", but cannot install Select Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor, platform=sys.platform)
163+
log.warning('Running on "{platform}", but cannot install Select Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor, platform=sys.platform)
164164
if require_optimal_reactor:
165165
raise ReactorAlreadyInstalledError()
166166
else:

‎autobahn/twisted/component.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def start(self, reactor=None):
329329
"done" or with a Failure if something went wrong.
330330
"""
331331
if reactor is None:
332-
self.log.warn("Using default reactor")
332+
self.log.warning("Using default reactor")
333333
from twisted.internet import reactor
334334

335335
return self._start(loop=reactor)
@@ -370,7 +370,7 @@ def done_callback(reactor, arg):
370370
if isinstance(arg, Failure):
371371
log.error('Something went wrong: {log_failure}', failure=arg)
372372
try:
373-
log.warn('Stopping reactor ..')
373+
log.warning('Stopping reactor ..')
374374
reactor.stop()
375375
except ReactorNotRunning:
376376
pass

‎autobahn/twisted/rawsocket.py

+24-23
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,12 @@ def _on_handshake_complete(self):
130130
res = self._session.onOpen(self)
131131
except Exception as e:
132132
# Exceptions raised in onOpen are fatal ..
133-
self.log.warn("{klass}._on_handshake_complete(): ApplicationSession constructor / onOpen raised ({err})",
134-
klass=self.__class__.__name__, err=e)
133+
self.log.warning("{klass}._on_handshake_complete(): ApplicationSession constructor / onOpen raised ({err})",
134+
klass=self.__class__.__name__, err=e)
135135
self.abort()
136136
else:
137-
self.log.debug('{klass}._on_handshake_complete(): {session} started (res={res}).', klass=self.__class__.__name__,
137+
self.log.debug('{klass}._on_handshake_complete(): {session} started (res={res}).',
138+
klass=self.__class__.__name__,
138139
session=self._session, res=res)
139140

140141
def connectionLost(self, reason):
@@ -146,8 +147,8 @@ def connectionLost(self, reason):
146147
self._session.onClose(wasClean)
147148
except Exception as e:
148149
# silently ignore exceptions raised here ..
149-
self.log.warn('{klass}.connectionLost(): ApplicationSession.onClose raised "{err}"',
150-
klass=self.__class__.__name__, err=e)
150+
self.log.warning('{klass}.connectionLost(): ApplicationSession.onClose raised "{err}"',
151+
klass=self.__class__.__name__, err=e)
151152
self._session = None
152153

153154
def stringReceived(self, payload):
@@ -165,34 +166,34 @@ def stringReceived(self, payload):
165166
err=e)
166167

167168
except InvalidUriError as e:
168-
self.log.warn("{klass}.stringReceived: WAMP InvalidUriError - aborting connection!\n{err}",
169-
klass=self.__class__.__name__,
170-
err=e)
169+
self.log.warning("{klass}.stringReceived: WAMP InvalidUriError - aborting connection!\n{err}",
170+
klass=self.__class__.__name__,
171+
err=e)
171172
self.abort()
172173

173174
except ProtocolError as e:
174-
self.log.warn("{klass}.stringReceived: WAMP ProtocolError - aborting connection!\n{err}",
175-
klass=self.__class__.__name__,
176-
err=e)
175+
self.log.warning("{klass}.stringReceived: WAMP ProtocolError - aborting connection!\n{err}",
176+
klass=self.__class__.__name__,
177+
err=e)
177178
self.abort()
178179

179180
except PayloadExceededError as e:
180-
self.log.warn("{klass}.stringReceived: WAMP PayloadExceededError - aborting connection!\n{err}",
181-
klass=self.__class__.__name__,
182-
err=e)
181+
self.log.warning("{klass}.stringReceived: WAMP PayloadExceededError - aborting connection!\n{err}",
182+
klass=self.__class__.__name__,
183+
err=e)
183184
self.abort()
184185

185186
except SerializationError as e:
186-
self.log.warn("{klass}.stringReceived: WAMP SerializationError - aborting connection!\n{err}",
187-
klass=self.__class__.__name__,
188-
err=e)
187+
self.log.warning("{klass}.stringReceived: WAMP SerializationError - aborting connection!\n{err}",
188+
klass=self.__class__.__name__,
189+
err=e)
189190
self.abort()
190191

191192
except Exception as e:
192193
self.log.failure()
193-
self.log.warn("{klass}.stringReceived: WAMP Exception - aborting connection!\n{err}",
194-
klass=self.__class__.__name__,
195-
err=e)
194+
self.log.warning("{klass}.stringReceived: WAMP Exception - aborting connection!\n{err}",
195+
klass=self.__class__.__name__,
196+
err=e)
196197
self.abort()
197198

198199
def send(self, msg):
@@ -212,7 +213,7 @@ def send(self, msg):
212213
if 0 < self._max_len_send < payload_len:
213214
emsg = 'tried to send RawSocket message with size {} exceeding payload limit of {} octets'.format(
214215
payload_len, self._max_len_send)
215-
self.log.warn(emsg)
216+
self.log.warning(emsg)
216217
raise PayloadExceededError(emsg)
217218
else:
218219
self.sendString(payload)
@@ -279,7 +280,7 @@ def dataReceived(self, data):
279280
#
280281
_magic = ord(self._handshake_bytes[0:1])
281282
if _magic != 127:
282-
self.log.warn(
283+
self.log.warning(
283284
"WampRawSocketServerProtocol: invalid magic byte (octet 1) in"
284285
" opening handshake: was {magic}, but expected 127",
285286
magic=_magic,
@@ -306,7 +307,7 @@ def dataReceived(self, data):
306307
serializer=ser_id,
307308
)
308309
else:
309-
self.log.warn(
310+
self.log.warning(
310311
"WampRawSocketServerProtocol: opening handshake - no suitable serializer found (client requested {serializer}, and we have {serializers}",
311312
serializer=ser_id,
312313
serializers=self.factory._serializers.keys(),

‎autobahn/wamp/component.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def transport_check(_):
706706
break
707707

708708
delay = transport.next_delay()
709-
self.log.warn(
709+
self.log.warning(
710710
'trying transport {transport_idx} ("{transport_url}") using connect delay {transport_delay}',
711711
transport_idx=transport.idx,
712712
transport_url=transport.url,
@@ -831,7 +831,7 @@ def on_disconnect(session, was_clean):
831831
)
832832
if not txaio.is_called(done):
833833
if not was_clean:
834-
self.log.warn(
834+
self.log.warning(
835835
"Session disconnected uncleanly"
836836
)
837837
else:

0 commit comments

Comments
 (0)