-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[py2py3] Fix pre-python2.6 idiom: use "isinstance()" instead of "type() == " #10172
Conversation
This comment has been minimized.
This comment has been minimized.
9ce6868
to
1e01272
Compare
This comment has been minimized.
This comment has been minimized.
1e01272
to
af2f060
Compare
This comment has been minimized.
This comment has been minimized.
af2f060
to
6d2d2c3
Compare
This comment has been minimized.
This comment has been minimized.
6d2d2c3
to
979f610
Compare
Jenkins results:
|
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.
Dario, this PR looks pretty good to me. I have requested only one change, and I have a couple of concerns along the code as well.
Jenkins results:
|
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.
Dario, thanks for the follow up.
It's isn't clear to me whether further changes should be made here. Please let me know if you consider it ready to go or if you want to make further changes to the ConfigSectionTree module. Thanks
I know I have not been too clear in answering to your comment. In any case: I can create a new issue about "ConfigSectionTree" and we move this discussion there, so that it is not lost. The rest of the changes here look good to me and I suggest to merge this PR if the rest looks good to you. [EDIT]: created #10218, moving this discussion over there Problem in ConfigSectionTreeBefore #10103 we had def formatNative(value):
if isinstance(value, int):
return value
if isinstance(value, float):
return value
if isinstance(value, list):
return value
if isinstance(value, dict):
return value # this was actually "return dict", but it is outside of our scope now
else:
return format(value)
def format(value):
if isinstance(value, str):
value = "\'%s\'" % value
return str(value) Since we run this code in py2 only, only py2- In #10103 we introduced ImplicationsIs this change a real problem? I am not sure. WMCore/src/python/WMCore/WMSpec/WMTask.py Line 631 in 08c1eea
Which is then used in How to proceedWe have a couple of options and I am not sure which is the best, since it is a bit hard for me to graps how the "pythonisedDict" is used in the Generators. 1. Leave it as is (surround unicode and return unicode)and investigate in testbed the impact of this problem. (This may not be the best option) 2. Surround both unicode and bytes, return unicodeWe could change - from builtins import str, object
+ from builtins import str, bytes, object
def format(value):
- if isinstance(value, str):
+ if isinstance(value, (str, bytes)):
value = "\'%s\'" % value
+ return str(value) (This is a nice option) 3. Make
|
Jenkins results:
|
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.
Thanks Dario. We better discuss that possible issue in the new issue you created. You further commits look good to me, can you please squash them in the first one? Thanks
19fb3f1
to
5f9d91e
Compare
Jenkins results:
|
Fixes #10171
Status
Ready
Related PR
This PR is independent form other PRs
Description
Run
futurize -f idioms
onsrc/python
.Manual changes
type([])
changed tolist
type(1)
changed toint
type.ListType
changed tolist
Changes involving
type(dict)
, which can cause problems (despite no problem has been caught by jenkins CI)src/python/WMCore/WMSpec/Steps/BuildTools.py
src/python/WMCore/WMSpec/ConfigSectionTree.py
What has been kept back and not included in this PR
JSONThunker
had some problems in the past with this fixers. Moreover, JSONThunker - strange dictionary key type comparison #9852 is still open.WMException
: this change caused a dramatic change in behavior that is being addressed in separate PRs, such as [py2py3] Fix potential bug in WMException #10174, [py2py3] Fix potential bug in WMException - again #10187, [py2py3] Fix potential bug in WMException - No modernization of WMException #10189Is it backward compatible (if not, which system it affects?)
Yes, it should be. any possibly breaking changes will be reported here.
External dependencies / deployment changes
This does not rely on third party libraries