[issue21406] Some socket constants are not enums

2015-07-21 Thread Ethan Furman

Changes by Ethan Furman :


--
resolution:  -> rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21406] Some socket constants are not enums

2014-05-01 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Ah, I missed the fact that the "family" and "type" properties are re-computed 
on the fly; I thought the enum values where stored on the socket object.

Then it makes it harder to do the same for "proto", since there are 
family-specific namespaces with colliding values, indeed.

>>> socket.IPPROTO_ICMP
1
>>> socket.BTPROTO_HCI
1

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21406] Some socket constants are not enums

2014-05-01 Thread Charles-François Natali

Charles-François Natali added the comment:

To put it slightly differently:
AF_XXX constant actually whome belong to the same namespace, the
socket address family namespace.
So we put them all in AddressFamily Enum.

Now, for many constants defined in system header files, it's not so
clear, e.g. BTPROTO_RFCOMM, TIPC_ADDR_ID, SCM_CREDENTIALS: in which
Enum would you declare them?

I'm not saying it's a bad idea: it actually probably makes sense for
e.g. socket-level options (SO_REUSEADDR & Co), but it don't see any
generic classification scheme that would make sense for all of them.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21406] Some socket constants are not enums

2014-05-01 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> It makes sense for address families, especially since they're used so
> much, but when it comes to e.g. SO_REUSEADDR or BTPROTO_RFCOMM,

Hmm, I was thinking mostly about protocol numbers. All the BTPROTO_* constants 
should be part of a given enum (BlueToothProtocol?), the CAN_* constants part 
of another one.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21406] Some socket constants are not enums

2014-05-01 Thread Charles-François Natali

Charles-François Natali added the comment:

> But no, nothing in the python Enum implementation restricts it to a value 
> *range*.  It is really a collection of named constants.

I didn't say in the implementation, I said in spirit.
Would you describe all possible Unix PIDs are a Enum?

Also, the problem is that many such constant can have identical values
(because they can be passed at different syscalls/argument offset),
and in this case the IntEnum equality isn't wanted:
cf@neobox:~/python/hg/default$ cat /tmp/test.py
from enum import IntEnum

class Const(IntEnum):

AF_INET = 1
SO_REUSEADDR = 1

print(Const.AF_INET == Const.SO_REUSEADDR)
cf@neobox:~/python/hg/default$ ./python /tmp/test.py
True

Really?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21406] Some socket constants are not enums

2014-05-01 Thread R. David Murray

R. David Murray added the comment:

This is why we should have had named constants and not Enums :)

But no, nothing in the python Enum implementation restricts it to a value 
*range*.  It is really a collection of named constants.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21406] Some socket constants are not enums

2014-05-01 Thread Charles-François Natali

Charles-François Natali added the comment:

Enum are for, well, enumerated values, so for values within a finite
and known range (like days, cards, etc).
OTOH, I'm not sure all socket constants could be categorized like this.
It makes sense for address families, especially since they're used so
much, but when it comes to e.g. SO_REUSEADDR or BTPROTO_RFCOMM, I'm
not sure how we could categorize them.
Unless would declare them all in a "SocketConstant" Enum?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21406] Some socket constants are not enums

2014-05-01 Thread Antoine Pitrou

New submission from Antoine Pitrou:

Many constants in the socket module, are not int enums. Examples are 
socket.CAN_BCM, socket.BTPROTO_RFCOMM, etc.

For example when creating a bluetooth socket, you may get the following repr():

>>> socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, 
>>> socket.BTPROTO_RFCOMM)


(notice the integer "proto")

--
messages: 217691
nosy: barry, eli.bendersky, ethan.furman, neologix, pitrou
priority: low
severity: normal
status: open
title: Some socket constants are not enums
type: enhancement
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com