473,383 Members | 1,762 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Retry: Question about FutureWarning

I'm trying again, since no response indicates that I'm not providing
enough info.

I have module M1 which has the following line in it:

StartTime = safe_dict_get ( dic, 'starttime', 0xFFFFFFFF )

It gets imported by modules M2 and M3. And finally, M4 imports both M2 and
M3. So the idea is that in total we have 4 files called M1.py M2.py M3.py
and M4.py

M4
|\M3
| |\M1
|\M2
| |\M1

I need to compile the python modules as part of the package building
process.

The shell compile command I use to generate both the .pyc and the .pyo
files is:

python=/usr/bin/python2.3
i_python ()
{
$python -c "import $1"
$python -O -c "import $1"
}
i_python M1
i_python M2
i_python M3
i_python M4

When M1 is compiled, there's no problem. The same for when I compile M2
and M3. But when M4 is compiled, I get the following message:

M1.py:268: FutureWarning: hex/oct constants sys.maxint will
return positive values in Python 2.4 and up
StartTime = safe_dict_get ( dic, 'starttime', 0xFFFFFFFF )

I get the message twice, ostensibly because of M3 and M2 both being
imported into M1

I was able to shut off the warning by adding the following lines *before*
the import of M2 and M3 in M4:

import warnings
warnings.filterwarnings('ignore', category=FutureWarning)

My question is this: Why can the warning not be shut off by putting the
two lines in M1 where the reference exists to 0xFFFFFFFF ?

I'm just leary of fixing warnings by looking for ways to shut them off.

Also, do I need to supply any more information?

Thanks for your patience.

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
Aug 15 '07 #1
5 1790
Steven W. Orr wrote:
M1.py:268: FutureWarning: hex/oct constants sys.maxint will
return positive values in Python 2.4 and up
StartTime = safe_dict_get ( dic, 'starttime', 0xFFFFFFFF )
...
import warnings
warnings.filterwarnings('ignore', category=FutureWarning)

My question is this: Why can the warning not be shut off by putting the
two lines in M1 where the reference exists to 0xFFFFFFFF ?
You really don't want to shut off the warning; it means just what it says:

