Bug 1016154 - python exceptions returned from libpwquality do not contain expected named members
python exceptions returned from libpwquality do not contain expected named me...
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: libpwquality (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Tomas Mraz
Fedora Extras Quality Assurance
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-07 11:43 EDT by David Shea
Modified: 2017-06-05 09:12 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-06-05 09:12:35 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description David Shea 2013-10-07 11:43:17 EDT
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 05:32:00 EDT
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 10:22:43 EDT
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 09:28:54 EDT
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 10:30:56 EDT
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 09:12:35 EDT
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.