Bug 1016154 - python exceptions returned from libpwquality do not contain expected named members
Summary: python exceptions returned from libpwquality do not contain expected named me...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: libpwquality
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Tomas Mraz
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-07 15:43 UTC by David Shea
Modified: 2017-06-05 13:12 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-06-05 13:12:35 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description David Shea 2013-10-07 15:43:17 UTC
Description of problem:
The Python exceptions raised in libpwquality set the exception value as a tuple of (error code, error descrption). PWQError does not define any attributes, so trying to access PWQError.message always returns an empty string.

PWQError derives from Exception, so it should provide a message attribute, either by using PyErr_SetString instead of PyErr_SetObject and adding the error code to the exception object elsewhere, or by setting the message attribute manually.

libpwquality also returns AttributeErrors with the value set to a tuple, same problem.


Steps to Reproduce:

from pwquality import PWQSettings, PWQError
try:
    PWQSettings().check("password", None, None)
except PWQError as e:
    # This should print something
    print(e.message)

Comment 1 Fedora End Of Life 2015-05-29 09:32:00 UTC
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 2 Tomas Mraz 2017-05-26 14:22:43 UTC
Is there a way how to fix this without breaking the compatibility with existing callers of the pwquality module?

Comment 3 David Shea 2017-05-30 13:28:54 UTC
Of course. The python2 exception types are already subscriptable, so an exception object could be created with the tuple items as the argument list and then the excepted attributes can be set on the object.

Comment 4 Tomas Mraz 2017-05-30 14:30:56 UTC
Is there any code example somewhere? Of course pull request on the github project would be the best but the example would be good enough.

https://github.com/libpwquality/libpwquality

Comment 5 Tomas Mraz 2017-06-05 13:12:35 UTC
So actually the message is deprecated in python >= 2.6 and dropped in python 3. I am wontfixing this.


Note You need to log in before you can comment on or make changes to this bug.