optparse.py: FutureWarning error

K

kosuke

I keep getting the following error/warning message when using the
python based program getmail4:

/usr/lib/python2.3/optparse.py:668: FutureWarning: %u/%o/%x/%X of
negative int will return a signed string in Python 2.4 and up
return ("<%s at 0x%x: %r>"

I'm using python2.3.5 on a debian sid box.

The getmail4 website/FAQ maintains that this is a bug in the optparse
module.

Any idea on how to resolve this?

Thanks
Kevin
 
T

Terry Reedy

kosuke said:
I keep getting the following error/warning message when using the
python based program getmail4:

/usr/lib/python2.3/optparse.py:668: FutureWarning: %u/%o/%x/%X of
negative int will return a signed string in Python 2.4 and up
return ("<%s at 0x%x: %r>"

I'm using python2.3.5 on a debian sid box.

The getmail4 website/FAQ maintains that this is a bug in the optparse
module.

Any idea on how to resolve this?

a) Learn to live with it ;-)
b) Upgrade to 2.4 (if getmail4 will run with it)
c) Check to see if Python has a startup option for suppressing warnings

As to c) python -h gives a list indicating what I thought, that -W controls
warnings, but gives insufficient info for me to use it, and I didn't find
any more in the docs. I hope someone else chimes in.

Terry J. Reedy


Terry J. Reedy
 
M

Michael Hoffman

Terry said:
c) Check to see if Python has a startup option for suppressing warnings

As to c) python -h gives a list indicating what I thought, that -W controls
warnings, but gives insufficient info for me to use it, and I didn't find
any more in the docs. I hope someone else chimes in.

man python. Search for -W.
 
J

John Machin

Michael said:
man python. Search for -W.

"""
C:\junk>man python
'man' is not recognized as an internal or external command,
operable program or batch file.
"""

Could someone please post a copy of the whole of the arg section of the
"man python" output, for the benefit of Windows users?

TIA,
John
 
K

kosuke

man python ---

COMMAND LINE OPTIONS
-c command
Specify the command to execute (see next section). This
terminates the option list (following options are passed as arguments
to
the command).

-d Turn on parser debugging output (for wizards only,
depending on compilation options).

-E Ignore environment variables like PYTHONPATH and
PYTHONHOME that modify the behavior of the interpreter.

-h Prints the usage for the interpreter executable and
exits.

-i When a script is passed as first argument or the -c
option is used, enter interactive mode after executing the script or
the com-
mand. It does not read the $PYTHONSTARTUP file. This
can be useful to inspect global variables or a stack trace when a
script
raises an exception.

-O Turn on basic optimizations. This changes the
filename extension for compiled (bytecode) files from .pyc to .pyo.
Given twice,
causes docstrings to be discarded.

-Q argument
Division control; see PEP 238. The argument must be one
of "old" (the default, int/int and long/long return an int or long),
"new"
(new division semantics, i.e. int/int and long/long
returns a float), "warn" (old division semantics with a warning for
int/int and
long/long), or "warnall" (old division semantics with a
warning for all use of the division operator). For a use of "warnall",
see
the Tools/scripts/fixdiv.py script.

-S Disable the import of the module site and the
site-dependent manipulations of sys.path that it entails.

-t Issue a warning when a source file mixes tabs and
spaces for indentation in a way that makes it depend on the worth of a
tab
expressed in spaces. Issue an error when the option is
given twice.

