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
81f68a7d
Commit
81f68a7d
authored
Nov 19, 2014
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #22453: Warn against the use of leaking macro PyObject_REPR().
parent
60fe5696
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
Include/object.h
Include/object.h
+6
-2
Python/compile.c
Python/compile.c
+10
-10
No files found.
Include/object.h
View file @
81f68a7d
...
@@ -572,8 +572,12 @@ PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *);
...
@@ -572,8 +572,12 @@ PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *);
PyAPI_FUNC
(
int
)
Py_ReprEnter
(
PyObject
*
);
PyAPI_FUNC
(
int
)
Py_ReprEnter
(
PyObject
*
);
PyAPI_FUNC
(
void
)
Py_ReprLeave
(
PyObject
*
);
PyAPI_FUNC
(
void
)
Py_ReprLeave
(
PyObject
*
);
/* Helper for passing objects to printf and the like */
#ifndef Py_LIMITED_API
#define PyObject_REPR(obj) _PyUnicode_AsString(PyObject_Repr(obj))
/* Helper for passing objects to printf and the like.
Leaks refcounts. Don't use it!
*/
#define PyObject_REPR(obj) PyUnicode_AsUTF8(PyObject_Repr(obj))
#endif
/* Flag bits for printing: */
/* Flag bits for printing: */
#define Py_PRINT_RAW 1
/* No string quotes etc. */
#define Py_PRINT_RAW 1
/* No string quotes etc. */
...
...
Python/compile.c
View file @
81f68a7d
...
@@ -1412,12 +1412,12 @@ get_ref_type(struct compiler *c, PyObject *name)
...
@@ -1412,12 +1412,12 @@ get_ref_type(struct compiler *c, PyObject *name)
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
"unknown scope for %.100s in %.100s(%s)
\n
"
"unknown scope for %.100s in %.100s(%s)
\n
"
"symbols: %s
\n
locals: %s
\n
globals: %s"
,
"symbols: %s
\n
locals: %s
\n
globals: %s"
,
Py
Bytes_AS_STRING
(
name
),
Py
Unicode_AsUTF8
(
name
),
Py
Bytes_AS_STRING
(
c
->
u
->
u_name
),
Py
Unicode_AsUTF8
(
c
->
u
->
u_name
),
Py
Object_REPR
(
c
->
u
->
u_ste
->
ste_id
),
Py
Unicode_AsUTF8
(
PyObject_Repr
(
c
->
u
->
u_ste
->
ste_id
)
),
Py
Object_REPR
(
c
->
u
->
u_ste
->
ste_symbols
),
Py
Unicode_AsUTF8
(
PyObject_Repr
(
c
->
u
->
u_ste
->
ste_symbols
)
),
Py
Object_REPR
(
c
->
u
->
u_varnames
),
Py
Unicode_AsUTF8
(
PyObject_Repr
(
c
->
u
->
u_varnames
)
),
Py
Object_REPR
(
c
->
u
->
u_names
)
Py
Unicode_AsUTF8
(
PyObject_Repr
(
c
->
u
->
u_names
)
)
);
);
Py_FatalError
(
buf
);
Py_FatalError
(
buf
);
}
}
...
@@ -1474,11 +1474,11 @@ compiler_make_closure(struct compiler *c, PyCodeObject *co, Py_ssize_t args, PyO
...
@@ -1474,11 +1474,11 @@ compiler_make_closure(struct compiler *c, PyCodeObject *co, Py_ssize_t args, PyO
fprintf
(
stderr
,
fprintf
(
stderr
,
"lookup %s in %s %d %d
\n
"
"lookup %s in %s %d %d
\n
"
"freevars of %s: %s
\n
"
,
"freevars of %s: %s
\n
"
,
Py
Object_REPR
(
name
),
Py
Unicode_AsUTF8
(
PyObject_Repr
(
name
)
),
Py
Bytes_AS_STRING
(
c
->
u
->
u_name
),
Py
Unicode_AsUTF8
(
c
->
u
->
u_name
),
reftype
,
arg
,
reftype
,
arg
,
_PyUnicode_AsString
(
co
->
co_name
),
PyUnicode_AsUTF8
(
co
->
co_name
),
Py
Object_REPR
(
co
->
co_freevars
));
Py
Unicode_AsUTF8
(
PyObject_Repr
(
co
->
co_freevars
)
));
Py_FatalError
(
"compiler_make_closure()"
);
Py_FatalError
(
"compiler_make_closure()"
);
}
}
ADDOP_I
(
c
,
LOAD_CLOSURE
,
arg
);
ADDOP_I
(
c
,
LOAD_CLOSURE
,
arg
);
...
...
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