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
4e8e8aab
Commit
4e8e8aab
authored
Apr 09, 2019
by
Inada Naoki
Committed by
GitHub
Apr 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-30134: fix BytesWarning doc, docstring and message (GH-12739)
parent
87ed1beb
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
7 additions
and
15 deletions
+7
-15
Doc/library/exceptions.rst
Doc/library/exceptions.rst
+1
-1
Doc/library/warnings.rst
Doc/library/warnings.rst
+1
-1
Include/code.h
Include/code.h
+1
-1
Objects/bytearrayobject.c
Objects/bytearrayobject.c
+1
-9
Objects/exceptions.c
Objects/exceptions.c
+2
-2
Python/pythonrun.c
Python/pythonrun.c
+1
-1
No files found.
Doc/library/exceptions.rst
View file @
4e8e8aab
...
...
@@ -526,7 +526,7 @@ module for more information.
.. exception:: BytesWarning
Base class for warnings related to
:class:`str` and :class:`bytearray`
.
Base class for warnings related to
bytes and bytearray
.
.. versionadded:: 2.6
...
...
Doc/library/warnings.rst
View file @
4e8e8aab
...
...
@@ -92,7 +92,7 @@ following warnings category classes are currently defined:
| | Unicode. |
+----------------------------------+-----------------------------------------------+
| :exc:`BytesWarning` | Base category for warnings related to |
| |
str and bytearray.
|
| |
bytes and bytearray.
|
+----------------------------------+-----------------------------------------------+
While these are technically built-in exceptions, they are documented here,
...
...
Include/code.h
View file @
4e8e8aab
...
...
@@ -104,7 +104,7 @@ PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co,
*
* Return (type(obj), obj, ...): a tuple with variable size (at least 2 items)
* depending on the type and the value. The type is the first item to not
* compare bytes and
str
which can raise a BytesWarning exception. */
* compare bytes and
unicode
which can raise a BytesWarning exception. */
PyAPI_FUNC
(
PyObject
*
)
_PyCode_ConstantKey
(
PyObject
*
obj
);
PyAPI_FUNC
(
PyObject
*
)
PyCode_Optimize
(
PyObject
*
code
,
PyObject
*
consts
,
...
...
Objects/bytearrayobject.c
View file @
4e8e8aab
...
...
@@ -1027,14 +1027,6 @@ bytearray_repr(PyByteArrayObject *self)
static
PyObject
*
bytearray_str
(
PyObject
*
op
)
{
#if 0
if (Py_BytesWarningFlag) {
if (PyErr_WarnEx(PyExc_BytesWarning,
"str() on a bytearray instance", 1))
return NULL;
}
return bytearray_repr((PyByteArrayObject*)op);
#endif
return
PyBytes_FromStringAndSize
(((
PyByteArrayObject
*
)
op
)
->
ob_bytes
,
Py_SIZE
(
op
));
}
...
...
@@ -1059,7 +1051,7 @@ bytearray_richcompare(PyObject *self, PyObject *other, int op)
if
(
rc
)
{
if
(
Py_BytesWarningFlag
&&
op
==
Py_EQ
)
{
if
(
PyErr_WarnEx
(
PyExc_BytesWarning
,
"Comparison between bytearray and
string
"
,
1
))
"Comparison between bytearray and
unicode
"
,
1
))
return
NULL
;
}
...
...
Objects/exceptions.c
View file @
4e8e8aab
...
...
@@ -2014,8 +2014,8 @@ SimpleExtendsException(PyExc_Warning, UnicodeWarning,
* BytesWarning extends Warning
*/
SimpleExtendsException
(
PyExc_Warning
,
BytesWarning
,
"Base class for warnings about bytes and b
uffer related problems, mostly
\n
"
"
related to conversion from str or
comparing to str."
);
"Base class for warnings about bytes and b
ytearray related problems,
\n
"
"
mostly related to
comparing to str."
);
/* Pre-computed MemoryError instance. Best to create this as early as
* possible and not wait until a MemoryError is actually raised!
...
...
Python/pythonrun.c
View file @
4e8e8aab
...
...
@@ -70,7 +70,7 @@ int Py_VerboseFlag; /* Needed by import.c */
int
Py_InteractiveFlag
;
/* Needed by Py_FdIsInteractive() below */
int
Py_InspectFlag
;
/* Needed to determine whether to exit at SystemExit */
int
Py_NoSiteFlag
;
/* Suppress 'import site' */
int
Py_BytesWarningFlag
;
/* Warn on
str(bytes) and str(buffer)
*/
int
Py_BytesWarningFlag
;
/* Warn on
comparison between bytearray and unicode
*/
int
Py_DontWriteBytecodeFlag
;
/* Suppress writing bytecode files (*.py[co]) */
int
Py_UseClassExceptionsFlag
=
1
;
/* Needed by bltinmodule.c: deprecated */
int
Py_FrozenFlag
;
/* Needed by getpath.c */
...
...
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