python x.7 code will break py3.7
See original GitHub issuehttps://github.com/srsudar/eg/blob/f2968471010fccf9e066d3064903eb49675ff766/eg/color.py#L90
One of the color functions only checks if python version is < x.7. However python3.7 is now the default py version so this might start breaking systems with newer python executables.
def _color_helper(s, text, pattern, repl):
# < 2.7 didn't have the flags named argument.
if sys.version_info[1] < 7:
compiled_pattern = re.compile(pattern, re.MULTILINE)
return re.sub(
compiled_pattern,
repl,
text
)
else:
return re.sub(
pattern,
repl,
text,
flags=re.MULTILINE
)
So couldn’t we do if sys.version_info < (2,7):
And be more explicit?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Python 3 - break statement - Tutorialspoint
The break statement is used for premature termination of the current loop. After abandoning the loop, execution at the next statement is resumed, ......
Read more >“How To Use Break, Continue, and Pass Statements when ...
In Python, the break statement provides you with the opportunity to exit out of a loop when an external condition is triggered. You'll...
Read more >Python break and continue (With Examples) - Programiz
The break statement is used to terminate the loop immediately when it is encountered. The syntax of the break statement is: break. Working...
Read more >4. More Control Flow Tools — Python 3.11.1 documentation
The break statement, like in C, breaks out of the innermost enclosing for or while loop. Loop statements may have an else clause;...
Read more >Pass, Break and Continue in Python 3 | by Josh Robin - Medium
One way to do this is by looping through each character in the string until the first space, and then using break to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
#76 employs your suggested fix. I didn’t realize you could compare tuples like that. I’m surprised there haven’t been any complaints given that 3.7 was apparently released over a month ago. If anyone chimes in that this is affecting them I will release immediately, otherwise I’ll release around the 5th of next month on my regular schedule.
This also tipped me off that switching to
py.test
means the tests don’t run on <2.7.Yup!
dir(sys.version_info)
Returns _lt_ and __gt__so you get intuitive comparisons like that. Gotta love the way the standard library implements operator overloading