[docs] Fwd: Doc suggestions re exceptions

Georg Brandl georg at python.org
Thu Jun 5 11:46:40 CEST 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1




- -------- Original Message --------
Subject: Doc suggestions re exceptions
Date: Thu, 5 Jun 2014 10:07:37 +0100
From: Mark Summerfield <mark at qtrac.eu>
Organization: Qtrac Ltd.
To: Georg Brandl <georg at python.org>

Hi Georg,

If you look on this page:
https://docs.python.org/3.4/library/getpass.html#module-getpass

The docs for getpass.getuser() say

"...otherwise, an exception is raised."

But does not specify what that exception might be. So now people must
write the catch all

    try:
	user = getpass.getuser()
    except:
	# handle failure

I think as a matter of policy, if a function or method can raise
exceptions, the specific ones (or their base type) should be mentioned
in the documentation so that people can catch just those and not use a
catch-all which might hide bugs.

Thanks!
- -- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    Python and PyQt/PySide - training and consultancy
        "Python in Practice" - ISBN 978-0321905635
            http://www.qtrac.eu/pipbook.html



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iEYEARECAAYFAlOQPIAACgkQN9GcIYhpnLB6AgCdF2PiYLt3dLYO20pP2Uf/Q1pR
K6gAnAnp4JJGqXXHXJOGVw2q9jMllrS1
=2+h5
-----END PGP SIGNATURE-----


More information about the docs mailing list