[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-03-08 Thread miss-islington


miss-islington  added the comment:


New changeset 8755f0aeb67125a154e5665a24276fe85d269d85 by Miss Islington (bot) 
in branch '3.7':
bpo-35899: Fix Enum handling of empty and weird strings (GH-11891)
https://github.com/python/cpython/commit/8755f0aeb67125a154e5665a24276fe85d269d85


--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-03-03 Thread Ethan Furman


Ethan Furman  added the comment:

Thank you, everyone!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.6, Python 3.8

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-03-03 Thread miss-islington


Change by miss-islington :


--
pull_requests: +12151

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-03-03 Thread miss-islington


Change by miss-islington :


--
pull_requests: +12150

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-03-03 Thread miss-islington


miss-islington  added the comment:


New changeset 8b914d2767acba3a9e78f1dacdc2d61dbfd7e304 by Miss Islington (bot) 
(Brennan D Baraban) in branch 'master':
bpo-35899: Fix Enum handling of empty and weird strings (GH-11891)
https://github.com/python/cpython/commit/8b914d2767acba3a9e78f1dacdc2d61dbfd7e304


--
nosy: +miss-islington

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-21 Thread Ethan Furman


Ethan Furman  added the comment:

The changes to `_is_sunder` and `_is_dunder` look good, but there is a problem 
with the underlying assumptions of what Enum should be doing:

- nameless members are not to be allowed
- non-alphanumeric characters are not supported

In other words, while `_is_sunder` should not fail, neither should an empty 
string be allowed as a member name.  This can be checked at line 154 (just add 
'' to the set) -- then double check that the error raised is a ValueError and 
not an IndexError.

For the strange character portion, use some non-latin numbers and letters to 
make sure they work, but don't check for symbols such as exclamation points -- 
while they might work, we are not supporting such things, and having a test 
that checks to make sure they work suggests that we do support it.

--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-18 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

Thank you for your contribution.

Have a nice day,

--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-15 Thread Brennan D Baraban


Change by Brennan D Baraban <3...@holbertonschool.com>:


--
keywords: +patch
pull_requests: +11919
stage: needs patch -> patch review

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-15 Thread Brennan D Baraban


Brennan D Baraban <3...@holbertonschool.com> added the comment:

Yes, I will submit a new PR today.

--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-15 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

Hi Brennan,

Normally, you wanted to work on this issue and you have waited for one week 
after the last message of Maxwell.

Do you want to work on this issue and submit your PR?

Have a nice day,

Stéphane

--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-13 Thread Brennan D Baraban

Brennan D Baraban <3...@holbertonschool.com> added the comment:

Thank you, Stéphane. I submitted a change request to your PR just now.

--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-13 Thread Cheryl Sabella


Change by Cheryl Sabella :


--
Removed message: https://bugs.python.org/msg335483

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-13 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

I found this issue that Serhiy did on the devguide where he added {} around the 
placeholder:
https://github.com/python/devguide/pull/444

I think that might be the correct way to do it.

--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-13 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

Hi,

I have created the PR for Maxwell.

After tomorrow, if we have no news from him, I propose to you to update/comment 
the PR. Of course, I will add a co-authored-by field in the commit.

--
keywords:  -patch
nosy: +matrixise
stage: patch review -> needs patch

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-13 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


--
keywords: +patch
pull_requests: +11870
stage: needs patch -> patch review

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-10 Thread Brennan D Baraban


Brennan D Baraban <3...@holbertonschool.com> added the comment:

Got it, makes sense. Thank you. New contributor here :)

--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-10 Thread Ethan Furman


Ethan Furman  added the comment:

Let's give Maxwell until the 14th (so a week from when I asked him to turn his 
code into a patch) and if nothing from him by then you are welcome to take it 
over.

--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-10 Thread Brennan


Brennan <3...@holbertonschool.com> added the comment:

I'm not sure if Maxwell is still working on this issue, but may I pick it up? I 
can submit a PR within the day.

