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: optparse: error: invalid integer value
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, hensing, r.david.murray
Priority: normal Keywords:

Created on 2011-01-26 12:29 by hensing, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
minimal.py hensing, 2011-01-26 12:29 minimal exmaple
Messages (7)
msg127106 - (view) Author: hensing (hensing) Date: 2011-01-26 12:29
OptionParser can't parse int "08" and "09". "8", "9" and "01..07" works.
msg127109 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-01-26 12:45
08 is not a valid octal number.  See http://docs.python.org/library/optparse#standard-option-types and http://docs.python.org/reference/lexical_analysis#integer-and-long-integer-literals

Hope this helps.
msg127112 - (view) Author: hensing (hensing) Date: 2011-01-26 13:07
Shouldn't it be better to parse only numbers with prefix "0o" "0o72" as an octal number?

So it would be consistent to hex and bin (0x and 0b).
msg127113 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-01-26 13:07
That change has been done in Python 3.
msg127171 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-01-27 03:48
09 is still an invalid token in python3.  Since int('09') works in python2 it might be worth looking in to this further.
msg127175 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-01-27 10:30
I think it’s good: optparse checks for a leading 0 and will use int(value, 8) in that case.
msg127204 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-01-27 17:54
Well, it is certainly intentional, then.  Whether it is good is a different story, but also a moot question since optparse has been replaced by argparse.
History
Date User Action Args
2022-04-11 14:57:11adminsetgithub: 55226
2011-01-27 17:54:11r.david.murraysetnosy: eric.araujo, r.david.murray, hensing
messages: + msg127204
2011-01-27 10:30:27eric.araujosetnosy: eric.araujo, r.david.murray, hensing
messages: + msg127175
2011-01-27 03:48:19r.david.murraysetnosy: + r.david.murray
messages: + msg127171
2011-01-26 13:07:40eric.araujosetnosy: eric.araujo, hensing
messages: + msg127113
2011-01-26 13:07:12hensingsetnosy: eric.araujo, hensing
messages: + msg127112
2011-01-26 12:45:06eric.araujosetstatus: open -> closed

type: crash -> behavior

nosy: + eric.araujo
messages: + msg127109
resolution: not a bug
stage: resolved
2011-01-26 12:29:22hensingcreate