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
from TypeSlots import Signature
import PyrexTypes
import Naming
import Options
# C-level implementations of builtin types, functions and methods
......@@ -413,8 +414,6 @@ builtin_function_table = [
utility_code = getattr3_utility_code),
BuiltinFunction('getattr3', "OOO", "O", "__Pyx_GetAttr3", "getattr",
utility_code = getattr3_utility_code), # Pyrex compatibility
BuiltinFunction('globals', "", "O", "__Pyx_Globals",
utility_code = globals_utility_code),
BuiltinFunction('hasattr', "OO", "b", "PyObject_HasAttr"),
BuiltinFunction('hash', "O", "h", "PyObject_Hash"),
#('hex', "", "", ""),
......@@ -462,6 +461,11 @@ builtin_function_table = [
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
# bool
# buffer
......
......@@ -137,6 +137,8 @@ def parse_command_line(args):
options.compiler_directives.update(Options.extra_warnings)
elif option == "--disable-function-redefinition":
Options.disable_function_redefinition = True
elif option == "--old-style-globals":
Options.old_style_globals = True
elif option == "--directive" or option.startswith('-X'):
if option.startswith('-X') and option[2:].strip():
x_args = option[2:]
......
......@@ -59,6 +59,10 @@ embed = None
# module creation time. For legacy code only, needed for some circular imports.
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
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