#50337 Replace exec() with setattr()
Opened 2 months ago by cheimes. Modified 2 months ago

I noticed that https://pagure.io/389-ds-base/blob/master/f/src/lib389/lib389/_constants.py uses exec() a lot to define module global variables. That's rather slow and not very elegant. You can get the current module object with sys.modules[__name__] and then use setattr() instead:

import sys

# current module object
mod = sys.modules[__name__]

setattr(mod, "HOST_STANDALONE{0}".format(N), "LOCALHOST")

Metadata Update from @mreynolds:
- Custom field origin adjusted to None
- Custom field reviewstatus adjusted to None
- Issue set to the milestone: 1.4.1

2 months ago

Metadata Update from @spichugi:
- Issue priority set to: minor
- Issue tagged with: Easyfix, lib389

2 months ago

Login to comment on this ticket.