summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/_add_newdocs.py4
-rw-r--r--numpy/core/include/numpy/npy_3kcompat.h2
-rw-r--r--numpy/lib/format.py3
3 files changed, 6 insertions, 3 deletions
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
index 2706093d2..021895b84 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -1316,7 +1316,9 @@ add_newdoc('numpy.core.multiarray', 'fromstring',
decimal numbers, an operation which is better spelt
``frombuffer(string, dtype, count)``. If `string` contains unicode
text, the binary mode of `fromstring` will first encode it into
- bytes using utf-8 (python 3) which does not produce sane results.
+ bytes using either utf-8 (python 3) or the default encoding
+ (python 2), neither of which produce sane results.
+
${ARRAY_FUNCTION_LIKE}
.. versionadded:: 1.20.0
diff --git a/numpy/core/include/numpy/npy_3kcompat.h b/numpy/core/include/numpy/npy_3kcompat.h
index 1ea897f55..11cc47765 100644
--- a/numpy/core/include/numpy/npy_3kcompat.h
+++ b/numpy/core/include/numpy/npy_3kcompat.h
@@ -1,6 +1,8 @@
/*
* This is a convenience header file providing compatibility utilities
* for supporting different minor versions of Python 3.
+ * It was originally used to support the transition from Python 2,
+ * hence the "3k" naming.
*
* If you want to use this for your own projects, it's recommended to make a
* copy of it. Although the stuff below is unlikely to change, we don't provide
diff --git a/numpy/lib/format.py b/numpy/lib/format.py
index dfd50b393..625768b62 100644
--- a/numpy/lib/format.py
+++ b/numpy/lib/format.py
@@ -370,8 +370,7 @@ def _wrap_header(header, version):
import struct
assert version is not None
fmt, encoding = _header_size_info[version]
- if not isinstance(header, bytes):
- header = header.encode(encoding)
+ header = header.encode(encoding)
hlen = len(header) + 1
padlen = ARRAY_ALIGN - ((MAGIC_LEN + struct.calcsize(fmt) + hlen) % ARRAY_ALIGN)
try: