ObjectPath icon indicating copy to clipboard operation
ObjectPath copied to clipboard

fix map and filter check on python 2 and 3.

Open truebit opened this issue 6 years ago • 3 comments

NameError for map and fitler would only occur in python 1. Python 2 and 3 both got these two keywords.

And type(map(string.lower, 'ABC')) is map is not true in Python 2, but true in Python 3. So I got a version check to add map and filter.

truebit avatar Oct 21 '19 05:10 truebit

Coverage Status

Coverage increased (+0.1%) to 89.214% when pulling 4f13d3fba79d46cfdac5974a6eed71712a4a7ac5 on truebit:master into f240821fa197ef5cd04f189c776ae356813abb2b on adriank:master.

coveralls avatar Oct 21 '19 05:10 coveralls

Thanks for the PR.

What problem does it solve? From what I remember, try..catch was a little bit faster and made the code work on Python 2 and 3, while other solutions didn't. I wonder if after change this would still work on PyPy or Python 3.3 for example.

adriank avatar Oct 21 '19 21:10 adriank

This PR fixes #91 tests failure on python 2.

As I mentioned, map and filter cannot be differed by try...catch, as they both exist in python 2 and 3. sys.version_info was introduced in python2.0. I changed access of named tuple attributes to list index to make it working in >=python2.0

truebit avatar Oct 22 '19 07:10 truebit