Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a8aefe5

Browse files
committed
Don't use dir() to find instance attribute names.
1 parent 49417e7 commit a8aefe5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Lib/distutils/dist.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ def __init__ (self, attrs=None):
122122
# worth it. Also delegate 'get_XXX()' methods to the 'metadata'
123123
# object in a sneaky and underhanded (but efficient!) way.
124124
self.metadata = DistributionMetadata()
125-
method_basenames = dir(self.metadata) + \
126-
['fullname', 'contact', 'contact_email']
127-
for basename in method_basenames:
125+
for basename in self.metadata._METHOD_BASENAMES:
128126
method_name = "get_" + basename
129127
setattr(self, method_name, getattr(self.metadata, method_name))
130128

@@ -962,6 +960,12 @@ class DistributionMetadata:
962960
author, and so forth.
963961
"""
964962

963+
_METHOD_BASENAMES = ("name", "version", "author", "author_email",
964+
"maintainer", "maintainer_email", "url",
965+
"license", "description", "long_description",
966+
"keywords", "platforms", "fullname", "contact",
967+
"contact_email", "licence")
968+
965969
def __init__ (self):
966970
self.name = None
967971
self.version = None

0 commit comments

Comments
 (0)