--
nosy: +bdbaraban

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-07 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-07 Thread Ethan Furman


Ethan Furman  added the comment:

Yes, the first solution will be fine.  Maxwell, can you create a github pull 
request with that?

--
keywords: +easy
stage:  -> needs patch
type: crash -> behavior

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-06 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

I agree with Rémi Lapeyre.

For reference, the len() check and current tests were added under issue 19156.

--
nosy: +cheryl.sabella

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-05 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee:  -> ethan.furman

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-05 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +barry, eli.bendersky, ethan.furman

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-05 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

Hi @Maxpxt, I think your first solution is appropriate, do you want to open a 
new pull request with your solution and an appropriate test case?

--
nosy: +remi.lapeyre

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-05 Thread Maxwell


Maxwell  added the comment:

Typo fix on solution 2:

def _is_sunder(name):
"""Returns True if a _sunder_ name, False otherwise."""
return (name[:1] == name[-1:] == '_' and
name[1:2] != '_' and
name[-2:-1] != '_' and
len(name) > 2)

--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-05 Thread Maxwell


New submission from Maxwell :

This is a really minor bug.

In enum.py the function _is_sunder(name) fails on empty string with an 
IndexError.

As a result, attempting to create an Enum with an empty string fails.

>>> from enum import Enum
>>> Yay = Enum('Yay', ('', 'B', 'C'))
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Program Files\Python37\lib\enum.py", line 311, in __call__
return cls._create_(value, names, module=module, qualname=qualname, 
type=type, start=start)
  File "C:\Program Files\Python37\lib\enum.py", line 422, in _create_
classdict[member_name] = member_value
  File "C:\Program Files\Python37\lib\enum.py", line 78, in __setitem__
if _is_sunder(key):
  File "C:\Program Files\Python37\lib\enum.py", line 36, in _is_sunder
return (name[0] == name[-1] == '_' and
IndexError: string index out of range
>>>



Expected behavior is for it to not fail, as Enum accepts wierd strings. Example:

>>> from enum import Enum
>>> Yay = Enum('Yay', ('!', 'B', 'C'))
>>> getattr(Yay, '!')

>>>



Transcript of lines 26 to 39 of enum.py:

def _is_dunder(name):
"""Returns True if a __dunder__ name, False otherwise."""
return (name[:2] == name[-2:] == '__' and
name[2:3] != '_' and
name[-3:-2] != '_' and
len(name) > 4)


def _is_sunder(name):
"""Returns True if a _sunder_ name, False otherwise."""
return (name[0] == name[-1] == '_' and
name[1:2] != '_' and
name[-2:-1] != '_' and
len(name) > 2)



Solution 1: Replace with:

def _is_dunder(name):
"""Returns True if a __dunder__ name, False otherwise."""
return (len(name) > 4 and
name[:2] == name[-2:] == '__' and
name[2] != '_' and
name[-3] != '_')


def _is_sunder(name):
"""Returns True if a _sunder_ name, False otherwise."""
return (len(name) > 2 and
name[0] == name[-1] == '_' and
name[1:2] != '_' and
name[-2:-1] != '_')

In this solution, function '_is_dunder' was also altered for consistency.
Altering '_is_dunder' is not necessary, though.



Solution 2: Replace with:

def _is_dunder(name):
"""Returns True if a __dunder__ name, False otherwise."""
return (name[:2] == name[-2:] == '__' and
name[2:3] != '_' and
name[-3:-2] != '_' and
len(name) > 4)


def _is_sunder(name):
"""Returns True if a _sunder_ name, False otherwise."""
return (name[:0] == name[-1:] == '_' and
name[1:2] != '_' and
name[-2:-1] != '_' and
len(name) > 2)

In this solution, function '_is_sunder' was altered to follow
the style used in function '_is_dunder'.

--
components: Library (Lib)
messages: 334866
nosy: Maxpxt
priority: normal
severity: normal
status: open
title: '_is_sunder' function in 'enum' module fails on empty string
type: crash
versions: Python 3.7

___
Python tracker 

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