This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: logging messages about bad version numbers should include the project name
Type: Stage: resolved
Components: Distutils2 Versions: Python 3.3, 3rd party
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: alexis, eric.araujo, nick.wilson, sigi, tarek
Priority: normal Keywords: easy, patch

Created on 2012-05-10 23:14 by nick.wilson, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bad_version_number_with_name.patch sigi, 2012-05-14 20:39 review
Messages (8)
msg160381 - (view) Author: Nick Wilson (nick.wilson) * Date: 2012-05-10 23:14
IrrationalVersionError in packaging/distutils2 should include the name of the project responsible for the error. It currently only includes the version:

  >>> import packaging.pypi.xmlrpc
  >>> client = packaging.pypi.xmlrpc.Client()
  >>> client.search_projects('req')
  Irrational version error found: 0.0.0-prealpha
  Irrational version error found: 0.1dev-20110502
  ...
msg160383 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-05-10 23:40
Setting to easy for the next sprints.  To do: add an argument to the IrrationalVersion constructor, add a test to make sure the result of __str__ includes it, and adapt the rest of the codebase to pass the project name when the exception is raised.
msg160630 - (view) Author: Christoph Echtinger-Sieghart (sigi) * Date: 2012-05-14 15:52
I took a look at the code and I don't think that adding an argument to the IrrationalVersionError constructor is the right way to go. 

The exception is raised in places where we don't know for which project we are raising the exception (eg in packaging.version.NormalizedVersion).

Wouldn't it be better to make packaging.pypi.xmlrpc.Client just print the
package name with the exception?

I would be glad to contribute a patch.
msg160632 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-05-14 16:11
You are right.  When the NormalizedVersion class is used standalone, there is no project name to pass, so it is the responsibility of higher-level code (the Metadata class I think here) to raise or log messages including the project name.

To make a patch, you can use the hg.python.org/distutils2 repo (also mirrored on Bitbucket under the python_mirrors user account for easing cloning) or the CPython repository.  Thanks!
msg160634 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-05-14 16:12
BTW there could be an optional argument in the exception constructor for the project name, but that does not seem clean to me.
msg160659 - (view) Author: Christoph Echtinger-Sieghart (sigi) * Date: 2012-05-14 19:55
The optional argument approach doesn't seem clean to me either. 

I think the correct approach is - as you wrote - to change the higher level code to include the project name in the exception message.
msg160665 - (view) Author: Christoph Echtinger-Sieghart (sigi) * Date: 2012-05-14 20:38
I wrote a trivial patch against the CPython repository that adds the name to the exception message. Did I forget anything? What kind of test would make sense?
msg213245 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-03-12 10:41
distutils2 development has stopped.
History
Date User Action Args
2022-04-11 14:57:30adminsetgithub: 58983
2014-03-12 10:41:59eric.araujosetstatus: open -> closed
resolution: out of date
messages: + msg213245

stage: needs patch -> resolved
2012-05-14 20:39:42sigisetfiles: + bad_version_number_with_name.patch
2012-05-14 20:39:01sigisetfiles: - bad_version_number_with_name.patch
2012-05-14 20:38:44sigisetfiles: + bad_version_number_with_name.patch
keywords: + patch
messages: + msg160665
2012-05-14 19:55:35sigisetmessages: + msg160659
2012-05-14 16:12:26eric.araujosetmessages: + msg160634
title: IrrationalVersionError should include the project name -> logging messages about bad version numbers should include the project name
2012-05-14 16:11:16eric.araujosetmessages: + msg160632
stage: needs patch
2012-05-14 15:52:41sigisetnosy: + sigi
messages: + msg160630
2012-05-10 23:40:46eric.araujosetkeywords: + easy

messages: + msg160383
2012-05-10 23:14:00nick.wilsoncreate