Travis CI: Don’t allow bare exceptions (#1734) · zinating/algorithms-python@670f952 · GitHub
Skip to content

Commit 670f952

Browse files
cclausspoyea
andauthored
Travis CI: Don’t allow bare exceptions (TheAlgorithms#1734)
* Travis CI: Don’t allow bare exceptions * fixup! Format Python code with psf/black push * except IOError: * except IOError: * Update hamming_code.py * IndexError * Get rid of the nonsense logic Co-authored-by: John Law <johnlaw.po@gmail.com>
1 parent f52b97f commit 670f952

5 files changed

Lines changed: 10 additions & 12 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion

ciphers/transposition_cipher.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import math
22

3-
'''
3+
"""
44
In cryptography, the TRANSPOSITION cipher is a method of encryption where the
55
positions of plaintext are shifted a certain number(determined by the key) that
66
follows a regular system that results in the permuted text, known as the encrypted
77
text. The type of transposition cipher demonstrated under is the ROUTE cipher.
8-
'''
8+
"""
9+
10+
911
def main():
1012
message = input("Enter message: ")
1113
key = int(input("Enter key [2-%s]: " % (len(message) - 1)))

ciphers/xor_cipher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def encrypt_file(self, file, key=0):
148148
for line in fin:
149149
fout.write(self.encrypt_string(line, key))
150150

151-
except:
151+
except IOError:
152152
return False
153153

154154
return True
@@ -173,7 +173,7 @@ def decrypt_file(self, file, key):
173173
for line in fin:
174174
fout.write(self.decrypt_string(line, key))
175175

176-
except:
176+
except IOError:
177177
return False
178178

179179
return True

hashes/hamming_code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def emitterConverter(sizePar, data):
125125
if x != None:
126126
try:
127127
aux = (binPos[contLoop])[-1 * (bp)]
128-
except:
128+
except IndexError:
129129
aux = "0"
130130
if aux == "1":
131131
if x == "1":
@@ -229,7 +229,7 @@ def receptorConverter(sizePar, data):
229229
if x != None:
230230
try:
231231
aux = (binPos[contLoop])[-1 * (bp)]
232-
except:
232+
except IndexError:
233233
aux = "0"
234234
if aux == "1":
235235
if x == "1":

linear_algebra/src/test_linear_algebra.py

Lines changed: 1 addition & 5 deletions

0 commit comments

Comments
 (0)