mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 03:13:45 +03:00
Remove 3.7 workarounds
This commit is contained in:
parent
be6508dc5d
commit
691160bd92
|
@ -263,15 +263,14 @@ class Connection(abc.ABC):
|
||||||
|
|
||||||
if self._writer:
|
if self._writer:
|
||||||
self._writer.close()
|
self._writer.close()
|
||||||
if sys.version_info >= (3, 7):
|
try:
|
||||||
try:
|
await self._writer.wait_closed()
|
||||||
await self._writer.wait_closed()
|
except Exception as e:
|
||||||
except Exception as e:
|
# Disconnecting should never raise. Seen:
|
||||||
# Disconnecting should never raise. Seen:
|
# * OSError: No route to host and
|
||||||
# * OSError: No route to host and
|
# * OSError: [Errno 32] Broken pipe
|
||||||
# * OSError: [Errno 32] Broken pipe
|
# * ConnectionResetError
|
||||||
# * ConnectionResetError
|
self._log.info('%s during disconnect: %s', type(e), e)
|
||||||
self._log.info('%s during disconnect: %s', type(e), e)
|
|
||||||
|
|
||||||
def send(self, data):
|
def send(self, data):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import sys
|
|
||||||
|
|
||||||
from ._custom import (
|
from ._custom import (
|
||||||
ReadCancelledError,
|
ReadCancelledError,
|
||||||
TypeNotFoundError,
|
TypeNotFoundError,
|
||||||
|
@ -25,24 +23,6 @@ from ._rpcbase import (
|
||||||
_mk_error_type
|
_mk_error_type
|
||||||
)
|
)
|
||||||
|
|
||||||
if sys.version_info < (3, 7):
|
# https://www.python.org/dev/peps/pep-0562/
|
||||||
# https://stackoverflow.com/a/7668273/
|
def __getattr__(name):
|
||||||
class _TelethonErrors:
|
return _mk_error_type(name=name)
|
||||||
def __init__(self, _mk_error_type, everything):
|
|
||||||
self._mk_error_type = _mk_error_type
|
|
||||||
self.__dict__.update({
|
|
||||||
k: v
|
|
||||||
for k, v in everything.items()
|
|
||||||
if isinstance(v, type) and issubclass(v, Exception)
|
|
||||||
})
|
|
||||||
|
|
||||||
def __getattr__(self, name):
|
|
||||||
return self._mk_error_type(name=name)
|
|
||||||
|
|
||||||
sys.modules[__name__] = _TelethonErrors(_mk_error_type, globals())
|
|
||||||
else:
|
|
||||||
# https://www.python.org/dev/peps/pep-0562/
|
|
||||||
def __getattr__(name):
|
|
||||||
return _mk_error_type(name=name)
|
|
||||||
|
|
||||||
del sys
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user