-u Force stdin, stdout and stderr to be totally unbuffered.
On systems where it matters, also put stdin, stdout and stderr in
binary
mode. Note that there is internal buffering in
xreadlines(), readlines() and file-object iterators ("for line in
sys.stdin") which
is not influenced by this option. To work around this,
you will want to use "sys.stdin.readline()" inside a "while 1:" loop.
-v Print a message each time a module is initialized,
showing the place (filename or built-in module) from which it is
loaded. When
given twice, print a message for each file that is
checked for when searching for a module. Also provides information on
module
cleanup at exit.

-V Prints the Python version number of the executable and
exits.

-W argument
Warning control. Python sometimes prints warning message
to sys.stderr. A typical warning message has the following
form:
file:line: category: message. By default, each warning
is printed once for each source line where it occurs. This option
controls
how often warnings are printed. Multiple -W options may
be given; when a warning matches more than one option, the action for
the
last matching option is performed. Invalid -W
options are ignored (a warning message is printed about invalid options
when the
first warning is issued). Warnings can also be
controlled from within a Python program using the warnings module.

The simplest form of argument is one of the following
action strings (or a unique abbreviation): ignore to ignore all
warnings;
default to explicitly request the default behavior
(printing each warning once per source line); all to print a warning
each time
it occurs (this may generate many messages if a warning
is triggered repeatedly for the same source line, such as inside a
loop);
module to print each warning only only the first time
it occurs in each module; once to print each warning only the first
time it
occurs in the program; or error to raise an exception
instead of printing a warning message.

The full form of argument is
action:message:category:module:line. Here, action is as explained
above but only applies to messages
that match the remaining fields. Empty fields match
all values; trailing empty fields may be omitted. The message field
matches
the start of the warning message printed; this match is
case-insensitive. The category field matches the warning category.
This
must be a class name; the match test whether the actual
warning category of the message is a subclass of the specified warning
cat-
egory. The full class name must be given. The module
field matches the (fully-qualified) module name; this match is
case-sensi-
tive. The line field matches the line number, where
zero matches all line numbers and is thus equivalent to an omitted line
num-
ber.

-x Skip the first line of the source. This is intended for
a DOS specific hack only. Warning: the line numbers in error
messages
will be off by one!
 
T

Terry Reedy

kosuke said:
man python ---

COMMAND LINE OPTIONS

This should REALLY be on the doc page of the Python site. I remember
asking for this about 7 years ago and being ridiculed for only having
Windows. It is really time to stop pretending that the only Python users
that count have a *nix on their desk.

Terry J. Reedy
 
K

Kent Johnson

Terry said:
This should REALLY be on the doc page of the Python site.

Hear, hear! I never even knew this existed!

Where should it go in the docs? In the Language Reference or the Tutorial or...?

Kent
 
M

Michael Hoffman

John said:
"""
C:\junk>man python
'man' is not recognized as an internal or external command,
operable program or batch file.
"""

Well it's obviously not going to work if you don't install man. <wink>

"""
C:\Documents and Settings\MichaelH>man python

PYTHON(1)

NAME

python - an interpreted, interactive, object-oriented programming language
"""

Here's a copy of the man page:

http://linuxcommand.org/man_pages/python1.html
 
T

Terry Reedy

Kent Johnson said:
Hear, hear! I never even knew this existed!

Where should it go in the docs? In the Language Reference or the Tutorial
or...?

Since the Tutorial already has section 2. Using the Python Interpreter that
discusses a few of the switches, I would add it as an appendix with a
reference to the appendix at the end of the appropriate subsection.
Perhaps I will submit a tracker item.

Terry J. Reedy
 
K

Kent Johnson

Terry said:
Since the Tutorial already has section 2. Using the Python Interpreter that
discusses a few of the switches, I would add it as an appendix with a
reference to the appendix at the end of the appropriate subsection.
Perhaps I will submit a tracker item.

Sounds good to me.

Kent
 
M

Magnus Lycka

Terry said:
This should REALLY be on the doc page of the Python site. Agreed.

It is really time to stop pretending that the only Python users
that count have a *nix on their desk.
I agree with this too, but if you're a programmer
on the Windows platform with possibility to install
software on the machine you work with, I strongly
suggest that you install cygwin or something
equivalent. Not just for "man python". Tools like
grep and find are vastly superior to anything I've
seen natively on windows if you want to process the
data you find in some automated way.

In my experience, Windows 2000 and later are fairly
decent operating systems if you have Python and
cygwin installed, but I'd feel awfully handicapped
without those tools.
 
J

John Abel

Magnus said:
Terry Reedy wrote:


I agree with this too, but if you're a programmer
on the Windows platform with possibility to install
software on the machine you work with, I strongly
suggest that you install cygwin or something
equivalent. Not just for "man python". Tools like
grep and find are vastly superior to anything I've
seen natively on windows if you want to process the
data you find in some automated way.

In my experience, Windows 2000 and later are fairly
decent operating systems if you have Python and
cygwin installed, but I'd feel awfully handicapped
without those tools.
As a programmer on Win32, and *nix platforms, I agree with needing
better tools. however, I find cygwin a pita. For tools such as grep
and find, try this http://unxutils.sourceforge.net/. No need for cygwin
( though that's not say cygwin isn't useful ).

J
 
M

Magnus Lycka

John said:
Magnus Lycka wrote:
As a programmer on Win32, and *nix platforms, I agree with needing
better tools. however, I find cygwin a pita. For tools such as grep
and find, try this http://unxutils.sourceforge.net/. No need for cygwin
( though that's not say cygwin isn't useful ).

Is there any shell there? While I do think that "cd /cygdrive/c" is a
bit silly, I still prefer bash to Microsoft's cmd.exe (even if cmd.exe
is much, much better than the old command.com).
 
J

John Abel

Magnus said:
John Abel wrote:



Is there any shell there? While I do think that "cd /cygdrive/c" is a
bit silly, I still prefer bash to Microsoft's cmd.exe (even if cmd.exe
is much, much better than the old command.com).
There is a sh, but no bash, scroll down the the linked page for a full
list of the executables.

J
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top