Repository navigation
[GR-80787] GitHub PRs #1227-1232 - #1242
Merged
Merged
Conversation
complexFromComplexObject, the specialization taken when imag is neither a complex nor a string, called imag's __float__ before it looked at real, so an exception from that conversion replaced the first-argument TypeError and complex(Real(), Imag()) converted imag first. CPython's complex_new_impl checks the type of real, then of imag, and only then converts real followed by imag. The specialization now does the same; the (Object, long/double/PInt) specializations already check real first. Signed-off-by: Jeongseop Lim <jeongseop_lim@korea.ac.kr>
compile() resolved mode with getParserInputType only inside the string compile path, after sourceAsString had converted the source and checkSource had looked for null bytes, and checked that func_type comes with PyCF_ONLY_AST later still. So compile(None, 'f', 'x') raised TypeError, a source with a null byte or bytes that fail to decode raised SyntaxError, and an AST source with mode 'func_type' but no PyCF_ONLY_AST reached obj2sst and hit ShouldNotReachHere. CPython reports all of these as ValueError. CPython's builtin_compile_impl validates mode, including the func_type flag requirement, right after the flags and optimize checks and before it touches the source. getParserInputType now does the func_type check, generic resolves the input type at that point and reuses it for the AST path, and compile() resolves it before checkSource. Signed-off-by: Jeongseop Lim <jeongseop_lim@korea.ac.kr>
The __reversed__ methods of dict, dict_keys, dict_items and dict_values wrapped the reverse storage iterator with the forward factories, so reversed(d) was a dict_keyiterator and type(reversed(d)) is type(iter(d)) held. The PDictReverse*Iterator types were still defined and registered with IteratorBuiltins, but nothing created them since afc1f12 dropped the reverse factories. Restore createDictReverse{Key,Item,Value}Iterator in their former shape and use them at the four sites, as CPython builds these iterators from the PyDictRevIter*_Type types. Signed-off-by: Jeongseop Lim <jeongseop_lim@korea.ac.kr>
BytesCommonBuiltins.DecodeNode, which backs bytes.decode,
bytearray.decode and str(obj, encoding), always went through the
codec, so b''.decode('bogus') and str(b'', 'bogus') raised
LookupError.
CPython's bytes and bytearray decode call PyUnicode_FromEncodedObject,
which returns '' for empty input without looking up the codec outside
dev mode. GraalPy's own PyUnicodeFromEncodedObject already does this
for the C API; DecodeNode now has the same shortcut.
Signed-off-by: Jeongseop Lim <jeongseop_lim@korea.ac.kr>
checkFlags called PRaiseNode.raiseStatic(this, ValueError, null,
NO_VALUE, UNRECOGNIZED_FLAGS, EMPTY_OBJECT_ARRAY), mirroring the
argument order of the old internal execute(). No public overload takes
those arguments, so the call bound to raiseStatic(Node, type, message,
Object...) with a null message and the intended message as a format
argument. The ValueError could be caught, but str(), repr() or .args on
it formatted the null message and threw a Java NullPointerException.
Use the message overload, as checkOptimize next to it does. CPython
raises ValueError("compile(): unrecognised flags").
Signed-off-by: Jeongseop Lim <jeongseop_lim@korea.ac.kr>
…7-GitHub_PRs_1227-1232
…7-GitHub_PRs_1227-1232
…7-GitHub_PRs_1227-1232
…7-GitHub_PRs_1227-1232
…7-GitHub_PRs_1227-1232
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.