python 2.3.1 issues DeprecationWarning for FCNTL when importing tempfile

David Bolen db3l at fitlinxx.com
Mon Oct 6 18:47:05 EDT 2003


Michael Hudson <mwh at python.net> writes:

> Pierre Rouleau <prouleau at impathnetworks.com> writes:
> 
> > 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...

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





More information about the Python-list mailing list