Skip to content

Commit 42a2878

Browse files
committed
Don't use sys.exit(), re-raise ImportError instead
1 parent ae21ada commit 42a2878

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

pyrogram/connection/transport/tcp/tcp.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@
1818

1919
import logging
2020
import socket
21-
import sys
2221
from collections import namedtuple
2322

2423
try:
2524
import socks
26-
except ImportError:
27-
sys.exit(
25+
except ImportError as e:
26+
e.msg = (
2827
"PySocks is missing and Pyrogram can't run without. "
2928
"Please install it using \"pip3 install pysocks\"."
3029
)
3130

31+
raise e
32+
3233
log = logging.getLogger(__name__)
3334

3435
Proxy = namedtuple("Proxy", ["enabled", "hostname", "port", "username", "password"])

pyrogram/crypto/aes.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,18 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
import sys
20-
2119
try:
2220
import tgcrypto
23-
except ImportError:
24-
sys.exit(
21+
except ImportError as e:
22+
e.msg = (
2523
"TgCrypto is missing and Pyrogram can't run without. "
2624
"Please install it using \"pip3 install tgcrypto\". "
2725
"More info: https://docs.pyrogram.ml/resources/TgCrypto"
2826
)
2927

28+
raise e
29+
3030

31-
# TODO: Ugly IFs
3231
class AES:
3332
@classmethod
3433
def ige_encrypt(cls, data: bytes, key: bytes, iv: bytes) -> bytes:

0 commit comments

Comments
 (0)