4 Replies - 318 Views - Last Post: 20 November 2019 - 02:37 PM Rate Topic: -----

#1 kam536   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 21-March 18

B110: try_except_pass

Posted 17 November 2019 - 08:05 PM

def integer():
    firstInteger = int(input("\nEnter your first integer: "))
    secondInteger = int(input("\nEnter your second integer: "))
    try:
        print("\nThe dividen of ", firstInteger, "and", secondInteger, \
    "is", firstInteger / secondInteger, ".")
    except Exception:
         pass


integer()




How do you get this code to cause a B110: try_except_pass error?
I have bandit installed already.

Is This A Good Question/Topic? 0
  • +

Replies To: B110: try_except_pass

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,605
  • Joined: 12-June 08

Re: B110: try_except_pass

Posted 17 November 2019 - 09:26 PM

Always a fan of dividing by zero.
Was This Post Helpful? 0
  • +
  • -

#3 kam536   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 21-March 18

Re: B110: try_except_pass

Posted 19 November 2019 - 10:08 PM

View Postmodi123_1, on 17 November 2019 - 09:26 PM, said:

Always a fan of dividing by zero.


Should have said I divided by 0 as well.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,605
  • Joined: 12-June 08

Re: B110: try_except_pass

Posted 19 November 2019 - 10:38 PM

Then I guess you are not providing enough information? Divide by zero always causes an exception.

Case in point:

import sys
a = 1
b = 0
try:
    c = a / b
    pass
except :
    print(sys.exc_info())
    pass



https://docs.python....ption-hierarchy
Was This Post Helpful? 0
  • +
  • -

#5 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 3000
  • View blog
  • Posts: 11,550
  • Joined: 03-December 12

Re: B110: try_except_pass

Posted 20 November 2019 - 02:37 PM

It should already be causing that error. If the plan is to use Bandit, then it is looking specifically for the pass in the catch, not actually throwing or not throwing anything.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1