Skip to content

Commit 24c8dea

Browse files
committed
Better handling of Python versions
1 parent ef2918a commit 24c8dea

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

seleniumbase/common/unobfuscate.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
"""
1010

1111
from seleniumbase.common import encryption
12+
import sys
1213
import time
1314

1415

1516
def main():
16-
try:
17+
if sys.version_info[0] >= 3:
18+
input_method = input # Using Python 3 (or higher)
19+
else:
1720
# Python 2 has the raw_input() method. Python 3 does not.
1821
input_method = raw_input # noqa: ignore=F821
19-
except Exception:
20-
input_method = input # Using Python 3
2122
try:
2223
while(1):
2324
code = input_method(

seleniumbase/core/log_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def log_test_failure_data(test, test_logpath, driver, browser):
3333
data_to_save = []
3434
data_to_save.append("Last_Page: %s" % last_page)
3535
data_to_save.append("Browser: %s " % browser)
36-
if sys.version.startswith('3') and hasattr(test, '_outcome'):
36+
if sys.version_info[0] >= 3 and hasattr(test, '_outcome'):
3737
if test._outcome.errors:
3838
try:
3939
exc_message = test._outcome.errors[0][1][1]

seleniumbase/fixtures/base_case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3377,7 +3377,7 @@ def tearDown(self):
33773377
super(SubClassOfBaseCase, self).tearDown()
33783378
"""
33793379
has_exception = False
3380-
if sys.version.startswith('3') and hasattr(self, '_outcome'):
3380+
if sys.version_info[0] >= 3 and hasattr(self, '_outcome'):
33813381
if hasattr(self._outcome, 'errors') and self._outcome.errors:
33823382
has_exception = True
33833383
else:

0 commit comments

Comments
 (0)