Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modernize function manipulations and attrs #727

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/rez/build_process_.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def run_hooks(self, hook_event, **kwargs):
debug_print("Running %s hook '%s'...",
hook_event.label, hook.name())
try:
func = getattr(hook, hook_event.func_name)
func = getattr(hook, hook_event.__name__)
func(user=getpass.getuser(), **kwargs)
except ReleaseHookCancellingError as e:
raise ReleaseError(
Expand Down
2 changes: 1 addition & 1 deletion src/rez/release_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class ReleaseHookEvent(Enum):
def __init__(self, label, noun, func_name):
self.label = label
self.noun = noun
self.func_name = func_name
self.__name__ = func_name


# Copyright 2013-2016 Allan Johns.
Expand Down
12 changes: 6 additions & 6 deletions src/rez/rex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,12 +1224,12 @@ def execute_function(self, func, *nargs, **kwargs):
"""
# makes a copy of the func
import types
fn = types.FunctionType(func.func_code,
func.func_globals.copy(),
name=func.func_name,
argdefs=func.func_defaults,
closure=func.func_closure)
fn.func_globals.update(self.globals)
fn = types.FunctionType(func.__code__,
func.__globals__.copy(),
name=func.__name__,
argdefs=func.__defaults__,
closure=func.__closure__)
fn.__globals__.update(self.globals)

error_class = Exception if config.catch_rex_errors else None

Expand Down
14 changes: 7 additions & 7 deletions src/rez/serialise.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,15 @@ def _process(value):

# make a copy of the func with its own globals, and add 'this'
import types
fn = types.FunctionType(func.func_code,
func.func_globals.copy(),
name=func.func_name,
argdefs=func.func_defaults,
closure=func.func_closure)
fn = types.FunctionType(func.__code__,
func.__globals__.copy(),
name=func.__name__,
argdefs=func.__defaults__,
closure=func.__closure__)

# apply globals
fn.func_globals["this"] = EarlyThis(data)
fn.func_globals.update(get_objects())
fn.__globals__["this"] = EarlyThis(data)
fn.__globals__.update(get_objects())

# execute the function
spec = getargspec(func)
Expand Down