digidotcom / xbee-python

Python library to interact with Digi International's XBee radio frequency modules.
Mozilla Public License 2.0
185 stars 93 forks source link

except TimeoutException, ex: #286

Closed bocephasj closed 1 year ago

bocephasj commented 1 year ago

I am getting a syntax error - except TimeoutException, ex: - python 3.9 says syntax error @ comma in this statement in base.py of xbee library. Does anyone know why?

ignore timeouts, but this allows the thread to be responsive rather

        # than blocking indefinitely on read
        except TimeoutException, ex:
            if ex.args: log.debug("Packet timeout after %s bytes", ex)
tatianaleon commented 1 year ago

Hi @bocephasj,

base.py does not include any code similar to that. If this is your code, use parenthesis for multiple exceptions or remove the comma for a single exception and as word to assign the exception to a variable:

    try:
        [...]
    except TimeoutException as ex:
        print(ex)

See https://docs.python.org/3.9/tutorial/errors.html#handling-exceptions and https://docs.python.org/3.9/reference/compound_stmts.html#except