Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ff350504
Commit
ff350504
authored
Jul 15, 2011
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Issue #11603: Fix a crash when __str__ is rebound as __repr__.
Patch by Andreas Stührk.
parents
8391cf4e
8cdc40e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
1 deletion
+12
-1
Lib/test/test_descr.py
Lib/test/test_descr.py
+8
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/typeobject.c
Objects/typeobject.c
+1
-1
No files found.
Lib/test/test_descr.py
View file @
ff350504
...
...
@@ -4252,6 +4252,14 @@ order (MRO) for bases """
with
self
.
assertRaises
(
TypeError
):
str
.
__add__
(
fake_str
,
"abc"
)
def
test_repr_as_str
(
self
):
# Issue #11603: crash or infinite loop when rebinding __str__ as
# __repr__.
class
Foo
:
pass
Foo
.
__repr__
=
Foo
.
__str__
foo
=
Foo
()
str
(
foo
)
class
DictProxyTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
Misc/NEWS
View file @
ff350504
...
...
@@ -27,6 +27,9 @@ Core and Builtins
Library
-------
- Issue #11603: Fix a crash when __str__ is rebound as __repr__. Patch by
Andreas Stührk.
- Issue #11321: Fix a crash with multiple imports of the _pickle module when
embedding Python. Patch by Andreas Stührk.
...
...
Objects/typeobject.c
View file @
ff350504
...
...
@@ -2890,7 +2890,7 @@ object_str(PyObject *self)
unaryfunc
f
;
f
=
Py_TYPE
(
self
)
->
tp_repr
;
if
(
f
==
NULL
)
if
(
f
==
NULL
||
f
==
object_str
)
f
=
object_repr
;
return
f
(
self
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment