[Pkg-javascript-devel] Bug#963320: libtgvoip: FTBFS: AttributeError: module 'string' has no attribute 'maketrans'

Nicholas Guriev nicholas at guriev.su
Fri Nov 6 21:23:40 GMT 2020


On Fri, 2020-11-06 at 22:06 +0100, Xavier wrote:
> sorry, I launched a full rebuild in unstable and didn't see this change.
> However I don't understand this error (I'm not Python dev), code is:
> 
>  try:
>    # maketrans moved to str in python3.
>    _maketrans = string.maketrans
>  except NameError:
>    _maketrans = str.maketrans
> 
> So error should be discarded, isn't it?

It seems wrong exception is handled here. NameError[1] happens when
unknown top-level variable is referenced. However, above this line,
there is importing of string module. So NameError is not possible here.
I daresay an original author meant AttributeError[2] here that is raised
when code is trying to get non-existent attribute (a thing after dot).

I suggest replace NameError with AttributeError:

   try:
     # maketrans moved to str in python3.
     _maketrans = string.maketrans
   except AttributeError:
     _maketrans = str.maketrans

(not tested)

 [1]: https://docs.python.org/3/library/exceptions.html#NameError
 [2]: https://docs.python.org/3/library/exceptions.html#AttributeError

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://alioth-lists.debian.net/pipermail/pkg-javascript-devel/attachments/20201107/66d4c7fd/attachment.sig>


More information about the Pkg-javascript-devel mailing list