8000 bpo-28598: Support __rmod__ for RHS subclasses of str in % string formatting operations by mjpieters · Pull Request #51 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-28598: Support __rmod__ for RHS subclasses of str in % string formatting operations #51

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

Merged
merged 3 commits into from
Feb 23, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review comments; reduce negations and credit patch
  • Loading branch information
Martijn Pieters committed Feb 12, 2017
commit 7b19b0265145eb3d7017569a2522cbd14a9f6072
3 changes: 2 additions & 1 deletion Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ What's New in Python 3.7.0 alpha 1?
Core and Builtins
-----------------

- Issue #28598: Support __rmod__ for subclasses of str being called before str.__mod__.
- Issue #28598: Support __rmod__ for subclasses of str being called before
str.__mod__. Patch by Martijn Pieters.

- bpo-29438: Fixed use-after-free problem in key sharing dict.

Expand Down
4 changes: 2 additions & 2 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1356,8 +1356,8 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
PyObject *divisor = POP();
PyObject *dividend = TOP();
PyObject *res;
if (PyUnicode_CheckExact(dividend) && !(
PyUnicode_Check(divisor) && !PyUnicode_CheckExact(divisor))) {
if (PyUnicode_CheckExact(dividend) && (
!PyUnicode_Check(divisor) || PyUnicode_CheckExact(divisor))) {
// fast path; string formatting, but not if the RHS is a str subclass
// (see issue28598)
res = PyUnicode_Format(dividend, divisor);
Expand Down
0