This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eli.bendersky
Recipients barry, eli.bendersky, ethan.furman, gvanrossum, ncoghlan, neologix, pitrou, serhiy.storchaka
Date 2013-08-14.12:45:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAF-Rda-8uZwUQSZJw0d=dbnrCtDr+EaOeSqfQhKws_rz_TjHNg@mail.gmail.com>
In-reply-to <1376474099.81.0.93512691707.issue18720@psf.upfronthosting.co.za>
Content
> I'm not really thrilled by the current implementation. The way it is done
> leads to duplication among socket constants.

Can you clarify which duplication you mean specifically? In the code review
tool, Serhiy proposed that instead of listing all the constants explicitly
in the Python code, we can just do:

AddressFamily = IntEnum('AddressFamily',
           {name: value for name, value in _moduledict.items()
            if name.startswith('AF_')})

Is this less duplication?

> Also, if I create a socket from a numeric value (because a well-known
> socket family is known yet known by Python), then socket.family will fail.
>

Well, the documentation of socket.socket says it should be one of the AF_*
constants. One thing we can do is check in the socket.socket constructor
whether it's a known AF_* constants and fail early with a meaningful error
message. Would that be better?
History
Date User Action Args
2013-08-14 12:45:27eli.benderskysetrecipients: + eli.bendersky, gvanrossum, barry, ncoghlan, pitrou, neologix, ethan.furman, serhiy.storchaka
2013-08-14 12:45:27eli.benderskylinkissue18720 messages
2013-08-14 12:45:26eli.benderskycreate