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
2cabc562
Commit
2cabc562
authored
Aug 28, 2008
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#3706: fix error message for wrong exec() argument type. R=Guido.
parent
9edd2bd3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
Python/bltinmodule.c
Python/bltinmodule.c
+9
-13
No files found.
Python/bltinmodule.c
View file @
2cabc562
...
...
@@ -495,7 +495,7 @@ Return negative if x<y, zero if x==y, positive if x>y.");
static
char
*
source_as_string
(
PyObject
*
cmd
)
source_as_string
(
PyObject
*
cmd
,
char
*
funcname
,
char
*
what
)
{
char
*
str
;
Py_ssize_t
size
;
...
...
@@ -506,8 +506,9 @@ source_as_string(PyObject *cmd)
return
NULL
;
}
else
if
(
!
PyObject_CheckReadBuffer
(
cmd
))
{
PyErr_SetString
(
PyExc_TypeError
,
"eval()/exec() arg 1 must be a string, bytes or code object"
);
PyErr_Format
(
PyExc_TypeError
,
"%s() arg 1 must be a %s object"
,
funcname
,
what
);
return
NULL
;
}
if
(
PyObject_AsReadBuffer
(
cmd
,
(
const
void
**
)
&
str
,
&
size
)
<
0
)
{
...
...
@@ -591,7 +592,7 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds)
return
result
;
}
str
=
source_as_string
(
cmd
);
str
=
source_as_string
(
cmd
,
"compile"
,
"string, bytes, AST or code"
);
if
(
str
==
NULL
)
return
NULL
;
...
...
@@ -703,7 +704,7 @@ builtin_eval(PyObject *self, PyObject *args)
return
PyEval_EvalCode
((
PyCodeObject
*
)
cmd
,
globals
,
locals
);
}
str
=
source_as_string
(
cmd
);
str
=
source_as_string
(
cmd
,
"eval"
,
"string, bytes or code"
);
if
(
str
==
NULL
)
return
NULL
;
...
...
@@ -751,13 +752,7 @@ builtin_exec(PyObject *self, PyObject *args)
}
else
if
(
locals
==
Py_None
)
locals
=
globals
;
if
(
!
PyUnicode_Check
(
prog
)
&&
!
PyCode_Check
(
prog
))
{
PyErr_Format
(
PyExc_TypeError
,
"exec() arg 1 must be a string, file, or code "
"object, not %.100s"
,
prog
->
ob_type
->
tp_name
);
return
NULL
;
}
if
(
!
PyDict_Check
(
globals
))
{
PyErr_Format
(
PyExc_TypeError
,
"exec() arg 2 must be a dict, not %.100s"
,
globals
->
ob_type
->
tp_name
);
...
...
@@ -785,7 +780,8 @@ builtin_exec(PyObject *self, PyObject *args)
v
=
PyEval_EvalCode
((
PyCodeObject
*
)
prog
,
globals
,
locals
);
}
else
{
char
*
str
=
source_as_string
(
prog
);
char
*
str
=
source_as_string
(
prog
,
"exec"
,
"string, bytes or code"
);
PyCompilerFlags
cf
;
if
(
str
==
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