python 2.3.1 issues DeprecationWarning for FCNTL when importing tempfile

P

Pierre Rouleau

Hi all!

I am using Python 2.3.1 on Win32 (NT, 2000).

Whenever a file imports the standard tempfile module, Python 2.3.1
issues the following warning:

C:\Python23\lib\fcntl.py:7: DeprecationWarning: the FCNTL module is
Deprecated; please use fcntl DeprecationWarning).

A quick look into tempfile.py show that it does import fcnt. Python 2.3
tempfile documentation says that it was changed. Was the use of fcntl()
forgotten? Is this a bug?

Thanks for your time.

Pierre
 
M

Michael Hudson

Pierre Rouleau said:
Hi all!

I am using Python 2.3.1 on Win32 (NT, 2000).

Whenever a file imports the standard tempfile module, Python 2.3.1
issues the following warning:

C:\Python23\lib\fcntl.py:7: DeprecationWarning: the FCNTL module is
Deprecated; please use fcntl DeprecationWarning).

A quick look into tempfile.py show that it does import fcnt. Python
2.3 tempfile documentation says that it was changed. Was the use of
fcntl() forgotten? Is this a bug?

Do you have the environment variable PYTHONCASEOK set? You probably
don't want to...

Cheers,
mwh
 
P

Pierre Rouleau

Whenever a file imports the standard tempfile module, Python 2.3.1
Do you have the environment variable PYTHONCASEOK set? You probably
don't want to...

No, PYTHONCASEOK is not set.

I get the problem with right away in the python shell:

D:\dev\python>python
Python 2.3.1 (#47, Sep 23 2003, 23:47:32) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.c:\python23\lib\fcntl.py:7: DeprecationWarning: the FCNTL module is
deprecated; please use fcntl
DeprecationWarning)
I also tried it within PythonWin: same result.


PythonWin 2.3.1 (#47, Sep 23 2003, 23:47:32) [MSC v.1200 32 bit (Intel)]
on win32.
Portions Copyright 1994-2001 Mark Hammond ([email protected]) -
see 'Help/About PythonWin' for further copyright information.C:\Python23\lib\fcntl.py:7: DeprecationWarning: the FCNTL module is
deprecated; please use fcntl
DeprecationWarning)
I did not edit any of the files in the Python library. It does the same
on WinNT and Win2000 but i also tried it on a XP machine and the problem
is not on the XP machine. But the source is the same on the XP machine
(the FCNTL.py and tempfile.py) and the NT and 2000 machines.

I am starting to wonder if the problem is caused by a package that was
installed on one set of machines and not the other.

Thanks!

Pierre
 
M

Michael Hudson

Pierre Rouleau said:
No, PYTHONCASEOK is not set.

Hmm, weird.
I get the problem with right away in the python shell:

D:\dev\python>python
Python 2.3.1 (#47, Sep 23 2003, 23:47:32) [MSC v.1200 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.c:\python23\lib\fcntl.py:7: DeprecationWarning: the FCNTL module is
^^^^^^^^
This is a bit bizarre; the file is really called FCNTL.py, right?
I did not edit any of the files in the Python library. It does the
same on WinNT and Win2000 but i also tried it on a XP machine and the
problem is not on the XP machine. But the source is the same on the
XP machine (the FCNTL.py and tempfile.py) and the NT and 2000 machines.

I am starting to wonder if the problem is caused by a package that was
installed on one set of machines and not the other.

Could be. I've reached the outer edge of my windows knowledge (not
very far, you'll notice), so I hope another reader can get you
further...

Cheers,
mwh
 
P

Pierre Rouleau

I get the problem with right away in the python shell:

D:\dev\python>python
Python 2.3.1 (#47, Sep 23 2003, 23:47:32) [MSC v.1200 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
import tempfile
c:\python23\lib\fcntl.py:7: DeprecationWarning: the FCNTL module is

^^^^^^^^
This is a bit bizarre; the file is really called FCNTL.py, right?
Yes. The file is old though:

C:\Python23\Lib>ls -l [fF]*.py
-rwxrwxrwa 1 Administrators None 418 May 9 2001 FCNTL.py
-rwxrwxrwa 1 Administrators None 10173 Sep 2 07:47 filecmp.py
-rwxrwxrwa 1 Administrators None 12732 Jan 8 2003 fileinput.py
-rwxrwxrwa 1 Administrators None 3126 Jul 13 18:06 fnmatch.py
-rwxrwxrwa 1 Administrators None 15548 Feb 27 2003 formatter.py
-rwxrwxrwa 1 Administrators None 4709 Jan 21 2001 fpformat.py
-rwxrwxrwa 1 Administrators None 27589 Jun 3 2002 ftplib.py

I wonder if FCNTL.py is a valid file. Here is what it contains:

C:\Python23\Lib>cat FCNTL.py
cat FCNTL.py
"""Backward-compatibility version of FCNTL; export constants exported by
fcntl, and issue a deprecation warning.
"""

import warnings
warnings.warn("the FCNTL module is deprecated; please use fcntl",
DeprecationWarning)


# Export the constants known to the fcntl module:
from fcntl import *

# and *only* the constants:
__all__ = [s for s in dir() if s[0] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]

C:\Python23\Lib>

----

BTW, I solved the problem by deleting the fcntl.pyc. See my other post
below.

Thanks for your help!
 
M

Michael Hudson

Pierre Rouleau said:
BTW, I solved the problem by deleting the fcntl.pyc. See my other
post below.

Actaully, I read this thread completely out of order, but glad to see
you got it sorted. Definitely a good mystery!

Cheers,
mwh
 
A

achrist

use McMillan installer on Windows, too, and I've also been getting
these messages. Didn't know they were fixable until reading this
thread. I was getting two sets of messages, one for fcntl and one
for termios. Each of these had a *.py, a *.pyc, and a *.pyo in the
python\Lib folder. Deleting them all seems to fix it.



Al
 
D

David Bolen

Michael Hudson said:
Do you have the environment variable PYTHONCASEOK set? You probably
don't want to...

Either that or just check the installed Python lib directory for an
"fcntl.pyc" file (lowercase). It shouldn't be there under Windows,
but something (outside of a Python installation) has created it on my
system in the past erroneously - e.g., the compiled version of that
file if it was ever used should be uppercase FCNTL.pyc.

In my case, I believe it may have been related to using the McMillan
Installer package. Yeah, I just tried using Installer (5b5) on a file
that imports fcntl and it does create the lower case file compiled
file while processing things. But I'm not sure if it's more an issue
with Installer or with the py_compile module. Under Windows if you
tell py_compile.compile to compile "fcntl.py" without picking a
destination name then it works even if the actual file is FCNTL.py,
and regardless of the PYTHONCASEOK setting, and it creates the
lowercase output file since that's the form you gave it on input. And
since I think installer just goes based on the module name in the
source code and passes that on to py_compile.compile, you end up with
the erroneous module.

But yes, tempfile changed in 2.3 so that it conditionally tries to
import fcntl, so once that erroneous compiled module exists, you'll
get the warning on tempfile (or anything else that tries to import
fcntl). And if the OP installed Python 2.3 on top of a prior version,
then it's also possible that the erroneous compiled file may have been
around on the OP's system for a while and just wasn't noticed since
typical use didn't involve a module that tried to import it.

-- David
 

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,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top