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
58e8761d
Commit
58e8761d
authored
Nov 22, 2011
by
Amaury Forgeot d'Arc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #13436: Fix a bogus error message when an AST object was passed
an invalid integer value.
parent
3b1acf11
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
5 deletions
+15
-5
Lib/test/test_ast.py
Lib/test/test_ast.py
+11
-0
Misc/NEWS
Misc/NEWS
+3
-0
Parser/asdl_c.py
Parser/asdl_c.py
+1
-5
No files found.
Lib/test/test_ast.py
View file @
58e8761d
...
...
@@ -486,6 +486,17 @@ class ASTHelpers_Test(unittest.TestCase):
self
.
assertEqual
(
ast
.
literal_eval
(
'10 + 2j'
),
10
+
2j
)
self
.
assertEqual
(
ast
.
literal_eval
(
'1.5 - 2j'
),
1.5
-
2j
)
def
test_bad_integer
(
self
):
# issue13436: Bad error message with invalid numeric values
body
=
[
ast
.
ImportFrom
(
module
=
'time'
,
names
=
[
ast
.
alias
(
name
=
'sleep'
)],
level
=
None
,
lineno
=
None
,
col_offset
=
None
)]
mod
=
ast
.
Module
(
body
)
with
self
.
assertRaises
(
ValueError
)
as
cm
:
compile
(
mod
,
'test'
,
'exec'
)
self
.
assertIn
(
"invalid integer value: None"
,
str
(
cm
.
exception
))
def
test_main
():
support
.
run_unittest
(
AST_Tests
,
ASTHelpers_Test
)
...
...
Misc/NEWS
View file @
58e8761d
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.2.3?
Core and Builtins
-----------------
- Issue #13436: Fix a bogus error message when an AST object was passed
an invalid integer value.
- Issue #13338: Handle all enumerations in _Py_ANNOTATE_MEMORY_ORDER
to allow compiling extension modules with -Wswitch-enum on gcc.
Initial patch by Floris Bruynooghe.
...
...
Parser/asdl_c.py
View file @
58e8761d
...
...
@@ -816,11 +816,7 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
{
int i;
if (!PyLong_Check(obj)) {
PyObject *s = PyObject_Repr(obj);
if (s == NULL) return 1;
PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s",
PyBytes_AS_STRING(s));
Py_DECREF(s);
PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
return 1;
}
...
...
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