Commit ba0b915f authored by Robert Bradshaw's avatar Robert Bradshaw

Add flag for archaic behavior of globals().

parent ff2fcf40
...@@ -7,6 +7,7 @@ from Code import UtilityCode ...@@ -7,6 +7,7 @@ from Code import UtilityCode
from TypeSlots import Signature from TypeSlots import Signature
import PyrexTypes import PyrexTypes
import Naming import Naming
import Options
# C-level implementations of builtin types, functions and methods # C-level implementations of builtin types, functions and methods
...@@ -413,8 +414,6 @@ builtin_function_table = [ ...@@ -413,8 +414,6 @@ builtin_function_table = [
utility_code = getattr3_utility_code), utility_code = getattr3_utility_code),
BuiltinFunction('getattr3', "OOO", "O", "__Pyx_GetAttr3", "getattr", BuiltinFunction('getattr3', "OOO", "O", "__Pyx_GetAttr3", "getattr",
utility_code = getattr3_utility_code), # Pyrex compatibility utility_code = getattr3_utility_code), # Pyrex compatibility
BuiltinFunction('globals', "", "O", "__Pyx_Globals",
utility_code = globals_utility_code),
BuiltinFunction('hasattr', "OO", "b", "PyObject_HasAttr"), BuiltinFunction('hasattr', "OO", "b", "PyObject_HasAttr"),
BuiltinFunction('hash', "O", "h", "PyObject_Hash"), BuiltinFunction('hash', "O", "h", "PyObject_Hash"),
#('hex', "", "", ""), #('hex', "", "", ""),
...@@ -462,6 +461,11 @@ builtin_function_table = [ ...@@ -462,6 +461,11 @@ builtin_function_table = [
BuiltinFunction('__Pyx_PyObject_Append', "OO", "O", "__Pyx_PyObject_Append"), BuiltinFunction('__Pyx_PyObject_Append', "OO", "O", "__Pyx_PyObject_Append"),
] ]
if not Options.old_style_globals:
builtin_function_table.append(
BuiltinFunction('globals', "", "O", "__Pyx_Globals",
utility_code = globals_utility_code))
# Builtin types # Builtin types
# bool # bool
# buffer # buffer
......
...@@ -137,6 +137,8 @@ def parse_command_line(args): ...@@ -137,6 +137,8 @@ def parse_command_line(args):
options.compiler_directives.update(Options.extra_warnings) options.compiler_directives.update(Options.extra_warnings)
elif option == "--disable-function-redefinition": elif option == "--disable-function-redefinition":
Options.disable_function_redefinition = True Options.disable_function_redefinition = True
elif option == "--old-style-globals":
Options.old_style_globals = True
elif option == "--directive" or option.startswith('-X'): elif option == "--directive" or option.startswith('-X'):
if option.startswith('-X') and option[2:].strip(): if option.startswith('-X') and option[2:].strip():
x_args = option[2:] x_args = option[2:]
......
...@@ -59,6 +59,10 @@ embed = None ...@@ -59,6 +59,10 @@ embed = None
# module creation time. For legacy code only, needed for some circular imports. # module creation time. For legacy code only, needed for some circular imports.
disable_function_redefinition = False disable_function_redefinition = False
# In previous iterations of Cython, globals() gave the first non-Cython module
# globals in the call stack. Sage relies on this behavior for variable injection.
old_style_globals = False
# Declare compiler directives # Declare compiler directives
directive_defaults = { directive_defaults = {
......
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