From ff12be26c2a973cf694e7e8e9b4c454aa8d5e3c5 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Mon, 13 Dec 2010 23:17:14 -0800 Subject: [PATCH] Add --disable-function-redefinition for legacy code. --- Cython/Compiler/CmdLine.py | 2 ++ Cython/Compiler/Options.py | 4 ++++ Cython/Compiler/Symtab.py | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/CmdLine.py b/Cython/Compiler/CmdLine.py index 061610f0..d7e5fb6e 100644 --- a/Cython/Compiler/CmdLine.py +++ b/Cython/Compiler/CmdLine.py @@ -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( diff --git a/Cython/Compiler/Options.py b/Cython/Compiler/Options.py index 84a27653..5ed89b85 100644 --- a/Cython/Compiler/Options.py +++ b/Cython/Compiler/Options.py @@ -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 = { diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index c1ac87ee..571dbb10 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -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: -- 2.26.2