-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Thanks to Andy Seit.)
- Loading branch information
Showing
1 changed file
with
5 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e68e73e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should replace 'basestring' with 'str' on line 364 too, for python 3 compatibility
e68e73e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gobuk It can break python 2.x for str (not unicode) because:
e68e73e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm no expert in Python 3 compatibility, but I'm quite sure there are more things that needs to be updated. A critical review I think is warranted.
e68e73e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about adding 'basestring = str' after 'from io import BytesIO' on line 33
e68e73e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to keep a single codebase for both Python 2 and Python 3, which imho is a quite sensible option if you don't need python <2.6, then you have two options
If you want to go with the second approach, you could use unio
e68e73e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I think using a compatibility library would be the best approach.
A while back I suggested using six, and volunteered to refactor that. But the core team thought six was too heavy weight. Perhaps unio which is focused on just the unicode piece wouldn't add too much.
I think the try/catch at import time is a bad approach. It creates unintended side effect with other libraries that does low level string processing such as PIL.
e68e73e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also keep in mind, that try/except approach is already also used in other parts of the python bindings code base. Such as, https://github.com/SeleniumHQ/selenium/blob/master/py/selenium/webdriver/remote/webelement.py#L20
so any refactoring to do this probably has to be done all at once. Because they'll all have side effects on one another.
e68e73e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AutomatedTester, any opinions on this?
e68e73e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukeis ?
e68e73e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we don't include third party dependencies, but we may in the near future. I don't have much skin in the game. Are there any potential conflict with any other library? If we can't definitively say, then we should probably make our own string utility to use.
e68e73e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue was also filed about this, which I've now resolved: https://code.google.com/p/selenium/issues/detail?id=7381
e68e73e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukeis
I am not sure what you mean. If you use something like this
and someone uses a star import (i.e.
from selenium.webdriver.firefox.firefox_profile import *
) then yes he may have side effects.That's the reason six and similar compatibility modules usually take this approach