Issue32801
Created on 2018-02-08 16:09 by dilyan.palauzov, last changed 2022-04-11 14:58 by admin.
| Messages (7) | |||
|---|---|---|---|
| msg311838 - (view) | Author: Дилян Палаузов (dilyan.palauzov) | Date: 2018-02-08 16:09 | |
diff --git a/Lib/_strptime.py b/Lib/_strptime.py
--- a/Lib/_strptime.py
+++ b/Lib/_strptime.py
@@ -238,10 +238,7 @@ class TimeRE(dict):
"""
to_convert = sorted(to_convert, key=len, reverse=True)
- for value in to_convert:
- if value != '':
- break
- else:
+ if all(value == '' for value in to_convert):
return ''
regex = '|'.join(re_escape(stuff) for stuff in to_convert)
regex = '(?P<%s>%s' % (directive, regex)
|
|||
| msg311935 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2018-02-10 04:10 | |
This looks straightforward. I believe we normally do not backport this type of change. The tests for _strptime.py are in test_strptime.py, not test__strptime.py. |
|||
| msg311941 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-02-10 07:08 | |
Just
if not any(to_convert):
return ''
|
|||
| msg311965 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2018-02-10 22:37 | |
And the conditional return can be done before sorting. |
|||
| msg312016 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2018-02-11 23:09 | |
Serhiy, Is there any reason to not combine last two lines in one?
- regex = '(?P<%s>%s' % (directive, regex)
- return '%s)' % regex
+ return '(?P<%s>%s)' % (directive, regex)
or to use f-string to then get
+ return f'(?P<{directive}>{regex})'
|
|||
| msg312022 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2018-02-11 23:37 | |
For me, on Windows, the tests for time, datetime, and _strptime have failures on the master branch, so I don't want to submit a PR just now. |
|||
| msg312024 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-02-11 23:49 | |
I don't know such reason. I would not combine f-strings and regular expressions. Curly braces are syntactically meaningful in regular expressions, and regular expression which uses them for substituting look strange. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:57 | admin | set | github: 76982 |
| 2018-02-11 23:49:45 | serhiy.storchaka | set | messages: + msg312024 |
| 2018-02-11 23:37:02 | terry.reedy | set | messages: + msg312022 |
| 2018-02-11 23:09:45 | terry.reedy | set | messages: + msg312016 |
| 2018-02-10 22:37:50 | terry.reedy | set | messages: + msg311965 |
| 2018-02-10 07:08:53 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg311941 |
| 2018-02-10 04:10:03 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg311935 type: performance |
| 2018-02-08 16:09:49 | dilyan.palauzov | create | |
