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
1643d5cb
Commit
1643d5cb
authored
Sep 28, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
give exception a nice message (closes #22379)
Patch by Yongzhi Pan.
parent
9ad23c6c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
22 deletions
+20
-22
Lib/test/string_tests.py
Lib/test/string_tests.py
+6
-7
Lib/test/test_string.py
Lib/test/test_string.py
+4
-7
Lib/test/test_userstring.py
Lib/test/test_userstring.py
+5
-7
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/stringobject.c
Objects/stringobject.c
+1
-1
No files found.
Lib/test/string_tests.py
View file @
1643d5cb
...
@@ -65,14 +65,12 @@ class CommonTest(unittest.TestCase):
...
@@ -65,14 +65,12 @@ class CommonTest(unittest.TestCase):
self
.
assertTrue
(
object
is
not
realresult
)
self
.
assertTrue
(
object
is
not
realresult
)
# check that object.method(*args) raises exc
# check that object.method(*args) raises exc
def
checkraises
(
self
,
exc
,
obj
ect
,
methodname
,
*
args
):
def
checkraises
(
self
,
exc
,
obj
,
methodname
,
*
args
):
obj
ect
=
self
.
fixtype
(
object
)
obj
=
self
.
fixtype
(
obj
)
args
=
self
.
fixtype
(
args
)
args
=
self
.
fixtype
(
args
)
self
.
assertRaises
(
with
self
.
assertRaises
(
exc
)
as
cm
:
exc
,
getattr
(
obj
,
methodname
)(
*
args
)
getattr
(
object
,
methodname
),
self
.
assertNotEqual
(
cm
.
exception
.
message
,
''
)
*
args
)
# call object.method(*args) without any checks
# call object.method(*args) without any checks
def
checkcall
(
self
,
object
,
methodname
,
*
args
):
def
checkcall
(
self
,
object
,
methodname
,
*
args
):
...
@@ -1057,6 +1055,7 @@ class MixinStrUnicodeUserStringTest:
...
@@ -1057,6 +1055,7 @@ class MixinStrUnicodeUserStringTest:
self
.
checkequal
(
'a b c'
,
' '
,
'join'
,
BadSeq2
())
self
.
checkequal
(
'a b c'
,
' '
,
'join'
,
BadSeq2
())
self
.
checkraises
(
TypeError
,
' '
,
'join'
)
self
.
checkraises
(
TypeError
,
' '
,
'join'
)
self
.
checkraises
(
TypeError
,
' '
,
'join'
,
None
)
self
.
checkraises
(
TypeError
,
' '
,
'join'
,
7
)
self
.
checkraises
(
TypeError
,
' '
,
'join'
,
7
)
self
.
checkraises
(
TypeError
,
' '
,
'join'
,
Sequence
([
7
,
'hello'
,
123L
]))
self
.
checkraises
(
TypeError
,
' '
,
'join'
,
Sequence
([
7
,
'hello'
,
123L
]))
try
:
try
:
...
...
Lib/test/test_string.py
View file @
1643d5cb
...
@@ -16,13 +16,10 @@ class StringTest(
...
@@ -16,13 +16,10 @@ class StringTest(
realresult
realresult
)
)
def
checkraises
(
self
,
exc
,
object
,
methodname
,
*
args
):
def
checkraises
(
self
,
exc
,
obj
,
methodname
,
*
args
):
self
.
assertRaises
(
with
self
.
assertRaises
(
exc
)
as
cm
:
exc
,
getattr
(
string
,
methodname
)(
obj
,
*
args
)
getattr
(
string
,
methodname
),
self
.
assertNotEqual
(
cm
.
exception
.
message
,
''
)
object
,
*
args
)
def
checkcall
(
self
,
object
,
methodname
,
*
args
):
def
checkcall
(
self
,
object
,
methodname
,
*
args
):
getattr
(
string
,
methodname
)(
object
,
*
args
)
getattr
(
string
,
methodname
)(
object
,
*
args
)
...
...
Lib/test/test_userstring.py
View file @
1643d5cb
...
@@ -28,14 +28,12 @@ class UserStringTest(
...
@@ -28,14 +28,12 @@ class UserStringTest(
realresult
realresult
)
)
def
checkraises
(
self
,
exc
,
obj
ect
,
methodname
,
*
args
):
def
checkraises
(
self
,
exc
,
obj
,
methodname
,
*
args
):
obj
ect
=
self
.
fixtype
(
object
)
obj
=
self
.
fixtype
(
obj
)
# we don't fix the arguments, because UserString can't cope with it
# we don't fix the arguments, because UserString can't cope with it
self
.
assertRaises
(
with
self
.
assertRaises
(
exc
)
as
cm
:
exc
,
getattr
(
obj
,
methodname
)(
*
args
)
getattr
(
object
,
methodname
),
self
.
assertNotEqual
(
cm
.
exception
.
message
,
''
)
*
args
)
def
checkcall
(
self
,
object
,
methodname
,
*
args
):
def
checkcall
(
self
,
object
,
methodname
,
*
args
):
object
=
self
.
fixtype
(
object
)
object
=
self
.
fixtype
(
object
)
...
...
Misc/ACKS
View file @
1643d5cb
...
@@ -1007,6 +1007,7 @@ Mike Pall
...
@@ -1007,6 +1007,7 @@ Mike Pall
Todd R. Palmer
Todd R. Palmer
Juan David Ibáñez Palomar
Juan David Ibáñez Palomar
Jan Palus
Jan Palus
Yongzhi Pan
Mathias Panzenböck
Mathias Panzenböck
M. Papillon
M. Papillon
Peter Parente
Peter Parente
...
...
Misc/NEWS
View file @
1643d5cb
...
@@ -10,6 +10,9 @@ What's New in Python 2.7.9?
...
@@ -10,6 +10,9 @@ What's New in Python 2.7.9?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #22379: Fix empty exception message in a TypeError raised in
``str.join``.
- Issue #22221: Now the source encoding declaration on the second line isn'
t
- Issue #22221: Now the source encoding declaration on the second line isn'
t
effective
if
the
first
line
contains
anything
except
a
comment
.
effective
if
the
first
line
contains
anything
except
a
comment
.
...
...
Objects/stringobject.c
View file @
1643d5cb
...
@@ -1594,7 +1594,7 @@ string_join(PyStringObject *self, PyObject *orig)
...
@@ -1594,7 +1594,7 @@ string_join(PyStringObject *self, PyObject *orig)
Py_ssize_t
i
;
Py_ssize_t
i
;
PyObject
*
seq
,
*
item
;
PyObject
*
seq
,
*
item
;
seq
=
PySequence_Fast
(
orig
,
""
);
seq
=
PySequence_Fast
(
orig
,
"
can only join an iterable
"
);
if
(
seq
==
NULL
)
{
if
(
seq
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
...
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