lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 11 Dec 2020 17:03:50 -0700
From:   Jonathan Corbet <corbet@....net>
To:     Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
Cc:     Linux Doc Mailing List <linux-doc@...r.kernel.org>,
        Masahiro Yamada <masahiroy@...nel.org>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Michal Marek <michal.lkml@...kovi.net>,
        linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-media@...r.kernel.org
Subject: Re: [PATCH RFC v2] docs: experimental: build PDF with rst2pdf

On Sat, 12 Dec 2020 00:54:35 +0100
Mauro Carvalho Chehab <mchehab+huawei@...nel.org> wrote:

> I'm not an usual python programmer, so, don't know much about its 
> specifics... Yet, I would be expecting that something like this:
> 
> 	try:
> 	    extensions.append("rst2pdf.pdfbuilder")
> 	except:
> 	    sys.stderr.write('rst2pdf extension not available.\n')
> 	
> 
> Would avoid it to crash, if the extension is not available.
> Silly me :-)

No, that's not going to do it, for a couple of reasons.  First being that
all it's doing is appending a string to a list, which pretty much always
succeeds.  The attempt to actually import the module happens later.

...and you won't catch that either because it isn't actually throwing an
exception, it's just noting the problem and giving up.

The right solution is probably something like this:

	try:
	    import rst2pdf
	    extensions.append('rst2pdf.pdfbuilder')
	except ModuleNotFoundError:
	    pass # no rst2pdf for you

This is totally untested, of course.

[Incidentally, a blank "except:" clause like the one you had is, in my
experience, a bad idea.  That will catch *anything*, leading to hiding all
kinds of bugs.  Not that I've ever committed such a faux pas and suffered
the consequences myself...no...never...honest...]

I'll mess with this a bit more later.

Thanks,

jon

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