Python 2.3.5 (#1, Feb 8 2005, 23:36:23)
[GCC 3.2.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>0xffffffff
<stdin>:1: FutureWarning: hex/oct constants sys.maxint will return
positive values in Python 2.4 and up
-1

Python 2.4.3 (#1, Mar 29 2006, 17:16:11)
[GCC 3.2.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>0xffffffff
4294967295L

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis
Black vinyl man with black plasticized imagination
-- Nik Kershaw
Aug 15 '07 #2
On Aug 14, 8:49 pm, Erik Max Francis <m...@alcyone.comwrote:
Steven W. Orr wrote:
M1.py:268: FutureWarning: hex/oct constants sys.maxint will
return positive values in Python 2.4 and up
StartTime = safe_dict_get ( dic, 'starttime', 0xFFFFFFFF )
...
import warnings
warnings.filterwarnings('ignore', category=FutureWarning)
My question is this: Why can the warning not be shut off by putting the
two lines in M1 where the reference exists to 0xFFFFFFFF ?

You really don't want to shut off the warning; it means just what it says:

Python 2.3.5 (#1, Feb 8 2005, 23:36:23)
[GCC 3.2.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>0xffffffff
<stdin>:1: FutureWarning: hex/oct constants sys.maxint will return
positive values in Python 2.4 and up
-1

Python 2.4.3 (#1, Mar 29 2006, 17:16:11)
[GCC 3.2.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>0xffffffff
4294967295L

--
Erik Max Francis && m...@alcyone.com &&http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis
Black vinyl man with black plasticized imagination
-- Nik Kershaw
So if by '0xFFFFFFFF' you meant -1, then change this line to use -1.
Otherwise, if you really meant 4294967295L, leave it at 0xFFFFFFFF and
move on.

-- Paul

Aug 15 '07 #3
On 2007-08-15, Paul McGuire <pt***@austin.rr.comwrote:
On Aug 14, 8:49 pm, Erik Max Francis <m...@alcyone.comwrote:

So if by '0xFFFFFFFF' you meant -1, then change this line to use -1.
Otherwise, if you really meant 4294967295L, leave it at 0xFFFFFFFF and
move on.
A third option is to specify 0xFFFFFFFF as 0xFFFFFFFFL in the latter case to
get rid of the warning.

Albert
Aug 15 '07 #4
Thanks guys, but that's not my question. The question is this: Why does
the call to filterwarnings not work if it's placed inside the M1 module?
Why do I have to place the call in M4 to make it work? This is more a
question about how import works than it is about what the value of -1 is.
;-)

On Tuesday, Aug 14th 2007 at 18:49 -0700, quoth Erik Max Francis:

=>Steven W. Orr wrote:
=>
=>M1.py:268: FutureWarning: hex/oct constants sys.maxint will
=>return positive values in Python 2.4 and up
=> StartTime = safe_dict_get ( dic, 'starttime', 0xFFFFFFFF )
=> ...
=>import warnings
=>warnings.filterwarnings('ignore', category=FutureWarning)
=>>
=>My question is this: Why can the warning not be shut off by putting the
=>two lines in M1 where the reference exists to 0xFFFFFFFF ?
=>
=>You really don't want to shut off the warning; it means just what it says:
=>
=>Python 2.3.5 (#1, Feb 8 2005, 23:36:23)
=>[GCC 3.2.3] on linux2
=>Type "help", "copyright", "credits" or "license" for more information.
=>0xffffffff
=><stdin>:1: FutureWarning: hex/oct constants sys.maxint will return
=>positive values in Python 2.4 and up
=>-1
=>
=>Python 2.4.3 (#1, Mar 29 2006, 17:16:11)
=>[GCC 3.2.3] on linux2
=>Type "help", "copyright", "credits" or "license" for more information.
=>0xffffffff
=>4294967295L
=>

On Wednesday, Aug 15th 2007 at 06:10 -0700, quoth Paul McGuire:

=>On Aug 14, 8:49 pm, Erik Max Francis <m...@alcyone.comwrote:
=>
=>So if by '0xFFFFFFFF' you meant -1, then change this line to use -1.
=>Otherwise, if you really meant 4294967295L, leave it at 0xFFFFFFFF and
=>move on.
=>
=>-- Paul
=>
=>--
=>http://mail.python.org/mailman/listinfo/python-list
=>

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
Aug 15 '07 #5
Steven W. Orr wrote:
I'm trying again, since no response indicates that I'm not providing
enough info.
No, you were providing too much irrelevant information. It would have been
better to put it that way:
Thanks guys, but that's not my question. The question is this: Why does
the call to filterwarnings not work if it's placed inside the M1 module?
Why do I have to place the call in M4 to make it work? This is more a
question about how import works than it is about what the value of -1 is.
;-)
You cannot switch off the warning inside the module because it is issued
during its compilation, not its execution:

$ cat tmp.py
import warnings
warnings.filterwarnings("ignore", category=FutureWarning)
print "FutureWarning switched off"
warnings.warn("yadda", category=FutureWarning)
0xffffffff

$ rm tmp.pyc
$ python2.3 -c'import tmp'
tmp.py:5: FutureWarning: hex/oct constants sys.maxint will return positive
values in Python 2.4 and up
0xffffffff
FutureWarning switched off

First you get the warning, then the "switched off" message. Oops.

$ python2.3 -c'import tmp'
FutureWarning switched off

When importing the module a second time you don't get the warning because
the compiled module already exists and is reused.

Note that you can disable warnings on the commmand line...

$ rm tmp.pyc
$ python2.3 -Wignore::FutureWarning -c'import tmp'
FutureWarning switched off

.... but as others already told you it is normally not a good idea to squash
these warnings. Well, you have been warned ;)

Peter
Aug 16 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bengt Richter | last post by:
>>> hex(-5) __main__:1: FutureWarning: hex()/oct() of negative int will return a signed string in Python 2.4 and up '0xfffffffb' >>> hex(-5) '0xfffffffb' >>> hex(-5L) '-0x5L' That is sooo...
7
by: Robert Brewer | last post by:
Alex Martelli wrote in another thread: > One sign that somebody has moved from "Python newbie" to "good Python > programmer" is exactly the moment they realize why it's wrong to code: > > ...
1
by: Egor Bolonev | last post by:
================= C:\Documents and Settings\\My Documents\Scripts\octopus_eye\1\oct_eye_db.py: 213: FutureWarning: hex()/oct() of negative int will return a signed string in P ython 2.4 and...
8
by: Grant Edwards | last post by:
How do I get rid of the following warning? <path>.py:233: FutureWarning: hex/oct constants > sys.maxint will return positive values in Python 2.4 and up...
0
by: Chris Curvey | last post by:
Hi all, When trying to automate IE thru win32com (using PAMIE), I'm getting this message out C:\Program Files\Plone 2\Python\lib\site-packages\win32com\client\dynamic.py:463 : FutureWarning:...
14
by: kosuke | last post by:
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...
7
by: Antoine De Groote | last post by:
Hi, I hope I don't upset anybody by comparing Python to Ruby (again). Is there something like Ruby's retry keyword in Python? I couldn't find any thing... Regards, antoine
0
by: Steven W. Orr | last post by:
I have module M1 which has the following line in it: StartTime = safe_dict_get ( dic, 'starttime', 0xFFFFFFFF ) It gets imported by modules M2 and M3. And finally, M4 imports both M2 and M3....
2
by: hofer | last post by:
Hi, I get following warning with a python script: optparse.py:668: FutureWarning: %u/%o/%x/%X of negative int will return a signed string in Python 2.4 and up my code:
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.