strange import error with Python-2.4.1

Steve Holden steve at holdenweb.com
Tue Oct 11 06:37:54 EDT 2005


Robin Becker wrote:
> Whilst testing the excellent xlrd http://www.python.org/pypi/xlrd/0.3a1
> I came across the following strangeness when trying to add an import of os to 
> assist with debugging/tracing.
> 
> 
> At line 66 I replaced
> 
> import sys
> 
> with import sys, os
> 
> and then ran python runxlrd.py --help and got this error which is not a real 
> syntax problem
> 
> Traceback (most recent call last):
>    File "runxlrd.py", line 5, in ?
>      import xlrd
>    File "C:\python24\lib\site-packages\xlrd\__init__.py", line 552
>          if DEBUG: print >> self.logfile, "SST Processing"
> 
> if I remove the , os then the run produces the expected
> 
> usage: runxlrd.py [options] command input-file-patterns
> 
> options:
>    -h, --help            show this help message and exit
>    -l LOGFILENAME, --logfilename=LOGFILENAME
>                          contains error messages
>    -v VERBOSITY, --verbosity=VERBOSITY
>                          level of information and diagnostics provided
> 
> I also am able to change the line to
> 
> import sys
> import os
> 
> without error.
> 
> This behaviour doesn't occur with 2.4.2 or 2.4 only with 2.4.1. I looked for 
> some bug fix in the recently released 2.4.2 that related, but couldn't find 
> anything obvious. My system doesn't have psyco so xlrd's attempted psyco use 
> shouldn't be an issue. Thanks for 2.4.2, but is this one of the fixed bugs or 
> has it just got harder to induce?

Robin:

Can I ask if you are specifying a source encoding in your file with a 
pragma (?) like

# -*- coding: iso-8859-15 -*-

I've noticed what appear to be spurious syntax errors from time to time 
on such files, and have been attempting to debug the problem for some 
time without any apparent success.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list