Commit ff12be26 authored by Robert Bradshaw's avatar Robert Bradshaw

Add --disable-function-redefinition for legacy code.

parent b16fceca
...@@ -125,6 +125,8 @@ def parse_command_line(args): ...@@ -125,6 +125,8 @@ def parse_command_line(args):
options.language_level = 3 options.language_level = 3
elif option == "--fast-fail": elif option == "--fast-fail":
Options.fast_fail = True Options.fast_fail = True
elif option == "--disable-function-redefinition":
Options.disable_function_redefinition = True
elif option in ("-X", "--directive"): elif option in ("-X", "--directive"):
try: try:
options.compiler_directives = Options.parse_directive_list( options.compiler_directives = Options.parse_directive_list(
......
...@@ -51,6 +51,10 @@ c_line_in_traceback = 1 ...@@ -51,6 +51,10 @@ c_line_in_traceback = 1
# executes the body of this module. # executes the body of this module.
embed = False 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 # Declare compiler directives
directive_defaults = { directive_defaults = {
......
...@@ -526,7 +526,7 @@ class Scope(object): ...@@ -526,7 +526,7 @@ class Scope(object):
def declare_pyfunction(self, name, pos, allow_redefine=False, visibility='extern'): def declare_pyfunction(self, name, pos, allow_redefine=False, visibility='extern'):
# Add an entry for a Python function. # Add an entry for a Python function.
entry = self.lookup_here(name) 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) return self._declare_pyfunction(name, pos, visibility=visibility, entry=entry)
if entry: if entry:
if entry.type.is_unspecified: if entry.type.is_unspecified:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment