Message195149
> 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_')})
Yes, that's better.
> > 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?
Well, no. We should still allow creating sockets with unknown numeric
values. The .family attribute should then return the raw integer. |
|
Date |
User |
Action |
Args |
2013-08-14 13:11:51 | pitrou | set | recipients:
+ pitrou, gvanrossum, barry, ncoghlan, eli.bendersky, neologix, ethan.furman, serhiy.storchaka |
2013-08-14 13:11:51 | pitrou | link | issue18720 messages |
2013-08-14 13:11:51 | pitrou | create | |
|