This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: compiler.compileFile fails on csv.py
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jhylton Nosy List: akuchling, jhylton, nnorwitz, paul.moore
Priority: normal Keywords:

Created on 2003-08-13 12:28 by paul.moore, last changed 2022-04-10 16:10 by admin. This issue is now closed.

Messages (6)
msg17725 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2003-08-13 12:28
When trying to compile the files in the standard library, I 
hit a problem compiling (using compiler.compileFile) 
the "csv.py" module. The following is the backtrace:

>>> compileFile("Lib\\csv.py")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Apps\Python\lib\compiler\pycodegen.py", line 
42, in compileFile
    mod.compile(display)
  File "C:\Apps\Python\lib\compiler\pycodegen.py", line 
112, in compile
    gen = ModuleCodeGenerator(tree)
  File "C:\Apps\Python\lib\compiler\pycodegen.py", line 
1149, in __init__
    walk(tree, self)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 106, 
in walk
    walker.preorder(tree, visitor)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 63, in 
preorder
    self.dispatch(tree, *args) # XXX *args make sense?
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\pycodegen.py", line 
342, in visitModule
    self.scopes = self.parseSymbols(node)
  File "C:\Apps\Python\lib\compiler\pycodegen.py", line 
255, in parseSymbols
    walk(tree, s)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 106, 
in walk
    walker.preorder(tree, visitor)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 63, in 
preorder
    self.dispatch(tree, *args) # XXX *args make sense?
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\symbols.py", line 207, 
in visitModule
    self.visit(node.node, scope)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 40, in 
default
    self.dispatch(child, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\symbols.py", line 258, 
in visitClass
    self.visit(node.code, scope)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 40, in 
default
    self.dispatch(child, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\symbols.py", line 220, 
in visitFunction
    self.visit(node.code, scope)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 40, in 
default
    self.dispatch(child, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 40, in 
default
    self.dispatch(child, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 40, in 
default
    self.dispatch(child, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\symbols.py", line 279, 
in visitFor
    self.visit(node.body, scope)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 40, in 
default
    self.dispatch(child, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\symbols.py", line 354, 
in visitIf
    self.visit(body, scope)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 40, in 
default
    self.dispatch(child, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\symbols.py", line 315, 
in visitAssign
    self.visit(node.expr, scope)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 40, in 
default
    self.dispatch(child, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 40, in 
default
    self.dispatch(child, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\symbols.py", line 324, 
in visitSubscript
    self.visit(node.expr, scope, 0)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 40, in 
default
    self.dispatch(child, *args)
  File "C:\Apps\Python\lib\compiler\visitor.py", line 57, in 
dispatch
    return meth(node, *args)
TypeError: visitLambda() takes exactly 3 arguments (4 
given)

The script I was using was:

import os
from os.path import join
from compiler import compileFile
for root, dirs, files in os.walk("Lib"):
    for name in files:
        if name.endswith(".py"):
            print join(root, name)
            compileFile(join(root, name))

Is there a better way of compiling all Python source in a 
directory (and its subdirectories)?
msg17726 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-08-13 13:39
Logged In: YES 
user_id=33168

Take a look at compileall.py in the std library.
msg17727 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003-08-13 23:38
Logged In: YES 
user_id=11375

The line of code that causes the problem is the following in 
csv.py:

modes[char] = reduce(lambda a, b: (0, a[1] + b[1]),
                     items)[1]
msg17728 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003-08-13 23:45
Logged In: YES 
user_id=11375

Actually it can be boiled down yet further:

f(lambda a, b: (0, 0))[1]

Assigning to Jeremy, because it looks like a compiler/ package 
bug.
msg17729 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2003-08-28 01:40
Logged In: YES 
user_id=31392

The smallest expression I've found is
(lambda: 0)[0]
msg17730 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2003-08-28 02:12
Logged In: YES 
user_id=31392

Fixed in rev 1.13 of compiler/symbols.py
History
Date User Action Args
2022-04-10 16:10:36adminsetgithub: 39055
2003-08-13 12:28:01paul.moorecreate