Add --disable-function-redefinition for legacy code.
authorRobert Bradshaw <robertwb@math.washington.edu>
Tue, 14 Dec 2010 07:17:14 +0000 (23:17 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Tue, 14 Dec 2010 07:17:14 +0000 (23:17 -0800)
Cython/Compiler/CmdLine.py
Cython/Compiler/Options.py
Cython/Compiler/Symtab.py

index 061610f0bced805a2b709d176f9d65af7f253e7f..d7e5fb6ef20712d0bd69ee90cbc28d49a7c6e889 100644 (file)
@@ -125,6 +125,8 @@ def parse_command_line(args):
                 options.language_level = 3
             elif option == "--fast-fail":
                 Options.fast_fail = True
+            elif option == "--disable-function-redefinition":
+                Options.disable_function_redefinition = True
             elif option in ("-X", "--directive"):
                 try:
                     options.compiler_directives = Options.parse_directive_list(
index 84a276536d832bf4def3d5bec2cd7c0da1c204ca..5ed89b85640b03874e0a620784bec16309866abe 100644 (file)
@@ -51,6 +51,10 @@ c_line_in_traceback = 1
 # executes the body of this module.
 embed = False
 
+# Disables function redefinition, allowing all functions to be declared at
+# module creation time. For legacy code only. 
+disable_function_redefinition = False
+
 
 # Declare compiler directives
 directive_defaults = {
index c1ac87eecae225c9cdcbad75cc5b4ea57cdc55da..571dbb1070b09f94c7c200135610e976f014f0b7 100644 (file)
@@ -526,7 +526,7 @@ class Scope(object):
     def declare_pyfunction(self, name, pos, allow_redefine=False, visibility='extern'):
         # Add an entry for a Python function.
         entry = self.lookup_here(name)
-        if not allow_redefine:
+        if not allow_redefine or Options.disable_function_redefinition:
             return self._declare_pyfunction(name, pos, visibility=visibility, entry=entry)
         if entry:
             if entry.type.is_unspecified: