Skip to content

Commit a77d7a5

Browse files
committed
(issue 17452 / ftplib) fix TypeError occurring in case ssl module is not installed
1 parent 0351928 commit a77d7a5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Lib/ftplib.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def retrbinary(self, cmd, callback, blocksize=8192, rest=None):
440440
break
441441
callback(data)
442442
# shutdown ssl layer
443-
if isinstance(conn, _SSLSocket):
443+
if _SSLSocket is not None and isinstance(conn, _SSLSocket):
444444
conn.unwrap()
445445
return self.voidresp()
446446

@@ -473,7 +473,7 @@ def retrlines(self, cmd, callback = None):
473473
line = line[:-1]
474474
callback(line)
475475
# shutdown ssl layer
476-
if isinstance(conn, _SSLSocket):
476+
if _SSLSocket is not None and isinstance(conn, _SSLSocket):
477477
conn.unwrap()
478478
return self.voidresp()
479479

@@ -502,7 +502,7 @@ def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
502502
if callback:
503503
callback(buf)
504504
# shutdown ssl layer
505-
if isinstance(conn, _SSLSocket):
505+
if _SSLSocket is not None and isinstance(conn, _SSLSocket):
506506
conn.unwrap()
507507
return self.voidresp()
508508

@@ -531,7 +531,7 @@ def storlines(self, cmd, fp, callback=None):
531531
if callback:
532532
callback(buf)
533533
# shutdown ssl layer
534-
if isinstance(conn, _SSLSocket):
534+
if _SSLSocket is not None and isinstance(conn, _SSLSocket):
535535
conn.unwrap()
536536
return self.voidresp()
537537

0 commit comments

Comments
 (0)