-
Notifications
You must be signed in to change notification settings - Fork 306
Eliminate contextless PythonTuple constructor #1946
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -213,7 +213,7 @@ value is string || | |
| object proto = DynamicHelpers.GetPythonTypeFromType(typeof(PythonSQLite.PrepareProtocol)); | ||
| object type = DynamicHelpers.GetPythonType(value); | ||
|
|
||
| object key = new PythonTuple(new[] { type, proto }); | ||
| object key = new PythonTuple(DefaultContext.Default, new[] { type, proto }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess these are not
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's right. This is also the reason why in #1938 I directly included Here, using |
||
|
|
||
| return PythonSQLite.adapters.ContainsKey(key); | ||
| } | ||
|
|
@@ -228,7 +228,7 @@ private object adaptValue(CodeContext context, object value) | |
| object proto = DynamicHelpers.GetPythonTypeFromType(typeof(PythonSQLite.PrepareProtocol)); | ||
| object type = DynamicHelpers.GetPythonType(value); | ||
|
|
||
| object key = new PythonTuple(new[] { type, proto }); | ||
| object key = new PythonTuple(DefaultContext.Default, new[] { type, proto }); | ||
|
|
||
| object adapter; | ||
| if(PythonSQLite.adapters.TryGetValue(key, out adapter)) | ||
|
|
||
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 guess this is technically a breaking change since the constructor was public. Doesn't seem unreasonable that someone could have been calling this from outside the codebase? Maybe we could keep it with the default context (we can add the Obsolete attribute).
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.
It is a breaking change, albeit a straightforward one: all is needed in user code is to add
DefaultContext.Defaultas the first argument to have the same behaviour as before, although I was hoping that by making the parameter explicit it will prompt the user to some deliberation which context to use.I don't think that adding another constructor with the signature of the old one will work — since they will only differ by
CodeContext, the method resolver will not be able to pick one when dynamic code (i.e. Python code) is being run.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 the overload is a conflict then go ahead and break it. 😊
Can't say I fully understand the whole concept of the context.
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.
Just to be sure, I ran a test with the old constructor added back, and sure enough, the resolver fails when trying to instantiate subclasses of
tuple.Perhaps I'll start a wiki page outlining all breaking changes like this one since 3.4.2 and the recommended workarounds, kind of what we have for upgrading from 2.x to 3.x. Hopefully it will be very short. In the release notes of 3.4.3 you could add a link to it.
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.
https://github.com/IronLanguages/ironpython3/wiki/Differences-between-versions