#50337 Replace exec() with setattr()
Closed: wontfix by vashirov. Opened by cheimes.

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

@spichugi what do you think?

Sure, sounds good.

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

Metadata Update from @mreynolds:
- Issue priority set to: normal (was: minor)

Metadata Update from @mreynolds:
- Custom field rhbz adjusted to https://bugzilla.redhat.com/show_bug.cgi?id=1816859

Metadata Update from @spichugi:
- Issue assigned to spichugi

https://pagure.io/389-ds-base/pull-request/50986

a171670d8..7a6bbc1df master -> origin/master
324b5b1d0..cd65f376c 389-ds-base-1.4.1 -> 389-ds-base-1.4.1
e56a2fad7..9820e1c37 389-ds-base-1.4.2 -> 389-ds-base-1.4.2

Metadata Update from @spichugi:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

Some tests started to fail because the instance ID constants now include superfluous quotes:

(Pdb) nsinactivate_cmd
['/usr/sbin/ns-inactivate.pl', '-Z', '"standalone1"', '-D', 'cn=Directory Manager', '-w', 'password', '-I', 'uid=buser123,ou=BOU,dc=example,dc=com']
(Pdb) Popen(nsinactivate_cmd)                                                          
<subprocess.Popen object at 0x7feb6b5ec550> 
(Pdb) Invalid server identifer: "standalone1"
Available instances in /etc/dirsrv: standalone1

Metadata Update from @vashirov:
- Issue status updated to: Open (was: Closed)

Commit 341d6145 fixes this issue

Commit 341d614 fixes this issue

92e6937eb..1ff754884 389-ds-base-1.4.2 -> 389-ds-base-1.4.2

0b8863399..42db968f3 389-ds-base-1.4.1 -> 389-ds-base-1.4.1

Metadata Update from @mreynolds:
- Issue close_status updated to: None (was: Fixed)

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/389ds/389-ds-base/issues/3396

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Metadata Update from @spichugi:
- Issue close_status updated to: wontfix

Metadata
Related Pull Requests